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") } }