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 80a5112508
commit 1172f7c3fd
2 changed files with 3 additions and 1 deletions

View File

@@ -101,5 +101,7 @@ class SaveCodecTest {
GameSession dst = freshWorld("slot-a");
// Should not throw NPE; world items remain in their default positions or cleared
org.junit.jupiter.api.Assertions.assertDoesNotThrow(() -> SaveCodec.apply(data, dst));
// Post-condition: applying a save with null/empty roomItemIds clears all room item tables.
assertThat(dst.getWorld().getRooms().get("kitchen").findItem("lamp")).isEmpty();
}
}