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

Method UpdateTrackMotion

src/openrct2/ride/Vehicle.TrackMotion.cpp:1455–1605  ·  view source on GitHub ↗

* * rct2: 0x006DAB4C */

Source from the content-addressed store, hash-verified

1453 * rct2: 0x006DAB4C
1454 */
1455int32_t Vehicle::UpdateTrackMotion(int32_t* outStation)
1456{
1457 auto curRide = GetRide();
1458 if (curRide == nullptr)
1459 return 0;
1460
1461 const auto* rideEntry = GetRideEntry();
1462 const auto* carEntry = Entry();
1463
1464 if (carEntry == nullptr)
1465 {
1466 return 0;
1467 }
1468
1469 if (carEntry->flags.has(CarEntryFlag::isMiniGolf))
1470 {
1471 return UpdateTrackMotionMiniGolf(outStation);
1472 }
1473
1474 _vehicleF64E2C = 0;
1475 gCurrentVehicle = this;
1476 _vehicleMotionTrackFlags = 0;
1477 _vehicleStationIndex = StationIndex::GetNull();
1478
1479 UpdateTrackMotionUpStopCheck();
1480 CheckAndApplyBlockSectionStopSite();
1481 UpdateVelocity();
1482
1483 Vehicle* vehicle = this;
1484 if (_vehicleVelocityF64E08 < 0 && !vehicle->flags.has(VehicleFlag::moveSingleCar))
1485 {
1486 vehicle = vehicle->TrainTail();
1487 }
1488 // This will be the front vehicle even when traveling
1489 // backwards.
1490 _vehicleFrontVehicle = vehicle;
1491
1492 auto spriteId = vehicle->id;
1493 while (!spriteId.IsNull())
1494 {
1495 Vehicle* car = getGameState().entities.GetEntity<Vehicle>(spriteId);
1496 if (car == nullptr)
1497 {
1498 break;
1499 }
1500 carEntry = car->Entry();
1501 if (carEntry != nullptr)
1502 {
1503 UpdateTrackMotionPreUpdate(*car, *curRide, *rideEntry, carEntry);
1504 }
1505
1506 car->Sub6DBF3E();
1507
1508 // Loc6DC0F7
1509 if (car->flags.has(VehicleFlag::onLiftHill))
1510 {
1511 _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_ON_LIFT_HILL;
1512 }

Callers 2

createVehiclesMethod · 0.80

Calls 13

GetRideFunction · 0.85
GetAccelerationDecrease2Function · 0.85
TrainTailMethod · 0.80
EntryMethod · 0.80
Sub6DBF3EMethod · 0.80
ToUnderlyingMethod · 0.80
IsHeadMethod · 0.80
IsOnCoveredTrackMethod · 0.80
hasMethod · 0.65
EntryClass · 0.50
IsNullMethod · 0.45

Tested by

no test coverage detected