dfhack
dfhack copied to clipboard
Don't include raiding units in Units::isActive; make getPosition return invalid coords
Raiding units are unflagged as inactive shortly after they leave the map, as they are removed from units.active. Scan this vector to rule out raiding units. The move_state and can_swap flags are also unset, which can be used to optimize the check.
Units::getPosition now returns invalid coords for inactive units. This impacts Units::isUnitInBox, and Units::getUnitsInBox.
It also impacts Items::getPosition, but an item in items.other.IN_PLAY has its holder is guaranteed to be active (artifact theft bugs notwithstanding).
Only iterate active units in spectate instead of all. (Mainly for efficiency. Units::isActive change would've caught any potential issue with raiding units.)