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

Function TrackRemoveStationElement

src/openrct2/ride/Track.cpp:248–388  ·  view source on GitHub ↗

* * rct2: 0x006C494B */

Source from the content-addressed store, hash-verified

246 * rct2: 0x006C494B
247 */
248ResultWithMessage TrackRemoveStationElement(const CoordsXYZD& loc, RideId rideIndex, CommandFlags flags)
249{
250 auto ride = GetRide(rideIndex);
251 if (ride == nullptr)
252 return { false };
253
254 CoordsXYZD removeLoc = loc;
255 CoordsXYZD stationBackLoc = loc;
256 CoordsXYZD stationFrontLoc = loc;
257 int32_t stationLength = 0;
258 int32_t ByteF441D1 = -1;
259
260 if (ride->getRideTypeDescriptor().flags.has(RtdFlag::hasSinglePieceStation))
261 {
262 TileElement* tileElement = MapGetTrackElementAtWithDirectionFromRide(loc, rideIndex);
263 if (tileElement != nullptr)
264 {
265 if (flags.has(CommandFlag::apply))
266 {
267 ride_remove_station(*ride, loc);
268 }
269 }
270 return { true };
271 }
272
273 TileElement* stationElement;
274
275 // Search backwards for more station
276 CoordsXYZD currentLoc = stationBackLoc;
277 while ((stationElement = find_station_element(currentLoc, rideIndex)) != nullptr)
278 {
279 if (stationElement->asTrack()->GetTrackType() == TrackElemType::endStation)
280 {
281 if (flags.has(CommandFlag::apply))
282 {
283 ride_remove_station(*ride, currentLoc);
284 }
285 }
286
287 stationBackLoc = currentLoc;
288 ByteF441D1++;
289
290 currentLoc -= CoordsDirectionDelta[currentLoc.direction];
291 }
292
293 // Search forwards for more station
294 currentLoc = stationFrontLoc;
295 do
296 {
297 currentLoc += CoordsDirectionDelta[currentLoc.direction];
298
299 stationElement = find_station_element(currentLoc, rideIndex);
300 if (stationElement != nullptr)
301 {
302 if (stationElement->asTrack()->GetTrackType() == TrackElemType::endStation)
303 {
304 if (flags.has(CommandFlag::apply))
305 {

Callers 2

QueryMethod · 0.85
ExecuteMethod · 0.85

Calls 11

GetRideFunction · 0.85
ride_remove_stationFunction · 0.85
find_station_elementFunction · 0.85
MapInvalidateElementFunction · 0.85
hasMethod · 0.65
GetTrackTypeMethod · 0.45
asTrackMethod · 0.45
IsNullMethod · 0.45
SetTrackTypeMethod · 0.45

Tested by

no test coverage detected