From 0e60567a7a0addb9421769ee7be7853bfa8788cb Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Sat, 19 Sep 2026 03:15:59 -0400 Subject: refactor: simplifcation, change how rooms are stored in player yaml, remove legacy code --- internal/game/lifecycle.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 internal/game/lifecycle.go (limited to 'internal/game/lifecycle.go') diff --git a/internal/game/lifecycle.go b/internal/game/lifecycle.go new file mode 100644 index 0000000..b39c805 --- /dev/null +++ b/internal/game/lifecycle.go @@ -0,0 +1,31 @@ +package game + +import ( + "thehouseoficarus/internal/net" + "thehouseoficarus/internal/player" +) + +// releaseCharacterRuntime tears down a character's live world presence when it +// leaves the world, whether through the quit countdown final tick or a hard +// disconnect. Keeping it in one place is what stops a per-player system from +// being cleaned up on one exit path and forgotten on another: the quit path +// used to leave a player occupying a safespot cover and holding a stale action. +// +// It deliberately does NOT detach the session registry, touch trigger +// sequences, persist the character, or resolve casino wagers. Callers own +// those because their ordering differs: disconnect must snapshot locked +// sequences (persistLockedOnDisconnect) before sequences are dropped, and +// resolves casino wagers through its deferral/refund path, while quit forfeits +// a mid-round stake immediately before saving. +func (g *Game) releaseCharacterRuntime(sess *net.Session, p *player.Player) { + if p == nil { + return + } + g.stopCombat(p.Name) + g.cancelRest(p.Name) + g.cancelAction(p) + if ss, ok := g.safespot.Get(p.Name); ok { + g.forceLeaveSafespot(sess, p, &ss, "") + } + delete(g.hackingStates, p.Name) +} -- cgit v1.2.3