unit owned_building pointers are known-bad as of 50.05 and dangle on zone delete 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 vector is also not sorted by id it also turns out that multiple units eg (solely?) spouses can point to one room
| 1282 | //this vector is also not sorted by id |
| 1283 | //it also turns out that multiple units eg (solely?) spouses can point to one room |
| 1284 | static void delete_assigned_unit_links(df::building_civzonest* zone) |
| 1285 | { |
| 1286 | //not clear if this is always true |
| 1287 | /*if (zone->assigned_unit_id == -1) |
| 1288 | return;*/ |
| 1289 | |
| 1290 | for (df::unit* unit : world->units.active) |
| 1291 | { |
| 1292 | for (int i=(int)unit->owned_buildings.size() - 1; i >= 0; i--) |
| 1293 | { |
| 1294 | if (unit->owned_buildings[i] == zone) |
| 1295 | unit->owned_buildings.erase(unit->owned_buildings.begin() + i); |
| 1296 | } |
| 1297 | } |
| 1298 | } |
| 1299 | |
| 1300 | static void on_civzone_delete(df::building_civzonest* civzone) |
| 1301 | { |
no test coverage detected