MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / removeFromMap

Method removeFromMap

game/state/tilemap/tileobject.cpp:38–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void TileObject::removeFromMap()
39{
40 auto thisPtr = shared_from_this();
41 /* owner may be NULL as this can be used to set the initial position after creation */
42 if (this->owningTile)
43 {
44 auto erased = this->owningTile->ownedObjects.erase(thisPtr);
45 if (erased != 1)
46 {
47 LogError("Nothing erased?");
48 }
49 int layer = map.getLayer(this->type);
50 this->drawOnTile->drawnObjects[layer].erase(
51 std::remove(this->drawOnTile->drawnObjects[layer].begin(),
52 this->drawOnTile->drawnObjects[layer].end(), thisPtr),
53 this->drawOnTile->drawnObjects[layer].end());
54 this->owningTile = nullptr;
55 }
56 for (auto *tile : this->intersectingTiles)
57 {
58 tile->intersectingObjects.erase(thisPtr);
59 }
60 this->intersectingTiles.clear();
61}
62
63namespace
64{

Callers 1

setPositionMethod · 0.95

Calls 5

removeFunction · 0.85
getLayerMethod · 0.80
endMethod · 0.80
beginMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected