diff --git a/source/core/config/postfx_config.cpp b/source/core/config/postfx_config.cpp index c83bde7..7f727a7 100644 --- a/source/core/config/postfx_config.cpp +++ b/source/core/config/postfx_config.cpp @@ -40,8 +40,10 @@ void readRgb255(const fkyaml::node& node, const char* key, dst_r = static_cast(R) / 255.0F; dst_g = static_cast(G) / 255.0F; dst_b = static_cast(B) / 255.0F; - } catch (...) { - // Mantiene los defaults si algún elemento no es entero. + } catch (...) { // @INTENTIONAL + // Mantiene los defaults si algún elemento del RGB no es entero parseable + // (el YAML viene de archivo, así que es razonable degradar a los defaults + // en vez de propagar la excepción y abortar el load del postpro entero). } } diff --git a/source/core/graphics/shape.hpp b/source/core/graphics/shape.hpp index aab6f5b..2dcc5ae 100644 --- a/source/core/graphics/shape.hpp +++ b/source/core/graphics/shape.hpp @@ -3,6 +3,7 @@ #pragma once +#include #include #include @@ -11,7 +12,7 @@ namespace Graphics { // Tipo de primitiva dins de una shape -enum class PrimitiveType { +enum class PrimitiveType : std::uint8_t { POLYLINE, // Secuencia de points connectats LINE // Línia individual (2 points) }; diff --git a/source/core/graphics/starfield.cpp b/source/core/graphics/starfield.cpp index 4a79eef..09b0d69 100644 --- a/source/core/graphics/starfield.cpp +++ b/source/core/graphics/starfield.cpp @@ -21,8 +21,7 @@ Starfield::Starfield(Rendering::Renderer* renderer, : shape_estrella_(ShapeLoader::load("star.shp")), renderer_(renderer), punt_fuga_(punt_fuga), - area_(area), - densitat_(densitat) { + area_(area) { if (!shape_estrella_ || !shape_estrella_->isValid()) { std::cerr << "ERROR: No s'ha pogut load star.shp" << '\n'; return; diff --git a/source/core/graphics/starfield.hpp b/source/core/graphics/starfield.hpp index 4814f5d..2a7fab7 100644 --- a/source/core/graphics/starfield.hpp +++ b/source/core/graphics/starfield.hpp @@ -77,7 +77,6 @@ class Starfield { Vec2 punt_fuga_; // Vec2 de origin de las estrelles SDL_FRect area_; // Àrea activa float radi_max_; // Distancia màxima del centro al límit de pantalla - int densitat_; // Nombre total de estrelles float multiplicador_brightness_{1.0F}; // Multiplicador de brightness (1.0 = default) }; diff --git a/source/core/graphics/vector_text.cpp b/source/core/graphics/vector_text.cpp index b9701f6..b494bfa 100644 --- a/source/core/graphics/vector_text.cpp +++ b/source/core/graphics/vector_text.cpp @@ -80,7 +80,9 @@ void VectorText::load_charset() { } auto VectorText::get_shape_filename(char c) const -> std::string { - // Mapeo carácter → nombre de archivo (con prefix "font/") + // Mapeo carácter → nombre de archivo (con prefix "font/"). + // Dígitos 0-9 y mayúsculas A-Z comparten el mismo path: la shape se llama + // como el caracter mismo, así que se agrupan en un único case. switch (c) { case '0': case '1': @@ -92,9 +94,6 @@ auto VectorText::get_shape_filename(char c) const -> std::string { case '7': case '8': case '9': - return std::string("font/char_") + c + ".shp"; - - // Lletres majúscules A-Z case 'A': case 'B': case 'C': diff --git a/source/core/input/input.cpp b/source/core/input/input.cpp index 7ed92f1..886e3b3 100644 --- a/source/core/input/input.cpp +++ b/source/core/input/input.cpp @@ -420,8 +420,11 @@ auto Input::handleEvent(const SDL_Event& event) -> std::string { return addGamepad(event.gdevice.which); case SDL_EVENT_GAMEPAD_REMOVED: return removeGamepad(event.gdevice.which); + default: + // El resto de eventos SDL no interesan a Input (los maneja el resto + // del sistema: ventana, teclado, mouse). + return {}; } - return {}; } auto Input::addGamepad(int device_index) -> std::string { diff --git a/source/core/input/input_types.hpp b/source/core/input/input_types.hpp index c032638..92f7a0f 100644 --- a/source/core/input/input_types.hpp +++ b/source/core/input/input_types.hpp @@ -3,11 +3,12 @@ #include #include +#include #include #include // --- Enums --- -enum class InputAction : int { // Acciones de entrada posibles en el juego +enum class InputAction : std::uint8_t { // Acciones de entrada posibles en el juego // Inputs de juego (movimiento y acción) LEFT, // Rotar izquierda RIGHT, // Rotar derecha diff --git a/source/core/system/game_config.hpp b/source/core/system/game_config.hpp index 42d55d0..9ee3562 100644 --- a/source/core/system/game_config.hpp +++ b/source/core/system/game_config.hpp @@ -5,7 +5,7 @@ namespace GameConfig { // Mode de juego -enum class Mode { +enum class Mode : std::uint8_t { NORMAL, // Partida normal DEMO // Mode demostració (futur) }; diff --git a/source/core/system/scene_context.hpp b/source/core/system/scene_context.hpp index 3705794..bd466e3 100644 --- a/source/core/system/scene_context.hpp +++ b/source/core/system/scene_context.hpp @@ -3,6 +3,8 @@ #pragma once +#include + #include "core/system/game_config.hpp" namespace SceneManager { @@ -12,7 +14,7 @@ namespace SceneManager { class SceneContext { public: // Tipo de escena del juego - enum class SceneType { + enum class SceneType : std::uint8_t { LOGO, // Pantalla de start (logo JAILGAMES) TITLE, // Pantalla de título con menú GAME, // Juego principal (Asteroids) @@ -20,7 +22,7 @@ class SceneContext { }; // Opciones específiques para cada escena - enum class Option { + enum class Option : std::uint8_t { NONE, // Sin opciones especials (comportament per defecte) JUMP_TO_TITLE_MAIN, // TITLE: Saltar directament a MAIN (starfield instantani) // MODE_DEMO, // GAME: Mode demostració con IA (futur) diff --git a/source/game/scenes/game_scene.hpp b/source/game/scenes/game_scene.hpp index 387406a..d5b82c6 100644 --- a/source/game/scenes/game_scene.hpp +++ b/source/game/scenes/game_scene.hpp @@ -61,7 +61,9 @@ class GameScene final : public Scene { // Estat del juego std::array ships_; // [0]=P1, [1]=P2 std::array enemies_; - std::array bullets_; // 6 balas: P1=[0,1,2], P2=[3,4,5] + // 6 balas: P1=[0,1,2], P2=[3,4,5]. El cast a size_t evita la + // widening conversion implícita que detecta clang-tidy. + std::array(Constants::MAX_BALES) * 2> bullets_; std::array hit_timer_per_player_; // Death timers per player (seconds) // Lives and game over system diff --git a/source/game/scenes/logo_scene.hpp b/source/game/scenes/logo_scene.hpp index a779f6b..929911e 100644 --- a/source/game/scenes/logo_scene.hpp +++ b/source/game/scenes/logo_scene.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -32,7 +33,7 @@ class LogoScene final : public Scene { private: // Màquina de estats per l'animación - enum class AnimationState { + enum class AnimationState : std::uint8_t { PRE_ANIMATION, // Pantalla negra inicial ANIMATION, // Animación de zoom de lletres POST_ANIMATION, // Logo complet visible diff --git a/source/game/scenes/title_scene.hpp b/source/game/scenes/title_scene.hpp index b021e72..1d70eb0 100644 --- a/source/game/scenes/title_scene.hpp +++ b/source/game/scenes/title_scene.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -39,7 +40,7 @@ class TitleScene final : public Scene { private: // Màquina de estats per la pantalla de título - enum class TitleState { + enum class TitleState : std::uint8_t { STARFIELD_FADE_IN, // Fade-in del starfield (3.0s) STARFIELD, // Pantalla con camp de estrelles (4.0s) MAIN, // Pantalla de título con text (indefinit, hasta START) diff --git a/source/game/stage_system/spawn_controller.cpp b/source/game/stage_system/spawn_controller.cpp index 187972f..97e03d9 100644 --- a/source/game/stage_system/spawn_controller.cpp +++ b/source/game/stage_system/spawn_controller.cpp @@ -15,9 +15,7 @@ namespace StageSystem { -SpawnController::SpawnController() - - {} +SpawnController::SpawnController() = default; void SpawnController::configure(const StageConfig* config) { config_ = config; diff --git a/source/game/stage_system/stage_config.hpp b/source/game/stage_system/stage_config.hpp index c51f732..a170f61 100644 --- a/source/game/stage_system/stage_config.hpp +++ b/source/game/stage_system/stage_config.hpp @@ -11,7 +11,7 @@ namespace StageSystem { // Tipo de mode de spawn -enum class ModeSpawn { +enum class ModeSpawn : std::uint8_t { PROGRESSIVE, // Spawn progressiu con intervals IMMEDIATE, // Todos los enemigos de cop WAVE // Onades de 3-5 enemigos (futura extensió) diff --git a/source/game/systems/collision_system.hpp b/source/game/systems/collision_system.hpp index 61e8545..a7ef980 100644 --- a/source/game/systems/collision_system.hpp +++ b/source/game/systems/collision_system.hpp @@ -31,7 +31,7 @@ namespace Systems::Collision { struct Context { std::array& ships; std::array& enemies; - std::array& bullets; + std::array(Defaults::Entities::MAX_BALES) * 2>& bullets; std::array& hit_timer_per_player; std::array& score_per_player; std::array& lives_per_player; diff --git a/source/game/title/ship_animator.hpp b/source/game/title/ship_animator.hpp index 898d079..6ebc769 100644 --- a/source/game/title/ship_animator.hpp +++ b/source/game/title/ship_animator.hpp @@ -8,6 +8,7 @@ #include #include +#include #include #include "core/graphics/shape.hpp" @@ -16,7 +17,7 @@ namespace Title { // Estats de l'animación de la ship -enum class ShipState { +enum class ShipState : std::uint8_t { ENTERING, // Entrant desde fuera de pantalla FLOATING, // Flotante en posición estàtica EXITING // Volant hacia el point de fuga