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

Function getElTrackAt

src/OpenLoco/src/GameCommands/Track/RemoveTrack.cpp:21–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19namespace OpenLoco::GameCommands
20{
21 static World::TrackElement* getElTrackAt(const TrackRemovalArgs& args, const uint8_t flags, const World::Pos3 pos, const uint8_t sequenceIndex)
22 {
23 auto tile = World::TileManager::get(pos);
24 for (auto& el : tile)
25 {
26 auto* elTrack = el.as<World::TrackElement>();
27 if (elTrack == nullptr)
28 {
29 continue;
30 }
31 if (elTrack->rotation() != args.rotation)
32 {
33 continue;
34 }
35 if (elTrack->baseHeight() != pos.z)
36 {
37 continue;
38 }
39 if (elTrack->sequenceIndex() != sequenceIndex)
40 {
41 continue;
42 }
43 if (elTrack->trackObjectId() != args.trackObjectId)
44 {
45 continue;
46 }
47 if (elTrack->trackId() != args.trackId)
48 {
49 continue;
50 }
51 if (elTrack->isGhost() != ((flags & Flags::ghost) != 0))
52 {
53 continue;
54 }
55 if (elTrack->isAiAllocated() != ((flags & Flags::aiAllocated) != 0))
56 {
57 continue;
58 }
59 // Ghost only as this is checked elsewhere for non-ghost so that
60 // neutral company is always allowed
61 if (elTrack->owner() != getUpdatingCompanyId() && ((flags & Flags::ghost) != 0))
62 {
63 continue;
64 }
65 return elTrack;
66 }
67 return nullptr;
68 };
69
70 // 0x0049CC23
71 static currency32_t trackRemoveCost(const TrackRemovalArgs& args, const World::TrackData::PreviewTrack trackPiece0, const World::Pos3 trackStart, const uint8_t flags)

Callers 2

trackRemoveCostFunction · 0.70
removeTrackFunction · 0.70

Calls 10

getUpdatingCompanyIdFunction · 0.85
baseHeightMethod · 0.80
trackObjectIdMethod · 0.80
trackIdMethod · 0.80
isAiAllocatedMethod · 0.80
getFunction · 0.50
rotationMethod · 0.45
sequenceIndexMethod · 0.45
isGhostMethod · 0.45
ownerMethod · 0.45

Tested by

no test coverage detected