diff --git a/distribution/changelog.txt b/distribution/changelog.txt index b0449b05de..3b83fde7c7 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -29,6 +29,7 @@ - Fix: [#10543] Secondary shop item prices are not imported correctly from RCT1 saves. - Fix: [#10547] RCT1 parks have too many rides available. - Fix: [#10587] Update last action coordinates on correct player. +- Fix: [#10631] Game bugs out and crashes if you get too many stations via copying stations with the tile inspector. - Fix: [#10662] Duck cheat tooltips look odd and do not explain anything. - Fix: [#10694] The lift hill speed of the flying roller coaster cannot be changed (original bug). - Fix: [#10705] Apply multithreaded rendering to all viewports. diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index c70065c221..a38ccce8ee 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -743,13 +743,18 @@ bool track_add_station_element(CoordsXYZD loc, ride_id_t rideIndex, int32_t flag if (stationLoc1 == loc) { auto stationIndex = ride_get_first_empty_station_start(ride); - assert(stationIndex != STATION_INDEX_NULL); - - ride->stations[stationIndex].Start = loc; - ride->stations[stationIndex].Height = loc.z / COORDS_Z_STEP; - ride->stations[stationIndex].Depart = 1; - ride->stations[stationIndex].Length = stationLength; - ride->num_stations++; + if (stationIndex == STATION_INDEX_NULL) + { + log_verbose("No empty station starts, not updating metadata! This can happen with hacked rides."); + } + else + { + ride->stations[stationIndex].Start = loc; + ride->stations[stationIndex].Height = loc.z / COORDS_Z_STEP; + ride->stations[stationIndex].Depart = 1; + ride->stations[stationIndex].Length = stationLength; + ride->num_stations++; + } targetTrackType = TRACK_ELEM_END_STATION; } @@ -887,14 +892,19 @@ bool track_remove_station_element(int32_t x, int32_t y, int32_t z, Direction dir { loc_6C4BF5:; auto stationIndex = ride_get_first_empty_station_start(ride); - assert(stationIndex != STATION_INDEX_NULL); - - ride->stations[stationIndex].Start.x = x; - ride->stations[stationIndex].Start.y = y; - ride->stations[stationIndex].Height = z; - ride->stations[stationIndex].Depart = 1; - ride->stations[stationIndex].Length = stationLength != 0 ? stationLength : byte_F441D1; - ride->num_stations++; + if (stationIndex == STATION_INDEX_NULL) + { + log_verbose("No empty station starts, not updating metadata! This can happen with hacked rides."); + } + else + { + ride->stations[stationIndex].Start.x = x; + ride->stations[stationIndex].Start.y = y; + ride->stations[stationIndex].Height = z; + ride->stations[stationIndex].Depart = 1; + ride->stations[stationIndex].Length = stationLength != 0 ? stationLength : byte_F441D1; + ride->num_stations++; + } stationLength = 0; targetTrackType = TRACK_ELEM_END_STATION;