activa -Wextra -Wpedantic i neteja warnings

This commit is contained in:
2026-05-19 15:42:50 +02:00
parent b65a615be2
commit d89141e014
4 changed files with 52 additions and 14 deletions
+8 -2
View File
@@ -216,6 +216,12 @@ target_include_directories(${PROJECT_NAME} PUBLIC
"${CMAKE_BINARY_DIR}" "${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 # Enlazar SDL3
if(APPLE AND MACOS_BUNDLE) if(APPLE AND MACOS_BUNDLE)
target_compile_definitions(${PROJECT_NAME} PRIVATE MACOS_BUNDLE) target_compile_definitions(${PROJECT_NAME} PRIVATE MACOS_BUNDLE)
@@ -232,7 +238,7 @@ else()
endif() endif()
# --- FLAGS DE COMPILACIÓN --- # --- 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 $<$<CONFIG:RELEASE>:-Os -ffunction-sections -fdata-sections>) target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:RELEASE>:-Os -ffunction-sections -fdata-sections>)
# --- CONFIGURACIÓN POR PLATAFORMA --- # --- CONFIGURACIÓN POR PLATAFORMA ---
@@ -269,7 +275,7 @@ if(NOT EMSCRIPTEN)
source/core/resources/resource_pack.cpp source/core/resources/resource_pack.cpp
) )
target_include_directories(pack_resources PRIVATE "${CMAKE_SOURCE_DIR}/source") 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 --- # --- Regeneració automàtica de resources.pack ---
# Cada `cmake --build build` torna a empaquetar `data/` si algun fitxer ha # Cada `cmake --build build` torna a empaquetar `data/` si algun fitxer ha
+1 -1
View File
@@ -13,7 +13,7 @@
#pragma GCC diagnostic ignored "-Wunused-but-set-variable" #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif #endif
// NOLINTBEGIN(clang-analyzer-unix.Malloc): codi extern de tercers, no l'auditem. // NOLINTBEGIN(clang-analyzer-unix.Malloc): codi extern de tercers, no l'auditem.
#include "external/gif.h" #include <gif.h> // tercer-part: resolt via SYSTEM include path (source/external/)
// NOLINTEND(clang-analyzer-unix.Malloc) // NOLINTEND(clang-analyzer-unix.Malloc)
#if defined(__clang__) #if defined(__clang__)
#pragma clang diagnostic pop #pragma clang diagnostic pop
+8 -8
View File
@@ -63,7 +63,7 @@ namespace Menu {
std::function<void(int dir)> change; // per TOGGLE/CYCLE/INT_RANGE std::function<void(int dir)> change; // per TOGGLE/CYCLE/INT_RANGE
std::function<void()> enter; // per SUBMENU i ACTION std::function<void()> enter; // per SUBMENU i ACTION
SDL_Scancode* scancode{nullptr}; // per KEY_BIND SDL_Scancode* scancode{nullptr}; // per KEY_BIND
std::function<bool()> visible; // nullptr ⇒ sempre visible std::function<bool()> visible{nullptr}; // nullptr ⇒ sempre visible
}; };
struct Page { struct Page {
@@ -102,7 +102,7 @@ namespace Menu {
// --- Transició entre pàgines --- // --- Transició entre pàgines ---
static constexpr float TRANSITION_SPEED = 5.5F; // ~180 ms 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 bool transition_active{false};
static float transition_progress{1.0F}; static float transition_progress{1.0F};
static int transition_dir{+1}; // +1 endavant, -1 enrere static int transition_dir{+1}; // +1 endavant, -1 enrere
@@ -137,7 +137,7 @@ namespace Menu {
static auto buildSystem() -> Page; static auto buildSystem() -> Page;
static auto buildRoot() -> 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.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.audio"), ItemKind::SUBMENU, nullptr, nullptr, [] { pushPage(buildAudio()); }, nullptr});
p.items.push_back({Locale::get("menu.items.controls"), ItemKind::SUBMENU, nullptr, nullptr, [] { pushPage(buildControls()); }, 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 { 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) // Zoom i fullscreen: sense sentit a WASM (el navegador posseix el canvas)
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
@@ -235,7 +235,7 @@ namespace Menu {
} }
static auto buildControls() -> Page { 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_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_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}); 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 { 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) { p.items.push_back({Locale::get("menu.items.master_enable"), ItemKind::TOGGLE, [] { return onOff(Options::audio.enabled); }, [](int) {
Options::audio.enabled = !Options::audio.enabled; Options::audio.enabled = !Options::audio.enabled;
@@ -269,7 +269,7 @@ namespace Menu {
} }
static auto buildGame() -> Page { 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}); 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 { 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.subtitle = std::string("v") + Texts::VERSION + " (" + Version::GIT_HASH + ")";
p.items.push_back({Locale::get("menu.items.restart"), ItemKind::ACTION, nullptr, nullptr, [] { p.items.push_back({Locale::get("menu.items.restart"), ItemKind::ACTION, nullptr, nullptr, [] {
@@ -77,7 +77,7 @@ namespace Rendering {
const std::string& fragment_source) -> bool override; const std::string& fragment_source) -> bool override;
void render() 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 cleanup() final; // Libera pipeline/texturas pero mantiene el device vivo
void destroy(); // Limpieza completa (device + swapchain); llamar solo al cerrar void destroy(); // Limpieza completa (device + swapchain); llamar solo al cerrar
[[nodiscard]] auto isHardwareAccelerated() const -> bool override { return is_initialized_; } [[nodiscard]] auto isHardwareAccelerated() const -> bool override { return is_initialized_; }
@@ -153,8 +153,40 @@ namespace Rendering {
SDL_GPUSampler* sampler_ = nullptr; // NEAREST SDL_GPUSampler* sampler_ = nullptr; // NEAREST
SDL_GPUSampler* linear_sampler_ = nullptr; // LINEAR (per texture_filter_linear_) 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}; PostFXUniforms uniforms_{
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}; .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 ShaderType active_shader_ = ShaderType::POSTFX; // Shader de post-procesado activo
int game_width_ = 0; // Dimensions originals del canvas int game_width_ = 0; // Dimensions originals del canvas