fix: tidy director/jdraw8/jinput/jfile (locals UPPER_CASE, file_*→Jf::)

This commit is contained in:
2026-05-16 14:57:07 +02:00
parent 35cdd88cbb
commit ae89b252e2
8 changed files with 72 additions and 68 deletions
+15 -15
View File
@@ -30,7 +30,7 @@ namespace {
Uint8 virtual_keystates[static_cast<size_t>(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<Uint8>('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<size_t>(source);
if (src_idx >= static_cast<size_t>(VirtualSource::COUNT)) {
const auto SRC_IDX = static_cast<size_t>(source);
if (SRC_IDX >= static_cast<size_t>(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<float>(now - last_update_tick);
last_update_tick = now;
const auto DELTA_MS = static_cast<float>(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<Uint8>(cheat_code[i])) {
const size_t OFFSET = sizeof(cheat) - LEN;
for (size_t i = 0; i < LEN; i++) {
if (cheat[OFFSET + i] != static_cast<Uint8>(cheat_code[i])) {
return false;
}
}