Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix/retrieve-units] *really* prevent duplicate units from being added to the active vector #1004

Merged
merged 1 commit into from
Feb 25, 2024
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 changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Template for new versions:

## Fixes
- `gui/design`: fix clicking the center point when there is a mark behind it entering both mark dragging and center dragging at the same time. Now you can click once to move the shape, and click twice to move only the mark behind the center point.
- `fix/retrieve-units`: prevent pulling in duplicate units from offscreen
- `warn-stranded`: when there was at least one truly stuck unit and miners were actively mining, the miners were also confusingly shown in the stuck units list
- `source`: fix issue where removing sources would make some other sources inactive
- `caravan`: display book and scroll titles in the goods and trade dialogs instead of generic scroll descriptions
Expand Down
10 changes: 4 additions & 6 deletions fix/retrieve-units.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@ function shouldRetrieve(unit)
end

function retrieveUnits()
for _, unit in pairs(df.global.world.units.all) do
for _, unit in ipairs(df.global.world.units.all) do
if unit.flags1.inactive and shouldRetrieve(unit) then
print(("Retrieving from the abyss: %s (%s)"):format(
dfhack.df2console(dfhack.TranslateName(dfhack.units.getVisibleName(unit))),
df.creature_raw.find(unit.race).name[0]
))
print(("Retrieving from the abyss: %s (%d)"):format(
dfhack.df2console(dfhack.units.getReadableName(unit)), unit.id))
unit.flags1.move_state = true
unit.flags1.inactive = false
unit.flags1.incoming = false
unit.flags1.can_swap = true
unit.flags1.hidden_in_ambush = false
-- add to active if missing
if not utils.linear_index(df.global.world.units.active, unit, 'id') then
if not utils.linear_index(df.global.world.units.active, unit.id, 'id') then
df.global.world.units.active:insert('#', unit)
end
end
Expand Down
Loading