Fix #20027: Looping coaster with the reverse train option makes the wrong sound (#20028)

* Always use carEntry 0 for friction sound

* Use front car entry for sound index

* Add note for carEntry sound properties

* Bump network version

---------

Co-authored-by: Trevor Finney <8711258+finneyt@users.noreply.github.com>
This commit is contained in:
kyphii 2023-04-24 03:03:01 -04:00 committed by GitHub
parent 21a0ccbb77
commit c74e69b8a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -68,7 +68,7 @@ enum : uint32_t
CAR_ENTRY_FLAG_SWINGING = 1 << 17,
CAR_ENTRY_FLAG_SPINNING = 1 << 18,
CAR_ENTRY_FLAG_POWERED = 1 << 19,
CAR_ENTRY_FLAG_RIDERS_SCREAM = 1 << 20,
CAR_ENTRY_FLAG_RIDERS_SCREAM = 1 << 20, // Only valid for front/default car of train
CAR_ENTRY_FLAG_SUSPENDED_SWING = 1 << 21, // Suspended swinging coaster, or bobsleigh if SLIDE_SWING is also enabled.
CAR_ENTRY_FLAG_BOAT_HIRE_COLLISION_DETECTION = 1 << 22,
CAR_ENTRY_FLAG_VEHICLE_ANIMATION = 1 << 23, // Set on animated vehicles like the Multi-dimension coaster trains,
@ -193,7 +193,7 @@ struct CarEntry
uint8_t no_seating_rows;
uint8_t spinning_inertia;
uint8_t spinning_friction;
OpenRCT2::Audio::SoundId friction_sound_id;
OpenRCT2::Audio::SoundId friction_sound_id; // Only valid for front/default car of train
uint8_t ReversedCarIndex; // When the car is reversed (using a turntable or reverser), it will be changed to this car.
uint8_t sound_range;
uint8_t double_sound_frequency; // (Doubles the velocity when working out the sound frequency {used on go karts})

View File

@ -5410,7 +5410,9 @@ void Vehicle::UpdateSound()
if (rideEntry == nullptr)
return;
const auto& carEntry = rideEntry->Cars[vehicle_type];
// Always use the head car's sound data (Some of the other vehicle subtypes have improperly set data)
auto soundCarIndex = (rideEntry->FrontCar == 0xff) ? rideEntry->DefaultCar : rideEntry->FrontCar;
const auto& carEntry = rideEntry->Cars[soundCarIndex];
int32_t ecx = abs(velocity) - 1.0_mph;
if (ecx >= 0)