aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_quit.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-18 15:16:44 -0400
committerhistoria <[not public]>2026-09-18 15:16:44 -0400
commit7eab582d8a8ee2af1a6baae7baf0696c7005de2e (patch)
tree902bbc8c6e39c9f62f779ca23267714ec420b9f5 /internal/game/cmd_quit.go
parent153acb7f644d755c45533b7c5311e3ffa47e8973 (diff)
downloadthehouseoficarus-7eab582d8a8ee2af1a6baae7baf0696c7005de2e.tar.gz
fix: harden triggers, economy, casino, world data, and admin/net paths
Diffstat (limited to 'internal/game/cmd_quit.go')
-rw-r--r--internal/game/cmd_quit.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/game/cmd_quit.go b/internal/game/cmd_quit.go
index bf46748..249df80 100644
--- a/internal/game/cmd_quit.go
+++ b/internal/game/cmd_quit.go
@@ -74,7 +74,16 @@ func (g *Game) beginQuitCountdown(sess *net.Session) {
g.broadcastAction(sess, "%s sits down to rest.", p.Name)
ticksLeft := 10
- id := g.SubscribeTicks(engine.ToTicks(1), func() bool {
+ var id uint64
+ id = g.SubscribeTicks(engine.ToTicks(1), func() bool {
+ // The engine snapshots its subscribers before firing them, so this
+ // callback can still run once after cancelRest unsubscribes it. Bail
+ // out unless this is still the registered countdown, so a quit
+ // cancelled on the final tick never force-disconnects the player (and
+ // never forfeits a committed casino wager).
+ if g.restTimers[p.Name] != id {
+ return false
+ }
switch ticksLeft {
case 10:
sess.WriteLine("You sit down to rest...")