Skip to content

Commit 14c30d4

Browse files
authored
Merge pull request #5542 from ab9rf/mitigate-5538
cheap mitigation of #5538
2 parents 2264abb + e6757c3 commit 14c30d4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Template for new versions:
5757
## New Features
5858

5959
## Fixes
60+
- `preserve-rooms` will no longer hang on startup in the presence of a cycle in the replacement relationship of noble positions
6061

6162
## Misc Improvements
6263

plugins/lua/preserve-rooms.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,13 @@ local function get_codes(positions)
320320
if position.replaced_by == -1 then
321321
ensure_key(grouped, id)[id] = position
322322
else
323+
-- replaced-by links may be cyclic. this code will behave "incorrectly" in the event
324+
-- of a cycle but will not hang. a proper fix is still needed. see issue DFHack/dfhack#5538
323325
local parent = positions[position.replaced_by]
324-
while parent.replaced_by ~= -1 do
326+
local counter = 0
327+
while parent.replaced_by ~= -1 and counter < 10 do
325328
parent = positions[parent.replaced_by]
329+
counter = counter + 1
326330
end
327331
ensure_key(grouped, parent.id)[id] = position
328332
end

0 commit comments

Comments
 (0)