aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/manager.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-18 17:48:26 -0400
committerhistoria <[not public]>2026-09-18 17:48:26 -0400
commit8fe9e3c3fef0049df82281a62afe35dda516dfe2 (patch)
treedd269f2c0710f334e19f00a191260ebc46284a90 /internal/casino/manager.go
parent194164a77eb4f2479b94c19e6f0e1278ab608781 (diff)
downloadthehouseoficarus-8fe9e3c3fef0049df82281a62afe35dda516dfe2.tar.gz
fix: close combat ghost, admin traversal, login throttle, journal double-pay, and quality/economy gaps
Diffstat (limited to 'internal/casino/manager.go')
-rw-r--r--internal/casino/manager.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/internal/casino/manager.go b/internal/casino/manager.go
index 8b87147..b1281b2 100644
--- a/internal/casino/manager.go
+++ b/internal/casino/manager.go
@@ -409,20 +409,28 @@ func (m *Manager) RekeyRooms(idMap map[int]int) {
// refunded through each game's refundAll before the entries drop.
func (m *Manager) EvictRoom(roomID int) []Event {
prefix := fmt.Sprintf("%d:", roomID)
- var events []Event
+ // Snapshot the games under the manager lock, then refund OUTSIDE it:
+ // refundAll appends to the money journal and saves character files, and
+ // holding m.mu across that I/O blocks every casino command and Tick.
+ type evictable interface{ refundAll() []Event }
+ var evicted []evictable
m.mu.Lock()
for key, table := range m.tables {
if strings.HasPrefix(key, prefix) {
- events = append(events, table.refundAll()...)
+ evicted = append(evicted, table)
delete(m.tables, key)
}
}
for key, machine := range m.machines {
if strings.HasPrefix(key, prefix) {
- events = append(events, machine.refundAll()...)
+ evicted = append(evicted, machine)
delete(m.machines, key)
}
}
m.mu.Unlock()
+ var events []Event
+ for _, game := range evicted {
+ events = append(events, game.refundAll()...)
+ }
return events
}