From 82378c09c322802587e32722228adcf492254274 Mon Sep 17 00:00:00 2001 From: spacek531 Date: Sun, 20 Feb 2022 18:20:06 -0800 Subject: [PATCH] Rename VAR_CE and its unions (#16215) --- src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2/GameStateSnapshots.cpp | 2 +- src/openrct2/park/ParkFile.cpp | 2 +- src/openrct2/rct1/RCT1.h | 8 ++--- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/rct2/RCT2.h | 8 ++--- src/openrct2/rct2/S6Importer.cpp | 4 +-- src/openrct2/ride/Ride.h | 2 +- src/openrct2/ride/RideRatings.cpp | 2 +- src/openrct2/ride/Station.cpp | 6 ++-- src/openrct2/ride/Vehicle.cpp | 54 ++++++++++++++--------------- src/openrct2/ride/Vehicle.h | 7 ++-- 12 files changed, 47 insertions(+), 52 deletions(-) diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 956d9901bb..e522f19623 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -3500,7 +3500,7 @@ static void WindowRideOperatingInvalidate(rct_window* w) case RideMode::Race: ft.Rewind(); ft.Increment(18); - ft.Add(ride->num_laps); + ft.Add(ride->NumLaps); format = STR_NUMBER_OF_LAPS_VALUE; caption = STR_NUMBER_OF_LAPS; tooltip = STR_NUMBER_OF_LAPS_TIP; diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index 0b81153630..3a01fa645e 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -444,7 +444,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(Vehicle, animationState); COMPARE_FIELD(Vehicle, scream_sound_id); COMPARE_FIELD(Vehicle, TrackSubposition); - COMPARE_FIELD(Vehicle, num_laps); + COMPARE_FIELD(Vehicle, NumLaps); COMPARE_FIELD(Vehicle, brake_speed); COMPARE_FIELD(Vehicle, lost_time_out); COMPARE_FIELD(Vehicle, vertical_drop_countdown); diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index dd82876d5d..5d0ea1188a 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -1829,7 +1829,7 @@ namespace OpenRCT2 } cs.ReadWrite(entity.scream_sound_id); cs.ReadWrite(entity.TrackSubposition); - cs.ReadWrite(entity.var_CE); + cs.ReadWrite(entity.NumLaps); cs.ReadWrite(entity.brake_speed); cs.ReadWrite(entity.lost_time_out); cs.ReadWrite(entity.vertical_drop_countdown); diff --git a/src/openrct2/rct1/RCT1.h b/src/openrct2/rct1/RCT1.h index 530c69b4c1..0a357b2735 100644 --- a/src/openrct2/rct1/RCT1.h +++ b/src/openrct2/rct1/RCT1.h @@ -379,11 +379,7 @@ namespace RCT1 uint32_t animationState; uint8_t scream_sound_id; // 0xCC uint8_t TrackSubposition; - union - { - uint8_t var_CE; - uint8_t num_laps; // 0xCE - }; + uint8_t NumLaps; // 0xCE uint8_t brake_speed; // 0xCF uint16_t lost_time_out; // 0xD0 int8_t vertical_drop_countdown; // 0xD1 @@ -810,7 +806,7 @@ namespace RCT1 { uint8_t operation_setting; uint8_t launch_speed; - uint8_t num_laps; + uint8_t NumLaps; uint8_t max_people; }; int8_t max_speed; // 0x29 diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 0c0a8cf09a..6b00d62d6f 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2750,7 +2750,7 @@ namespace RCT1 dst->var_C4 = src->var_C4; dst->animation_frame = src->animation_frame; dst->animationState = src->animationState; - dst->var_CE = src->var_CE; + dst->NumLaps = src->NumLaps; dst->var_D3 = src->var_D3; dst->scream_sound_id = OpenRCT2::Audio::SoundId::Null; dst->Pitch = src->Pitch; diff --git a/src/openrct2/rct2/RCT2.h b/src/openrct2/rct2/RCT2.h index fa31c3f51c..326f079aba 100644 --- a/src/openrct2/rct2/RCT2.h +++ b/src/openrct2/rct2/RCT2.h @@ -121,7 +121,7 @@ namespace RCT2 { uint8_t operation_option; // 0x0D0 uint8_t time_limit; // 0x0D0 - uint8_t num_laps; // 0x0D0 + uint8_t NumLaps; // 0x0D0 uint8_t launch_speed; // 0x0D0 uint8_t speed; // 0x0D0 uint8_t rotations; // 0x0D0 @@ -514,11 +514,7 @@ namespace RCT2 uint32_t animationState; uint8_t scream_sound_id; // 0xCC uint8_t TrackSubposition; - union - { - uint8_t var_CE; - uint8_t num_laps; // 0xCE - }; + uint8_t NumLaps; // 0xCE uint8_t brake_speed; // 0xCF uint16_t lost_time_out; // 0xD0 int8_t vertical_drop_countdown; // 0xD1 diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 0719444af2..aba57cec6f 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -751,7 +751,7 @@ namespace RCT2 dst->min_waiting_time = src->min_waiting_time; dst->max_waiting_time = src->max_waiting_time; - // Includes time_limit, num_laps, launch_speed, speed, rotations + // Includes time_limit, NumLaps, launch_speed, speed, rotations dst->operation_option = src->operation_option; dst->boat_hire_return_direction = src->boat_hire_return_direction; @@ -1881,7 +1881,7 @@ namespace RCT2 dst->animationState = src->animationState; dst->scream_sound_id = static_cast(src->scream_sound_id); dst->TrackSubposition = VehicleTrackSubposition{ src->TrackSubposition }; - dst->var_CE = src->var_CE; + dst->NumLaps = src->NumLaps; dst->brake_speed = src->brake_speed; dst->lost_time_out = src->lost_time_out; dst->vertical_drop_countdown = src->vertical_drop_countdown; diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index aa15b9776d..53854975cf 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -135,7 +135,7 @@ struct Ride { uint8_t operation_option; uint8_t time_limit; - uint8_t num_laps; + uint8_t NumLaps; uint8_t launch_speed; uint8_t speed; uint8_t rotations; diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index 9ff01a8ce9..7eeb81237b 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -2583,7 +2583,7 @@ void ride_ratings_calculate_go_karts(Ride* ride, RideRatingUpdateState& state) { ride_ratings_add(&ratings, RIDE_RATING(1, 40), RIDE_RATING(0, 50), 0); - int32_t lapsFactor = (ride->num_laps - 1) * 30; + int32_t lapsFactor = (ride->NumLaps - 1) * 30; ride_ratings_add(&ratings, lapsFactor, lapsFactor / 2, 0); } diff --git a/src/openrct2/ride/Station.cpp b/src/openrct2/ride/Station.cpp index 52ea593499..d27a82eb90 100644 --- a/src/openrct2/ride/Station.cpp +++ b/src/openrct2/ride/Station.cpp @@ -108,7 +108,7 @@ static void ride_update_station_dodgems(Ride* ride, StationIndex stationIndex) if (vehicle == nullptr) continue; - if (vehicle->var_CE < dh) + if (vehicle->NumLaps < dh) continue; // End match @@ -197,7 +197,7 @@ static void ride_update_station_race(Ride* ride, StationIndex stationIndex) if (ride->lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) { - int32_t numLaps = ride->num_laps; + int32_t numLaps = ride->NumLaps; for (size_t i = 0; i < ride->num_vehicles; i++) { @@ -205,7 +205,7 @@ static void ride_update_station_race(Ride* ride, StationIndex stationIndex) if (vehicle == nullptr) continue; - if (vehicle->status != Vehicle::Status::WaitingToDepart && vehicle->num_laps >= numLaps) + if (vehicle->status != Vehicle::Status::WaitingToDepart && vehicle->NumLaps >= numLaps) { // Found a winner if (vehicle->num_peeps != 0) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index eff0c53787..4d810591e7 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -1458,7 +1458,7 @@ void Vehicle::UpdateMeasurements() } int32_t distance = abs(((velocity + acceleration) >> 10) * 42); - if (var_CE == 0) + if (NumLaps == 0) { stationForTestSegment.SegmentLength = add_clamp_int32_t(stationForTestSegment.SegmentLength, distance); } @@ -2341,7 +2341,7 @@ void Vehicle::UpdateDodgemsMode() // Update the length of time vehicle has been in dodgems mode if (sub_state++ == 0xFF) { - var_CE++; + TimeActive++; } if (curRide->lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) @@ -2464,21 +2464,21 @@ void Vehicle::UpdateWaitingToDepart() switch (curRide->mode) { case RideMode::Dodgems: - // Dodgems mode uses sub_state / var_CE to tell how long + // Dodgems mode uses sub_state and TimeActive to tell how long // the vehicle has been ridden. SetState(Vehicle::Status::TravellingDodgems); - var_CE = 0; + TimeActive = 0; UpdateDodgemsMode(); break; case RideMode::Swing: SetState(Vehicle::Status::Swinging); - var_CE = 0; + NumSwings = 0; current_time = -1; UpdateSwinging(); break; case RideMode::Rotation: SetState(Vehicle::Status::Rotating); - var_CE = 0; + NumRotations = 0; current_time = -1; UpdateRotating(); break; @@ -2521,7 +2521,7 @@ void Vehicle::UpdateWaitingToDepart() case RideMode::ForwardRotation: case RideMode::BackwardRotation: SetState(Vehicle::Status::FerrisWheelRotating, Pitch); - var_CE = 0; + NumRotations = 0; ferris_wheel_var_0 = 8; ferris_wheel_var_1 = 8; UpdateFerrisWheelRotating(); @@ -2575,7 +2575,7 @@ void Vehicle::UpdateWaitingToDepart() break; default: SetState(status); - var_CE = 0; + NumLaps = 0; break; } } @@ -3112,7 +3112,7 @@ void Vehicle::UpdateDeparting() OpenRCT2::Audio::Play3D(soundId, GetLocation()); } - if (curRide->mode == RideMode::UpwardLaunch || (curRide->mode == RideMode::DownwardLaunch && var_CE > 1)) + if (curRide->mode == RideMode::UpwardLaunch || (curRide->mode == RideMode::DownwardLaunch && NumLaunches > 1)) { OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::RideLaunch2, GetLocation()); } @@ -3164,7 +3164,7 @@ void Vehicle::UpdateDeparting() acceleration = curRide->launch_speed << 12; break; case RideMode::DownwardLaunch: - if (var_CE >= 1) + if (NumLaunches >= 1) { if ((14 << 16) > velocity) acceleration = 14 << 12; @@ -3274,7 +3274,7 @@ void Vehicle::UpdateDeparting() bool shouldLaunch = true; if (curRide->mode == RideMode::DownwardLaunch) { - if (var_CE < 1) + if (NumLaunches < 1) shouldLaunch = false; } @@ -3324,7 +3324,7 @@ void Vehicle::FinishDeparting() if (curRide->mode == RideMode::DownwardLaunch) { - if (var_CE >= 1 && (14 << 16) > velocity) + if (NumLaunches >= 1 && (14 << 16) > velocity) return; OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::RideLaunch1, GetLocation()); @@ -3795,7 +3795,7 @@ void Vehicle::UpdateArrivingPassThroughStation( if (curRide.num_circuits != 1) { - if (num_laps + 1 < curRide.num_circuits) + if (NumLaps + 1 < curRide.num_circuits) { return; } @@ -3826,12 +3826,12 @@ void Vehicle::UpdateArrivingPassThroughStation( return; } - if (num_laps + 1 < curRide.num_circuits) + if (NumLaps + 1 < curRide.num_circuits) { return; } - if (num_laps + 1 != curRide.num_circuits) + if (NumLaps + 1 != curRide.num_circuits) { velocity -= velocity_diff; acceleration = 0; @@ -3943,30 +3943,30 @@ void Vehicle::UpdateArriving() } current_station = trackElement->GetStationIndex(); - num_laps++; + NumLaps++; if (sub_state != 0) { - if (num_laps < curRide->num_circuits) + if (NumLaps < curRide->num_circuits) { SetState(Vehicle::Status::Departing, 1); return; } - if (num_laps == curRide->num_circuits && HasUpdateFlag(VEHICLE_UPDATE_FLAG_12)) + if (NumLaps == curRide->num_circuits && HasUpdateFlag(VEHICLE_UPDATE_FLAG_12)) { SetState(Vehicle::Status::Departing, 1); return; } } - if (curRide->num_circuits != 1 && num_laps < curRide->num_circuits) + if (curRide->num_circuits != 1 && NumLaps < curRide->num_circuits) { SetState(Vehicle::Status::Departing, 1); return; } - if ((curRide->mode == RideMode::UpwardLaunch || curRide->mode == RideMode::DownwardLaunch) && var_CE < 2) + if ((curRide->mode == RideMode::UpwardLaunch || curRide->mode == RideMode::DownwardLaunch) && NumLaunches < 2) { OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::RideLaunch2, GetLocation()); velocity = 0; @@ -4664,12 +4664,12 @@ void Vehicle::UpdateSwinging() } current_time = -1; - var_CE++; + NumSwings++; if (curRide->status != RideStatus::Closed) { // It takes 3 swings to get into full swing // ride->rotations already takes this into account - if (var_CE + 3 < curRide->rotations) + if (NumSwings + 3 < curRide->rotations) { // Go to the next swing state until we // are at full swing. @@ -4742,7 +4742,7 @@ void Vehicle::UpdateFerrisWheelRotating() Pitch = rotation; if (rotation == sub_state) - var_CE++; + NumRotations++; Invalidate(); @@ -4758,7 +4758,7 @@ void Vehicle::UpdateFerrisWheelRotating() bool shouldStop = true; if (curRide->status != RideStatus::Closed) { - if (var_CE < curRide->rotations) + if (NumRotations < curRide->rotations) shouldStop = false; } @@ -4865,13 +4865,13 @@ void Vehicle::UpdateRotating() } current_time = -1; - var_CE++; + NumRotations++; if (_vehicleBreakdown != BREAKDOWN_CONTROL_FAILURE) { bool shouldStop = true; if (curRide->status != RideStatus::Closed) { - sprite = var_CE + 1; + sprite = NumRotations + 1; if (curRide->type == RIDE_TYPE_ENTERPRISE) sprite += 9; @@ -9855,7 +9855,7 @@ void Vehicle::Serialise(DataSerialiser& stream) stream << animationState; stream << scream_sound_id; stream << TrackSubposition; - stream << var_CE; + stream << NumLaps; stream << brake_speed; stream << lost_time_out; stream << vertical_drop_countdown; diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index d0ba04f143..bdc81307a3 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -190,8 +190,11 @@ struct Vehicle : EntityBase VehicleTrackSubposition TrackSubposition; union { - uint8_t var_CE; - uint8_t num_laps; + uint8_t NumLaps; + uint8_t NumSwings; + uint8_t NumLaunches; + uint8_t NumRotations; + uint8_t TimeActive; }; uint8_t brake_speed; uint16_t lost_time_out;