From 727ba2d7d040f75075fe9adc937ffa926d9d87c2 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 1 Dec 2018 15:39:19 +0100 Subject: [PATCH] Fix #8333: Replace assert with in-game error. --- data/language/en-GB.txt | 1 + src/openrct2/actions/RideSetStatus.hpp | 2 ++ src/openrct2/localisation/StringIds.h | 1 + src/openrct2/peep/Guest.cpp | 26 +++++++++++++++++++++++--- src/openrct2/ride/Ride.h | 11 +++++++++++ 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index cc207bb2f3..5d79929020 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3723,6 +3723,7 @@ STR_6272 :Stations STR_6273 :Music STR_6274 :Can't set colour scheme... STR_6275 :{WINDOW_COLOUR_2}Station style: +STR_6276 :{RED}{STRINGID} has guests getting stuck, possibly due to invalid ride type or operating mode. ############# # Scenarios # diff --git a/src/openrct2/actions/RideSetStatus.hpp b/src/openrct2/actions/RideSetStatus.hpp index 8d5a2f5b90..00bf31899c 100644 --- a/src/openrct2/actions/RideSetStatus.hpp +++ b/src/openrct2/actions/RideSetStatus.hpp @@ -173,6 +173,8 @@ public: ride->race_winner = SPRITE_INDEX_NULL; ride->status = _status; + ride->current_issues = 0; + ride->last_issue_time = 0; ride_get_measurement(_rideIndex, nullptr); ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST; window_invalidate_by_number(WC_RIDE, _rideIndex); diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index bf38aa8b09..384451d450 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3894,6 +3894,7 @@ enum STR_CANT_SET_COLOUR_SCHEME = 6274, STR_STATION_STYLE = 6275, + STR_GUESTS_GETTING_STUCK_ON_RIDE = 6276, // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 22d429b4ad..8ed4f64e13 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -3597,10 +3597,30 @@ void rct_peep::UpdateRideAdvanceThroughEntrance() peep_update_ride_leave_entrance_maze(this, ride, entranceLocation); return; } - Guard::Assert(ride->type == RIDE_TYPE_SPIRAL_SLIDE); + else if (ride->type == RIDE_TYPE_SPIRAL_SLIDE) + { + peep_update_ride_leave_entrance_spiral_slide(this, ride, entranceLocation); + return; + } + else + { + // If the ride type was changed guests will become stuck. + // Inform the player about this if its a new issue or hasn't been addressed within 120 seconds. + if ((ride->current_issues & RIDE_ISSUE_GUESTS_STUCK) == 0 || gCurrentTicks - ride->last_issue_time > 3000) + { + ride->current_issues |= RIDE_ISSUE_GUESTS_STUCK; + ride->last_issue_time = gCurrentTicks; - peep_update_ride_leave_entrance_spiral_slide(this, ride, entranceLocation); - return; + set_format_arg(0, rct_string_id, ride->name); + set_format_arg(2, uint32_t, ride->name_arguments); + if (gConfigNotifications.ride_warnings) + { + news_item_add_to_queue(NEWS_ITEM_RIDE, STR_GUESTS_GETTING_STUCK_ON_RIDE, current_ride); + } + } + + return; + } } rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[current_train]); diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 512e56b3e0..3777ad446f 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -342,6 +342,11 @@ struct Ride uint8_t cable_lift_z; uint16_t cable_lift; uint16_t queue_length[MAX_STATIONS]; + // These fields are used to warn users about issues. + // Such issue can be hacked rides with incompatible options set. + // They don't require export/import. + uint8_t current_issues; + uint32_t last_issue_time; bool CanBreakDown() const; }; @@ -881,6 +886,12 @@ enum RIDE_MODIFY_RENEW }; +enum +{ + RIDE_ISSUE_NONE = 0, + RIDE_ISSUE_GUESTS_STUCK = (1 << 0), +}; + struct rct_ride_properties { uint32_t flags;