Skip to content

Commit

Permalink
Bugfix: Use coherent method to determine if no stranded units
Browse files Browse the repository at this point in the history
  • Loading branch information
azrazalea committed Sep 12, 2023
1 parent e295ec0 commit cadcd70
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions warn-stranded.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ local function compareGroups(group_one, group_two)
end

local function getStrandedUnits()
local grouped = { n = 0 }
local groupCount = 0
local grouped = {}
local citizens = dfhack.units.getCitizens()

-- Don't use ignored units to determine if there are any stranded units
Expand All @@ -202,12 +203,14 @@ local function getStrandedUnits()
table.insert(ensure_key(ignoredGroup, walkGroup), unit)
else
table.insert(ensure_key(grouped, walkGroup), unit)
grouped['n'] = grouped['n'] + 1
if #grouped[walkGroup] == 1 then
groupCount = groupCount + 1
end
end
end

-- No one is stranded, so stop here
if grouped['n'] <= 1 then
if groupCount <= 1 then
return false, {}
end

Expand Down

0 comments on commit cadcd70

Please sign in to comment.