Runtime/MP1/World: Replace bitfield unions with constructor initializers

This commit is contained in:
Luke Street 2020-04-10 15:33:05 -04:00
parent 402e45ecb5
commit 153004faee
14 changed files with 154 additions and 147 deletions

View File

@ -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({SBIG('WPSC'), babyData.x44_fireBreathWeapon})
: g_SimplePool->GetObj("FlameThrower"sv)) : g_SimplePool->GetObj("FlameThrower"sv))
, x98c_dVuln(pInfo.GetDamageVulnerability()) , 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<CModel> model = g_SimplePool->GetObj({SBIG('CMDL'), babyData.x138_noShellModel}); TLockedToken<CModel> model = g_SimplePool->GetObj({SBIG('CMDL'), babyData.x138_noShellModel});
TLockedToken<CSkinRules> skin = g_SimplePool->GetObj({SBIG('CSKR'), babyData.x13c_noShellSkin}); TLockedToken<CSkinRules> skin = g_SimplePool->GetObj({SBIG('CSKR'), babyData.x13c_noShellSkin});
xa08_noShellModel = 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}); xa2c_destroyShellParticle = g_SimplePool->GetObj({SBIG('PART'), babyData.x154_destroyShellParticle});
if (x570_babyData.x148_intermediateCrackParticle.IsValid()) if (x570_babyData.x148_intermediateCrackParticle.IsValid())
xa38_intermediateCrackParticle = g_SimplePool->GetObj({SBIG('PART'), babyData.x148_intermediateCrackParticle}); xa38_intermediateCrackParticle = g_SimplePool->GetObj({SBIG('PART'), babyData.x148_intermediateCrackParticle});
xa48_31_approachNeedsPathSearch = true;
x958_iceProjectile.Token().Lock(); x958_iceProjectile.Token().Lock();
UpdateTouchBounds(); UpdateTouchBounds();
x460_knockBackController.SetEnableFreeze(false); x460_knockBackController.SetEnableFreeze(false);

View File

@ -100,8 +100,6 @@ private:
TToken<CGenDescription> xa20_crackTwoParticle; TToken<CGenDescription> xa20_crackTwoParticle;
TToken<CGenDescription> xa2c_destroyShellParticle; TToken<CGenDescription> xa2c_destroyShellParticle;
TLockedToken<CGenDescription> xa38_intermediateCrackParticle; // Used to be an optional, not necessary in URDE TLockedToken<CGenDescription> xa38_intermediateCrackParticle; // Used to be an optional, not necessary in URDE
union {
struct {
bool xa48_24_isAlert : 1; bool xa48_24_isAlert : 1;
bool xa48_25_ : 1; bool xa48_25_ : 1;
bool xa48_26_inProjectileAttack : 1; bool xa48_26_inProjectileAttack : 1;
@ -116,9 +114,6 @@ private:
bool xa49_27_locomotionValid : 1; bool xa49_27_locomotionValid : 1;
bool xa49_28_onApproachPath : 1; bool xa49_28_onApproachPath : 1;
bool xa49_29_objectSpaceCollision : 1; bool xa49_29_objectSpaceCollision : 1;
};
u32 _dummy = 0;
};
void AddSphereCollisionList(const SSphereJointInfo*, s32, std::vector<CJointCollisionDescription>&); void AddSphereCollisionList(const SSphereJointInfo*, s32, std::vector<CJointCollisionDescription>&);

View File

@ -18,22 +18,23 @@ CBeetle::CBeetle(TUniqueId uid, std::string_view name, const CEntityInfo& info,
CModelData&& mData, const CPatternedInfo& pInfo, CPatterned::EFlavorType flavor, CModelData&& mData, const CPatternedInfo& pInfo, CPatterned::EFlavorType flavor,
CBeetle::EEntranceType entranceType, const CDamageInfo& touchDamage, CBeetle::EEntranceType entranceType, const CDamageInfo& touchDamage,
const CDamageVulnerability& platingVuln, const zeus::CVector3f& tailAimReference, const CDamageVulnerability& platingVuln, const zeus::CVector3f& tailAimReference,
float initialAttackDelay, float retreatTime, float f3, float initialAttackDelay, float retreatTime, float f3, const CDamageVulnerability& tailVuln,
const CDamageVulnerability& tailVuln, const CActorParameters& aParams, const CActorParameters& aParams, const std::optional<CStaticRes>& tailModel)
const std::optional<CStaticRes>& tailModel)
: CPatterned(ECharacter::Beetle, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Ground, : CPatterned(ECharacter::Beetle, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Ground,
EColliderType::One, EBodyType::BiPedal, aParams, EKnockBackVariant(flavor)) EColliderType::One, EBodyType::BiPedal, aParams, EKnockBackVariant(flavor))
, x56c_entranceType(entranceType) , x56c_entranceType(entranceType)
, x574_tailAimReference(tailAimReference) , x574_tailAimReference(tailAimReference)
, x580_f3(f3) , x580_f3(f3)
, x584_touchDamage(touchDamage) , x584_touchDamage(touchDamage)
, x5ac_tailModel(tailModel ? std::optional<CModelData>(CModelData(*tailModel)) : , x5ac_tailModel(tailModel ? std::optional<CModelData>(CModelData(*tailModel)) : std::nullopt)
std::optional<CModelData>())
, x5fc_pathFindSearch(nullptr, 1, pInfo.GetPathfindingIndex(), 1.f, 1.f) , x5fc_pathFindSearch(nullptr, 1, pInfo.GetPathfindingIndex(), 1.f, 1.f)
, x744_platingVuln(platingVuln) , x744_platingVuln(platingVuln)
, x7ac_tailVuln(tailVuln) , x7ac_tailVuln(tailVuln)
, x814_attackDelayTimer(initialAttackDelay) , 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))); x5a0_headbuttDist = GetAnimationDistance(CPASAnimParmData(7, CPASAnimParm::FromEnum(0), CPASAnimParm::FromEnum(1)));
x5a4_jumpBackwardDist = x5a4_jumpBackwardDist =
x64_modelData->GetScale().y() * x64_modelData->GetScale().y() *

View File

@ -38,14 +38,9 @@ private:
zeus::CVector3f x824_predictPos; zeus::CVector3f x824_predictPos;
float x830_intoGroundFactor = 1.f; float x830_intoGroundFactor = 1.f;
float x834_retreatTime; float x834_retreatTime;
union {
struct {
bool x838_24_hitSomething : 1; bool x838_24_hitSomething : 1;
bool x838_25_burrowing : 1; bool x838_25_burrowing : 1;
bool x838_26_canSkid : 1; bool x838_26_canSkid : 1;
};
u32 _dummy3 = 0;
};
void SquadAdd(CStateManager& mgr); void SquadAdd(CStateManager& mgr);
void SquadRemove(CStateManager& mgr); void SquadRemove(CStateManager& mgr);

View File

@ -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 zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
const CActorParameters& aParms, const CMetroidData& metroidData, TUniqueId) const CActorParameters& aParms, const CMetroidData& metroidData, TUniqueId)
: CPatterned(ECharacter::Metroid, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer, : 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 } // namespace urde::MP1

View File

@ -30,12 +30,7 @@ public:
}; };
class CMetroid : public CPatterned { class CMetroid : public CPatterned {
union {
struct {
bool x9bf_29_ : 1; bool x9bf_29_ : 1;
};
u32 _dummy = 0;
};
public: public:
DEFINE_PATTERNED(Metroid) DEFINE_PATTERNED(Metroid)

View File

@ -56,7 +56,15 @@ CMetroidBeta::CMetroidBeta(TUniqueId uid, std::string_view name, const CEntityIn
, x824_(std::make_unique<CParticleSwoosh>(x7f0_, 0)) , x824_(std::make_unique<CParticleSwoosh>(x7f0_, 0))
, x828_(std::make_unique<CElementGen>(x7fc_)) , x828_(std::make_unique<CElementGen>(x7fc_))
, x82c_(std::make_unique<CElementGen>(x808_)) , x82c_(std::make_unique<CElementGen>(x808_))
, x830_(std::make_unique<CElementGen>(x814_)) { , x830_(std::make_unique<CElementGen>(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); x820_->SetParticleEmission(false);
x828_->SetParticleEmission(false); x828_->SetParticleEmission(false);
x82c_->SetParticleEmission(false); x82c_->SetParticleEmission(false);

View File

@ -75,8 +75,6 @@ class CMetroidBeta : public CPatterned {
float x834_ = 0.f; float x834_ = 0.f;
CRandom16 x838_ = CRandom16(1469); CRandom16 x838_ = CRandom16(1469);
float x83c_; float x83c_;
union {
struct {
bool x840_24_ : 1; bool x840_24_ : 1;
bool x840_25_ : 1; bool x840_25_ : 1;
bool x840_26_ : 1; bool x840_26_ : 1;
@ -85,9 +83,6 @@ class CMetroidBeta : public CPatterned {
bool x840_29_ : 1; bool x840_29_ : 1;
bool x840_30_ : 1; bool x840_30_ : 1;
bool x840_31_ : 1; bool x840_31_ : 1;
};
u32 _dummy = 0;
};
void CreateCollisionActorManager(CStateManager& mgr); void CreateCollisionActorManager(CStateManager& mgr);
void AddSphereJoints(SSphereJointInfo* sphereJoints, s32 count, std::vector<CJointCollisionDescription>& joints); void AddSphereJoints(SSphereJointInfo* sphereJoints, s32 count, std::vector<CJointCollisionDescription>& joints);

View File

@ -58,10 +58,19 @@ CParasite::CParasite(TUniqueId uid, std::string_view name, EFlavorType flavor, c
, x714_iceZoomerJointHP(iceZoomerJointHP) , x714_iceZoomerJointHP(iceZoomerJointHP)
, x73c_haltSfx(CSfxManager::TranslateSFXID(haltSfx)) , x73c_haltSfx(CSfxManager::TranslateSFXID(haltSfx))
, x73e_getUpSfx(CSfxManager::TranslateSFXID(getUpSfx)) , x73e_getUpSfx(CSfxManager::TranslateSFXID(getUpSfx))
, x740_crouchSfx(CSfxManager::TranslateSFXID(crouchSfx)) { , x740_crouchSfx(CSfxManager::TranslateSFXID(crouchSfx))
x742_28_onGround = true; , x742_24_receivedTelegraph(false)
x742_30_attackOver = true; , 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) { switch (x5d0_walkerType) {
case EWalkerType::Geemer: case EWalkerType::Geemer:
x460_knockBackController.SetEnableFreeze(false); x460_knockBackController.SetEnableFreeze(false);

View File

@ -70,8 +70,6 @@ class CParasite : public CWallWalker {
u16 x73c_haltSfx; u16 x73c_haltSfx;
u16 x73e_getUpSfx; u16 x73e_getUpSfx;
u16 x740_crouchSfx; u16 x740_crouchSfx;
union {
struct {
bool x742_24_receivedTelegraph : 1; bool x742_24_receivedTelegraph : 1;
bool x742_25_jumpVelDirty : 1; bool x742_25_jumpVelDirty : 1;
bool x742_26_ : 1; bool x742_26_ : 1;
@ -84,9 +82,7 @@ class CParasite : public CWallWalker {
bool x743_25_vulnerable : 1; bool x743_25_vulnerable : 1;
bool x743_26_oculusShotAt : 1; bool x743_26_oculusShotAt : 1;
bool x743_27_inJump : 1; bool x743_27_inJump : 1;
};
u16 _dummy = 0;
};
bool CloseToWall(const CStateManager& mgr) const; bool CloseToWall(const CStateManager& mgr) const;
void FaceTarget(const zeus::CVector3f& target); void FaceTarget(const zeus::CVector3f& target);
TUniqueId RecursiveFindClosestWayPoint(CStateManager& mgr, TUniqueId id, float& dist); TUniqueId RecursiveFindClosestWayPoint(CStateManager& mgr, TUniqueId id, float& dist);

View File

@ -418,6 +418,7 @@ CSpacePirate::CSpacePirate(TUniqueId uid, std::string_view name, const CEntityIn
x637_24_enablePatrol = false; x637_24_enablePatrol = false;
x637_25_enableAim = false; x637_25_enableAim = false;
x637_26_hearPlayerFire = false; x637_26_hearPlayerFire = false;
x637_27_inProjectilePath = false;
x637_28_noPlayerLos = false; x637_28_noPlayerLos = false;
x637_29_inWallHang = false; x637_29_inWallHang = false;
x637_30_jumpVelSet = false; x637_30_jumpVelSet = false;
@ -438,6 +439,7 @@ CSpacePirate::CSpacePirate(TUniqueId uid, std::string_view name, const CEntityIn
x639_29_enableBreakDodge = false; x639_29_enableBreakDodge = false;
x639_30_closeMelee = false; x639_30_closeMelee = false;
x639_31_sentAttackMsg = false; x639_31_sentAttackMsg = false;
x63a_24_normalDodge = false;
x758_headSeg = x64_modelData->GetAnimationData()->GetLocatorSegId("Head_1"sv); x758_headSeg = x64_modelData->GetAnimationData()->GetLocatorSegId("Head_1"sv);
x7b6_gunSeg = x64_modelData->GetAnimationData()->GetLocatorSegId("R_gun_LCTR"sv); x7b6_gunSeg = x64_modelData->GetAnimationData()->GetLocatorSegId("R_gun_LCTR"sv);

View File

@ -97,8 +97,7 @@ private:
}; };
CSpacePirateData x568_pirateData; CSpacePirateData x568_pirateData;
union {
struct {
bool x634_24_pendingAmbush : 1; bool x634_24_pendingAmbush : 1;
bool x634_25_ceilingAmbush : 1; bool x634_25_ceilingAmbush : 1;
bool x634_26_nonAggressive : 1; bool x634_26_nonAggressive : 1;
@ -148,10 +147,6 @@ private:
bool x639_30_closeMelee : 1; bool x639_30_closeMelee : 1;
bool x639_31_sentAttackMsg : 1; bool x639_31_sentAttackMsg : 1;
bool x63a_24_normalDodge : 1; bool x63a_24_normalDodge : 1;
};
u64 _dummy = 0;
};
s32 x63c_frenzyFrames = 0; s32 x63c_frenzyFrames = 0;
TUniqueId x640_coverPoint = kInvalidUniqueId; TUniqueId x640_coverPoint = kInvalidUniqueId;

View File

@ -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) , x590_pfSearch(nullptr, 0x3, pInfo.GetPathfindingIndex(), 1.f, 1.f)
, x684_(dInfo1) , x684_(dInfo1)
, x6d4_projectileInfo(projectileWeapon, projectileDamage) , x6d4_projectileInfo(projectileWeapon, projectileDamage)
, x72c_projectileVisorSfx(CSfxManager::TranslateSFXID(projecileVisorSfx)) { , x72c_projectileVisorSfx(CSfxManager::TranslateSFXID(projecileVisorSfx))
x72e_24_jumpBackRepeat = true; , x72e_24_jumpBackRepeat(true)
x72e_26_initiallyInactive = !pInfo.GetActive(); , 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(); x6d4_projectileInfo.Token().Lock();
UpdateTouchBounds(); UpdateTouchBounds();
SetCoefficientOfRestitutionModifier(0.1f); SetCoefficientOfRestitutionModifier(0.1f);

View File

@ -33,8 +33,6 @@ class CWarWasp : public CPatterned {
float x718_circleBurstOffTotemAngle = zeus::degToRad(90.f); float x718_circleBurstOffTotemAngle = zeus::degToRad(90.f);
TLockedToken<CGenDescription> x71c_projectileVisorParticle; // Used to be optional TLockedToken<CGenDescription> x71c_projectileVisorParticle; // Used to be optional
u16 x72c_projectileVisorSfx; u16 x72c_projectileVisorSfx;
union {
struct {
bool x72e_24_jumpBackRepeat : 1; bool x72e_24_jumpBackRepeat : 1;
bool x72e_25_canApplyDamage : 1; bool x72e_25_canApplyDamage : 1;
bool x72e_26_initiallyInactive : 1; bool x72e_26_initiallyInactive : 1;
@ -43,9 +41,7 @@ class CWarWasp : public CPatterned {
bool x72e_29_pathObstructed : 1; bool x72e_29_pathObstructed : 1;
bool x72e_30_isRetreating : 1; bool x72e_30_isRetreating : 1;
bool x72e_31_heardNoise : 1; bool x72e_31_heardNoise : 1;
};
u32 _dummy = 0;
};
void SwarmAdd(CStateManager& mgr); void SwarmAdd(CStateManager& mgr);
void SwarmRemove(CStateManager& mgr); void SwarmRemove(CStateManager& mgr);
void ApplyDamage(CStateManager& mgr); void ApplyDamage(CStateManager& mgr);