diff --git a/source/core/audio/jail_audio.hpp b/source/core/audio/jail_audio.hpp index 276841f..a7d9e50 100644 --- a/source/core/audio/jail_audio.hpp +++ b/source/core/audio/jail_audio.hpp @@ -259,7 +259,7 @@ namespace Ja { sdl_audio_device = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &audio_spec); if (sdl_audio_device == 0) { std::cout << "Failed to initialize SDL audio!" << '\n'; } for (auto& ch : channels) { ch.state = ChannelState::FREE; } - std::fill(std::begin(sound_volume), std::end(sound_volume), 0.5F); + std::ranges::fill(sound_volume, 0.5F); } inline void quit() { @@ -663,7 +663,7 @@ namespace Ja { const float V = SDL_clamp(volume, 0.0F, 1.0F); if (group == -1) { - std::fill(std::begin(sound_volume), std::end(sound_volume), V); + std::ranges::fill(sound_volume, V); } else if (group >= 0 && group < MAX_GROUPS) { sound_volume[group] = V; } else { diff --git a/source/core/rendering/background.cpp b/source/core/rendering/background.cpp index 61c66bb..73416ae 100644 --- a/source/core/rendering/background.cpp +++ b/source/core/rendering/background.cpp @@ -1,3 +1,4 @@ +// NOLINTNEXTLINE(bugprone-reserved-identifier) -- requerido por para exponer M_PI en MSVC #define _USE_MATH_DEFINES #include "core/rendering/background.hpp" diff --git a/source/core/rendering/screen.cpp b/source/core/rendering/screen.cpp index 9770478..709ce0e 100644 --- a/source/core/rendering/screen.cpp +++ b/source/core/rendering/screen.cpp @@ -17,16 +17,13 @@ #ifndef NO_SHADERS #include "core/rendering/sdl3gpu/sdl3gpu_shader.hpp" // Para SDL3GPUShader #endif -#include "core/rendering/text.hpp" // Para Text -#include "core/rendering/texture.hpp" // Para Texture -#include "core/resources/asset.hpp" // Para Asset -#include "core/resources/resource.hpp" // Para Resource -#include "core/system/director.hpp" // Para Director::debug_config -#include "game/options.hpp" // Para Video, video, Window, window -#include "game/ui/notifier.hpp" // Para Notifier -#include "game/ui/service_menu.hpp" // Para ServiceMenu -#include "utils/param.hpp" // Para Param, param, ParamGame, ParamDebug -#include "utils/utils.hpp" // Para toLower +#include "core/rendering/text.hpp" // Para Text +#include "core/rendering/texture.hpp" // Para Texture +#include "core/resources/asset.hpp" // Para Asset +#include "game/options.hpp" // Para Video, video, Window, window +#include "game/ui/notifier.hpp" // Para Notifier +#include "game/ui/service_menu.hpp" // Para ServiceMenu +#include "utils/param.hpp" // Para Param, param, ParamGame, ParamDebug // Singleton Screen* Screen::instance = nullptr; @@ -82,12 +79,7 @@ auto Screen::get() -> Screen* { return Screen::instance; } // Constructor Screen::Screen() - : window_(nullptr), - renderer_(nullptr), - game_canvas_(nullptr), - service_menu_(nullptr), - notifier_(nullptr), - src_rect_(SDL_FRect{.x = 0, .y = 0, .w = param.game.width, .h = param.game.height}), + : src_rect_(SDL_FRect{.x = 0, .y = 0, .w = param.game.width, .h = param.game.height}), dst_rect_(SDL_FRect{.x = 0, .y = 0, .w = param.game.width, .h = param.game.height}) { // Arranca SDL VIDEO, crea la ventana y el renderizador initSDLVideo(); diff --git a/source/core/rendering/screen.hpp b/source/core/rendering/screen.hpp index c3ea96a..92fc271 100644 --- a/source/core/rendering/screen.hpp +++ b/source/core/rendering/screen.hpp @@ -214,11 +214,11 @@ class Screen { #endif // --- Objetos y punteros --- - SDL_Window* window_; // Ventana de la aplicación - SDL_Renderer* renderer_; // El renderizador de la ventana - SDL_Texture* game_canvas_; // Textura donde se dibuja todo antes de volcarse al renderizador - ServiceMenu* service_menu_; // Objeto para mostrar el menú de servicio - Notifier* notifier_; // Objeto para mostrar las notificaciones por pantalla + SDL_Window* window_ = nullptr; // Ventana de la aplicación + SDL_Renderer* renderer_ = nullptr; // El renderizador de la ventana + SDL_Texture* game_canvas_ = nullptr; // Textura donde se dibuja todo antes de volcarse al renderizador + ServiceMenu* service_menu_ = nullptr; // Objeto para mostrar el menú de servicio + Notifier* notifier_ = nullptr; // Objeto para mostrar las notificaciones por pantalla std::shared_ptr text_; // Objeto para escribir texto en pantalla std::unique_ptr shader_backend_; // Backend de shaders (SDL3GPU) @@ -236,20 +236,20 @@ class Screen { #endif // --- Métodos internos --- - auto initSDLVideo() -> bool; // Arranca SDL VIDEO y crea la ventana - void registerEmscriptenEventCallbacks(); // Registra callbacks nativos para restaurar el canvas en wasm (no-op fuera de emscripten) - void renderFlash(); // Dibuja el efecto de flash en la pantalla - void renderShake(); // Aplica el efecto de agitar la pantalla - void renderInfo() const; // Muestra información por pantalla + auto initSDLVideo() -> bool; // Arranca SDL VIDEO y crea la ventana + void registerEmscriptenEventCallbacks(); // Registra callbacks nativos para restaurar el canvas en wasm (no-op fuera de emscripten) + void renderFlash(); // Dibuja el efecto de flash en la pantalla + void renderShake(); // Aplica el efecto de agitar la pantalla + void renderInfo() const; // Muestra información por pantalla [[nodiscard]] auto buildDebugInfoText() const -> std::string; // Compone fps + driver + shader/preset para renderInfo - void renderPresent(); // Selecciona y ejecuta el método de renderizado adecuado - void applyCurrentPostFXPreset(); // Aplica el preset PostFX activo al backend - void applyCurrentCrtPiPreset(); // Aplica el preset CrtPi activo al backend - void adjustWindowSize(); // Calcula el tamaño de la ventana - void getDisplayInfo(); // Obtiene información sobre la pantalla - void renderOverlays(); // Renderiza todos los overlays y efectos - void renderAttenuate(); // Atenúa la pantalla - void createText(); // Crea el objeto de texto + void renderPresent(); // Selecciona y ejecuta el método de renderizado adecuado + void applyCurrentPostFXPreset(); // Aplica el preset PostFX activo al backend + void applyCurrentCrtPiPreset(); // Aplica el preset CrtPi activo al backend + void adjustWindowSize(); // Calcula el tamaño de la ventana + void getDisplayInfo(); // Obtiene información sobre la pantalla + void renderOverlays(); // Renderiza todos los overlays y efectos + void renderAttenuate(); // Atenúa la pantalla + void createText(); // Crea el objeto de texto // --- Constructores y destructor privados (singleton) --- Screen(); // Constructor privado diff --git a/source/core/resources/resource_loader.cpp b/source/core/resources/resource_loader.cpp index 04c6e9b..a0e9406 100644 --- a/source/core/resources/resource_loader.cpp +++ b/source/core/resources/resource_loader.cpp @@ -9,9 +9,7 @@ std::unique_ptr ResourceLoader::instance = nullptr; -ResourceLoader::ResourceLoader() - : resource_pack_(nullptr), - fallback_to_files_(true) {} +ResourceLoader::ResourceLoader() = default; auto ResourceLoader::getInstance() -> ResourceLoader& { if (!instance) { diff --git a/source/core/resources/resource_loader.hpp b/source/core/resources/resource_loader.hpp index 96dc3d5..01262d0 100644 --- a/source/core/resources/resource_loader.hpp +++ b/source/core/resources/resource_loader.hpp @@ -11,9 +11,9 @@ class ResourcePack; class ResourceLoader { private: static std::unique_ptr instance; - ResourcePack* resource_pack_; + ResourcePack* resource_pack_ = nullptr; std::string pack_path_; - bool fallback_to_files_; + bool fallback_to_files_ = true; ResourceLoader(); diff --git a/source/core/resources/resource_pack.cpp b/source/core/resources/resource_pack.cpp index 540ddbf..097b37e 100644 --- a/source/core/resources/resource_pack.cpp +++ b/source/core/resources/resource_pack.cpp @@ -10,8 +10,7 @@ const std::string ResourcePack::DEFAULT_ENCRYPT_KEY = "CCAE_RESOURCES__2024"; -ResourcePack::ResourcePack() - : loaded_(false) {} +ResourcePack::ResourcePack() = default; ResourcePack::~ResourcePack() { clear(); diff --git a/source/core/resources/resource_pack.hpp b/source/core/resources/resource_pack.hpp index e5edd3c..2c7f84d 100644 --- a/source/core/resources/resource_pack.hpp +++ b/source/core/resources/resource_pack.hpp @@ -17,7 +17,7 @@ class ResourcePack { private: std::unordered_map resources_; std::vector data_; - bool loaded_; + bool loaded_ = false; static auto calculateChecksum(const std::vector& data) -> uint32_t; static void encryptData(std::vector& data, const std::string& key); diff --git a/source/game/gameplay/stage.cpp b/source/game/gameplay/stage.cpp index 9d549ec..349fba3 100644 --- a/source/game/gameplay/stage.cpp +++ b/source/game/gameplay/stage.cpp @@ -9,19 +9,13 @@ // Implementación de StageData StageData::StageData(int power_to_complete, int min_menace, int max_menace, std::string name) - : status_(StageStatus::LOCKED), - name_(std::move(name)), + : name_(std::move(name)), power_to_complete_(power_to_complete), min_menace_(min_menace), max_menace_(max_menace) {} // Implementación de StageManager -StageManager::StageManager() - : power_change_callback_(nullptr), - power_collection_state_(PowerCollectionState::ENABLED), - current_stage_index_(0), - current_power_(0), - total_power_(0) { initialize(); } +StageManager::StageManager() { initialize(); } void StageManager::initialize() { stages_.clear(); diff --git a/source/game/gameplay/stage.hpp b/source/game/gameplay/stage.hpp index 63fe7a4..b68b19e 100644 --- a/source/game/gameplay/stage.hpp +++ b/source/game/gameplay/stage.hpp @@ -40,11 +40,11 @@ class StageData { private: // --- Variables de estado --- - StageStatus status_; // Estado actual de la fase - std::string name_; // Nombre de la fase - int power_to_complete_; // Poder necesario para completar la fase - int min_menace_; // Nivel mínimo de amenaza - int max_menace_; // Nivel máximo de amenaza + StageStatus status_ = StageStatus::LOCKED; // Estado actual de la fase + std::string name_; // Nombre de la fase + int power_to_complete_; // Poder necesario para completar la fase + int min_menace_; // Nivel mínimo de amenaza + int max_menace_; // Nivel máximo de amenaza }; // --- Clase StageManager: gestor principal del sistema de fases del juego --- @@ -100,12 +100,12 @@ class StageManager : public IStageInfo { private: // --- Variables de estado --- - std::vector stages_; // Lista de todas las fases - PowerChangeCallback power_change_callback_; // Callback para notificar cambios de poder - PowerCollectionState power_collection_state_; // Estado de recolección de poder - size_t current_stage_index_; // Índice de la fase actual - int current_power_; // Poder actual en la fase activa - int total_power_; // Poder total acumulado en todo el juego + std::vector stages_; // Lista de todas las fases + PowerChangeCallback power_change_callback_; // Callback para notificar cambios de poder + PowerCollectionState power_collection_state_ = PowerCollectionState::ENABLED; // Estado de recolección de poder + size_t current_stage_index_ = 0; // Índice de la fase actual + int current_power_ = 0; // Poder actual en la fase activa + int total_power_ = 0; // Poder total acumulado en todo el juego // --- Métodos internos --- void createDefaultStages(); // Crea las fases predeterminadas del juego diff --git a/source/game/scenes/hiscore_table.cpp b/source/game/scenes/hiscore_table.cpp index 38a9780..185a3df 100644 --- a/source/game/scenes/hiscore_table.cpp +++ b/source/game/scenes/hiscore_table.cpp @@ -36,7 +36,6 @@ HiScoreTable::HiScoreTable() background_(std::make_unique()), view_area_(SDL_FRect{.x = 0, .y = 0, .w = param.game.width, .h = param.game.height}), - fade_mode_(Fade::Mode::IN), background_fade_color_(Color(0, 0, 0)) { // Inicializa el resto Section::name = Section::Name::HI_SCORE_TABLE; diff --git a/source/game/scenes/hiscore_table.hpp b/source/game/scenes/hiscore_table.hpp index c7a0376..78b4a41 100644 --- a/source/game/scenes/hiscore_table.hpp +++ b/source/game/scenes/hiscore_table.hpp @@ -55,12 +55,12 @@ class HiScoreTable { std::vector paths_; // Vector con los recorridos precalculados // --- Variables --- - float elapsed_time_ = 0.0F; // Tiempo transcurrido (segundos) - Uint64 last_time_ = 0; // Último timestamp para calcular delta-time - SDL_FRect view_area_; // Parte de la textura que se muestra en pantalla - Fade::Mode fade_mode_; // Modo de fade a utilizar - Color background_fade_color_; // Color de atenuación del fondo - std::vector entry_colors_; // Colores para destacar las entradas en la tabla + float elapsed_time_ = 0.0F; // Tiempo transcurrido (segundos) + Uint64 last_time_ = 0; // Último timestamp para calcular delta-time + SDL_FRect view_area_; // Parte de la textura que se muestra en pantalla + Fade::Mode fade_mode_ = Fade::Mode::IN; // Modo de fade a utilizar + Color background_fade_color_; // Color de atenuación del fondo + std::vector entry_colors_; // Colores para destacar las entradas en la tabla // --- Flags para eventos basados en tiempo --- struct HiScoreFlags { diff --git a/source/game/scenes/title.cpp b/source/game/scenes/title.cpp index 9ba4e61..7d68282 100644 --- a/source/game/scenes/title.cpp +++ b/source/game/scenes/title.cpp @@ -35,7 +35,6 @@ Title::Title() tiled_bg_(std::make_unique(param.game.game_area.rect, TiledBGMode::RANDOM)), game_logo_(std::make_unique(param.game.game_area.center_x, param.title.title_c_c_position)), mini_logo_sprite_(std::make_unique(Resource::get()->getTexture("logo_jailgames_mini.png"))), - state_(State::LOGO_ANIMATING), num_controllers_(Input::get()->getNumGamepads()) { // Configura objetos tiled_bg_->setColor(param.title.bg_color); diff --git a/source/game/scenes/title.hpp b/source/game/scenes/title.hpp index fa18d98..7b7aeb6 100644 --- a/source/game/scenes/title.hpp +++ b/source/game/scenes/title.hpp @@ -94,7 +94,7 @@ class Title { Anchor anchor_; // Anclas para definir la posición de los elementos del título Section::Name next_section_; // Siguiente sección a cargar Section::Options selection_ = Section::Options::TITLE_TIME_OUT; // Opción elegida en el título - State state_; // Estado actual de la sección + State state_ = State::LOGO_ANIMATING; // Estado actual de la sección Uint64 last_time_ = 0; // Último timestamp para calcular delta-time float counter_time_ = 0.0F; // Temporizador para la pantalla de título (en segundos) float blink_accumulator_ = 0.0F; // Acumulador para el parpadeo (en segundos) diff --git a/source/game/ui/notifier.cpp b/source/game/ui/notifier.cpp index 58c9331..3eb0dce 100644 --- a/source/game/ui/notifier.cpp +++ b/source/game/ui/notifier.cpp @@ -33,7 +33,6 @@ Notifier::Notifier(const std::string& icon_file, std::shared_ptr text) icon_texture_(!icon_file.empty() ? std::make_unique(renderer_, icon_file) : nullptr), text_(std::move(text)), bg_color_(param.notification.color), - stack_(false), has_icons_(!icon_file.empty()) {} // Dibuja las notificaciones por pantalla diff --git a/source/game/ui/notifier.hpp b/source/game/ui/notifier.hpp index f81a2c0..98452b0 100644 --- a/source/game/ui/notifier.hpp +++ b/source/game/ui/notifier.hpp @@ -88,8 +88,8 @@ class Notifier { std::vector notifications_; // Lista de notificaciones activas Color bg_color_; // Color de fondo de las notificaciones // Nota: wait_time_ eliminado, ahora se usa STAY_DURATION_S - bool stack_; // Indica si las notificaciones se apilan - bool has_icons_; // Indica si el notificador tiene textura para iconos + bool stack_ = false; // Indica si las notificaciones se apilan + bool has_icons_; // Indica si el notificador tiene textura para iconos // --- Métodos internos --- void clearFinishedNotifications(); // Elimina las notificaciones cuyo estado es FINISHED diff --git a/source/game/ui/service_menu.cpp b/source/game/ui/service_menu.cpp index 27d72f6..a82dd43 100644 --- a/source/game/ui/service_menu.cpp +++ b/source/game/ui/service_menu.cpp @@ -28,9 +28,7 @@ void ServiceMenu::destroy() { delete ServiceMenu::instance; } auto ServiceMenu::get() -> ServiceMenu* { return ServiceMenu::instance; } // Constructor -ServiceMenu::ServiceMenu() - : current_settings_group_(SettingsGroup::MAIN), - previous_settings_group_(current_settings_group_) { +ServiceMenu::ServiceMenu() { auto element_text = Resource::get()->getText("04b_25_flat"); auto title_text = Resource::get()->getText("04b_25_flat_2x"); diff --git a/source/game/ui/service_menu.hpp b/source/game/ui/service_menu.hpp index 8facf81..db87336 100644 --- a/source/game/ui/service_menu.hpp +++ b/source/game/ui/service_menu.hpp @@ -88,8 +88,8 @@ class ServiceMenu { std::vector> options_; std::vector display_options_; std::vector> option_pairs_; - SettingsGroup current_settings_group_; - SettingsGroup previous_settings_group_; + SettingsGroup current_settings_group_ = SettingsGroup::MAIN; + SettingsGroup previous_settings_group_ = SettingsGroup::MAIN; std::string title_; size_t selected_ = 0; size_t main_menu_selected_ = 0; @@ -103,15 +103,15 @@ class ServiceMenu { void updateDisplayOptions(); void updateOptionPairs(); void initializeOptions(); - void addControlsOptions(); // CONTROLS: mandos 1/2, teclat, swap - void addVideoOptions(); // VIDEO: orquestra els blocs de vídeo - void addVideoShaderOption(); // VIDEO: tria de shader (Disabled/PostFX/CrtPi) - void addVideoPresetOption(); // VIDEO: cicla presets del shader actiu - void addVideoFilterOption(); // VIDEO: filtre Nearest/Linear (fallback SDL) - void addAudioOptions(); // AUDIO: enabled + tres volums - void addSettingsOptions(); // SETTINGS: autofire, idioma, dificultat, shutdown - void addSystemOptions(); // SYSTEM: reset, quit, shutdown - void addMainMenuOptions(); // MAIN: carpetes de menú + void addControlsOptions(); // CONTROLS: mandos 1/2, teclat, swap + void addVideoOptions(); // VIDEO: orquestra els blocs de vídeo + void addVideoShaderOption(); // VIDEO: tria de shader (Disabled/PostFX/CrtPi) + void addVideoPresetOption(); // VIDEO: cicla presets del shader actiu + void addVideoFilterOption(); // VIDEO: filtre Nearest/Linear (fallback SDL) + void addAudioOptions(); // AUDIO: enabled + tres volums + void addSettingsOptions(); // SETTINGS: autofire, idioma, dificultat, shutdown + void addSystemOptions(); // SYSTEM: reset, quit, shutdown + void addMainMenuOptions(); // MAIN: carpetes de menú void updateMenu(); void applySettings(); void applyControlsSettings(); diff --git a/source/utils/color.cpp b/source/utils/color.cpp index 4c4c0ba..aa9b8bf 100644 --- a/source/utils/color.cpp +++ b/source/utils/color.cpp @@ -1,3 +1,4 @@ +// NOLINTNEXTLINE(bugprone-reserved-identifier) -- requerido por para exponer M_PI en MSVC #define _USE_MATH_DEFINES #include "utils/color.hpp"