From c3453967652710d9588d0b7dfcae7018c3b64893 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 12 May 2021 07:56:32 +0100 Subject: [PATCH] Move duck method into class --- src/openrct2-ui/interface/ViewportInteraction.cpp | 2 +- src/openrct2/actions/SetCheatAction.cpp | 2 +- src/openrct2/scenario/Scenario.cpp | 4 ++-- src/openrct2/world/Duck.cpp | 8 ++++---- src/openrct2/world/Duck.h | 7 +++---- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 3607cc8714..a35a5808a1 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -208,7 +208,7 @@ bool ViewportInteractionLeftClick(const ScreenCoordsXY& screenCoords) auto duck = entity->As(); if (duck != nullptr) { - duck_press(duck); + duck->Press(); } } } diff --git a/src/openrct2/actions/SetCheatAction.cpp b/src/openrct2/actions/SetCheatAction.cpp index 79bea5407f..628059b6a8 100644 --- a/src/openrct2/actions/SetCheatAction.cpp +++ b/src/openrct2/actions/SetCheatAction.cpp @@ -232,7 +232,7 @@ GameActions::Result::Ptr SetCheatAction::Execute() const CreateDucks(_param1); break; case CheatType::RemoveDucks: - duck_remove_all(); + Duck::RemoveAll(); break; case CheatType::AllowTrackPlaceInvalidHeights: gCheatsAllowTrackPlaceInvalidHeights = _param1 != 0; diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 4b4a1f953d..6662f1bea7 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -153,7 +153,7 @@ void scenario_begin() award_reset(); reset_all_ride_build_dates(); date_reset(); - duck_remove_all(); + Duck::RemoveAll(); park_calculate_size(); map_count_remaining_land_rights(); Staff::ResetStats(); @@ -478,7 +478,7 @@ bool scenario_create_ducks() CoordsXY targetPos{ centrePos.x + innerPos.x - SquareRadiusSize, centrePos.y + innerPos.y - SquareRadiusSize }; Guard::Assert(map_is_location_valid(targetPos)); - create_duck(targetPos); + Duck::Create(targetPos); } return true; diff --git a/src/openrct2/world/Duck.cpp b/src/openrct2/world/Duck.cpp index 6fe88bc38a..e6cf1a282f 100644 --- a/src/openrct2/world/Duck.cpp +++ b/src/openrct2/world/Duck.cpp @@ -279,7 +279,7 @@ uint32_t Duck::GetFrameImage(int32_t direction) const return imageId; } -void create_duck(const CoordsXY& pos) +void Duck::Create(const CoordsXY& pos) { auto* duck = CreateEntity(); if (duck == nullptr) @@ -340,12 +340,12 @@ void Duck::Update() } } -void duck_press(Duck* duck) +void Duck::Press() { - OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Quack, { duck->x, duck->y, duck->z }); + OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Quack, { x, y, z }); } -void duck_remove_all() +void Duck::RemoveAll() { for (auto duck : EntityList()) { diff --git a/src/openrct2/world/Duck.h b/src/openrct2/world/Duck.h index c6bfe66b78..feef90e15e 100644 --- a/src/openrct2/world/Duck.h +++ b/src/openrct2/world/Duck.h @@ -29,6 +29,9 @@ struct Duck : MiscEntity int16_t target_y; DuckState state; + static void Create(const CoordsXY& pos); + static void RemoveAll(); + void Press(); void Update(); uint32_t GetFrameImage(int32_t direction) const; bool IsFlying(); @@ -42,7 +45,3 @@ private: void UpdateDoubleDrink(); void UpdateFlyAway(); }; - -void create_duck(const CoordsXY& pos); -void duck_press(Duck* duck); -void duck_remove_all();