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

Function removeRoadMod

src/OpenLoco/src/GameCommands/Road/RemoveRoadMod.cpp:13–79  ·  view source on GitHub ↗

0x0047A42F

Source from the content-addressed store, hash-verified

11{
12 // 0x0047A42F
13 static currency32_t removeRoadMod(const RoadModsRemovalArgs& args, uint8_t flags)
14 {
15 setExpenditureType(ExpenditureType::Construction);
16 setPosition(args.pos + World::Pos3(16, 16, 0));
17
18 auto* elRoad = [&args]() -> const World::RoadElement* {
19 const auto tile = World::TileManager::get(args.pos);
20 for (const auto& el : tile)
21 {
22 auto* elRoad = el.as<World::RoadElement>();
23 if (elRoad == nullptr)
24 {
25 continue;
26 }
27
28 if (elRoad->baseHeight() != args.pos.z)
29 {
30 continue;
31 }
32
33 if (elRoad->rotation() != args.rotation)
34 {
35 continue;
36 }
37
38 if (elRoad->sequenceIndex() != args.index)
39 {
40 continue;
41 }
42
43 if (elRoad->roadObjectId() != args.roadObjType)
44 {
45 continue;
46 }
47
48 if (elRoad->roadId() != args.roadId)
49 {
50 continue;
51 }
52
53 return elRoad;
54 }
55 return nullptr;
56 }();
57
58 if (elRoad == nullptr)
59 {
60 return kFailure;
61 }
62
63 if (!sub_431E6A(elRoad->owner(), reinterpret_cast<const World::TileElement*>(elRoad)))
64 {
65 return kFailure;
66 }
67
68 const auto& piece = World::TrackData::getRoadPiece(elRoad->roadId())[elRoad->sequenceIndex()];
69 const auto offsetToFirstTile = World::Pos3{
70 Math::Vector::rotate(World::Pos2{ piece.x, piece.y }, elRoad->rotation()),

Callers

nothing calls this directly

Calls 15

setExpenditureTypeFunction · 0.85
setPositionFunction · 0.85
sub_431E6AFunction · 0.85
getRoadPieceFunction · 0.85
_RoadAndDirectionClass · 0.85
RoadModsRemovalArgsClass · 0.85
baseHeightMethod · 0.80
roadObjectIdMethod · 0.80
roadIdMethod · 0.80
getFunction · 0.50
rotateFunction · 0.50

Tested by

no test coverage detected