From ec3d757854163d7bd2fc145ede0c7e759883a785 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 27 Mar 2019 20:53:48 +0100 Subject: [PATCH] Fix #5905: Urban Park MGR has entrance/exit swapped --- distribution/changelog.txt | 1 + src/openrct2/rct1/S4Importer.cpp | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 9480598377..cb3415c26d 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -5,6 +5,7 @@ - Feature: [#8963] Add missing Czech letters to sprite font, use sprite font for Czech. - Change: [#8688] Move common actions from debug menu into cheats menu. - Fix: [#5579] Network desync immediately after connecting. +- Fix: [#5905] Urban Park merry-go-round has entrance and exit swapped (original bug). - Fix: [#6006] Objects higher than 6 metres are considered trees (original bug). - Fix: [#7884] Unfinished preserved rides can be demolished with quick demolish. - Fix: [#8537] Imported RCT1 rides/shops are all numbered 1. diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 0e61e26db1..9c86195a03 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -103,6 +103,7 @@ private: rct1_s4 _s4 = {}; uint8_t _gameVersion = 0; uint8_t _parkValueConversionFactor = 0; + bool _isScenario = false; // Lists of dynamic object entries EntryList _rideEntries; @@ -168,6 +169,7 @@ public: { _s4 = *ReadAndDecodeS4(stream, isScenario); _s4Path = path; + _isScenario = isScenario; // Only determine what objects we required to import this saved game InitialiseEntryMaps(); @@ -197,6 +199,7 @@ public: ImportScenarioObjective(); ImportSavedView(); FixLandOwnership(); + FixUrbanPark(); CountBlockSections(); SetDefaultNames(); determine_ride_entrance_and_exit_locations(); @@ -2937,6 +2940,50 @@ private: } } + /** + * In Urban Park, the entrance and exit of the merry-go-round are the wrong way round. This code fixes that. + * To avoid messing up saves (in which this problem is most likely solved by the user), only carry out this + * fix when loading from a scenario. + */ + void FixUrbanPark() + { + if (_s4.scenario_slot_index == SC_URBAN_PARK && _isScenario) + { + // First, make the queuing peep exit + int32_t i; + Peep* peep; + FOR_ALL_GUESTS (i, peep) + { + if (peep->state == PEEP_STATE_QUEUING_FRONT && peep->current_ride == 0) + { + peep->RemoveFromQueue(); + peep->SetState(PEEP_STATE_FALLING); + break; + } + } + + // Now, swap the entrance and exit. + Ride* ride = get_ride(0); + auto entranceCoords = ride->stations[0].Exit; + auto exitCoords = ride->stations[0].Entrance; + ride->stations[0].Entrance = entranceCoords; + ride->stations[0].Exit = exitCoords; + + auto entranceElement = map_get_ride_exit_element_at( + entranceCoords.x * 32, entranceCoords.y * 32, entranceCoords.z, false); + entranceElement->SetEntranceType(ENTRANCE_TYPE_RIDE_ENTRANCE); + auto exitElement = map_get_ride_entrance_element_at(exitCoords.x * 32, exitCoords.y * 32, exitCoords.z, false); + exitElement->SetEntranceType(ENTRANCE_TYPE_RIDE_EXIT); + + // Trigger footpath update + footpath_queue_chain_reset(); + footpath_connect_edges( + entranceCoords.x * 32, (entranceCoords.y) * 32, (TileElement*)entranceElement, + GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); + footpath_update_queue_chains(); + } + } + /** * Counts the block sections. The reason this iterates over the map is to avoid getting into infinite loops, * which can happen with hacked parks.