Settings, caller naming and hook chaining
Three parts of RPS Framework serve a mod's own housekeeping rather than engine calls: the RPS::Settings TOML store, caller naming and hook chaining. The RPS mods use them for their own settings files, the log lines of their version refusals, and hooks.
RPS::Settings
Link RPS::Settings and include <RPS/Settings/Store.h>. A Store owns a mod's settings files under Documents/My Games/Fallout4VR/Mods_Config/<Mod>/: one player file and an optional developer file.
The mod declares every option once as a Definition: TOML table path (for example ControllerInput.Left), key, category, help text, group (Player or Developer), ValueType (Boolean, Integer, Float, String or Float3 for [x, y, z]) and a canonical default. The constructor throws std::invalid_argument for a duplicated option, a non-canonical default, a developer option without a developer file, or a legacy key that names a missing option or the wrong type.
| Call | Purpose |
|---|---|
load(startup) | With startup true, organizes the files (and migrates old INIs); otherwise only reads. |
setValue(group, table, key, value), setValues(group, changes) | Write the file only. The loaded values, settings() and revision() change at the next load, so the owner applies a write the same way as an external edit. error() gives the reason a write failed. |
loadedValues(), settings(), find(table, key) | The values the files specify, and every declared option with its value, default and whether the file holds it. |
messages() | Problems found by the last load, each naming its file and line. |
notices() | What the last startup load did besides reading, such as an INI migration. |
revision() | Advances whenever a load changes a value or whether it is specified. |
What a Store guarantees:
- Startup and every write organize each file the same way: every recognized key once, grouped by table in declaration order under its category heading, with its help above it as
##lines. Single-#lines above a key are the player's notes and stay with it. - The player file gains every missing option at its default. Entries the mod does not read (retired options, options of the other file, foreign keys) become
#comments in a trailing block and never apply. - A value of the wrong type is kept as written, reported with its line, and the option keeps its last value. A file that does not parse is never rewritten and keeps its last values.
- The developer file is never created by loading: it holds only options that differ from their defaults and is removed when none remain.
normalizeValuegives the canonical text of a value (true/false, a decimal integer, a float with a.or exponent, raw text,[x, y, z]) and accepts the looser forms an API caller may send (1/0,yes/no,on/off,x, y, z).
A Store is not thread-safe: the owning mod serializes load and writes.
Migrating old INI files
When the player file does not exist at startup, Store migrates the mod's old INI files once and deletes them after the TOML files read back. The mod lists its old keys in a frozen LegacyIni table (<RPS/Settings/LegacyIni.h>): each LegacyKey names the old key and optionally its INI section, the option it became, how it maps (Value, one Float3Component, or BooleanToString), and the old defaults of up to two shipped versions. A value equal to an old default was never changed by the player and is not carried over, so the current default applies.
Caller naming
<RPS/Runtime/CallerModule.h> is header-only. A provider that refuses a request (a consumer built for another provider API, or a version it does not serve) names the calling mod in its log; the game keeps running and the refused mod runs without that provider's features. A provider passes the return address of its discovery export, which lies in the calling mod's DLL.
| Call | Thread | Purpose |
|---|---|---|
moduleFileNameAt(address) | Any | File name, without its folder, of the loaded DLL that contains address; empty when none. |
moduleNameForLog(address) | Any | The same name for a log line: characters outside ASCII become ?, and an unknown module reads "an unidentified module". |
firstFromCaller(address) | Any | True the first time a call site is seen, so a refused mod that retries every frame is looked up and logged once. |
The seen-caller table lives in the header, so each DLL that includes it has its own; it remembers up to 32 call sites. The required-update stop (RequiredUpdate.h), which closed the game with an error box naming the mod to update, is removed.
Hook chaining
<RPS/Runtime/HookChain.h> is header-only. When another plugin already hooked a call site, vtable slot or function entry, these helpers recognize its detour so your hook can call through it instead of refusing to install:
| Call | Native when | Foreign when |
|---|---|---|
resolveCall(callsite, nativeTarget) | The E8 call still reaches nativeTarget | It calls an F4SE trampoline or a function in another loaded DLL |
resolveSlot(slot, nativeTarget) | The slot holds nativeTarget | It holds another DLL's function |
resolveEntry(entry, ...) | The prologue matches | Another plugin's jump sits at the entry; a chained detour calls its destination as the original and may overwrite only entryJumpBytes bytes |
Each returns a Resolved with origin (Native, Foreign or Unrecognized) and what to call for the wrapped behavior. A detour counts only when its jump chain ends in executable code of a loaded DLL that is neither the game nor the calling DLL. Anything else (a changed game binary, your own earlier patch, unreadable memory) stays Unrecognized, and the hook fails closed. reaches(from, destination) checks that a patch, chained or not, still reaches a hook. Raw byte patches of instructions cannot chain.
These are load-time helpers: they query memory protection and module tables, so never call them per frame.