diff options
Diffstat (limited to 'internal/world/world.go')
| -rw-r--r-- | internal/world/world.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/world/world.go b/internal/world/world.go index 7475ce0..a084f63 100644 --- a/internal/world/world.go +++ b/internal/world/world.go @@ -91,16 +91,24 @@ func (w *World) SeedGroundItems(roomID int) { w.mu.Unlock() return } - w.seeded[roomID] = true w.mu.Unlock() room, err := w.LoadRoom(roomID) if err != nil { + // Do NOT mark a room seeded before it loads: a dangling exit (or a + // not-yet-created room) would otherwise permanently disable its item + // spawns even after the room is fixed/created. return } w.mu.Lock() defer w.mu.Unlock() + // Re-check under the lock: a concurrent seed may have won the race while + // this call was loading. + if w.seeded[roomID] { + return + } + w.seeded[roomID] = true for _, s := range room.ItemSpawns { merged := false |
