From cadcd70a2c981e7db17b6217275596a496f1256c Mon Sep 17 00:00:00 2001 From: Lily Carpenter Date: Mon, 11 Sep 2023 22:37:13 -0500 Subject: [PATCH] Bugfix: Use coherent method to determine if no stranded units --- warn-stranded.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/warn-stranded.lua b/warn-stranded.lua index 5e331def13..cca630e1a9 100644 --- a/warn-stranded.lua +++ b/warn-stranded.lua @@ -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 @@ -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