feat(editor): add WCRE JSON round-trip (--export/--import-wcre-json)

Dual encoding for ccImmunityMask: int OR "+"-joined
token string composed from {root, snare, stun, fear,
sleep, silence, charm, disarm, polymorph, banish,
knockback, interrupt, taunt, bleed} plus the shorthands
"all" (0xFFFF, typical raid-boss profile) and "none" (0).
The "+" syntax matches what ccImmunityString emits on
info display so the round-trip uses identical syntax.

Per-bit token form is much more useful than raw bitfield
ints for hand-edited JSON — operators can read
"fear+silence" and immediately know the buff hits both
without doing 0x0028 & flag math.

mechanicImmunityMask remains a raw uint32 (no token form
yet — the underlying mechanic enum has 30+ values that
would clutter the token table; deferred until a real
authoring need surfaces).

All 3 presets (bosses/elites/immunities) byte-identical
roundtrip OK. Token-form import smoke-tested with
"fear+silence+polymorph" parsing to 0x0128 correctly.
CLI flag count 1167 -> 1169.
This commit is contained in:
Kelsi 2026-05-10 01:42:56 -07:00
parent f9cad45154
commit 3c8516f8d4
3 changed files with 198 additions and 0 deletions

View file

@ -2247,6 +2247,10 @@ void printUsage(const char* argv0) {
std::printf(" Print WCRE entries (id / creatureEntry / 6 school resists / phys%% / school-immune mask / CC-immune token list / name)\n");
std::printf(" --validate-wcre <wcre-base> [--json]\n");
std::printf(" Static checks: id+name+creatureEntry required, no duplicate resistIds OR creatureEntries (damage-calc lookup ambiguity); warns on resist<-100 (extreme negative >2x dmg taken), physicalResistPct>75 (clamped at runtime), schoolImmunityMask reserved bits 0xC0 set\n");
std::printf(" --export-wcre-json <wcre-base> [out.json]\n");
std::printf(" Export binary .wcre to a human-editable JSON sidecar (defaults to <base>.wcre.json; emits ccImmunityMask as both raw uint16 AND \"+\"-joined name string \"root+stun+fear\" / \"all\" / \"none\")\n");
std::printf(" --import-wcre-json <json-path> [out-base]\n");
std::printf(" Import a .wcre.json sidecar back into binary .wcre (ccImmunityMask int OR token string \"all\"/\"none\"/\"+\"-joined from {root,snare,stun,fear,sleep,silence,charm,disarm,polymorph,banish,knockback,interrupt,taunt,bleed})\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");