diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index c4501edeef..e81dd5970f 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -2883,12 +2883,6 @@ void Vehicle::UpdateCollisionSetup() velocity = 0; } -/** rct2: 0x009A3AC4, 0x009A3AC6 */ -static constexpr CoordsXY stru_9A3AC4[] = { - { -256, 0 }, { -236, 98 }, { -181, 181 }, { -98, 236 }, { 0, 256 }, { 98, 236 }, { 181, 181 }, { 236, 98 }, - { 256, 0 }, { 236, -98 }, { 181, -181 }, { 98, -236 }, { 0, -256 }, { -98, -236 }, { -181, -181 }, { -236, -98 }, -}; - /** * * rct2: 0x006D9EFE @@ -2922,8 +2916,8 @@ void Vehicle::UpdateCrashSetup() lastVehicle = trainVehicle; trainVehicle->sub_state = 0; - int32_t trainX = stru_9A3AC4[trainVehicle->Orientation / 2].x; - int32_t trainY = stru_9A3AC4[trainVehicle->Orientation / 2].y; + int32_t trainX = Geometry::kCrashDirectionComponents[trainVehicle->Orientation / 2].x; + int32_t trainY = Geometry::kCrashDirectionComponents[trainVehicle->Orientation / 2].y; auto carLaunchDirection = Geometry::getPitchVector32(trainVehicle->pitch); @@ -4922,7 +4916,7 @@ void Vehicle::UpdateSound() sound2_volume = soundIdVolume.volume; // Calculate Sound Vector (used for sound frequency calcs) - int32_t soundDirection = SpriteDirectionToSoundDirection[Orientation]; + int32_t soundDirection = Geometry::kSpriteDirectionToSoundDirection[Orientation]; int32_t soundVector = ((velocity >> 14) * soundDirection) >> 14; soundVector = std::clamp(soundVector, -127, 127); diff --git a/src/openrct2/ride/VehicleData.cpp b/src/openrct2/ride/VehicleData.cpp index c794105d62..ad3f4fd10d 100644 --- a/src/openrct2/ride/VehicleData.cpp +++ b/src/openrct2/ride/VehicleData.cpp @@ -794,40 +794,4 @@ const uint8_t MotionSimulatorTimeToSpriteMap[] = { }; const int32_t MotionSimulatorTimeToSpriteMapCount = static_cast(std::size(MotionSimulatorTimeToSpriteMap)); - -/** rct2: 0x009A3684 */ -const int32_t SpriteDirectionToSoundDirection[] = { - -0x4000, // 0 - -0x3000, // 1 - -0x2000, // 2 - -0x1000, // 3 - 0, // 4 - 0x1000, // 5 - 0x2000, // 6 - 0x3000, // 7 - 0x4000, // 8 - 0x4800, // 9 - 0x4800, // 10 - 0x4800, // 11 - 0x4800, // 12 - 0x4800, // 13 - 0x4800, // 14 - 0x4800, // 15 - 0x4000, // 16 - 0x3000, // 17 - 0x2000, // 18 - 0x1000, // 19 - 0, // 20 - -0x1000, // 21 - -0x2000, // 22 - -0x3000, // 23 - -0x4000, // 24 - -0x4800, // 25 - -0x4800, // 26 - -0x4800, // 27 - -0x4800, // 28 - -0x4800, // 29 - -0x4800, // 30 - -0x4800, // 31 -}; // clang-format on diff --git a/src/openrct2/ride/VehicleData.h b/src/openrct2/ride/VehicleData.h index 0618f82acd..8665a430d5 100644 --- a/src/openrct2/ride/VehicleData.h +++ b/src/openrct2/ride/VehicleData.h @@ -25,5 +25,3 @@ extern const TopSpinTimeToSpriteMap* TopSpinTimeToSpriteMaps[]; extern const uint8_t MotionSimulatorTimeToSpriteMap[]; extern const int32_t MotionSimulatorTimeToSpriteMapCount; - -extern const int32_t SpriteDirectionToSoundDirection[]; diff --git a/src/openrct2/ride/VehicleGeometry.cpp b/src/openrct2/ride/VehicleGeometry.cpp index 25a27e3a33..8148ee9ac6 100644 --- a/src/openrct2/ride/VehicleGeometry.cpp +++ b/src/openrct2/ride/VehicleGeometry.cpp @@ -190,4 +190,62 @@ namespace OpenRCT2::RideVehicle::Geometry -1859775391, 0, 2096579710, 1946281152, 2096579710, 1946281152, }); static_assert(std::size(kRollHorizontalComponent) == EnumValue(VehicleRoll::rollCount)); + + /** rct2: 0x009A3684 */ + constexpr auto kSpriteDirectionToSoundDirection = std::to_array({ + -0x4000, // 0 + -0x3000, // 1 + -0x2000, // 2 + -0x1000, // 3 + 0, // 4 + 0x1000, // 5 + 0x2000, // 6 + 0x3000, // 7 + 0x4000, // 8 + 0x4800, // 9 + 0x4800, // 10 + 0x4800, // 11 + 0x4800, // 12 + 0x4800, // 13 + 0x4800, // 14 + 0x4800, // 15 + 0x4000, // 16 + 0x3000, // 17 + 0x2000, // 18 + 0x1000, // 19 + 0, // 20 + -0x1000, // 21 + -0x2000, // 22 + -0x3000, // 23 + -0x4000, // 24 + -0x4800, // 25 + -0x4800, // 26 + -0x4800, // 27 + -0x4800, // 28 + -0x4800, // 29 + -0x4800, // 30 + -0x4800, // 31 + }); + + /** rct2: 0x009A3AC4, 0x009A3AC6 */ + constexpr auto kCrashDirectionComponents = std::to_array({ + { -256, 0 }, + { -236, 98 }, + { -181, 181 }, + { -98, 236 }, + { 0, 256 }, + { 98, 236 }, + { 181, 181 }, + { 236, 98 }, + { 256, 0 }, + { 236, -98 }, + { 181, -181 }, + { 98, -236 }, + { 0, -256 }, + { -98, -236 }, + { -181, -181 }, + { -236, -98 }, + }); + static_assert(std::size(kCrashDirectionComponents) == 16); + } // namespace OpenRCT2::RideVehicle::Geometry diff --git a/src/openrct2/ride/VehicleGeometry.h b/src/openrct2/ride/VehicleGeometry.h index 7768dbbddf..8358aa05e4 100644 --- a/src/openrct2/ride/VehicleGeometry.h +++ b/src/openrct2/ride/VehicleGeometry.h @@ -30,6 +30,8 @@ namespace OpenRCT2::RideVehicle::Geometry extern const std::array kAccelerationFromPitch; extern const std::array kPitchToDirectionVectorInt32; extern const std::array kRollHorizontalComponent; + extern const std::array kSpriteDirectionToSoundDirection; + extern const std::array kCrashDirectionComponents; /** The distance between subposition points in a movement vector. * Squashes vector components to 0 or !0, so vector length is ignored.