diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 7bdd6368c9..5b8c48ed50 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -2512,7 +2512,7 @@ static void PeepChooseSeatFromCar(Guest* guest, const Ride& ride, Vehicle* vehic if (ride.mode == RideMode::forwardRotation || ride.mode == RideMode::backwardRotation) { - chosen_seat = (((~vehicle->pitch + 1) >> 3) & 0xF) * 2; + chosen_seat = (((~vehicle->flatRideAnimationFrame + 1) >> 3) & 0xF) * 2; if (vehicle->next_free_seat & 1) { chosen_seat++; @@ -2627,7 +2627,7 @@ static bool FindVehicleToEnter( if (ride.mode == RideMode::forwardRotation || ride.mode == RideMode::backwardRotation) { - uint8_t position = (((~vehicle->pitch + 1) >> 3) & 0xF) * 2; + uint8_t position = (((~vehicle->flatRideAnimationFrame + 1) >> 3) & 0xF) * 2; if (!vehicle->peep[position].IsNull()) continue; } diff --git a/src/openrct2/paint/track/gentle/FerrisWheel.cpp b/src/openrct2/paint/track/gentle/FerrisWheel.cpp index 45a299a1c0..f6d5a250de 100644 --- a/src/openrct2/paint/track/gentle/FerrisWheel.cpp +++ b/src/openrct2/paint/track/gentle/FerrisWheel.cpp @@ -56,7 +56,7 @@ static void PaintFerrisWheelRiders( if (peep == nullptr || peep->State != PeepState::OnRide) continue; - auto frameNum = (vehicle.pitch + i * 4) % 128; + auto frameNum = (vehicle.flatRideAnimationFrame + i * 4) % 128; auto imageIndex = rideEntry.Cars[0].base_image_id + 32 + direction * 128 + frameNum; auto imageId = ImageId(imageIndex, vehicle.peep_tshirt_colours[i], vehicle.peep_tshirt_colours[i + 1]); PaintAddImageAsChild(session, imageId, offset, bb); @@ -88,7 +88,7 @@ static void PaintFerrisWheelStructure( wheelImageTemplate = stationColour; } - auto imageOffset = vehicle != nullptr ? vehicle->pitch % 8 : 0; + auto imageOffset = vehicle != nullptr ? vehicle->flatRideAnimationFrame % 8 : 0; auto leftSupportImageId = supportsImageTemplate.WithIndex(22150 + (direction & 1) * 2); auto wheelImageId = wheelImageTemplate.WithIndex(rideEntry->Cars[0].base_image_id + direction * 8 + imageOffset); auto rightSupportImageId = leftSupportImageId.WithIndexOffset(1); diff --git a/src/openrct2/paint/track/gentle/HauntedHouse.cpp b/src/openrct2/paint/track/gentle/HauntedHouse.cpp index f26252cc1e..af7e0be60f 100644 --- a/src/openrct2/paint/track/gentle/HauntedHouse.cpp +++ b/src/openrct2/paint/track/gentle/HauntedHouse.cpp @@ -44,7 +44,7 @@ static void PaintHauntedHouseStructure( { session.InteractionType = ViewportInteractionItem::Entity; session.CurrentlyDrawnEntity = vehicle; - frameNum = vehicle->pitch; + frameNum = vehicle->flatRideAnimationFrame; } const auto& boundBox = kHauntedHouseData[part]; diff --git a/src/openrct2/paint/track/gentle/MerryGoRound.cpp b/src/openrct2/paint/track/gentle/MerryGoRound.cpp index 4086082c7a..3bd8e1f49a 100644 --- a/src/openrct2/paint/track/gentle/MerryGoRound.cpp +++ b/src/openrct2/paint/track/gentle/MerryGoRound.cpp @@ -82,7 +82,7 @@ static void PaintCarousel( if (vehicle != nullptr) { auto rotation = ((vehicle->Orientation >> 3) + session.CurrentRotation) << 5; - rotationOffset = (vehicle->pitch + rotation) % 128; + rotationOffset = (vehicle->flatRideAnimationFrame + rotation) % 128; } CoordsXYZ offset(xOffset, yOffset, height); diff --git a/src/openrct2/paint/track/gentle/SpaceRings.cpp b/src/openrct2/paint/track/gentle/SpaceRings.cpp index 006c400647..5f6e7ba1e4 100644 --- a/src/openrct2/paint/track/gentle/SpaceRings.cpp +++ b/src/openrct2/paint/track/gentle/SpaceRings.cpp @@ -58,7 +58,7 @@ static void PaintSpaceRingsStructure( { session.InteractionType = ViewportInteractionItem::Entity; session.CurrentlyDrawnEntity = vehicle; - frameNum += static_cast(vehicle->pitch) * 4; + frameNum += static_cast(vehicle->flatRideAnimationFrame) * 4; } if (ride.vehicleColourSettings != VehicleColourSettings::perTrain) diff --git a/src/openrct2/paint/track/thrill/Enterprise.cpp b/src/openrct2/paint/track/thrill/Enterprise.cpp index f15af05745..87d53d33cc 100644 --- a/src/openrct2/paint/track/thrill/Enterprise.cpp +++ b/src/openrct2/paint/track/thrill/Enterprise.cpp @@ -72,7 +72,7 @@ static void PaintEnterpriseStructure( uint32_t imageOffset = trackElement.GetDirectionWithOffset(session.CurrentRotation); if (vehicle != nullptr) { - imageOffset = (vehicle->pitch << 2) + (((vehicle->Orientation >> 3) + session.CurrentRotation) % 4); + imageOffset = (vehicle->flatRideAnimationFrame << 2) + (((vehicle->Orientation >> 3) + session.CurrentRotation) % 4); } auto imageTemplate = ImageId(0, ride.vehicleColours[0].Body, ride.vehicleColours[0].Trim); diff --git a/src/openrct2/paint/track/thrill/MagicCarpet.cpp b/src/openrct2/paint/track/thrill/MagicCarpet.cpp index b77f87c871..21c430997a 100644 --- a/src/openrct2/paint/track/thrill/MagicCarpet.cpp +++ b/src/openrct2/paint/track/thrill/MagicCarpet.cpp @@ -192,7 +192,7 @@ static void PaintMagicCarpetStructure( auto* vehicle = GetFirstVehicle(ride); if (vehicle != nullptr) { - swing = vehicle->pitch; + swing = vehicle->flatRideAnimationFrame; session.InteractionType = ViewportInteractionItem::Entity; session.CurrentlyDrawnEntity = vehicle; } diff --git a/src/openrct2/paint/track/thrill/MotionSimulator.cpp b/src/openrct2/paint/track/thrill/MotionSimulator.cpp index 21b99bbaa5..8918116352 100644 --- a/src/openrct2/paint/track/thrill/MotionSimulator.cpp +++ b/src/openrct2/paint/track/thrill/MotionSimulator.cpp @@ -65,7 +65,7 @@ static void PaintMotionSimulatorVehicle( } else { - imageIndex += vehicle->pitch * 4; + imageIndex += vehicle->flatRideAnimationFrame * 4; } } diff --git a/src/openrct2/paint/track/thrill/SwingingInverterShip.cpp b/src/openrct2/paint/track/thrill/SwingingInverterShip.cpp index b4d5bc55f7..9633056c60 100644 --- a/src/openrct2/paint/track/thrill/SwingingInverterShip.cpp +++ b/src/openrct2/paint/track/thrill/SwingingInverterShip.cpp @@ -88,7 +88,7 @@ static void PaintSwingingInverterShipStructure( ImageIndex vehicleImageIndex = rideEntry->Cars[0].base_image_id + kSwingingInverterShipBaseSpriteOffset[direction]; if (vehicle != nullptr) { - int32_t rotation = static_cast(vehicle->pitch); + int32_t rotation = static_cast(vehicle->flatRideAnimationFrame); if (rotation != 0) { vehicleImageIndex = rideEntry->Cars[0].base_image_id + kSwingingInverterShipAnimatingBaseSpriteOffset[direction]; diff --git a/src/openrct2/paint/track/thrill/SwingingShip.cpp b/src/openrct2/paint/track/thrill/SwingingShip.cpp index c6761a266f..270e0fec4f 100644 --- a/src/openrct2/paint/track/thrill/SwingingShip.cpp +++ b/src/openrct2/paint/track/thrill/SwingingShip.cpp @@ -110,7 +110,7 @@ static void PaintSwingingShipStructure( auto baseImageId = rideEntry->Cars[0].base_image_id + kSwingingShipBaseSpriteOffset[direction]; if (vehicle != nullptr) { - int32_t rotation = static_cast(vehicle->pitch); + int32_t rotation = static_cast(vehicle->flatRideAnimationFrame); if (rotation != 0) { if (direction & 2) diff --git a/src/openrct2/paint/track/thrill/TopSpin.cpp b/src/openrct2/paint/track/thrill/TopSpin.cpp index e150de9137..da620997a4 100644 --- a/src/openrct2/paint/track/thrill/TopSpin.cpp +++ b/src/openrct2/paint/track/thrill/TopSpin.cpp @@ -135,8 +135,8 @@ static void PaintTopSpinVehicle( session.InteractionType = ViewportInteractionItem::Entity; session.CurrentlyDrawnEntity = vehicle; - armRotation = vehicle->pitch; - seatRotation = vehicle->roll; + armRotation = vehicle->flatRideAnimationFrame; + seatRotation = vehicle->flatRideSecondaryAnimationFrame; } int32_t armImageOffset = armRotation; diff --git a/src/openrct2/paint/track/thrill/Twist.cpp b/src/openrct2/paint/track/thrill/Twist.cpp index b0c25e97a6..54f9fc3856 100644 --- a/src/openrct2/paint/track/thrill/Twist.cpp +++ b/src/openrct2/paint/track/thrill/Twist.cpp @@ -50,7 +50,7 @@ static void PaintTwistStructure( if (vehicle != nullptr) { frameNum += (vehicle->Orientation >> 3) << 4; - frameNum += vehicle->pitch; + frameNum += vehicle->flatRideAnimationFrame; frameNum = frameNum % 216; } diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 3121d9e4d3..d43271a8af 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -1501,7 +1501,7 @@ void Vehicle::TrainReadyToDepart(uint8_t num_peeps_on_train, uint8_t num_used_se if (curRide->mode == RideMode::forwardRotation || curRide->mode == RideMode::backwardRotation) { - uint8_t seat = ((-pitch) / 8) & 0xF; + uint8_t seat = ((-flatRideAnimationFrame) / 8) & 0xF; if (!peep[seat].IsNull()) { curRide->getStation(current_station).TrainAtStation = RideStation::kNoTrain; @@ -1791,7 +1791,7 @@ void Vehicle::UpdateWaitingToDepart() { if (curRide->mode == RideMode::forwardRotation || curRide->mode == RideMode::backwardRotation) { - uint8_t seat = ((-pitch) >> 3) & 0xF; + uint8_t seat = ((-flatRideAnimationFrame) >> 3) & 0xF; if (peep[seat * 2].IsNull()) { if (num_peeps == 0) @@ -1917,13 +1917,13 @@ void Vehicle::UpdateWaitingToDepart() } } current_time = -1; - pitch = 0; - roll = 0; + flatRideAnimationFrame = 0; + flatRideSecondaryAnimationFrame = 0; UpdateTopSpinOperating(); break; case RideMode::forwardRotation: case RideMode::backwardRotation: - SetState(Vehicle::Status::FerrisWheelRotating, pitch); + SetState(Vehicle::Status::FerrisWheelRotating, flatRideAnimationFrame); NumRotations = 0; ferris_wheel_var_0 = 8; ferris_wheel_var_1 = 8; @@ -1960,19 +1960,19 @@ void Vehicle::UpdateWaitingToDepart() break; case RideMode::spaceRings: SetState(Vehicle::Status::SpaceRingsOperating); - pitch = 0; + flatRideAnimationFrame = 0; current_time = -1; UpdateSpaceRingsOperating(); break; case RideMode::hauntedHouse: SetState(Vehicle::Status::HauntedHouseOperating); - pitch = 0; + flatRideAnimationFrame = 0; current_time = -1; UpdateHauntedHouseOperating(); break; case RideMode::crookedHouse: SetState(Vehicle::Status::CrookedHouseOperating); - pitch = 0; + flatRideAnimationFrame = 0; current_time = -1; UpdateCrookedHouseOperating(); break; @@ -3425,7 +3425,7 @@ void Vehicle::UpdateUnloadingPassengers() if (curRide->mode == RideMode::forwardRotation || curRide->mode == RideMode::backwardRotation) { - uint8_t seat = ((-pitch) >> 3) & 0xF; + uint8_t seat = ((-flatRideAnimationFrame) >> 3) & 0xF; if (restraints_position == 255 && !peep[seat * 2].IsNull()) { next_free_seat -= 2; @@ -4074,10 +4074,10 @@ void Vehicle::UpdateSwinging() if (spriteType != -128) { current_time++; - if (static_cast(spriteType) != pitch) + if (static_cast(spriteType) != flatRideAnimationFrame) { // Used to know which sprite to draw - pitch = static_cast(spriteType); + flatRideAnimationFrame = static_cast(spriteType); Invalidate(); } return; @@ -4152,14 +4152,14 @@ void Vehicle::UpdateFerrisWheelRotating() ferris_wheel_var_1 = curFerrisWheelVar0; } - uint8_t rotation = pitch; + uint8_t rotation = flatRideAnimationFrame; if (curRide->mode == RideMode::forwardRotation) rotation++; else rotation--; rotation &= 0x7F; - pitch = rotation; + flatRideAnimationFrame = rotation; if (rotation == sub_state) NumRotations++; @@ -4173,7 +4173,7 @@ void Vehicle::UpdateFerrisWheelRotating() subState--; subState &= 0x7F; - if (subState == pitch) + if (subState == flatRideAnimationFrame) { bool shouldStop = true; if (curRide->status != RideStatus::closed) @@ -4200,7 +4200,7 @@ void Vehicle::UpdateFerrisWheelRotating() subState -= 8; subState &= 0x7F; - if (subState != pitch) + if (subState != flatRideAnimationFrame) return; SetState(Vehicle::Status::Arriving); @@ -4222,9 +4222,9 @@ void Vehicle::UpdateSimulatorOperating() if (al != 0xFF) { current_time++; - if (al == pitch) + if (al == flatRideAnimationFrame) return; - pitch = al; + flatRideAnimationFrame = al; Invalidate(); return; } @@ -4295,9 +4295,9 @@ void Vehicle::UpdateRotating() if (sprite != 0xFF) { current_time = time; - if (sprite == pitch) + if (sprite == flatRideAnimationFrame) return; - pitch = sprite; + flatRideAnimationFrame = sprite; Invalidate(); return; } @@ -4348,9 +4348,9 @@ void Vehicle::UpdateSpaceRingsOperating() if (spriteType != 255) { current_time++; - if (spriteType != pitch) + if (spriteType != flatRideAnimationFrame) { - pitch = spriteType; + flatRideAnimationFrame = spriteType; Invalidate(); } } @@ -4370,15 +4370,15 @@ void Vehicle::UpdateHauntedHouseOperating() if (_vehicleBreakdown == 0) return; - if (pitch != 0) + if (flatRideAnimationFrame != 0) { if (getGameState().currentTicks & 1) { - pitch++; + flatRideAnimationFrame++; Invalidate(); - if (pitch == 19) - pitch = 0; + if (flatRideAnimationFrame == 19) + flatRideAnimationFrame = 0; } } @@ -4396,7 +4396,7 @@ void Vehicle::UpdateHauntedHouseOperating() OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScare, GetLocation()); break; case 75: - pitch = 1; + flatRideAnimationFrame = 1; Invalidate(); break; case 400: @@ -4406,7 +4406,7 @@ void Vehicle::UpdateHauntedHouseOperating() OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScare, GetLocation()); break; case 775: - pitch = 1; + flatRideAnimationFrame = 1; Invalidate(); break; case 1100: @@ -4449,15 +4449,15 @@ void Vehicle::UpdateTopSpinOperating() if (rotation != 0xFF) { current_time = current_time + 1; - if (rotation != pitch) + if (rotation != flatRideAnimationFrame) { - pitch = rotation; + flatRideAnimationFrame = rotation; Invalidate(); } rotation = sprite_map[current_time].bank_rotation; - if (rotation != roll) + if (rotation != flatRideSecondaryAnimationFrame) { - roll = rotation; + flatRideSecondaryAnimationFrame = rotation; Invalidate(); } return; diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index 0173dc1038..7e09f43acb 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -107,8 +107,16 @@ struct Vehicle : EntityBase }; Type SubType; - uint8_t pitch; - uint8_t roll; + union + { + uint8_t pitch; + uint8_t flatRideAnimationFrame; + }; + union + { + uint8_t roll; + uint8_t flatRideSecondaryAnimationFrame; + }; int32_t remaining_distance; int32_t velocity; int32_t acceleration;