aboutsummaryrefslogtreecommitdiff
path: root/internal/world/objects.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-10-06 12:57:23 -0400
committerhistoria <[not public]>2026-10-06 12:57:23 -0400
commit9666676766bf21364f4fc4d0d1d336e72f2a91b4 (patch)
tree0cade34091d7602790dc38cd44053f0b74bbadf2 /internal/world/objects.go
parent4bc1daaf259e0c19c5fe4a12ec8bc7f6e5a735c1 (diff)
downloadthehouseoficarus-9666676766bf21364f4fc4d0d1d336e72f2a91b4.tar.gz
refactor: split casino.go, dedup helpers, remove audit docs
Diffstat (limited to 'internal/world/objects.go')
-rw-r--r--internal/world/objects.go15
1 files changed, 10 insertions, 5 deletions
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{