MCPcopy Create free account
hub / github.com/DFHack/dfhack / delete_civzone_squad_links

Function delete_civzone_squad_links

library/modules/Buildings.cpp:1257–1277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1255}
1256
1257static void delete_civzone_squad_links(df::building_civzonest* zone)
1258{
1259 for (auto room_info : zone->squad_room_info)
1260 {
1261 if (auto squad = df::squad::find(room_info->squad_id)) {
1262 for (int i=(int)squad->rooms.size() - 1; i >= 0; i--)
1263 {
1264 if (squad->rooms[i]->building_id == zone->id)
1265 {
1266 auto room = squad->rooms[i];
1267 squad->rooms.erase(squad->rooms.begin() + i);
1268 delete room;
1269 }
1270 }
1271 }
1272
1273 delete room_info;
1274 }
1275
1276 zone->squad_room_info.clear();
1277}
1278
1279//unit owned_building pointers are known-bad as of 50.05 and dangle on zone delete
1280//do not use anything that touches anything other than the pointer value

Callers 1

on_civzone_deleteFunction · 0.85

Calls 5

findFunction · 0.50
sizeMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected