diff options
| author | historia <[not public]> | 2026-09-18 01:50:17 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-18 01:50:17 -0400 |
| commit | 87d08f0151e643951769e323995f1c5ed89ee200 (patch) | |
| tree | dc42a0b30ebb5a00dd7ba505cc4eaa44f4f308bc /internal/casino/manager.go | |
| parent | 32a3c59cebf2a16277e54d715a67adfdbe00b456 (diff) | |
| download | thehouseoficarus-87d08f0151e643951769e323995f1c5ed89ee200.tar.gz | |
fix: harden economy recovery, shutdown concurrency, world validation, and inventory-loss paths
Diffstat (limited to 'internal/casino/manager.go')
| -rw-r--r-- | internal/casino/manager.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/casino/manager.go b/internal/casino/manager.go index 78e26b0..4798217 100644 --- a/internal/casino/manager.go +++ b/internal/casino/manager.go @@ -3,6 +3,7 @@ package casino import ( "fmt" "math/rand" + "reflect" "sort" "strings" "sync" @@ -41,7 +42,10 @@ func (m *Manager) EnsureMachine(roomID int, cfg MachineConfig) *Machine { m.mu.Lock() defer m.mu.Unlock() if machine := m.machines[key]; machine != nil { - if machine.Config == cfg { + // DeepEqual (not ==) so the *bool rule fields compare by value; + // == would treat every freshly parsed config as different and + // discard an idle machine on every room load. + if reflect.DeepEqual(machine.Config, cfg) { return machine } if machine.idle() { @@ -74,7 +78,7 @@ func (m *Manager) EnsureTable(roomID int, cfg TableConfig) *Table { m.mu.Lock() defer m.mu.Unlock() if table := m.tables[key]; table != nil { - if table.Config == cfg { + if reflect.DeepEqual(table.Config, cfg) { return table } if table.idle() { @@ -308,6 +312,10 @@ func (m *Manager) RefundAll() []Event { // (oldID -> newID): both the manager's map keys and each game's RoomID. // Game state (wagers, rounds) is preserved — the games continue in the // renamed room. Uses delete-all-then-set-all so a swap cannot clobber. +// +// Callers MUST run on the owner goroutine: each game's RoomID is mutated +// without taking that game's own lock, which is safe only because Tick and +// every command are owner-serialized too. func (m *Manager) RekeyRooms(idMap map[int]int) { if len(idMap) == 0 { return |
