aboutsummaryrefslogtreecommitdiff
path: root/internal/world/room_migrate.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-18 20:03:13 -0400
committerhistoria <[not public]>2026-09-18 20:03:13 -0400
commit79764732406d6484f67d3dec045483dcb5d08c28 (patch)
tree7a64e8581a540b97ed554f5723e2d587424ab1c6 /internal/world/room_migrate.go
parentf1e461ab6aec6b9bf056bbe2daa88a251e0f21da (diff)
downloadthehouseoficarus-79764732406d6484f67d3dec045483dcb5d08c28.tar.gz
feat: better card ascii art
Diffstat (limited to 'internal/world/room_migrate.go')
-rw-r--r--internal/world/room_migrate.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/internal/world/room_migrate.go b/internal/world/room_migrate.go
index b7840bc..42cd1ae 100644
--- a/internal/world/room_migrate.go
+++ b/internal/world/room_migrate.go
@@ -101,6 +101,48 @@ func (r *Room) RewriteRoomIDs(idMap map[int]int) bool {
return changed
}
+// RemoveRoomRefs drops references to a deleted room from this room's
+// per-instance mob and object wander lists. Exit targets are removed by the
+// deletion caller. Teleport steps and conditions that name the deleted room
+// are left in place and neutralized at runtime (teleportPlayer refuses a
+// missing destination, and a Condition.Room that no longer exists simply
+// never matches), so this only removes the references the validator would
+// otherwise report as dangling. Returns whether anything changed.
+func (r *Room) RemoveRoomRefs(removedID int) bool {
+ if r == nil || removedID <= 0 {
+ return false
+ }
+ changed := false
+ for i := range r.Mobs {
+ if removeRoomRef(&r.Mobs[i].WanderRooms, removedID) {
+ changed = true
+ }
+ }
+ for i := range r.Objects {
+ if removeRoomRef(&r.Objects[i].WanderRooms, removedID) {
+ changed = true
+ }
+ }
+ return changed
+}
+
+// removeRoomRef removes target from list in place and reports whether it was
+// present.
+func removeRoomRef(list *[]int, target int) bool {
+ src := *list
+ out := src[:0]
+ removed := false
+ for _, v := range src {
+ if v == target {
+ removed = true
+ continue
+ }
+ out = append(out, v)
+ }
+ *list = out
+ return removed
+}
+
// remapTriggers remaps step fields across a []behavior.Trigger (each trigger's
// Steps + per-step Condition + trigger-level Condition).
func remapTriggers(idMap map[int]int, list []behavior.Trigger) bool {