From 87d08f0151e643951769e323995f1c5ed89ee200 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 18 Sep 2026 01:50:17 -0400 Subject: fix: harden economy recovery, shutdown concurrency, world validation, and inventory-loss paths --- internal/game/cmd_shutdown.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'internal/game/cmd_shutdown.go') diff --git a/internal/game/cmd_shutdown.go b/internal/game/cmd_shutdown.go index 0030649..9a57c6b 100644 --- a/internal/game/cmd_shutdown.go +++ b/internal/game/cmd_shutdown.go @@ -105,9 +105,16 @@ func (g *Game) broadcastLoggedIn(msg string) { if g.Hub == nil { return } - for _, other := range g.Hub.AllSessions() { - if other.Player != nil { - other.WriteLine(msg) + // Player pointers and option maps are owner-owned. Route the broadcast + // through the owner so it cannot race a login/logout or an option change + // from a raw shutdown goroutine (a concurrent map read/write would fatal + // the process before the final save). Drops harmlessly once the owner has + // stopped. + g.run(func() { + for _, other := range g.Hub.AllSessions() { + if other.Player != nil { + other.WriteLine(msg) + } } - } + }) } -- cgit v1.2.3