From fae4e6323fa9acfbdb1d751768c90b6d21000e8b Mon Sep 17 00:00:00 2001 From: GalBr <33638710+GalBr@users.noreply.github.com> Date: Sun, 9 Jan 2022 00:03:58 +0200 Subject: [PATCH] Fix #16234: Wrap vehicle colors when there are more than 32 trains (#16323) * Wrap vehicle_colours in TrackDesignAction * Wrap the color presets in set_vehicle_colours_to_random_preset * Increment network version * Update changelog.txt Co-authored-by: Tulio Leao --- distribution/changelog.txt | 1 + src/openrct2/actions/TrackDesignAction.cpp | 2 +- src/openrct2/network/NetworkBase.cpp | 2 +- src/openrct2/ride/Ride.cpp | 5 +++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index e8f0fd05af..29df902608 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -24,6 +24,7 @@ - Fix: [#15998] Cannot set map size to the actual maximum. - Fix: [#16007] Scenario Editor "Entry Price" appears to the right of the value field. - Fix: [#16008] Tile Inspector can select elements from last tile without reselecting it. +- Fix: [#16024] Go-Karts with more thant 32 vehicles do not color themselves correctly. - Fix: [#16063] Object Selection preview for objects with glass is broken. - Fix: [#16075] Exporting track designs saves scenery in incorrect locations. - Fix: [#16087] The Looping Roller Coaster booster is now always drawn correctly. diff --git a/src/openrct2/actions/TrackDesignAction.cpp b/src/openrct2/actions/TrackDesignAction.cpp index 1d4fde195a..2ef82f6fdc 100644 --- a/src/openrct2/actions/TrackDesignAction.cpp +++ b/src/openrct2/actions/TrackDesignAction.cpp @@ -259,7 +259,7 @@ GameActions::Result TrackDesignAction::Execute() const for (size_t i = 0; i <= MAX_VEHICLES_PER_RIDE; i++) { - auto tdIndex = std::min(i, std::size(_td.vehicle_colours) - 1); + auto tdIndex = i % std::size(_td.vehicle_colours); ride->vehicle_colours[i].Body = _td.vehicle_colours[tdIndex].body_colour; ride->vehicle_colours[i].Trim = _td.vehicle_colours[tdIndex].trim_colour; ride->vehicle_colours[i].Ternary = _td.vehicle_additional_colour[tdIndex]; diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 5174a127c3..a43407cada 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -41,7 +41,7 @@ // This string specifies which version of network stream current build uses. // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -#define NETWORK_STREAM_VERSION "9" +#define NETWORK_STREAM_VERSION "10" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 00364e41a4..5c35bb9e53 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -2164,10 +2164,11 @@ void ride_set_vehicle_colours_to_random_preset(Ride* ride, uint8_t preset_index) else { ride->colour_scheme_type = RIDE_COLOUR_SCHEME_DIFFERENT_PER_TRAIN; - uint32_t count = std::min(presetList->count, static_cast(32)); + uint32_t count = presetList->count; for (uint32_t i = 0; i < count; i++) { - VehicleColour* preset = &presetList->list[i]; + auto index = i % static_cast(32); + VehicleColour* preset = &presetList->list[index]; ride->vehicle_colours[i] = *preset; } }