don't overcount units for misery widget

addendum to #2366
develop
Myk 2022-11-20 09:45:23 -08:00 committed by GitHub
parent 152aa70b21
commit ff447d46bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

@ -116,9 +116,11 @@ end
function MiseryWidget:overlay_onupdate()
local counts, num_colors = {}, #self.colors
for _,unit in ipairs(df.global.world.units.active) do
if not dfhack.units.isCitizen(unit, true) then goto continue end
local stress_category = math.min(num_colors,
dfhack.units.getStressCategory(unit))
counts[stress_category] = (counts[stress_category] or 0) + 1
::continue::
end
local width = 2 + num_colors - 1 -- 'H:' plus the slashes