Merge pull request #3965 from myk002/myk_inactive_burrow

[Burrows] handle inactive burrows when assigning/clearing units
develop
Myk 2023-11-05 01:42:03 -08:00 committed by GitHub
commit bf6eea7e2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

@ -77,6 +77,7 @@ Template for new versions:
- ``Gui::revealInDwarfmodeMap``: gained ``highlight`` parameter to control setting the tile highlight on the zoom target
- ``Maps::getWalkableGroup``: get the walkability group of a tile
- ``Units::getReadableName``: now returns the *untranslated* name
- ``Burrows::setAssignedUnit``: now properly handles inactive burrows
## Lua
- ``dfhack.gui.revealInDwarfmodeMap``: gained ``highlight`` parameter to control setting the tile highlight on the zoom target

@ -78,8 +78,10 @@ void Burrows::clearUnits(df::burrow *burrow)
{
auto unit = df::unit::find(burrow->units[i]);
if (unit)
if (unit) {
erase_from_vector(unit->burrows, burrow->id);
erase_from_vector(unit->inactive_burrows, burrow->id);
}
}
burrow->units.clear();
@ -90,7 +92,8 @@ bool Burrows::isAssignedUnit(df::burrow *burrow, df::unit *unit)
CHECK_NULL_POINTER(unit);
CHECK_NULL_POINTER(burrow);
return binsearch_index(unit->burrows, burrow->id) >= 0;
return binsearch_index(unit->burrows, burrow->id) >= 0 ||
binsearch_index(unit->inactive_burrows, burrow->id) >= 0;
}
void Burrows::setAssignedUnit(df::burrow *burrow, df::unit *unit, bool enable)
@ -100,14 +103,15 @@ void Burrows::setAssignedUnit(df::burrow *burrow, df::unit *unit, bool enable)
CHECK_NULL_POINTER(unit);
CHECK_NULL_POINTER(burrow);
if (enable)
{
if (enable) {
if (burrow->limit_workshops & 2) // inactive flag
insert_into_vector(unit->inactive_burrows, burrow->id);
else
insert_into_vector(unit->burrows, burrow->id);
insert_into_vector(burrow->units, unit->id);
}
else
{
} else {
erase_from_vector(unit->burrows, burrow->id);
erase_from_vector(unit->inactive_burrows, burrow->id);
erase_from_vector(burrow->units, unit->id);
}
}