diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 4e0cbcc887..29a0331006 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -541,7 +541,12 @@ private: } 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 dst->name = 0; diff --git a/src/openrct2/ride/shops/facility.c b/src/openrct2/ride/shops/facility.c index e8fa0cacb5..6e4bac4514 100644 --- a/src/openrct2/ride/shops/facility.c +++ b/src/openrct2/ride/shops/facility.c @@ -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_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]; imageId |= firstVehicleEntry->base_image_id; imageId += (direction + 2) & 3; diff --git a/src/openrct2/ride/shops/shop.c b/src/openrct2/ride/shops/shop.c index 39845c7672..e5ad3f7e66 100644 --- a/src/openrct2/ride/shops/shop.c +++ b/src/openrct2/ride/shops/shop.c @@ -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_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]; if (imageId & 0x80000000) { imageId &= 0x60FFFFFF; diff --git a/src/openrct2/ride/track_design.c b/src/openrct2/ride/track_design.c index 71412d336c..949d011ff5 100644 --- a/src/openrct2/ride/track_design.c +++ b/src/openrct2/ride/track_design.c @@ -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; // 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].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 - 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]; } // Set additional colour to trim colour for all vehicles