neteja cppcheck (105 → 0)
This commit is contained in:
@@ -222,13 +222,13 @@ void BalloonFormations::createFloaterVariants() {
|
||||
formations_.resize(100);
|
||||
|
||||
// Crear variantes flotantes de las primeras 50 formaciones
|
||||
for (size_t k = 0; k < 50 && k < formations_.size(); k++) {
|
||||
for (size_t k = 0; k < 50; k++) {
|
||||
const auto& source = formations_.at(k).balloons;
|
||||
std::vector<SpawnParams> floater_params;
|
||||
floater_params.reserve(formations_.at(k).balloons.size());
|
||||
|
||||
for (const auto& original : formations_.at(k).balloons) {
|
||||
floater_params.emplace_back(original.x, original.y, original.vel_x, Balloon::Type::FLOATER, original.size, original.creation_counter);
|
||||
}
|
||||
floater_params.reserve(source.size());
|
||||
std::ranges::transform(source, std::back_inserter(floater_params), [](const auto& original) {
|
||||
return SpawnParams{original.x, original.y, original.vel_x, Balloon::Type::FLOATER, original.size, original.creation_counter};
|
||||
});
|
||||
|
||||
formations_.at(k + 50) = Formation(floater_params);
|
||||
}
|
||||
@@ -395,24 +395,21 @@ void BalloonFormations::loadDefaultPools() {
|
||||
}
|
||||
}
|
||||
|
||||
// Pool 2: Mix de formaciones normales y floaters (50+)
|
||||
// Pools 2 i 3: requereixen formacions de floaters (>50)
|
||||
if (total_formations > 50) {
|
||||
// Pool 2: Mix de formacions normals i floaters
|
||||
Pool pool2;
|
||||
// Agregar algunas formaciones básicas
|
||||
for (size_t i = 0; i < std::min(static_cast<size_t>(5), total_formations); ++i) {
|
||||
pool2.push_back(static_cast<int>(i));
|
||||
}
|
||||
// Agregar algunas floaters si existen
|
||||
for (size_t i = 50; i < std::min(static_cast<size_t>(55), total_formations); ++i) {
|
||||
pool2.push_back(static_cast<int>(i));
|
||||
}
|
||||
if (!pool2.empty()) {
|
||||
pools_.push_back(pool2);
|
||||
}
|
||||
}
|
||||
|
||||
// Pool 3: Solo floaters (si existen formaciones 50+)
|
||||
if (total_formations > 50) {
|
||||
// Pool 3: Només floaters
|
||||
Pool pool3;
|
||||
for (size_t i = 50; i < std::min(static_cast<size_t>(70), total_formations); ++i) {
|
||||
pool3.push_back(static_cast<int>(i));
|
||||
|
||||
@@ -39,7 +39,7 @@ class BalloonFormations {
|
||||
std::vector<SpawnParams> balloons; // Vector con todas las inicializaciones de los globos de la formación
|
||||
|
||||
// Constructor con parámetros
|
||||
Formation(const std::vector<SpawnParams>& spawn_params)
|
||||
explicit Formation(const std::vector<SpawnParams>& spawn_params)
|
||||
: balloons(spawn_params) {}
|
||||
|
||||
// Constructor por defecto
|
||||
|
||||
@@ -106,7 +106,7 @@ void BalloonManager::deployRandomFormation(int stage) {
|
||||
|
||||
// Crea los globos de la formación
|
||||
const auto BALLOONS = balloon_formations_->getFormationFromPool(stage, formation_id).balloons;
|
||||
for (auto balloon : BALLOONS) {
|
||||
for (const auto& balloon : BALLOONS) {
|
||||
Balloon::Config config = {
|
||||
.x = balloon.x,
|
||||
.y = balloon.y,
|
||||
@@ -127,7 +127,7 @@ void BalloonManager::deployRandomFormation(int stage) {
|
||||
// Crea una formación de globos específica
|
||||
void BalloonManager::deployFormation(int formation_id) {
|
||||
const auto BALLOONS = balloon_formations_->getFormation(formation_id).balloons;
|
||||
for (auto balloon : BALLOONS) {
|
||||
for (const auto& balloon : BALLOONS) {
|
||||
Balloon::Config config = {
|
||||
.x = balloon.x,
|
||||
.y = balloon.y,
|
||||
@@ -143,7 +143,7 @@ void BalloonManager::deployFormation(int formation_id) {
|
||||
// Crea una formación de globos específica a una altura determinada
|
||||
void BalloonManager::deployFormation(int formation_id, float y) {
|
||||
const auto BALLOONS = balloon_formations_->getFormation(formation_id).balloons;
|
||||
for (auto balloon : BALLOONS) {
|
||||
for (const auto& balloon : BALLOONS) {
|
||||
Balloon::Config config = {
|
||||
.x = balloon.x,
|
||||
.y = y,
|
||||
|
||||
@@ -24,7 +24,7 @@ using Balloons = std::list<std::shared_ptr<Balloon>>;
|
||||
class BalloonManager {
|
||||
public:
|
||||
// --- Constructor y destructor ---
|
||||
BalloonManager(IStageInfo* stage_info);
|
||||
explicit BalloonManager(IStageInfo* stage_info);
|
||||
~BalloonManager() = default;
|
||||
|
||||
// --- Métodos principales ---
|
||||
|
||||
@@ -14,7 +14,7 @@ BulletManager::BulletManager()
|
||||
|
||||
// Actualiza el estado de todas las balas
|
||||
void BulletManager::update(float delta_time) {
|
||||
for (auto& bullet : bullets_) {
|
||||
for (const auto& bullet : bullets_) {
|
||||
if (bullet->isEnabled()) {
|
||||
processBulletUpdate(bullet, delta_time);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ void BulletManager::update(float delta_time) {
|
||||
|
||||
// Renderiza todas las balas activas
|
||||
void BulletManager::render() {
|
||||
for (auto& bullet : bullets_) {
|
||||
for (const auto& bullet : bullets_) {
|
||||
if (bullet->isEnabled()) {
|
||||
bullet->render();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
class Cooldown {
|
||||
public:
|
||||
Cooldown(float first_delay_s = 0.0F, float repeat_delay_s = 0.0F)
|
||||
explicit Cooldown(float first_delay_s = 0.0F, float repeat_delay_s = 0.0F)
|
||||
: first_delay_s_(first_delay_s),
|
||||
repeat_delay_s_(repeat_delay_s) {}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "game/gameplay/difficulty.hpp"
|
||||
|
||||
#include <vector> // Para vector
|
||||
#include <algorithm> // Para ranges::find_if
|
||||
#include <vector> // Para vector
|
||||
|
||||
namespace Difficulty {
|
||||
|
||||
@@ -18,19 +19,19 @@ namespace Difficulty {
|
||||
}
|
||||
|
||||
auto getNameFromCode(Code code) -> std::string {
|
||||
for (const auto& difficulty : difficulties_list) {
|
||||
if (difficulty.code == code) {
|
||||
return difficulty.name;
|
||||
}
|
||||
const auto it = std::ranges::find_if(difficulties_list,
|
||||
[code](const auto& difficulty) { return difficulty.code == code; });
|
||||
if (it != difficulties_list.end()) {
|
||||
return it->name;
|
||||
}
|
||||
return !difficulties_list.empty() ? difficulties_list.front().name : "Unknown";
|
||||
}
|
||||
|
||||
auto getCodeFromName(const std::string& name) -> Code {
|
||||
for (const auto& difficulty : difficulties_list) {
|
||||
if (difficulty.name == name) {
|
||||
return difficulty.code;
|
||||
}
|
||||
const auto it = std::ranges::find_if(difficulties_list,
|
||||
[&name](const auto& difficulty) { return difficulty.name == name; });
|
||||
if (it != difficulties_list.end()) {
|
||||
return it->code;
|
||||
}
|
||||
return !difficulties_list.empty() ? difficulties_list.front().code : Code::NORMAL;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class EnterName {
|
||||
void removeLastCharacter(); // Elimina el último carácter del nombre
|
||||
|
||||
auto getFinalName() -> std::string; // Obtiene el nombre final (o aleatorio si vacío)
|
||||
[[nodiscard]] auto getCurrentName() const -> std::string { return name_; } // Obtiene el nombre actual en proceso
|
||||
[[nodiscard]] auto getCurrentName() const -> const std::string& { return name_; } // Obtiene el nombre actual en proceso
|
||||
[[nodiscard]] auto getSelectedCharacter(int offset = 0) const -> std::string; // Devuelve el carácter seleccionado con offset relativo
|
||||
[[nodiscard]] auto getCarousel(int size) const -> std::string; // Devuelve el carrusel de caracteres (size debe ser impar)
|
||||
[[nodiscard]] auto getSelectedIndex() const -> int { return selected_index_; } // Obtiene el índice del carácter seleccionado
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <iomanip> // Para std::setw, std::setfill
|
||||
#include <iostream> // Para std::cout
|
||||
#include <iterator> // Para distance
|
||||
#include <numeric> // Para accumulate
|
||||
#include <ranges> // Para __find_if_fn, find_if
|
||||
#include <utility> // Para move
|
||||
|
||||
@@ -260,22 +261,11 @@ auto ManageHiScoreTable::verifyChecksum(SDL_IOStream* file, const std::string& f
|
||||
|
||||
// Calcula checksum de la tabla
|
||||
auto ManageHiScoreTable::calculateChecksum(const Table& table) -> unsigned int {
|
||||
unsigned int checksum = 0x12345678; // Magic seed
|
||||
|
||||
for (const auto& entry : table) {
|
||||
// Checksum del score
|
||||
return std::accumulate(table.begin(), table.end(), 0x12345678U, [](unsigned int checksum, const auto& entry) {
|
||||
checksum = ((checksum << 5) + checksum) + static_cast<unsigned int>(entry.score);
|
||||
|
||||
// Checksum del nombre
|
||||
for (char c : entry.name) {
|
||||
checksum = ((checksum << 5) + checksum) + static_cast<unsigned int>(c);
|
||||
}
|
||||
|
||||
// Checksum de one_credit_complete
|
||||
checksum = ((checksum << 5) + checksum) + (entry.one_credit_complete ? 1U : 0U);
|
||||
}
|
||||
|
||||
return checksum;
|
||||
checksum = std::accumulate(entry.name.begin(), entry.name.end(), checksum, [](unsigned int acc, char c) { return ((acc << 5) + acc) + static_cast<unsigned int>(c); });
|
||||
return ((checksum << 5) + checksum) + (entry.one_credit_complete ? 1U : 0U);
|
||||
});
|
||||
}
|
||||
|
||||
// Guarda la tabla en un fichero
|
||||
|
||||
@@ -724,7 +724,7 @@ void Scoreboard::renderSeparator() {
|
||||
// Pinta el carrusel de caracteres con efecto de color LERP y animación suave
|
||||
void Scoreboard::renderCarousel(size_t panel_index, int center_x, int y) {
|
||||
// Obtener referencia a EnterName
|
||||
EnterName* enter_name = enter_name_ref_.at(panel_index);
|
||||
const EnterName* enter_name = enter_name_ref_.at(panel_index);
|
||||
if (enter_name == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <algorithm> // Para max, min
|
||||
#include <exception> // Para exception
|
||||
#include <fstream> // Para basic_istream, basic_ifstream, ifstream, stringstream
|
||||
#include <numeric> // Para accumulate
|
||||
#include <sstream> // Para basic_stringstream
|
||||
#include <utility> // Para move
|
||||
|
||||
@@ -282,11 +283,7 @@ auto StageManager::getPowerNeededForCurrentStage() const -> int {
|
||||
}
|
||||
|
||||
auto StageManager::getTotalPowerNeededToCompleteGame() const -> int {
|
||||
int total_power_needed = 0;
|
||||
for (const auto& stage : stages_) {
|
||||
total_power_needed += stage.getPowerToComplete();
|
||||
}
|
||||
return total_power_needed;
|
||||
return std::accumulate(stages_.begin(), stages_.end(), 0, [](int total, const auto& stage) { return total + stage.getPowerToComplete(); });
|
||||
}
|
||||
|
||||
auto StageManager::getPowerNeededToReachStage(size_t target_stage_index) const -> int {
|
||||
|
||||
Reference in New Issue
Block a user