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

Function removeTrackMod

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

0x004A668A

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

setExpenditureTypeFunction · 0.85
setPositionFunction · 0.85
sub_431E6AFunction · 0.85
getTrackPieceFunction · 0.85
_TrackAndDirectionClass · 0.85
baseHeightMethod · 0.80
trackObjectIdMethod · 0.80
trackIdMethod · 0.80
getFunction · 0.50
rotateFunction · 0.50

Tested by

no test coverage detected