mirror of https://github.com/OpenRCT2/OpenRCT2.git
Guard better against incorrect subtypes
This commit is contained in:
parent
91c3b5c592
commit
79f9cf611d
|
@ -541,7 +541,12 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
rct_ride_entry * rideEntry = get_ride_entry(dst->subtype);
|
rct_ride_entry * rideEntry = get_ride_entry(dst->subtype);
|
||||||
Guard::Assert(rideEntry != nullptr && rideEntry != (rct_ride_entry*)-1);
|
// This can happen with hacked parks
|
||||||
|
if (rideEntry == nullptr || rideEntry == (rct_ride_entry*)-1)
|
||||||
|
{
|
||||||
|
dst = nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Ride name
|
// Ride name
|
||||||
dst->name = 0;
|
dst->name = 0;
|
||||||
|
|
|
@ -37,6 +37,12 @@ static void facility_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 dir
|
||||||
rct_ride_entry *rideEntry = get_ride_entry(ride->subtype);
|
rct_ride_entry *rideEntry = get_ride_entry(ride->subtype);
|
||||||
rct_ride_entry_vehicle *firstVehicleEntry = &rideEntry->vehicles[0];
|
rct_ride_entry_vehicle *firstVehicleEntry = &rideEntry->vehicles[0];
|
||||||
|
|
||||||
|
if (rideEntry == NULL || firstVehicleEntry == NULL)
|
||||||
|
{
|
||||||
|
log_error("Error drawing facility, rideEntry or firstVehicleEntry is NULL.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint32 imageId = gTrackColours[SCHEME_TRACK];
|
uint32 imageId = gTrackColours[SCHEME_TRACK];
|
||||||
imageId |= firstVehicleEntry->base_image_id;
|
imageId |= firstVehicleEntry->base_image_id;
|
||||||
imageId += (direction + 2) & 3;
|
imageId += (direction + 2) & 3;
|
||||||
|
|
|
@ -37,6 +37,12 @@ static void shop_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 directi
|
||||||
rct_ride_entry *rideEntry = get_ride_entry(ride->subtype);
|
rct_ride_entry *rideEntry = get_ride_entry(ride->subtype);
|
||||||
rct_ride_entry_vehicle *firstVehicleEntry = &rideEntry->vehicles[0];
|
rct_ride_entry_vehicle *firstVehicleEntry = &rideEntry->vehicles[0];
|
||||||
|
|
||||||
|
if (rideEntry == NULL || firstVehicleEntry == NULL)
|
||||||
|
{
|
||||||
|
log_error("Error drawing shop, rideEntry or firstVehicleEntry is NULL.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint32 imageId = gTrackColours[SCHEME_TRACK];
|
uint32 imageId = gTrackColours[SCHEME_TRACK];
|
||||||
if (imageId & 0x80000000) {
|
if (imageId & 0x80000000) {
|
||||||
imageId &= 0x60FFFFFF;
|
imageId &= 0x60FFFFFF;
|
||||||
|
|
|
@ -188,7 +188,7 @@ static rct_track_td6 * track_design_open_from_td4(uint8 *src, size_t srcLength)
|
||||||
td6->version_and_colour_scheme = td4->version_and_colour_scheme;
|
td6->version_and_colour_scheme = td4->version_and_colour_scheme;
|
||||||
|
|
||||||
// Vehicle colours
|
// Vehicle colours
|
||||||
for (sint32 i = 0; i < 12; i++) {
|
for (sint32 i = 0; i < RCT1_MAX_VEHICLES_PER_RIDE; i++) {
|
||||||
td6->vehicle_colours[i].body_colour = rct1_get_colour(td4->vehicle_colours[i].body_colour);
|
td6->vehicle_colours[i].body_colour = rct1_get_colour(td4->vehicle_colours[i].body_colour);
|
||||||
td6->vehicle_colours[i].trim_colour = rct1_get_colour(td4->vehicle_colours[i].trim_colour);
|
td6->vehicle_colours[i].trim_colour = rct1_get_colour(td4->vehicle_colours[i].trim_colour);
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ static rct_track_td6 * track_design_open_from_td4(uint8 *src, size_t srcLength)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set remaining vehicles to same colour as first vehicle
|
// Set remaining vehicles to same colour as first vehicle
|
||||||
for (sint32 i = 12; i < 32; i++) {
|
for (sint32 i = RCT1_MAX_VEHICLES_PER_RIDE; i < 32; i++) {
|
||||||
td6->vehicle_colours[i] = td6->vehicle_colours[0];
|
td6->vehicle_colours[i] = td6->vehicle_colours[0];
|
||||||
}
|
}
|
||||||
// Set additional colour to trim colour for all vehicles
|
// Set additional colour to trim colour for all vehicles
|
||||||
|
|
Loading…
Reference in New Issue