From 0ba2f62271890b0fbd924025c2e175d80d5c33c5 Mon Sep 17 00:00:00 2001 From: Kyphii Date: Thu, 18 Sep 2025 09:21:23 -0400 Subject: [PATCH 1/9] Fix bugged states involving simulating with block sections --- distribution/changelog.txt | 1 + src/openrct2/actions/TrackPlaceAction.cpp | 18 ++++++++++++------ src/openrct2/network/NetworkBase.cpp | 2 +- src/openrct2/ride/Ride.cpp | 15 +++------------ 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 52d2fde808..a3e56aa17e 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -14,6 +14,7 @@ - Fix: [#25163] Some of the Junior Roller Coaster flat to steep track wooden support clearance heights are different to RCT1. - Fix: [#25173] Desync when placing a park entrance in multiplayer. - Fix: [#25179] The LIM Launched Roller Coaster inline twists have incorrect wooden support clearance heights (original bug). +- Fix: [#25190] Inserting a block brake while a coaster is simulating will cause the simulation to behave strangely. 0.4.26 (2025-09-06) ------------------------------------------------------------------------ diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index c15274e8bb..819bff8009 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -667,21 +667,21 @@ namespace OpenRCT2::GameActions // Update ride stats and block brake count if the piece was successfully built if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST)) { - InvalidateTestResults(*ride); switch (_trackType) { case TrackElemType::OnRidePhoto: ride->lifecycleFlags |= RIDE_LIFECYCLE_ON_RIDE_PHOTO; + InvalidateTestResults(*ride); break; case TrackElemType::CableLiftHill: ride->lifecycleFlags |= RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED; ride->cableLiftLoc = originLocation; + InvalidateTestResults(*ride); break; case TrackElemType::DiagBlockBrakes: case TrackElemType::BlockBrakes: { ride->numBlockBrakes++; - ride->windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_OPERATING; // change the current mode to its circuit blocked equivalent RideMode newMode = RideMode::continuousCircuitBlockSectioned; @@ -694,10 +694,16 @@ namespace OpenRCT2::GameActions newMode = RideMode::poweredLaunch; } - auto rideSetSetting = GameActions::RideSetSettingAction( - ride->id, GameActions::RideSetSetting::Mode, static_cast(newMode)); - ExecuteNested(&rideSetSetting, gameState); - break; + if (newMode != ride->mode) + { + // InvalidateTestResults() is called by RideSetSettingAction, so no need to call it here + + ride->windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_OPERATING; + auto rideSetSetting = GameActions::RideSetSettingAction( + ride->id, GameActions::RideSetSetting::Mode, static_cast(newMode)); + ExecuteNested(&rideSetSetting, gameState); + break; + } } default: break; diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 634e9574fd..b12864500e 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -47,7 +47,7 @@ // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -constexpr uint8_t kStreamVersion = 5; +constexpr uint8_t kStreamVersion = 6; const std::string kStreamID = std::string(kOpenRCT2Version) + "-" + std::to_string(kStreamVersion); diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 40d2fc46d3..153bbae245 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1133,18 +1133,9 @@ void Ride::update() // If ride is simulating but crashed, reset the vehicles if (status == RideStatus::simulating && (lifecycleFlags & RIDE_LIFECYCLE_CRASHED)) { - if (mode == RideMode::continuousCircuitBlockSectioned || mode == RideMode::poweredLaunchBlockSectioned) - { - // We require this to execute right away during the simulation, always ignore network and queue. - auto gameAction = GameActions::RideSetStatusAction(id, RideStatus::closed); - GameActions::ExecuteNested(&gameAction, getGameState()); - } - else - { - // We require this to execute right away during the simulation, always ignore network and queue. - auto gameAction = GameActions::RideSetStatusAction(id, RideStatus::simulating); - GameActions::ExecuteNested(&gameAction, getGameState()); - } + // We require this to execute right away during the simulation, always ignore network and queue. + auto gameAction = GameActions::RideSetStatusAction(id, RideStatus::simulating); + GameActions::ExecuteNested(&gameAction, getGameState()); } } From 4dfebb031422e8ea2d88a563c1a06d7afe96cdb8 Mon Sep 17 00:00:00 2001 From: Kyphii Date: Sat, 4 Oct 2025 16:19:56 -0400 Subject: [PATCH 2/9] Fix merge conflict --- src/openrct2/actions/TrackPlaceAction.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index 74503b8961..fb7af29227 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -689,6 +689,7 @@ namespace OpenRCT2::GameActions bool canSwitch = rtd.SupportsRideMode(newMode) || getGameState().cheats.showAllOperatingModes; if (canSwitch) { + ride->windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_OPERATING; auto rideSetSetting = GameActions::RideSetSettingAction( ride->id, GameActions::RideSetSetting::Mode, static_cast(newMode)); ExecuteNested(&rideSetSetting, gameState); From be9f1f141e7f59d9af35363dfac70e732926e85a Mon Sep 17 00:00:00 2001 From: Kyphii Date: Mon, 6 Oct 2025 18:39:35 -0400 Subject: [PATCH 3/9] Also catch TrackRemoveAction case --- src/openrct2/actions/TrackRemoveAction.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/openrct2/actions/TrackRemoveAction.cpp b/src/openrct2/actions/TrackRemoveAction.cpp index ab0178ab3c..19bd8ed2c4 100644 --- a/src/openrct2/actions/TrackRemoveAction.cpp +++ b/src/openrct2/actions/TrackRemoveAction.cpp @@ -452,7 +452,6 @@ namespace OpenRCT2::GameActions ride->numBlockBrakes--; if (ride->numBlockBrakes == 0 && ride->isBlockSectioned()) { - ride->windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_OPERATING; RideMode newMode = RideMode::continuousCircuit; if (ride->mode == RideMode::poweredLaunchBlockSectioned) { @@ -460,9 +459,18 @@ namespace OpenRCT2::GameActions newMode = ride->getRideTypeDescriptor().DefaultMode; } - auto rideSetSetting = GameActions::RideSetSettingAction( - ride->id, GameActions::RideSetSetting::Mode, static_cast(newMode)); - ExecuteNested(&rideSetSetting, gameState); + if (ride->mode != newMode) + { + bool canSwitch = ride->getRideTypeDescriptor().SupportsRideMode(newMode) + || getGameState().cheats.showAllOperatingModes; + if (canSwitch) + { + ride->windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_OPERATING; + auto rideSetSetting = GameActions::RideSetSettingAction( + ride->id, GameActions::RideSetSetting::Mode, static_cast(newMode)); + ExecuteNested(&rideSetSetting, gameState); + } + } } break; From 11e490a56d617127a941e7a1be58199e7dcb4606 Mon Sep 17 00:00:00 2001 From: Kyphii Date: Mon, 6 Oct 2025 18:52:55 -0400 Subject: [PATCH 4/9] Force close simulating rides when changing ride mode --- src/openrct2/actions/RideSetSettingAction.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/openrct2/actions/RideSetSettingAction.cpp b/src/openrct2/actions/RideSetSettingAction.cpp index 52b04dbe29..7afabd1b03 100644 --- a/src/openrct2/actions/RideSetSettingAction.cpp +++ b/src/openrct2/actions/RideSetSettingAction.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ #include "RideSetSettingAction.h" - +#include "RideSetStatusAction.h" #include "../Context.h" #include "../Diagnostic.h" #include "../GameState.h" @@ -169,6 +169,13 @@ namespace OpenRCT2::GameActions RideClearForConstruction(*ride); ride->removePeeps(); + if (ride->status == RideStatus::simulating) + { + // Also close the ride + auto gameAction = GameActions::RideSetStatusAction(ride->id, RideStatus::closed); + ExecuteNested(&gameAction, gameState); + } + ride->mode = static_cast(_value); ride->updateMaxVehicles(); ride->updateNumberOfCircuits(); From c02a41b6ae0cf3bb6f9e4b611aa74b7c9332b9f4 Mon Sep 17 00:00:00 2001 From: Kyphii Date: Mon, 6 Oct 2025 19:11:29 -0400 Subject: [PATCH 5/9] Do force close in RideClearForConstruction instead, to cover all cases --- src/openrct2/actions/RideSetSettingAction.cpp | 7 ------- src/openrct2/ride/RideConstruction.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/openrct2/actions/RideSetSettingAction.cpp b/src/openrct2/actions/RideSetSettingAction.cpp index 7afabd1b03..e250fa9c06 100644 --- a/src/openrct2/actions/RideSetSettingAction.cpp +++ b/src/openrct2/actions/RideSetSettingAction.cpp @@ -169,13 +169,6 @@ namespace OpenRCT2::GameActions RideClearForConstruction(*ride); ride->removePeeps(); - if (ride->status == RideStatus::simulating) - { - // Also close the ride - auto gameAction = GameActions::RideSetStatusAction(ride->id, RideStatus::closed); - ExecuteNested(&gameAction, gameState); - } - ride->mode = static_cast(_value); ride->updateMaxVehicles(); ride->updateNumberOfCircuits(); diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 0e63a38d63..69453cbd08 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -236,6 +236,12 @@ void RideClearForConstruction(Ride& ride) ride.removeVehicles(); RideClearBlockedTiles(ride); + // Force close simulating rides, to reset flag widget in Construction UI + if (ride.status == RideStatus::simulating) + { + ride.status = RideStatus::closed; + } + auto* windowMgr = Ui::GetWindowManager(); auto w = windowMgr->FindByNumber(WindowClass::ride, ride.id.ToUnderlying()); if (w != nullptr) From a4751789fe76147a64c3753531dc27a6cf635e3f Mon Sep 17 00:00:00 2001 From: Michael Steenbeek <1478678+Gymnasiast@users.noreply.github.com> Date: Tue, 14 Oct 2025 12:47:04 +0200 Subject: [PATCH 6/9] Remove stray change --- src/openrct2/actions/RideSetSettingAction.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/openrct2/actions/RideSetSettingAction.cpp b/src/openrct2/actions/RideSetSettingAction.cpp index e250fa9c06..99ef4de0db 100644 --- a/src/openrct2/actions/RideSetSettingAction.cpp +++ b/src/openrct2/actions/RideSetSettingAction.cpp @@ -8,7 +8,6 @@ *****************************************************************************/ #include "RideSetSettingAction.h" -#include "RideSetStatusAction.h" #include "../Context.h" #include "../Diagnostic.h" #include "../GameState.h" From bc4dc97119a1f28f96f0a6f557e87d7f7c408ab5 Mon Sep 17 00:00:00 2001 From: Kyphii Date: Tue, 14 Oct 2025 11:42:18 -0400 Subject: [PATCH 7/9] Clang formatting fix --- src/openrct2/actions/RideSetSettingAction.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openrct2/actions/RideSetSettingAction.cpp b/src/openrct2/actions/RideSetSettingAction.cpp index 99ef4de0db..52b04dbe29 100644 --- a/src/openrct2/actions/RideSetSettingAction.cpp +++ b/src/openrct2/actions/RideSetSettingAction.cpp @@ -8,6 +8,7 @@ *****************************************************************************/ #include "RideSetSettingAction.h" + #include "../Context.h" #include "../Diagnostic.h" #include "../GameState.h" From 5ade2960b6b496de86ab348c868abf97cddcd643 Mon Sep 17 00:00:00 2001 From: Kyphii Date: Thu, 16 Oct 2025 09:46:15 -0400 Subject: [PATCH 8/9] Bump network version --- distribution/changelog.txt | 2 +- src/openrct2/network/NetworkBase.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 4071a321bc..6c23e24752 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,8 +1,8 @@ 0.4.28 (in development) ------------------------------------------------------------------------ - Change: [#25089] Peep actions and animations that cause them to stop moving no longer trigger when they are on a level crossing. -- Fix: [#22779, #25330] Incorrect queue paths in Nevermore Park and Six Flags Holland scenarios (bug in the original scenarios). - Fix: [#25190] Inserting a block brake while a coaster is simulating will cause the simulation to behave strangely. +- Fix: [#22779, #25330] Incorrect queue paths in Nevermore Park and Six Flags Holland scenarios (bug in the original scenarios). - Fix: [#25299] The Mine Train Coaster left large helix draws incorrect sprites at certain angles (original bug). - Fix: [#25328] Spiral Slide in Blackpool Pleasure Beach has its entrance and exit the wrong way round (bug in the original scenario). diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 4b4b963c2d..cad46ba29e 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -47,7 +47,7 @@ // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -constexpr uint8_t kStreamVersion = 1; +constexpr uint8_t kStreamVersion = 2; const std::string kStreamID = std::string(kOpenRCT2Version) + "-" + std::to_string(kStreamVersion); From 798f307dafdceae113d3e7e9268d1faefb3c4336 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek <1478678+Gymnasiast@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:14:42 +0200 Subject: [PATCH 9/9] Fix changelog order --- distribution/changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 6c23e24752..4071a321bc 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,8 +1,8 @@ 0.4.28 (in development) ------------------------------------------------------------------------ - Change: [#25089] Peep actions and animations that cause them to stop moving no longer trigger when they are on a level crossing. -- Fix: [#25190] Inserting a block brake while a coaster is simulating will cause the simulation to behave strangely. - Fix: [#22779, #25330] Incorrect queue paths in Nevermore Park and Six Flags Holland scenarios (bug in the original scenarios). +- Fix: [#25190] Inserting a block brake while a coaster is simulating will cause the simulation to behave strangely. - Fix: [#25299] The Mine Train Coaster left large helix draws incorrect sprites at certain angles (original bug). - Fix: [#25328] Spiral Slide in Blackpool Pleasure Beach has its entrance and exit the wrong way round (bug in the original scenario).