Skip to content

Commit 8744fb4

Browse files
committed
exclude inactive units from inBox functions
1 parent 872ba28 commit 8744fb4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Template for new versions:
7878
## API
7979
- ``Military::removeFromSquad``: removes unit from any squad assignments
8080
- ``Buildings::checkFreeTiles``: now replaces the extents parameter for a building pointer
81+
- ``Units::isUnitInBox``, ``Units::getUnitsInBox``: don't include inactive units
8182

8283
## Lua
8384
- ``dfhack.units.setAutomaticProfessions``: sets unit labors according to current work detail settings

library/modules/Units.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,8 @@ bool Units::isGreatDanger(df::unit *unit) {
665665

666666
bool Units::isUnitInBox(df::unit *u, const cuboid &box) {
667667
CHECK_NULL_POINTER(u);
668+
if (!isActive(unit))
669+
return false;
668670
return box.containsPos(getPosition(u));
669671
}
670672

@@ -674,7 +676,7 @@ bool Units::getUnitsInBox(vector<df::unit *> &units, const cuboid &box, std::fun
674676

675677
units.clear();
676678
for (auto unit : world->units.active)
677-
if (filter(unit) && isUnitInBox(unit, box))
679+
if (isUnitInBox(unit, box) && filter(unit))
678680
units.push_back(unit);
679681
return true;
680682
}

0 commit comments

Comments
 (0)