|
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
|
The foundation library (projects/common/src/pse-common). Tiny – six files – but everything else links against it. Fully documented in code; this is the conceptual companion. See also the macro picture in overview.md.
| File | Provides |
|---|---|
| types.h | The var8/var16/var32/var64 fixed-width integer aliases (and the full [us]var[#][sfe] family they shorthand). |
| random.h / .cpp | Random – the shared randomness source. |
| utility.h / .cpp | Utility – shared helpers + the QML entry point + the QML-ownership guard. |
| common_autoport.h | The COMMON_AUTOPORT dllimport/export macro for the shared library. |
A save editor is byte arithmetic end to end, so the project never trusts int/ short. Every integer is spelled as an explicit width via these aliases. The everyday forms (var8, var16, var32, var64) resolve to the exact-width types on purpose: a note in the file records that "fastest" types once silently widened an 8-bit pointer to 32-bit in another project, so exact width is the safe default here.
A thin QObject wrapper over QRandomGenerator::global(). It exists so randomization code reads in intent ("flip a coin", "30% chance", "range a..b") instead of repeating bounds math. Notable shape:
A QObject singleton exposed to QML as the context property pseCommon. Through it QML reaches pseCommon.random and two string helpers (encodeBeforeUrl / decodeAfterUrl, a hex round-trip used to pass name text through route fragments).
Its most load-bearing member is qmlProtectUtil(): the one-liner that pins a C++ QObject to C++ ownership so the QML engine's garbage collector can't delete it. Every database and save object in the project calls into this. Centralizing the GC-ownership incantation here means exactly one place knows it. This is one half of the project's answer to the "QML GC'd my parentless QObject" class of crashes; the other half (qmlCppOwned() for Q_INVOKABLE returns) lives in the savefile layer. Full mechanism: ../reference/qt-patterns.md.