1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Reduce scope of some variables

This commit is contained in:
ζeh Matt
2025-09-12 14:52:34 +03:00
parent 4698ddc5f5
commit 977ec4517f
2 changed files with 7 additions and 14 deletions

View File

@@ -515,8 +515,7 @@ namespace OpenRCT2::Ui::Windows
// If normal peep set sprite to normal (no food)
// If staff set sprite to staff sprite
auto spriteType = PeepAnimationGroup::Normal;
auto* staff = peep->As<Staff>();
if (staff != nullptr)
if (auto* staff = peep->As<Staff>(); staff != nullptr)
{
spriteType = staff->AnimationGroup;
if (staff->AssignedStaffType == StaffType::Entertainer)

View File

@@ -460,8 +460,7 @@ std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
}
// Should we throw up, and are we at the frame where sick appears?
auto* guest = As<Guest>();
if (Action == PeepActionType::ThrowUp && AnimationFrameNum == 15 && guest != nullptr)
if (Action == PeepActionType::ThrowUp && AnimationFrameNum == 15 && Is<Guest>())
{
ThrowUp();
}
@@ -626,8 +625,7 @@ void PeepWindowStateUpdate(Peep* peep)
void Peep::Pickup()
{
auto* guest = As<Guest>();
if (guest != nullptr)
if (auto* guest = As<Guest>(); guest != nullptr)
{
guest->RemoveFromRide();
}
@@ -701,8 +699,7 @@ GameActions::Result Peep::Place(const TileCoordsXYZ& location, bool apply)
AnimationType = PeepAnimationType::Walking;
PathCheckOptimisation = 0;
EntityTweener::Get().Reset();
auto* guest = As<Guest>();
if (guest != nullptr)
if (auto* guest = As<Guest>(); guest != nullptr)
{
AnimationType = PeepAnimationType::Invalid;
guest->HappinessTarget = std::max(guest->HappinessTarget - 10, 0);
@@ -834,8 +831,7 @@ void Peep::UpdateFalling()
// Looks like we are drowning!
MoveTo({ x, y, height });
auto* guest = As<Guest>();
if (guest != nullptr)
if (auto* guest = As<Guest>(); guest != nullptr)
{
// Drop balloon if held
GuestReleaseBalloon(guest, height);
@@ -1333,8 +1329,7 @@ void Peep::FormatActionTo(Formatter& ft) const
case PeepState::Walking:
case PeepState::UsingBin:
{
auto* guest = As<Guest>();
if (guest != nullptr)
if (auto* guest = As<Guest>(); guest != nullptr)
{
if (!guest->GuestHeadingToRideId.IsNull())
{
@@ -1567,8 +1562,7 @@ bool Peep::IsActionInterruptable() const
void PeepSetMapTooltip(Peep* peep)
{
auto ft = Formatter();
auto* guest = peep->As<Guest>();
if (guest != nullptr)
if (auto* guest = peep->As<Guest>(); guest != nullptr)
{
ft.Add<StringId>((peep->PeepFlags & PEEP_FLAGS_TRACKING) ? STR_TRACKED_GUEST_MAP_TIP : STR_GUEST_MAP_TIP);
ft.Add<uint32_t>(GetPeepFaceSpriteSmall(guest));