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

Method trainStation

src/OpenLoco/src/Map/Tile.cpp:101–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99 }
100
101 StationElement* Tile::trainStation(uint8_t trackId, uint8_t direction, uint8_t baseZ) const
102 {
103 StationElement* result = nullptr;
104 bool trackFound = false;
105 for (auto& tile : *this)
106 {
107 if (trackFound)
108 {
109 result = tile.as<StationElement>();
110 if (result != nullptr)
111 {
112 break;
113 }
114 }
115 auto* elTrack = tile.as<TrackElement>();
116 if (elTrack == nullptr)
117 {
118 continue;
119 }
120 trackFound = false;
121 if (elTrack->baseZ() != baseZ)
122 {
123 continue;
124 }
125 if (elTrack->rotation() != direction)
126 {
127 continue;
128 }
129 if (elTrack->trackId() != trackId)
130 {
131 continue;
132 }
133 if (!elTrack->hasStationElement())
134 {
135 continue;
136 }
137 trackFound = true;
138 }
139 return result;
140 }
141
142 StationElement* Tile::roadStation(uint8_t roadId, uint8_t direction, uint8_t baseZ) const
143 {

Callers 3

getLoadingModifierMethod · 0.80
sub_4ACEF1Function · 0.80
tryFindStationAtFunction · 0.80

Calls 4

baseZMethod · 0.80
trackIdMethod · 0.80
rotationMethod · 0.45
hasStationElementMethod · 0.45

Tested by

no test coverage detected