From b1413bbf8a786ec59fd8066869c1971b1705975f Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 18 Apr 2026 11:54:33 +0200 Subject: [PATCH] =?UTF-8?q?surface:=20hallazgo=203=20=E2=80=94=20sustituye?= =?UTF-8?q?=20sizeof=20check=20por=20static=5Fassert=20en=20fade*Palette?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit palette_ y sub_palette_ son std::array de tamaño fijo, así que el check en runtime nunca podía fallar. Movido a static_assert sobre tuple_size_v. El throw asociado era código muerto. Co-Authored-By: Claude Opus 4.7 (1M context) --- source/core/rendering/surface.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/source/core/rendering/surface.cpp b/source/core/rendering/surface.cpp index d6f38d0..de32ec2 100644 --- a/source/core/rendering/surface.cpp +++ b/source/core/rendering/surface.cpp @@ -635,11 +635,8 @@ void Surface::copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture, SDL_FR // Realiza un efecto de fundido en la paleta principal auto Surface::fadePalette() -> bool { // NOLINT(readability-convert-member-functions-to-static) - // Verificar que el tamaño mínimo de palette_ sea adecuado static constexpr int PALETTE_SIZE = 19; - if (sizeof(palette_) / sizeof(palette_[0]) < PALETTE_SIZE) { - throw std::runtime_error("Palette size is insufficient for fadePalette operation."); - } + static_assert(std::tuple_size_v >= PALETTE_SIZE, "Palette size is insufficient for fadePalette operation."); // Desplazar colores (pares e impares) for (int i = 18; i > 1; --i) { @@ -669,11 +666,8 @@ auto Surface::fadeSubPalette(Uint32 delay) -> bool { // NOLINT(readability-conv // Actualizar el último tick last_tick_ = current_tick; - // Verificar que el tamaño mínimo de sub_palette_ sea adecuado static constexpr int SUB_PALETTE_SIZE = 19; - if (sizeof(sub_palette_) / sizeof(sub_palette_[0]) < SUB_PALETTE_SIZE) { - throw std::runtime_error("Palette size is insufficient for fadePalette operation."); - } + static_assert(std::tuple_size_v >= SUB_PALETTE_SIZE, "Sub-palette size is insufficient for fadeSubPalette operation."); // Desplazar colores (pares e impares) for (int i = 18; i > 1; --i) {