blob: 7bd670803c52b2860fe83cbb1ecb646d8eac5fab (
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
|
package game
import "testing"
// TestDisconnectHardRemoveEndsCombat pins the P0 fix: a session hard-removed
// while a fight is live must have that fight ended. Otherwise the combat tick
// subscribers (keyed by character name) keep attacking and saving a detached
// Player, which duplicates items/credits on death and can permanently lock a
// finishing_blow mob.
func TestDisconnectHardRemoveEndsCombat(t *testing.T) {
h := newHarness(t)
h.seedAccount("alice")
h.seedCharacter("alice", "alice")
sess, _ := h.connect("alice")
p := sess.Player
h.g.RunOnOwner(func() {
sess.StartDisconnect(1)
h.g.Combat.Enter(p.Name, "skeleton")
for i := 0; i < disconnectCombatGraceTicks+5 && len(h.g.Hub.AllSessions()) > 0; i++ {
h.g.DisconnectTick()
}
})
if len(h.g.Hub.AllSessions()) != 0 {
t.Fatal("session was not hard-removed")
}
if h.g.Combat.Get(p.Name) != nil {
t.Fatal("combat survived the hard remove; a ghost fight would keep saving the detached character")
}
}
|