diff --git a/src/openrct2/ride/CableLift.cpp b/src/openrct2/ride/CableLift.cpp index 4bfc9ecae7..325829222b 100644 --- a/src/openrct2/ride/CableLift.cpp +++ b/src/openrct2/ride/CableLift.cpp @@ -240,7 +240,7 @@ bool Vehicle::CableLiftUpdateTrackMotionForwards() if (curRide == nullptr) return false; - for (; remaining_distance >= 13962; _vehicleUnkF64E10++) + for (; remaining_distance >= 13962; _vehicleSubpositionsMoved++) { auto trackType = GetTrackType(); if (trackType == TrackElemType::cableLiftHill && track_progress == 160) @@ -300,7 +300,7 @@ bool Vehicle::CableLiftUpdateTrackMotionBackwards() if (curRide == nullptr) return false; - for (; remaining_distance < 0; _vehicleUnkF64E10++) + for (; remaining_distance < 0; _vehicleSubpositionsMoved++) { uint16_t trackProgress = track_progress - 1; @@ -360,14 +360,14 @@ bool Vehicle::CableLiftUpdateTrackMotionBackwards() */ int32_t Vehicle::CableLiftUpdateTrackMotion() { - _vehicleF64E2C = 0; + _vehicleBrakeSoundTimeout = 0; gCurrentVehicle = this; _vehicleMotionTrackFlags = 0; _vehicleStationIndex = StationIndex::GetNull(); velocity += acceleration; - _vehicleVelocityF64E08 = velocity; - _vehicleVelocityF64E0C = (velocity / 1024) * 42; + _vehicleVelocity = velocity; + _vehicleRemainingDistance = (velocity / 1024) * 42; Vehicle* frontVehicle = this; if (velocity < 0) @@ -380,8 +380,8 @@ int32_t Vehicle::CableLiftUpdateTrackMotion() for (Vehicle* vehicle = frontVehicle; vehicle != nullptr;) { vehicle->acceleration = Geometry::getAccelerationFromPitch(vehicle->pitch); - _vehicleUnkF64E10 = 1; - vehicle->remaining_distance += _vehicleVelocityF64E0C; + _vehicleSubpositionsMoved = 1; + vehicle->remaining_distance += _vehicleRemainingDistance; if (vehicle->remaining_distance < 0 || vehicle->remaining_distance >= 13962) { @@ -398,10 +398,10 @@ int32_t Vehicle::CableLiftUpdateTrackMotion() } _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= vehicle->remaining_distance - 13962; + _vehicleRemainingDistance -= vehicle->remaining_distance - 13962; vehicle->remaining_distance = 13962; vehicle->acceleration += Geometry::getAccelerationFromPitch(vehicle->pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; continue; } @@ -411,15 +411,15 @@ int32_t Vehicle::CableLiftUpdateTrackMotion() } _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= vehicle->remaining_distance + 1; + _vehicleRemainingDistance -= vehicle->remaining_distance + 1; vehicle->remaining_distance = -1; vehicle->acceleration += Geometry::getAccelerationFromPitch(vehicle->pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; } vehicle->moveTo(_vehicleCurPosition); } - vehicle->acceleration /= _vehicleUnkF64E10; - if (_vehicleVelocityF64E08 >= 0) + vehicle->acceleration /= _vehicleSubpositionsMoved; + if (_vehicleVelocity >= 0) { vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train); } diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 670d1f8ac4..452aa298ee 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -3413,7 +3413,7 @@ namespace OpenRCT2 if (!carEntry->flags.has(CarEntryFlag::useDodgemCarPlacement)) { - vehicle->UpdateTrackMotion(nullptr); + vehicle->updateTrackMotionTrain(nullptr); } vehicle->EnableCollisionsForTrain(); @@ -3456,7 +3456,7 @@ namespace OpenRCT2 // until they reach a closed block brake. The block brake directly before the station is set to closed every frame // because the trains will open the block brake when the tail leaves the station. Brakes have no effect at this // time, so do not set linked brakes when closing the first block. - train->UpdateTrackMotion(nullptr); + train->updateTrackMotionTrain(nullptr); if (i == 0) { @@ -3491,7 +3491,7 @@ namespace OpenRCT2 car->SwingSprite = 0; car->remaining_distance += 13962; } - } while (!(train->UpdateTrackMotion(nullptr) & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_BLOCK_BRAKE)); + } while (!(train->updateTrackMotionTrain(nullptr) & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_BLOCK_BRAKE)); // All vehicles are in position, set the block brake directly before the station one last time and make sure the // brakes are set appropriately diff --git a/src/openrct2/ride/Vehicle.Animation.cpp b/src/openrct2/ride/Vehicle.Animation.cpp index 68aa51b862..e3fd8c7819 100644 --- a/src/openrct2/ride/Vehicle.Animation.cpp +++ b/src/openrct2/ride/Vehicle.Animation.cpp @@ -658,7 +658,7 @@ namespace OpenRCT2 */ void Vehicle::UpdateSwingingCar() { - int32_t dword_F64E08 = abs(_vehicleVelocityF64E08); + int32_t dword_F64E08 = abs(_vehicleVelocity); if (flags.has(VehicleFlag::carIsReversed)) { dword_F64E08 *= -1; @@ -769,7 +769,7 @@ namespace OpenRCT2 } int32_t spinningInertia = carEntry->spinningInertia; auto trackType = GetTrackType(); - int32_t dword_F64E08 = _vehicleVelocityF64E08; + int32_t dword_F64E08 = _vehicleVelocity; int32_t spinSpeed{}; // An L spin adds to the spin speed, R does the opposite // The number indicates how much right shift of the velocity will become spin @@ -949,7 +949,7 @@ namespace OpenRCT2 */ static void AnimateSimpleVehicle(Vehicle& vehicle, const CarEntry& carEntry) { - vehicle.animationState += _vehicleVelocityF64E08; + vehicle.animationState += _vehicleVelocity; uint8_t targetFrame = GetTargetFrame(carEntry, vehicle.animationState); if (vehicle.animation_frame != targetFrame) { @@ -963,7 +963,7 @@ namespace OpenRCT2 */ static void AnimateSteamLocomotive(Vehicle& vehicle, const CarEntry& carEntry) { - vehicle.animationState += _vehicleVelocityF64E08; + vehicle.animationState += _vehicleVelocity; uint8_t targetFrame = GetTargetFrame(carEntry, vehicle.animationState); if (vehicle.animation_frame != targetFrame) { @@ -995,7 +995,7 @@ namespace OpenRCT2 { // The animation of swan boats places frames at 0 and 2 instead of 0 and 1 like Water Tricycles due to the second // pair of peeps. The animation technically uses 4 frames, but ignores frames 1 and 3. - vehicle.animationState += _vehicleVelocityF64E08; + vehicle.animationState += _vehicleVelocity; uint8_t targetFrame = GetTargetFrame(carEntry, vehicle.animationState) * 2; if (vehicle.animation_frame != targetFrame) { @@ -1078,7 +1078,7 @@ namespace OpenRCT2 { vehicle.UpdateAnimationAnimalFlying(); // makes animation play faster with vehicle speed - uint8_t targetFrame = abs(_vehicleVelocityF64E08) >> carEntry.animationSpeed; + uint8_t targetFrame = abs(_vehicleVelocity) >> carEntry.animationSpeed; vehicle.animationState = std::max(vehicle.animationState - targetFrame, 0u); } diff --git a/src/openrct2/ride/Vehicle.BoatHire.cpp b/src/openrct2/ride/Vehicle.BoatHire.cpp index e9a384be4d..d8759e2503 100644 --- a/src/openrct2/ride/Vehicle.BoatHire.cpp +++ b/src/openrct2/ride/Vehicle.BoatHire.cpp @@ -106,8 +106,8 @@ void Vehicle::UpdateMotionBoatHire() { _vehicleMotionTrackFlags = 0; velocity += acceleration; - _vehicleVelocityF64E08 = velocity; - _vehicleVelocityF64E0C = (velocity >> 10) * 42; + _vehicleVelocity = velocity; + _vehicleRemainingDistance = (velocity >> 10) * 42; auto carEntry = Entry(); if (carEntry == nullptr) @@ -119,9 +119,9 @@ void Vehicle::UpdateMotionBoatHire() UpdateAdditionalAnimation(); } - _vehicleUnkF64E10 = 1; + _vehicleSubpositionsMoved = 1; acceleration = 0; - remaining_distance += _vehicleVelocityF64E0C; + remaining_distance += _vehicleRemainingDistance; if (remaining_distance >= 0x368A) { sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; @@ -341,7 +341,7 @@ void Vehicle::UpdateMotionBoatHire() { break; } - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; } moveTo(_vehicleCurPosition); diff --git a/src/openrct2/ride/Vehicle.Dodgems.cpp b/src/openrct2/ride/Vehicle.Dodgems.cpp index 0144d964b7..31ac71a3b9 100644 --- a/src/openrct2/ride/Vehicle.Dodgems.cpp +++ b/src/openrct2/ride/Vehicle.Dodgems.cpp @@ -23,9 +23,9 @@ using namespace OpenRCT2::RideVehicle; // External globals from Vehicle.cpp extern uint32_t _vehicleMotionTrackFlags; -extern int32_t _vehicleVelocityF64E08; -extern int32_t _vehicleVelocityF64E0C; -extern int32_t _vehicleUnkF64E10; +extern int32_t _vehicleVelocity; +extern int32_t _vehicleRemainingDistance; +extern int32_t _vehicleSubpositionsMoved; extern CoordsXYZ _vehicleCurPosition; struct DodgemsTrackSize @@ -123,9 +123,9 @@ int32_t Vehicle::UpdateMotionDodgems() } velocity = nextVelocity; - _vehicleVelocityF64E08 = nextVelocity; - _vehicleVelocityF64E0C = (nextVelocity / 1024) * 42; - _vehicleUnkF64E10 = 1; + _vehicleVelocity = nextVelocity; + _vehicleRemainingDistance = (nextVelocity / 1024) * 42; + _vehicleSubpositionsMoved = 1; acceleration = 0; if (!curRide->flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown) @@ -176,7 +176,7 @@ int32_t Vehicle::UpdateMotionDodgems() } } - remaining_distance += _vehicleVelocityF64E0C; + remaining_distance += _vehicleRemainingDistance; if (remaining_distance >= 13962) { @@ -207,7 +207,7 @@ int32_t Vehicle::UpdateMotionDodgems() { break; } - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; } if (remaining_distance >= 13962) diff --git a/src/openrct2/ride/Vehicle.MiniGolf.cpp b/src/openrct2/ride/Vehicle.MiniGolf.cpp index a56af6c685..df6c3e6af3 100644 --- a/src/openrct2/ride/Vehicle.MiniGolf.cpp +++ b/src/openrct2/ride/Vehicle.MiniGolf.cpp @@ -58,7 +58,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const return UpdateMiniGolfSubroutineStatus::stop; } acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; return UpdateMiniGolfSubroutineStatus::restart; } @@ -80,7 +80,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const return UpdateMiniGolfSubroutineStatus::stop; } acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; return UpdateMiniGolfSubroutineStatus::restart; } miniGolfFlags.unset(MiniGolfFlag::flag2); @@ -108,7 +108,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const return UpdateMiniGolfSubroutineStatus::stop; } acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; return UpdateMiniGolfSubroutineStatus::restart; } if (vEDI->var_D3 != 0) @@ -125,7 +125,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const return UpdateMiniGolfSubroutineStatus::stop; } acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; return UpdateMiniGolfSubroutineStatus::restart; } vEDI->miniGolfFlags.unset(MiniGolfFlag::flag0); @@ -154,7 +154,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const return UpdateMiniGolfSubroutineStatus::stop; } acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; return UpdateMiniGolfSubroutineStatus::restart; } if (vEDI->var_D3 != 0) @@ -171,7 +171,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const return UpdateMiniGolfSubroutineStatus::stop; } acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; return UpdateMiniGolfSubroutineStatus::restart; } vEDI->miniGolfFlags.unset(MiniGolfFlag::flag1); @@ -207,7 +207,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const return UpdateMiniGolfSubroutineStatus::stop; } acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; return UpdateMiniGolfSubroutineStatus::restart; } @@ -243,10 +243,10 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const if (!trackBlockGetNext(&input, &output, &outZ, &outDirection)) { _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance + 1; + _vehicleRemainingDistance -= remaining_distance + 1; remaining_distance = -1; acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; return UpdateMiniGolfSubroutineStatus::carryOn; } tileElement = output.element; @@ -256,14 +256,14 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const if (PitchAndRollStart(false, tileElement) != TrackPitchAndRollEnd(GetTrackType())) { _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance + 1; + _vehicleRemainingDistance -= remaining_distance + 1; remaining_distance = -1; if (remaining_distance >= 0) { Loc6DCDE4(curRide); } acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; return UpdateMiniGolfSubroutineStatus::carryOn; } @@ -409,7 +409,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const if (this == _vehicleFrontVehicle) { - if (_vehicleVelocityF64E08 >= 0) + if (_vehicleVelocity >= 0) { auto otherVehicleIndex = prev_vehicle_on_ride; UpdateMotionCollisionDetection(trackPos, &otherVehicleIndex); @@ -421,7 +421,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const return UpdateMiniGolfSubroutineStatus::stop; } acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; } } @@ -436,10 +436,10 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const if (!trackBlockGetPrevious({ TrackLocation, tileElement }, &trackBeginEnd)) { _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance + 1; + _vehicleRemainingDistance -= remaining_distance + 1; remaining_distance = -1; acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; continue; } CoordsXYZ trackPos = { trackBeginEnd.begin_x, trackBeginEnd.begin_y, trackBeginEnd.begin_z }; @@ -449,10 +449,10 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const if (PitchAndRollStart(false, tileElement) != TrackPitchAndRollEnd(GetTrackType())) { _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance - 0x368A; + _vehicleRemainingDistance -= remaining_distance - 0x368A; remaining_distance = 0x368A; acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; return UpdateMiniGolfSubroutineStatus::restart; } @@ -463,7 +463,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const flags.unset(VehicleFlag::onLiftHill); if (next_vehicle_on_train.IsNull()) { - if (_vehicleVelocityF64E08 < 0) + if (_vehicleVelocity < 0) { _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_8; } @@ -499,12 +499,12 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const if (this == _vehicleFrontVehicle) { - if (_vehicleVelocityF64E08 >= 0) + if (_vehicleVelocity >= 0) { auto otherVehicleIndex = EntityId::FromUnderlying(var_44); // Possibly wrong?. if (UpdateMotionCollisionDetection(trackPos, &otherVehicleIndex)) { - _vehicleVelocityF64E0C -= remaining_distance - 0x368A; + _vehicleRemainingDistance -= remaining_distance - 0x368A; remaining_distance = 0x368A; { Vehicle* vEBP = getGameState().entities.GetEntity(otherVehicleIndex); @@ -522,7 +522,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const } _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_2; acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; return UpdateMiniGolfSubroutineStatus::restart; } } @@ -534,7 +534,7 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const return UpdateMiniGolfSubroutineStatus::stop; } acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; } } @@ -546,11 +546,11 @@ void OpenRCT2::RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const void Vehicle::UpdateTrackMotionMiniGolfVehicle(const Ride& curRide, const RideObjectEntry& rideEntry, const CarEntry* carEntry) { - _vehicleUnkF64E10 = 1; + _vehicleSubpositionsMoved = 1; acceleration = Geometry::getAccelerationFromPitch(pitch); if (!flags.has(VehicleFlag::moveSingleCar)) { - remaining_distance = _vehicleVelocityF64E0C + remaining_distance; + remaining_distance = _vehicleRemainingDistance + remaining_distance; } if (remaining_distance >= 0 && remaining_distance < 0x368A) { @@ -588,7 +588,7 @@ void Vehicle::Loc6DCDE4(const Ride& curRide) void Vehicle::Loc6DCE02(const Ride& curRide) { - acceleration /= _vehicleUnkF64E10; + acceleration /= _vehicleSubpositionsMoved; if (TrackSubposition == VehicleTrackSubposition::chairliftGoingBack) { return; @@ -609,7 +609,7 @@ void Vehicle::Loc6DCE02(const Ride& curRide) { return; } - if (_vehicleVelocityF64E08 < 0) + if (_vehicleVelocity < 0) { if (track_progress > 11) { @@ -692,9 +692,9 @@ int32_t Vehicle::UpdateTrackMotionMiniGolf(int32_t* outStation) gCurrentVehicle = this; _vehicleMotionTrackFlags = 0; velocity += acceleration; - _vehicleVelocityF64E08 = velocity; - _vehicleVelocityF64E0C = (velocity >> 10) * 42; - _vehicleFrontVehicle = _vehicleVelocityF64E08 < 0 ? TrainTail() : this; + _vehicleVelocity = velocity; + _vehicleRemainingDistance = (velocity >> 10) * 42; + _vehicleFrontVehicle = _vehicleVelocity < 0 ? TrainTail() : this; for (Vehicle* vehicle = _vehicleFrontVehicle; vehicle != nullptr;) { @@ -709,7 +709,7 @@ int32_t Vehicle::UpdateTrackMotionMiniGolf(int32_t* outStation) *outStation = _vehicleStationIndex.ToUnderlying(); return _vehicleMotionTrackFlags; } - if (_vehicleVelocityF64E08 >= 0) + if (_vehicleVelocity >= 0) { vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train); } diff --git a/src/openrct2/ride/Vehicle.Station.cpp b/src/openrct2/ride/Vehicle.Station.cpp index 0e1f20a2c0..ecfee6fbe5 100644 --- a/src/openrct2/ride/Vehicle.Station.cpp +++ b/src/openrct2/ride/Vehicle.Station.cpp @@ -368,7 +368,7 @@ void Vehicle::UpdateMovingToEndOfStation() velocity -= velocity / 16; acceleration = 0; } - curFlags = UpdateTrackMotion(&station); + curFlags = updateTrackMotionTrain(&station); if (!(curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_5)) break; [[fallthrough]]; @@ -417,7 +417,7 @@ void Vehicle::UpdateMovingToEndOfStation() acceleration = 0; } - curFlags = UpdateTrackMotion(&station); + curFlags = updateTrackMotionTrain(&station); if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_1) { @@ -1116,7 +1116,7 @@ void Vehicle::UpdateDeparting() } } - uint32_t curFlags = UpdateTrackMotion(nullptr); + uint32_t curFlags = updateTrackMotionTrain(nullptr); if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_8) { @@ -1363,7 +1363,7 @@ void Vehicle::UpdateTravelling() return; } - uint32_t curFlags = UpdateTrackMotion(nullptr); + uint32_t curFlags = updateTrackMotionTrain(nullptr); bool skipCheck = false; if (curFlags & (VEHICLE_UPDATE_MOTION_TRACK_FLAG_8 | VEHICLE_UPDATE_MOTION_TRACK_FLAG_9) @@ -1644,7 +1644,7 @@ void Vehicle::UpdateArriving() UpdateArrivingPassThroughStation(*curRide, carEntry, stationBrakesWork); - curFlags = UpdateTrackMotion(nullptr); + curFlags = updateTrackMotionTrain(nullptr); if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION && !stationBrakesWork) { UpdateCollisionSetup(); diff --git a/src/openrct2/ride/Vehicle.TrackMotion.cpp b/src/openrct2/ride/Vehicle.TrackMotion.cpp index 5949bd1e32..6f9b68fb23 100644 --- a/src/openrct2/ride/Vehicle.TrackMotion.cpp +++ b/src/openrct2/ride/Vehicle.TrackMotion.cpp @@ -39,10 +39,10 @@ namespace OpenRCT2 extern Breakdown _vehicleBreakdown; extern StationIndex _vehicleStationIndex; extern uint32_t _vehicleMotionTrackFlags; - extern int32_t _vehicleVelocityF64E08; - extern int32_t _vehicleVelocityF64E0C; - extern int32_t _vehicleUnkF64E10; - extern uint8_t _vehicleF64E2C; + extern int32_t _vehicleVelocity; + extern int32_t _vehicleRemainingDistance; + extern int32_t _vehicleSubpositionsMoved; + extern uint8_t _vehicleBrakeSoundTimeout; extern Vehicle* _vehicleFrontVehicle; extern CoordsXYZ _vehicleCurPosition; @@ -56,7 +56,7 @@ namespace OpenRCT2 * * rct2: 0x006DAB90 */ - void Vehicle::UpdateTrackMotionUpStopCheck() const + void Vehicle::upstopCheck() const { const auto* carEntry = Entry(); if (carEntry == nullptr) @@ -129,7 +129,7 @@ namespace OpenRCT2 * merely as a velocity regulator, in a closed state. When the brake is open, it * boosts the train to the speed limit */ - void Vehicle::ApplyNonStopBlockBrake() + void Vehicle::applyNonstopBlockBrake() { if (velocity >= 0) { @@ -152,7 +152,7 @@ namespace OpenRCT2 * * Modifies the train's velocity influenced by a block brake */ - void Vehicle::ApplyStopBlockBrake() + void Vehicle::applyStopBlockBrake() { // Slow it down till completely stop the car _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_BLOCK_BRAKE; @@ -168,7 +168,7 @@ namespace OpenRCT2 } } - void Vehicle::ApplyCableLiftBlockBrake(bool brakeClosed) + void Vehicle::applyCableLiftBlockBrake(bool brakeClosed) { // If we are already on the cable lift, ignore the brake if (status == Status::travellingCableLift) @@ -202,7 +202,7 @@ namespace OpenRCT2 * * rct2: 0x006DAC43 */ - void Vehicle::CheckAndApplyBlockSectionStopSite() + void Vehicle::handleBlockBrake() { auto curRide = GetRide(); if (curRide == nullptr) @@ -241,16 +241,16 @@ namespace OpenRCT2 TrackLocation, *curRide, GetTrackDirection(), &track, &zUnused, &direction, false) && track.element != nullptr && track.element->asTrack()->HasCableLift()) { - ApplyCableLiftBlockBrake(curRide->isBlockSectioned() && trackElement->asTrack()->IsBrakeClosed()); + applyCableLiftBlockBrake(curRide->isBlockSectioned() && trackElement->asTrack()->IsBrakeClosed()); break; } } [[fallthrough]]; case TrackElemType::diagBlockBrakes: if (curRide->isBlockSectioned() && trackElement->asTrack()->IsBrakeClosed()) - ApplyStopBlockBrake(); + applyStopBlockBrake(); else - ApplyNonStopBlockBrake(); + applyNonstopBlockBrake(); break; case TrackElemType::endStation: @@ -269,7 +269,7 @@ namespace OpenRCT2 { if (trackElement->asTrack()->IsBrakeClosed()) { - ApplyStopBlockBrake(); + applyStopBlockBrake(); } } } @@ -283,7 +283,7 @@ namespace OpenRCT2 * * rct2: 0x006DADAE */ - void Vehicle::UpdateVelocity() + void Vehicle::updateVelocity() { int32_t nextVelocity = acceleration + velocity; if (flags.has(VehicleFlag::stoppedBySafetyCutout)) @@ -301,11 +301,11 @@ namespace OpenRCT2 } velocity = nextVelocity; - _vehicleVelocityF64E08 = nextVelocity; - _vehicleVelocityF64E0C = (nextVelocity >> 10) * 42; + _vehicleVelocity = nextVelocity; + _vehicleRemainingDistance = (nextVelocity >> 10) * 42; } - static void BlockBrakesOpenPreviousSection( + static void blockBrakesOpenPreviousSection( const Ride& ride, const CoordsXYZ& vehicleTrackLocation, TileElement* tileElement) { CoordsXYZ location = vehicleTrackLocation; @@ -328,7 +328,7 @@ namespace OpenRCT2 } } - void Vehicle::UpdateGoKartAttemptSwitchLanes() + void Vehicle::goKartAttemptLaneSwitch() { uint16_t probability = 0x8000; if (flags.has(VehicleFlag::currentlyColliding)) @@ -346,9 +346,9 @@ namespace OpenRCT2 } } - static void vehicle_update_play_water_splash_sound() + static void playSplashSound() { - if (_vehicleVelocityF64E08 <= kBlockBrakeBaseSpeed) + if (_vehicleVelocity <= kBlockBrakeBaseSpeed) { return; } @@ -360,7 +360,7 @@ namespace OpenRCT2 * * rct2: 0x006DB59E */ - void Vehicle::UpdateHandleWaterSplash() const + void Vehicle::handleWaterSplash() const { const auto* rideEntry = GetRideEntry(); auto trackType = GetTrackType(); @@ -385,7 +385,7 @@ namespace OpenRCT2 { if (track_progress == 4) { - vehicle_update_play_water_splash_sound(); + playSplashSound(); } } } @@ -398,7 +398,7 @@ namespace OpenRCT2 { if (track_progress == 12) { - vehicle_update_play_water_splash_sound(); + playSplashSound(); } } } @@ -408,7 +408,7 @@ namespace OpenRCT2 { if (track_progress == 48) { - vehicle_update_play_water_splash_sound(); + playSplashSound(); } } } @@ -418,11 +418,11 @@ namespace OpenRCT2 * * rct2: 0x006DBF3E */ - void Vehicle::Sub6DBF3E() + void Vehicle::findStationStopPoint() { const auto* carEntry = Entry(); - acceleration /= _vehicleUnkF64E10; + acceleration /= _vehicleSubpositionsMoved; if (TrackSubposition == VehicleTrackSubposition::chairliftGoingBack) { return; @@ -479,7 +479,7 @@ namespace OpenRCT2 } uint16_t ax = track_progress; - if (_vehicleVelocityF64E08 < 0) + if (_vehicleVelocity < 0) { if (ax <= 22) { @@ -512,7 +512,7 @@ namespace OpenRCT2 * Determine whether to use block brake speed or brake speed. If block brake is closed or no block brake present, use the * brake's speed; if block brake is open, use maximum of brake speed or block brake speed. */ - uint8_t Vehicle::ChooseBrakeSpeed() const + uint8_t Vehicle::chooseBrakeSpeed() const { if (!trackTypeIsBrakes(GetTrackType())) return brake_speed; @@ -530,7 +530,7 @@ namespace OpenRCT2 /** * Populate the vehicle's brake_speed and BlockBrakeSpeed values. */ - void Vehicle::PopulateBrakeSpeed(const CoordsXYZ& vehicleTrackLocation, TrackElement& brake) + void Vehicle::populateBrakeSpeed(const CoordsXYZ& vehicleTrackLocation, TrackElement& brake) { auto trackSpeed = brake.GetBrakeBoosterSpeed(); brake_speed = trackSpeed; @@ -566,8 +566,7 @@ namespace OpenRCT2 * * rct2: 0x006DB08C */ - bool Vehicle::UpdateTrackMotionForwardsGetNewTrack( - TrackElemType trackType, const Ride& curRide, const RideObjectEntry& rideEntry) + bool Vehicle::trackMotionForwardsGetNewTrack(TrackElemType trackType, const Ride& curRide, const RideObjectEntry& rideEntry) { CoordsXYZD location = {}; @@ -597,7 +596,7 @@ namespace OpenRCT2 } } MapInvalidateElement(TrackLocation, tileElement); - BlockBrakesOpenPreviousSection(curRide, TrackLocation, tileElement); + blockBrakesOpenPreviousSection(curRide, TrackLocation, tileElement); if (trackTypeIsBlockBrakes(trackType)) { BlockBrakeSetLinkedBrakesClosed(TrackLocation, *tileElement->asTrack(), true); @@ -707,7 +706,7 @@ namespace OpenRCT2 || trackType == TrackElemType::sBendLeft || trackType == TrackElemType::sBendRight || (curRide.flags.has(RideFlag::passStationNoStopping) && tileElement->asTrack()->IsStation())) { - UpdateGoKartAttemptSwitchLanes(); + goKartAttemptLaneSwitch(); } } @@ -741,7 +740,7 @@ namespace OpenRCT2 } SetTrackDirection(location.direction); SetTrackType(trackType); - PopulateBrakeSpeed(TrackLocation, *tileElement->asTrack()); + populateBrakeSpeed(TrackLocation, *tileElement->asTrack()); if (flags.has(VehicleFlag::stoppedOnHoldingBrake) && vertical_drop_countdown <= 0) { flags.unset(VehicleFlag::stoppedOnHoldingBrake); @@ -766,7 +765,7 @@ namespace OpenRCT2 * * rct2: 0x006DAEB9 */ - bool Vehicle::UpdateTrackMotionForwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) + bool Vehicle::trackMotionForwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) { EntityId otherVehicleIndex = EntityId::GetNull(); while (true) @@ -779,11 +778,11 @@ namespace OpenRCT2 vehicle_type ^= 1; carEntry = Entry(); } - if (_vehicleVelocityF64E08 >= 0x40000) + if (_vehicleVelocity >= 0x40000) { - acceleration = -_vehicleVelocityF64E08 * 8; + acceleration = -_vehicleVelocity * 8; } - else if (_vehicleVelocityF64E08 < 0x20000) + else if (_vehicleVelocity < 0x20000) { acceleration = 0x50000; } @@ -792,17 +791,17 @@ namespace OpenRCT2 { if (!curRide.hasFailingBrakes()) { - auto brakeSpeed = ChooseBrakeSpeed() << kTrackSpeedShiftAmount; + auto brakeSpeed = chooseBrakeSpeed() << kTrackSpeedShiftAmount; - if ((brakeSpeed) < _vehicleVelocityF64E08) + if ((brakeSpeed) < _vehicleVelocity) { - acceleration = -_vehicleVelocityF64E08 * 16; + acceleration = -_vehicleVelocity * 16; } else if (!(getGameState().currentTicks & 0x0F)) { - if (_vehicleF64E2C == 0) + if (_vehicleBrakeSoundTimeout == 0) { - _vehicleF64E2C++; + _vehicleBrakeSoundTimeout++; Play3D(SoundId::brakeRelease, { x, y, z }); } } @@ -811,7 +810,7 @@ namespace OpenRCT2 else if (trackTypeIsBooster(trackType)) { auto boosterSpeed = GetUnifiedBoosterSpeed(curRide.type, brake_speed) << kTrackSpeedShiftAmount; - if (boosterSpeed > _vehicleVelocityF64E08) + if (boosterSpeed > _vehicleVelocity) { acceleration = GetRideTypeDescriptor(curRide.type).LegacyBoosterSettings.BoosterAcceleration << kBoosterAccelerationShiftAmount; @@ -836,7 +835,7 @@ namespace OpenRCT2 { if (track_progress >= 8) { - acceleration = -_vehicleVelocityF64E08 * 16; + acceleration = -_vehicleVelocity * 16; if (track_progress >= 24) { flags.set(VehicleFlag::stoppedOnHoldingBrake); @@ -870,10 +869,10 @@ namespace OpenRCT2 { UpdateCrossings(); - if (!UpdateTrackMotionForwardsGetNewTrack(trackType, curRide, rideEntry)) + if (!trackMotionForwardsGetNewTrack(trackType, curRide, rideEntry)) { _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance + 1; + _vehicleRemainingDistance -= remaining_distance + 1; remaining_distance = -1; return false; } @@ -881,7 +880,7 @@ namespace OpenRCT2 } track_progress = newTrackProgress; - UpdateHandleWaterSplash(); + handleWaterSplash(); // Loc6DB706 const auto moveInfo = GetMoveInfo(); @@ -925,12 +924,12 @@ namespace OpenRCT2 // this == frontVehicle if (this == _vehicleFrontVehicle) { - if (_vehicleVelocityF64E08 >= 0) + if (_vehicleVelocity >= 0) { otherVehicleIndex = prev_vehicle_on_ride; if (UpdateMotionCollisionDetection(nextVehiclePosition, &otherVehicleIndex)) { - _vehicleVelocityF64E0C -= remaining_distance + 1; + _vehicleRemainingDistance -= remaining_distance + 1; remaining_distance = -1; // Might need to be bp rather than this, but hopefully not @@ -979,11 +978,11 @@ namespace OpenRCT2 } acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; } } - static PitchAndRoll PitchAndRollEnd( + static PitchAndRoll getPitchAndRollEnd( const Ride& curRide, bool useInvertedSprites, TrackElemType trackType, TileElement* tileElement) { bool isInverted = useInvertedSprites ^ tileElement->asTrack()->IsInverted(); @@ -995,7 +994,7 @@ namespace OpenRCT2 * * rct2: 0x006DBAA6 */ - bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(TrackElemType trackType, const Ride& curRide, uint16_t* progress) + bool Vehicle::trackMotionBackwardsGetNewTrack(TrackElemType trackType, const Ride& curRide, uint16_t* progress) { auto pitchAndRollStart = TrackPitchAndRollStart(trackType); TileElement* tileElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, trackType, 0); @@ -1044,7 +1043,7 @@ namespace OpenRCT2 return false; } - if (PitchAndRollEnd(curRide, flags.has(VehicleFlag::carIsInverted), trackType, tileElement) != pitchAndRollStart) + if (getPitchAndRollEnd(curRide, flags.has(VehicleFlag::carIsInverted), trackType, tileElement) != pitchAndRollStart) { return false; } @@ -1105,7 +1104,7 @@ namespace OpenRCT2 if (tileElement->asTrack()->HasChain()) { - if (_vehicleVelocityF64E08 < 0) + if (_vehicleVelocity < 0) { if (next_vehicle_on_train.IsNull()) { @@ -1126,7 +1125,7 @@ namespace OpenRCT2 flags.unset(VehicleFlag::onLiftHill); if (next_vehicle_on_train.IsNull()) { - if (_vehicleVelocityF64E08 < 0) + if (_vehicleVelocity < 0) { _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_8; } @@ -1142,7 +1141,7 @@ namespace OpenRCT2 direction &= 3; SetTrackType(trackType); SetTrackDirection(direction); - PopulateBrakeSpeed(TrackLocation, *tileElement->asTrack()); + populateBrakeSpeed(TrackLocation, *tileElement->asTrack()); if (flags.has(VehicleFlag::stoppedOnHoldingBrake) && vertical_drop_countdown <= 0) { flags.unset(VehicleFlag::stoppedOnHoldingBrake); @@ -1157,7 +1156,7 @@ namespace OpenRCT2 * * rct2: 0x006DBA33 */ - bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) + bool Vehicle::trackMotionBackwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) { EntityId otherVehicleIndex = EntityId::GetNull(); @@ -1166,7 +1165,7 @@ namespace OpenRCT2 auto trackType = GetTrackType(); if (trackType == TrackElemType::flat && curRide.getRideTypeDescriptor().flags.has(RtdFlag::hasLsmBehaviourOnFlat)) { - int32_t unkVelocity = _vehicleVelocityF64E08; + int32_t unkVelocity = _vehicleVelocity; if (unkVelocity < -524288) { unkVelocity = abs(unkVelocity); @@ -1176,11 +1175,11 @@ namespace OpenRCT2 if (trackTypeIsBrakes(trackType)) { - auto brakeSpeed = ChooseBrakeSpeed(); + auto brakeSpeed = chooseBrakeSpeed(); - if (-(brakeSpeed << kTrackSpeedShiftAmount) > _vehicleVelocityF64E08) + if (-(brakeSpeed << kTrackSpeedShiftAmount) > _vehicleVelocity) { - acceleration = _vehicleVelocityF64E08 * -16; + acceleration = _vehicleVelocity * -16; } } @@ -1189,10 +1188,10 @@ namespace OpenRCT2 { UpdateCrossings(); - if (!UpdateTrackMotionBackwardsGetNewTrack(trackType, curRide, &newTrackProgress)) + if (!trackMotionBackwardsGetNewTrack(trackType, curRide, &newTrackProgress)) { _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance - 0x368A; + _vehicleRemainingDistance -= remaining_distance - 0x368A; remaining_distance = 0x368A; return false; } @@ -1222,12 +1221,12 @@ namespace OpenRCT2 if (this == _vehicleFrontVehicle) { - if (_vehicleVelocityF64E08 < 0) + if (_vehicleVelocity < 0) { otherVehicleIndex = next_vehicle_on_ride; if (UpdateMotionCollisionDetection(nextVehiclePosition, &otherVehicleIndex)) { - _vehicleVelocityF64E0C -= remaining_distance - 0x368A; + _vehicleRemainingDistance -= remaining_distance - 0x368A; remaining_distance = 0x368A; Vehicle* v3 = getGameState().entities.GetEntity(otherVehicleIndex); @@ -1273,7 +1272,7 @@ namespace OpenRCT2 return true; } acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; } } @@ -1281,7 +1280,7 @@ namespace OpenRCT2 * * rct2: 0x006DC1E4 */ - static uint8_t modified_speed(TrackElemType trackType, VehicleTrackSubposition trackSubposition, uint8_t speed) + static uint8_t poweredCarCurveSpeed(TrackElemType trackType, VehicleTrackSubposition trackSubposition, uint8_t speed) { enum { @@ -1311,8 +1310,7 @@ namespace OpenRCT2 return speed; } - int32_t Vehicle::UpdateTrackMotionPoweredRideAcceleration( - const CarEntry* carEntry, uint32_t totalMass, const int32_t curAcceleration) + int32_t Vehicle::getPoweredCarAcceleration(const CarEntry* carEntry, uint32_t totalMass, const int32_t curAcceleration) { if (carEntry->flags.has(CarEntryFlag::isPoweredRideWithUnrestrictedGravity)) { @@ -1326,7 +1324,7 @@ namespace OpenRCT2 return curAcceleration; } } - uint8_t modifiedSpeed = modified_speed(GetTrackType(), TrackSubposition, speed); + uint8_t modifiedSpeed = poweredCarCurveSpeed(GetTrackType(), TrackSubposition, speed); int32_t poweredAcceleration = modifiedSpeed << 14; int32_t quarterForce = (modifiedSpeed * totalMass) >> 2; if (flags.has(VehicleFlag::poweredCarInReverse)) @@ -1384,7 +1382,7 @@ namespace OpenRCT2 return curAcceleration + poweredAcceleration; } - void Vehicle::UpdateTrackMotionPreUpdate( + void Vehicle::updateTrackMotionCar( Vehicle& car, const Ride& curRide, const RideObjectEntry& rideEntry, const CarEntry* carEntry) { if (carEntry->flags.has(CarEntryFlag::hasSwinging)) @@ -1400,11 +1398,11 @@ namespace OpenRCT2 car.UpdateAdditionalAnimation(); } car.acceleration = Geometry::getAccelerationFromPitch(car.pitch); - _vehicleUnkF64E10 = 1; + _vehicleSubpositionsMoved = 1; if (!car.flags.has(VehicleFlag::moveSingleCar)) { - car.remaining_distance += _vehicleVelocityF64E0C; + car.remaining_distance += _vehicleRemainingDistance; } car.sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; @@ -1418,7 +1416,7 @@ namespace OpenRCT2 if (car.remaining_distance < 0) { // Backward loop - if (car.UpdateTrackMotionBackwards(carEntry, curRide, rideEntry)) + if (car.trackMotionBackwards(carEntry, curRide, rideEntry)) { break; } @@ -1428,7 +1426,7 @@ namespace OpenRCT2 break; } car.acceleration += Geometry::getAccelerationFromPitch(car.pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; continue; } if (car.remaining_distance < 0x368A) @@ -1436,7 +1434,7 @@ namespace OpenRCT2 // Location found return; } - if (car.UpdateTrackMotionForwards(carEntry, curRide, rideEntry)) + if (car.trackMotionForwards(carEntry, curRide, rideEntry)) { break; } @@ -1446,7 +1444,7 @@ namespace OpenRCT2 break; } car.acceleration = Geometry::getAccelerationFromPitch(car.pitch); - _vehicleUnkF64E10++; + _vehicleSubpositionsMoved++; } // Loc6DBF20 car.moveTo(_vehicleCurPosition); @@ -1456,7 +1454,7 @@ namespace OpenRCT2 * * rct2: 0x006DAB4C */ - int32_t Vehicle::UpdateTrackMotion(int32_t* outStation) + int32_t Vehicle::updateTrackMotionTrain(int32_t* outStation) { auto curRide = GetRide(); if (curRide == nullptr) @@ -1475,17 +1473,17 @@ namespace OpenRCT2 return UpdateTrackMotionMiniGolf(outStation); } - _vehicleF64E2C = 0; + _vehicleBrakeSoundTimeout = 0; gCurrentVehicle = this; _vehicleMotionTrackFlags = 0; _vehicleStationIndex = StationIndex::GetNull(); - UpdateTrackMotionUpStopCheck(); - CheckAndApplyBlockSectionStopSite(); - UpdateVelocity(); + upstopCheck(); + handleBlockBrake(); + updateVelocity(); Vehicle* vehicle = this; - if (_vehicleVelocityF64E08 < 0 && !vehicle->flags.has(VehicleFlag::moveSingleCar)) + if (_vehicleVelocity < 0 && !vehicle->flags.has(VehicleFlag::moveSingleCar)) { vehicle = vehicle->TrainTail(); } @@ -1504,10 +1502,10 @@ namespace OpenRCT2 carEntry = car->Entry(); if (carEntry != nullptr) { - UpdateTrackMotionPreUpdate(*car, *curRide, *rideEntry, carEntry); + updateTrackMotionCar(*car, *curRide, *rideEntry, carEntry); } - car->Sub6DBF3E(); + car->findStationStopPoint(); // Loc6DC0F7 if (car->flags.has(VehicleFlag::onLiftHill)) @@ -1520,7 +1518,7 @@ namespace OpenRCT2 *outStation = _vehicleStationIndex.ToUnderlying(); return _vehicleMotionTrackFlags; } - if (_vehicleVelocityF64E08 >= 0) + if (_vehicleVelocity >= 0) { spriteId = car->next_vehicle_on_train; } @@ -1565,7 +1563,7 @@ namespace OpenRCT2 if (carEntry->flags.has(CarEntryFlag::isPowered)) { - curAcceleration = vehicle->UpdateTrackMotionPoweredRideAcceleration(carEntry, totalMass, curAcceleration); + curAcceleration = vehicle->getPoweredCarAcceleration(carEntry, totalMass, curAcceleration); } else if (curAcceleration <= 0 && curAcceleration >= -500) { diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 7e1f5edc39..8b3fc2873e 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -55,10 +55,10 @@ namespace OpenRCT2 Breakdown _vehicleBreakdown; StationIndex _vehicleStationIndex; uint32_t _vehicleMotionTrackFlags; - int32_t _vehicleVelocityF64E08; - int32_t _vehicleVelocityF64E0C; - int32_t _vehicleUnkF64E10; - uint8_t _vehicleF64E2C; + int32_t _vehicleVelocity; + int32_t _vehicleRemainingDistance; + int32_t _vehicleSubpositionsMoved; + uint8_t _vehicleBrakeSoundTimeout; Vehicle* _vehicleFrontVehicle; CoordsXYZ _vehicleCurPosition; @@ -194,7 +194,7 @@ namespace OpenRCT2 remaining_distance += distance; flags.set(VehicleFlag::moveSingleCar, VehicleFlag::collisionDisabled); - UpdateTrackMotion(nullptr); + updateTrackMotionTrain(nullptr); flags.unset(VehicleFlag::moveSingleCar, VehicleFlag::collisionDisabled); } @@ -1115,7 +1115,7 @@ namespace OpenRCT2 { acceleration = 4398; } - int32_t curFlags = UpdateTrackMotion(nullptr); + int32_t curFlags = updateTrackMotionTrain(nullptr); if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_11) { diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index c7522a3b37..1d48cc2d9e 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -254,7 +254,7 @@ namespace OpenRCT2 void SetState(Status vehicleStatus, uint8_t subState = 0); bool isGhost() const; std::optional DodgemsCarWouldCollideAt(const CoordsXY& coords) const; - int32_t UpdateTrackMotion(int32_t* outStation); + int32_t updateTrackMotionTrain(int32_t* outStation); int32_t CableLiftUpdateTrackMotion(); GForces GetGForces() const; void SetMapToolbar() const; @@ -310,7 +310,7 @@ namespace OpenRCT2 void CableLiftUpdateDeparting(); void CableLiftUpdateTravelling(); void CableLiftUpdateArriving(); - void Sub6DBF3E(); + void findStationStopPoint(); void UpdateMeasurements(); void UpdateMovingToEndOfStation(); void UpdateWaitingForPassengers(); @@ -352,9 +352,9 @@ namespace OpenRCT2 void UpdateAdditionalAnimation(); void CheckIfMissing(); bool CurrentTowerElementIsTop(); - bool UpdateTrackMotionForwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry); - bool UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry); - int32_t UpdateTrackMotionPoweredRideAcceleration(const CarEntry* carEntry, uint32_t totalMass, int32_t curAcceleration); + bool trackMotionForwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry); + bool trackMotionBackwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry); + int32_t getPoweredCarAcceleration(const CarEntry* carEntry, uint32_t totalMass, int32_t curAcceleration); int32_t NumPeepsUntilTrainTail() const; void InvalidateWindow(); void TestReset(); @@ -363,14 +363,14 @@ namespace OpenRCT2 bool CanDepartSynchronised() const; void ReverseReverserCar(); void UpdateReverserCarBogies(); - void UpdateHandleWaterSplash() const; + void handleWaterSplash() const; void Claxon() const; - void UpdateTrackMotionUpStopCheck() const; - void ApplyNonStopBlockBrake(); - void ApplyStopBlockBrake(); - void ApplyCableLiftBlockBrake(bool brakeClosed); - void CheckAndApplyBlockSectionStopSite(); - void UpdateVelocity(); + void upstopCheck() const; + void applyNonstopBlockBrake(); + void applyStopBlockBrake(); + void applyCableLiftBlockBrake(bool brakeClosed); + void handleBlockBrake(); + void updateVelocity(); void UpdateSpinningCar(); void UpdateSwingingCar(); int32_t GetSwingAmount() const; @@ -385,17 +385,16 @@ namespace OpenRCT2 int32_t UpdateTrackMotionMiniGolfCalculateAcceleration(const CarEntry& carEntry); int32_t UpdateTrackMotionMiniGolf(int32_t* outStation); void UpdateTrackMotionMiniGolfVehicle(const Ride& curRide, const RideObjectEntry& rideEntry, const CarEntry* carEntry); - bool UpdateTrackMotionForwardsGetNewTrack( - TrackElemType trackType, const Ride& curRide, const RideObjectEntry& rideEntry); - bool UpdateTrackMotionBackwardsGetNewTrack(TrackElemType trackType, const Ride& curRide, uint16_t* progress); + bool trackMotionForwardsGetNewTrack(TrackElemType trackType, const Ride& curRide, const RideObjectEntry& rideEntry); + bool trackMotionBackwardsGetNewTrack(TrackElemType trackType, const Ride& curRide, uint16_t* progress); bool UpdateMotionCollisionDetection(const CoordsXYZ& loc, EntityId* otherVehicleIndex); - void UpdateGoKartAttemptSwitchLanes(); + void goKartAttemptLaneSwitch(); void UpdateSceneryDoor() const; void UpdateSceneryDoorBackwards() const; void UpdateLandscapeDoors(int32_t previousTrackHeight) const; int32_t CalculateRiderBraking() const; - uint8_t ChooseBrakeSpeed() const; - void PopulateBrakeSpeed(const CoordsXYZ& vehicleTrackLocation, TrackElement& brake); + uint8_t chooseBrakeSpeed() const; + void populateBrakeSpeed(const CoordsXYZ& vehicleTrackLocation, TrackElement& brake); void Loc6DCE02(const Ride& curRide); void Loc6DCDE4(const Ride& curRide); @@ -415,7 +414,7 @@ namespace OpenRCT2 * @return UpdateMiniGolfSubroutineStatus::stop or UpdateMiniGolfSubroutineStatus::restart */ [[nodiscard]] UpdateMiniGolfSubroutineStatus Loc6DCA9A(const Ride& curRide); - void UpdateTrackMotionPreUpdate( + void updateTrackMotionCar( Vehicle& car, const Ride& curRide, const RideObjectEntry& rideEntry, const CarEntry* carEntry); }; static_assert(sizeof(Vehicle) <= 512); @@ -551,10 +550,10 @@ namespace OpenRCT2 extern Breakdown _vehicleBreakdown; extern StationIndex _vehicleStationIndex; extern uint32_t _vehicleMotionTrackFlags; - extern int32_t _vehicleVelocityF64E08; - extern int32_t _vehicleVelocityF64E0C; - extern int32_t _vehicleUnkF64E10; - extern uint8_t _vehicleF64E2C; + extern int32_t _vehicleVelocity; + extern int32_t _vehicleRemainingDistance; + extern int32_t _vehicleSubpositionsMoved; + extern uint8_t _vehicleBrakeSoundTimeout; extern Vehicle* _vehicleFrontVehicle; extern CoordsXYZ _vehicleCurPosition; } // namespace OpenRCT2 diff --git a/src/openrct2/ride/VehicleRiderControl.cpp b/src/openrct2/ride/VehicleRiderControl.cpp index 3bfc76ca71..5c77db3aba 100644 --- a/src/openrct2/ride/VehicleRiderControl.cpp +++ b/src/openrct2/ride/VehicleRiderControl.cpp @@ -138,9 +138,9 @@ int32_t Vehicle::CalculateRiderBraking() const // Brake if close to the vehicle in front Vehicle* prevVehicle = getGameState().entities.GetEntity(prev_vehicle_on_ride); - if (prevVehicle != nullptr && this != prevVehicle && _vehicleVelocityF64E08 > minFollowVelocity) + if (prevVehicle != nullptr && this != prevVehicle && _vehicleVelocity > minFollowVelocity) { - int32_t followDistance = std::max(minFollowDistance, (riderSettings.followDistance * _vehicleVelocityF64E08) >> 15); + int32_t followDistance = std::max(minFollowDistance, (riderSettings.followDistance * _vehicleVelocity) >> 15); int32_t distance = std::max(abs(x - prevVehicle->x), abs(y - prevVehicle->y)); int32_t relativeVelocity = velocity - prevVehicle->velocity; int32_t z_diff = abs(z - prevVehicle->z); @@ -219,11 +219,11 @@ int32_t Vehicle::CalculateRiderBraking() const } // Brake if car exceeds rider's preferred max speed - if (_vehicleVelocityF64E08 > targetSpeed + brakeThreshold) + if (_vehicleVelocity > targetSpeed + brakeThreshold) { return -maxBrake; } - else if (_vehicleVelocityF64E08 > targetSpeed) + else if (_vehicleVelocity > targetSpeed) { return -minBrake; }