Merge pull request #3582 from myk002/myk_living

Units: don't include dead citizens in the getCitizens list
develop
Myk 2023-07-19 08:22:46 -07:00 committed by GitHub
commit 24500dbafd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

@ -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 - 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 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 - `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 ## Misc Improvements
- `stockpiles`: include exotic pets in the "tameable" filter - `stockpiles`: include exotic pets in the "tameable" filter

@ -1454,8 +1454,7 @@ Units module
* ``dfhack.units.getCitizens([ignore_sanity])`` * ``dfhack.units.getCitizens([ignore_sanity])``
Returns a table (list) of all citizens, which you would otherwise have to Returns a list of all living citizens.
loop over all units in world and test against ``isCitizen()`` to discover.
* ``dfhack.units.teleport(unit, pos)`` * ``dfhack.units.teleport(unit, pos)``

@ -841,7 +841,7 @@ df::unit *Units::getUnitByNobleRole(string noble) {
bool Units::getCitizens(std::vector<df::unit *> &citizens, bool ignore_sanity) { bool Units::getCitizens(std::vector<df::unit *> &citizens, bool ignore_sanity) {
for (auto &unit : world->units.active) { for (auto &unit : world->units.active) {
if (isCitizen(unit, ignore_sanity)) if (isCitizen(unit, ignore_sanity) && isAlive(unit))
citizens.emplace_back(unit); citizens.emplace_back(unit);
} }
return true; return true;