1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 07:14:31 +01:00

Separate flat ride and tracked ride users of pitch and roll fields

In preparation for strong-typing the pitch and roll enums, unions are created to properly document which users of the field are flat rides.
This commit is contained in:
spacek531
2025-09-07 03:06:49 -07:00
committed by GitHub
parent dc1c59e715
commit 2fa20a2f3d
14 changed files with 56 additions and 48 deletions

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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];

View File

@@ -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);

View File

@@ -58,7 +58,7 @@ static void PaintSpaceRingsStructure(
{
session.InteractionType = ViewportInteractionItem::Entity;
session.CurrentlyDrawnEntity = vehicle;
frameNum += static_cast<int8_t>(vehicle->pitch) * 4;
frameNum += static_cast<int8_t>(vehicle->flatRideAnimationFrame) * 4;
}
if (ride.vehicleColourSettings != VehicleColourSettings::perTrain)

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -65,7 +65,7 @@ static void PaintMotionSimulatorVehicle(
}
else
{
imageIndex += vehicle->pitch * 4;
imageIndex += vehicle->flatRideAnimationFrame * 4;
}
}

View File

@@ -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<int8_t>(vehicle->pitch);
int32_t rotation = static_cast<int8_t>(vehicle->flatRideAnimationFrame);
if (rotation != 0)
{
vehicleImageIndex = rideEntry->Cars[0].base_image_id + kSwingingInverterShipAnimatingBaseSpriteOffset[direction];

View File

@@ -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<int8_t>(vehicle->pitch);
int32_t rotation = static_cast<int8_t>(vehicle->flatRideAnimationFrame);
if (rotation != 0)
{
if (direction & 2)

View File

@@ -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;

View File

@@ -50,7 +50,7 @@ static void PaintTwistStructure(
if (vehicle != nullptr)
{
frameNum += (vehicle->Orientation >> 3) << 4;
frameNum += vehicle->pitch;
frameNum += vehicle->flatRideAnimationFrame;
frameNum = frameNum % 216;
}

View File

@@ -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<uint8_t>(spriteType) != pitch)
if (static_cast<uint8_t>(spriteType) != flatRideAnimationFrame)
{
// Used to know which sprite to draw
pitch = static_cast<uint8_t>(spriteType);
flatRideAnimationFrame = static_cast<uint8_t>(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;

View File

@@ -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;