diff options
Diffstat (limited to 'internal/game/cmd_hide.go')
| -rw-r--r-- | internal/game/cmd_hide.go | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/internal/game/cmd_hide.go b/internal/game/cmd_hide.go index 9f567ca..52ebaea 100644 --- a/internal/game/cmd_hide.go +++ b/internal/game/cmd_hide.go @@ -54,9 +54,7 @@ func (g *Game) executeHide(sess *net.Session, args []string, rawInput string) { return } - g.safespotMu.Lock() - existingSS, alreadyHiding := g.safespotStates[p.Name] - g.safespotMu.Unlock() + existingSS, alreadyHiding := g.safespot.Get(p.Name) if alreadyHiding && existingSS.Active { if existingSS.ObjectDefID == objDef.ID && existingSS.ObjectIndex == instances[0].Index { @@ -99,15 +97,13 @@ func (g *Game) executeHide(sess *net.Session, args []string, rawInput string) { hideCountdown = 4 } - g.safespotMu.Lock() - g.safespotStates[p.Name] = &SafespotState{ - Active: true, - ObjectDefID: objDef.ID, - ObjectIndex: instances[0].Index, - RoomID: p.RoomID, - HideCountdown: hideCountdown, - } - g.safespotMu.Unlock() + g.safespot.Set(p.Name, SafespotState{ + Active: true, + ObjectDefID: objDef.ID, + ObjectIndex: instances[0].Index, + RoomID: p.RoomID, + HideCountdown: hideCountdown, + }) p.ActionState = &ActionState{Type: ActionHiding, TargetName: objDef.Name} @@ -119,9 +115,7 @@ func (g *Game) executeHide(sess *net.Session, args []string, rawInput string) { func (g *Game) executeUnhide(sess *net.Session, args []string, rawInput string) { p := sess.Player - g.safespotMu.Lock() - ss, ok := g.safespotStates[p.Name] - g.safespotMu.Unlock() + ss, ok := g.safespot.Get(p.Name) if !ok || !ss.Active { sess.WriteLine("You're not hiding behind anything.") @@ -129,9 +123,7 @@ func (g *Game) executeUnhide(sess *net.Session, args []string, rawInput string) } if ss.HideCountdown > 0 { - g.safespotMu.Lock() - delete(g.safespotStates, p.Name) - g.safespotMu.Unlock() + g.safespot.Delete(p.Name) p.ActionState = nil sess.WriteLine("You stop trying to hide.") return |
