From 2a7839941891366fe7abc8613355e582aeed1ec8 Mon Sep 17 00:00:00 2001 From: Rik Smeets <30838294+rik-smeets@users.noreply.github.com> Date: Sun, 7 Apr 2024 19:02:11 +0200 Subject: [PATCH 1/3] Introduce BoatHireSubState enum --- src/openrct2/ride/Vehicle.cpp | 6 +++--- src/openrct2/ride/Vehicle.h | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 462038b032..d266a3642e 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -3771,7 +3771,7 @@ void Vehicle::UpdateMotionBoatHire() return; bool do_Loc6DAA97 = false; - if (sub_state != 1) + if (sub_state != BoatHireSubState::EnteringReturnPosition) { do_Loc6DAA97 = true; } @@ -3908,12 +3908,12 @@ void Vehicle::UpdateBoatLocation() if (location.ToTileStart() == returnPosition.ToCoordsXY()) { - sub_state = 1; + sub_state = BoatHireSubState::EnteringReturnPosition; BoatLocation = location.ToTileStart(); return; } - sub_state = 0; + sub_state = BoatHireSubState::Normal; uint8_t curDirection = ((Orientation + 19) >> 3) & 3; uint8_t randDirection = ScenarioRand() & 3; diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index cfb8c660a4..15db70bd94 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -425,6 +425,12 @@ enum class MiniGolfAnimation : uint8_t Putt, }; +enum BoatHireSubState : uint8_t +{ + Normal, + EnteringReturnPosition, +}; + namespace VehicleFlags { constexpr uint32_t OnLiftHill = (1 << 0); From e250ec3b66b7474a6c74be9c3967d3bd4f1624e9 Mon Sep 17 00:00:00 2001 From: Rik Smeets <30838294+rik-smeets@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:17:55 +0200 Subject: [PATCH 2/3] Fix #866: Boat Hire boats get stuck entering track --- distribution/changelog.txt | 1 + src/openrct2/network/NetworkBase.cpp | 2 +- src/openrct2/ride/Vehicle.cpp | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index c822a6103e..083db567ae 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.4.11 (in development) ------------------------------------------------------------------------ +- Fix: [#866] Boat Hire boats get stuck entering track. 0.4.10 (2024-04-02) ------------------------------------------------------------------------ diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index c4df36b1ea..1e32583e17 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -46,7 +46,7 @@ using namespace OpenRCT2; // 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 diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index d266a3642e..167ec3cada 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -6644,6 +6644,12 @@ bool Vehicle::UpdateMotionCollisionDetection(const CoordsXYZ& loc, EntityId* oth return false; } + if (collideVehicle->status == Vehicle::Status::TravellingBoat + && sub_state == BoatHireSubState::EnteringReturnPosition) + { + return false; + } + CollisionDetectionTimer++; if (CollisionDetectionTimer < 200) { From b009643ab01a218b87a7c1b60b74edb546ebfbb1 Mon Sep 17 00:00:00 2001 From: Rik Smeets <30838294+rik-smeets@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:21:17 +0200 Subject: [PATCH 3/3] Remove to do statement by explicit null check on collideVehicle --- src/openrct2/ride/Vehicle.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 167ec3cada..1fed0299db 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -6638,14 +6638,13 @@ bool Vehicle::UpdateMotionCollisionDetection(const CoordsXYZ& loc, EntityId* oth } } - if (!mayCollide) + if (!mayCollide || collideVehicle == nullptr) { CollisionDetectionTimer = 0; return false; } - if (collideVehicle->status == Vehicle::Status::TravellingBoat - && sub_state == BoatHireSubState::EnteringReturnPosition) + if (collideVehicle->status == Vehicle::Status::TravellingBoat && sub_state == BoatHireSubState::EnteringReturnPosition) { return false; } @@ -6659,8 +6658,6 @@ bool Vehicle::UpdateMotionCollisionDetection(const CoordsXYZ& loc, EntityId* oth return true; } - // TODO Is it possible for collideVehicle to be NULL? - if (status == Vehicle::Status::MovingToEndOfStation) { if (Orientation == 0)