From ae89b252e2b00f64e7202c31e02d362a5923f3e8 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 16 May 2026 14:57:07 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20tidy=20director/jdraw8/jinput/jfile=20(l?= =?UTF-8?q?ocals=20UPPER=5FCASE,=20file=5F*=E2=86=92Jf::)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/core/jail/jdraw8.cpp | 32 +++++++++++------------ source/core/jail/jfile.cpp | 12 ++++----- source/core/jail/jfile.hpp | 16 +++++++----- source/core/jail/jinput.cpp | 30 ++++++++++----------- source/core/resources/resource_helper.cpp | 2 +- source/core/resources/resource_helper.hpp | 2 +- source/core/system/director.cpp | 32 +++++++++++------------ source/main.cpp | 14 +++++----- 8 files changed, 72 insertions(+), 68 deletions(-) diff --git a/source/core/jail/jdraw8.cpp b/source/core/jail/jdraw8.cpp index 8f74420..b851349 100644 --- a/source/core/jail/jdraw8.cpp +++ b/source/core/jail/jdraw8.cpp @@ -117,9 +117,9 @@ void Jd8::setScreenPalette(Jd8::Palette palette) { } void Jd8::fillSquare(int ini, int height, Uint8 color) { - const int offset = ini * 320; - const int size = height * 320; - memset(&screen[offset], color, size); + const int OFFSET = ini * 320; + const int SIZE = height * 320; + memset(&screen[OFFSET], color, SIZE); } void Jd8::fillRect(int x, int y, int w, int h, Uint8 color) { @@ -265,25 +265,25 @@ void Jd8::setPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b) { namespace { enum class FadeType : std::uint8_t { - None = 0, - Out, - ToPal, + NONE = 0, + OUT, + TO_PAL, }; constexpr int FADE_STEPS = 32; - FadeType fade_type = FadeType::None; + FadeType fade_type = FadeType::NONE; Color fade_target[256]; int fade_step = 0; - void apply_fade_step() { - if (fade_type == FadeType::Out) { + void applyFadeStep() { + if (fade_type == FadeType::OUT) { for (int i = 0; i < 256; i++) { main_palette[i].r = main_palette[i].r >= 8 ? main_palette[i].r - 8 : 0; main_palette[i].g = main_palette[i].g >= 8 ? main_palette[i].g - 8 : 0; main_palette[i].b = main_palette[i].b >= 8 ? main_palette[i].b - 8 : 0; } - } else if (fade_type == FadeType::ToPal) { + } else if (fade_type == FadeType::TO_PAL) { for (int i = 0; i < 256; i++) { main_palette[i].r = main_palette[i].r <= int(fade_target[i].r) - 8 ? main_palette[i].r + 8 @@ -301,30 +301,30 @@ namespace { } // namespace void Jd8::fadeStartOut() { - fade_type = FadeType::Out; + fade_type = FadeType::OUT; fade_step = 0; } void Jd8::fadeStartToPal(const Color* pal) { - fade_type = FadeType::ToPal; + fade_type = FadeType::TO_PAL; memcpy(fade_target, pal, sizeof(Color) * 256); fade_step = 0; } auto Jd8::fadeIsActive() -> bool { - return fade_type != FadeType::None; + return fade_type != FadeType::NONE; } auto Jd8::fadeTickStep() -> bool { - if (fade_type == FadeType::None) { + if (fade_type == FadeType::NONE) { return true; } - apply_fade_step(); + applyFadeStep(); fade_step++; if (fade_step >= FADE_STEPS) { - fade_type = FadeType::None; + fade_type = FadeType::NONE; return true; } return false; diff --git a/source/core/jail/jfile.cpp b/source/core/jail/jfile.cpp index 48ec485..e75ad28 100644 --- a/source/core/jail/jfile.cpp +++ b/source/core/jail/jfile.cpp @@ -55,17 +55,17 @@ namespace { } // namespace -void file_setresourcefolder(const char* str) { +void Jf::setResourceFolder(const char* str) { resource_folder = str; } -auto file_getresourcefolder() -> const char* { +auto Jf::getResourceFolder() -> const char* { return resource_folder.c_str(); } // Crea la carpeta del sistema on guardar les dades. // Accepta rutes amb subdirectoris (ex: "jailgames/aee") i crea tota la jerarquia. -void file_setconfigfolder(const char* foldername) { +void Jf::setConfigFolder(const char* foldername) { #ifdef _WIN32 const char* base = getenv("APPDATA"); if (!base) base = "C:/"; @@ -102,13 +102,13 @@ void file_setconfigfolder(const char* foldername) { // volàtil al navegador de totes formes: ignorem l'error i continuem. } -auto file_getconfigfolder() -> const char* { +auto Jf::getConfigFolder() -> const char* { thread_local std::string folder_; folder_ = config_folder + "/"; return folder_.c_str(); } -auto file_getconfigvalue(const char* key) -> const char* { +auto Jf::getConfigValue(const char* key) -> const char* { if (config.empty()) { loadConfigValues(); } @@ -121,7 +121,7 @@ auto file_getconfigvalue(const char* key) -> const char* { return nullptr; } -void file_setconfigvalue(const char* key, const char* value) { +void Jf::setConfigValue(const char* key, const char* value) { if (config.empty()) { loadConfigValues(); } diff --git a/source/core/jail/jfile.hpp b/source/core/jail/jfile.hpp index ac7c21c..3642810 100644 --- a/source/core/jail/jfile.hpp +++ b/source/core/jail/jfile.hpp @@ -1,10 +1,14 @@ #pragma once -void file_setconfigfolder(const char* foldername); -auto file_getconfigfolder() -> const char*; +namespace Jf { -void file_setresourcefolder(const char* str); -auto file_getresourcefolder() -> const char*; + void setConfigFolder(const char* foldername); + auto getConfigFolder() -> const char*; -auto file_getconfigvalue(const char* key) -> const char*; -void file_setconfigvalue(const char* key, const char* value); + void setResourceFolder(const char* str); + auto getResourceFolder() -> const char*; + + auto getConfigValue(const char* key) -> const char*; + void setConfigValue(const char* key, const char* value); + +} // namespace Jf diff --git a/source/core/jail/jinput.cpp b/source/core/jail/jinput.cpp index 98fecc5..de9532e 100644 --- a/source/core/jail/jinput.cpp +++ b/source/core/jail/jinput.cpp @@ -30,7 +30,7 @@ namespace { Uint8 virtual_keystates[static_cast(Ji::VirtualSource::COUNT)][SDL_SCANCODE_COUNT] = {{0}}; - auto scancode_to_ascii(Uint8 scancode) -> Uint8 { + auto scancodeToAscii(Uint8 scancode) -> Uint8 { if (scancode >= SDL_SCANCODE_A && scancode <= SDL_SCANCODE_Z) { return static_cast('a' + (scancode - SDL_SCANCODE_A)); } @@ -51,11 +51,11 @@ void Ji::setVirtualKey(int scancode, VirtualSource source, bool pressed) { if (scancode < 0 || scancode >= SDL_SCANCODE_COUNT) { return; } - const auto src_idx = static_cast(source); - if (src_idx >= static_cast(VirtualSource::COUNT)) { + const auto SRC_IDX = static_cast(source); + if (SRC_IDX >= static_cast(VirtualSource::COUNT)) { return; } - virtual_keystates[src_idx][scancode] = pressed ? 1 : 0; + virtual_keystates[SRC_IDX][scancode] = pressed ? 1 : 0; } void Ji::moveCheats(Uint8 scancode) { @@ -63,7 +63,7 @@ void Ji::moveCheats(Uint8 scancode) { cheat[1] = cheat[2]; cheat[2] = cheat[3]; cheat[3] = cheat[4]; - cheat[4] = scancode_to_ascii(scancode); + cheat[4] = scancodeToAscii(scancode); } void Ji::update() { @@ -73,15 +73,15 @@ void Ji::update() { keystates = SDL_GetKeyboardState(nullptr); } - const Uint64 now = SDL_GetTicks(); + const Uint64 NOW = SDL_GetTicks(); if (last_update_tick == 0) { - last_update_tick = now; + last_update_tick = NOW; } - const auto delta_ms = static_cast(now - last_update_tick); - last_update_tick = now; + const auto DELTA_MS = static_cast(NOW - last_update_tick); + last_update_tick = NOW; if (wait_ms > 0.0F) { - wait_ms -= delta_ms; + wait_ms -= DELTA_MS; wait_ms = std::max(wait_ms, 0.0F); } @@ -111,15 +111,15 @@ auto Ji::keyPressed(int key) -> bool { } auto Ji::cheatActivated(const char* cheat_code) -> bool { - const size_t len = std::strlen(cheat_code); - if (len > sizeof(cheat)) { + const size_t LEN = std::strlen(cheat_code); + if (LEN > sizeof(cheat)) { return false; } // Compara contra els últims `len` caràcters del buffer. El buffer té // mida fixa 5 i acumula sempre el darrer tecle a la posició 4. - const size_t offset = sizeof(cheat) - len; - for (size_t i = 0; i < len; i++) { - if (cheat[offset + i] != static_cast(cheat_code[i])) { + const size_t OFFSET = sizeof(cheat) - LEN; + for (size_t i = 0; i < LEN; i++) { + if (cheat[OFFSET + i] != static_cast(cheat_code[i])) { return false; } } diff --git a/source/core/resources/resource_helper.cpp b/source/core/resources/resource_helper.cpp index a9627f3..6fcea0a 100644 --- a/source/core/resources/resource_helper.cpp +++ b/source/core/resources/resource_helper.cpp @@ -14,7 +14,7 @@ namespace ResourceHelper { bool fallback_enabled_ = true; auto readFromDisk(const std::string& relative_path) -> std::vector { - const std::string full = std::string(file_getresourcefolder()) + relative_path; + const std::string full = std::string(Jf::getResourceFolder()) + relative_path; std::ifstream file(full, std::ios::binary | std::ios::ate); if (!file) { return {}; diff --git a/source/core/resources/resource_helper.hpp b/source/core/resources/resource_helper.hpp index a4df9b4..ea2b3ac 100644 --- a/source/core/resources/resource_helper.hpp +++ b/source/core/resources/resource_helper.hpp @@ -5,7 +5,7 @@ #include // API d'alt nivell per a llegir recursos. Prova primer el pack (si està -// carregat), després cau al fitxer solt dins `file_getresourcefolder()` +// carregat), després cau al fitxer solt dins `Jf::getResourceFolder()` // si el fallback està activat. namespace ResourceHelper { diff --git a/source/core/system/director.cpp b/source/core/system/director.cpp index c968064..bcb9b62 100644 --- a/source/core/system/director.cpp +++ b/source/core/system/director.cpp @@ -170,7 +170,7 @@ auto Director::iterate() -> bool { constexpr Uint32 FRAME_MS_VSYNC = 16; // ~60 FPS amb VSync constexpr Uint32 FRAME_MS_NO_VSYNC = 4; // ~250 FPS sense VSync (límit superior) - const Uint32 frame_start = SDL_GetTicks(); + const Uint32 FRAME_START = SDL_GetTicks(); Gamepad::update(); KeyRemap::update(); @@ -184,12 +184,12 @@ auto Director::iterate() -> bool { // Dispara els crèdits cinematogràfics la primera vegada que el joc // arriba al menú del títol (info::ctx.num_piramide == 0). - static bool credits_triggered = false; - if (!credits_triggered && info::ctx.num_piramide == 0) { + static bool credits_triggered_ = false; + if (!credits_triggered_ && info::ctx.num_piramide == 0) { if (Options::game.show_title_credits) { Overlay::startCredits(); } - credits_triggered = true; + credits_triggered_ = true; } // Si l'overlay ja no bloqueja ESC (timeout), desbloquegem @@ -225,12 +225,12 @@ auto Director::iterate() -> bool { } // Tick de l'escena. Ji::update refresca key_pressed/any_key; el - // delta_ms és el temps real transcorregut des de l'últim tick. + // DELTA_MS és el temps real transcorregut des de l'últim tick. Ji::update(); - const Uint32 now = SDL_GetTicks(); - const int delta_ms = static_cast(now - last_tick_ms_); - last_tick_ms_ = now; - current_scene_->tick(delta_ms); + const Uint32 NOW = SDL_GetTicks(); + const int DELTA_MS = static_cast(NOW - last_tick_ms_); + last_tick_ms_ = NOW; + current_scene_->tick(DELTA_MS); // Converteix `screen` indexat → `pixel_data` ARGB amb la paleta // actual. Jd8::flip ja no fa yield (Phase B.2 eliminà els fibers); @@ -250,10 +250,10 @@ auto Director::iterate() -> bool { // Nota: quan el runtime posseïx el main loop (SDL_AppIterate / // emscripten), aquest SDL_Delay no és ideal. Fase 7 afegirà un mode // que es basa en el timing intern de SDL en lloc del delay explícit. - const Uint32 target_ms = Options::video.vsync ? FRAME_MS_VSYNC : FRAME_MS_NO_VSYNC; - const Uint32 elapsed = SDL_GetTicks() - frame_start; - if (elapsed < target_ms) { - SDL_Delay(target_ms - elapsed); + const Uint32 TARGET_MS = Options::video.vsync ? FRAME_MS_VSYNC : FRAME_MS_NO_VSYNC; + const Uint32 ELAPSED = SDL_GetTicks() - FRAME_START; + if (ELAPSED < TARGET_MS) { + SDL_Delay(TARGET_MS - ELAPSED); } return true; @@ -386,10 +386,10 @@ void Director::handleEvent(const SDL_Event& event) { // KeyConfig::isGuiKey cobreix totes les tecles GUI a la vegada, // incloent pause_toggle i menu_toggle (defensa en profunditat: // aquestes ja s'haurien hagut de menjar al swallow d'amunt). - const auto sc = event.key.scancode; - if (!KeyConfig::isGuiKey(sc)) { + const auto SC = event.key.scancode; + if (!KeyConfig::isGuiKey(SC)) { key_pressed_ = true; - Ji::moveCheats(sc); + Ji::moveCheats(SC); } } Mouse::handleEvent(event); diff --git a/source/main.cpp b/source/main.cpp index d256b3d..a39ecf7 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -30,7 +30,7 @@ auto SDL_AppInit(void** /*appstate*/, int /*argc*/, char* /*argv*/[]) -> SDL_App srand(unsigned(time(nullptr))); // Crea la carpeta de configuració i carrega les opcions - file_setconfigfolder("jailgames/aee"); + Jf::setConfigFolder("jailgames/aee"); // Ruta absoluta a data/ basada en la ubicació de l'executable. // SDL_GetBasePath() detecta automàticament si estem dins d'un .app bundle @@ -39,7 +39,7 @@ auto SDL_AppInit(void** /*appstate*/, int /*argc*/, char* /*argv*/[]) -> SDL_App std::string resource_pack_path; if (base_path != nullptr) { const std::string data_path = std::string(base_path) + "data/"; - file_setresourcefolder(data_path.c_str()); + Jf::setResourceFolder(data_path.c_str()); resource_pack_path = std::string(base_path) + "resources.pack"; } else { resource_pack_path = "resources.pack"; @@ -57,17 +57,17 @@ auto SDL_AppInit(void** /*appstate*/, int /*argc*/, char* /*argv*/[]) -> SDL_App return SDL_APP_FAILURE; } - Options::setConfigFile(std::string(file_getconfigfolder()) + "config.yaml"); + Options::setConfigFile(std::string(Jf::getConfigFolder()) + "config.yaml"); Options::loadFromFile(); // KeyConfig: defaults des de data/input/keys.yaml + overrides de l'usuari KeyConfig::init("input/keys.yaml", - std::string(file_getconfigfolder()) + "keys.yaml"); + std::string(Jf::getConfigFolder()) + "keys.yaml"); #ifndef NDEBUG // debug.yaml: estat inicial de gameplay per a tests ràpids, // només en builds de debug. - Options::setDebugFile(std::string(file_getconfigfolder()) + "debug.yaml"); + Options::setDebugFile(std::string(Jf::getConfigFolder()) + "debug.yaml"); Options::loadDebugFromFile(); #endif @@ -84,9 +84,9 @@ auto SDL_AppInit(void** /*appstate*/, int /*argc*/, char* /*argv*/[]) -> SDL_App Locale::load("locale/ca.yaml"); // Carrega presets de shaders - Options::setPostFXFile(std::string(file_getconfigfolder()) + "postfx.yaml"); + Options::setPostFXFile(std::string(Jf::getConfigFolder()) + "postfx.yaml"); Options::loadPostFXFromFile(); - Options::setCrtPiFile(std::string(file_getconfigfolder()) + "crtpi.yaml"); + Options::setCrtPiFile(std::string(Jf::getConfigFolder()) + "crtpi.yaml"); Options::loadCrtPiFromFile(); Jg::init();