aboutsummaryrefslogtreecommitdiff
path: root/internal/game/game.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/game.go')
-rw-r--r--internal/game/game.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/game/game.go b/internal/game/game.go
index 8bf289b..d3bb391 100644
--- a/internal/game/game.go
+++ b/internal/game/game.go
@@ -57,6 +57,16 @@ type Game struct {
guardWatchTimers map[string]int
farmTickCounter int
hackingStates map[string]*hacking.Session
+ safespotMu sync.Mutex
+ safespotStates map[string]*SafespotState
+}
+
+type SafespotState struct {
+ Active bool
+ ObjectDefID string
+ ObjectIndex int
+ RoomID int
+ HideCountdown int
}
func New(dataDir string, colorConfig *config.ColorsConfig, valConfig config.ValidationConfig) *Game {
@@ -81,6 +91,7 @@ func New(dataDir string, colorConfig *config.ColorsConfig, valConfig config.Vali
pendingDepletions: nil,
guardWatchTimers: make(map[string]int),
hackingStates: make(map[string]*hacking.Session),
+ safespotStates: make(map[string]*SafespotState),
}
g.CourseStore.LoadAll()
g.LoadMods()
@@ -98,6 +109,13 @@ func (g *Game) SetHub(hub *net.Hub) {
delete(g.loggedInChars, p.Name)
g.charsMu.Unlock()
delete(g.hackingStates, p.Name)
+ g.safespotMu.Lock()
+ if ss, ok := g.safespotStates[p.Name]; ok {
+ g.safespotMu.Unlock()
+ g.forceLeaveSafespot(sess, p, ss, "")
+ } else {
+ g.safespotMu.Unlock()
+ }
}
})
}