MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / clearTile

Function clearTile

src/OpenLoco/src/GameCommands/Terraform/ClearLand.cpp:24–61  ·  view source on GitHub ↗

0x00469D76

Source from the content-addressed store, hash-verified

22{
23 // 0x00469D76
24 static uint32_t clearTile(World::Pos2 pos, World::TileClearance::RemovedBuildings& removedBuildings, const uint8_t flags)
25 {
26 // This shouldn't happen due to using TilePosRangeView
27 if (!World::validCoords(pos))
28 {
29 GameCommands::setErrorText(StringIds::off_edge_of_map);
30 return GameCommands::kFailure;
31 }
32
33 if (flags & GameCommands::Flags::apply)
34 {
35 if (!SceneManager::isEditorMode())
36 {
37 TileManager::setTerrainStyleAsCleared(pos);
38 }
39
40 auto tileHeight = World::TileManager::getHeight(pos);
41 TileManager::removeAllWallsOnTileAbove(World::toTileSpace(pos), tileHeight.landHeight / 4);
42 }
43
44 World::QuarterTile qt(0xF, 0);
45
46 currency32_t cost{};
47 // Bind our local vars to the tile clear function
48 auto clearFunc = [pos, &removedBuildings, flags, &cost](World::TileElement& el) {
49 return TileClearance::clearWithoutDefaultCollision(el, pos, removedBuildings, flags, cost);
50 };
51
52 auto tileHeight = World::TileManager::getHeight(pos);
53 if (TileClearance::applyClearAtAllHeights(pos, tileHeight.landHeight / 4, tileHeight.landHeight / 4, qt, clearFunc))
54 {
55 return cost;
56 }
57 else
58 {
59 return GameCommands::kFailure;
60 }
61 }
62
63 // 0x00469CCB
64 static uint32_t clearLand(const ClearLandArgs& args, const uint8_t flags)

Callers 1

clearLandFunction · 0.85

Calls 9

validCoordsFunction · 0.85
setErrorTextFunction · 0.85
isEditorModeFunction · 0.85
setTerrainStyleAsClearedFunction · 0.85
getHeightFunction · 0.85
toTileSpaceFunction · 0.85
applyClearAtAllHeightsFunction · 0.85

Tested by

no test coverage detected