forked from jaildesigner-jailgames/jaildoctors_dilemma
cppcheck
This commit is contained in:
@@ -341,7 +341,7 @@ void Input::resetInputStates() {
|
|||||||
key.second.just_pressed = false;
|
key.second.just_pressed = false;
|
||||||
}
|
}
|
||||||
// Resetear todos los ControllerBindings.active a false
|
// Resetear todos los ControllerBindings.active a false
|
||||||
for (auto& gamepad : gamepads_) {
|
for (const auto& gamepad : gamepads_) {
|
||||||
for (auto& binding : gamepad->bindings) {
|
for (auto& binding : gamepad->bindings) {
|
||||||
binding.second.is_held = false;
|
binding.second.is_held = false;
|
||||||
binding.second.just_pressed = false;
|
binding.second.just_pressed = false;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class Input {
|
|||||||
std::string path;
|
std::string path;
|
||||||
std::unordered_map<Action, ButtonState> bindings;
|
std::unordered_map<Action, ButtonState> bindings;
|
||||||
|
|
||||||
Gamepad(SDL_Gamepad* gamepad)
|
explicit Gamepad(SDL_Gamepad* gamepad)
|
||||||
: pad(gamepad),
|
: pad(gamepad),
|
||||||
instance_id(SDL_GetJoystickID(SDL_GetGamepadJoystick(gamepad))),
|
instance_id(SDL_GetJoystickID(SDL_GetGamepadJoystick(gamepad))),
|
||||||
name(std::string(SDL_GetGamepadName(gamepad))),
|
name(std::string(SDL_GetGamepadName(gamepad))),
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ class SurfaceAnimatedSprite : public SurfaceMovingSprite {
|
|||||||
// [DOC:29/10/2025] la surface ara se pillarà del .ANI.
|
// [DOC:29/10/2025] la surface ara se pillarà del .ANI.
|
||||||
// Necesite constructors que no requereixquen la surface al crear el objecte,
|
// Necesite constructors que no requereixquen la surface al crear el objecte,
|
||||||
// ja que la trau al llegir el arxiu. Aixó afecta a totes les classes base...
|
// ja que la trau al llegir el arxiu. Aixó afecta a totes les classes base...
|
||||||
SurfaceAnimatedSprite(const std::string& file_path);
|
explicit SurfaceAnimatedSprite(const std::string& file_path);
|
||||||
SurfaceAnimatedSprite(const Animations& animations);
|
explicit SurfaceAnimatedSprite(const Animations& animations);
|
||||||
// [/DOC]
|
// [/DOC]
|
||||||
SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, const std::string& file_path);
|
SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, const std::string& file_path);
|
||||||
SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, const Animations& animations);
|
SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, const Animations& animations);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ struct ResourcePalette {
|
|||||||
Palette palette; // Paleta
|
Palette palette; // Paleta
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
ResourcePalette(std::string name, Palette palette)
|
ResourcePalette(std::string name, const Palette& palette)
|
||||||
: name(std::move(name)),
|
: name(std::move(name)),
|
||||||
palette(palette) {}
|
palette(palette) {}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -525,8 +525,6 @@ void Player::playFallSound() {
|
|||||||
// Comprueba si el jugador tiene suelo debajo de los pies
|
// Comprueba si el jugador tiene suelo debajo de los pies
|
||||||
auto Player::isOnFloor() -> bool {
|
auto Player::isOnFloor() -> bool {
|
||||||
bool on_floor = false;
|
bool on_floor = false;
|
||||||
bool on_slope_l = false;
|
|
||||||
bool on_slope_r = false;
|
|
||||||
|
|
||||||
updateFeet();
|
updateFeet();
|
||||||
|
|
||||||
@@ -537,8 +535,8 @@ auto Player::isOnFloor() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las rampas
|
// Comprueba las rampas
|
||||||
on_slope_l = room_->checkLeftSlopes(under_feet_.data());
|
auto on_slope_l = room_->checkLeftSlopes(under_feet_.data());
|
||||||
on_slope_r = room_->checkRightSlopes(&under_feet_[1]);
|
auto on_slope_r = room_->checkRightSlopes(&under_feet_[1]);
|
||||||
|
|
||||||
return on_floor || on_slope_l || on_slope_r;
|
return on_floor || on_slope_l || on_slope_r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
#include <cstddef> // Para NULL
|
#include <algorithm> // Para std::count_if
|
||||||
#include <fstream> // Para basic_ostream, operator<<, basic_ofstream
|
#include <cstddef> // Para NULL
|
||||||
#include <iostream> // Para cout, cerr
|
#include <fstream> // Para basic_ostream, operator<<, basic_ofstream
|
||||||
|
#include <iostream> // Para cout, cerr
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "game/options.hpp" // Para Options, options
|
#include "game/options.hpp" // Para Options, options
|
||||||
@@ -159,13 +160,8 @@ void Cheevos::saveToFile() {
|
|||||||
|
|
||||||
// Devuelve el número total de logros desbloqueados
|
// Devuelve el número total de logros desbloqueados
|
||||||
auto Cheevos::getTotalUnlockedAchievements() -> int {
|
auto Cheevos::getTotalUnlockedAchievements() -> int {
|
||||||
int count = 0;
|
return std::count_if(cheevos_list_.begin(), cheevos_list_.end(),
|
||||||
for (const auto& cheevo : cheevos_list_) {
|
[](const auto& cheevo) { return cheevo.completed; });
|
||||||
if (cheevo.completed) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Elimina el estado "no obtenible"
|
// Elimina el estado "no obtenible"
|
||||||
|
|||||||
@@ -288,20 +288,17 @@ void LoadingScreen::renderHeaderBorder() const {
|
|||||||
const auto COLOR = carrier_.toggle ? static_cast<Uint8>(PaletteColor::RED) : static_cast<Uint8>(PaletteColor::CYAN);
|
const auto COLOR = carrier_.toggle ? static_cast<Uint8>(PaletteColor::RED) : static_cast<Uint8>(PaletteColor::CYAN);
|
||||||
const int WIDTH = Options::game.width + (Options::video.border.width * 2);
|
const int WIDTH = Options::game.width + (Options::video.border.width * 2);
|
||||||
const int HEIGHT = Options::game.height + (Options::video.border.height * 2);
|
const int HEIGHT = Options::game.height + (Options::video.border.height * 2);
|
||||||
bool draw_enabled = true;
|
|
||||||
|
|
||||||
// Primera linea (con el color y tamaño de la portadora)
|
// Primera linea (con el color y tamaño de la portadora)
|
||||||
int row = 0;
|
int row = 0;
|
||||||
const int FIRST_ROW_HEIGHT = static_cast<int>(carrier_.offset);
|
const int FIRST_ROW_HEIGHT = static_cast<int>(carrier_.offset);
|
||||||
if (draw_enabled) {
|
for (int i = row; i < row + FIRST_ROW_HEIGHT; ++i) {
|
||||||
for (int i = row; i < row + FIRST_ROW_HEIGHT; ++i) {
|
border->drawLine(0, i, WIDTH, i, COLOR);
|
||||||
border->drawLine(0, i, WIDTH, i, COLOR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
row += FIRST_ROW_HEIGHT;
|
row += FIRST_ROW_HEIGHT;
|
||||||
draw_enabled = !draw_enabled;
|
|
||||||
|
|
||||||
// Resto de lineas (siguen a la portadora)
|
// Resto de lineas (siguen a la portadora)
|
||||||
|
bool draw_enabled = false;
|
||||||
while (row < HEIGHT) {
|
while (row < HEIGHT) {
|
||||||
if (draw_enabled) {
|
if (draw_enabled) {
|
||||||
for (int i = row; i < row + HEADER_DATAROW_HEIGHT; ++i) {
|
for (int i = row; i < row + HEADER_DATAROW_HEIGHT; ++i) {
|
||||||
|
|||||||
Reference in New Issue
Block a user