From 153004faee48fb9a12d0a696339fdb932d89a613 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:33:05 -0400 Subject: [PATCH] Runtime/MP1/World: Replace bitfield unions with constructor initializers --- Runtime/MP1/World/CBabygoth.cpp | 17 ++++- Runtime/MP1/World/CBabygoth.hpp | 33 ++++----- Runtime/MP1/World/CBeetle.cpp | 13 ++-- Runtime/MP1/World/CBeetle.hpp | 11 +-- Runtime/MP1/World/CMetroid.cpp | 3 +- Runtime/MP1/World/CMetroid.hpp | 7 +- Runtime/MP1/World/CMetroidBeta.cpp | 10 ++- Runtime/MP1/World/CMetroidBeta.hpp | 21 +++--- Runtime/MP1/World/CParasite.cpp | 17 +++-- Runtime/MP1/World/CParasite.hpp | 30 ++++----- Runtime/MP1/World/CSpacePirate.cpp | 2 + Runtime/MP1/World/CSpacePirate.hpp | 103 ++++++++++++++--------------- Runtime/MP1/World/CWarWasp.cpp | 12 +++- Runtime/MP1/World/CWarWasp.hpp | 22 +++--- 14 files changed, 154 insertions(+), 147 deletions(-) diff --git a/Runtime/MP1/World/CBabygoth.cpp b/Runtime/MP1/World/CBabygoth.cpp index 1a831d151..775fa57ee 100644 --- a/Runtime/MP1/World/CBabygoth.cpp +++ b/Runtime/MP1/World/CBabygoth.cpp @@ -69,7 +69,21 @@ CBabygoth::CBabygoth(TUniqueId uid, std::string_view name, const CEntityInfo& in g_SimplePool->GetObj({SBIG('WPSC'), babyData.x44_fireBreathWeapon}) : g_SimplePool->GetObj("FlameThrower"sv)) , x98c_dVuln(pInfo.GetDamageVulnerability()) -, xa00_shellHitPoints(babyData.GetShellHitPoints()) { +, xa00_shellHitPoints(babyData.GetShellHitPoints()) +, xa48_24_isAlert(false) +, xa48_25_(false) +, xa48_26_inProjectileAttack(false) +, xa48_27_(false) +, xa48_28_pendingAttackContactDamage(false) +, xa48_29_hasBeenEnraged(false) +, xa48_30_heardPlayerFire(false) +, xa48_31_approachNeedsPathSearch(true) +, xa49_24_gettingUp(false) +, xa49_25_shouldStepBackwards(false) +, xa49_26_readyForTeam(false) +, xa49_27_locomotionValid(false) +, xa49_28_onApproachPath(false) +, xa49_29_objectSpaceCollision(false) { TLockedToken model = g_SimplePool->GetObj({SBIG('CMDL'), babyData.x138_noShellModel}); TLockedToken skin = g_SimplePool->GetObj({SBIG('CSKR'), babyData.x13c_noShellSkin}); xa08_noShellModel = @@ -80,7 +94,6 @@ CBabygoth::CBabygoth(TUniqueId uid, std::string_view name, const CEntityInfo& in xa2c_destroyShellParticle = g_SimplePool->GetObj({SBIG('PART'), babyData.x154_destroyShellParticle}); if (x570_babyData.x148_intermediateCrackParticle.IsValid()) xa38_intermediateCrackParticle = g_SimplePool->GetObj({SBIG('PART'), babyData.x148_intermediateCrackParticle}); - xa48_31_approachNeedsPathSearch = true; x958_iceProjectile.Token().Lock(); UpdateTouchBounds(); x460_knockBackController.SetEnableFreeze(false); diff --git a/Runtime/MP1/World/CBabygoth.hpp b/Runtime/MP1/World/CBabygoth.hpp index 706f0be2e..a39674db2 100644 --- a/Runtime/MP1/World/CBabygoth.hpp +++ b/Runtime/MP1/World/CBabygoth.hpp @@ -100,25 +100,20 @@ private: TToken xa20_crackTwoParticle; TToken xa2c_destroyShellParticle; TLockedToken xa38_intermediateCrackParticle; // Used to be an optional, not necessary in URDE - union { - struct { - bool xa48_24_isAlert : 1; - bool xa48_25_ : 1; - bool xa48_26_inProjectileAttack : 1; - bool xa48_27_ : 1; - bool xa48_28_pendingAttackContactDamage : 1; - bool xa48_29_hasBeenEnraged : 1; - bool xa48_30_heardPlayerFire : 1; - bool xa48_31_approachNeedsPathSearch : 1; - bool xa49_24_gettingUp : 1; - bool xa49_25_shouldStepBackwards : 1; - bool xa49_26_readyForTeam : 1; - bool xa49_27_locomotionValid : 1; - bool xa49_28_onApproachPath : 1; - bool xa49_29_objectSpaceCollision : 1; - }; - u32 _dummy = 0; - }; + bool xa48_24_isAlert : 1; + bool xa48_25_ : 1; + bool xa48_26_inProjectileAttack : 1; + bool xa48_27_ : 1; + bool xa48_28_pendingAttackContactDamage : 1; + bool xa48_29_hasBeenEnraged : 1; + bool xa48_30_heardPlayerFire : 1; + bool xa48_31_approachNeedsPathSearch : 1; + bool xa49_24_gettingUp : 1; + bool xa49_25_shouldStepBackwards : 1; + bool xa49_26_readyForTeam : 1; + bool xa49_27_locomotionValid : 1; + bool xa49_28_onApproachPath : 1; + bool xa49_29_objectSpaceCollision : 1; void AddSphereCollisionList(const SSphereJointInfo*, s32, std::vector&); diff --git a/Runtime/MP1/World/CBeetle.cpp b/Runtime/MP1/World/CBeetle.cpp index 85764d1e0..2f94a2614 100644 --- a/Runtime/MP1/World/CBeetle.cpp +++ b/Runtime/MP1/World/CBeetle.cpp @@ -18,22 +18,23 @@ CBeetle::CBeetle(TUniqueId uid, std::string_view name, const CEntityInfo& info, CModelData&& mData, const CPatternedInfo& pInfo, CPatterned::EFlavorType flavor, CBeetle::EEntranceType entranceType, const CDamageInfo& touchDamage, const CDamageVulnerability& platingVuln, const zeus::CVector3f& tailAimReference, - float initialAttackDelay, float retreatTime, float f3, - const CDamageVulnerability& tailVuln, const CActorParameters& aParams, - const std::optional& tailModel) + float initialAttackDelay, float retreatTime, float f3, const CDamageVulnerability& tailVuln, + const CActorParameters& aParams, const std::optional& tailModel) : CPatterned(ECharacter::Beetle, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Ground, EColliderType::One, EBodyType::BiPedal, aParams, EKnockBackVariant(flavor)) , x56c_entranceType(entranceType) , x574_tailAimReference(tailAimReference) , x580_f3(f3) , x584_touchDamage(touchDamage) -, x5ac_tailModel(tailModel ? std::optional(CModelData(*tailModel)) : - std::optional()) +, x5ac_tailModel(tailModel ? std::optional(CModelData(*tailModel)) : std::nullopt) , x5fc_pathFindSearch(nullptr, 1, pInfo.GetPathfindingIndex(), 1.f, 1.f) , x744_platingVuln(platingVuln) , x7ac_tailVuln(tailVuln) , x814_attackDelayTimer(initialAttackDelay) -, x834_retreatTime(retreatTime) { +, x834_retreatTime(retreatTime) +, x838_24_hitSomething(false) +, x838_25_burrowing(false) +, x838_26_canSkid(false) { x5a0_headbuttDist = GetAnimationDistance(CPASAnimParmData(7, CPASAnimParm::FromEnum(0), CPASAnimParm::FromEnum(1))); x5a4_jumpBackwardDist = x64_modelData->GetScale().y() * diff --git a/Runtime/MP1/World/CBeetle.hpp b/Runtime/MP1/World/CBeetle.hpp index 3e396b02e..a810c5a6f 100644 --- a/Runtime/MP1/World/CBeetle.hpp +++ b/Runtime/MP1/World/CBeetle.hpp @@ -38,14 +38,9 @@ private: zeus::CVector3f x824_predictPos; float x830_intoGroundFactor = 1.f; float x834_retreatTime; - union { - struct { - bool x838_24_hitSomething : 1; - bool x838_25_burrowing : 1; - bool x838_26_canSkid : 1; - }; - u32 _dummy3 = 0; - }; + bool x838_24_hitSomething : 1; + bool x838_25_burrowing : 1; + bool x838_26_canSkid : 1; void SquadAdd(CStateManager& mgr); void SquadRemove(CStateManager& mgr); diff --git a/Runtime/MP1/World/CMetroid.cpp b/Runtime/MP1/World/CMetroid.cpp index 8adbdbff1..0361fa327 100644 --- a/Runtime/MP1/World/CMetroid.cpp +++ b/Runtime/MP1/World/CMetroid.cpp @@ -23,6 +23,7 @@ CMetroid::CMetroid(TUniqueId uid, std::string_view name, EFlavorType flavor, con const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& aParms, const CMetroidData& metroidData, TUniqueId) : CPatterned(ECharacter::Metroid, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer, - EColliderType::One, EBodyType::Flyer, aParms, EKnockBackVariant::Medium) {} + EColliderType::One, EBodyType::Flyer, aParms, EKnockBackVariant::Medium) +, x9bf_29_(false) {} } // namespace urde::MP1 diff --git a/Runtime/MP1/World/CMetroid.hpp b/Runtime/MP1/World/CMetroid.hpp index 1a547f75c..14c4d5b25 100644 --- a/Runtime/MP1/World/CMetroid.hpp +++ b/Runtime/MP1/World/CMetroid.hpp @@ -30,12 +30,7 @@ public: }; class CMetroid : public CPatterned { - union { - struct { - bool x9bf_29_ : 1; - }; - u32 _dummy = 0; - }; + bool x9bf_29_ : 1; public: DEFINE_PATTERNED(Metroid) diff --git a/Runtime/MP1/World/CMetroidBeta.cpp b/Runtime/MP1/World/CMetroidBeta.cpp index fac634659..6750f6006 100644 --- a/Runtime/MP1/World/CMetroidBeta.cpp +++ b/Runtime/MP1/World/CMetroidBeta.cpp @@ -56,7 +56,15 @@ CMetroidBeta::CMetroidBeta(TUniqueId uid, std::string_view name, const CEntityIn , x824_(std::make_unique(x7f0_, 0)) , x828_(std::make_unique(x7fc_)) , x82c_(std::make_unique(x808_)) -, x830_(std::make_unique(x814_)) { +, x830_(std::make_unique(x814_)) +, x840_24_(false) +, x840_25_(false) +, x840_26_(false) +, x840_27_(false) +, x840_28_(false) +, x840_29_(false) +, x840_30_(false) +, x840_31_(false) { x820_->SetParticleEmission(false); x828_->SetParticleEmission(false); x82c_->SetParticleEmission(false); diff --git a/Runtime/MP1/World/CMetroidBeta.hpp b/Runtime/MP1/World/CMetroidBeta.hpp index 5c421dcf6..0c4400203 100644 --- a/Runtime/MP1/World/CMetroidBeta.hpp +++ b/Runtime/MP1/World/CMetroidBeta.hpp @@ -75,19 +75,14 @@ class CMetroidBeta : public CPatterned { float x834_ = 0.f; CRandom16 x838_ = CRandom16(1469); float x83c_; - union { - struct { - bool x840_24_ : 1; - bool x840_25_ : 1; - bool x840_26_ : 1; - bool x840_27_ : 1; - bool x840_28_ : 1; - bool x840_29_ : 1; - bool x840_30_ : 1; - bool x840_31_ : 1; - }; - u32 _dummy = 0; - }; + bool x840_24_ : 1; + bool x840_25_ : 1; + bool x840_26_ : 1; + bool x840_27_ : 1; + bool x840_28_ : 1; + bool x840_29_ : 1; + bool x840_30_ : 1; + bool x840_31_ : 1; void CreateCollisionActorManager(CStateManager& mgr); void AddSphereJoints(SSphereJointInfo* sphereJoints, s32 count, std::vector& joints); diff --git a/Runtime/MP1/World/CParasite.cpp b/Runtime/MP1/World/CParasite.cpp index 07fb97d61..e21fed1f5 100644 --- a/Runtime/MP1/World/CParasite.cpp +++ b/Runtime/MP1/World/CParasite.cpp @@ -58,10 +58,19 @@ CParasite::CParasite(TUniqueId uid, std::string_view name, EFlavorType flavor, c , x714_iceZoomerJointHP(iceZoomerJointHP) , x73c_haltSfx(CSfxManager::TranslateSFXID(haltSfx)) , x73e_getUpSfx(CSfxManager::TranslateSFXID(getUpSfx)) -, x740_crouchSfx(CSfxManager::TranslateSFXID(crouchSfx)) { - x742_28_onGround = true; - x742_30_attackOver = true; - +, x740_crouchSfx(CSfxManager::TranslateSFXID(crouchSfx)) +, x742_24_receivedTelegraph(false) +, x742_25_jumpVelDirty(false) +, x742_26_(false) +, x742_27_landed(false) +, x742_28_onGround(true) +, x742_29_(false) +, x742_30_attackOver(true) +, x742_31_(false) +, x743_24_halted(false) +, x743_25_vulnerable(false) +, x743_26_oculusShotAt(false) +, x743_27_inJump(false) { switch (x5d0_walkerType) { case EWalkerType::Geemer: x460_knockBackController.SetEnableFreeze(false); diff --git a/Runtime/MP1/World/CParasite.hpp b/Runtime/MP1/World/CParasite.hpp index 1e673d124..69b07dc15 100644 --- a/Runtime/MP1/World/CParasite.hpp +++ b/Runtime/MP1/World/CParasite.hpp @@ -70,23 +70,19 @@ class CParasite : public CWallWalker { u16 x73c_haltSfx; u16 x73e_getUpSfx; u16 x740_crouchSfx; - union { - struct { - bool x742_24_receivedTelegraph : 1; - bool x742_25_jumpVelDirty : 1; - bool x742_26_ : 1; - bool x742_27_landed : 1; - bool x742_28_onGround : 1; - bool x742_29_ : 1; - bool x742_30_attackOver : 1; - bool x742_31_ : 1; - bool x743_24_halted : 1; - bool x743_25_vulnerable : 1; - bool x743_26_oculusShotAt : 1; - bool x743_27_inJump : 1; - }; - u16 _dummy = 0; - }; + bool x742_24_receivedTelegraph : 1; + bool x742_25_jumpVelDirty : 1; + bool x742_26_ : 1; + bool x742_27_landed : 1; + bool x742_28_onGround : 1; + bool x742_29_ : 1; + bool x742_30_attackOver : 1; + bool x742_31_ : 1; + bool x743_24_halted : 1; + bool x743_25_vulnerable : 1; + bool x743_26_oculusShotAt : 1; + bool x743_27_inJump : 1; + bool CloseToWall(const CStateManager& mgr) const; void FaceTarget(const zeus::CVector3f& target); TUniqueId RecursiveFindClosestWayPoint(CStateManager& mgr, TUniqueId id, float& dist); diff --git a/Runtime/MP1/World/CSpacePirate.cpp b/Runtime/MP1/World/CSpacePirate.cpp index 409a11e5b..f95beba06 100644 --- a/Runtime/MP1/World/CSpacePirate.cpp +++ b/Runtime/MP1/World/CSpacePirate.cpp @@ -418,6 +418,7 @@ CSpacePirate::CSpacePirate(TUniqueId uid, std::string_view name, const CEntityIn x637_24_enablePatrol = false; x637_25_enableAim = false; x637_26_hearPlayerFire = false; + x637_27_inProjectilePath = false; x637_28_noPlayerLos = false; x637_29_inWallHang = false; x637_30_jumpVelSet = false; @@ -438,6 +439,7 @@ CSpacePirate::CSpacePirate(TUniqueId uid, std::string_view name, const CEntityIn x639_29_enableBreakDodge = false; x639_30_closeMelee = false; x639_31_sentAttackMsg = false; + x63a_24_normalDodge = false; x758_headSeg = x64_modelData->GetAnimationData()->GetLocatorSegId("Head_1"sv); x7b6_gunSeg = x64_modelData->GetAnimationData()->GetLocatorSegId("R_gun_LCTR"sv); diff --git a/Runtime/MP1/World/CSpacePirate.hpp b/Runtime/MP1/World/CSpacePirate.hpp index 0663fd803..89e61b92d 100644 --- a/Runtime/MP1/World/CSpacePirate.hpp +++ b/Runtime/MP1/World/CSpacePirate.hpp @@ -97,61 +97,56 @@ private: }; CSpacePirateData x568_pirateData; - union { - struct { - bool x634_24_pendingAmbush : 1; - bool x634_25_ceilingAmbush : 1; - bool x634_26_nonAggressive : 1; - bool x634_27_melee : 1; - bool x634_28_noShuffleCloseCheck : 1; - bool x634_29_onlyAttackInRange : 1; - bool x634_30_ : 1; - bool x634_31_noKnockbackImpulseReset : 1; - bool x635_24_noMeleeAttack : 1; - bool x635_25_breakAttack : 1; - bool x635_26_seated : 1; - bool x635_27_shadowPirate : 1; - bool x635_28_alertBeforeCloak : 1; - bool x635_29_noBreakDodge : 1; - bool x635_30_floatingCorpse : 1; - bool x635_31_ragdollNoAiCollision : 1; - bool x636_24_trooper : 1; - bool x636_25_hearNoise : 1; - bool x636_26_enableMeleeAttack : 1; - bool x636_27_ : 1; - bool x636_28_ : 1; - bool x636_29_enableRetreat : 1; - bool x636_30_shuffleClose : 1; - bool x636_31_inAttackState : 1; - bool x637_24_enablePatrol : 1; - bool x637_25_enableAim : 1; - bool x637_26_hearPlayerFire : 1; - bool x637_27_inProjectilePath : 1; - bool x637_28_noPlayerLos : 1; - bool x637_29_inWallHang : 1; - bool x637_30_jumpVelSet : 1; - bool x637_31_prevInCineCam : 1; - bool x638_24_pendingFrenzyChance : 1; - bool x638_25_appliedBladeDamage : 1; - bool x638_26_alwaysAggressive : 1; - bool x638_27_coverCheck : 1; - bool x638_28_enableDodge : 1; - bool x638_29_noPlayerDodge : 1; - bool x638_30_ragdollOver : 1; - bool x638_31_mayStartAttack : 1; - bool x639_24_ : 1; - bool x639_25_useJumpBackJump : 1; - bool x639_26_started : 1; - bool x639_27_inRange : 1; - bool x639_28_satUp : 1; - bool x639_29_enableBreakDodge : 1; - bool x639_30_closeMelee : 1; - bool x639_31_sentAttackMsg : 1; - bool x63a_24_normalDodge : 1; - }; - u64 _dummy = 0; - }; + bool x634_24_pendingAmbush : 1; + bool x634_25_ceilingAmbush : 1; + bool x634_26_nonAggressive : 1; + bool x634_27_melee : 1; + bool x634_28_noShuffleCloseCheck : 1; + bool x634_29_onlyAttackInRange : 1; + bool x634_30_ : 1; + bool x634_31_noKnockbackImpulseReset : 1; + bool x635_24_noMeleeAttack : 1; + bool x635_25_breakAttack : 1; + bool x635_26_seated : 1; + bool x635_27_shadowPirate : 1; + bool x635_28_alertBeforeCloak : 1; + bool x635_29_noBreakDodge : 1; + bool x635_30_floatingCorpse : 1; + bool x635_31_ragdollNoAiCollision : 1; + bool x636_24_trooper : 1; + bool x636_25_hearNoise : 1; + bool x636_26_enableMeleeAttack : 1; + bool x636_27_ : 1; + bool x636_28_ : 1; + bool x636_29_enableRetreat : 1; + bool x636_30_shuffleClose : 1; + bool x636_31_inAttackState : 1; + bool x637_24_enablePatrol : 1; + bool x637_25_enableAim : 1; + bool x637_26_hearPlayerFire : 1; + bool x637_27_inProjectilePath : 1; + bool x637_28_noPlayerLos : 1; + bool x637_29_inWallHang : 1; + bool x637_30_jumpVelSet : 1; + bool x637_31_prevInCineCam : 1; + bool x638_24_pendingFrenzyChance : 1; + bool x638_25_appliedBladeDamage : 1; + bool x638_26_alwaysAggressive : 1; + bool x638_27_coverCheck : 1; + bool x638_28_enableDodge : 1; + bool x638_29_noPlayerDodge : 1; + bool x638_30_ragdollOver : 1; + bool x638_31_mayStartAttack : 1; + bool x639_24_ : 1; + bool x639_25_useJumpBackJump : 1; + bool x639_26_started : 1; + bool x639_27_inRange : 1; + bool x639_28_satUp : 1; + bool x639_29_enableBreakDodge : 1; + bool x639_30_closeMelee : 1; + bool x639_31_sentAttackMsg : 1; + bool x63a_24_normalDodge : 1; s32 x63c_frenzyFrames = 0; TUniqueId x640_coverPoint = kInvalidUniqueId; diff --git a/Runtime/MP1/World/CWarWasp.cpp b/Runtime/MP1/World/CWarWasp.cpp index 69da69330..0f5002574 100644 --- a/Runtime/MP1/World/CWarWasp.cpp +++ b/Runtime/MP1/World/CWarWasp.cpp @@ -24,9 +24,15 @@ CWarWasp::CWarWasp(TUniqueId uid, std::string_view name, const CEntityInfo& info , x590_pfSearch(nullptr, 0x3, pInfo.GetPathfindingIndex(), 1.f, 1.f) , x684_(dInfo1) , x6d4_projectileInfo(projectileWeapon, projectileDamage) -, x72c_projectileVisorSfx(CSfxManager::TranslateSFXID(projecileVisorSfx)) { - x72e_24_jumpBackRepeat = true; - x72e_26_initiallyInactive = !pInfo.GetActive(); +, x72c_projectileVisorSfx(CSfxManager::TranslateSFXID(projecileVisorSfx)) +, x72e_24_jumpBackRepeat(true) +, x72e_25_canApplyDamage(false) +, x72e_26_initiallyInactive(!pInfo.GetActive()) +, x72e_27_teamMatesMelee(false) +, x72e_28_inProjectileAttack(false) +, x72e_29_pathObstructed(false) +, x72e_30_isRetreating(false) +, x72e_31_heardNoise(false) { x6d4_projectileInfo.Token().Lock(); UpdateTouchBounds(); SetCoefficientOfRestitutionModifier(0.1f); diff --git a/Runtime/MP1/World/CWarWasp.hpp b/Runtime/MP1/World/CWarWasp.hpp index 86cb01aaa..b5b5f84d8 100644 --- a/Runtime/MP1/World/CWarWasp.hpp +++ b/Runtime/MP1/World/CWarWasp.hpp @@ -33,19 +33,15 @@ class CWarWasp : public CPatterned { float x718_circleBurstOffTotemAngle = zeus::degToRad(90.f); TLockedToken x71c_projectileVisorParticle; // Used to be optional u16 x72c_projectileVisorSfx; - union { - struct { - bool x72e_24_jumpBackRepeat : 1; - bool x72e_25_canApplyDamage : 1; - bool x72e_26_initiallyInactive : 1; - bool x72e_27_teamMatesMelee : 1; - bool x72e_28_inProjectileAttack : 1; - bool x72e_29_pathObstructed : 1; - bool x72e_30_isRetreating : 1; - bool x72e_31_heardNoise : 1; - }; - u32 _dummy = 0; - }; + bool x72e_24_jumpBackRepeat : 1; + bool x72e_25_canApplyDamage : 1; + bool x72e_26_initiallyInactive : 1; + bool x72e_27_teamMatesMelee : 1; + bool x72e_28_inProjectileAttack : 1; + bool x72e_29_pathObstructed : 1; + bool x72e_30_isRetreating : 1; + bool x72e_31_heardNoise : 1; + void SwarmAdd(CStateManager& mgr); void SwarmRemove(CStateManager& mgr); void ApplyDamage(CStateManager& mgr);