diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 1b5ed59155..44a62c57a3 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -22,7 +22,9 @@ - Fix: [#8015] RCT2 files are not found when put into the OpenRCT2 folder. - Fix: [#8957] Error title missing when building with insufficient funds - Fix: [#10186] Placing multiple saved rides ignores design name (original bug). +- Fix: [#12368] Desync due to ghost station pieces affecting changing ride settings. - Fix: [#12940] Windows cause issues with snow drawing. +- Fix: [#13019] Simulated trains sometimes open construction window when they crash. - Fix: [#13021] Mowed grass and weeds don't show up in extra zoom levels. - Fix: [#13024] Console cursor does not correctly render at current cursor position. - Fix: [#13029] Not all Junior Roller Coaster pieces are shown when "Show all track pieces" cheat is enabled. @@ -39,6 +41,7 @@ - Fix: [#13222] Vehicle collision causes negative number of passengers (original bug). - Fix: [#13226, #7280] No error is shown when attempting to load a corrupted save. - Fix: [#13266] Plugin API: Deleting key of sharedStorage not working. +- Fix: [#13278] Desync caused by to ghost tiles changing the ride mode. - Improved: [#13023] Made add_news_item console command last argument, assoc, optional. - Improved: [#13098] Improvements to the maze construction window user interface - Improved: [#13125] Selecting the RCT2 files now uses localised dialogs. diff --git a/src/openrct2/actions/TrackPlaceAction.hpp b/src/openrct2/actions/TrackPlaceAction.hpp index a419d83d8e..dffe32ade2 100644 --- a/src/openrct2/actions/TrackPlaceAction.hpp +++ b/src/openrct2/actions/TrackPlaceAction.hpp @@ -18,6 +18,7 @@ #include "../world/MapAnimation.h" #include "../world/Surface.h" #include "GameAction.h" +#include "RideSetSetting.hpp" class TrackPlaceActionResult final : public GameActions::Result { @@ -546,43 +547,51 @@ public: cost += ((supportHeight / (2 * COORDS_Z_STEP)) * RideTypeDescriptors[ride->type].BuildCosts.SupportPrice) * 5; - invalidate_test_results(ride); - switch (_trackType) - { - case TrackElemType::OnRidePhoto: - ride->lifecycle_flags |= RIDE_LIFECYCLE_ON_RIDE_PHOTO; - break; - case TrackElemType::CableLiftHill: - if (trackBlock->index != 0) - break; - ride->lifecycle_flags |= RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED; - ride->CableLiftLoc = mapLoc; - break; - case TrackElemType::BlockBrakes: - ride->num_block_brakes++; - ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_OPERATING; - - ride->mode = RideMode::ContinuousCircuitBlockSectioned; - if (ride->type == RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER) - ride->mode = RideMode::PoweredLaunchBlockSectioned; - - break; - } - - if (trackBlock->index == 0) + if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST)) { + invalidate_test_results(ride); switch (_trackType) { - case TrackElemType::Up25ToFlat: - case TrackElemType::Up60ToFlat: - case TrackElemType::DiagUp25ToFlat: - case TrackElemType::DiagUp60ToFlat: - if (!(_trackPlaceFlags & CONSTRUCTION_LIFT_HILL_SELECTED)) - break; - [[fallthrough]]; - case TrackElemType::CableLiftHill: - ride->num_block_brakes++; + case TrackElemType::OnRidePhoto: + ride->lifecycle_flags |= RIDE_LIFECYCLE_ON_RIDE_PHOTO; break; + case TrackElemType::CableLiftHill: + if (trackBlock->index != 0) + break; + ride->lifecycle_flags |= RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED; + ride->CableLiftLoc = mapLoc; + break; + case TrackElemType::BlockBrakes: + { + ride->num_block_brakes++; + ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_OPERATING; + + RideMode newMode = RideMode::ContinuousCircuitBlockSectioned; + if (ride->type == RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER) + newMode = RideMode::PoweredLaunchBlockSectioned; + + auto rideSetSetting = RideSetSettingAction( + ride->id, RideSetSetting::Mode, static_cast(newMode)); + GameActions::ExecuteNested(&rideSetSetting); + break; + } + } + + if (trackBlock->index == 0) + { + switch (_trackType) + { + case TrackElemType::Up25ToFlat: + case TrackElemType::Up60ToFlat: + case TrackElemType::DiagUp25ToFlat: + case TrackElemType::DiagUp60ToFlat: + if (!(_trackPlaceFlags & CONSTRUCTION_LIFT_HILL_SELECTED)) + break; + [[fallthrough]]; + case TrackElemType::CableLiftHill: + ride->num_block_brakes++; + break; + } } } @@ -686,7 +695,7 @@ public: } } - if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN) + if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN && !(GetFlags() & GAME_COMMAND_FLAG_GHOST)) { if (trackBlock->index == 0) { diff --git a/src/openrct2/actions/TrackRemoveAction.hpp b/src/openrct2/actions/TrackRemoveAction.hpp index 38e4d163a2..b82ef2be66 100644 --- a/src/openrct2/actions/TrackRemoveAction.hpp +++ b/src/openrct2/actions/TrackRemoveAction.hpp @@ -18,6 +18,7 @@ #include "../world/MapAnimation.h" #include "../world/Surface.h" #include "GameAction.h" +#include "RideSetSetting.hpp" DEFINE_GAME_ACTION(TrackRemoveAction, GAME_COMMAND_REMOVE_TRACK, GameActions::Result) { @@ -428,7 +429,8 @@ public: cost += (_support_height / 2) * RideTypeDescriptors[ride->type].BuildCosts.SupportPrice; - if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN && (tileElement->AsTrack()->GetSequenceIndex() == 0)) + if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN && !(tileElement->Flags & TILE_ELEMENT_FLAG_GHOST) + && (tileElement->AsTrack()->GetSequenceIndex() == 0)) { if (!track_remove_station_element({ mapLoc, _origin.direction }, rideIndex, GAME_COMMAND_FLAG_APPLY)) { @@ -456,40 +458,48 @@ public: } } - switch (trackType) + if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST)) { - case TrackElemType::OnRidePhoto: - ride->lifecycle_flags &= ~RIDE_LIFECYCLE_ON_RIDE_PHOTO; - break; - case TrackElemType::CableLiftHill: - ride->lifecycle_flags &= ~RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED; - break; - case TrackElemType::BlockBrakes: - ride->num_block_brakes--; - if (ride->num_block_brakes == 0) - { - ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_OPERATING; - ride->mode = RideMode::ContinuousCircuit; - if (ride->type == RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER) - { - ride->mode = RideMode::PoweredLaunch; - } - } - break; - } - - switch (trackType) - { - case TrackElemType::Up25ToFlat: - case TrackElemType::Up60ToFlat: - case TrackElemType::DiagUp25ToFlat: - case TrackElemType::DiagUp60ToFlat: - if (!isLiftHill) + switch (trackType) + { + case TrackElemType::OnRidePhoto: + ride->lifecycle_flags &= ~RIDE_LIFECYCLE_ON_RIDE_PHOTO; break; - [[fallthrough]]; - case TrackElemType::CableLiftHill: - ride->num_block_brakes--; - break; + case TrackElemType::CableLiftHill: + ride->lifecycle_flags &= ~RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED; + break; + case TrackElemType::BlockBrakes: + ride->num_block_brakes--; + if (ride->num_block_brakes == 0) + { + ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_OPERATING; + RideMode newMode = RideMode::ContinuousCircuit; + if (ride->type == RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER) + { + newMode = RideMode::PoweredLaunch; + } + + auto rideSetSetting = RideSetSettingAction( + ride->id, RideSetSetting::Mode, static_cast(newMode)); + GameActions::ExecuteNested(&rideSetSetting); + } + + break; + } + + switch (trackType) + { + case TrackElemType::Up25ToFlat: + case TrackElemType::Up60ToFlat: + case TrackElemType::DiagUp25ToFlat: + case TrackElemType::DiagUp60ToFlat: + if (!isLiftHill) + break; + [[fallthrough]]; + case TrackElemType::CableLiftHill: + ride->num_block_brakes--; + break; + } } money32 price = RideTypeDescriptors[ride->type].BuildCosts.TrackPrice; diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 4be3980077..471f473727 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -34,7 +34,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 "2" +#define NETWORK_STREAM_VERSION "3" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index e8d959992b..5bcfedfac0 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -2077,9 +2077,18 @@ void Ride::Update() // If ride is simulating but crashed, reset the vehicles if (status == RIDE_STATUS_SIMULATING && (lifecycle_flags & RIDE_LIFECYCLE_CRASHED)) { - // We require this to execute right away during the simulation, always ignore network and queue. - auto gameAction = RideSetStatusAction(id, RIDE_STATUS_SIMULATING); - GameActions::ExecuteNested(&gameAction); + if (mode == RideMode::ContinuousCircuitBlockSectioned || mode == RideMode::PoweredLaunchBlockSectioned) + { + // We require this to execute right away during the simulation, always ignore network and queue. + RideSetStatusAction gameAction = RideSetStatusAction(id, RIDE_STATUS_CLOSED); + GameActions::ExecuteNested(&gameAction); + } + else + { + // We require this to execute right away during the simulation, always ignore network and queue. + RideSetStatusAction gameAction = RideSetStatusAction(id, RIDE_STATUS_SIMULATING); + GameActions::ExecuteNested(&gameAction); + } } }