Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Template for new versions:
## New Features

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

## Misc Improvements

Expand Down
6 changes: 5 additions & 1 deletion plugins/lua/preserve-rooms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,13 @@ local function get_codes(positions)
if position.replaced_by == -1 then
ensure_key(grouped, id)[id] = position
else
-- replaced-by links may be cyclic. this code will behave "incorrectly" in the event
-- of a cycle but will not hang. a proper fix is still needed. see issue DFHack/dfhack#5538
local parent = positions[position.replaced_by]
while parent.replaced_by ~= -1 do
local counter = 0
while parent.replaced_by ~= -1 and counter < 10 do
parent = positions[parent.replaced_by]
counter = counter + 1
end
ensure_key(grouped, parent.id)[id] = position
end
Expand Down
Loading