From f05aeb1fcd96953f01cf9a63bb749032c98a276c Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Sun, 12 Jan 2020 10:32:11 +0100 Subject: [PATCH] Fix #7784: Vehicle tab takes 1st car colour instead of tab_vehicle's colour (#10544) --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2/ride/Ride.cpp | 12 ++++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index c2629c959c..e6a504bd2b 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -5,6 +5,7 @@ - Feature: [#10189] Make Track Designs work in multiplayer. - Change: [#1164] Use available translations for shortcut key bindings. - Fix: [#5249] No collision detection when building ride entrance at heights > 85.5m. +- Fix: [#7784] Vehicle tab takes 1st car colour instead of tab_vehicle's colour. - Fix: [#10228] Can't import RCT1 Deluxe from Steam. - Fix: [#10313] Path furniture can be placed on level crossings. - Fix: [#10325] Crash when banners have no text. diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index bb4f1fa83f..a85185beb2 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1357,7 +1357,7 @@ static void window_ride_draw_tab_vehicle(rct_drawpixelinfo* dpi, rct_window* w) ride->subtype, ride->num_cars_per_train, rideEntry->tab_vehicle); rct_ride_entry_vehicle* rideVehicleEntry = &rideEntry->vehicles[vehicle]; - vehicle_colour vehicleColour = ride_get_vehicle_colour(ride, 0); + vehicle_colour vehicleColour = ride_get_vehicle_colour(ride, rideEntry->tab_vehicle); int32_t spriteIndex = 32; if (w->page == WINDOW_RIDE_PAGE_VEHICLE) spriteIndex += w->frame_no; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 8a46511ce3..72d0b89578 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -3108,8 +3108,16 @@ vehicle_colour ride_get_vehicle_colour(Ride* ride, int32_t vehicleIndex) { vehicle_colour result; - // Prevent indexing array out of bounds - vehicleIndex = std::min(vehicleIndex, MAX_CARS_PER_TRAIN); + if (ride->colour_scheme_type == VEHICLE_COLOUR_SCHEME_PER_VEHICLE) + { + // Prevent indexing array out of bounds + vehicleIndex = std::min(vehicleIndex, MAX_CARS_PER_TRAIN); + } + else + { + // In this case, only the first car will be set and the rest will be either black or some residual colour. + vehicleIndex = 0; + } result.main = ride->vehicle_colours[vehicleIndex].Body; result.additional_1 = ride->vehicle_colours[vehicleIndex].Trim;