cppcheck
This commit is contained in:
@@ -146,6 +146,9 @@ class Balloon {
|
||||
// Destructor
|
||||
~Balloon();
|
||||
|
||||
Balloon(const Balloon &) = delete;
|
||||
Balloon &operator=(const Balloon &) = delete;
|
||||
|
||||
// Centra el globo en la posición X
|
||||
void allignTo(int x);
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ class Bullet {
|
||||
// Destructor
|
||||
~Bullet();
|
||||
|
||||
Bullet(const Bullet &) = delete;
|
||||
Bullet &operator=(const Bullet &) = delete;
|
||||
|
||||
// Pinta el objeto en pantalla
|
||||
void render();
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@ class Item {
|
||||
// Destructor
|
||||
~Item();
|
||||
|
||||
Item(const Item &) = delete;
|
||||
Item &operator=(const Item &) = delete;
|
||||
|
||||
// Centra el objeto en la posición X
|
||||
void allignTo(int x);
|
||||
|
||||
|
||||
@@ -86,6 +86,9 @@ class Player {
|
||||
// Destructor
|
||||
~Player();
|
||||
|
||||
Player(const Player &) = delete;
|
||||
Player &operator=(const Player &) = delete;
|
||||
|
||||
// Iniciador
|
||||
void init();
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <stdlib.h> // for rand
|
||||
|
||||
#include <algorithm> // for max, min
|
||||
#include <numeric> // for accumulate
|
||||
#include <fstream> // for basic_ifstream
|
||||
#include <iostream> // for basic_ostream, char_traits, operator<<
|
||||
#include <numeric> // for accumulate
|
||||
|
||||
#include "core/audio/jail_audio.hpp" // for JA_PlaySound, JA_DeleteSound, JA_LoadSound
|
||||
#include "core/input/global_inputs.hpp" // for GlobalInputs::handle
|
||||
@@ -2184,8 +2184,7 @@ void Game::updateDeathSequence() {
|
||||
|
||||
// Calcula y establece el valor de amenaza en funcion de los globos activos
|
||||
void Game::evaluateAndSetMenace() {
|
||||
menaceCurrent = std::accumulate(balloons.begin(), balloons.end(), Uint8(0),
|
||||
[](Uint8 acc, Balloon *b) { return b->isEnabled() ? acc + b->getMenace() : acc; });
|
||||
menaceCurrent = std::accumulate(balloons.begin(), balloons.end(), Uint8(0), [](Uint8 acc, Balloon *b) { return b->isEnabled() ? acc + b->getMenace() : acc; });
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
@@ -3048,8 +3047,7 @@ bool Game::canPowerBallBeCreated() {
|
||||
|
||||
// Calcula el poder actual de los globos en pantalla
|
||||
int Game::calculateScreenPower() {
|
||||
return std::accumulate(balloons.begin(), balloons.end(), 0,
|
||||
[](int acc, Balloon *b) { return b->isEnabled() ? acc + b->getPower() : acc; });
|
||||
return std::accumulate(balloons.begin(), balloons.end(), 0, [](int acc, Balloon *b) { return b->isEnabled() ? acc + b->getPower() : acc; });
|
||||
}
|
||||
|
||||
// Inicializa las variables que contienen puntos de ruta para mover objetos
|
||||
|
||||
@@ -243,7 +243,7 @@ class Game {
|
||||
Uint8 lastStageReached; // Contiene el numero de la última pantalla que se ha alcanzado
|
||||
demo_t demo; // Variable con todas las variables relacionadas con el modo demo
|
||||
int totalPowerToCompleteGame; // La suma del poder necesario para completar todas las fases
|
||||
int cloudsSpeed; // Velocidad a la que se desplazan las nubes
|
||||
int cloudsSpeed{0}; // Velocidad a la que se desplazan las nubes
|
||||
int pauseCounter; // Contador para salir del menu de pausa y volver al juego
|
||||
bool leavingPauseMenu; // Indica si esta saliendo del menu de pausa para volver al juego
|
||||
bool pauseInitialized; // Indica si la pausa ha sido inicializada
|
||||
@@ -524,6 +524,9 @@ class Game {
|
||||
// Destructor
|
||||
~Game();
|
||||
|
||||
Game(const Game &) = delete;
|
||||
Game &operator=(const Game &) = delete;
|
||||
|
||||
// Bucle para el juego
|
||||
void run();
|
||||
|
||||
|
||||
@@ -26,14 +26,14 @@ class Instructions {
|
||||
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||
|
||||
// Variables
|
||||
Uint16 counter; // Contador
|
||||
Uint16 counterEnd; // Valor final para el contador
|
||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
bool manualQuit; // Indica si se quiere salir del modo manual
|
||||
mode_e mode; // Modo en el que se van a ejecutar las instrucciones
|
||||
bool finished; // Indica si las instrucciones han terminado
|
||||
bool quitRequested; // Indica si se ha solicitado salir de la aplicación
|
||||
Uint16 counter; // Contador
|
||||
Uint16 counterEnd; // Valor final para el contador
|
||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
bool manualQuit; // Indica si se quiere salir del modo manual
|
||||
mode_e mode{m_auto}; // Modo en el que se van a ejecutar las instrucciones
|
||||
bool finished; // Indica si las instrucciones han terminado
|
||||
bool quitRequested; // Indica si se ha solicitado salir de la aplicación
|
||||
|
||||
// Comprueba las entradas
|
||||
void checkInput();
|
||||
@@ -45,6 +45,9 @@ class Instructions {
|
||||
// Destructor
|
||||
~Instructions();
|
||||
|
||||
Instructions(const Instructions &) = delete;
|
||||
Instructions &operator=(const Instructions &) = delete;
|
||||
|
||||
// Bucle principal
|
||||
void run(mode_e mode);
|
||||
|
||||
|
||||
@@ -47,6 +47,9 @@ class Intro {
|
||||
// Destructor
|
||||
~Intro();
|
||||
|
||||
Intro(const Intro &) = delete;
|
||||
Intro &operator=(const Intro &) = delete;
|
||||
|
||||
// Bucle principal
|
||||
void run();
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ class Logo {
|
||||
// Destructor
|
||||
~Logo();
|
||||
|
||||
Logo(const Logo &) = delete;
|
||||
Logo &operator=(const Logo &) = delete;
|
||||
|
||||
// Bucle principal
|
||||
void run();
|
||||
|
||||
|
||||
@@ -860,11 +860,13 @@ void Title::iterate() {
|
||||
demoGame->iterate();
|
||||
|
||||
if (demoGame->hasFinished()) {
|
||||
bool wasQuit = (section->name == SECTION_PROG_QUIT);
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
const bool wasQuit = (section->name == SECTION_PROG_QUIT);
|
||||
delete demoGame;
|
||||
demoGame = nullptr;
|
||||
demoGameActive = false;
|
||||
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (wasQuit) {
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
} else if (demoThenInstructions) {
|
||||
|
||||
@@ -38,11 +38,11 @@ class Title {
|
||||
};
|
||||
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Instructions *instructions; // Objeto para la sección de las instrucciones
|
||||
Game *demoGame; // Objeto para lanzar la demo del juego
|
||||
SDL_Event *eventHandler; // Manejador de eventos
|
||||
section_t *section; // Indicador para el bucle del titulo
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Instructions *instructions{nullptr}; // Objeto para la sección de las instrucciones
|
||||
Game *demoGame{nullptr}; // Objeto para lanzar la demo del juego
|
||||
SDL_Event *eventHandler; // Manejador de eventos
|
||||
section_t *section; // Indicador para el bucle del titulo
|
||||
|
||||
Texture *dustTexture; // Textura con los graficos del polvo
|
||||
Texture *coffeeTexture; // Textura con los graficos de la palabra coffee
|
||||
@@ -87,16 +87,16 @@ class Title {
|
||||
std::vector<int> deviceIndex; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles
|
||||
|
||||
// Variables para la vibración del título (SUBSECTION_TITLE_2)
|
||||
int vibrationStep; // Paso actual de la vibración
|
||||
int vibrationCoffeeBaseX; // Posición X base del bitmap Coffee
|
||||
int vibrationCrisisBaseX; // Posición X base del bitmap Crisis
|
||||
bool vibrationInitialized; // Indica si se han capturado las posiciones base
|
||||
int vibrationStep; // Paso actual de la vibración
|
||||
int vibrationCoffeeBaseX{0}; // Posición X base del bitmap Coffee
|
||||
int vibrationCrisisBaseX{0}; // Posición X base del bitmap Crisis
|
||||
bool vibrationInitialized; // Indica si se han capturado las posiciones base
|
||||
|
||||
// Variables para sub-estados delegados (instrucciones y demo)
|
||||
bool instructionsActive; // Indica si las instrucciones están activas
|
||||
bool demoGameActive; // Indica si el juego demo está activo
|
||||
mode_e instructionsMode; // Modo de las instrucciones activas
|
||||
bool demoThenInstructions; // Indica si tras la demo hay que mostrar instrucciones
|
||||
bool instructionsActive; // Indica si las instrucciones están activas
|
||||
bool demoGameActive; // Indica si el juego demo está activo
|
||||
mode_e instructionsMode{m_auto}; // Modo de las instrucciones activas
|
||||
bool demoThenInstructions; // Indica si tras la demo hay que mostrar instrucciones
|
||||
|
||||
// Inicializa los valores
|
||||
void init();
|
||||
@@ -147,6 +147,9 @@ class Title {
|
||||
// Destructor
|
||||
~Title();
|
||||
|
||||
Title(const Title &) = delete;
|
||||
Title &operator=(const Title &) = delete;
|
||||
|
||||
// Bucle para el titulo del juego
|
||||
void run();
|
||||
|
||||
|
||||
@@ -430,8 +430,7 @@ void Menu::setSelectorPos(int index) {
|
||||
|
||||
// Obtiene la anchura del elemento más ancho del menu
|
||||
int Menu::getWidestItem() {
|
||||
return std::accumulate(item.begin(), item.end(), 0,
|
||||
[](int acc, const item_t &i) { return std::max(acc, i.rect.w); });
|
||||
return std::accumulate(item.begin(), item.end(), 0, [](int acc, const item_t &i) { return std::max(acc, i.rect.w); });
|
||||
}
|
||||
|
||||
// Deja el menu apuntando al primer elemento
|
||||
@@ -792,8 +791,7 @@ int Menu::findWidth() {
|
||||
|
||||
// Calcula el alto del menu
|
||||
int Menu::findHeight() {
|
||||
const int height = std::accumulate(item.begin(), item.end(), 0,
|
||||
[](int acc, const item_t &i) { return acc + i.rect.h + i.hPaddingDown; });
|
||||
const int height = std::accumulate(item.begin(), item.end(), 0, [](int acc, const item_t &i) { return acc + i.rect.h + i.hPaddingDown; });
|
||||
|
||||
return height - item.back().hPaddingDown;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user