From 2530cd1ac3a94f309bfc48cad8f4f7ef69d2986d Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Sat, 22 Dec 2018 15:34:17 +0100 Subject: [PATCH] Fix #8426: Queue banner left behind after ride demolition --- src/openrct2/actions/RideDemolishAction.hpp | 26 ++++----------------- src/openrct2/network/Network.cpp | 2 +- src/openrct2/ride/Ride.cpp | 17 ++++++++++++++ src/openrct2/ride/Ride.h | 1 + 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/openrct2/actions/RideDemolishAction.hpp b/src/openrct2/actions/RideDemolishAction.hpp index 4af3057157..b36deab0bf 100644 --- a/src/openrct2/actions/RideDemolishAction.hpp +++ b/src/openrct2/actions/RideDemolishAction.hpp @@ -126,6 +126,7 @@ private: ride_stop_peeps_queuing(_rideIndex); sub_6CB945(_rideIndex); + ride_clear_leftover_entrances(_rideIndex); news_item_disable_news(NEWS_ITEM_RIDE, _rideIndex); for (auto& banner : gBanners) @@ -150,7 +151,7 @@ private: { if (peep->current_ride == _rideIndex) { - peep->current_ride = MAX_RIDES; + peep->current_ride = RIDE_ID_NULL; if (peep->time_to_stand >= 50) { // make peep stop watching the ride @@ -200,11 +201,11 @@ private: if (peep->guest_heading_to_ride_id == _rideIndex) { - peep->guest_heading_to_ride_id = MAX_RIDES; + peep->guest_heading_to_ride_id = RIDE_ID_NULL; } if (peep->favourite_ride == _rideIndex) { - peep->favourite_ride = MAX_RIDES; + peep->favourite_ride = RIDE_ID_NULL; } for (int32_t i = 0; i < PEEP_MAX_THOUGHTS; i++) @@ -288,24 +289,7 @@ private: tile_element_iterator_begin(&it); while (tile_element_iterator_next(&it)) { - uint8_t tile_type = it.element->GetType(); - - if (tile_type == TILE_ELEMENT_TYPE_ENTRANCE) - { - uint8_t type = it.element->AsEntrance()->GetEntranceType(); - if (type == ENTRANCE_TYPE_PARK_ENTRANCE) - continue; - - if (it.element->AsEntrance()->GetRideIndex() == _rideIndex) - { - tile_element_remove(it.element); - tile_element_iterator_restart_for_tile(&it); - } - - continue; - } - - if (tile_type != TILE_ELEMENT_TYPE_TRACK) + if (it.element->GetType() != TILE_ELEMENT_TYPE_TRACK) continue; if (it.element->AsTrack()->GetRideIndex() != _rideIndex) diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index 54e17cfb99..fe9a10dd15 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -30,7 +30,7 @@ // This string specifies which version of network stream current build uses. // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -#define NETWORK_STREAM_VERSION "17" +#define NETWORK_STREAM_VERSION "18" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static rct_peep* _pickup_peep = nullptr; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 7947354954..322d90507f 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -8990,3 +8990,20 @@ void determine_ride_entrance_and_exit_locations() } } } + +void ride_clear_leftover_entrances(uint8_t rideIndex) +{ + tile_element_iterator it; + + tile_element_iterator_begin(&it); + while (tile_element_iterator_next(&it)) + { + if (it.element->GetType() == TILE_ELEMENT_TYPE_ENTRANCE + && it.element->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE + && it.element->AsEntrance()->GetRideIndex() == rideIndex) + { + tile_element_remove(it.element); + tile_element_iterator_restart_for_tile(&it); + } + } +} diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 5446450fa6..512e56b3e0 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -1195,5 +1195,6 @@ void ride_stop_peeps_queuing(int32_t rideIndex); LocationXY16 ride_get_rotated_coords(int16_t x, int16_t y, int16_t z); void determine_ride_entrance_and_exit_locations(); +void ride_clear_leftover_entrances(uint8_t rideIndex); #endif