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

Function clearTreeCollision

src/OpenLoco/src/Map/TileClearance.cpp:540–558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

538 }
539
540 ClearFuncResult clearTreeCollision(World::TreeElement& elTree, const World::Pos2 pos, const uint8_t flags, currency32_t& cost)
541 {
542 auto* treeObj = ObjectManager::get<TreeObject>(elTree.treeObjectId());
543 cost += Economy::getInflationAdjustedCost(treeObj->clearCostFactor, treeObj->costIndex, 12);
544
545 if ((flags & (GameCommands::Flags::ghost | GameCommands::Flags::aiAllocated)) || !(flags & GameCommands::Flags::apply))
546 {
547 return ClearFuncResult::noCollision;
548 }
549
550 World::TileManager::setRemoveElementPointerChecker(reinterpret_cast<TileElement&>(elTree));
551 World::TileManager::removeTree(elTree, GameCommands::Flags::apply, pos);
552 Scenario::getOptions().madeAnyChanges = 1;
553 if (World::TileManager::wasRemoveOnLastElement())
554 {
555 return ClearFuncResult::allCollisionsRemoved;
556 }
557 return ClearFuncResult::collisionRemoved;
558 }
559
560 ElementPositionFlags getPositionFlags()
561 {

Callers 8

tileClearFunctionFunction · 0.85
createBuildingFunction · 0.85
createBuildingFunction · 0.85
clearFunctionFunction · 0.85
tileClearFunctionFunction · 0.85
createBuildingFunction · 0.85
clearFunctionFunction · 0.85
clearFunctionFunction · 0.85

Calls 5

getInflationAdjustedCostFunction · 0.85
wasRemoveOnLastElementFunction · 0.85
treeObjectIdMethod · 0.80
removeTreeFunction · 0.70

Tested by

no test coverage detected