Runtime/Weapon: Replace bitfield unions with constructor initializers

This commit is contained in:
Luke Street 2020-04-11 00:49:02 -04:00
parent c7ca8dc3a7
commit 22880abb7e
19 changed files with 174 additions and 171 deletions

View File

@ -9,7 +9,8 @@
#include <zeus/Math.hpp>
namespace urde {
CBurstFire::CBurstFire(const SBurst* const* burstDefs, s32 firstBurstCount) : x10_firstBurstCounter(firstBurstCount) {
CBurstFire::CBurstFire(const SBurst* const* burstDefs, s32 firstBurstCount)
: x10_firstBurstCounter(firstBurstCount), x14_24_shouldFire(false), x14_25_avoidAccuracy(false) {
while (*burstDefs) {
x1c_burstDefs.push_back(*burstDefs);
++burstDefs;

View File

@ -23,13 +23,8 @@ class CBurstFire {
float x8_timeToNextShot = 0.f;
s32 xc_firstBurstIdx = 0;
s32 x10_firstBurstCounter;
union {
struct {
bool x14_24_shouldFire : 1;
bool x14_25_avoidAccuracy : 1;
};
u32 _dummy = 0;
};
const SBurst* x18_curBursts = nullptr;
rstl::reserved_vector<const SBurst*, 16> x1c_burstDefs;

View File

@ -20,13 +20,17 @@ CEnergyProjectile::CEnergyProjectile(bool active, const TToken<CWeaponDescriptio
const zeus::CTransform& xf, EMaterialTypes excludeMat, const CDamageInfo& damage,
TUniqueId uid, TAreaId aid, TUniqueId owner, TUniqueId homingTarget,
EProjectileAttrib attribs, bool underwater, const zeus::CVector3f& scale,
const std::optional<TLockedToken<CGenDescription>>& visorParticle,
u16 visorSfx, bool sendCollideMsg)
const std::optional<TLockedToken<CGenDescription>>& visorParticle, u16 visorSfx,
bool sendCollideMsg)
: CGameProjectile(active, desc, "GameProjectile", type, xf, excludeMat, damage, uid, aid, owner, homingTarget, attribs,
underwater, scale, visorParticle, visorSfx, sendCollideMsg)
, x2ec_dir(xf.basis[1])
, x2ec_dir(xf.frontVector())
, x2f8_mag(x2ec_dir.magnitude())
, x2fc_camShake(CCameraShakeData::BuildProjectileCameraShake(0.5f, 0.75f)) {
, x2fc_camShake(CCameraShakeData::BuildProjectileCameraShake(0.5f, 0.75f))
, x3d0_24_dead(false)
, x3d0_25_(false)
, x3d0_26_(false)
, x3d0_27_camShakeDirty(false) {
xe6_27_thermalVisorFlags = 2;
}

View File

@ -10,15 +10,10 @@ class CEnergyProjectile : public CGameProjectile {
zeus::CVector3f x2ec_dir;
float x2f8_mag;
CCameraShakeData x2fc_camShake;
union {
struct {
bool x3d0_24_dead : 1;
bool x3d0_25_ : 1;
bool x3d0_26_ : 1;
bool x3d0_27_camShakeDirty : 1;
};
u32 _dummy = 0;
};
float x3d4_curTime = 0.f;
void StopProjectile(CStateManager& mgr);

View File

@ -33,10 +33,8 @@ CFlameThrower::CFlameThrower(const TToken<CWeaponDescription>& wDesc, std::strin
, x3fc_playerIceTxtr(playerIceTxtr)
, x400_24_active(false)
, x400_25_particlesActive(false)
, x400_26_(!(flameInfo.GetAttributes() & 1))
, x400_27_coneCollision((flameInfo.GetAttributes() & 0x2) != 0) {
}
, x400_26_((flameInfo.GetAttributes() & 1) == 0)
, x400_27_coneCollision((flameInfo.GetAttributes() & 0x2) != 0) {}
void CFlameThrower::Accept(IVisitor& visitor) { visitor.Visit(this); }

View File

@ -31,16 +31,10 @@ private:
CAssetId x3f4_playerSteamTxtr;
s16 x3f8_playerHitSfx;
CAssetId x3fc_playerIceTxtr;
union {
struct {
bool x400_24_active : 1;
bool x400_25_particlesActive : 1;
bool x400_26_ : 1;
bool x400_27_coneCollision : 1; /* Z-sort and finer collision detection */
};
u32 _dummy = 0;
};
void CreateFlameParticles(CStateManager&);
void SetFlameLightActive(CStateManager&, bool);

View File

@ -11,16 +11,12 @@ class CGSComboFire {
s32 x4_loopState = -1; // In, loop, out
s32 x8_cueAnimId = -1;
s32 xc_gunId = -1;
union {
struct {
bool x10_24_over : 1;
bool x10_25_idle : 1;
};
u8 _dummy = 0;
};
public:
CGSComboFire() : x10_24_over(false), x10_25_idle(false) {}
bool IsComboOver() const { return x10_24_over; }
s32 GetLoopState() const { return x4_loopState; }
void SetLoopState(s32 l) { x4_loopState = l; }

View File

@ -1,5 +1,7 @@
#include "Runtime/Weapon/CGameProjectile.hpp"
#include <utility>
#include "Runtime/CStateManager.hpp"
#include "Runtime/Collision/CCollisionActor.hpp"
#include "Runtime/Collision/CInternalRayCastStructure.hpp"
@ -19,15 +21,15 @@ CGameProjectile::CGameProjectile(bool active, const TToken<CWeaponDescription>&
const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner,
TUniqueId homingTarget, EProjectileAttrib attribs, bool underwater,
const zeus::CVector3f& scale,
const std::optional<TLockedToken<CGenDescription>>& visorParticle,
u16 visorSfx, bool sendCollideMsg)
std::optional<TLockedToken<CGenDescription>> visorParticle, u16 visorSfx,
bool sendCollideMsg)
: CWeapon(uid, aid, active, owner, wType, name, xf,
CMaterialFilter::MakeIncludeExclude(
{EMaterialTypes::Solid, EMaterialTypes::NonSolidDamageable},
{EMaterialTypes::Projectile, EMaterialTypes::ProjectilePassthrough, excludeMat}),
CMaterialList(EMaterialTypes::Projectile), dInfo, attribs | GetBeamAttribType(wType),
CModelData::CModelDataNull())
, x158_visorParticle(visorParticle)
, x158_visorParticle(std::move(visorParticle))
, x168_visorSfx(visorSfx)
, x170_projectile(wDesc, xf.origin, xf.basis, scale,
(attribs & EProjectileAttrib::ParticleOPTS) == EProjectileAttrib::ParticleOPTS)
@ -35,13 +37,12 @@ CGameProjectile::CGameProjectile(bool active, const TToken<CWeaponDescription>&
, x2a4_projExtent((xe8_projectileAttribs & EProjectileAttrib::BigProjectile) == EProjectileAttrib::BigProjectile ? 0.25f
: 0.1f)
, x2c0_homingTargetId(homingTarget)
, x2cc_wpscId(wDesc.GetObjectTag()->id) {
x2e4_24_active = true;
x2e4_25_startedUnderwater = underwater;
x2e4_26_waterUpdate = underwater;
x2e4_27_inWater = underwater;
x2e4_28_sendProjectileCollideMsg = sendCollideMsg;
}
, x2cc_wpscId(wDesc.GetObjectTag()->id)
, x2e4_24_active(true)
, x2e4_25_startedUnderwater(underwater)
, x2e4_26_waterUpdate(underwater)
, x2e4_27_inWater(underwater)
, x2e4_28_sendProjectileCollideMsg(sendCollideMsg) {}
void CGameProjectile::Accept(urde::IVisitor& visitor) { visitor.Visit(this); }

View File

@ -49,23 +49,18 @@ protected:
CAssetId x2cc_wpscId;
std::vector<CProjectileTouchResult> x2d0_touchResults;
float x2e0_minHomingDist = 0.f;
union {
struct {
bool x2e4_24_active : 1;
bool x2e4_25_startedUnderwater : 1;
bool x2e4_26_waterUpdate : 1;
bool x2e4_27_inWater : 1;
bool x2e4_28_sendProjectileCollideMsg : 1;
};
};
public:
CGameProjectile(bool active, const TToken<CWeaponDescription>&, std::string_view name, EWeaponType wType,
const zeus::CTransform& xf, EMaterialTypes excludeMat, const CDamageInfo& dInfo, TUniqueId uid,
TAreaId aid, TUniqueId owner, TUniqueId homingTarget, EProjectileAttrib attribs, bool underwater,
const zeus::CVector3f& scale,
const std::optional<TLockedToken<CGenDescription>>& visorParticle, u16 visorSfx,
bool sendCollideMsg);
const zeus::CVector3f& scale, std::optional<TLockedToken<CGenDescription>> visorParticle,
u16 visorSfx, bool sendCollideMsg);
void Accept(IVisitor& visitor) override;
virtual void ResolveCollisionWithActor(const CRayCastResult& res, CActor& act, CStateManager& mgr);

View File

@ -37,7 +37,13 @@ CGrappleArm::CGrappleArm(const zeus::CVector3f& scale)
, x398_grappleHitGen(std::make_unique<CElementGen>(x36c_grappleHitDesc))
, x39c_grappleMuzzleGen(std::make_unique<CElementGen>(x378_grappleMuzzleDesc))
, x3a0_grappleSwooshGen(std::make_unique<CParticleSwoosh>(x384_grappleSwooshDesc, 0))
, x3a4_rainSplashGenerator(std::make_unique<CRainSplashGenerator>(scale, 20, 2, 0.f, 0.125f)) {
, x3a4_rainSplashGenerator(std::make_unique<CRainSplashGenerator>(scale, 20, 2, 0.f, 0.125f))
, x3b2_24_active(false)
, x3b2_25_beamActive(false)
, x3b2_26_grappleHit(false)
, x3b2_27_armMoving(false)
, x3b2_28_isGrappling(false)
, x3b2_29_suitLoading(false) {
x0_grappleArmModel->SetSortThermal(true);
xa0_grappleGearModel.SetSortThermal(true);
xec_grapNoz1Model.SetSortThermal(true);

View File

@ -75,17 +75,12 @@ private:
CPlayerState::EPlayerSuit x3a8_loadedSuit = CPlayerState::EPlayerSuit::Invalid;
float x3ac_pitchBend = 0.f;
s16 x3b0_rumbleHandle = -1;
union {
struct {
bool x3b2_24_active : 1;
bool x3b2_25_beamActive : 1;
bool x3b2_26_grappleHit : 1;
bool x3b2_27_armMoving : 1;
bool x3b2_28_isGrappling : 1;
bool x3b2_29_suitLoading : 1;
};
u32 _dummy = 0;
};
static float g_GrappleBeamAnglePhaseDelta;
static float g_GrappleBeamXWaveAmplitude;

View File

@ -70,7 +70,13 @@ CGunWeapon::CGunWeapon(CAssetId ancsId, EWeaponType type, TUniqueId playerId, EM
, x1c8_playerMaterial(playerMaterial)
, x200_beamId(GetWeaponIndex(type))
, x20c_shaderIdx(u32(x200_beamId))
, x214_ancsId(ancsId) {
, x214_ancsId(ancsId)
, x218_24(false)
, x218_25_enableCharge(false)
, x218_26_loaded(false)
, x218_27_subtypeBasePose(false)
, x218_28_suitArmLocked(false)
, x218_29_drawHologram(false) {
AllocResPools(x200_beamId);
BuildDependencyList(x200_beamId);
}

View File

@ -84,8 +84,6 @@ protected:
// 0x1: load request, 0x2: muzzle fx, 0x4: projectile data, 0x8: anims, 0x10: everything else
u32 x210_loadFlags = 0;
CAssetId x214_ancsId;
union {
struct {
bool x218_24 : 1;
bool x218_25_enableCharge : 1;
bool x218_26_loaded : 1;
@ -93,9 +91,6 @@ protected:
bool x218_27_subtypeBasePose : 1;
bool x218_28_suitArmLocked : 1;
bool x218_29_drawHologram : 1;
};
u32 _dummy = 0;
};
void AllocResPools(CPlayerState::EBeamId beam);
void FreeResPools();

View File

@ -29,8 +29,8 @@ CPlasmaProjectile::CPlasmaProjectile(const TToken<CWeaponDescription>& wDesc, st
const CBeamInfo& bInfo, const zeus::CTransform& xf, EMaterialTypes matType,
const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner,
const PlayerEffectResoures& res, bool growingBeam, EProjectileAttrib attribs)
: CBeamProjectile(wDesc, name, wType, xf, bInfo.GetLength(), bInfo.GetRadius(), bInfo.GetTravelSpeed(), matType,
dInfo, uid, aid, owner, attribs, growingBeam)
: CBeamProjectile(wDesc, name, wType, xf, bInfo.GetLength(), bInfo.GetRadius(), bInfo.GetTravelSpeed(), matType, dInfo,
uid, aid, owner, attribs, growingBeam)
, x478_beamAttributes(bInfo.GetBeamAttributes())
, x47c_lifeTime(bInfo.GetLifeTime())
, x480_pulseSpeed(bInfo.GetPulseSpeed())
@ -38,7 +38,13 @@ CPlasmaProjectile::CPlasmaProjectile(const TToken<CWeaponDescription>& wDesc, st
, x488_expansionSpeed(bInfo.GetExpansionSpeed())
, x48c_(bInfo.GetLength() / 32.f)
, x490_innerColor(bInfo.GetInnerColor())
, x494_outerColor(bInfo.GetOuterColor()) {
, x494_outerColor(bInfo.GetOuterColor())
, x548_24_(false)
, x548_25_enableEnergyPulse(true)
, x548_26_firing(false)
, x548_27_texturesLoaded(false)
, x548_28_drawOwnerFirst(growingBeam)
, x548_29_activePlayerPhazon(false) {
x4e8_texture = g_SimplePool->GetObj(SObjectTag{FOURCC('TXTR'), bInfo.GetTextureId()});
x4f4_glowTexture = g_SimplePool->GetObj(SObjectTag{FOURCC('TXTR'), bInfo.GetGlowTextureId()});
x500_contactFxDesc = g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), bInfo.GetContactFxId()});
@ -53,8 +59,6 @@ CPlasmaProjectile::CPlasmaProjectile(const TToken<CWeaponDescription>& wDesc, st
x538_visorParticle = g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), res[3]});
x544_freezeSfx = CSfxManager::TranslateSFXID(res[4]);
x546_electricSfx = CSfxManager::TranslateSFXID(res[5]);
x548_25_enableEnergyPulse = true;
x548_28_drawOwnerFirst = growingBeam;
x518_contactGen->SetGlobalScale(zeus::CVector3f(bInfo.GetContactFxScale()));
x51c_pulseGen->SetGlobalScale(zeus::CVector3f(bInfo.GetPulseFxScale()));
x518_contactGen->SetParticleEmission(false);

View File

@ -67,17 +67,12 @@ private:
TToken<CGenDescription> x538_visorParticle; // Used to be optional
u16 x544_freezeSfx;
u16 x546_electricSfx;
union {
struct {
bool x548_24_ : 1;
bool x548_25_enableEnergyPulse : 1;
bool x548_26_firing : 1;
bool x548_27_texturesLoaded : 1;
bool x548_28_drawOwnerFirst : 1;
bool x548_29_activePlayerPhazon : 1;
};
u32 _dummy3 = 0;
};
struct RenderObjects {
CColoredStripShader m_beamStrip1;

View File

@ -131,7 +131,39 @@ CPlayerGun::CPlayerGun(TUniqueId playerId)
, x678_morph(g_tweakPlayerGun->GetGunTransformTime(), g_tweakPlayerGun->GetHoloHoldTime())
, x6c8_hologramClipCube(zeus::CVector3f(-0.29329199f, 0.f, -0.2481945f),
zeus::CVector3f(0.29329199f, 1.292392f, 0.2481945f))
, x6e0_rightHandModel(CAnimRes(g_tweakGunRes->xc_rightHand, 0, zeus::CVector3f(3.f), 0, true)) {
, x6e0_rightHandModel(CAnimRes(g_tweakGunRes->xc_rightHand, 0, zeus::CVector3f(3.f), 0, true))
, x832_24_coolingCharge(false)
, x832_25_chargeEffectVisible(false)
, x832_26_comboFiring(false)
, x832_27_chargeAnimStarted(false)
, x832_28_readyForShot(false)
, x832_29_lockedOn(false)
, x832_30_requestReturnToDefault(false)
, x832_31_inRestPose(true)
, x833_24_notFidgeting(true)
, x833_25_(false)
, x833_26_(false)
, x833_27_(false)
, x833_28_phazonBeamActive(false)
, x833_29_pointBlankWorldSurface(false)
, x833_30_canShowAuxMuzzleEffect(true)
, x833_31_inFreeLook(false)
, x834_24_charging(false)
, x834_25_gunMotionFidgeting(false)
, x834_26_animPlaying(false)
, x834_27_underwater(false)
, x834_28_requestImmediateRecharge(false)
, x834_29_frozen(false)
, x834_30_inBigStrike(false)
, x834_31_gunMotionInFidgetBasePosition(false)
, x835_24_canFirePhazon(false)
, x835_25_inPhazonBeam(false)
, x835_26_phazonBeamMorphing(false)
, x835_27_intoPhazonBeam(false)
, x835_28_bombReady(false)
, x835_29_powerBombReady(false)
, x835_30_inPhazonPool(false)
, x835_31_actorAttached(false) {
x354_bombFuseTime = g_tweakPlayerGun->GetBombFuseTime();
x358_bombDropDelayTime = g_tweakPlayerGun->GetBombDropDelayTime();
x668_aimVerticalSpeed = g_tweakPlayerGun->GetAimVerticalSpeed();
@ -155,9 +187,6 @@ CPlayerGun::CPlayerGun(TUniqueId playerId)
g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), g_tweakGunRes->x24_holoTransition}));
x82c_shadow = std::make_unique<CWorldShadow>(256, 256, true);
x832_31_inRestPose = true;
x833_24_notFidgeting = true;
x833_30_canShowAuxMuzzleEffect = true;
x6e0_rightHandModel.SetSortThermal(true);
kVerticalAngleTable[2] = g_tweakPlayerGun->GetUpLookAngle();

View File

@ -82,18 +82,15 @@ private:
float x18_transitionFactor = 1.f;
EDir x1c_dir = EDir::Done;
EGunState x20_gunState = EGunState::OutWipeDone;
union {
struct {
bool x24_24_morphing : 1;
bool x24_25_weaponChanged : 1;
};
u32 _dummy = 0;
};
public:
CGunMorph(float gunTransformTime, float holoHoldTime)
: x4_gunTransformTime(gunTransformTime), x10_holoHoldTime(std::fabs(holoHoldTime)) {}
: x4_gunTransformTime(gunTransformTime)
, x10_holoHoldTime(std::fabs(holoHoldTime))
, x24_24_morphing(false)
, x24_25_weaponChanged(false) {}
float GetYLerp() const { return x0_yLerp; }
float GetTransitionFactor() const { return x18_transitionFactor; }
EGunState GetGunState() const { return x20_gunState; }
@ -225,8 +222,6 @@ private:
std::unique_ptr<CWorldShadow> x82c_shadow;
s16 x830_chargeRumbleHandle = -1;
union {
struct {
bool x832_24_coolingCharge : 1;
bool x832_25_chargeEffectVisible : 1;
bool x832_26_comboFiring : 1;
@ -262,9 +257,6 @@ private:
bool x835_29_powerBombReady : 1;
bool x835_30_inPhazonPool : 1;
bool x835_31_actorAttached : 1;
};
u32 _dummy = 0;
};
CTexturedQuadFilter m_screenQuad{EFilterType::Blend, CGraphics::g_SpareTexture.get(),
CTexturedQuadFilter::ZTest::GEqualZWrite};

View File

@ -15,8 +15,15 @@ CProjectileWeapon::CProjectileWeapon(const TToken<CWeaponDescription>& wDesc, co
, x10_random(g_GlobalSeed)
, x14_localToWorldXf(localToWorld)
, x74_worldOffset(worldOffset)
, xe4_flags(flags) {
x124_24_active = true;
, xe4_flags(flags)
, x124_24_active(true)
, x124_25_APSO(false)
, x124_26_AP11(false)
, x124_27_AP21(false)
, x124_28_AS11(false)
, x124_29_AS12(false)
, x124_30_AS13(false)
, x124_31_VMD2(false) {
CGlobalRandom gr(x10_random);
x124_31_VMD2 = x4_weaponDesc->x10_VMD2;
x124_25_APSO = x4_weaponDesc->x28_APSO;

View File

@ -53,8 +53,6 @@ class CProjectileWeapon {
std::unique_ptr<CParticleSwoosh> x118_swoosh1;
std::unique_ptr<CParticleSwoosh> x11c_swoosh2;
std::unique_ptr<CParticleSwoosh> x120_swoosh3;
union {
struct {
bool x124_24_active : 1;
bool x124_25_APSO : 1;
bool x124_26_AP11 : 1;
@ -63,9 +61,6 @@ class CProjectileWeapon {
bool x124_29_AS12 : 1;
bool x124_30_AS13 : 1;
bool x124_31_VMD2 : 1;
};
u32 _dummy = 0;
};
public:
CProjectileWeapon(const TToken<CWeaponDescription>& wDesc, const zeus::CVector3f& worldOffset,