1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 05:23:04 +01:00

Fix #1013: negative length in Ride window (#11651)

This commit is contained in:
Michael Steenbeek
2020-05-06 11:32:10 +02:00
committed by GitHub
parent 5271e06abf
commit 8660bbe9d7
4 changed files with 9 additions and 8 deletions

View File

@@ -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;

View File

@@ -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<char**>(&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<char**>(&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<int16_t>(value));
format_length(dest, size, static_cast<uint16_t>(value));
break;
case FORMAT_SPRITE:
// Pop argument