[PR #316] mods: hash a mod.json name as hashdict.joaat does (lower-cased Latin-1, not UTF-8 bytes) #368

Open
opened 2026-11-26 20:17:39 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/316
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/10050


📝 Commits (1)

  • 3bf9490 mods: hash a mod.json name as hashdict.joaat does (lower-cased Latin-1, not UTF-8 bytes)

📊 Changes

2 files changed (+63 additions, -5 deletions)

View changed files

📝 runtime/src/mods.h (+48 -5)
📝 runtime/test/mods_test.cpp (+15 -0)

📄 Description

Carried over from old PR 10050 by Conrage in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10050, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
Conrage: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue as: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7117095716

What and why

runtime/src/mods.h's joaat() hashed the UTF-8 bytes of a mod.json name and lower-cased only ASCII. Every other copy of joaat is pinned to tools/hashdict.py (s.lower().encode("latin-1", "replace"), enforced by tests/test_joaat_agreement.py), so a non-ASCII name in an archetype swap ("from": "Café") got a hash nothing else in the pipeline produces and the swap silently matched no model. #10002 left this open ("leonida_mods hashes UTF-8 bytes like runtime/src/mods.h, so both sides change together"); #9902 changes tools/leonida_mods.py, this changes the runtime so gta6rt and the mod manager agree again.

joaat() now decodes the UTF-8, applies Python's str.lower() for every code point whose lower case lands in Latin-1 (A-Z, U+00C0-U+00DE but U+00D7, plus U+0178, U+1E9E, U+212A, U+212B and U+0130 -> "i" + an unencodable dot; the list was checked against str.lower() over all of Unicode), and hashes the Latin-1 byte, ? for anything else, as hashdict.joaat does. Malformed UTF-8 hashes as ? per bad byte. ASCII names hash exactly as before (the existing model-id asserts are unchanged). Still constexpr.

Tested

  • mods_test gets 12 static_asserts whose values come from hashdict.joaat (accented Latin-1, ×, Ÿ, ẞ, Kelvin/Angstrom signs, İ, CJK). On main 12 of them fail to compile; with this change mods_test: 48 checks, 0 failures with g++ 13 and clang (-std=c++20 -Wall -Wextra -Wconversion -Wsign-conversion, no warnings from mods.h), Linux x86-64. No GPU involved. Not built with MSVC here.
  • The portable Linux runtime ctest set (22 tests) still passes.

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a, no translator change)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/316 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/10050` --- ### 📝 Commits (1) - [`3bf9490`](https://github.com/ubiquitarianism/leonida/commit/3bf949084455e79961153c63ee951aebf61c1c52) mods: hash a mod.json name as hashdict.joaat does (lower-cased Latin-1, not UTF-8 bytes) ### 📊 Changes **2 files changed** (+63 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/mods.h` (+48 -5) 📝 `runtime/test/mods_test.cpp` (+15 -0) </details> ### 📄 Description > Carried over from **old PR 10050** by `Conrage` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10050`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `Conrage`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): <!-- claude-projects-attribution: {"github_login":"Conrage"} --> Claimed in the coordination issue as: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7117095716 ### What and why `runtime/src/mods.h`'s `joaat()` hashed the **UTF-8 bytes** of a mod.json name and lower-cased only ASCII. Every other copy of joaat is pinned to `tools/hashdict.py` (`s.lower().encode("latin-1", "replace")`, enforced by `tests/test_joaat_agreement.py`), so a non-ASCII name in an archetype swap (`"from": "Café"`) got a hash nothing else in the pipeline produces and the swap silently matched no model. `#10002` left this open ("leonida_mods hashes UTF-8 bytes like runtime/src/mods.h, so both sides change together"); `#9902` changes `tools/leonida_mods.py`, this changes the runtime so gta6rt and the mod manager agree again. `joaat()` now decodes the UTF-8, applies Python's `str.lower()` for every code point whose lower case lands in Latin-1 (A-Z, U+00C0-U+00DE but U+00D7, plus U+0178, U+1E9E, U+212A, U+212B and U+0130 -> "i" + an unencodable dot; the list was checked against `str.lower()` over all of Unicode), and hashes the Latin-1 byte, `?` for anything else, as `hashdict.joaat` does. Malformed UTF-8 hashes as `?` per bad byte. ASCII names hash exactly as before (the existing model-id asserts are unchanged). Still `constexpr`. ### Tested - `mods_test` gets 12 `static_assert`s whose values come from `hashdict.joaat` (accented Latin-1, ×, Ÿ, ẞ, Kelvin/Angstrom signs, İ, CJK). On main 12 of them fail to compile; with this change `mods_test: 48 checks, 0 failures` with g++ 13 and clang (`-std=c++20 -Wall -Wextra -Wconversion -Wsign-conversion`, no warnings from mods.h), Linux x86-64. No GPU involved. Not built with MSVC here. - The portable Linux runtime ctest set (22 tests) still passes. AI-assisted: yes ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a, no translator change) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#368
No description provided.