From 3a37be9d277058fc9ed6d90bef9fd12c57823d19 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 12 Mar 2020 15:06:01 -0700 Subject: [PATCH] Minor CFlaahgra fixes --- Runtime/MP1/World/CFlaahgra.cpp | 11 ++++++--- Runtime/MP1/World/CFlaahgra.hpp | 44 ++++++++++++++++----------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Runtime/MP1/World/CFlaahgra.cpp b/Runtime/MP1/World/CFlaahgra.cpp index f99d1c7c8..1ca620638 100644 --- a/Runtime/MP1/World/CFlaahgra.cpp +++ b/Runtime/MP1/World/CFlaahgra.cpp @@ -895,8 +895,8 @@ void CFlaahgra::Faint(CStateManager& mgr, EStateMsg msg, float arg) { x7d4_ += arg; if (x7d4_ >= x56c_.xc_) x568_ = 4; - else - x450_bodyController->FaceDirection(x894_, arg); + } else { + x450_bodyController->FaceDirection(x894_, arg); } } } else if (msg == EStateMsg::Deactivate) { @@ -1186,13 +1186,16 @@ TUniqueId CFlaahgra::GetMirrorNearestPlayer(const CStateManager& mgr) const { zeus::CVector3f playerPos = mgr.GetPlayer().GetTranslation(); TUniqueId nearId = kInvalidUniqueId; + float prevMag = -1.f; for (TUniqueId id : x770_mirrorWaypoints) { if (TCastToConstPtr wp = mgr.GetObjectById(id)) { if (!wp->GetActive()) continue; - - if ((wp->GetTranslation() - playerPos).magSquared() > -1.f) + const float mag = (wp->GetTranslation() - playerPos).magSquared(); + if (mag > prevMag) { nearId = id; + prevMag = mag; + } } } diff --git a/Runtime/MP1/World/CFlaahgra.hpp b/Runtime/MP1/World/CFlaahgra.hpp index 140cb60db..37c95062c 100644 --- a/Runtime/MP1/World/CFlaahgra.hpp +++ b/Runtime/MP1/World/CFlaahgra.hpp @@ -22,7 +22,7 @@ class CCollisionActorManager; class CDependencyGroup; class CElementGen; class CGenDescription; -} +} // namespace urde namespace urde::MP1 { class CFlaahgraData { @@ -44,6 +44,7 @@ class CFlaahgraData { float x148_; CAnimationParameters x14c_animationParameters; CAssetId x158_; + public: static constexpr u32 GetNumProperties() { return 23; } CFlaahgraData(CInputStream&); @@ -53,6 +54,7 @@ public: class CFlaahgraRenderer : public CActor { TUniqueId xe8_owner; + public: CFlaahgraRenderer(TUniqueId, TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&); @@ -69,6 +71,7 @@ class CFlaahgraPlants : public CActor { float x12c_lastDt = 0.f; zeus::COBBox x130_obbox; TUniqueId x16c_colAct = kInvalidUniqueId; + public: CFlaahgraPlants(const TToken&, const CActorParameters&, TUniqueId, TAreaId, TUniqueId, const zeus::CTransform&, const CDamageInfo&, const zeus::CVector3f&); @@ -137,26 +140,21 @@ class CFlaahgra : public CPatterned { CAnimRes x8ac_; std::optional> x8c8_depGroup; std::vector x8d4_tokens; - union { - struct { - bool x8e4_24_loaded : 1; - bool x8e4_25_loading : 1; - bool x8e4_26_ : 1; - bool x8e4_27_ : 1; - bool x8e4_28_ : 1; - bool x8e4_29_getup : 1; - bool x8e4_30_ : 1; - bool x8e4_31_ : 1; - bool x8e5_24_ : 1; - bool x8e5_25_ : 1; - bool x8e5_26_ : 1; - bool x8e5_27_ : 1; - bool x8e5_28_ : 1; - bool x8e5_29_ : 1; - bool x8e5_30_ : 1; - }; - u32 _dummy = 0; - }; + bool x8e4_24_loaded : 1; + bool x8e4_25_loading : 1; + bool x8e4_26_ : 1; + bool x8e4_27_ : 1; + bool x8e4_28_ : 1; + bool x8e4_29_getup : 1; + bool x8e4_30_ : 1; + bool x8e4_31_ : 1; + bool x8e5_24_ : 1; + bool x8e5_25_ : 1; + bool x8e5_26_ : 1; + bool x8e5_27_ : 1; + bool x8e5_28_ : 1; + bool x8e5_29_ : 1; + bool x8e5_30_ : 1; void LoadDependencies(CAssetId); void ResetModelDataAndBodyController(); @@ -192,6 +190,7 @@ class CFlaahgra : public CPatterned { zeus::CVector3f sub801ae754(const CStateManager&) const; TUniqueId GetMirrorNearestPlayer(const CStateManager&) const; + public: DEFINE_PATTERNED(Flaahgra); CFlaahgra(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, const CAnimRes&, @@ -235,6 +234,5 @@ public: void Cover(CStateManager&, EStateMsg, float) override; void SpecialAttack(CStateManager&, EStateMsg, float) override; void Enraged(CStateManager&, EStateMsg, float) override; - }; -} \ No newline at end of file +} // namespace urde::MP1 \ No newline at end of file