From 9666676766bf21364f4fc4d0d1d336e72f2a91b4 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 6 Oct 2026 12:57:23 -0400 Subject: refactor: split casino.go, dedup helpers, remove audit docs --- internal/world/objects.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'internal/world/objects.go') diff --git a/internal/world/objects.go b/internal/world/objects.go index 3c004a5..9101fbc 100644 --- a/internal/world/objects.go +++ b/internal/world/objects.go @@ -2,6 +2,7 @@ package world import ( "fmt" + "log" "math/rand" "sort" "strings" @@ -343,7 +344,7 @@ func (w *World) SetObjName(roomID int, defID string, name string) { w.mu.Lock() defer w.mu.Unlock() for _, st := range w.objStates { - if st.RoomID == roomID && st.DefID == defID { + if st.HomeRoomID == roomID && st.DefID == defID { st.Name = name } } @@ -353,7 +354,7 @@ func (w *World) SetObjAliases(roomID int, defID string, aliases []string) { w.mu.Lock() defer w.mu.Unlock() for _, st := range w.objStates { - if st.RoomID == roomID && st.DefID == defID { + if st.HomeRoomID == roomID && st.DefID == defID { st.Aliases = aliases } } @@ -363,7 +364,7 @@ func (w *World) SetObjWander(roomID int, defID string, rooms []int, interval flo w.mu.Lock() defer w.mu.Unlock() for _, st := range w.objStates { - if st.RoomID == roomID && st.DefID == defID { + if st.HomeRoomID == roomID && st.DefID == defID { st.WanderRooms = rooms st.WanderInterval = interval } @@ -374,7 +375,7 @@ func (w *World) SetObjDepleteTimer(roomID int, defID string, max float64) { w.mu.Lock() defer w.mu.Unlock() for _, st := range w.objStates { - if st.RoomID == roomID && st.DefID == defID && st.SharedMax == 0 { + if st.HomeRoomID == roomID && st.DefID == defID && st.SharedMax == 0 { st.SharedMax = max st.SharedTimer = int(max) } @@ -451,8 +452,12 @@ func (w *World) TickObjWander() { for _, m := range moves { oldKey := w.ObjStateKey(m.st.RoomID, m.st.DefID, m.st.Index) fromRoom := m.st.RoomID + newKey := w.ObjStateKey(m.toRoom, m.st.DefID, m.st.Index) + if existing, ok := w.objStates[newKey]; ok && existing != m.st { + log.Printf("skip wander of object %q index %d from room %d to %d: destination key %q is already occupied", m.st.DefID, m.st.Index, fromRoom, m.toRoom, newKey) + continue + } m.st.RoomID = m.toRoom - newKey := w.ObjStateKey(m.st.RoomID, m.st.DefID, m.st.Index) delete(w.objStates, oldKey) w.objStates[newKey] = m.st w.objMoves = append(w.objMoves, ObjMove{ -- cgit v1.2.3