diff options
Diffstat (limited to 'internal/world')
| -rw-r--r-- | internal/world/room_migrate.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/internal/world/room_migrate.go b/internal/world/room_migrate.go index 42cd1ae..12859f2 100644 --- a/internal/world/room_migrate.go +++ b/internal/world/room_migrate.go @@ -25,7 +25,7 @@ func (r *Room) RewriteRoomIDs(idMap map[int]int) bool { // Exit targets + their on_traverse steps + exit/desc conditions. for dir, exit := range r.Exits { var exitChanged bool - if remapInt(idMap, &exit.Room) { + if RemapInt(idMap, &exit.Room) { exitChanged = true } if remapTriggers(idMap, exit.OnTraverse) { @@ -166,7 +166,7 @@ func remapStepList(idMap map[int]int, steps []behavior.Step) bool { changed := false for i := range steps { s := &steps[i] - if remapInt(idMap, &s.Teleport) { + if RemapInt(idMap, &s.Teleport) { changed = true } if s.SpawnMob != nil && remapIntSlice(idMap, s.SpawnMob.DespawnRooms) { @@ -186,7 +186,7 @@ func remapCondition(idMap map[int]int, c *behavior.Condition) bool { return false } changed := false - if c.Room != 0 && remapInt(idMap, &c.Room) { + if c.Room != 0 && RemapInt(idMap, &c.Room) { changed = true } for i := range c.AllOf { @@ -202,7 +202,10 @@ func remapCondition(idMap map[int]int, c *behavior.Condition) bool { return changed } -func remapInt(idMap map[int]int, n *int) bool { +// RemapInt rewrites *n through idMap (oldID -> newID) and reports whether it +// changed. Shared by the room-file and player-state migrations so they cannot +// disagree on the remap semantics. +func RemapInt(idMap map[int]int, n *int) bool { if newID, ok := idMap[*n]; ok && newID != *n { *n = newID return true @@ -213,7 +216,7 @@ func remapInt(idMap map[int]int, n *int) bool { func remapIntSlice(idMap map[int]int, slice []int) bool { changed := false for i := range slice { - if remapInt(idMap, &slice[i]) { + if RemapInt(idMap, &slice[i]) { changed = true } } |
