aboutsummaryrefslogtreecommitdiff
path: root/internal/world/world.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/world/world.go
parent2c38386484cdb507c4687caceb37e0b963e33594 (diff)
downloadthehouseoficarus-cc33072eced3d5460512c09c42ec4531c807d7af.tar.gz
fix: casino stake preservation, world state reconciliation, casino game registration
Diffstat (limited to 'internal/world/world.go')
-rw-r--r--internal/world/world.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/internal/world/world.go b/internal/world/world.go
index cb53b77..7a91894 100644
--- a/internal/world/world.go
+++ b/internal/world/world.go
@@ -3,6 +3,7 @@ package world
import (
"fmt"
"log"
+ "math"
"os"
"path/filepath"
"strconv"
@@ -120,7 +121,7 @@ func (w *World) SeedGroundItems(roomID int) {
e.quantity += s.Quantity
e.respawnQty += s.Quantity
e.isSpawn = true
- e.respawnDelay = int(s.RespawnTicks)
+ e.respawnDelay = spawnRespawnDelay(s.RespawnTicks)
merged = true
break
}
@@ -130,7 +131,7 @@ func (w *World) SeedGroundItems(roomID int) {
itemID: s.ID,
quantity: s.Quantity,
isSpawn: true,
- respawnDelay: int(s.RespawnTicks),
+ respawnDelay: spawnRespawnDelay(s.RespawnTicks),
respawnQty: s.Quantity,
}
w.groundItems[roomID] = append(w.groundItems[roomID], e)
@@ -138,6 +139,20 @@ func (w *World) SeedGroundItems(roomID int) {
}
}
+// spawnRespawnDelay converts a fractional respawn_ticks value to whole ticks.
+// Truncating (the old int(v)) turned any 0 < v < 1 into a one-shot spawn that
+// never returned; round instead and floor a positive value at one tick.
+func spawnRespawnDelay(ticks float64) int {
+ if ticks <= 0 {
+ return 0
+ }
+ delay := int(math.Round(ticks))
+ if delay < 1 {
+ delay = 1
+ }
+ return delay
+}
+
func (w *World) RoomIndex() map[int]bool {
w.mu.Lock()
defer w.mu.Unlock()
@@ -255,6 +270,9 @@ func (w *World) RekeyRooms(idMap map[int]int) {
// from the renamed room (and TickObjWander then creates a second
// entry for the same state). Remap wander rooms like MobStore does.
m.st.RoomID = m.newID
+ if mapped, ok := idMap[m.st.HomeRoomID]; ok && mapped != m.st.HomeRoomID {
+ m.st.HomeRoomID = mapped
+ }
for i, room := range m.st.WanderRooms {
if mapped, ok := idMap[room]; ok && mapped != room {
m.st.WanderRooms[i] = mapped