From a435fd743445ef275d0e0cd12aa0944393623d9d Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 31 Dec 2017 18:55:52 +0100 Subject: [PATCH] Fix #6833: shops and maze in corrupted file not imported correctly --- src/openrct2/rct1/S4Importer.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 7984c190c1..0722d91bcc 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -511,9 +511,12 @@ private: for (size_t i = 0; i < Util::CountOf(_s4.rides); i++) { rct1_ride * ride = &_s4.rides[i]; - if (ride->type != RCT1_RIDE_TYPE_NULL && RCT1::RideTypeUsesVehicles(ride->type)) + if (ride->type != RCT1_RIDE_TYPE_NULL) { - AddEntryForVehicleType(ride->type, ride->vehicle_type); + if (RCT1::RideTypeUsesVehicles(ride->type)) + AddEntryForVehicleType(ride->type, ride->vehicle_type); + else + AddEntryForRideType(ride->type); } } } @@ -724,7 +727,8 @@ private: // This can happen with hacked parks if (rideEntry == nullptr) { - dst = nullptr; + log_warning("Discarding ride with invalid ride entry"); + dst->type = RIDE_TYPE_NULL; return; } @@ -935,6 +939,16 @@ private: void SetRideColourScheme(Ride * dst, rct1_ride * src) { + // In RCT1 and AA, the maze was always hedges. + // LL has 4 types, like RCT2. For LL, only guard against invalid values. + if (dst->type == RIDE_TYPE_MAZE) + { + if (_gameVersion < FILE_VERSION_RCT1_LL || src->track_colour_supports[0] > 3) + dst->track_colour_supports[0] = MAZE_WALL_TYPE_HEDGE; + + return; + } + // Colours dst->colour_scheme_type = src->colour_scheme; if (_gameVersion == FILE_VERSION_RCT1)