From 02c5ece7b703386570acd188a8b5e303a43ddb59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Mon, 7 Mar 2016 23:02:37 +0100 Subject: [PATCH] Be more careful when dealing with hacked rides. Fix #3109 --- src/management/award.c | 15 +++++++++++++++ src/management/marketing.c | 3 +++ src/ride/ride.c | 3 +++ src/scenario.c | 6 ++++++ src/windows/new_campaign.c | 3 +++ 5 files changed, 30 insertions(+) diff --git a/src/management/award.c b/src/management/award.c index bc7ce6063f..9904033c31 100644 --- a/src/management/award.c +++ b/src/management/award.c @@ -140,6 +140,9 @@ static int award_is_deserved_best_rollercoasters(int awardType, int activeAwardT rollerCoasters = 0; FOR_ALL_RIDES(i, ride) { rideType = get_ride_entry(ride->subtype); + if (rideType == NULL) { + continue; + } if (rideType->category[0] != RIDE_GROUP_ROLLERCOASTER && rideType->category[1] != RIDE_GROUP_ROLLERCOASTER) continue; @@ -296,6 +299,9 @@ static int award_is_deserved_best_food(int awardType, int activeAwardTypes) shops++; rideType = get_ride_entry(ride->subtype); + if (rideType == NULL) { + continue; + } if (!(shopTypes & (1ULL << rideType->shop_item))) { shopTypes |= (1ULL << rideType->shop_item); uniqueShops++; @@ -342,6 +348,9 @@ static int award_is_deserved_worst_food(int awardType, int activeAwardTypes) shops++; rideType = get_ride_entry(ride->subtype); + if (rideType == NULL) { + continue; + } if (!(shopTypes & (1ULL << rideType->shop_item))) { shopTypes |= (1ULL << rideType->shop_item); uniqueShops++; @@ -439,6 +448,9 @@ static int award_is_deserved_best_water_rides(int awardType, int activeAwardType waterRides = 0; FOR_ALL_RIDES(i, ride) { rideType = get_ride_entry(ride->subtype); + if (rideType == NULL) { + continue; + } if (rideType->category[0] != RIDE_GROUP_WATER && rideType->category[1] != RIDE_GROUP_WATER) continue; @@ -539,6 +551,9 @@ static int award_is_deserved_best_gentle_rides(int awardType, int activeAwardTyp gentleRides = 0; FOR_ALL_RIDES(i, ride) { rideType = get_ride_entry(ride->subtype); + if (rideType == NULL) { + continue; + } if (rideType->category[0] != RIDE_GROUP_GENTLE && rideType->category[1] != RIDE_GROUP_GENTLE) continue; diff --git a/src/management/marketing.c b/src/management/marketing.c index 58b63d3f49..1d4eddab54 100644 --- a/src/management/marketing.c +++ b/src/management/marketing.c @@ -214,6 +214,9 @@ bool marketing_is_campaign_type_applicable(int campaignType) // Check if any food or drink stalls exist FOR_ALL_RIDES(i, ride) { rideEntry = get_ride_entry(ride->subtype); + if (rideEntry == NULL) { + continue; + } if ( shop_item_is_food_or_drink(rideEntry->shop_item) || shop_item_is_food_or_drink(rideEntry->shop_item_secondary) diff --git a/src/ride/ride.c b/src/ride/ride.c index 9e85a9be3d..4bd0c383e5 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -5687,6 +5687,9 @@ static money32 shop_item_get_common_price(rct_ride *forRide, int shopItem) FOR_ALL_RIDES(i, ride) { if (ride != forRide) { rideEntry = get_ride_entry(ride->subtype); + if (rideEntry == NULL) { + continue; + } if (rideEntry->shop_item == shopItem) { return ride->price; } diff --git a/src/scenario.c b/src/scenario.c index 107b415156..206b4d1798 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -1299,6 +1299,9 @@ static void scenario_objective_check_10_rollercoasters() FOR_ALL_RIDES(i, ride) { uint8 subtype_id = ride->subtype; rct_ride_entry *rideType = get_ride_entry(subtype_id); + if (rideType == NULL) { + continue; + } if (rideType != NULL && (rideType->category[0] == RIDE_GROUP_ROLLERCOASTER || rideType->category[1] == RIDE_GROUP_ROLLERCOASTER) && @@ -1377,6 +1380,9 @@ static void scenario_objective_check_10_rollercoasters_length() FOR_ALL_RIDES(i, ride) { uint8 subtype_id = ride->subtype; rct_ride_entry *rideType = get_ride_entry(subtype_id); + if (rideType == NULL) { + continue; + } if ((rideType->category[0] == RIDE_GROUP_ROLLERCOASTER || rideType->category[1] == RIDE_GROUP_ROLLERCOASTER) && ride->status == RIDE_STATUS_OPEN && ride->excitement >= RIDE_RATING(7,00) && type_already_counted[subtype_id] == 0){ diff --git a/src/windows/new_campaign.c b/src/windows/new_campaign.c index 98a192a23e..927a7b58f4 100644 --- a/src/windows/new_campaign.c +++ b/src/windows/new_campaign.c @@ -200,6 +200,9 @@ static void window_new_campaign_get_shop_items() uint64 items = 0; FOR_ALL_RIDES(i, ride) { rct_ride_entry *rideType = get_ride_entry(ride->subtype); + if (rideType == NULL) { + continue; + } uint8 itemType = rideType->shop_item; if (itemType != 255) items |= 1LL << itemType;