From 24a5446e8c8d786ab820bb2e89d1e56089f7624f Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 12 May 2021 08:04:29 +0100 Subject: [PATCH] Move particle functions into class --- src/openrct2/ride/Vehicle.cpp | 16 ++++++++-------- src/openrct2/world/Particle.cpp | 6 +++--- src/openrct2/world/Particle.h | 6 ++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 8e625863ff..ae2222d7fc 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -3603,7 +3603,7 @@ void Vehicle::UpdateCollisionSetup() for (int32_t i = 0; i < 10; i++) { - crashed_vehicle_particle_create(train->colours, { train->x, train->y, train->z }); + VehicleCrashParticle::Create(train->colours, { train->x, train->y, train->z }); } train->IsCrashedVehicle = true; @@ -5363,7 +5363,7 @@ void Vehicle::CrashOnLand() uint8_t numParticles = std::min(sprite_width, static_cast(7)); while (numParticles-- != 0) - crashed_vehicle_particle_create(colours, { x, y, z }); + VehicleCrashParticle::Create(colours, { x, y, z }); IsCrashedVehicle = true; animation_frame = 0; @@ -5419,14 +5419,14 @@ void Vehicle::CrashOnWater() sub_state = 2; OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Water1, { x, y, z }); - crash_splash_create({ x, y, z }); - crash_splash_create({ x - 8, y - 9, z }); - crash_splash_create({ x + 11, y - 9, z }); - crash_splash_create({ x + 11, y + 8, z }); - crash_splash_create({ x - 4, y + 8, z }); + CrashSplashParticle::Create({ x, y, z }); + CrashSplashParticle::Create({ x - 8, y - 9, z }); + CrashSplashParticle::Create({ x + 11, y - 9, z }); + CrashSplashParticle::Create({ x + 11, y + 8, z }); + CrashSplashParticle::Create({ x - 4, y + 8, z }); for (int32_t i = 0; i < 10; ++i) - crashed_vehicle_particle_create(colours, { x - 4, y + 8, z }); + VehicleCrashParticle::Create(colours, { x - 4, y + 8, z }); IsCrashedVehicle = true; animation_frame = 0; diff --git a/src/openrct2/world/Particle.cpp b/src/openrct2/world/Particle.cpp index 56796c8134..965797e4e3 100644 --- a/src/openrct2/world/Particle.cpp +++ b/src/openrct2/world/Particle.cpp @@ -28,7 +28,7 @@ template<> bool SpriteBase::Is() const * * rct2: 0x006735A1 */ -void crashed_vehicle_particle_create(rct_vehicle_colour colours, const CoordsXYZ& vehiclePos) +void VehicleCrashParticle::Create(rct_vehicle_colour colours, const CoordsXYZ& vehiclePos) { VehicleCrashParticle* sprite = CreateEntity(); if (sprite != nullptr) @@ -93,7 +93,7 @@ void VehicleCrashParticle::Update() { // Splash OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Water2, { x, y, waterZ }); - crash_splash_create({ x, y, waterZ }); + CrashSplashParticle::Create({ x, y, waterZ }); sprite_remove(this); return; } @@ -117,7 +117,7 @@ void VehicleCrashParticle::Update() * * rct2: 0x00673699 */ -void crash_splash_create(const CoordsXYZ& splashPos) +void CrashSplashParticle::Create(const CoordsXYZ& splashPos) { auto* sprite = CreateEntity(); if (sprite != nullptr) diff --git a/src/openrct2/world/Particle.h b/src/openrct2/world/Particle.h index 68b71cffc4..fd764c2ad3 100644 --- a/src/openrct2/world/Particle.h +++ b/src/openrct2/world/Particle.h @@ -27,7 +27,7 @@ struct VehicleCrashParticle : MiscEntity int32_t acceleration_x; int32_t acceleration_y; int32_t acceleration_z; - + static void Create(rct_vehicle_colour colours, const CoordsXYZ& vehiclePos); void Update(); void Serialise(DataSerialiser& stream); }; @@ -35,9 +35,7 @@ struct VehicleCrashParticle : MiscEntity struct CrashSplashParticle : MiscEntity { static constexpr auto cEntityType = EntityType::CrashSplash; + static void Create(const CoordsXYZ& splashPos); void Update(); void Serialise(DataSerialiser& stream); }; - -void crashed_vehicle_particle_create(rct_vehicle_colour colours, const CoordsXYZ& vehiclePos); -void crash_splash_create(const CoordsXYZ& splashPos);