diff options
Diffstat (limited to 'internal/game/sys_safespot_state.go')
| -rw-r--r-- | internal/game/sys_safespot_state.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/game/sys_safespot_state.go b/internal/game/sys_safespot_state.go index 1520bc7..32f57ec 100644 --- a/internal/game/sys_safespot_state.go +++ b/internal/game/sys_safespot_state.go @@ -67,6 +67,22 @@ func (m *SafespotManager) Delete(name string) bool { return ok } +// RekeyRooms remaps the stored RoomID of every safespot per idMap so a live +// room rename does not orphan a player's cover (the safespot lookup keys on +// the room ID and force-ejects on a miss). +func (m *SafespotManager) RekeyRooms(idMap map[int]int) { + if len(idMap) == 0 { + return + } + m.mu.Lock() + defer m.mu.Unlock() + for _, ss := range m.states { + if newID, ok := idMap[ss.RoomID]; ok && newID != ss.RoomID { + ss.RoomID = newID + } + } +} + // DecrementHideCountdown decrements the hide countdown for a player who is // transitioning from hiding to hidden. Returns (newCountdown, ok). A return of // ok=true with newCountdown > 0 means the player is still counting down; |
