1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Fix #19800. Crash when more than 62 stations on a ride (#20039)

* Fix #19800. Crash when more than 62 stations on a ride

This is a bit of a temporary fix. The crash happens due to exhausting the space in the formatter but the format string only ever handled 4 stations so it was still not going to work for 5 <=> 62 stations. So for the time being capped the output at 4 stations.

* Add changelog entry

* Apply review comment
This commit is contained in:
Duncan
2023-04-24 22:16:21 +01:00
committed by GitHub
parent 9dac7f889f
commit ee100f59c0
2 changed files with 7 additions and 2 deletions

View File

@@ -28,6 +28,7 @@
- Fix: [#19733] Favorite ride of X guests integer overflow.
- Fix: [#19756] Crash with title sequences containing no commands.
- Fix: [#19767] No message when path is not connected to ride exit and is therefore unreachable for mechanics.
- Fix: [#19800] Crash when displaying station stats with more than 62 stations.
- Fix: [#19801] The in-game load/save window cannot be resized anymore.
- Fix: [#19854] Looping Coaster trains clipping through steep quarter turns down.
- Fix: [#19858] Issue drawing simulate flag icon on alternate colour palettes.

View File

@@ -5772,7 +5772,10 @@ static void WindowRideMeasurementsPaint(WindowBase* w, DrawPixelInfo& dpi)
// Ride time
ft = Formatter();
int32_t numTimes = 0;
for (int32_t i = 0; i < ride->num_stations; i++)
// TODO: STR_RIDE_TIME only takes up to 4 stations modify to take more
// also if modified may need to be split into multiple format strings
// as formatter cannot take more than 256 bytes
for (int32_t i = 0; i < std::min<int32_t>(ride->num_stations, 4); i++)
{
StationIndex stationIndex = StationIndex::FromUnderlying(numTimes);
auto time = ride->GetStation(stationIndex).SegmentTime;
@@ -5810,7 +5813,8 @@ static void WindowRideMeasurementsPaint(WindowBase* w, DrawPixelInfo& dpi)
// Ride length
ft = Formatter();
int32_t numLengths = 0;
for (int32_t i = 0; i < ride->num_stations; i++)
// TODO: see above STR_RIDE_LENGTH is also only able to display max 4
for (int32_t i = 0; i < std::min<int32_t>(ride->num_stations, 4); i++)
{
StationIndex stationIndex = StationIndex::FromUnderlying(i);
auto length = ride->GetStation(stationIndex).SegmentLength;