jugant amb clang-tidy

This commit is contained in:
2025-07-19 22:38:01 +02:00
parent 1d3fd79a9e
commit a7ef29b750
28 changed files with 735 additions and 734 deletions

View File

@@ -57,13 +57,13 @@ void Input::bindGameControllerButton(int controller_index, InputAction input_tar
bool Input::checkInput(InputAction input, bool repeat, InputDevice device, int controller_index) {
bool success_keyboard = false;
bool success_controller = false;
const int input_index = static_cast<int>(input);
const int INPUT_INDEX = static_cast<int>(input);
if (device == InputDevice::KEYBOARD || device == InputDevice::ANY) {
if (repeat) { // El usuario quiere saber si está pulsada (estado mantenido)
success_keyboard = key_bindings_[input_index].is_held;
success_keyboard = key_bindings_[INPUT_INDEX].is_held;
} else { // El usuario quiere saber si ACABA de ser pulsada (evento de un solo fotograma)
success_keyboard = key_bindings_[input_index].just_pressed;
success_keyboard = key_bindings_[INPUT_INDEX].just_pressed;
}
}
@@ -73,9 +73,9 @@ bool Input::checkInput(InputAction input, bool repeat, InputDevice device, int c
if (!success_controller) {
if (repeat) { // El usuario quiere saber si está pulsada (estado mantenido)
success_controller = controller_bindings_.at(controller_index).at(input_index).is_held;
success_controller = controller_bindings_.at(controller_index).at(INPUT_INDEX).is_held;
} else { // El usuario quiere saber si ACABA de ser pulsada (evento de un solo fotograma)
success_controller = controller_bindings_.at(controller_index).at(input_index).just_pressed;
success_controller = controller_bindings_.at(controller_index).at(INPUT_INDEX).just_pressed;
}
}
}
@@ -87,11 +87,11 @@ bool Input::checkInput(InputAction input, bool repeat, InputDevice device, int c
// Comprueba si hay almenos un input activo
bool Input::checkAnyInput(InputDevice device, int controller_index) {
// Obtenemos el número total de acciones posibles para iterar sobre ellas.
const int num_actions = static_cast<int>(InputAction::SIZE);
const int NUM_ACTIONS = static_cast<int>(InputAction::SIZE);
// --- Comprobación del Teclado ---
if (device == InputDevice::KEYBOARD || device == InputDevice::ANY) {
for (int i = 0; i < num_actions; ++i) {
for (int i = 0; i < NUM_ACTIONS; ++i) {
// Simplemente leemos el estado pre-calculado por Input::update().
// Ya no se llama a SDL_GetKeyboardState ni se modifica el estado '.active'.
if (key_bindings_.at(i).just_pressed) {
@@ -105,7 +105,7 @@ bool Input::checkAnyInput(InputDevice device, int controller_index) {
if (gameControllerFound() && controller_index >= 0 && controller_index < num_gamepads_) {
if (device == InputDevice::CONTROLLER || device == InputDevice::ANY) {
// Bucle CORREGIDO: Iteramos sobre todas las acciones, no sobre el número de mandos.
for (int i = 0; i < num_actions; ++i) {
for (int i = 0; i < NUM_ACTIONS; ++i) {
// Leemos el estado pre-calculado para el mando y la acción específicos.
if (controller_bindings_.at(controller_index).at(i).just_pressed) {
return true; // Se encontró una acción recién pulsada en el mando.
@@ -277,15 +277,15 @@ std::string Input::inputToString(InputAction input) const {
// Convierte un std::string a InputAction
InputAction Input::stringToInput(const std::string &name) const {
static const std::unordered_map<std::string, InputAction> inputMap = {
static const std::unordered_map<std::string, InputAction> INPUT_MAP = {
{"input_fire_left", InputAction::FIRE_LEFT},
{"input_fire_center", InputAction::FIRE_CENTER},
{"input_fire_right", InputAction::FIRE_RIGHT},
{"input_start", InputAction::START},
{"input_service", InputAction::SERVICE}};
auto it = inputMap.find(name);
return it != inputMap.end() ? it->second : InputAction::NONE;
auto it = INPUT_MAP.find(name);
return it != INPUT_MAP.end() ? it->second : InputAction::NONE;
}
// Comprueba el eje del mando