Skip to content

Commit

Permalink
Fix OpenRCT2#10631: Assertion fails when modifying copied station pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
Gymnasiast committed Mar 21, 2020
1 parent b90f8e6 commit d194d4c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
1 change: 1 addition & 0 deletions distribution/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
40 changes: 25 additions & 15 deletions src/openrct2/ride/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_error("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;
}
Expand Down Expand Up @@ -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_error("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;
Expand Down

0 comments on commit d194d4c

Please sign in to comment.