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

Method getBuildingIfValidOrRemoveIfNot

plugins/buildingplan/plannedbuilding.cpp:122–131  ·  view source on GitHub ↗

Ensure the building still exists and is in a valid state. It can disappear for lots of reasons, such as running the game with the buildingplan plugin disabled, manually removing the building, modifying it via the API, etc.

Source from the content-addressed store, hash-verified

120// for lots of reasons, such as running the game with the buildingplan plugin
121// disabled, manually removing the building, modifying it via the API, etc.
122df::building * PlannedBuilding::getBuildingIfValidOrRemoveIfNot(color_ostream &out, bool skip_remove) {
123 auto bld = df::building::find(id);
124 bool valid = bld && bld->getBuildStage() == 0;
125 if (!valid) {
126 if (!skip_remove)
127 remove(out);
128 return NULL;
129 }
130 return bld;
131}

Callers 4

registerPlannedBuildingFunction · 0.80
printStatusFunction · 0.80
countAvailableItemsFunction · 0.80
popInvalidTasksFunction · 0.80

Calls 1

findFunction · 0.50

Tested by

no test coverage detected