mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-30 10:15:36 +01:00
Fix #10631: Assertion fails when modifying copied station pieces
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user