treball en curs: correccions de tidy

This commit is contained in:
2026-05-16 17:19:40 +02:00
parent 3421f34a84
commit ee2dd0bc2c
30 changed files with 1220 additions and 1479 deletions
+118 -120
View File
@@ -12,19 +12,17 @@
#include <cstdlib> // for exit, EXIT_FAILURE, srand
#include <filesystem>
#include <fstream> // for basic_ostream, operator<<, basi...
#include <iostream> // for cout
#include <memory>
#include <string> // for basic_string, operator+, char_t...
#include <vector> // for vector
#include "core/audio/audio.hpp" // for Audio::init, Audio::destroy
#include "core/input/input.h" // for Input, InputAction, INPUT_USE_GAME...
#include "core/input/mouse.hpp" // for Mouse::handleEvent, Mouse::upda...
#include "core/locale/lang.h" // for Lang, MAX_LANGUAGES, ba_BA, en_UK
#include "core/locale/lang.h" // for Lang, Lang::Code
#include "core/rendering/screen.h" // for Screen
#include "core/rendering/texture.h" // for Texture
#include "core/resources/asset.h" // for Asset, AssetType
#include "core/resources/asset.h" // for Asset, Asset::Type
#include "core/resources/resource.h"
#include "core/resources/resource_helper.h"
#include "game/defaults.hpp" // for SECTION_PROG_LOGO, GAMECANVAS_H...
@@ -86,18 +84,18 @@ Director::Director(int argc, const char *argv[]) {
// de emscripten ya empaqueta data/ — no hay resources.pack.
{
#if defined(__EMSCRIPTEN__)
const bool enable_fallback = true;
const bool ENABLE_FALLBACK = true;
#elif defined(RELEASE_BUILD)
const bool enable_fallback = false;
const bool ENABLE_FALLBACK = false;
#else
const bool enable_fallback = true;
const bool ENABLE_FALLBACK = true;
#endif
#ifdef MACOS_BUNDLE
const std::string pack_path = executablePath + "../Resources/resources.pack";
const std::string PACK_PATH = executablePath + "../Resources/resources.pack";
#else
const std::string pack_path = executablePath + "resources.pack";
const std::string PACK_PATH = executablePath + "resources.pack";
#endif
if (!ResourceHelper::initializeResourceSystem(pack_path, enable_fallback)) {
if (!ResourceHelper::initializeResourceSystem(PACK_PATH, ENABLE_FALLBACK)) {
std::cerr << "Fatal: resource system init failed (missing resources.pack?)" << '\n';
exit(EXIT_FAILURE);
}
@@ -129,11 +127,11 @@ Director::Director(int argc, const char *argv[]) {
Input::init("/gamecontrollerdb.txt");
#else
{
const std::string binDir = std::filesystem::path(executablePath).parent_path().string();
const std::string BIN_DIR = std::filesystem::path(executablePath).parent_path().string();
#ifdef MACOS_BUNDLE
Input::init(binDir + "/../Resources/gamecontrollerdb.txt");
Input::init(BIN_DIR + "/../Resources/gamecontrollerdb.txt");
#else
Input::init(binDir + "/gamecontrollerdb.txt");
Input::init(BIN_DIR + "/gamecontrollerdb.txt");
#endif
}
#endif
@@ -324,127 +322,127 @@ auto Director::initSDL() -> bool {
// Crea el indice de ficheros
auto Director::setFileList() -> bool {
#ifdef MACOS_BUNDLE
const std::string prefix = "/../Resources";
const std::string PREFIX = "/../Resources";
#else
const std::string prefix;
const std::string PREFIX;
#endif
// Ficheros de configuración
Asset::get()->add(systemFolder + "/score.bin", t_data, false, true);
Asset::get()->add(prefix + "/data/demo/demo.bin", t_data);
Asset::get()->add(systemFolder + "/score.bin", Asset::Type::DATA, false, true);
Asset::get()->add(PREFIX + "/data/demo/demo.bin", Asset::Type::DATA);
// Musicas
Asset::get()->add(prefix + "/data/music/intro.ogg", t_music);
Asset::get()->add(prefix + "/data/music/playing.ogg", t_music);
Asset::get()->add(prefix + "/data/music/title.ogg", t_music);
Asset::get()->add(PREFIX + "/data/music/intro.ogg", Asset::Type::MUSIC);
Asset::get()->add(PREFIX + "/data/music/playing.ogg", Asset::Type::MUSIC);
Asset::get()->add(PREFIX + "/data/music/title.ogg", Asset::Type::MUSIC);
// Sonidos
Asset::get()->add(prefix + "/data/sound/balloon.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/bubble1.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/bubble2.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/bubble3.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/bubble4.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/bullet.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/coffeeout.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/hiscore.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/itemdrop.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/itempickup.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/menu_move.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/menu_select.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/player_collision.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/stage_change.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/title.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/clock.wav", t_sound);
Asset::get()->add(prefix + "/data/sound/powerball.wav", t_sound);
Asset::get()->add(PREFIX + "/data/sound/balloon.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/bubble1.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/bubble2.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/bubble3.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/bubble4.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/bullet.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/coffeeout.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/hiscore.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/itemdrop.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/itempickup.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/menu_move.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/menu_select.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/player_collision.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/stage_change.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/title.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/clock.wav", Asset::Type::SOUND);
Asset::get()->add(PREFIX + "/data/sound/powerball.wav", Asset::Type::SOUND);
// Texturas
Asset::get()->add(prefix + "/data/gfx/balloon1.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon1.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/balloon2.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon2.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/balloon3.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon3.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/balloon4.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon4.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/bullet.png", t_bitmap);
Asset::get()->add(PREFIX + "/data/gfx/balloon1.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/balloon1.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/balloon2.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/balloon2.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/balloon3.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/balloon3.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/balloon4.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/balloon4.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/bullet.png", Asset::Type::BITMAP);
Asset::get()->add(prefix + "/data/gfx/game_buildings.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game_clouds.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game_grass.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game_power_meter.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game_sky_colors.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game_text.png", t_bitmap);
Asset::get()->add(PREFIX + "/data/gfx/game_buildings.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/game_clouds.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/game_grass.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/game_power_meter.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/game_sky_colors.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/game_text.png", Asset::Type::BITMAP);
Asset::get()->add(prefix + "/data/gfx/intro.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/logo.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/menu_game_over.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/menu_game_over_end.png", t_bitmap);
Asset::get()->add(PREFIX + "/data/gfx/intro.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/logo.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/menu_game_over.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/menu_game_over_end.png", Asset::Type::BITMAP);
Asset::get()->add(prefix + "/data/gfx/item_points1_disk.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item_points1_disk.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/item_points2_gavina.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item_points2_gavina.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/item_points3_pacmar.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item_points3_pacmar.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/item_clock.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item_clock.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/item_coffee.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item_coffee.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/item_coffee_machine.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item_coffee_machine.ani", t_data);
Asset::get()->add(PREFIX + "/data/gfx/item_points1_disk.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/item_points1_disk.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/item_points2_gavina.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/item_points2_gavina.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/item_points3_pacmar.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/item_points3_pacmar.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/item_clock.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/item_clock.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/item_coffee.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/item_coffee.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/item_coffee_machine.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/item_coffee_machine.ani", Asset::Type::DATA);
Asset::get()->add(prefix + "/data/gfx/title_bg_tile.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/title_coffee.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/title_crisis.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/title_dust.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/title_dust.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/title_gradient.png", t_bitmap);
Asset::get()->add(PREFIX + "/data/gfx/title_bg_tile.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/title_coffee.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/title_crisis.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/title_dust.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/title_dust.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/title_gradient.png", Asset::Type::BITMAP);
Asset::get()->add(prefix + "/data/gfx/player_head.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/player_body.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/player_legs.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/player_death.ani", t_data);
Asset::get()->add(prefix + "/data/gfx/player_fire.ani", t_data);
Asset::get()->add(PREFIX + "/data/gfx/player_head.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/player_body.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/player_legs.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/player_death.ani", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/gfx/player_fire.ani", Asset::Type::DATA);
Asset::get()->add(prefix + "/data/gfx/player_bal1_head.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/player_bal1_body.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/player_bal1_legs.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/player_bal1_death.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/player_bal1_fire.png", t_bitmap);
Asset::get()->add(PREFIX + "/data/gfx/player_bal1_head.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/player_bal1_body.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/player_bal1_legs.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/player_bal1_death.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/player_bal1_fire.png", Asset::Type::BITMAP);
Asset::get()->add(prefix + "/data/gfx/player_arounder_head.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/player_arounder_body.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/player_arounder_legs.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/player_arounder_death.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/player_arounder_fire.png", t_bitmap);
Asset::get()->add(PREFIX + "/data/gfx/player_arounder_head.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/player_arounder_body.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/player_arounder_legs.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/player_arounder_death.png", Asset::Type::BITMAP);
Asset::get()->add(PREFIX + "/data/gfx/player_arounder_fire.png", Asset::Type::BITMAP);
// Fuentes
Asset::get()->add(prefix + "/data/font/8bithud.png", t_font);
Asset::get()->add(prefix + "/data/font/8bithud.txt", t_font);
Asset::get()->add(prefix + "/data/font/nokia.png", t_font);
Asset::get()->add(prefix + "/data/font/nokia_big2.png", t_font);
Asset::get()->add(prefix + "/data/font/nokia.txt", t_font);
Asset::get()->add(prefix + "/data/font/nokia2.png", t_font);
Asset::get()->add(prefix + "/data/font/nokia2.txt", t_font);
Asset::get()->add(prefix + "/data/font/nokia_big2.txt", t_font);
Asset::get()->add(prefix + "/data/font/smb2_big.png", t_font);
Asset::get()->add(prefix + "/data/font/smb2_big.txt", t_font);
Asset::get()->add(prefix + "/data/font/smb2.png", t_font);
Asset::get()->add(prefix + "/data/font/smb2.txt", t_font);
Asset::get()->add(PREFIX + "/data/font/8bithud.png", Asset::Type::FONT);
Asset::get()->add(PREFIX + "/data/font/8bithud.txt", Asset::Type::FONT);
Asset::get()->add(PREFIX + "/data/font/nokia.png", Asset::Type::FONT);
Asset::get()->add(PREFIX + "/data/font/nokia_big2.png", Asset::Type::FONT);
Asset::get()->add(PREFIX + "/data/font/nokia.txt", Asset::Type::FONT);
Asset::get()->add(PREFIX + "/data/font/nokia2.png", Asset::Type::FONT);
Asset::get()->add(PREFIX + "/data/font/nokia2.txt", Asset::Type::FONT);
Asset::get()->add(PREFIX + "/data/font/nokia_big2.txt", Asset::Type::FONT);
Asset::get()->add(PREFIX + "/data/font/smb2_big.png", Asset::Type::FONT);
Asset::get()->add(PREFIX + "/data/font/smb2_big.txt", Asset::Type::FONT);
Asset::get()->add(PREFIX + "/data/font/smb2.png", Asset::Type::FONT);
Asset::get()->add(PREFIX + "/data/font/smb2.txt", Asset::Type::FONT);
// Textos
Asset::get()->add(prefix + "/data/lang/es_ES.txt", t_lang);
Asset::get()->add(prefix + "/data/lang/en_UK.txt", t_lang);
Asset::get()->add(prefix + "/data/lang/ba_BA.txt", t_lang);
Asset::get()->add(PREFIX + "/data/lang/es_ES.txt", Asset::Type::LANG);
Asset::get()->add(PREFIX + "/data/lang/en_UK.txt", Asset::Type::LANG);
Asset::get()->add(PREFIX + "/data/lang/ba_BA.txt", Asset::Type::LANG);
// Menus
Asset::get()->add(prefix + "/data/menu/title.men", t_data);
Asset::get()->add(prefix + "/data/menu/title_gc.men", t_data);
Asset::get()->add(prefix + "/data/menu/options.men", t_data);
Asset::get()->add(prefix + "/data/menu/options_gc.men", t_data);
Asset::get()->add(prefix + "/data/menu/pause.men", t_data);
Asset::get()->add(prefix + "/data/menu/gameover.men", t_data);
Asset::get()->add(prefix + "/data/menu/player_select.men", t_data);
Asset::get()->add(PREFIX + "/data/menu/title.men", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/menu/title_gc.men", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/menu/options.men", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/menu/options_gc.men", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/menu/pause.men", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/menu/gameover.men", Asset::Type::DATA);
Asset::get()->add(PREFIX + "/data/menu/player_select.men", Asset::Type::DATA);
return Asset::get()->check();
}
@@ -524,26 +522,26 @@ void Director::createSystemFolder(const std::string &folder) {
// Gestiona las transiciones entre secciones
void Director::handleSectionTransition() {
// Determina qué sección debería estar activa
ActiveSection targetSection = ActiveSection::None;
ActiveSection target_section = ActiveSection::None;
switch (section->name) {
case SECTION_PROG_LOGO:
targetSection = ActiveSection::Logo;
target_section = ActiveSection::Logo;
break;
case SECTION_PROG_INTRO:
targetSection = ActiveSection::Intro;
target_section = ActiveSection::Intro;
break;
case SECTION_PROG_TITLE:
targetSection = ActiveSection::Title;
target_section = ActiveSection::Title;
break;
case SECTION_PROG_GAME:
targetSection = ActiveSection::Game;
target_section = ActiveSection::Game;
break;
default:
break;
}
// Si no ha cambiado, no hay nada que hacer
if (targetSection == activeSection) {
if (target_section == activeSection) {
return;
}
@@ -554,7 +552,7 @@ void Director::handleSectionTransition() {
game.reset();
// Crea la nueva sección
activeSection = targetSection;
activeSection = target_section;
switch (activeSection) {
case ActiveSection::Logo:
logo = std::make_unique<Logo>(renderer, section);
@@ -566,8 +564,8 @@ void Director::handleSectionTransition() {
title = std::make_unique<Title>(renderer, section);
break;
case ActiveSection::Game: {
const int numPlayers = section->subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
game = std::make_unique<Game>(numPlayers, 0, renderer, false, section);
const int NUM_PLAYERS = section->subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
game = std::make_unique<Game>(NUM_PLAYERS, 0, renderer, false, section);
break;
}
case ActiveSection::None: