v0.57.4 - Editor Hotfix + Companion & NPC Bag Persistence
Fixes after v0.57.3's editor shipped with a few rough edges, plus a structural follow-up to the "my item disappeared from my companion" bug from the v0.57.2 cycle. Five passes of audit, locked in with regression tests.
The Editor Actually Saves Now
"I set my character to level 50 and added 500 stats in each field. On reload, only level persisted."
Confirmed within hours of v0.57.3 shipping. Two bugs were stacked on top of each other:
- JSON options mismatch. The editor wrote saves with default property names (PascalCase) but the game reads with camelCase. Result: every edit was silently discarded by the game's loader, then overwritten by the next autosave.
- Stat edits wrote the wrong fields. The editor changed Strength, MaxHP, etc. But the game's load path calls RecalculateStats(), which resets every derived stat from its Base* counterpart and then adds equipment bonuses on top. Edits survived the file round-trip but got wiped the instant the game loaded.
Both fixed. The editor now writes the same JSON format FileSaveBackend uses, and stat edits target the Base* fields so they actually take effect.
Long Menus Finally Scroll
"The NPC list has 60 characters but only shows the last 40 - the first 20 scroll off the top with no way to see them."
RunArrowMenu was rendering every label on every redraw, which pushed early rows into terminal scrollback where ReadKey couldn't reach them. Now menus viewport-scroll: show a window of rows sized to your terminal, with "N more above" / "N more below" indicators, a position counter, and PgUp/PgDn/Home/End support. Number shortcuts still work and scroll the viewport to your target.
Companion Bags Survive Save and Load
"I gave stuff to Mira in the dungeon and now her bag is empty." - Lumina
The v0.57.2 Party Inventory Viewer let players SEE items companions were carrying, but the underlying Companion class had no inventory field. Items transferred via combat [T] / Home / Team Corner / dungeon viewer worked on screen until the dungeon reload or logout discarded the wrapper.
Structural fix. Companion now holds its own Inventory list, shared by reference with the Character wrapper so every take/give on the wrapper mutates the actual bag. Combat transfers to companions now flush the save immediately, so a mid-dungeon disconnect can't lose the item.
NPC Teammate Bags Also Survive Now
Same bug class on a different save path. Non-companion NPCs - spouses, recruited citizens, party members added via Team Corner - use NPCData serialization, which had no Inventory field at all. Items transferred to them evaporated every save.
Same shape of fix: added Inventory to NPCData, wired it through every save and restore path (single-player save, MUD server world_state, in-dungeon orphan sync). In MUD mode the world sim persists NPC state every tick, so this now runs cleanly on the live server as well.
Companion Permadeath Returns the Whole Bag
When a companion died permanently (KillCompanion or the Moral Paradox trigger), the game carefully returned their equipped gear to the player but completely ignored their personal bag. If a companion died with potions, herbs, or dungeon loot in their pack, those items evaporated.
Now the death handler returns both equipped gear AND bag contents, respecting the player's 50-item cap. Items past the cap are explicitly reported as "dropped on the battlefield" rather than silently disappearing.
Editor UX Pass
Several places in the editor asked users to know internal integer IDs (item IDs, spell IDs, monster abilities). Nobody knows those. Every raw-ID prompt is now an arrow-key picker:
- Inventory add/equip/unequip/remove - pick from a scrollable item list with slot and name filters
- Equip for NPC/companion - filtered to only items that fit the chosen slot
- Monster ability tier editor - pick from the actual MonsterAbilities enum instead of typing names that silently fell through at runtime
- Skill proficiency - real skill IDs (basic_attack, class abilities, class spells) instead of a placeholder vocabulary that wrote dead keys
- Language setting - pick from actually-installed languages instead of free text
- Companion / artifact / old god / quest / ability grants - enum-backed pickers across the board
Achievement Editing Removed
Granting achievements through the editor is now disabled on every platform. Two reasons:
- The save-side grant is inert anyway - the game's achievement system is condition-driven at runtime, and a dictionary edit doesn't trigger the unlock hooks or grant the rewards.
- The GameData/achievements.json editor let users edit the built-in "first_steps" achievement to pay out 100,000 gold, which the game would then unlock normally via the runtime TryUnlock path - AND fire the matching Steam achievement. Since this would be cheating on the Steam leaderboards, that whole editor screen is disabled.
Modders who want custom achievements can still hand-edit achievements.json directly. The editor just doesn't facilitate the leaderboard-cheating path.
Warnings Where They Were Needed
Several editor sections let you write values the game ignored or soft-locked on. Each now shows a clear warning up front:
- NPC edits only apply to single-player / Steam saves. In online mode the world_state database overrides them.
- Quest status edits aren't re-validated by the game - marking a quest "Completed" via the editor doesn't re-fire rewards or objective hooks. Treat as cosmetic.
- Old God states load with no prerequisite enforcement. Setting Manwe defeated while Maelketh is dormant is a valid save but can soft-lock dungeon events and endings. Floor order now shown so you know what you're skipping.
- Relationship edits affect dialogue tone only. Marriages, lovers, and exes live in the separate RomanceTracker and aren't touched by editing the relationship score.
- King / Immortal / Team / Guild fields in single-player saves don't sync to online mode - those live in server SQLite and are authoritative.
- Spell grant on non-caster classes now warns and requires confirmation. Warriors, Barbarians, Rangers, Assassins, Jesters, Paladins, Bards, and Alchemists have no mana pool, so granted spells can't be cast.
- NG+ cycle edits now offer to also adjust CycleExpMultiplier so you don't face cycle-5 monsters with cycle-1 XP rates.
Input Validation
- Gold, BankGold, BankLoan, BankInterest, RoyalLoanAmount - all now bounded at 0 so negative values can't confuse shop/loan/interest math.
- Chivalry and Darkness capped at the game's 0-1000 range so editor values match what the game will clamp to on the next modification.
- Equipment custom-item fields - WeaponPower, ArmorClass, ShieldBonus, Value bounded at 0; BlockChance clamped 0-100.
- Equipment ID validation at save time refuses to write items below the 200000 modded-ID range (prevents silent drops when someone hand-edits the JSON).
- File-name sanitization now matches the game's backend exactly, so saves with hyphens or apostrophes in the name (John-Smith, Fastfinge'1) no longer fail "file not found" in Clone/Delete/Restore.
Companion State Desync
The editor's companion Recruit action flipped IsActive=true on the per-companion record but didn't add the companion to the top-level ActiveCompanionIds list, which is the list the game actually reads. Companions looked recruited but never joined the active party on load. Reviving a companion similarly left a stale FallenCompanions entry that kept them "permanently dead" in gameplay UI.
Fixed: Recruit / Dismiss / Revive all sync the bool AND the list together. Recruit refuses to add a 5th companion when the 4-slot cap is full rather than silently producing a ghost active.
Dynamic equipment (dungeon loot, IDs 10000+) now also registers into the editor's equipment database on load, so equipped loot items show their actual names in the equip views instead of "".
Forensic Logging
Every step of a companion or NPC bag transfer now writes to logs/debug.log under two greppable categories: COMPANION_BAG and NPC_BAG.
When someone reports "I gave X to Y and it disappeared," the logs answer it immediately:
- Did the transfer happen? (TRANSFER line)
- Was it in the save when the game serialized? (Serialize SAVING line with item name)
- Was it restored when the game loaded? (Deserialize / RESTORED line with same count)
- Did the permadeath path catch the bag? (PERMADEATH line with equipped/bag/dropped counts)
- Did the MUD orphan sync copy it across? (Orphan sync line)
Logs only fire when there's something to report and cap item names at 3-5 per line to avoid flooding on huge bags.
Regression Tests
Seven new tests in the save round-trip suite (595/595 passing) lock the fixes in forever:
- CompanionSaveInfo round-trip preserves Inventory
- Companion inventory preserves LootEffects (CON/INT/AllStats bonuses on looted items)
- Legacy saves without the Inventory field load cleanly as empty lists
- NPCData round-trip preserves Inventory
- NPC inventory preserves LootEffects
- Legacy NPC saves without Inventory field also load clean
- Companion and NPC inventory fields don't alias (a refactor that collapsed them would corrupt saves)
If any of these ever regress, the test suite fails loudly.
The Short Version
v0.57.3's editor works correctly now. Save and load actually persist your edits. Long lists scroll instead of disappearing off the top. Items given to companions and NPCs persist through save/load cycles, survive permadeath, and are fully traceable in the debug log if they ever go missing. Steam achievement integrity is protected. The raw-ID-prompt UX is replaced with pickers across the board.
