Commitet pa gastar el Cppcheck

This commit is contained in:
2024-10-08 20:32:24 +02:00
parent c00f4326ae
commit 3e3d764b25
12 changed files with 241 additions and 405 deletions

View File

@@ -117,11 +117,11 @@ Director::~Director()
Asset::destroy();
Input::destroy();
//Screen::destroy();
Screen::destroy();
OnScreenHelp::destroy();
deleteSounds();
deleteMusics();
sounds.clear();
musics.clear();
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
@@ -593,30 +593,10 @@ void Director::loadMusics()
}
}
// Libera la memoria usada por los sonidos del juego
void Director::deleteSounds()
{
for (auto s : sounds)
{
JA_DeleteSound(s.file);
}
sounds.clear();
}
// Libera la memoria usada por las músicas del juego
void Director::deleteMusics()
{
for (auto m : musics)
{
JA_DeleteMusic(m.file);
}
musics.clear();
}
// Ejecuta la sección con el logo
void Director::runLogo()
{
Logo *logo = new Logo();
auto *logo = new Logo();
logo->run();
delete logo;
}
@@ -624,7 +604,7 @@ void Director::runLogo()
// Ejecuta la sección con la secuencia de introducción
void Director::runIntro()
{
Intro *intro = new Intro(getMusic(musics, "intro.ogg"));
auto *intro = new Intro(getMusic(musics, "intro.ogg"));
intro->run();
delete intro;
}
@@ -632,7 +612,7 @@ void Director::runIntro()
// Ejecuta la sección con el titulo del juego
void Director::runTitle()
{
Title *title = new Title(getMusic(musics, "title.ogg"));
auto *title = new Title(getMusic(musics, "title.ogg"));
title->run();
delete title;
}
@@ -640,9 +620,9 @@ void Director::runTitle()
// Ejecuta la sección donde se juega al juego
void Director::runGame()
{
const int playerID = section::options == section::OPTIONS_GAME_PLAY_1P ? 1 : 2;
const int currentStage = 0;
Game *game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, getMusic(musics, "playing.ogg"));
const auto playerID = section::options == section::OPTIONS_GAME_PLAY_1P ? 1 : 2;
constexpr auto currentStage = 0;
auto *game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, getMusic(musics, "playing.ogg"));
game->run();
delete game;
}
@@ -650,7 +630,7 @@ void Director::runGame()
// Ejecuta la sección donde se muestran las instrucciones
void Director::runInstructions()
{
Instructions *instructions = new Instructions(getMusic(musics, "title.ogg"));
auto *instructions = new Instructions(getMusic(musics, "title.ogg"));
instructions->run();
delete instructions;
}
@@ -658,7 +638,7 @@ void Director::runInstructions()
// Ejecuta la sección donde se muestra la tabla de puntuaciones
void Director::runHiScoreTable()
{
HiScoreTable *hiScoreTable = new HiScoreTable(getMusic(musics, "title.ogg"));
auto *hiScoreTable = new HiScoreTable(getMusic(musics, "title.ogg"));
hiScoreTable->run();
delete hiScoreTable;
}
@@ -666,9 +646,9 @@ void Director::runHiScoreTable()
// Ejecuta el juego en modo demo
void Director::runDemoGame()
{
const int playerID = (rand() % 2) + 1;
const int currentStage = 0;
Game *game = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, nullptr);
const auto playerID = (rand() % 2) + 1;
constexpr auto currentStage = 0;
auto *game = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, nullptr);
game->run();
delete game;
}