Skip to content

Commit

Permalink
Merge pull request #3582 from myk002/myk_living
Browse files Browse the repository at this point in the history
Units: don't include dead citizens in the getCitizens list
  • Loading branch information
myk002 authored Jul 19, 2023
2 parents 65daf56 + 0d81f5c commit 24500db
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions docs/dev/Lua API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)``

Expand Down
2 changes: 1 addition & 1 deletion library/modules/Units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ df::unit *Units::getUnitByNobleRole(string noble) {

bool Units::getCitizens(std::vector<df::unit *> &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;
Expand Down

0 comments on commit 24500db

Please sign in to comment.