From 646d16e745713c8ed40a0a707bb07a0d1178535d 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/6] Move WaitingAtCrossing logic to 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 94b56e9fdb..848140a9a5 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -5697,44 +5697,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 0257f0c93c..f009227098 100644 --- a/src/openrct2/entity/Guest.h +++ b/src/openrct2/entity/Guest.h @@ -377,7 +377,6 @@ private: 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 603aee0819..602f0b4948 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -250,6 +250,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 fefadec182..88c3550183 100644 --- a/src/openrct2/entity/Peep.h +++ b/src/openrct2/entity/Peep.h @@ -387,6 +387,7 @@ public: // Peep 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 21cf85b90e..f4f47a400f 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 80977e1e0d04ac25f325da20bbcaa0dceb8d7624 Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Mon, 6 Oct 2025 21:06:25 -0300 Subject: [PATCH 2/6] Check if guest action is interruptable This fixes a bug where the waving or eating animations for the guests could suddenly reset while it was already playing --- src/openrct2/entity/Peep.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index 602f0b4948..dbcf8b1770 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -266,21 +266,24 @@ void Peep::UpdateWaitingAtCrossing() if (auto* guest = As(); guest != nullptr) { - if (guest->HasFoodOrDrink()) + if (guest->IsActionInterruptable()) { - if ((ScenarioRand() & 0xFFFF) <= 1310) + if (guest->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) <= 64) - { - Action = PeepActionType::wave2; - AnimationFrameNum = 0; - AnimationImageIdOffset = 0; - } } UpdateCurrentAnimationType(); From 03af42598c19630eb7ecbfa1d605358f738fd388 Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Tue, 7 Oct 2025 13:57:07 -0300 Subject: [PATCH 3/6] Make crossing-related Peep methods protected --- src/openrct2/entity/Peep.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openrct2/entity/Peep.h b/src/openrct2/entity/Peep.h index 88c3550183..2eb783394d 100644 --- a/src/openrct2/entity/Peep.h +++ b/src/openrct2/entity/Peep.h @@ -387,7 +387,6 @@ public: // Peep void Remove(); void UpdateCurrentAnimationType(); void UpdateSpriteBoundingBox(); - void UpdateWaitingAtCrossing(); void SwitchToSpecialSprite(uint8_t special_sprite_id); void StateReset(); [[nodiscard]] uint8_t GetNextDirection() const; @@ -422,15 +421,16 @@ public: // Peep // 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 UpdateWaitingAtCrossing(); void UpdateFalling(); void Update1(); void UpdatePicked(); From 72f23f5d14a0fa82cd81da03d36f2c08b0846fa5 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 4/6] Add changelog entry --- distribution/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 0dcf24fb44..2a76ba1eaa 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.4.30 (in development) ------------------------------------------------------------------------ +- Improved: [#24912] Staff now use an appropriate standing animation while waiting at level crossings. - Improved: [#25529] The map selection grid no longer redraws every frame if it has not changed. - Improved: [#25530] Wall dragging can now be cancelled without closing the Scenery window. - Improved: [#25575] Updated the network protocol to a new format that supports larger packets, allowing clients to connect reliably to servers with many objects or large maps. From f82b445a73c131965a61edfc68149a0de27b7829 Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Sun, 7 Dec 2025 10:37:29 -0300 Subject: [PATCH 5/6] Update 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 4f8b3dad66..c3cbf6610b 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 = 3; +constexpr uint8_t kStreamVersion = 4; const std::string kStreamID = std::string(kOpenRCT2Version) + "-" + std::to_string(kStreamVersion); From 6c97dd1dc710aeb670df69b1dcbc0b607995d7a6 Mon Sep 17 00:00:00 2001 From: matheusvb3 <98937378+matheusvb3@users.noreply.github.com> Date: Sun, 7 Dec 2025 13:05:44 -0300 Subject: [PATCH 6/6] Implement Gymnasiast's suggestion --- src/openrct2/entity/Peep.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index dbcf8b1770..68936d21a2 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -264,7 +264,8 @@ void Peep::UpdateWaitingAtCrossing() NextAnimationType = PeepAnimationType::watchRide; SwitchNextAnimationType(); - if (auto* guest = As(); guest != nullptr) + auto* guest = As(); + if (guest != nullptr) { if (guest->IsActionInterruptable()) {