Skip to content

Commit 4bd7b8d

Browse files
committed
clang-tidy:
- fix more errors
1 parent a72503c commit 4bd7b8d

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

src/manager/settings_manager.hpp

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,39 @@ using Controls = std::variant<input::KeyboardSettings, input::JoystickSettings,
1414
namespace nlohmann {
1515
template<>
1616
struct adl_serializer<Controls> {
17-
static Controls from_json(const json& j) {
18-
const auto& type = j.at("type");
17+
static Controls from_json(const json& obj) {
18+
const auto& type = obj.at("type");
1919

2020
if (type == "keyboard") {
21-
return Controls{ nlohmann::adl_serializer<input::KeyboardSettings>::from_json(j) };
22-
} else if (type == "joystick") {
23-
return Controls{ nlohmann::adl_serializer<input::JoystickSettings>::from_json(j) };
24-
} else if (type == "touch") {
25-
return Controls{ nlohmann::adl_serializer<input::TouchSettings>::from_json(j) };
26-
} else {
27-
throw std::runtime_error{ fmt::format("unsupported control type '{}'", to_string(type)) };
21+
return Controls{ nlohmann::adl_serializer<input::KeyboardSettings>::from_json(obj) };
2822
}
23+
24+
if (type == "joystick") {
25+
return Controls{ nlohmann::adl_serializer<input::JoystickSettings>::from_json(obj) };
26+
}
27+
28+
if (type == "touch") {
29+
return Controls{ nlohmann::adl_serializer<input::TouchSettings>::from_json(obj) };
30+
}
31+
32+
throw std::runtime_error{ fmt::format("unsupported control type '{}'", to_string(type)) };
2933
}
3034

31-
static void to_json(json& j, Controls controls) {
35+
static void to_json(json& obj, Controls controls) { // NOLINT(misc-no-recursion)
3236
std::visit(
33-
helper::overloaded{ [&](const input::KeyboardSettings& keyboard_settings) {
34-
to_json(j, keyboard_settings);
35-
j["type"] = "keyboard";
36-
},
37-
[&](const input::JoystickSettings& joystick_settings) {
38-
to_json(j, joystick_settings);
39-
j["type"] = "joystick";
40-
},
41-
[&](const input::TouchSettings& touch_settings) {
42-
to_json(j, touch_settings);
43-
j["type"] = "touch";
44-
} },
37+
helper::overloaded{
38+
[&](const input::KeyboardSettings& keyboard_settings) { // NOLINT(misc-no-recursion)
39+
to_json(obj, keyboard_settings);
40+
obj["type"] = "keyboard";
41+
},
42+
[&](const input::JoystickSettings& joystick_settings) { // NOLINT(misc-no-recursion)
43+
to_json(obj, joystick_settings);
44+
obj["type"] = "joystick";
45+
},
46+
[&](const input::TouchSettings& touch_settings) { // NOLINT(misc-no-recursion)
47+
to_json(obj, touch_settings);
48+
obj["type"] = "touch";
49+
} },
4550
controls
4651
);
4752
}

src/scenes/single_player_game/single_player_game.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ namespace scenes {
104104
m_game->render(service_provider);
105105
}
106106

107-
[[nodiscard]] bool
108-
SinglePlayerGame::handle_event(const std::shared_ptr<input::InputManager>&, const SDL_Event& event) {
107+
[[nodiscard]] bool SinglePlayerGame::handle_event(
108+
const std::shared_ptr<input::InputManager>& /*input_manager*/,
109+
const SDL_Event& event
110+
) {
109111

110112
const auto& game_input = m_game->game_input();
111113

0 commit comments

Comments
 (0)