commit 71fdb960a7756e2ebe196158e871759cb24a60c6
parent 1b9d3806e568bc0c574fa09fb283adaf6adf4382
Author: anon <anon@example.com>
Date: Thu, 29 Oct 2026 01:50:59 +0000
Persist corpse expiry before native removal
Diffstat:
9 files changed, 334 insertions(+), 47 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -64,8 +64,8 @@ survives restart without respawning. Returning that exact book to its issuing
booth now completes the fixed contract and atomically grants authored cash
and a selected-quality equipment reward. The small reward pool is provisional;
new missions now select the five Leets' level and scalable reward QL from player
-level and difficulty, using explicitly provisional later measurements. Only
-levels 1 and 2 currently have admitted combat profiles; unsupported requests
+level and difficulty, using explicitly provisional later measurements. Leet
+levels 1..5 currently have admitted combat profiles; unsupported requests
return no offer without charging. See [mission levels](docs/mission-levels.md).
Indoor combatants now use shared body/collision probes to plan bounded detours;
native movement timing still needs refinement. An earned level-2 Enforcer can
@@ -3014,6 +3014,15 @@ and server restarts. Turn every reproduced bug into a focused regression test.
team-loot runtime pass restored server ownership and a native corpse object,
but could not locate clickable remains. Distinguish camera/fixture placement
from mesh creation, original-actor prerequisites and interest replay order.
+- [x] Commit corpse expiry before native removal. Check: unclaimed loot and filled
+ bags retire atomically before close/delete packets; failed or ignored writes
+ and failed COMMIT preserve state and retry. Cover both respawn/expiry orderings,
+ already taken items, identity retention and cold recovery. An ordinary native
+ Stalker corpse accepted pickup after cold replay without the original actor;
+ a second kill retained its unclaimed item and open window through a scoped
+ database fault, then removed both after a successful retry. The broader corpse
+ audit and earlier team-fixture picking uncertainty remain open. See
+ [corpse expiry](docs/corpse-loot.md#corpse-expiry).
- [ ] [P1] Audit consumables and skill locks. Cover self/friendly/invalid targets,
resource boundaries, combat and posture restrictions, last-charge removal,
overlapping locks, concurrent requests and restart during a lock.
diff --git a/docs/corpse-loot.md b/docs/corpse-loot.md
@@ -14,9 +14,10 @@ remaining production loot tables are unresolved.
version 7. The native reader is `kkr.dll` `sub_360AF9C0`; activation is
`sub_360AFCB0`. The original character identity appears inside the body.
The corpse is a separate object, and activation hides the original actor.
-Prerequisite `sub_360AFBC0` waits for the original actor's death state. The
-creature must receive the correct death animation key 6000, as described in
-[the combat protocol](protocol.md), before this transition can finish.
+Prerequisite `sub_360AFBC0` checks the original actor's death state. The warm
+transition needs the correct death animation key 6000, as described in
+[the combat protocol](protocol.md). Cold replay without an original actor update
+is separately verified for the Stalker below.
The decoded body has this order; integers are network-order uint32 unless
specified otherwise:
@@ -266,6 +267,16 @@ expiry queue entry are removed. A pending respawn retains the source needed
to create a fresh life if the corpse's deadline comes first; an existing
replacement has a separate identity and remains untouched.
+Before sending those packets, one SQLite transaction deletes every unclaimed
+item's placement and record, including the contents of portable bags, and
+retires the corpse. If a replacement is still pending, its hidden source and
+deadline remain stored without corpse state; otherwise the source row is
+deleted. Taken items are outside this transaction. Failed or ignored writes
+and failed commits roll back the entire operation, retain the in-memory corpse
+and open handles, and retry on a subsequent cleanup tick. No native removal is
+published before a successful commit, and cleanup does not depend on a later
+periodic checkpoint or respawn.
+
Use and pickup also check the deadline directly, rejecting expired requests
before the cleanup tick. Cleanup and pickup share the normal update/state
lock order, so a competing pickup either commits ownership first or finds no
@@ -277,6 +288,40 @@ reentry cannot recreate an expired actor or recover its contents.
for two observers, stale requests before and after cleanup, pickup persistence,
concurrent expiry/pickup, both timer orderings, fixed and roaming creatures,
offline cleanup, loading clients and reentry.
+`server/corpse_expiry_outcome_test.go` additionally reads SQLite at the first
+native close packet, checks both respawn/expiry orderings, injects failed and
+ignored placement/item/source writes and failed commits, and verifies retries
+and cold recovery. Filled-bag failures preserve both the bag and its contents;
+successful expiry removes them together without reusing their identities.
+
+An ordinary level-2 Tiny Stalker kill also verified cold replay in the GPU-backed
+WASM client: the server restarted with almost 178 seconds of the normal lifetime
+remaining, sent the separate corpse without an original living-actor update,
+and the rendered remains accepted right-click Use. Native pickup transferred
+Monster Parts item 137, QL3, Count 1 into player 5's inventory. Expiry closed its
+empty window; reconnect preserved that item and the living replacement. This
+establishes the outdoor Stalker path. The earlier team fixture's unlocated
+remains and the general activation prerequisites still need their own checks.
+
+A second ordinary kill left item 138, QL2 Monster Parts, unclaimed while a scoped
+SQLite trigger blocked only that corpse's retirement for twelve seconds after
+expiry. All 47 failed cleanup attempts retained the item, corpse and native loot
+window. Removing the trigger allowed one committed cleanup followed by native
+close and both deletions. The wire capture contains no removal during the fault.
+The earlier taken item and all 62 pre-existing item records remained intact.
+Another cold server restart and native reconnect retained all 21 owned instances,
+the same 62 total records, 1075 current-level XP, 8309 IP and 40 credits. The
+expired corpse and its unclaimed item stayed absent; item identity 138 remained
+reserved. Neither native phase had a page exception or adapter failure; the
+console contained two generic HTTP 404 errors in each phase.
+Captures, SQLite snapshots and the fault/retry checks are retained under
+`local/corpse-replay/`; neither run required a client or corpse-packet workaround.
+
+The maintained Go suite passed 1,685 root tests / 16,575 results with no test
+skips. Focused race runs passed 14 roots / 35 results in total, and vet passed.
+All 22 new regression results fail against the previous committed expiry and
+respawn implementation through a Go overlay. The source hashes, test reports
+and native verification are recorded in `local/corpse-replay/verification.json`.
Two published WASM clients checked the full 180-second lifetime after a real
100-HP Leet kill. Corpse 1000000 held untaken fixture item 101 while the owner
diff --git a/server/corpse_expiry.go b/server/corpse_expiry.go
@@ -1,6 +1,8 @@
package main
import (
+ "fmt"
+ "log"
"slices"
"time"
)
@@ -17,6 +19,11 @@ func (server *server) advanceCorpseExpiry(now time.Time) {
server.corpseExpiry = append(server.corpseExpiry, corpse)
continue
}
+ if err := server.saveCorpseExpiry_locked(corpse, now); err != nil {
+ log.Printf("Corpse expiry: %v", err)
+ server.corpseExpiry = append(server.corpseExpiry, corpse)
+ continue
+ }
// Close the registered container before deleting the corpse and hidden actor.
for _, client := range server.clients {
@@ -41,3 +48,74 @@ func (server *server) advanceCorpseExpiry(now time.Time) {
server.mutex.Unlock()
server.sendCombatUpdates(updates)
}
+
+func (server *server) saveCorpseExpiry_locked(corpse *character, now time.Time) error {
+ db, err := server.database()
+ if err != nil {
+ return err
+ }
+ tx, err := db.Begin()
+ if err != nil {
+ return err
+ }
+ defer tx.Rollback()
+
+ // Destroy only remaining corpse loot and the contents of its portable bags.
+ var removed []uint32
+ for _, item := range corpse.corpse.items {
+ removed = append(removed, item.ID)
+ for _, contained := range server.items[item.ID].Slots {
+ if contained != nil {
+ removed = append(removed, *contained)
+ }
+ }
+ }
+ // Remove locations before bag records that their contents referenced.
+ for _, id := range removed {
+ var deleted uint32
+ if err := tx.QueryRow("DELETE FROM item_locations WHERE item_id=? RETURNING item_id", id).Scan(&deleted); err != nil {
+ return fmt.Errorf("expire item %d placement: %w", id, err)
+ }
+ }
+ for _, id := range removed {
+ var deleted uint32
+ if err := tx.QueryRow("DELETE FROM items WHERE id=? RETURNING id", id).Scan(&deleted); err != nil {
+ return fmt.Errorf("expire item %d: %w", id, err)
+ }
+ }
+
+ // A pending replacement retains a hidden source; otherwise retire the actor too.
+ var respawnAt time.Time
+ for _, pending := range server.npcRespawns {
+ if pending.npc == corpse {
+ respawnAt = pending.at
+ break
+ }
+ }
+ state := corpse.worldState(false, respawnAt)
+ state.HasCorpse, state.Corpse = false, corpseState{}
+ if respawnAt.IsZero() {
+ var deleted uint32
+ if err := tx.QueryRow("DELETE FROM characters WHERE id=? RETURNING id", corpse.id).Scan(&deleted); err != nil {
+ return fmt.Errorf("expire NPC %d: %w", corpse.id, err)
+ }
+ } else if err := writeNPCState_locked(tx, corpse, &state); err != nil {
+ return err
+ }
+ if err := tx.Commit(); err != nil {
+ return err
+ }
+
+ // Publish cache changes only after the complete retirement is durable.
+ corpse.corpse = nil
+ for _, id := range removed {
+ delete(server.items, id)
+ delete(server.itemPlacements, id)
+ }
+ if respawnAt.IsZero() {
+ delete(server.savedNPCs, corpse.id)
+ } else {
+ server.rememberNPCOutcome_locked(corpse, state, now)
+ }
+ return nil
+}
diff --git a/server/corpse_expiry_outcome_test.go b/server/corpse_expiry_outcome_test.go
@@ -0,0 +1,184 @@
+package main
+
+import (
+ "context"
+ "database/sql"
+ "encoding/binary"
+ "fmt"
+ "testing"
+ "time"
+)
+
+type corpseExpiryCommitConn struct {
+ combatTestConn
+ db *sql.DB
+ observed bool
+ visible int
+ items int
+ location int
+ err error
+}
+
+func (conn *corpseExpiryCommitConn) Write(packet []byte) (int, error) {
+ if !conn.observed && binary.BigEndian.Uint32(packet[16:20]) == 0x2049527c {
+ conn.observed = true
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+ defer cancel()
+ conn.err = conn.db.QueryRowContext(ctx, `SELECT
+ EXISTS(SELECT 1 FROM npcs WHERE id=1000000 AND present=1),
+ EXISTS(SELECT 1 FROM items WHERE id=3),
+ EXISTS(SELECT 1 FROM item_locations WHERE item_id=3)`).Scan(&conn.visible, &conn.items, &conn.location)
+ }
+ return conn.combatTestConn.Write(packet)
+}
+
+func newCorpseExpiryOutcomeWorld(t *testing.T, pending bool) (*server, *corpseExpiryCommitConn, time.Time) {
+ t.Helper()
+ world, _ := newKillExperienceWorld(t, "unarmed")
+ world.combatRoll = func(uint32) uint32 { return 0 }
+ if pending {
+ profile := *world.characters[1000000].combatProfile
+ profile.CorpseSeconds = 1
+ world.characters[1000000].combatProfile = &profile
+ }
+ attackForExperience(t, world, "unarmed")
+ if granted, err := world.grantItem_locked(world.characters[1], 99719); err != nil || !granted {
+ t.Fatal(granted, err)
+ }
+ if err := world.handleLootUse(world.clients[1], lootUseRequest(1)); err != nil {
+ t.Fatal(err)
+ }
+ if !pending {
+ world.advanceNPCRespawns(world.npcRespawns[0].at)
+ }
+ output := &corpseExpiryCommitConn{db: world.db}
+ world.clients[1].conn = output
+ return world, output, world.characters[1000000].corpse.expiresAt
+}
+
+func TestCorpseExpiryCommitsBeforeClosingTheNativeContainer(t *testing.T) {
+ for _, pending := range []bool{false, true} {
+ t.Run(fmt.Sprintf("pending=%t", pending), func(t *testing.T) {
+ world, output, deadline := newCorpseExpiryOutcomeWorld(t, pending)
+
+ world.advanceCorpseExpiry(deadline)
+ cold := newTestInventoryServer(t)
+ cold.advanceNPCRespawns(deadline.Add(100 * time.Second))
+
+ if !output.observed || output.err != nil || output.visible != 0 || output.items != 0 || output.location != 0 {
+ t.Fatal("native expiry preceded durable corpse/item retirement", output.observed, output.err, output.visible, output.items, output.location)
+ }
+ if world.characters[1000000] != nil || cold.characters[1000000] != nil || cold.characters[1000001] == nil ||
+ cold.characters[1000001].health != 100 || world.items[3].Template != 0 || cold.items[3].Template != 0 ||
+ world.items[4].Template != 99719 || cold.items[4].Template != 99719 || cold.nextItem != 4 || cold.nextNPC != 1000002 {
+ t.Fatal("expiry restored the corpse, reused an identity or lost the unrelated owned item")
+ }
+ if len(output.packets) != 3 || world.clients[1].lootCorpse != 0 || world.clients[1].npcs[1000000] {
+ t.Fatal("committed expiry did not close and delete exactly once")
+ }
+ })
+ }
+}
+
+func TestCorpseExpiryWriteFailuresRetainStateAndRetry(t *testing.T) {
+ for _, pending := range []bool{false, true} {
+ for _, failure := range []string{"placement failure", "ignored placement", "item failure", "ignored item", "retirement failure", "ignored retirement", "commit"} {
+ t.Run(fmt.Sprintf("pending=%t/%s", pending, failure), func(t *testing.T) {
+ world, output, deadline := newCorpseExpiryOutcomeWorld(t, pending)
+ corpse := world.characters[1000000]
+ statement := "CREATE TRIGGER fail_expiry BEFORE DELETE ON item_locations WHEN OLD.item_id=3 BEGIN SELECT RAISE(FAIL,'expiry'); END"
+ switch failure {
+ case "ignored placement":
+ statement = "CREATE TRIGGER fail_expiry BEFORE DELETE ON item_locations WHEN OLD.item_id=3 BEGIN SELECT RAISE(IGNORE); END"
+ case "item failure":
+ statement = "CREATE TRIGGER fail_expiry BEFORE DELETE ON items WHEN OLD.id=3 BEGIN SELECT RAISE(FAIL,'expiry'); END"
+ case "ignored item":
+ statement = "CREATE TRIGGER fail_expiry BEFORE DELETE ON items WHEN OLD.id=3 BEGIN SELECT RAISE(IGNORE); END"
+ case "retirement failure", "ignored retirement":
+ operation, table := "DELETE", "characters"
+ if pending {
+ operation, table = "UPDATE OF present", "npcs"
+ }
+ result := "FAIL,'expiry'"
+ if failure == "ignored retirement" {
+ result = "IGNORE"
+ }
+ statement = fmt.Sprintf("CREATE TRIGGER fail_expiry BEFORE %s ON %s WHEN OLD.id=1000000 BEGIN SELECT RAISE(%s); END", operation, table, result)
+ case "commit":
+ statement = "CREATE TABLE expiry_commit_failure (id INTEGER REFERENCES items(id) DEFERRABLE INITIALLY DEFERRED); CREATE TRIGGER fail_expiry AFTER DELETE ON items WHEN OLD.id=3 BEGIN INSERT INTO expiry_commit_failure VALUES(9999); END"
+ }
+ if _, err := world.db.Exec(statement); err != nil {
+ t.Fatal(err)
+ }
+
+ world.advanceCorpseExpiry(deadline)
+
+ var items, locations, visible int
+ if err := world.db.QueryRow(`SELECT
+ (SELECT count(*) FROM items WHERE id=3),
+ (SELECT count(*) FROM item_locations WHERE item_id=3),
+ (SELECT present FROM npcs WHERE id=1000000)`).Scan(&items, &locations, &visible); err != nil {
+ t.Fatal(err)
+ }
+ if world.characters[1000000] != corpse || corpse.corpse == nil || len(corpse.corpse.items) != 1 ||
+ len(world.corpseExpiry) != 1 || world.clients[1].lootCorpse != 1000000 || !world.clients[1].npcs[1000000] ||
+ len(output.packets) != 0 || output.observed || items != 1 || locations != 1 || visible != 1 || world.items[3].Template != 42640 {
+ t.Fatal("failed expiry changed cached state, durable ownership or native handles")
+ }
+
+ // Retry the same deadline after removing the fault.
+ if _, err := world.db.Exec("DROP TRIGGER fail_expiry"); err != nil {
+ t.Fatal(err)
+ }
+ world.advanceCorpseExpiry(deadline.Add(time.Second))
+ world.advanceCorpseExpiry(deadline.Add(2 * time.Second))
+ cold := newTestInventoryServer(t)
+ if world.characters[1000000] != nil || cold.characters[1000000] != nil || len(world.corpseExpiry) != 0 ||
+ !output.observed || output.err != nil || output.visible != 0 || output.items != 0 || output.location != 0 ||
+ len(output.packets) != 3 || world.items[4].Template != 99719 || cold.items[4].Template != 99719 {
+ t.Fatal("expiry retry did not retire exactly once or preserve the unrelated item")
+ }
+ })
+ }
+ }
+}
+
+func TestCorpseExpiryContainedItemFailureRollsBackTheWholeBag(t *testing.T) {
+ for _, failure := range []struct{ name, sql string }{
+ {"ignored placement", "CREATE TRIGGER fail_bag_expiry BEFORE DELETE ON item_locations WHEN OLD.item_id=18 BEGIN SELECT RAISE(IGNORE); END"},
+ {"ignored item", "CREATE TRIGGER fail_bag_expiry BEFORE DELETE ON items WHEN OLD.id=18 BEGIN SELECT RAISE(IGNORE); END"},
+ {"commit", "CREATE TABLE bag_expiry_commit (id INTEGER REFERENCES items(id) DEFERRABLE INITIALLY DEFERRED); CREATE TRIGGER fail_bag_expiry AFTER DELETE ON items WHEN OLD.id=18 BEGIN INSERT INTO bag_expiry_commit VALUES(9999); END"},
+ } {
+ t.Run(failure.name, func(t *testing.T) {
+ world := newFilledLootContainerWorld(t, 143832)
+ corpse := world.characters[1000000]
+ world.corpseExpiry = []*character{corpse}
+ if err := world.handleLootUse(world.clients[1], lootUseRequest(1)); err != nil {
+ t.Fatal(err)
+ }
+ output := &combatTestConn{}
+ world.clients[1].conn = output
+ if _, err := world.db.Exec(failure.sql); err != nil {
+ t.Fatal(err)
+ }
+
+ world.advanceCorpseExpiry(time.Now())
+ cold := newTestInventoryServer(t)
+
+ if world.characters[1000000] != corpse || corpse.corpse == nil || len(output.packets) != 0 ||
+ len(world.items) != 2 || len(cold.items) != 2 || len(world.corpseExpiry) != 1 ||
+ world.clients[1].lootCorpse != 1000000 || cold.items[18].Count != 3 ||
+ world.items[17].Slots["slot_1"] == nil || *world.items[17].Slots["slot_1"] != 18 {
+ t.Fatal("contained-item failure retired the bag, contents or open container")
+ }
+ if _, err := world.db.Exec("DROP TRIGGER fail_bag_expiry"); err != nil {
+ t.Fatal(err)
+ }
+ world.advanceCorpseExpiry(time.Now())
+ cold = newTestInventoryServer(t)
+ if len(world.items) != 0 || len(cold.items) != 0 || cold.nextItem != 18 || len(output.packets) != 3 {
+ t.Fatal("bag expiry retry left orphan contents, reused IDs or repeated removal")
+ }
+ })
+ }
+}
diff --git a/server/corpse_expiry_test.go b/server/corpse_expiry_test.go
@@ -19,6 +19,9 @@ func newExpiringCorpseWorld(t *testing.T) (*server, *combatTestConn, time.Time)
killed := world.characters[1].nextAttack
world.advanceCombat(killed)
world.characters[1000000].corpse.items = []ownedItem{{ID: 17, Type: 51005, Template: 42640, Quality: 1, Count: 1}}
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
return world, conn, killed
}
diff --git a/server/loot_rights_test.go b/server/loot_rights_test.go
@@ -115,7 +115,7 @@ func TestLootRightsRejectFinalHitterAndSurviveCloseUntilExpiry(t *testing.T) {
world.handleLootUse(world.clients[2], ownerUse)
if world.clients[1].lootCorpse != 0 || world.clients[2].lootCorpse != 0 || world.characters[npc.id] != nil ||
- len(world.characters[1].inventory.Items) != 0 || world.characters[1].inventory.Credits != 0 || len(npc.corpse.items) != 0 ||
+ len(world.characters[1].inventory.Items) != 0 || world.characters[1].inventory.Credits != 0 || npc.corpse != nil ||
len(world.characters[2].inventory.Items) != 1 || world.characters[2].inventory.Items[0].ID != 17 {
t.Fatal("final hit, stale handle, closing or expiry transferred loot rights")
}
diff --git a/server/portable_container_loot_test.go b/server/portable_container_loot_test.go
@@ -94,11 +94,10 @@ func TestFilledLootContainerExpiryRemovesContents(t *testing.T) {
expires := corpse.corpse.expiresAt
world.advanceCorpseExpiry(expires)
- err := world.checkpointWorld(expires)
restarted := newTestInventoryServer(t)
- if err != nil || len(restarted.items) != 0 || restarted.nextItem != 18 {
- t.Fatal("expired container left recoverable orphan contents or reused IDs", err)
+ if len(restarted.items) != 0 || restarted.nextItem != 18 {
+ t.Fatal("expired container left recoverable orphan contents or reused IDs")
}
}
diff --git a/server/respawn.go b/server/respawn.go
@@ -82,42 +82,15 @@ func (server *server) saveNPCRespawn_locked(source, npc *character, now time.Tim
defer tx.Rollback()
sourceState := source.worldState(server.characters[source.id] != nil, time.Time{})
state := npc.worldState(true, time.Time{})
- var expiredItems []uint32
if sourceState.Present {
// Retire the pending deadline while preserving still-visible loot rights.
if err := writeNPCState_locked(tx, source, &sourceState); err != nil {
return err
}
} else {
- // An expired source may still own a filled container until its checkpoint.
- rows, err := tx.Query("SELECT item_id FROM item_locations WHERE corpse_id=? OR backpack_id IN (SELECT item_id FROM item_locations WHERE corpse_id=?)", source.id, source.id)
- if err != nil {
- return err
- }
- for rows.Next() {
- var id uint32
- if err := rows.Scan(&id); err != nil {
- rows.Close()
- return err
- }
- expiredItems = append(expiredItems, id)
- }
- if err := rows.Err(); err != nil {
- rows.Close()
- return err
- }
- rows.Close()
- for _, id := range expiredItems {
- if _, err := tx.Exec("DELETE FROM item_locations WHERE item_id=?", id); err != nil {
- return err
- }
- }
- for _, id := range expiredItems {
- if _, err := tx.Exec("DELETE FROM items WHERE id=?", id); err != nil {
- return err
- }
- }
- if _, err := tx.Exec("DELETE FROM characters WHERE id=?", source.id); err != nil {
+ // Expiry already retired its loot; remove the hidden replacement source.
+ var deleted uint32
+ if err := tx.QueryRow("DELETE FROM characters WHERE id=? RETURNING id", source.id).Scan(&deleted); err != nil {
return err
}
}
@@ -133,10 +106,6 @@ func (server *server) saveNPCRespawn_locked(source, npc *character, now time.Tim
server.rememberNPCOutcome_locked(source, sourceState, now)
} else {
delete(server.savedNPCs, source.id)
- for _, id := range expiredItems {
- delete(server.items, id)
- delete(server.itemPlacements, id)
- }
}
server.rememberNPCOutcome_locked(npc, state, now)
return nil
diff --git a/server/respawn_durability_test.go b/server/respawn_durability_test.go
@@ -170,10 +170,10 @@ func TestNPCRespawnAfterExpiryPreservesTransferredBackpack(t *testing.T) {
}
}
-func TestNPCRespawnExpiredCleanupFailureRestoresOwnershipAndRetries(t *testing.T) {
+func TestNPCRespawnExpiredSourceRemovalFailureKeepsPendingReplacement(t *testing.T) {
for _, statement := range []string{
- "CREATE TRIGGER fail_cleanup BEFORE DELETE ON items WHEN OLD.id=18 BEGIN SELECT RAISE(FAIL, 'test contents failure'); END",
"CREATE TRIGGER fail_cleanup BEFORE DELETE ON characters WHEN OLD.id=1000000 BEGIN SELECT RAISE(FAIL, 'test source removal failure'); END",
+ "CREATE TRIGGER fail_cleanup BEFORE DELETE ON characters WHEN OLD.id=1000000 BEGIN SELECT RAISE(IGNORE); END",
} {
t.Run(statement, func(t *testing.T) {
world, now := newRespawnWithFilledCorpse(t)
@@ -189,9 +189,9 @@ func TestNPCRespawnExpiredCleanupFailureRestoresOwnershipAndRetries(t *testing.T
if err := world.db.QueryRow("SELECT count(*) FROM item_locations WHERE item_id IN (17,18)").Scan(&locations); err != nil {
t.Fatal(err)
}
- if locations != 2 || len(world.items) != 3 || len(world.itemPlacements) != 3 || len(world.npcRespawns) != 1 ||
+ if locations != 0 || len(world.items) != 1 || len(world.itemPlacements) != 1 || len(world.npcRespawns) != 1 ||
world.characters[1000001] != nil || world.nextNPC != 1000001 || len(conn.packets) != 0 {
- t.Fatal("failed cleanup destroyed contents, lost the pending life or published a replacement")
+ t.Fatal("failed source removal restored expired loot, lost the pending life or published a replacement")
}
if _, err := world.db.Exec("DROP TRIGGER fail_cleanup"); err != nil {
t.Fatal(err)