MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / MapGetTrackElementAtWithDirectionFromRide

Function MapGetTrackElementAtWithDirectionFromRide

src/openrct2/world/Map.cpp:2061–2082  ·  view source on GitHub ↗

* Gets the track element at x, y, z that is the given track type and sequence. * @param x x units, not tiles. * @param y y units, not tiles. * @param z Base height. * @param direction The direction (0 - 3). */

Source from the content-addressed store, hash-verified

2059 * @param direction The direction (0 - 3).
2060 */
2061 TileElement* MapGetTrackElementAtWithDirectionFromRide(const CoordsXYZD& trackPos, RideId rideIndex)
2062 {
2063 TileElement* tileElement = MapGetFirstElementAt(trackPos);
2064 if (tileElement == nullptr)
2065 return nullptr;
2066 auto trackTilePos = TileCoordsXYZ{ trackPos };
2067 do
2068 {
2069 if (tileElement->getType() != TileElementType::Track)
2070 continue;
2071 if (tileElement->baseHeight != trackTilePos.z)
2072 continue;
2073 if (tileElement->asTrack()->GetRideIndex() != rideIndex)
2074 continue;
2075 if (tileElement->getDirection() != trackPos.direction)
2076 continue;
2077
2078 return tileElement;
2079 } while (!(tileElement++)->isLastForTile());
2080
2081 return nullptr;
2082 }
2083
2084 WallElement* MapGetWallElementAt(const CoordsXYRangedZ& coords)
2085 {

Callers 1

Calls 6

MapGetFirstElementAtFunction · 0.85
getTypeMethod · 0.45
GetRideIndexMethod · 0.45
asTrackMethod · 0.45
getDirectionMethod · 0.45
isLastForTileMethod · 0.45

Tested by

no test coverage detected