neteja cppcheck (44 → 0) i aïllar impls de tercers
This commit is contained in:
@@ -178,9 +178,7 @@ namespace {
|
||||
}
|
||||
|
||||
// Si quedan colores sin asignar, añadirlos al final
|
||||
for (const auto& c : available) {
|
||||
result.push_back(c);
|
||||
}
|
||||
std::ranges::copy(available, std::back_inserter(result));
|
||||
|
||||
Palette out{};
|
||||
out.fill(0);
|
||||
@@ -208,11 +206,11 @@ PaletteManager::PaletteManager(
|
||||
// Leer la paleta de referencia directamente desde el archivo
|
||||
// (Resource::Cache aún no está disponible en este punto del ciclo de vida)
|
||||
const std::string REF_NAME = std::string(Defaults::Video::PALETTE_NAME) + ".pal";
|
||||
for (const auto& p : palettes_) {
|
||||
if (getFileName(p) == REF_NAME) {
|
||||
reference_palette_ = readPalFile(p);
|
||||
break;
|
||||
}
|
||||
auto ref_it = std::ranges::find_if(palettes_, [&](const auto& p) {
|
||||
return getFileName(p) == REF_NAME;
|
||||
});
|
||||
if (ref_it != palettes_.end()) {
|
||||
reference_palette_ = readPalFile(*ref_it);
|
||||
}
|
||||
|
||||
// Leer y aplicar paleta inicial
|
||||
|
||||
@@ -8,9 +8,8 @@
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "external/stb_image_write.h" // Para stbi_write_png
|
||||
#include "external/stb_image_write.h" // Para stbi_write_png (impl en source/external/stb_image_write_impl.cpp)
|
||||
|
||||
namespace Screenshot {
|
||||
|
||||
@@ -21,7 +20,7 @@ namespace Screenshot {
|
||||
|
||||
auto now = std::chrono::system_clock::now();
|
||||
std::time_t time = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm* tm = std::localtime(&time);
|
||||
const std::tm* tm = std::localtime(&time);
|
||||
|
||||
char timestamp[20];
|
||||
std::strftime(timestamp, sizeof(timestamp), "%Y%m%d_%H%M%S", tm);
|
||||
@@ -45,15 +44,15 @@ namespace Screenshot {
|
||||
} // namespace
|
||||
|
||||
auto save(const Surface& surface) -> std::string {
|
||||
int width = static_cast<int>(surface.getWidth());
|
||||
int height = static_cast<int>(surface.getHeight());
|
||||
std::vector<Uint32> buffer(static_cast<size_t>(width * height));
|
||||
const int WIDTH = surface.getWidth();
|
||||
const int HEIGHT = surface.getHeight();
|
||||
std::vector<Uint32> buffer(static_cast<size_t>(WIDTH * HEIGHT));
|
||||
surface.toARGBBuffer(buffer.data());
|
||||
|
||||
std::string filename;
|
||||
std::string filepath = generateFilePath(filename);
|
||||
|
||||
return writePng(buffer.data(), width, height, filepath) ? filename : "";
|
||||
return writePng(buffer.data(), WIDTH, HEIGHT, filepath) ? filename : "";
|
||||
}
|
||||
|
||||
auto save(const Uint32* buffer, int width, int height) -> std::string {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -427,7 +427,7 @@ static auto computeFadeDensity(int screen_y, int fade_h, int canvas_height) -> f
|
||||
}
|
||||
|
||||
// Render amb dissolució als cantons superior/inferior (hash 2D, sense parpelleig)
|
||||
void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, SDL_FRect* src_rect) const {
|
||||
void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, const SDL_FRect* src_rect) const {
|
||||
// Aplicar render offset (usado per transicions entre pantalles)
|
||||
x += Screen::get()->getRenderOffsetX();
|
||||
y += Screen::get()->getRenderOffsetY();
|
||||
@@ -468,7 +468,7 @@ void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height
|
||||
}
|
||||
|
||||
// Idem però reemplaçant un color índex
|
||||
void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color, SDL_FRect* src_rect) const {
|
||||
void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color, const SDL_FRect* src_rect) const {
|
||||
// Aplicar render offset (usado per transicions entre pantalles)
|
||||
x += Screen::get()->getRenderOffsetX();
|
||||
y += Screen::get()->getRenderOffsetY();
|
||||
|
||||
@@ -87,10 +87,10 @@ class Surface {
|
||||
void renderWithColorReplace(int x, int y, Uint8 source_color = 0, Uint8 target_color = 0, SDL_FRect* src_rect = nullptr, SDL_FlipMode flip = SDL_FLIP_NONE) const;
|
||||
|
||||
// Render amb dissolució als cantons superior/inferior (hash 2D, sense parpelleig)
|
||||
void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, SDL_FRect* src_rect = nullptr) const;
|
||||
void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, const SDL_FRect* src_rect = nullptr) const;
|
||||
|
||||
// Idem però reemplaçant un color índex (per a sprites sobre fons del mateix color)
|
||||
void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color, SDL_FRect* src_rect = nullptr) const;
|
||||
void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color, const SDL_FRect* src_rect = nullptr) const;
|
||||
|
||||
// Establece un color en la paleta
|
||||
void setColor(int index, Uint32 color);
|
||||
|
||||
Reference in New Issue
Block a user