From 5606b4895b5335889cfa3ae8aeb00e81a560b880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= Date: Sat, 16 Nov 2019 16:12:33 +0100 Subject: [PATCH] Fix desync because of ride status (#10227) --- distribution/changelog.txt | 1 + src/openrct2/network/Network.cpp | 2 +- src/openrct2/ride/Ride.cpp | 5 ++++- src/openrct2/ride/Vehicle.cpp | 13 ++++++++++--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 559f5f44d3..311dc0814a 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -36,6 +36,7 @@ - Fix: [#10036] Do not allocate large chunks of memory for save file classification. - Fix: [#10106] Ride circuits should not be used for modes that do not support it. - Fix: [#10149] Desync in headless mode with rides that create smoke particles. +- Fix: [#10249] Desync because of ride crashes and simulation mode. - Improved: [#9466] Add the rain weather effect to the OpenGL renderer. - Improved: [#9987] Minimum load rounding. - Improved: [#10125] Better support for high DPI screens. diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index 047161063a..5e5903943d 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -31,7 +31,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 "0" +#define NETWORK_STREAM_VERSION "1" #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 8449182335..db3eced204 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -17,6 +17,7 @@ #include "../OpenRCT2.h" #include "../actions/RideEntranceExitRemoveAction.hpp" #include "../actions/RideSetSetting.hpp" +#include "../actions/RideSetStatus.hpp" #include "../actions/RideSetVehiclesAction.hpp" #include "../actions/TrackRemoveAction.hpp" #include "../audio/AudioMixer.h" @@ -2100,7 +2101,9 @@ void Ride::Update() // If ride is simulating but crashed, reset the vehicles if (status == RIDE_STATUS_SIMULATING && (lifecycle_flags & RIDE_LIFECYCLE_CRASHED)) { - ride_set_status(this, RIDE_STATUS_SIMULATING); + // 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); } } diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 59a5a84634..3a3bed85d7 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -13,6 +13,7 @@ #include "../Editor.h" #include "../Game.h" #include "../OpenRCT2.h" +#include "../actions/RideSetStatus.hpp" #include "../audio/AudioMixer.h" #include "../audio/audio.h" #include "../config/Config.h" @@ -3528,7 +3529,9 @@ static void vehicle_update_collision_setup(rct_vehicle* vehicle) if (ride->status != RIDE_STATUS_CLOSED) { - ride_set_status(ride, RIDE_STATUS_CLOSED); + // We require this to execute right away during the simulation, always ignore network and queue. + auto gameAction = RideSetStatusAction(ride->id, RIDE_STATUS_CLOSED); + GameActions::ExecuteNested(&gameAction); } } @@ -5260,7 +5263,9 @@ static void vehicle_crash_on_land(rct_vehicle* vehicle) if (ride->status != RIDE_STATUS_CLOSED) { - ride_set_status(ride, RIDE_STATUS_CLOSED); + // We require this to execute right away during the simulation, always ignore network and queue. + auto gameAction = RideSetStatusAction(ride->id, RIDE_STATUS_CLOSED); + GameActions::ExecuteNested(&gameAction); } } ride->lifecycle_flags |= RIDE_LIFECYCLE_CRASHED; @@ -5321,7 +5326,9 @@ static void vehicle_crash_on_water(rct_vehicle* vehicle) if (ride->status != RIDE_STATUS_CLOSED) { - ride_set_status(ride, RIDE_STATUS_CLOSED); + // We require this to execute right away during the simulation, always ignore network and queue. + auto gameAction = RideSetStatusAction(ride->id, RIDE_STATUS_CLOSED); + GameActions::ExecuteNested(&gameAction); } } ride->lifecycle_flags |= RIDE_LIFECYCLE_CRASHED;