aboutsummaryrefslogtreecommitdiff
path: root/internal/game/session_registry.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/game/session_registry.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/game/session_registry.go')
-rw-r--r--internal/game/session_registry.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/game/session_registry.go b/internal/game/session_registry.go
index c4f5d67..cf4e8df 100644
--- a/internal/game/session_registry.go
+++ b/internal/game/session_registry.go
@@ -23,3 +23,17 @@ func (g *Game) detachSession(name string) {
g.queue.ClearPlayer(name)
}
}
+
+// sessionRegistered reports whether sess is still the live session for name.
+// Tick subscribers that can outlive a disconnect/re-login must consult this
+// before acting on a session that is no longer in the world (a detached
+// combat or logout subscriber would otherwise keep saving a ghost).
+func (g *Game) sessionRegistered(sess *net.Session, name string) bool {
+ if sess == nil || sess.Player == nil {
+ return false
+ }
+ g.charsMu.Lock()
+ current := g.loggedInChars[name]
+ g.charsMu.Unlock()
+ return current == sess
+}