From 8660bbe9d73dd334e8a3a44351bf599da339eb27 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 6 May 2020 11:32:10 +0200 Subject: [PATCH] Fix #1013: negative length in Ride window (#11651) --- data/language/en-GB.txt | 4 ++-- distribution/changelog.txt | 2 ++ src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2/localisation/Localisation.cpp | 9 ++++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 807a925277..1b217cee2b 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -1940,8 +1940,8 @@ STR_2728 :{UINT16}hour:{UINT16}min STR_2729 :{UINT16}hour:{UINT16}mins STR_2730 :{UINT16}hours:{UINT16}min STR_2731 :{UINT16}hours:{UINT16}mins -STR_2732 :{COMMA16}ft -STR_2733 :{COMMA16}m +STR_2732 :{COMMA32}ft +STR_2733 :{COMMA32}m STR_2734 :{COMMA16}mph STR_2735 :{COMMA16}km/h STR_2736 :{MONTH}, Year {COMMA16} diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 6588e669b6..fabcf9bf57 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.2.6+ (in development) ------------------------------------------------------------------------ +- Feature: [#7648] "Enable all drawable track pieces" now enables more pieces for the Twister, Vertical and Air Powered Vertical coasters. - Feature: [#9029] Open doors with the tile inspector. - Feature: [#10572] Cheat to allow building at invalid heights. - Feature: [#11231] Change shortcut window list order to be more intuitive, and split it into logical sections. @@ -8,6 +9,7 @@ - Change: [#11209] Warn when user is running OpenRCT2 through Wine. - Change: [#11358] Switch copy and paste button positions in tile inspector. - Change: [#11449] Remove complete circuit requirement from Air Powered Vertical Coaster (for RCT1 parity). +- Fix: [#1013] Negative length displayed in Ride window. - Fix: [#1148] Research funding dropdown not shown in finances window. - Fix: [#5451] Guests scream on every descent, no matter how small. - Fix: [#6119] Advertising campaign for ride window not updated properly (original bug). diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index a8696b2a4c..9034c8051f 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -5831,7 +5831,7 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi int32_t numLengths = 0; for (int32_t i = 0; i < ride->num_stations; i++) { - length = ride->stations[numLengths].SegmentLength; + length = ride->stations[i].SegmentLength; if (length != 0) { length >>= 16; diff --git a/src/openrct2/localisation/Localisation.cpp b/src/openrct2/localisation/Localisation.cpp index b309628651..f9fea148ab 100644 --- a/src/openrct2/localisation/Localisation.cpp +++ b/src/openrct2/localisation/Localisation.cpp @@ -882,7 +882,7 @@ static void format_date(char** dest, size_t* size, uint16_t value) format_string_part(dest, size, STR_DATE_FORMAT_MY, reinterpret_cast(&argsRef)); } -static void format_length(char** dest, size_t* size, int16_t value) +static void format_length(char** dest, size_t* size, int32_t value) { rct_string_id stringId = STR_UNIT_SUFFIX_METRES; @@ -892,7 +892,7 @@ static void format_length(char** dest, size_t* size, int16_t value) stringId = STR_UNIT_SUFFIX_FEET; } - int16_t* argRef = &value; + int32_t* argRef = &value; format_string_part(dest, size, stringId, reinterpret_cast(&argRef)); } @@ -1135,11 +1135,10 @@ static void format_string_code(uint32_t format_code, char** dest, size_t* size, break; case FORMAT_LENGTH: // Pop argument - std::memcpy(&temp16, *args, sizeof(int16_t)); - value = temp16; + std::memcpy(&value, *args, sizeof(uint16_t)); *args += 2; - format_length(dest, size, static_cast(value)); + format_length(dest, size, static_cast(value)); break; case FORMAT_SPRITE: // Pop argument