Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor GoTo loc_6D7A97 #13298

Merged
merged 13 commits into from
Nov 16, 2020
43 changes: 29 additions & 14 deletions src/openrct2/ride/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5496,6 +5496,20 @@ void Vehicle::UpdateCrash()
}
}
}

void Vehicle::screamSubFunction(Ride* curRide, OpenRCT2::Audio::SoundId screamId, uint8_t screamVolume)
rpstester marked this conversation as resolved.
Show resolved Hide resolved
{
scream_sound_id = OpenRCT2::Audio::SoundId::Null;
if (curRide->type < std::size(RideTypeDescriptors))
{
// Get lift hill sound
screamId = RideTypeDescriptors[curRide->type].LiftData.sound_id;
screamVolume = 243;
if (!(sound2_flags & VEHICLE_SOUND2_FLAGS_LIFT_HILL))
screamId = OpenRCT2::Audio::SoundId::Null;
}
}

/**
*
* rct2: 0x006D7888
Expand Down Expand Up @@ -5534,7 +5548,10 @@ void Vehicle::UpdateSound()
if (!(gCurrentTicks & 0x7F))
rpstester marked this conversation as resolved.
Show resolved Hide resolved
{
if (velocity < 0x40000 || scream_sound_id != OpenRCT2::Audio::SoundId::Null)
goto loc_6D7A97;
{
screamSubFunction(curRide, screamId, screamVolume);
break;
}

if ((scenario_rand() & 0xFFFF) <= 0x5555)
{
Expand All @@ -5553,7 +5570,10 @@ void Vehicle::UpdateSound()
if (!(gCurrentTicks & 0x7F))
{
if (velocity < 0x40000 || scream_sound_id != OpenRCT2::Audio::SoundId::Null)
goto loc_6D7A97;
{
screamSubFunction(curRide, screamId, screamVolume);
break;
}

if ((scenario_rand() & 0xFFFF) <= 0x5555)
{
Expand All @@ -5574,21 +5594,16 @@ void Vehicle::UpdateSound()
if (screamId == OpenRCT2::Audio::SoundId::NoScream)
screamId = OpenRCT2::Audio::SoundId::Null;
else if (screamId == OpenRCT2::Audio::SoundId::Null)
goto loc_6D7A97;
{
screamSubFunction(curRide, screamId, screamVolume);
break;
}
break;
}

loc_6D7A97:
scream_sound_id = OpenRCT2::Audio::SoundId::Null;
if (curRide->type < std::size(RideTypeDescriptors))
{
// Get lift hill sound
screamId = RideTypeDescriptors[curRide->type].LiftData.sound_id;
screamVolume = 243;
if (!(sound2_flags & VEHICLE_SOUND2_FLAGS_LIFT_HILL))
screamId = OpenRCT2::Audio::SoundId::Null;
}
}
screamSubFunction(curRide, screamId, screamVolume);

} // end switch
rpstester marked this conversation as resolved.
Show resolved Hide resolved

// Friction sound
auto soundIdVolume = sub_6D7AC0(sound1_id, sound1_volume, frictionId, frictionVolume);
Expand Down
1 change: 1 addition & 0 deletions src/openrct2/ride/Vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ struct Vehicle : SpriteBase
void UpdateShowingFilm();
void UpdateDoingCircusShow();
void UpdateCrossings() const;
void screamSubFunction(Ride*, OpenRCT2::Audio::SoundId, uint8_t);
void UpdateSound();
OpenRCT2::Audio::SoundId UpdateScreamSound();
OpenRCT2::Audio::SoundId ProduceScreamSound(const int32_t totalNumPeeps);
Expand Down