From 069052e3cbfc50b37af61737382887ac2b625c61 Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Thu, 18 Sep 2025 09:18:44 -0300 Subject: [PATCH 1/8] Move WaitingAtCrossing logic to peep.cpp Update Peep.cpp --- src/openrct2/entity/Guest.cpp | 38 ----------------------------------- src/openrct2/entity/Guest.h | 1 - src/openrct2/entity/Peep.cpp | 36 +++++++++++++++++++++++++++++++++ src/openrct2/entity/Peep.h | 1 + src/openrct2/entity/Staff.cpp | 3 +++ 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index b821d36a471d..62da2de0c2fb 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -5698,44 +5698,6 @@ void Guest::UpdateWalking() } } -void Guest::UpdateWaitingAtCrossing() -{ - if (!IsActionInterruptable()) - { - UpdateAction(); - Invalidate(); - if (!IsActionWalking()) - return; - } - - Action = PeepActionType::idle; - NextAnimationType = PeepAnimationType::watchRide; - SwitchNextAnimationType(); - - if (HasFoodOrDrink()) - { - if ((ScenarioRand() & 0xFFFF) <= 1310) - { - Action = PeepActionType::eatFood; - AnimationFrameNum = 0; - AnimationImageIdOffset = 0; - } - - UpdateCurrentAnimationType(); - - return; - } - - if ((ScenarioRand() & 0xFFFF) <= 64) - { - Action = PeepActionType::wave2; - AnimationFrameNum = 0; - AnimationImageIdOffset = 0; - } - - UpdateCurrentAnimationType(); -} - /** * * rct2: 0x69185D diff --git a/src/openrct2/entity/Guest.h b/src/openrct2/entity/Guest.h index 0257f0c93c31..f00922709899 100644 --- a/src/openrct2/entity/Guest.h +++ b/src/openrct2/entity/Guest.h @@ -377,7 +377,6 @@ struct Guest : Peep void UpdateRide(); void UpdateOnRide() {}; // TODO void UpdateWalking(); - void UpdateWaitingAtCrossing(); void UpdateQueuing(); void UpdateSitting(); void UpdateEnteringPark(); diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index 6b8fdf34ad64..6dc6274f1087 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -258,6 +258,42 @@ void PeepUpdateAllBoundingBoxes() } } +void Peep::UpdateWaitingAtCrossing() +{ + if (!IsActionInterruptable()) + { + UpdateAction(); + Invalidate(); + if (!IsActionWalking()) + return; + } + + Action = PeepActionType::idle; + NextAnimationType = PeepAnimationType::watchRide; + SwitchNextAnimationType(); + + if (auto* guest = As(); guest != nullptr) + { + if (guest->HasFoodOrDrink()) + { + if ((ScenarioRand() & 0xFFFF) <= 1310) + { + Action = PeepActionType::EatFood; + AnimationFrameNum = 0; + AnimationImageIdOffset = 0; + } + } + else if ((ScenarioRand() & 0xFFFF) <= 64) + { + Action = PeepActionType::Wave2; + AnimationFrameNum = 0; + AnimationImageIdOffset = 0; + } + } + + UpdateCurrentAnimationType(); +} + /* * rct2: 0x68F3AE * Set peep state to falling if path below has gone missing, return true if current path is valid, false if peep starts falling. diff --git a/src/openrct2/entity/Peep.h b/src/openrct2/entity/Peep.h index 40140b6ac4a7..9c41ae44efe0 100644 --- a/src/openrct2/entity/Peep.h +++ b/src/openrct2/entity/Peep.h @@ -370,6 +370,7 @@ struct Peep : EntityBase void Remove(); void UpdateCurrentAnimationType(); void UpdateSpriteBoundingBox(); + void UpdateWaitingAtCrossing(); void SwitchToSpecialSprite(uint8_t special_sprite_id); void StateReset(); [[nodiscard]] uint8_t GetNextDirection() const; diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index 8759d11697aa..4f399b44a0f7 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -1830,7 +1830,10 @@ void Staff::UpdatePatrolling() return; if (ShouldWaitForLevelCrossing() && !IsMechanicHeadingToFixRideBlockingPath()) + { + UpdateWaitingAtCrossing(); return; + } const auto [pathingResult, _] = PerformNextAction(); if (!(pathingResult & PATHING_DESTINATION_REACHED)) From 5fa489720fe3ee9f7243f606f42dbbf0e91df1dd Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Sat, 4 Oct 2025 20:05:42 -0300 Subject: [PATCH 2/8] Add changelog entry for v0.4.28 --- distribution/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index f55b88530bc6..19ca63bfe5ac 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.4.28 (in development) ------------------------------------------------------------------------ +- Improved: [#24912] Staff now use an appropriate standing animation while waiting at level crossings. - Change: [#25089] Peep actions and animations that cause them to stop moving no longer trigger when they are on a level crossing. - Fix: [#25299] The Mine Train Coaster left large helix draws incorrect sprites at certain angles (original bug). From d89ce2ea11b0f2770fa5aa971784b6215469cf41 Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Sat, 4 Oct 2025 20:06:18 -0300 Subject: [PATCH 3/8] Increment network version --- src/openrct2/network/NetworkBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 27b45a8232c5..8495c3df2bf9 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 035393e94539f81293970153efff55b09f4addb2 Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Sun, 5 Oct 2025 23:14:41 -0300 Subject: [PATCH 4/8] Make Peep crossing-related functions protected --- src/openrct2/entity/Peep.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openrct2/entity/Peep.h b/src/openrct2/entity/Peep.h index 9c41ae44efe0..649ee3510aa7 100644 --- a/src/openrct2/entity/Peep.h +++ b/src/openrct2/entity/Peep.h @@ -405,15 +405,15 @@ struct Peep : EntityBase // TODO: Make these private again when done refactoring public: // Peep [[nodiscard]] bool CheckForPath(); - bool ShouldWaitForLevelCrossing() const; - bool IsOnLevelCrossing() const; - bool IsOnPathBlockedByVehicle() const; std::pair PerformNextAction(); [[nodiscard]] int32_t GetZOnSlope(int32_t tile_x, int32_t tile_y); void SwitchNextAnimationType(); [[nodiscard]] PeepAnimationType GetAnimationType(); protected: + bool ShouldWaitForLevelCrossing() const; + bool IsOnLevelCrossing() const; + bool IsOnPathBlockedByVehicle() const; void UpdateFalling(); void Update1(); void UpdatePicked(); From 6fdf4fba24ddf06e8e95fd7d3646be358fdde640 Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Sun, 5 Oct 2025 23:33:06 -0300 Subject: [PATCH 5/8] Separate Staff and Guest specific behavior from Peep --- src/openrct2/entity/Guest.cpp | 22 ++++++++++++++++++++++ src/openrct2/entity/Guest.h | 1 + src/openrct2/entity/Peep.cpp | 21 --------------------- src/openrct2/entity/Peep.h | 2 +- src/openrct2/entity/Staff.cpp | 17 +++++++++++++++++ src/openrct2/entity/Staff.h | 1 + 6 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 62da2de0c2fb..fa27cc755aa8 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -7799,6 +7799,28 @@ void Guest::ThrowUp() OpenRCT2::Audio::Play3D(soundId, curLoc); } +void Guest::UpdateWaitingAtCrossing() +{ + Peep::UpdateWaitingAtCrossing(); + if (HasFoodOrDrink()) + { + if ((ScenarioRand() & 0xFFFF) <= 1310) + { + Action = PeepActionType::eatFood; + AnimationFrameNum = 0; + AnimationImageIdOffset = 0; + } + } + else if ((ScenarioRand() & 0xFFFF) <= 64) + { + Action = PeepActionType::wave2; + AnimationFrameNum = 0; + AnimationImageIdOffset = 0; + } + + UpdateCurrentAnimationType(); +} + void Guest::Serialise(DataSerialiser& stream) { Peep::Serialise(stream); diff --git a/src/openrct2/entity/Guest.h b/src/openrct2/entity/Guest.h index f00922709899..80f56583dc97 100644 --- a/src/openrct2/entity/Guest.h +++ b/src/openrct2/entity/Guest.h @@ -371,6 +371,7 @@ struct Guest : Peep void ThrowUp(); private: + void UpdateWaitingAtCrossing(); bool ShouldFindBench(); bool UpdateWalkingFindBin(); bool UpdateWalkingFindBench(); diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index 6dc6274f1087..4850c1d15f35 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -271,27 +271,6 @@ void Peep::UpdateWaitingAtCrossing() Action = PeepActionType::idle; NextAnimationType = PeepAnimationType::watchRide; SwitchNextAnimationType(); - - if (auto* guest = As(); guest != nullptr) - { - if (guest->HasFoodOrDrink()) - { - if ((ScenarioRand() & 0xFFFF) <= 1310) - { - Action = PeepActionType::EatFood; - AnimationFrameNum = 0; - AnimationImageIdOffset = 0; - } - } - else if ((ScenarioRand() & 0xFFFF) <= 64) - { - Action = PeepActionType::Wave2; - AnimationFrameNum = 0; - AnimationImageIdOffset = 0; - } - } - - UpdateCurrentAnimationType(); } /* diff --git a/src/openrct2/entity/Peep.h b/src/openrct2/entity/Peep.h index 649ee3510aa7..a42f42a1724c 100644 --- a/src/openrct2/entity/Peep.h +++ b/src/openrct2/entity/Peep.h @@ -370,7 +370,6 @@ struct Peep : EntityBase void Remove(); void UpdateCurrentAnimationType(); void UpdateSpriteBoundingBox(); - void UpdateWaitingAtCrossing(); void SwitchToSpecialSprite(uint8_t special_sprite_id); void StateReset(); [[nodiscard]] uint8_t GetNextDirection() const; @@ -411,6 +410,7 @@ struct Peep : EntityBase [[nodiscard]] PeepAnimationType GetAnimationType(); protected: + void UpdateWaitingAtCrossing(); bool ShouldWaitForLevelCrossing() const; bool IsOnLevelCrossing() const; bool IsOnPathBlockedByVehicle() const; diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index 4f399b44a0f7..a6317ddd3be1 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -1010,6 +1010,23 @@ GameActions::Result StaffSetColour(StaffType staffType, colour_t value) return GameActions::Result(); } +void Staff::UpdateWaitingAtCrossing() +{ + Peep::UpdateWaitingAtCrossing(); + if (isEntertainer()) + { + if ((ScenarioRand() & 0xFFFF) <= 1310) + { + Action = PeepActionType::wave2; + AnimationFrameNum = 0; + AnimationImageIdOffset = 0; + EntertainerUpdateNearbyPeeps(); + } + } + + UpdateCurrentAnimationType(); +} + /** rct2: 0x009929C8 */ static constexpr CoordsXY kMowingWaypoints[] = { { 28, 28 }, { 28, 4 }, { 20, 4 }, { 20, 28 }, { 12, 28 }, { 12, 4 }, { 4, 4 }, { 4, 28 }, diff --git a/src/openrct2/entity/Staff.h b/src/openrct2/entity/Staff.h index 905f5d40250f..9be9b3d7dcfa 100644 --- a/src/openrct2/entity/Staff.h +++ b/src/openrct2/entity/Staff.h @@ -88,6 +88,7 @@ struct Staff : Peep bool HasPatrolArea() const; private: + void UpdateWaitingAtCrossing(); void UpdatePatrolling(); void UpdateMowing(); void UpdateSweeping(); From a95280f095f3b513491f5565f1904eab0a1a0a82 Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Mon, 6 Oct 2025 14:35:40 -0300 Subject: [PATCH 6/8] test random values --- src/openrct2/entity/Guest.cpp | 4 ++-- src/openrct2/entity/Staff.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index fa27cc755aa8..899a621e3886 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -7804,14 +7804,14 @@ void Guest::UpdateWaitingAtCrossing() Peep::UpdateWaitingAtCrossing(); if (HasFoodOrDrink()) { - if ((ScenarioRand() & 0xFFFF) <= 1310) + if ((ScenarioRand() & 0xFFFF) <= 64) { Action = PeepActionType::eatFood; AnimationFrameNum = 0; AnimationImageIdOffset = 0; } } - else if ((ScenarioRand() & 0xFFFF) <= 64) + else if ((ScenarioRand() & 0xFFFF) <= 1310) { Action = PeepActionType::wave2; AnimationFrameNum = 0; diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index a6317ddd3be1..8ada83674d80 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -1015,7 +1015,7 @@ void Staff::UpdateWaitingAtCrossing() Peep::UpdateWaitingAtCrossing(); if (isEntertainer()) { - if ((ScenarioRand() & 0xFFFF) <= 1310) + if ((ScenarioRand() & 0xFFFF) <= 256) { Action = PeepActionType::wave2; AnimationFrameNum = 0; From 7d4b833374307248b2a19b9571054d70f6701105 Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Mon, 6 Oct 2025 14:53:28 -0300 Subject: [PATCH 7/8] dsfsdf --- src/openrct2/entity/Guest.cpp | 21 ++++++++++++--------- src/openrct2/entity/Staff.cpp | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 899a621e3886..9a43ef314e1c 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -7802,21 +7802,24 @@ void Guest::ThrowUp() void Guest::UpdateWaitingAtCrossing() { Peep::UpdateWaitingAtCrossing(); - if (HasFoodOrDrink()) + if (IsActionInterruptable()) { - if ((ScenarioRand() & 0xFFFF) <= 64) + if (HasFoodOrDrink()) { - Action = PeepActionType::eatFood; + if ((ScenarioRand() & 0xFFFF) <= 1310) + { + Action = PeepActionType::eatFood; + AnimationFrameNum = 0; + AnimationImageIdOffset = 0; + } + } + else if ((ScenarioRand() & 0xFFFF) <= 64) + { + Action = PeepActionType::wave2; AnimationFrameNum = 0; AnimationImageIdOffset = 0; } } - else if ((ScenarioRand() & 0xFFFF) <= 1310) - { - Action = PeepActionType::wave2; - AnimationFrameNum = 0; - AnimationImageIdOffset = 0; - } UpdateCurrentAnimationType(); } diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index 8ada83674d80..22f287772fe2 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -1013,9 +1013,9 @@ GameActions::Result StaffSetColour(StaffType staffType, colour_t value) void Staff::UpdateWaitingAtCrossing() { Peep::UpdateWaitingAtCrossing(); - if (isEntertainer()) + if (isEntertainer() && IsActionInterruptable()) { - if ((ScenarioRand() & 0xFFFF) <= 256) + if ((ScenarioRand() & 0xFFFF) <= 384) { Action = PeepActionType::wave2; AnimationFrameNum = 0; From 13188b0a293dda06e452c2f9b0e2a358c3a999fa Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Mon, 6 Oct 2025 19:24:31 -0300 Subject: [PATCH 8/8] Update Staff.cpp --- src/openrct2/entity/Staff.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index 22f287772fe2..788b630d1f59 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -1015,7 +1015,7 @@ void Staff::UpdateWaitingAtCrossing() Peep::UpdateWaitingAtCrossing(); if (isEntertainer() && IsActionInterruptable()) { - if ((ScenarioRand() & 0xFFFF) <= 384) + if ((ScenarioRand() & 0xFFFF) <= 1600) { Action = PeepActionType::wave2; AnimationFrameNum = 0;