MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ClearElementsAt

Function ClearElementsAt

src/openrct2/world/Map.cpp:1481–1501  ·  view source on GitHub ↗

* Clears all elements properly from a certain tile. * rct2: 0x0068AE2A */

Source from the content-addressed store, hash-verified

1479 * rct2: 0x0068AE2A
1480 */
1481 static void ClearElementsAt(const CoordsXY& loc)
1482 {
1483 auto& gameState = getGameState();
1484 // Remove the spawn point (if there is one in the current tile)
1485 gameState.peepSpawns.erase(
1486 std::remove_if(
1487 gameState.peepSpawns.begin(), gameState.peepSpawns.end(),
1488 [loc](const CoordsXY& spawn) { return spawn.ToTileStart() == loc.ToTileStart(); }),
1489 gameState.peepSpawns.end());
1490
1491 TileElement* tileElement = MapGetFirstElementAt(loc);
1492 if (tileElement == nullptr)
1493 return;
1494
1495 // Remove all elements except the last one
1496 while (!tileElement->isLastForTile())
1497 ClearElementAt(loc, &tileElement);
1498
1499 // Remove the last element
1500 ClearElementAt(loc, &tileElement);
1501 }
1502
1503 int32_t MapGetHighestZ(const CoordsXY& loc)
1504 {

Callers 2

MapClearAllElementsFunction · 0.85

Calls 6

MapGetFirstElementAtFunction · 0.85
ClearElementAtFunction · 0.85
endMethod · 0.65
beginMethod · 0.45
ToTileStartMethod · 0.45
isLastForTileMethod · 0.45

Tested by

no test coverage detected