From ea467ff723707c54995ca18fe03c6338067a23db Mon Sep 17 00:00:00 2001 From: Spacek531 Date: Mon, 20 Oct 2025 16:10:55 -0700 Subject: [PATCH] move array unk9A36C4 to kFreeroamVehicleMovementData --- src/openrct2/ride/Vehicle.cpp | 35 +++++++-------------------- src/openrct2/ride/VehicleGeometry.cpp | 11 +++++++++ src/openrct2/ride/VehicleGeometry.h | 9 +++++++ 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index bdf162a867..366883eec5 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -380,23 +380,6 @@ static constexpr const int8_t* SwingingTimeToSpriteMaps[] = { kSwingingTimeToSpriteMap8, kSwingingTimeToSpriteMap9, kSwingingTimeToSpriteMap10, kSwingingTimeToSpriteMap11, }; -struct Unk9A36C4Struct -{ - int16_t x; - int16_t y; - uint32_t distance; -}; - -/** rct2: 0x009A36C4 */ -static constexpr Unk9A36C4Struct kUnk9A36C4[] = { - { -1, 0, 8716 }, { -1, 0, 8716 }, { -1, 0, 8716 }, { -1, 1, 12327 }, { -1, 1, 12327 }, { -1, 1, 12327 }, - { 0, 1, 8716 }, { -1, 1, 12327 }, { 0, 1, 8716 }, { 0, 1, 8716 }, { 0, 1, 8716 }, { 1, 1, 12327 }, - { 1, 1, 12327 }, { 1, 1, 12327 }, { 1, 0, 8716 }, { 1, 1, 12327 }, { 1, 0, 8716 }, { 1, 0, 8716 }, - { 1, 0, 8716 }, { 1, -1, 12327 }, { 1, -1, 12327 }, { 1, -1, 12327 }, { 0, -1, 8716 }, { 1, -1, 12327 }, - { 0, -1, 8716 }, { 0, -1, 8716 }, { 0, -1, 8716 }, { -1, -1, 12327 }, { -1, -1, 12327 }, { -1, -1, 12327 }, - { -1, 0, 8716 }, { -1, -1, 12327 }, -}; - /** rct2: 0x009A37C4 */ static constexpr CoordsXY kSurroundingTiles[] = { { 0, 0 }, @@ -3792,7 +3775,7 @@ void Vehicle::UpdateMotionBoatHire() } int32_t edi = (Orientation | (var_35 & 1)) & 0x1F; - loc2 = { x + kUnk9A36C4[edi].x, y + kUnk9A36C4[edi].y }; + loc2 = { x + Geometry::kFreeroamVehicleMovementData[edi].x, y + Geometry::kFreeroamVehicleMovementData[edi].y }; if (UpdateMotionCollisionDetection({ loc2, z }, nullptr)) { remaining_distance = 0; @@ -3890,7 +3873,7 @@ void Vehicle::UpdateMotionBoatHire() TrackLocation = { flooredLocation, TrackLocation.z }; } - remaining_distance -= kUnk9A36C4[edi].distance; + remaining_distance -= Geometry::kFreeroamVehicleMovementData[edi].distance; _vehicleCurPosition.x = loc2.x; _vehicleCurPosition.y = loc2.y; if (remaining_distance < 0x368A) @@ -5229,10 +5212,10 @@ int32_t Vehicle::UpdateMotionDodgems() CoordsXYZ location = { x, y, z }; - location.x += kUnk9A36C4[oldCollisionDirection].x; - location.y += kUnk9A36C4[oldCollisionDirection].y; - location.x += kUnk9A36C4[oldCollisionDirection + 1].x; - location.y += kUnk9A36C4[oldCollisionDirection + 1].y; + location.x += Geometry::kFreeroamVehicleMovementData[oldCollisionDirection].x; + location.y += Geometry::kFreeroamVehicleMovementData[oldCollisionDirection].y; + location.x += Geometry::kFreeroamVehicleMovementData[oldCollisionDirection + 1].x; + location.y += Geometry::kFreeroamVehicleMovementData[oldCollisionDirection + 1].y; if (collideSprite = DodgemsCarWouldCollideAt(location); !collideSprite.has_value()) { @@ -5256,15 +5239,15 @@ int32_t Vehicle::UpdateMotionDodgems() direction |= var_35 & 1; CoordsXY location = _vehicleCurPosition; - location.x += kUnk9A36C4[direction].x; - location.y += kUnk9A36C4[direction].y; + location.x += Geometry::kFreeroamVehicleMovementData[direction].x; + location.y += Geometry::kFreeroamVehicleMovementData[direction].y; if (collideSprite = DodgemsCarWouldCollideAt(location); collideSprite.has_value()) { break; } - remaining_distance -= kUnk9A36C4[direction].distance; + remaining_distance -= Geometry::kFreeroamVehicleMovementData[direction].distance; _vehicleCurPosition.x = location.x; _vehicleCurPosition.y = location.y; if (remaining_distance < 13962) diff --git a/src/openrct2/ride/VehicleGeometry.cpp b/src/openrct2/ride/VehicleGeometry.cpp index 53c241aa9d..70e2f56cbf 100644 --- a/src/openrct2/ride/VehicleGeometry.cpp +++ b/src/openrct2/ride/VehicleGeometry.cpp @@ -38,4 +38,15 @@ namespace OpenRCT2::RideVehicle::Geometry }); static_assert(std::size(kSubpositionTranslationDistances) == 16); + /** rct2: 0x009A36C4 */ + constexpr auto kFreeroamVehicleMovementData = std::to_array( { + { -1, 0, 8716 }, { -1, 0, 8716 }, { -1, 0, 8716 }, { -1, 1, 12327 }, { -1, 1, 12327 }, { -1, 1, 12327 }, + { 0, 1, 8716 }, { -1, 1, 12327 }, { 0, 1, 8716 }, { 0, 1, 8716 }, { 0, 1, 8716 }, { 1, 1, 12327 }, + { 1, 1, 12327 }, { 1, 1, 12327 }, { 1, 0, 8716 }, { 1, 1, 12327 }, { 1, 0, 8716 }, { 1, 0, 8716 }, + { 1, 0, 8716 }, { 1, -1, 12327 }, { 1, -1, 12327 }, { 1, -1, 12327 }, { 0, -1, 8716 }, { 1, -1, 12327 }, + { 0, -1, 8716 }, { 0, -1, 8716 }, { 0, -1, 8716 }, { -1, -1, 12327 }, { -1, -1, 12327 }, { -1, -1, 12327 }, + { -1, 0, 8716 }, { -1, -1, 12327 }, + }); + static_assert(std::size(kFreeroamVehicleMovementData) == 32); + } // namespace OpenRCT2::RideVehicle::Geometry diff --git a/src/openrct2/ride/VehicleGeometry.h b/src/openrct2/ride/VehicleGeometry.h index 918b886046..68aea8c92e 100644 --- a/src/openrct2/ride/VehicleGeometry.h +++ b/src/openrct2/ride/VehicleGeometry.h @@ -17,7 +17,16 @@ namespace OpenRCT2::RideVehicle::Geometry { + + struct Unk9A36C4Struct + { + int16_t x; + int16_t y; + uint32_t distance; + }; + extern const std::array kSubpositionTranslationDistances; + extern const std::array kFreeroamVehicleMovementData; /** The distance between subposition points in a movement vector. * Squashes vector components to 0 or !0, so vector length is ignored.