1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-25 07:44:38 +01:00

Small cleanup of sound range parameters

This commit is contained in:
Michael Steenbeek
2025-07-04 18:52:58 +02:00
committed by GitHub
parent e8d9663eed
commit b77aa9a956
7 changed files with 36 additions and 32 deletions

View File

@@ -121,7 +121,7 @@ namespace OpenRCT2::Audio
LiftWildMouse,
LiftBM,
TrackFrictionBM,
Scream8,
Scream8, // Blood-curdling, Haunted House-like scream
Tram,
DoorOpen,
DoorClose,

View File

@@ -417,7 +417,7 @@ void RideObject::ReadLegacyCar([[maybe_unused]] IReadObjectContext* context, ISt
car->spinning_friction = stream->ReadValue<uint8_t>();
car->friction_sound_id = stream->ReadValue<OpenRCT2::Audio::SoundId>();
car->ReversedCarIndex = stream->ReadValue<uint8_t>();
car->sound_range = stream->ReadValue<uint8_t>();
car->soundRange = stream->ReadValue<SoundRange>();
car->double_sound_frequency = stream->ReadValue<uint8_t>();
car->powered_acceleration = stream->ReadValue<uint8_t>();
car->powered_max_speed = stream->ReadValue<uint8_t>();
@@ -561,7 +561,7 @@ void RideObject::ReadJson(IReadObjectContext* context, json_t& root)
car.flags = CAR_ENTRY_FLAG_SPINNING;
car.PaintStyle = VEHICLE_VISUAL_FLAT_RIDE_OR_CAR_RIDE;
car.friction_sound_id = OpenRCT2::Audio::SoundId::Null;
car.sound_range = 0xFF;
car.soundRange = SoundRange::none;
car.draw_order = 6;
// Shop item
@@ -719,7 +719,7 @@ CarEntry RideObject::ReadJsonCar([[maybe_unused]] IReadObjectContext* context, j
car.spinning_friction = Json::GetNumber<uint8_t>(jCar["spinningFriction"]);
car.friction_sound_id = Json::GetEnum<OpenRCT2::Audio::SoundId>(jCar["frictionSoundId"], OpenRCT2::Audio::SoundId::Null);
car.ReversedCarIndex = Json::GetNumber<uint8_t>(jCar["logFlumeReverserVehicleType"]);
car.sound_range = Json::GetNumber<uint8_t>(jCar["soundRange"], 255);
car.soundRange = Json::GetEnum<SoundRange>(jCar["soundRange"], SoundRange::none);
car.double_sound_frequency = Json::GetNumber<uint8_t>(jCar["doubleSoundFrequency"]);
car.powered_acceleration = Json::GetNumber<uint8_t>(jCar["poweredAcceleration"]);
car.powered_max_speed = Json::GetNumber<uint8_t>(jCar["poweredMaxSpeed"]);

View File

@@ -23,6 +23,8 @@ namespace OpenRCT2::Audio
enum class SoundId : uint8_t;
}
enum class SoundRange : uint8_t;
enum class CarEntryAnimation : uint8_t
{
None = 0,
@@ -213,7 +215,7 @@ struct CarEntry
uint8_t spinning_friction;
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;
SoundRange soundRange;
uint8_t double_sound_frequency; // (Doubles the velocity when working out the sound frequency {used on go karts})
uint8_t powered_acceleration;
uint8_t powered_max_speed;

View File

@@ -190,7 +190,7 @@ const CarEntry kCableLiftVehicle = {
.spinning_friction = 255,
.friction_sound_id = Audio::SoundId::LiftClassic,
.ReversedCarIndex = 0,
.sound_range = 0,
.soundRange = SoundRange::screamsMisc,
.double_sound_frequency = 0,
.powered_acceleration = 0,
.powered_max_speed = 0,

View File

@@ -94,16 +94,16 @@ uint8_t _vehicleF64E2C;
Vehicle* _vehicleFrontVehicle;
CoordsXYZ _vehicleCurPosition;
static constexpr OpenRCT2::Audio::SoundId _screamSet0[] = {
static constexpr OpenRCT2::Audio::SoundId _screamSetMisc[] = {
OpenRCT2::Audio::SoundId::Scream8,
OpenRCT2::Audio::SoundId::Scream1,
};
static constexpr OpenRCT2::Audio::SoundId _screamSet1Wooden[] = {
static constexpr OpenRCT2::Audio::SoundId _screamSetWooden[] = {
OpenRCT2::Audio::SoundId::Scream3, OpenRCT2::Audio::SoundId::Scream1, OpenRCT2::Audio::SoundId::Scream5,
OpenRCT2::Audio::SoundId::Scream6, OpenRCT2::Audio::SoundId::Scream7, OpenRCT2::Audio::SoundId::Scream2,
OpenRCT2::Audio::SoundId::Scream4,
};
static constexpr OpenRCT2::Audio::SoundId _screamSet2[] = {
static constexpr OpenRCT2::Audio::SoundId _screamSetSteel[] = {
OpenRCT2::Audio::SoundId::Scream1,
OpenRCT2::Audio::SoundId::Scream6,
};
@@ -2528,8 +2528,8 @@ void Vehicle::UpdateDeparting()
if (rideEntry->flags & RIDE_ENTRY_FLAG_PLAY_DEPART_SOUND)
{
auto soundId = (rideEntry->Cars[0].sound_range == 4) ? OpenRCT2::Audio::SoundId::Tram
: OpenRCT2::Audio::SoundId::TrainDeparting;
auto soundId = (rideEntry->Cars[0].soundRange == SoundRange::tramBell) ? OpenRCT2::Audio::SoundId::Tram
: OpenRCT2::Audio::SoundId::TrainDeparting;
OpenRCT2::Audio::Play3D(soundId, GetLocation());
}
@@ -4884,9 +4884,9 @@ void Vehicle::UpdateSound()
}
const auto currentTicks = getGameState().currentTicks;
switch (carEntry.sound_range)
switch (carEntry.soundRange)
{
case SOUND_RANGE_WHISTLE:
case SoundRange::steamWhistle:
screamSound.id = scream_sound_id;
if (!(currentTicks & 0x7F))
{
@@ -4908,7 +4908,7 @@ void Vehicle::UpdateSound()
screamSound.volume = 255;
break;
case SOUND_RANGE_BELL:
case SoundRange::tramBell:
screamSound.id = scream_sound_id;
if (!(currentTicks & 0x7F))
{
@@ -5032,16 +5032,16 @@ OpenRCT2::Audio::SoundId Vehicle::ProduceScreamSound(const int32_t totalNumPeeps
auto r = ScenarioRand();
if (totalNumPeeps >= static_cast<int32_t>(r % 16))
{
switch (carEntry.sound_range)
switch (carEntry.soundRange)
{
case SOUND_RANGE_SCREAMS_0:
scream_sound_id = _screamSet0[r % std::size(_screamSet0)];
case SoundRange::screamsMisc:
scream_sound_id = _screamSetMisc[r % std::size(_screamSetMisc)];
break;
case SOUND_RANGE_SCREAMS_1_WOODEN_COASTERS:
scream_sound_id = _screamSet1Wooden[r % std::size(_screamSet1Wooden)];
case SoundRange::screamsWoodenRollerCoaster:
scream_sound_id = _screamSetWooden[r % std::size(_screamSetWooden)];
break;
case SOUND_RANGE_SCREAMS_2:
scream_sound_id = _screamSet2[r % std::size(_screamSet2)];
case SoundRange::screamSteelRollerCoaster:
scream_sound_id = _screamSetSteel[r % std::size(_screamSetSteel)];
break;
default:
scream_sound_id = OpenRCT2::Audio::SoundId::NoScream;
@@ -8919,14 +8919,16 @@ void Vehicle::UpdateCrossings() const
void Vehicle::Claxon() const
{
const auto* rideEntry = GetRideEntry();
switch (rideEntry->Cars[vehicle_type].sound_range)
switch (rideEntry->Cars[vehicle_type].soundRange)
{
case SOUND_RANGE_WHISTLE:
case SoundRange::steamWhistle:
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::TrainWhistle, { x, y, z });
break;
case SOUND_RANGE_BELL:
case SoundRange::tramBell:
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Tram, { x, y, z });
break;
default:
break;
}
}

View File

@@ -535,14 +535,14 @@ enum
FRICTION_SOUND_NONE = 255
};
enum
enum class SoundRange : uint8_t
{
SOUND_RANGE_SCREAMS_0 = 0,
SOUND_RANGE_SCREAMS_1_WOODEN_COASTERS = 1,
SOUND_RANGE_SCREAMS_2 = 2,
SOUND_RANGE_WHISTLE = 3,
SOUND_RANGE_BELL = 4,
SOUND_RANGE_NONE = 255
screamsMisc = 0, // Used by rides where the screams should not include rolling sounds.
screamsWoodenRollerCoaster = 1,
screamSteelRollerCoaster = 2,
steamWhistle = 3,
tramBell = 4,
none = 255,
};
constexpr uint8_t kVehicleSeatPairFlag = 0x80;

View File

@@ -398,7 +398,7 @@ namespace OpenRCT2::Scripting
auto entry = GetEntry();
if (entry != nullptr)
{
return entry->sound_range;
return EnumValue(entry->soundRange);
}
return 0;
}