fix(save): restore visited set before setting current room; strengthen null-tolerance test

Reorder apply() so visitedRoomIds is restored before setCurrentRoom() is
called, ensuring the current room is never accidentally stripped from the
visited set by the subsequent clear(). Also adds a post-condition assertion
to applyToleratesMissingCollections that proves null roomItemIds leaves
room item tables empty after apply.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 14:42:15 +02:00
parent 3be1036142
commit 3c7c9d2ad4
2 changed files with 3 additions and 1 deletions

View File

@@ -95,9 +95,9 @@ public final class SaveCodec {
}
// 3. Player position + visited + gold.
p.setCurrentRoom(requireRoom(w, data.currentRoomId()));
p.getVisitedRoomIds().clear();
p.getVisitedRoomIds().addAll(data.visitedRoomIds());
p.setCurrentRoom(requireRoom(w, data.currentRoomId()));
p.setGold(data.gold());
// 4. Flags, quests, turn.