From 0d81f5ce6eba0cea97953c81525f22cfa6a4e085 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 18 Jul 2023 23:09:19 -0700 Subject: [PATCH] don't include dead citizens in the citizens list --- docs/changelog.txt | 1 + docs/dev/Lua API.rst | 3 +-- library/modules/Units.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index e45273a25..97bc202fe 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -41,6 +41,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - Fix extra keys appearing in DFHack text boxes when shift (or any other modifier) is released before the other key you were pressing - `logistics`: don't autotrain domestic animals brought by invaders (they'll get attacked by friendly creatures as soon as you let them out of their cage) - `logistics`: don't bring trade goods to depot if the only caravans present are tribute caravans +- `gui/create-item`: when choosing a citizen to create the chosen items, avoid choosing a dead citizen ## Misc Improvements - `stockpiles`: include exotic pets in the "tameable" filter diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index b52bf3c76..6776bb617 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -1454,8 +1454,7 @@ Units module * ``dfhack.units.getCitizens([ignore_sanity])`` - Returns a table (list) of all citizens, which you would otherwise have to - loop over all units in world and test against ``isCitizen()`` to discover. + Returns a list of all living citizens. * ``dfhack.units.teleport(unit, pos)`` diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index ed667b2a2..f517a07b5 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -841,7 +841,7 @@ df::unit *Units::getUnitByNobleRole(string noble) { bool Units::getCitizens(std::vector &citizens, bool ignore_sanity) { for (auto &unit : world->units.active) { - if (isCitizen(unit, ignore_sanity)) + if (isCitizen(unit, ignore_sanity) && isAlive(unit)) citizens.emplace_back(unit); } return true;