feat(editor): add WCFG JSON round-trip (--export/--import-wcfg-json)

Dual encoding for both WCFG enums via the readEnumField
template: configKind (int 0..7 OR 255 OR token "xprate"/
"droprate"/"honorrate"/"restedxp"/"realmtype"/
"worldflag"/"performance"/"security"/"misc") and
valueKind (int 0..3 OR token "float"/"int"/"bool"/
"string"). restartRequired accepts bool or int.

The polymorphic value field is preserved on disk by
emitting ALL THREE value carriers (floatValue,
intValue, strValue) regardless of valueKind — only the
matching one is meaningful at runtime, but the others
must round-trip byte-identically. JSON also includes
the activeValue derived field rendering only the
meaningful one per kind, so operators editing the
sidecar see the right value front-and-center.

intValue uses int64_t for the trade-gold-cap and other
high-magnitude configs that exceed uint32 range.

All 3 presets (rates/perf/security with mixed value
kinds: Float, Int, Bool, String) byte-identical
roundtrip OK. CLI flag count 1267 -> 1269.
This commit is contained in:
Kelsi 2026-05-10 02:59:53 -07:00
parent 441ca0d139
commit 695c22b274
3 changed files with 192 additions and 0 deletions

View file

@ -2443,6 +2443,10 @@ void printUsage(const char* argv0) {
std::printf(" Print WCFG entries (id / configKind / valueKind / restart-required / active value rendered per kind / name)\n");
std::printf(" --validate-wcfg <wcfg-base> [--json]\n");
std::printf(" Static checks: id+name required, configKind 0..7 OR 255 Misc, valueKind 0..3, no duplicate configIds OR config names (server name-based lookups would be ambiguous), Bool valueKind requires intValue 0/1; warns on cross-field bleed (Float kind with non-zero intValue, etc.)\n");
std::printf(" --export-wcfg-json <wcfg-base> [out.json]\n");
std::printf(" Export binary .wcfg to a human-editable JSON sidecar (defaults to <base>.wcfg.json; emits configKind + valueKind as int+name; ALL three value carriers (floatValue/intValue/strValue) plus an activeValue derived field rendering only the meaningful one per kind)\n");
std::printf(" --import-wcfg-json <json-path> [out-base]\n");
std::printf(" Import a .wcfg.json sidecar back into binary .wcfg (configKind int OR \"xprate\"/\"droprate\"/\"honorrate\"/\"restedxp\"/\"realmtype\"/\"worldflag\"/\"performance\"/\"security\"/\"misc\"; valueKind int OR \"float\"/\"int\"/\"bool\"/\"string\"; restartRequired bool OR int)\n");
std::printf(" --catalog-pluck <wXXX-file> <id> [--json]\n");
std::printf(" Extract one entry by id from any registered catalog format. Auto-detects magic, dispatches to the per-format --info-* handler internally, then prints just the matching entry. Primary-key field is auto-detected (first *Id field, or first numeric)\n");
std::printf(" --catalog-find <directory> <id> [--magic <WXXX>] [--json]\n");