1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 04:53:12 +01:00

Close #12253: Refactor Vehicle sound to remove goto (#12267)

* Refactor Vehicle Scream Sound goto

* updated contributors
This commit is contained in:
michael coates
2020-07-15 02:48:47 -04:00
committed by GitHub
parent 60ff09fce6
commit 01d0287ee2
3 changed files with 13 additions and 9 deletions

View File

@@ -5560,10 +5560,6 @@ void Vehicle::UpdateSound()
*/
SoundId Vehicle::UpdateScreamSound()
{
rct_ride_entry* rideEntry = GetRideEntry();
rct_ride_entry_vehicle* vehicleEntry = &rideEntry->vehicles[vehicle_type];
int32_t totalNumPeeps = NumPeepsUntilTrainTail();
if (totalNumPeeps == 0)
return SoundId::Null;
@@ -5585,11 +5581,11 @@ SoundId Vehicle::UpdateScreamSound()
if (vehicle2->vehicle_sprite_type < 1)
continue;
if (vehicle2->vehicle_sprite_type <= 4)
goto produceScream;
return ProduceScreamSound(totalNumPeeps);
if (vehicle2->vehicle_sprite_type < 9)
continue;
if (vehicle2->vehicle_sprite_type <= 15)
goto produceScream;
return ProduceScreamSound(totalNumPeeps);
}
return SoundId::Null;
}
@@ -5608,15 +5604,21 @@ SoundId Vehicle::UpdateScreamSound()
if (vehicle2->vehicle_sprite_type < 5)
continue;
if (vehicle2->vehicle_sprite_type <= 8)
goto produceScream;
return ProduceScreamSound(totalNumPeeps);
if (vehicle2->vehicle_sprite_type < 17)
continue;
if (vehicle2->vehicle_sprite_type <= 23)
goto produceScream;
return ProduceScreamSound(totalNumPeeps);
}
return SoundId::Null;
}
SoundId Vehicle::ProduceScreamSound(const int32_t totalNumPeeps)
{
rct_ride_entry* rideEntry = GetRideEntry();
rct_ride_entry_vehicle* vehicleEntry = &rideEntry->vehicles[vehicle_type];
produceScream:
if (scream_sound_id == SoundId::Null)
{
auto r = scenario_rand();

View File

@@ -401,6 +401,7 @@ private:
void UpdateCrossings() const;
void UpdateSound();
SoundId UpdateScreamSound();
SoundId ProduceScreamSound(const int32_t totalNumPeeps);
void UpdateCrashSetup();
void UpdateCollisionSetup();
int32_t UpdateMotionDodgems();