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 f97a26c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions warn-stranded.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ local function compareGroups(group_one, group_two)
end

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

-- Don't use ignored units to determine if there are any stranded units
Expand All @@ -202,12 +202,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 f97a26c

Please sign in to comment.