From 853f718aeeea0c81649f803f2c9a493236fca157 Mon Sep 17 00:00:00 2001 From: rpstester <32249806+rpstester@users.noreply.github.com> Date: Mon, 19 Oct 2020 21:22:24 -0400 Subject: [PATCH] Close #12391: Refactor PeepUsingBinSubState to use strong enum (#13247) Changed it to enum class and updated references. --- src/openrct2/peep/Guest.cpp | 10 +++++----- src/openrct2/peep/Peep.h | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 027aa94181..a79aa0ec5c 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -5849,9 +5849,9 @@ void Guest::UpdateWatching() */ void Guest::UpdateUsingBin() { - switch (SubState) + switch (UsingBinSubState) { - case PEEP_USING_BIN_WALKING_TO_BIN: + case PeepUsingBinSubState::WalkingToBin: { if (!CheckForPath()) return; @@ -5860,11 +5860,11 @@ void Guest::UpdateUsingBin() PerformNextAction(pathingResult); if (pathingResult & PATHING_DESTINATION_REACHED) { - SubState = PEEP_USING_BIN_GOING_BACK; + UsingBinSubState = PeepUsingBinSubState::GoingBack; } break; } - case PEEP_USING_BIN_GOING_BACK: + case PeepUsingBinSubState::GoingBack: { if (Action != PeepActionType::None2) { @@ -6201,7 +6201,7 @@ bool Guest::UpdateWalkingFindBin() peep->Var37 = chosen_edge; peep->SetState(PeepState::UsingBin); - peep->SubState = PEEP_USING_BIN_WALKING_TO_BIN; + peep->UsingBinSubState = PeepUsingBinSubState::WalkingToBin; int32_t binX = (peep->x & 0xFFE0) + BinUseOffsets[peep->Var37 & 0x3].x; int32_t binY = (peep->y & 0xFFE0) + BinUseOffsets[peep->Var37 & 0x3].y; diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index eb98299689..5426bbdc65 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -277,10 +277,10 @@ enum class PeepRideSubState : uint8_t LeaveShop = 21 }; -enum PeepUsingBinSubState +enum class PeepUsingBinSubState : uint8_t { - PEEP_USING_BIN_WALKING_TO_BIN = 0, - PEEP_USING_BIN_GOING_BACK, + WalkingToBin = 0, + GoingBack, }; enum class PeepActionType : uint8_t @@ -623,6 +623,7 @@ struct Peep : SpriteBase uint8_t SubState; PeepSittingSubState SittingSubState; PeepRideSubState RideSubState; + PeepUsingBinSubState UsingBinSubState; }; PeepSpriteType SpriteType; PeepType AssignedPeepType;