update for multiple ownership

develop
20k 2023-01-22 22:56:51 +00:00
parent b15fcc93d2
commit 4559168005
1 changed files with 10 additions and 7 deletions

@ -1357,19 +1357,22 @@ static void delete_civzone_squad_links(df::building_civzonest* zone)
//do not use anything that touches anything other than the pointer value //do not use anything that touches anything other than the pointer value
//this means also that if dwarf fortress reuses a memory allocation, we will end up with duplicates //this means also that if dwarf fortress reuses a memory allocation, we will end up with duplicates
//this vector is also not sorted by id //this vector is also not sorted by id
//it also turns out that multiple units eg (solely?) spouses can point to one room
static void delete_assigned_unit_links(df::building_civzonest* zone) static void delete_assigned_unit_links(df::building_civzonest* zone)
{ {
if (zone->assigned_unit_id == -1) //not clear if this is always true
return; /*if (zone->assigned_unit_id == -1)
return;*/
df::unit* unit = zone->assigned_unit;
for (df::unit* unit : world->units.active)
{
for (int i=(int)unit->owned_buildings.size() - 1; i >= 0; i--) for (int i=(int)unit->owned_buildings.size() - 1; i >= 0; i--)
{ {
if (unit->owned_buildings[i] == zone) if (unit->owned_buildings[i] == zone)
unit->owned_buildings.erase(unit->owned_buildings.begin() + i); unit->owned_buildings.erase(unit->owned_buildings.begin() + i);
} }
} }
}
static void on_civzone_delete(df::building_civzonest* civzone) static void on_civzone_delete(df::building_civzonest* civzone)
{ {