MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / FindRailStationEnd

Function FindRailStationEnd

src/newgrf_station.cpp:158–178  ·  view source on GitHub ↗

* Find the end of a railway station, from the \a tile, in the direction of \a delta. * @param tile Start tile. * @param delta Movement direction. * @param check_type Stop when the custom station type changes. * @param check_axis Stop when the station direction changes. * @return Found end of the railway station. */

Source from the content-addressed store, hash-verified

156 * @return Found end of the railway station.
157 */
158static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool check_type, bool check_axis)
159{
160 uint8_t orig_type = 0;
161 Axis orig_axis = AXIS_X;
162 StationID sid = GetStationIndex(tile);
163
164 if (check_type) orig_type = GetCustomStationSpecIndex(tile);
165 if (check_axis) orig_axis = GetRailStationAxis(tile);
166
167 for (;;) {
168 TileIndex new_tile = TileAdd(tile, delta);
169
170 if (!IsTileType(new_tile, MP_STATION) || GetStationIndex(new_tile) != sid) break;
171 if (!HasStationRail(new_tile)) break;
172 if (check_type && GetCustomStationSpecIndex(new_tile) != orig_type) break;
173 if (check_axis && GetRailStationAxis(new_tile) != orig_axis) break;
174
175 tile = new_tile;
176 }
177 return tile;
178}
179
180
181static uint32_t GetPlatformInfoHelper(TileIndex tile, bool check_type, bool check_axis, bool centred)

Callers 1

GetPlatformInfoHelperFunction · 0.85

Calls 6

GetStationIndexFunction · 0.85
GetRailStationAxisFunction · 0.85
IsTileTypeFunction · 0.85
HasStationRailFunction · 0.85
TileAddFunction · 0.70

Tested by

no test coverage detected