From d89141e014f21c60d4dd143d1bc7b0a9575b3831 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 19 May 2026 15:42:50 +0200 Subject: [PATCH] activa -Wextra -Wpedantic i neteja warnings --- CMakeLists.txt | 10 ++++- source/core/jail/jdraw8.cpp | 2 +- source/core/rendering/menu.cpp | 16 ++++---- .../core/rendering/sdl3gpu/sdl3gpu_shader.hpp | 38 +++++++++++++++++-- 4 files changed, 52 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a87999..85485f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,6 +216,12 @@ target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_BINARY_DIR}" ) +# Capçaleres de tercers a source/external/ — tractades com a sistema per +# silenciar warnings (gif.h, etc.) que no controlem. +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC + "${CMAKE_SOURCE_DIR}/source/external" +) + # Enlazar SDL3 if(APPLE AND MACOS_BUNDLE) target_compile_definitions(${PROJECT_NAME} PRIVATE MACOS_BUNDLE) @@ -232,7 +238,7 @@ else() endif() # --- FLAGS DE COMPILACIÓN --- -target_compile_options(${PROJECT_NAME} PRIVATE -Wall) +target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic) target_compile_options(${PROJECT_NAME} PRIVATE $<$:-Os -ffunction-sections -fdata-sections>) # --- CONFIGURACIÓN POR PLATAFORMA --- @@ -269,7 +275,7 @@ if(NOT EMSCRIPTEN) source/core/resources/resource_pack.cpp ) target_include_directories(pack_resources PRIVATE "${CMAKE_SOURCE_DIR}/source") - target_compile_options(pack_resources PRIVATE -Wall) + target_compile_options(pack_resources PRIVATE -Wall -Wextra -Wpedantic) # --- Regeneració automàtica de resources.pack --- # Cada `cmake --build build` torna a empaquetar `data/` si algun fitxer ha diff --git a/source/core/jail/jdraw8.cpp b/source/core/jail/jdraw8.cpp index edfd095..e89ae3e 100644 --- a/source/core/jail/jdraw8.cpp +++ b/source/core/jail/jdraw8.cpp @@ -13,7 +13,7 @@ #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif // NOLINTBEGIN(clang-analyzer-unix.Malloc): codi extern de tercers, no l'auditem. -#include "external/gif.h" +#include // tercer-part: resolt via SYSTEM include path (source/external/) // NOLINTEND(clang-analyzer-unix.Malloc) #if defined(__clang__) #pragma clang diagnostic pop diff --git a/source/core/rendering/menu.cpp b/source/core/rendering/menu.cpp index 5aa1723..e1890a4 100644 --- a/source/core/rendering/menu.cpp +++ b/source/core/rendering/menu.cpp @@ -63,7 +63,7 @@ namespace Menu { std::function change; // per TOGGLE/CYCLE/INT_RANGE std::function enter; // per SUBMENU i ACTION SDL_Scancode* scancode{nullptr}; // per KEY_BIND - std::function visible; // nullptr ⇒ sempre visible + std::function visible{nullptr}; // nullptr ⇒ sempre visible }; struct Page { @@ -102,7 +102,7 @@ namespace Menu { // --- Transició entre pàgines --- static constexpr float TRANSITION_SPEED = 5.5F; // ~180 ms - static Page transition_outgoing{.title = "", .items = {}, .cursor = 0}; + static Page transition_outgoing{.title = "", .items = {}, .cursor = 0, .subtitle = ""}; static bool transition_active{false}; static float transition_progress{1.0F}; static int transition_dir{+1}; // +1 endavant, -1 enrere @@ -137,7 +137,7 @@ namespace Menu { static auto buildSystem() -> Page; static auto buildRoot() -> Page { - Page p{.title = Locale::get("menu.titles.root"), .items = {}, .cursor = 0}; + Page p{.title = Locale::get("menu.titles.root"), .items = {}, .cursor = 0, .subtitle = ""}; p.items.push_back({Locale::get("menu.items.video"), ItemKind::SUBMENU, nullptr, nullptr, [] { pushPage(buildVideo()); }, nullptr}); p.items.push_back({Locale::get("menu.items.audio"), ItemKind::SUBMENU, nullptr, nullptr, [] { pushPage(buildAudio()); }, nullptr}); p.items.push_back({Locale::get("menu.items.controls"), ItemKind::SUBMENU, nullptr, nullptr, [] { pushPage(buildControls()); }, nullptr}); @@ -147,7 +147,7 @@ namespace Menu { } static auto buildVideo() -> Page { - Page p{.title = Locale::get("menu.titles.video"), .items = {}, .cursor = 0}; + Page p{.title = Locale::get("menu.titles.video"), .items = {}, .cursor = 0, .subtitle = ""}; // Zoom i fullscreen: sense sentit a WASM (el navegador posseix el canvas) #ifndef __EMSCRIPTEN__ @@ -235,7 +235,7 @@ namespace Menu { } static auto buildControls() -> Page { - Page p{.title = Locale::get("menu.titles.controls"), .items = {}, .cursor = 0}; + Page p{.title = Locale::get("menu.titles.controls"), .items = {}, .cursor = 0, .subtitle = ""}; p.items.push_back({Locale::get("menu.items.move_up"), ItemKind::KEY_BIND, nullptr, nullptr, nullptr, &Options::keys_game.up}); p.items.push_back({Locale::get("menu.items.move_down"), ItemKind::KEY_BIND, nullptr, nullptr, nullptr, &Options::keys_game.down}); p.items.push_back({Locale::get("menu.items.move_left"), ItemKind::KEY_BIND, nullptr, nullptr, nullptr, &Options::keys_game.left}); @@ -245,7 +245,7 @@ namespace Menu { } static auto buildAudio() -> Page { - Page p{.title = Locale::get("menu.titles.audio"), .items = {}, .cursor = 0}; + Page p{.title = Locale::get("menu.titles.audio"), .items = {}, .cursor = 0, .subtitle = ""}; p.items.push_back({Locale::get("menu.items.master_enable"), ItemKind::TOGGLE, [] { return onOff(Options::audio.enabled); }, [](int) { Options::audio.enabled = !Options::audio.enabled; @@ -269,7 +269,7 @@ namespace Menu { } static auto buildGame() -> Page { - Page p{.title = Locale::get("menu.titles.game"), .items = {}, .cursor = 0}; + Page p{.title = Locale::get("menu.titles.game"), .items = {}, .cursor = 0, .subtitle = ""}; p.items.push_back({Locale::get("menu.items.use_new_logo"), ItemKind::TOGGLE, [] { return yesNo(Options::game.use_new_logo); }, [](int) { Options::game.use_new_logo = !Options::game.use_new_logo; }, nullptr}); @@ -281,7 +281,7 @@ namespace Menu { } static auto buildSystem() -> Page { - Page p{.title = Locale::get("menu.titles.system"), .items = {}, .cursor = 0}; + Page p{.title = Locale::get("menu.titles.system"), .items = {}, .cursor = 0, .subtitle = ""}; p.subtitle = std::string("v") + Texts::VERSION + " (" + Version::GIT_HASH + ")"; p.items.push_back({Locale::get("menu.items.restart"), ItemKind::ACTION, nullptr, nullptr, [] { diff --git a/source/core/rendering/sdl3gpu/sdl3gpu_shader.hpp b/source/core/rendering/sdl3gpu/sdl3gpu_shader.hpp index b0cf031..9f337be 100644 --- a/source/core/rendering/sdl3gpu/sdl3gpu_shader.hpp +++ b/source/core/rendering/sdl3gpu/sdl3gpu_shader.hpp @@ -77,7 +77,7 @@ namespace Rendering { const std::string& fragment_source) -> bool override; void render() override; - void setTextureSize(float width, float height) override {} + void setTextureSize(float /*width*/, float /*height*/) override {} void cleanup() final; // Libera pipeline/texturas pero mantiene el device vivo void destroy(); // Limpieza completa (device + swapchain); llamar solo al cerrar [[nodiscard]] auto isHardwareAccelerated() const -> bool override { return is_initialized_; } @@ -153,8 +153,40 @@ namespace Rendering { SDL_GPUSampler* sampler_ = nullptr; // NEAREST SDL_GPUSampler* linear_sampler_ = nullptr; // LINEAR (per texture_filter_linear_) - PostFXUniforms uniforms_{.vignette_strength = 0.6F, .chroma_min = 0.15F, .scanline_strength = 0.7F, .screen_height = 200.0F, .pixel_scale = 1.0F, .chroma_max = 0.15F, .scan_dark_ratio = 0.333F, .scan_dark_floor = 0.42F, .scan_edge_soft = 1.0F}; - CrtPiUniforms crtpi_uniforms_{.scanline_weight = 6.0F, .scanline_gap_brightness = 0.12F, .bloom_factor = 3.5F, .input_gamma = 2.4F, .output_gamma = 2.2F, .mask_brightness = 0.80F, .curvature_x = 0.05F, .curvature_y = 0.10F, .mask_type = 2, .enable_scanlines = 1, .enable_multisample = 1, .enable_gamma = 1}; + PostFXUniforms uniforms_{ + .vignette_strength = 0.6F, + .chroma_min = 0.15F, + .scanline_strength = 0.7F, + .screen_height = 200.0F, + .mask_strength = 0.0F, + .gamma_strength = 0.0F, + .curvature = 0.0F, + .bleeding = 0.0F, + .pixel_scale = 1.0F, + .time = 0.0F, + .flicker = 0.0F, + .chroma_max = 0.15F, + .scan_dark_ratio = 0.333F, + .scan_dark_floor = 0.42F, + .scan_edge_soft = 1.0F, + .pad3 = 0.0F}; + CrtPiUniforms crtpi_uniforms_{ + .scanline_weight = 6.0F, + .scanline_gap_brightness = 0.12F, + .bloom_factor = 3.5F, + .input_gamma = 2.4F, + .output_gamma = 2.2F, + .mask_brightness = 0.80F, + .curvature_x = 0.05F, + .curvature_y = 0.10F, + .mask_type = 2, + .enable_scanlines = 1, + .enable_multisample = 1, + .enable_gamma = 1, + .enable_curvature = 0, + .enable_sharper = 0, + .texture_width = 0.0F, + .texture_height = 0.0F}; ShaderType active_shader_ = ShaderType::POSTFX; // Shader de post-procesado activo int game_width_ = 0; // Dimensions originals del canvas