aboutsummaryrefslogtreecommitdiff
path: root/internal/game/combat_mob.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-19 01:55:34 -0400
committerhistoria <[not public]>2026-09-19 01:55:34 -0400
commitcc33072eced3d5460512c09c42ec4531c807d7af (patch)
treeb1b451fa87fa389cb8343a3645372f3b43f5523e /internal/game/combat_mob.go
parent2c38386484cdb507c4687caceb37e0b963e33594 (diff)
downloadthehouseoficarus-cc33072eced3d5460512c09c42ec4531c807d7af.tar.gz
fix: casino stake preservation, world state reconciliation, casino game registration
Diffstat (limited to 'internal/game/combat_mob.go')
-rw-r--r--internal/game/combat_mob.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/internal/game/combat_mob.go b/internal/game/combat_mob.go
index 21aaf4c..b16e4e1 100644
--- a/internal/game/combat_mob.go
+++ b/internal/game/combat_mob.go
@@ -330,10 +330,16 @@ func (g *Game) awardKillDrops(sess *net.Session, p *player.Player, mob *world.Mo
// scheduleMobRespawn removes trigger-spawned mobs or schedules a normal respawn.
func (g *Game) scheduleMobRespawn(mob *world.MobInstance) {
- instanceID := mob.InstanceID
+ if mob == nil {
+ return
+ }
if mob.SpawnedByTrigger {
g.SubscribeTicks(10, func() bool {
- g.MobStore.RemoveInstance(instanceID)
+ // Read the ID at fire time: a room-ID migration may have rewritten
+ // it while the timer was pending.
+ if id := mob.InstanceID; id != "" {
+ g.MobStore.RemoveInstance(id)
+ }
return false
})
return
@@ -343,7 +349,11 @@ func (g *Game) scheduleMobRespawn(mob *world.MobInstance) {
respawnTicks = engine.ToTicks(30)
}
g.SubscribeTicks(respawnTicks, func() bool {
- g.respawnMob(instanceID)
+ // Re-read the current ID at fire time instead of capturing the string:
+ // RekeyRooms rewrites an instance's key when its home room is rekeyed,
+ // so a captured ID would miss, the mob would stay at HP 0 forever, and
+ // SeedMobs would skip the (now-correct) key as already present.
+ g.respawnMob(mob.InstanceID)
return false
})
}