blob: 99e8b4f4e1f0ade5905bc40aa471ad681aaf59ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package game
import (
"testing"
"thehouseoficarus/internal/config"
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/player"
)
// TestQuitCountdownClearsSafespot: the safespot predicates are room-agnostic,
// so logging out while covered used to leave the character registered as a
// phantom occupant of the cover (blocking a max_occupants cover for an offline
// player) and resume hazard immunity on the next login. The quit path must
// release cover just like every other room-changing path.
func TestQuitCountdownClearsSafespot(t *testing.T) {
dir := t.TempDir()
seedWorld(t, dir)
colors := &config.ColorsConfig{}
g := New(dir, colors, colors, config.ValidationConfig{}, 1)
g.SetHub(net.NewHub())
sess := &net.Session{Player: player.New("alice"), Conn: &casinoTestConn{}}
sess.Player.Credits = 1000
g.charsMu.Lock()
g.loggedInChars["alice"] = sess
g.charsMu.Unlock()
g.safespot.Set("alice", SafespotState{Active: true, ObjectDefID: "rock", ObjectIndex: 0, RoomID: 1})
if !g.isSafespotted("alice") {
t.Fatal("safespot not active before quit")
}
g.doQuit(sess)
for i := 0; i < 15 && sess.Player != nil; i++ {
g.Ticks.Tick()
}
if sess.Player != nil {
t.Fatal("quit countdown never completed")
}
if g.safespot.Has("alice") {
t.Fatal("safespot state survived logout")
}
if g.isSafespotted("alice") {
t.Fatal("player still counts as safespotted after logout")
}
}
|