From f4dea6d39b44e6ad5e357dface487e3af44a290a Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Thu, 14 May 2026 20:47:34 +0200 Subject: [PATCH] fix: const a punters i refs (13 troballes) --- source/core/rendering/surface.cpp | 4 ++-- source/core/rendering/surface.hpp | 4 ++-- source/game/editor/map_editor.cpp | 4 ++-- source/game/editor/mini_map.cpp | 2 +- source/game/gameplay/cheevos.cpp | 2 +- source/game/scenes/credits.cpp | 2 +- source/game/scenes/ending.cpp | 2 +- source/game/scenes/game_over.cpp | 2 +- source/game/scenes/title.cpp | 6 +++--- source/game/ui/console_commands.cpp | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/source/core/rendering/surface.cpp b/source/core/rendering/surface.cpp index 7b040ed..a33263d 100644 --- a/source/core/rendering/surface.cpp +++ b/source/core/rendering/surface.cpp @@ -415,7 +415,7 @@ static auto computeFadeDensity(int screen_y, int fade_h, int canvas_height) -> f } // Render amb dissolució als cantons superior/inferior (hash 2D, sense parpelleig) -void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, SDL_FRect* src_rect) const { +void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, const SDL_FRect* src_rect) const { const int SX = (src_rect != nullptr) ? static_cast(src_rect->x) : 0; const int SY = (src_rect != nullptr) ? static_cast(src_rect->y) : 0; const int SW = (src_rect != nullptr) ? static_cast(src_rect->w) : surface_data_->width; @@ -452,7 +452,7 @@ void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height } // Idem però reemplaçant un color índex -void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color, SDL_FRect* src_rect) const { +void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color, const SDL_FRect* src_rect) const { const int SX = (src_rect != nullptr) ? static_cast(src_rect->x) : 0; const int SY = (src_rect != nullptr) ? static_cast(src_rect->y) : 0; const int SW = (src_rect != nullptr) ? static_cast(src_rect->w) : surface_data_->width; diff --git a/source/core/rendering/surface.hpp b/source/core/rendering/surface.hpp index 572847d..7cb3032 100644 --- a/source/core/rendering/surface.hpp +++ b/source/core/rendering/surface.hpp @@ -87,10 +87,10 @@ class Surface { void renderWithColorReplace(int x, int y, Uint8 source_color = 0, Uint8 target_color = 0, SDL_FRect* src_rect = nullptr, SDL_FlipMode flip = SDL_FLIP_NONE) const; // Render amb dissolució als cantons superior/inferior (hash 2D, sense parpelleig) - void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, SDL_FRect* src_rect = nullptr) const; + void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, const SDL_FRect* src_rect = nullptr) const; // Idem però reemplaçant un color índex (per a sprites sobre fons del mateix color) - void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color, SDL_FRect* src_rect = nullptr) const; + void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color, const SDL_FRect* src_rect = nullptr) const; // Establece un color en la paleta void setColor(int index, Uint32 color); diff --git a/source/game/editor/map_editor.cpp b/source/game/editor/map_editor.cpp index 7e7d6a3..d917d34 100644 --- a/source/game/editor/map_editor.cpp +++ b/source/game/editor/map_editor.cpp @@ -1278,7 +1278,7 @@ auto MapEditor::createNewRoom(const std::string& direction) -> std::string { // // Comprobar que no hay ya una room en esa dirección if (!direction.empty()) { - std::string* existing = nullptr; + const std::string* existing = nullptr; if (direction == "UP") { existing = &room_data_.upper_room; } else if (direction == "DOWN") { @@ -1294,7 +1294,7 @@ auto MapEditor::createNewRoom(const std::string& direction) -> std::string { // } // Encontrar el primer número libre (reutiliza huecos) - auto& rooms = Resource::Cache::get()->getRooms(); + const auto& rooms = Resource::Cache::get()->getRooms(); std::set used; for (const auto& r : rooms) { try { diff --git a/source/game/editor/mini_map.cpp b/source/game/editor/mini_map.cpp index ea2c2be..adaae4d 100644 --- a/source/game/editor/mini_map.cpp +++ b/source/game/editor/mini_map.cpp @@ -79,7 +79,7 @@ void MiniMap::buildTileColorTable(const std::string& tileset_name) { // Posiciona las rooms en un grid usando BFS desde las conexiones void MiniMap::layoutRooms() { - auto& rooms = Resource::Cache::get()->getRooms(); + const auto& rooms = Resource::Cache::get()->getRooms(); if (rooms.empty()) { return; } // Mapa de nombre → Room::Data diff --git a/source/game/gameplay/cheevos.cpp b/source/game/gameplay/cheevos.cpp index cf36a6a..c82bfc0 100644 --- a/source/game/gameplay/cheevos.cpp +++ b/source/game/gameplay/cheevos.cpp @@ -45,7 +45,7 @@ Cheevos::~Cheevos() { // Inicializa los logros void Cheevos::init() { // NOLINT(readability-convert-member-functions-to-static) cheevos_list_.clear(); - auto* loc = Locale::get(); + const auto* loc = Locale::get(); cheevos_list_.emplace_back(Achievement{.id = 1, .caption = loc->get("achievements.c1"), .description = loc->get("achievements.d1"), .icon = 2}); cheevos_list_.emplace_back(Achievement{.id = 2, .caption = loc->get("achievements.c2"), .description = loc->get("achievements.d2"), .icon = 2}); cheevos_list_.emplace_back(Achievement{.id = 3, .caption = loc->get("achievements.c3"), .description = loc->get("achievements.d3"), .icon = 2}); diff --git a/source/game/scenes/credits.cpp b/source/game/scenes/credits.cpp index 0feac46..74f89c2 100644 --- a/source/game/scenes/credits.cpp +++ b/source/game/scenes/credits.cpp @@ -50,7 +50,7 @@ void Credits::handleInput() { // Inicializa los textos void Credits::iniTexts() { // NOLINT(readability-convert-member-functions-to-static) - auto* loc = Locale::get(); + const auto* loc = Locale::get(); texts_.clear(); texts_.push_back({.label = "", .color = static_cast(PaletteColor::WHITE)}); diff --git a/source/game/scenes/ending.cpp b/source/game/scenes/ending.cpp index d09a499..2a85237 100644 --- a/source/game/scenes/ending.cpp +++ b/source/game/scenes/ending.cpp @@ -172,7 +172,7 @@ void Ending::updateState(float delta_time) { void Ending::iniTexts() { // NOLINT(readability-convert-member-functions-to-static) // Vector con los textos (traducidos según el idioma activo) std::vector texts; - auto* loc = Locale::get(); + const auto* loc = Locale::get(); // Escena #0 texts.push_back({.caption = loc->get("ending.t0"), .pos = 32}); diff --git a/source/game/scenes/game_over.cpp b/source/game/scenes/game_over.cpp index 6b74d96..19de968 100644 --- a/source/game/scenes/game_over.cpp +++ b/source/game/scenes/game_over.cpp @@ -68,7 +68,7 @@ void GameOver::render() { auto text = Resource::Cache::get()->getText("smb2"); // Escribe el texto de GAME OVER - auto* loc = Locale::get(); + const auto* loc = Locale::get(); text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y, loc->get("game_over.title"), 1, color_); // NOLINT(readability-static-accessed-through-instance) // Dibuja los sprites (ya posicionados en el constructor, solo ajustamos Y) diff --git a/source/game/scenes/title.cpp b/source/game/scenes/title.cpp index 2e831df..7910bac 100644 --- a/source/game/scenes/title.cpp +++ b/source/game/scenes/title.cpp @@ -544,7 +544,7 @@ void Title::renderMainMenu() { const int TOTAL_HEIGHT = 3 * SPACING; // 3 espacios entre 4 items const int START_Y = MENU_CENTER_Y - (TOTAL_HEIGHT / 2); - auto* loc = Locale::get(); + const auto* loc = Locale::get(); menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y, loc->get("title.menu.play"), 1, COLOR); menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y + SPACING, loc->get("title.menu.keyboard"), 1, COLOR); menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y + (2 * SPACING), loc->get("title.menu.joystick"), 1, COLOR); @@ -683,7 +683,7 @@ void Title::renderKeyboardRemap() const { const int START_Y = MENU_CENTER_Y - (2 * TEXT_SIZE); // Centrado aproximado // Mensaje principal: "PRESS KEY FOR [ACTION]" o "KEYS DEFINED" si completado - auto* loc = Locale::get(); + const auto* loc = Locale::get(); if (remap_step_ >= 3) { menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y, loc->get("title.keys.defined"), 1, COLOR); } else { @@ -731,7 +731,7 @@ void Title::renderJoystickRemap() const { const int START_Y = MENU_CENTER_Y - (2 * TEXT_SIZE); // Centrado aproximado // Mensaje principal: "PRESS BUTTON FOR [ACTION]" o "BUTTONS DEFINED" si completado - auto* loc = Locale::get(); + const auto* loc = Locale::get(); if (remap_step_ >= 3) { menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y, loc->get("title.buttons.defined"), 1, COLOR); } else { diff --git a/source/game/ui/console_commands.cpp b/source/game/ui/console_commands.cpp index 745f39a..5a37065 100644 --- a/source/game/ui/console_commands.cpp +++ b/source/game/ui/console_commands.cpp @@ -32,7 +32,7 @@ // Toggle genérico para comandos booleanos ON/OFF (reemplaza macro BOOL_TOGGLE_CMD) static auto boolToggle( const std::string& label, - bool& option, + const bool& option, const std::function& toggle_fn, const std::vector& args) -> std::string { if (args.empty()) {