diff --git a/src/openrct2/ride/gentle/SpiralSlide.cpp b/src/openrct2/ride/gentle/SpiralSlide.cpp index 672909dbbc..67391302bb 100644 --- a/src/openrct2/ride/gentle/SpiralSlide.cpp +++ b/src/openrct2/ride/gentle/SpiralSlide.cpp @@ -12,55 +12,60 @@ #include "../../paint/Paint.h" #include "../../paint/Supports.h" #include "../Ride.h" +#include "../RideEntry.h" #include "../Track.h" #include "../TrackPaint.h" enum { - SPIRAL_SLIDE_LEFT_R0 = 20548, - SPIRAL_SLIDE_CENTRE_R0 = 20549, - SPIRAL_SLIDE_RIGHT_R0 = 20550, + SPIRAL_SLIDE_LEFT_R0 = 0, + SPIRAL_SLIDE_CENTRE_R0 = 1, + SPIRAL_SLIDE_RIGHT_R0 = 2, - SPIRAL_SLIDE_LEFT_R1 = 20551, - SPIRAL_SLIDE_CENTRE_R1 = 20552, - SPIRAL_SLIDE_RIGHT_R1 = 20553, + SPIRAL_SLIDE_LEFT_R1 = 3, + SPIRAL_SLIDE_CENTRE_R1 = 4, + SPIRAL_SLIDE_RIGHT_R1 = 5, - SPIRAL_SLIDE_LEFT_R2 = 20554, - SPIRAL_SLIDE_CENTRE_R2 = 20555, - SPIRAL_SLIDE_RIGHT_R2 = 20556, + SPIRAL_SLIDE_LEFT_R2 = 6, + SPIRAL_SLIDE_CENTRE_R2 = 7, + SPIRAL_SLIDE_RIGHT_R2 = 8, - SPIRAL_SLIDE_LEFT_R3 = 20557, - SPIRAL_SLIDE_CENTRE_R3 = 20558, - SPIRAL_SLIDE_RIGHT_R3 = 20559, + SPIRAL_SLIDE_LEFT_R3 = 9, + SPIRAL_SLIDE_CENTRE_R3 = 10, + SPIRAL_SLIDE_RIGHT_R3 = 11, - SPIRAL_SLIDE_INSIDE_R1 = 20560, - SPIRAL_SLIDE_INSIDE_R2 = 20561, + SPIRAL_SLIDE_INSIDE_R1 = 12, + SPIRAL_SLIDE_INSIDE_R2 = 13, - SPIRAL_SLIDE_BASE_A = 20562, - SPIRAL_SLIDE_BASE_B = 20563, + SPIRAL_SLIDE_BASE_A = 14, + SPIRAL_SLIDE_BASE_B = 15, - SPIRAL_SLIDE_FENCE_TOP_RIGHT = 20564, - SPIRAL_SLIDE_FENCE_BOTTOM_RIGHT = 20565, - SPIRAL_SLIDE_FENCE_BOTTOM_LEFT = 20566, - SPIRAL_SLIDE_FENCE_TOP_LEFT = 20567, + SPIRAL_SLIDE_FENCE_TOP_RIGHT = 16, + SPIRAL_SLIDE_FENCE_BOTTOM_RIGHT = 17, + SPIRAL_SLIDE_FENCE_BOTTOM_LEFT = 18, + SPIRAL_SLIDE_FENCE_TOP_LEFT = 19, - SPIRAL_SLIDE_PEEP = 20568, // 46 sprites per direction + SPIRAL_SLIDE_PEEP = 20, // 46 sprites per direction }; static void spiral_slide_paint_tile_right( paint_session& session, const Ride& ride, uint8_t trackSequence, uint8_t direction, int32_t height, const TrackElement& trackElement) { + auto rideEntry = ride.GetRideEntry(); + if (rideEntry == nullptr) + return; + uint32_t image_id = 0; if (direction == 0) - image_id = SPIRAL_SLIDE_RIGHT_R0 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_RIGHT_R0) | session.TrackColours[SCHEME_TRACK]; if (direction == 1) - image_id = SPIRAL_SLIDE_RIGHT_R1 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_RIGHT_R1) | session.TrackColours[SCHEME_TRACK]; if (direction == 2) - image_id = SPIRAL_SLIDE_RIGHT_R2 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_RIGHT_R2) | session.TrackColours[SCHEME_TRACK]; if (direction == 3) - image_id = SPIRAL_SLIDE_RIGHT_R3 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_RIGHT_R3) | session.TrackColours[SCHEME_TRACK]; PaintAddImageAsParent(session, image_id, { 16, 16, height }, { 16, 16, 108 }, { 16, 0, height + 3 }); } @@ -69,16 +74,20 @@ static void spiral_slide_paint_tile_left( paint_session& session, const Ride& ride, uint8_t trackSequence, uint8_t direction, int32_t height, const TrackElement& trackElement) { + auto rideEntry = ride.GetRideEntry(); + if (rideEntry == nullptr) + return; + uint32_t image_id = 0; if (direction == 0) - image_id = SPIRAL_SLIDE_LEFT_R0 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_LEFT_R0) | session.TrackColours[SCHEME_TRACK]; if (direction == 1) - image_id = SPIRAL_SLIDE_LEFT_R1 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_LEFT_R1) | session.TrackColours[SCHEME_TRACK]; if (direction == 2) - image_id = SPIRAL_SLIDE_LEFT_R2 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_LEFT_R2) | session.TrackColours[SCHEME_TRACK]; if (direction == 3) - image_id = SPIRAL_SLIDE_LEFT_R3 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_LEFT_R3) | session.TrackColours[SCHEME_TRACK]; PaintAddImageAsParent(session, image_id, { 16, 16, height }, { 16, 16, 108 }, { 0, 16, height + 3 }); } @@ -87,37 +96,41 @@ static void spiral_slide_paint_tile_front( paint_session& session, const Ride& ride, uint8_t trackSequence, uint8_t direction, int32_t height, const TrackElement& trackElement) { + auto rideEntry = ride.GetRideEntry(); + if (rideEntry == nullptr) + return; + uint32_t image_id = 0; if (direction == 1) { - image_id = SPIRAL_SLIDE_INSIDE_R1 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_INSIDE_R1) | session.TrackColours[SCHEME_TRACK]; PaintAddImageAsParent(session, image_id, { 16, 16, height }, { 2, 16, 108 }, { -12, 0, height + 3 }); } else if (direction == 2) { - image_id = SPIRAL_SLIDE_INSIDE_R2 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_INSIDE_R2) | session.TrackColours[SCHEME_TRACK]; PaintAddImageAsParent(session, image_id, { 16, 16, height }, { 16, 2, 108 }, { 0, -12, height + 3 }); } if (direction == 0) { - image_id = SPIRAL_SLIDE_CENTRE_R0 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_CENTRE_R0) | session.TrackColours[SCHEME_TRACK]; PaintAddImageAsParent(session, image_id, { 16, 16, height }, { 16, 8, 108 }, { 0, 8, height + 3 }); } else if (direction == 1) { - image_id = SPIRAL_SLIDE_CENTRE_R1 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_CENTRE_R1) | session.TrackColours[SCHEME_TRACK]; PaintAddImageAsParent(session, image_id, { 16, 16, height }, { 2, 16, 108 }, { 14, 0, height + 3 }); } else if (direction == 2) { - image_id = SPIRAL_SLIDE_CENTRE_R2 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_CENTRE_R2) | session.TrackColours[SCHEME_TRACK]; PaintAddImageAsParent(session, image_id, { 16, 16, height }, { 16, 2, 108 }, { 0, 14, height + 3 }); } else if (direction == 3) { - image_id = SPIRAL_SLIDE_CENTRE_R3 | session.TrackColours[SCHEME_TRACK]; + image_id = (rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_CENTRE_R3) | session.TrackColours[SCHEME_TRACK]; PaintAddImageAsParent(session, image_id, { 16, 16, height }, { 8, 16, 108 }, { 8, 0, height + 3 }); } @@ -137,7 +150,7 @@ static void spiral_slide_paint_tile_front( if (slide_progress < 46) { - int32_t offset = SPIRAL_SLIDE_PEEP + 46 * direction; + int32_t offset = rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_PEEP + 46 * direction; CoordsXYZ boundingBox = { 0, 0, 108 }; CoordsXYZ boundingBoxOffset = { 0, 0, static_cast(height + 3) }; @@ -177,13 +190,6 @@ static void spiral_slide_paint_tile_front( } } -static constexpr const uint32_t spiral_slide_fence_sprites[] = { - SPIRAL_SLIDE_FENCE_TOP_RIGHT, - SPIRAL_SLIDE_FENCE_BOTTOM_RIGHT, - SPIRAL_SLIDE_FENCE_BOTTOM_LEFT, - SPIRAL_SLIDE_FENCE_TOP_LEFT, -}; - /** * rct: 0x007485C8 */ @@ -191,6 +197,10 @@ static void paint_spiral_slide( paint_session& session, const Ride& ride, uint8_t trackSequence, uint8_t direction, int32_t height, const TrackElement& trackElement) { + auto rideEntry = ride.GetRideEntry(); + if (rideEntry == nullptr) + return; + trackSequence = track_map_2x2[direction][trackSequence]; int32_t edges = edges_2x2[trackSequence]; @@ -202,11 +212,19 @@ static void paint_spiral_slide( if (stationObject != nullptr && !(stationObject->Flags & STATION_OBJECT_FLAGS::NO_PLATFORMS)) { - uint32_t imageId = ((direction & 1) ? SPIRAL_SLIDE_BASE_B : SPIRAL_SLIDE_BASE_A) + uint32_t imageId = ((direction & 1) ? rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_BASE_B + : rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_BASE_A) | session.TrackColours[SCHEME_SUPPORTS]; PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 32, 1 }, { 0, 0, height }); } + const uint32_t spiral_slide_fence_sprites[] = { + rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_FENCE_TOP_RIGHT, + rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_FENCE_BOTTOM_RIGHT, + rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_FENCE_BOTTOM_LEFT, + rideEntry->vehicles[0].base_image_id + SPIRAL_SLIDE_FENCE_TOP_LEFT, + }; + track_paint_util_paint_fences( session, edges, session.MapPosition, trackElement, ride, session.TrackColours[SCHEME_TRACK], height, spiral_slide_fence_sprites, session.CurrentRotation);