1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 19:43:06 +01:00

Make peeps not stop on level crossings (#25089)

* Check if actions can be performed safely

* Add explanatory comment

* Refactor Easter egg logic in Guest::UpdateWalking

* Add changelog entry

* Make the comment more explanatory

* Update NetworkBase.cpp

* Update changelog for v0.28
This commit is contained in:
matheusvb3
2025-10-04 19:52:26 -03:00
committed by GitHub
parent 1089b11192
commit d8da02e7dd
7 changed files with 33 additions and 32 deletions

View File

@@ -532,7 +532,7 @@ void Guest::GivePassingGuestPizza(Guest& passingPeep)
int32_t otherPeepOppositeDirection = passingPeep.Orientation >> 3;
if (peepDirection == otherPeepOppositeDirection)
{
if (passingPeep.IsActionInterruptable())
if (passingPeep.IsActionInterruptableSafely())
{
passingPeep.Action = PeepActionType::Wave2;
passingPeep.AnimationFrameNum = 0;
@@ -547,7 +547,7 @@ void Guest::MakePassingGuestSick(Guest& passingPeep)
if (passingPeep.State != PeepState::Walking)
return;
if (passingPeep.IsActionInterruptable())
if (passingPeep.IsActionInterruptableSafely())
{
passingPeep.Action = PeepActionType::ThrowUp;
passingPeep.AnimationFrameNum = 0;
@@ -595,7 +595,7 @@ void Guest::UpdateEasterEggInteractions()
{
if ((ScenarioRand() & 0xFFFF) <= 1456)
{
if (IsActionInterruptable())
if (IsActionInterruptableSafely())
{
Action = PeepActionType::Joy;
AnimationFrameNum = 0;
@@ -800,7 +800,7 @@ void Guest::UpdateMotivesIdle()
{
if ((ScenarioRand() & 0xFF) <= static_cast<uint8_t>((Nausea - 128) / 2))
{
if (IsActionInterruptable())
if (IsActionInterruptableSafely())
{
Action = PeepActionType::ThrowUp;
AnimationFrameNum = 0;
@@ -2426,7 +2426,7 @@ void Guest::ChoseNotToGoOnRide(const Ride& ride, bool peepAtRide, bool updateLas
void Guest::ReadMap()
{
if (IsActionInterruptable() && !IsOnLevelCrossing())
if (IsActionInterruptableSafely())
{
Action = PeepActionType::ReadMap;
AnimationFrameNum = 0;
@@ -5473,32 +5473,22 @@ void Guest::UpdateWalking()
const auto currentTicks = getGameState().currentTicks;
if (!IsOnLevelCrossing())
if (IsActionInterruptableSafely())
{
if (PeepFlags & PEEP_FLAGS_WAVING && IsActionInterruptable() && (0xFFFF & ScenarioRand()) < 936)
PeepActionType NewAction = Action;
if (PeepFlags & PEEP_FLAGS_WAVING && (0xFFFF & ScenarioRand()) < 936)
NewAction = PeepActionType::Wave2;
else if (PeepFlags & PEEP_FLAGS_PHOTO && (0xFFFF & ScenarioRand()) < 936)
NewAction = PeepActionType::TakePhoto;
else if (PeepFlags & PEEP_FLAGS_PAINTING && (0xFFFF & ScenarioRand()) < 936)
NewAction = PeepActionType::DrawPicture;
if (NewAction != Action)
{
Action = PeepActionType::Wave2;
Action = NewAction;
AnimationFrameNum = 0;
AnimationImageIdOffset = 0;
UpdateCurrentAnimationType();
}
if (PeepFlags & PEEP_FLAGS_PHOTO && IsActionInterruptable() && (0xFFFF & ScenarioRand()) < 936)
{
Action = PeepActionType::TakePhoto;
AnimationFrameNum = 0;
AnimationImageIdOffset = 0;
UpdateCurrentAnimationType();
}
if (PeepFlags & PEEP_FLAGS_PAINTING && IsActionInterruptable() && (0xFFFF & ScenarioRand()) < 936)
{
Action = PeepActionType::DrawPicture;
AnimationFrameNum = 0;
AnimationImageIdOffset = 0;
UpdateCurrentAnimationType();
}
}
@@ -7129,7 +7119,7 @@ void Guest::InsertNewThought(PeepThoughtType thought_type, RideId rideId)
void Guest::InsertNewThought(PeepThoughtType thoughtType, uint16_t thoughtArguments)
{
PeepActionType newAction = PeepThoughtToActionMap[EnumValue(thoughtType)].action;
if (newAction != PeepActionType::Walking && IsActionInterruptable())
if (newAction != PeepActionType::Walking && IsActionInterruptableSafely())
{
Action = newAction;
AnimationFrameNum = 0;

View File

@@ -1229,7 +1229,7 @@ void PeepApplause()
GuestReleaseBalloon(peep, peep->z + 9);
// Clap
if ((peep->State == PeepState::Walking || peep->State == PeepState::Queuing) && peep->IsActionInterruptable())
if ((peep->State == PeepState::Walking || peep->State == PeepState::Queuing) && peep->IsActionInterruptableSafely())
{
peep->Action = PeepActionType::Clap;
peep->AnimationFrameNum = 0;
@@ -1533,6 +1533,15 @@ bool Peep::IsActionInterruptable() const
return IsActionIdle() || IsActionWalking();
}
/**
* Used to avoid peep action and animation triggers that cause them to stop moving and might put them at risk
* of getting run over at level crossings, such as guests reading the map and entertainers performing.
*/
bool Peep::IsActionInterruptableSafely() const
{
return IsActionInterruptable() && !IsOnLevelCrossing();
}
void PeepSetMapTooltip(Peep* peep)
{
auto ft = Formatter();

View File

@@ -388,6 +388,7 @@ public: // Peep
bool IsActionWalking() const;
bool IsActionIdle() const;
bool IsActionInterruptable() const;
bool IsActionInterruptableSafely() const;
// Reset the peep's stored goal, which means they will forget any stored pathfinding history
// on the next GuestPathfinding::ChooseDirection call.

View File

@@ -924,7 +924,7 @@ void Staff::EntertainerUpdateNearbyPeeps() const
*/
bool Staff::DoEntertainerPathFinding()
{
if (((ScenarioRand() & 0xFFFF) <= 0x4000) && IsActionInterruptable())
if (((ScenarioRand() & 0xFFFF) <= 0x4000) && IsActionInterruptableSafely())
{
Action = (ScenarioRand() & 1) ? PeepActionType::Wave2 : PeepActionType::Joy;
AnimationFrameNum = 0;

View File

@@ -47,7 +47,7 @@
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
constexpr uint8_t kStreamVersion = 0;
constexpr uint8_t kStreamVersion = 1;
const std::string kStreamID = std::string(kOpenRCT2Version) + "-" + std::to_string(kStreamVersion);

View File

@@ -176,7 +176,7 @@ static std::optional<UpdateType> UpdateSmallSceneryAnimation(
auto quad = EntityTileList<Peep>(CoordsXY{ loc.x, loc.y } - CoordsDirectionDelta[direction]);
for (auto peep : quad)
{
if (peep->State != PeepState::Walking || peep->z != baseZ || peep->Action < PeepActionType::Idle)
if (peep->State != PeepState::Walking || peep->z != baseZ || !peep->IsActionInterruptableSafely())
continue;
peep->Action = PeepActionType::CheckTime;
peep->AnimationFrameNum = 0;