From 9a72a3e4968e733138ac273121d6ede096b36535 Mon Sep 17 00:00:00 2001 From: mix Date: Sun, 31 Aug 2025 11:24:05 +0100 Subject: [PATCH 1/6] Implement RCT1 spinning cars as a special paint mode --- src/openrct2/libopenrct2.vcxproj | 1 + .../vehicle/Vehicle.ClassicMiniSpinning.cpp | 110 ++++++++++++++++++ src/openrct2/paint/vehicle/VehiclePaint.cpp | 3 + src/openrct2/paint/vehicle/VehiclePaint.h | 3 + src/openrct2/rct1/Tables.cpp | 2 +- src/openrct2/ride/Vehicle.h | 3 +- 6 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 src/openrct2/paint/vehicle/Vehicle.ClassicMiniSpinning.cpp diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 3a45283ef5..abf3841227 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -1080,6 +1080,7 @@ + diff --git a/src/openrct2/paint/vehicle/Vehicle.ClassicMiniSpinning.cpp b/src/openrct2/paint/vehicle/Vehicle.ClassicMiniSpinning.cpp new file mode 100644 index 0000000000..ba771e03cf --- /dev/null +++ b/src/openrct2/paint/vehicle/Vehicle.ClassicMiniSpinning.cpp @@ -0,0 +1,110 @@ +/***************************************************************************** + * Copyright (c) 2014-2025 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "../../ride/Vehicle.h" + +#include "../../ride/Angles.h" +#include "../Paint.h" +#include "VehiclePaint.h" + +#include + +namespace OpenRCT2 +{ + struct PitchInfo + { + uint8_t imageIndex = 0; + uint8_t precisionShift = Entity::Yaw::kPrecisionOffset[EnumValue(Entity::Yaw::SpritePrecision::Sprites1)]; + uint8_t rotation = 0; + uint8_t boundingBoxIndex = 0; + uint8_t boundingBoxPrecisionShift = Entity::Yaw::kPrecisionOffset[EnumValue(Entity::Yaw::SpritePrecision::Sprites16)]; + }; + + constexpr const std::array kPitchInfos = []() consteval { + std::array pitchInfo; + namespace Yaw = OpenRCT2::Entity::Yaw; + const uint8_t reverse = Yaw::kBaseRotation / 2; + const uint8_t shift4 = Yaw::kPrecisionOffset[EnumValue(Yaw::SpritePrecision::Sprites4)]; + const uint8_t shift8 = Yaw::kPrecisionOffset[EnumValue(Yaw::SpritePrecision::Sprites8)]; + const uint8_t shift16 = Yaw::kPrecisionOffset[EnumValue(Yaw::SpritePrecision::Sprites16)]; + pitchInfo[EnumValue(VehiclePitch::up12)] = { 4, shift4, 0, 0, shift16 }; + pitchInfo[EnumValue(VehiclePitch::up25)] = { 68, shift16, 0, 16, shift16 }; + pitchInfo[EnumValue(VehiclePitch::up42)] = { 20, shift8, 0, 32, shift8 }; + pitchInfo[EnumValue(VehiclePitch::up60)] = { 52, shift4, 0, 40, shift16 }; + pitchInfo[EnumValue(VehiclePitch::down12)] = { 4, shift4, reverse, 0, shift16 }; + pitchInfo[EnumValue(VehiclePitch::down25)] = { 68, shift16, reverse, 16, shift16 }; + pitchInfo[EnumValue(VehiclePitch::down42)] = { 20, shift8, reverse, 32, shift8 }; + pitchInfo[EnumValue(VehiclePitch::down60)] = { 52, shift4, reverse, 40, shift16 }; + pitchInfo[EnumValue(VehiclePitch::up8)] = { 135, shift4, 0, 0, shift16 }; + pitchInfo[EnumValue(VehiclePitch::up16)] = { 151, shift4, 0, 0, shift16 }; + pitchInfo[EnumValue(VehiclePitch::up50)] = { 167, shift4, 0, 104, shift4 }; + pitchInfo[EnumValue(VehiclePitch::down8)] = { 135, shift4, reverse, 0, shift16 }; + pitchInfo[EnumValue(VehiclePitch::down16)] = { 151, shift4, reverse, 0, shift16 }; + pitchInfo[EnumValue(VehiclePitch::down50)] = { 167, shift4, reverse, 104, shift4 }; + return pitchInfo; + }(); + + void VehicleVisualClassicMiniSpinning( + PaintSession& session, const int32_t x, const int32_t imageDirection, const int32_t y, const int32_t z, + const Vehicle* const vehicle, const CarEntry* const carEntry) + { + constexpr const int32_t spriteCount = 183; + constexpr const int32_t spriteRotationPrecision = 4; + constexpr const int32_t rotationPrecision = 16; + + const PitchInfo& pitchInfo = kPitchInfos[EnumValue(vehicle->pitch)]; + const int32_t rotatedImageDirection = OpenRCT2::Entity::Yaw::YawTo32(imageDirection) ^ pitchInfo.rotation; + const ImageIndex pitchImageIndex = pitchInfo.imageIndex + + (rotatedImageDirection >> pitchInfo.precisionShift) * spriteRotationPrecision; + + const int32_t spin = vehicle->spin_sprite >> 4; + const ImageIndex rotationImageIndex = spin & (spriteRotationPrecision - 1); + + const ImageIndex carImageIndex = carEntry->base_image_id + pitchImageIndex + rotationImageIndex; + + constexpr const int32_t restraintsImageIndexOffset = 132; + constexpr const int32_t restraintsInterval = 64; + const bool restraints = vehicle->restraints_position >= restraintsInterval; + const ImageIndex restraintsImageIndex = carEntry->base_image_id + restraintsImageIndexOffset + + ((vehicle->restraints_position - restraintsInterval) / restraintsInterval); + + const ImageIndex imageIndex = ((!restraints) * carImageIndex) + (restraints * restraintsImageIndex); + const ImageId imageId = vehicle->IsGhost() ? ConstructionMarker.WithIndex(imageIndex) + : ImageId(imageIndex, vehicle->colours.Body, vehicle->colours.Trim); + + const uint32_t boundingBoxIndex = pitchInfo.boundingBoxIndex + + (rotatedImageDirection >> pitchInfo.boundingBoxPrecisionShift); + const VehicleBoundBox& bb = VehicleBoundboxes[carEntry->draw_order][boundingBoxIndex]; + const BoundBoxXYZ boundingBox = { { bb.offset_x, bb.offset_y, bb.offset_z + z }, + { bb.length_x, bb.length_y, bb.length_z } }; + PaintAddImageAsParent(session, imageId, { 0, 0, z }, boundingBox); + + if (session.rt.zoom_level < ZoomLevel{ 2 }) + { + for (int32_t i = 0; i < vehicle->num_peeps / 2; i++) + { + const int32_t seatRotation = i * spriteRotationPrecision; + const int32_t guestRotationPrecision = rotationPrecision / 2; + const int32_t rotation = spin + (session.CurrentRotation * 4) + seatRotation; + const int32_t guestRotation = rotation & (guestRotationPrecision - 1); + const ImageIndex guestImageIndexOffset = guestRotation >= 4 ? spriteCount * 2 : spriteCount; + + const ImageIndex guestImageIndex = imageIndex + guestImageIndexOffset; + + const bool swapGuestColours = (rotation & (rotationPrecision - 1)) >= guestRotationPrecision; + const Drawing::Colour guestColour0 = vehicle->peep_tshirt_colours[(i * 2) + swapGuestColours]; + const Drawing::Colour guestColour1 = vehicle->peep_tshirt_colours[(i * 2) + !swapGuestColours]; + + const ImageId guestImageId = vehicle->IsGhost() ? ConstructionMarker.WithIndex(guestImageIndex) + : ImageId(guestImageIndex, guestColour0, guestColour1); + PaintAddImageAsChild(session, guestImageId, { 0, 0, z }, boundingBox); + } + } + } +} // namespace OpenRCT2 diff --git a/src/openrct2/paint/vehicle/VehiclePaint.cpp b/src/openrct2/paint/vehicle/VehiclePaint.cpp index b6182a2cca..3fda7d00e9 100644 --- a/src/openrct2/paint/vehicle/VehiclePaint.cpp +++ b/src/openrct2/paint/vehicle/VehiclePaint.cpp @@ -4783,5 +4783,8 @@ void Vehicle::Paint(PaintSession& session, int32_t imageDirection) const case VEHICLE_VISUAL_SUBMARINE: VehicleVisualSubmarine(session, x, imageDirection, y, z + zOffset, this, carEntry); break; + case VEHICLE_VISUAL_SPINNING_CARS: + VehicleVisualClassicMiniSpinning(session, x, imageDirection, y, z + zOffset, this, carEntry); + break; } } diff --git a/src/openrct2/paint/vehicle/VehiclePaint.h b/src/openrct2/paint/vehicle/VehiclePaint.h index aee9142fab..8bddfd7dd7 100644 --- a/src/openrct2/paint/vehicle/VehiclePaint.h +++ b/src/openrct2/paint/vehicle/VehiclePaint.h @@ -61,4 +61,7 @@ namespace OpenRCT2 PaintSession& session, int32_t x, int32_t imageDirection, int32_t y, int32_t z, const Vehicle* vehicle); void VehicleVisualMiniGolfBall( PaintSession& session, int32_t x, int32_t imageDirection, int32_t y, int32_t z, const Vehicle* vehicle); + void VehicleVisualClassicMiniSpinning( + PaintSession& session, int32_t x, int32_t imageDirection, int32_t y, int32_t z, const Vehicle* vehicle, + const CarEntry* carEntry); } // namespace OpenRCT2 diff --git a/src/openrct2/rct1/Tables.cpp b/src/openrct2/rct1/Tables.cpp index a878e271a7..f6772535be 100644 --- a/src/openrct2/rct1/Tables.cpp +++ b/src/openrct2/rct1/Tables.cpp @@ -806,7 +806,7 @@ namespace OpenRCT2::RCT1 "rct1.ride.suspended_swinging_cars", // VehicleType::suspendedSwingingCars "rct1.ride.ladybird_trains", // VehicleType::ladybirdCars "rct1.ride.stand_up_trains", // VehicleType::standupRollerCoasterCars - "rct2.ride.wmspin", // VehicleType::spinningCars + "rct1.ride.spinning_cars", // VehicleType::spinningCars "rct1.ride.single_person_swinging_cars", // VehicleType::singlePersonSwingingChairs "rct2.ride.swans", // VehicleType::swansPedalBoats "rct1.ride.streamlined_monorail_trains", // VehicleType::largeMonorailTrain diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index 1e93e05fde..84a55e1338 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -506,7 +506,8 @@ enum VEHICLE_VISUAL_SPLASH4_EFFECT, VEHICLE_VISUAL_SPLASH5_EFFECT, VEHICLE_VISUAL_VIRGINIA_REEL, - VEHICLE_VISUAL_SUBMARINE + VEHICLE_VISUAL_SUBMARINE, + VEHICLE_VISUAL_SPINNING_CARS, }; enum : uint32_t From 4734187a11ceb2647ce5798f111976d7327da936 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 10 Mar 2026 00:03:13 +0100 Subject: [PATCH 2/6] Limit the Spinning Cars paint style to just our Spinning Cars port --- src/openrct2/object/RideObject.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/openrct2/object/RideObject.cpp b/src/openrct2/object/RideObject.cpp index 16cfae5463..b2124bb65f 100644 --- a/src/openrct2/object/RideObject.cpp +++ b/src/openrct2/object/RideObject.cpp @@ -451,6 +451,9 @@ namespace OpenRCT2 car.powered_acceleration = stream->ReadValue(); car.powered_max_speed = stream->ReadValue(); car.PaintStyle = stream->ReadValue(); + // Since this animation style may be replaced with a generic spinner system, make sure it gets limited to just our port. + if (car.PaintStyle == VEHICLE_VISUAL_SPINNING_CARS) + car.PaintStyle = VEHICLE_VISUAL_DEFAULT; car.effect_visual = stream->ReadValue(); car.draw_order = stream->ReadValue(); car.num_vertical_frames_override = stream->ReadValue(); @@ -763,6 +766,13 @@ namespace OpenRCT2 car.powered_acceleration = Json::GetNumber(jCar["poweredAcceleration"]); car.powered_max_speed = Json::GetNumber(jCar["poweredMaxSpeed"]); car.PaintStyle = Json::GetNumber(jCar["carVisual"]); + // Since this animation style may be replaced with a generic spinner system, make sure it gets limited to just our port. + if (car.PaintStyle == VEHICLE_VISUAL_SPINNING_CARS + && (GetIdentifier() != "rct1.ride.spinning_cars" + || _legacyType.ride_type[0] != RIDE_TYPE_CLASSIC_MINI_ROLLER_COASTER)) + { + car.PaintStyle = VEHICLE_VISUAL_DEFAULT; + } car.effect_visual = Json::GetNumber(jCar["effectVisual"], 1); car.draw_order = Json::GetNumber(jCar["drawOrder"]); car.num_vertical_frames_override = Json::GetNumber(jCar["numVerticalFramesOverride"]); From 37e3506d66f5704acb9a2d8df287069fd3bdf6e0 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 10 Mar 2026 11:17:35 +0100 Subject: [PATCH 3/6] Fix track piece availability --- src/openrct2-ui/windows/RideConstruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index f41bac5e9a..c786bd7fec 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2860,7 +2860,7 @@ namespace OpenRCT2::Ui::Windows // Non-default vehicle visuals do not use this system, so we have to assume it supports all the track pieces. auto& firstCar = currentRideEntry->Cars[0]; - if (firstCar.PaintStyle != VEHICLE_VISUAL_DEFAULT + if ((firstCar.PaintStyle != VEHICLE_VISUAL_DEFAULT && firstCar.PaintStyle != VEHICLE_VISUAL_SPINNING_CARS) || firstCar.flags.hasAny(CarEntryFlag::isChairlift, CarEntryFlag::useSlideSwing)) { disabledGroups.reset(); From 1dcee390ba6c3e1586cff1973ae30254370c3fbe Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 10 Mar 2026 22:14:07 +0100 Subject: [PATCH 4/6] Update objects to v1.7.8 --- assets.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets.json b/assets.json index c62ac1b6d0..1a31bdb833 100644 --- a/assets.json +++ b/assets.json @@ -1,7 +1,7 @@ { "objects": { - "url": "https://github.com/OpenRCT2/objects/releases/download/v1.7.7/objects.zip", - "sha256": "54d28a134a1af12fb2a863564def6e6e226a003559856c7df4ae0e94ef7334fd" + "url": "https://github.com/OpenRCT2/objects/releases/download/v1.7.8/objects.zip", + "sha256": "3d1d98802c6a0cd27f195a0ae7aa05067a071157d776f3326b49f3012c2311bb" }, "openmusic": { "url": "https://github.com/OpenRCT2/OpenMusic/releases/download/v1.6.1/openmusic.zip", From d4db9c5d0a1a1e3faec5ce2c629af14ad901b238 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 10 Mar 2026 22:27:42 +0100 Subject: [PATCH 5/6] Implement "noReverseOption" flag --- src/openrct2-ui/windows/Ride.cpp | 3 ++- src/openrct2/object/RideObject.cpp | 1 + src/openrct2/ride/RideEntry.h | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 5264424f86..8742aee3e5 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -2908,7 +2908,8 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_VEHICLE_CARS_PER_TRAIN_DECREASE].type = WidgetType::empty; } - if (ride->getRideTypeDescriptor().flags.has(RtdFlag::allowReversedTrains) + if ((ride->getRideTypeDescriptor().flags.has(RtdFlag::allowReversedTrains) + && !rideEntry->flags.has(RideEntryFlag::noReverseOption)) || (gameState.cheats.disableTrainLengthLimit && !ride->getRideTypeDescriptor().flags.has(RtdFlag::isFlatRide))) { widgets[WIDX_VEHICLE_REVERSED_TRAINS_CHECKBOX].type = WidgetType::checkbox; diff --git a/src/openrct2/object/RideObject.cpp b/src/openrct2/object/RideObject.cpp index b2124bb65f..f85e326fda 100644 --- a/src/openrct2/object/RideObject.cpp +++ b/src/openrct2/object/RideObject.cpp @@ -672,6 +672,7 @@ namespace OpenRCT2 { "disablePainting", RideEntryFlag::disableColourTab }, { "riderControlsSpeed", RideEntryFlag::riderControlsSpeed }, { "hideEmptyTrains", RideEntryFlag::hideEmptyTrains }, + { "noReverseOption", RideEntryFlag::noReverseOption }, }); } diff --git a/src/openrct2/ride/RideEntry.h b/src/openrct2/ride/RideEntry.h index 007f50de05..ffc7dd6edd 100644 --- a/src/openrct2/ride/RideEntry.h +++ b/src/openrct2/ride/RideEntry.h @@ -67,6 +67,9 @@ enum class RideEntryFlag : uint8_t magicCarpetSwingMode, riderControlsSpeed, hideEmptyTrains, + // Hide the ‘Reverse trains’ checkbox in the Ride window. Used for symmetrical spinning trains and legacy pre-reversed + // vehicles (to avoid double-dipping on the reverse bonus). + noReverseOption, }; using RideEntryFlags = FlagHolder; From 7d15f54080a6932001b81ef0ac7d1b147f6cac5b Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 10 Mar 2026 22:30:02 +0100 Subject: [PATCH 6/6] Update changelog --- distribution/changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 0c506d0221..6179ad9634 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,6 +1,8 @@ 0.4.33 (in development) ------------------------------------------------------------------------ +- Feature: [#26178] Port of the Spinning Cars from RollerCoaster Tycoon 1. - Change: [#25962] The station style dropdown now shows entrance icons next to the labels for easier selection. +- Change: [#26178] Symmetric spinning trains and legacy ‘pre-reversed’ trains can no longer be reversed. - Fix: [#10616] Quarter-tile trees cannot be placed on dry portions of half-water tiles. - Fix: [#25735] Ride synchronisation z-check works incorrectly. - Fix: [#25962] Dropdown triangle glyphs are not optically centred.