neteja cppcheck (44 → 0) i aïllar impls de tercers

This commit is contained in:
2026-05-16 17:53:50 +02:00
parent fe186ad39a
commit e31a3e9182
20 changed files with 151 additions and 196 deletions
@@ -4,6 +4,7 @@
#include <cstddef> // Para size_t
#include <fstream> // Para basic_ostream, basic_istream, operator<<, basic...
#include <iostream> // Para cout, cerr
#include <numeric> // Para std::accumulate
#include <sstream> // Para basic_stringstream
#include <stdexcept> // Para runtime_error
#include <utility>
@@ -155,11 +156,10 @@ void AnimatedSprite::animate(float delta_time) {
anim.accumulated_time += delta_time;
// Calcular duración total de la animación
float total = 0.0F;
for (auto s : anim.speeds) { total += s; }
const float TOTAL = std::accumulate(anim.speeds.begin(), anim.speeds.end(), 0.0F);
// Si hemos superado la duración total, manejar loop o congelar
if (anim.accumulated_time >= total) {
if (anim.accumulated_time >= TOTAL) {
if (anim.loop_from < 0) {
// Sin loop: congelar en el último frame
anim.current_frame = static_cast<int>(anim.frames.size()) - 1;
@@ -168,10 +168,9 @@ void AnimatedSprite::animate(float delta_time) {
return;
}
// Con loop: envolver el tiempo en el rango del loop
float loop_start = 0.0F;
for (int i = 0; i < anim.loop_from; ++i) { loop_start += anim.speeds[i]; }
float loop_len = total - loop_start;
anim.accumulated_time = loop_start + std::fmod(anim.accumulated_time - loop_start, loop_len);
const float LOOP_START = std::accumulate(anim.speeds.begin(), anim.speeds.begin() + anim.loop_from, 0.0F);
const float LOOP_LEN = TOTAL - LOOP_START;
anim.accumulated_time = LOOP_START + std::fmod(anim.accumulated_time - LOOP_START, LOOP_LEN);
}
// Buscar el frame correspondiente al tiempo acumulado