From 346d110b79822966b368519bc24730744fefdf3b Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:02:36 -0400 Subject: [PATCH 01/16] Runtime: Replace bitfield unions with constructor initializers --- Runtime/CGameOptions.cpp | 10 ++++++---- Runtime/CGameOptions.hpp | 37 ++++++++++++------------------------- Runtime/CGameState.cpp | 2 ++ Runtime/CGameState.hpp | 10 ++-------- Runtime/CPakFile.cpp | 1 + Runtime/CPakFile.hpp | 15 +++++---------- Runtime/CPlayerState.cpp | 8 ++++---- Runtime/CPlayerState.hpp | 12 +++--------- Runtime/CStateManager.cpp | 9 ++++++++- Runtime/CStateManager.hpp | 20 +++++++------------- 10 files changed, 50 insertions(+), 74 deletions(-) diff --git a/Runtime/CGameOptions.cpp b/Runtime/CGameOptions.cpp index fff4226eb..4b2b8e4ee 100644 --- a/Runtime/CGameOptions.cpp +++ b/Runtime/CGameOptions.cpp @@ -212,10 +212,12 @@ void CGameOptions::PutTo(CBitStreamWriter& writer) const { writer.WriteEncoded(x68_27_swapBeamsControls, 1); } -CGameOptions::CGameOptions() { - x68_24_hudLag = true; - x68_26_rumble = true; - x68_28_hintSystem = true; +CGameOptions::CGameOptions() +: x68_24_hudLag(true) +, x68_25_invertY(false) +, x68_26_rumble(true) +, x68_27_swapBeamsControls(false) +, x68_28_hintSystem(true) { InitSoundMode(); } diff --git a/Runtime/CGameOptions.hpp b/Runtime/CGameOptions.hpp index 554ecea86..a77e3e849 100644 --- a/Runtime/CGameOptions.hpp +++ b/Runtime/CGameOptions.hpp @@ -56,18 +56,12 @@ class CPersistentOptions { u32 xc4_frozenBallCount = 0; u32 xc8_powerBombAmmoCount = 0; u32 xcc_logScanPercent = 0; - - union { - struct { - bool xd0_24_fusionLinked : 1; - bool xd0_25_normalModeBeat : 1; - bool xd0_26_hardModeBeat : 1; - bool xd0_27_fusionBeat : 1; - bool xd0_28_fusionSuitActive : 1; - bool xd0_29_allItemsCollected : 1; - }; - u16 _dummy = 0; - }; + bool xd0_24_fusionLinked : 1; + bool xd0_25_normalModeBeat : 1; + bool xd0_26_hardModeBeat : 1; + bool xd0_27_fusionBeat : 1; + bool xd0_28_fusionSuitActive : 1; + bool xd0_29_allItemsCollected : 1; public: CPersistentOptions() = default; @@ -116,22 +110,15 @@ class CGameOptions { u32 x5c_musicVol = 0x7f; u32 x60_hudAlpha = 0xff; u32 x64_helmetAlpha = 0xff; + bool x68_24_hudLag : 1; + bool x68_25_invertY : 1; + bool x68_26_rumble : 1; + bool x68_27_swapBeamsControls : 1; + bool x68_28_hintSystem : 1; + std::vector> x6c_controlTxtrMap; s32 m_gamma = 0; - union { - struct { - bool x68_24_hudLag : 1; - bool x68_25_invertY : 1; - bool x68_26_rumble : 1; - bool x68_27_swapBeamsControls : 1; - bool x68_28_hintSystem : 1; - }; - u16 _dummy = 0; - }; - - std::vector> x6c_controlTxtrMap; - public: CGameOptions(); explicit CGameOptions(CBitStreamReader& stream); diff --git a/Runtime/CGameState.cpp b/Runtime/CGameState.cpp index 2bd9531f6..ca4d7e469 100644 --- a/Runtime/CGameState.cpp +++ b/Runtime/CGameState.cpp @@ -137,6 +137,7 @@ CGameState::GameFileStateInfo CGameState::LoadGameFileState(const u8* data) { CGameState::CGameState() { x98_playerState = std::make_shared(); x9c_transManager = std::make_shared(); + x228_24_hardMode = false; x228_25_initPowerupsAtFirstSpawn = true; if (g_MemoryCardSys) InitializeMemoryStates(); @@ -144,6 +145,7 @@ CGameState::CGameState() { CGameState::CGameState(CBitStreamReader& stream, u32 saveIdx) : x20c_saveFileIdx(saveIdx) { x9c_transManager = std::make_shared(); + x228_24_hardMode = false; x228_25_initPowerupsAtFirstSpawn = true; for (bool& value : x0_) { diff --git a/Runtime/CGameState.hpp b/Runtime/CGameState.hpp index 32349f8d9..ad4146e6d 100644 --- a/Runtime/CGameState.hpp +++ b/Runtime/CGameState.hpp @@ -81,14 +81,8 @@ class CGameState { u32 x20c_saveFileIdx = 0; u64 x210_cardSerial = 0; std::vector x218_backupBuf; - - union { - struct { - bool x228_24_hardMode : 1; - bool x228_25_initPowerupsAtFirstSpawn : 1; - }; - u8 _dummy = 0; - }; + bool x228_24_hardMode : 1; + bool x228_25_initPowerupsAtFirstSpawn : 1; public: CGameState(); diff --git a/Runtime/CPakFile.cpp b/Runtime/CPakFile.cpp index 8d29f7367..7cb34c700 100644 --- a/Runtime/CPakFile.cpp +++ b/Runtime/CPakFile.cpp @@ -8,6 +8,7 @@ CPakFile::CPakFile(std::string_view filename, bool buildDepList, bool worldPak, Log.report(logvisor::Fatal, fmt("{}: Unable to open"), GetPath()); x28_24_buildDepList = buildDepList; //x28_24_buildDepList = true; // Always do this so URDE can rapidly pre-warm shaders + x28_25_aramFile = false; x28_26_worldPak = worldPak; x28_27_stashedInARAM = false; m_override = override; diff --git a/Runtime/CPakFile.hpp b/Runtime/CPakFile.hpp index d978d7fc6..f0b1ec91a 100644 --- a/Runtime/CPakFile.hpp +++ b/Runtime/CPakFile.hpp @@ -36,16 +36,11 @@ public: }; private: - union { - struct { - bool x28_24_buildDepList : 1; - bool x28_25_aramFile : 1; - bool x28_26_worldPak : 1; - bool x28_27_stashedInARAM : 1; - bool m_override : 1; - }; - u32 _dummy = 0; - }; + bool x28_24_buildDepList : 1; + bool x28_25_aramFile : 1; + bool x28_26_worldPak : 1; + bool x28_27_stashedInARAM : 1; + bool m_override : 1; enum class EAsyncPhase { Warmup = 0, InitialHeader = 1, diff --git a/Runtime/CPlayerState.cpp b/Runtime/CPlayerState.cpp index 38e9e9841..210a7f4e0 100644 --- a/Runtime/CPlayerState.cpp +++ b/Runtime/CPlayerState.cpp @@ -74,13 +74,13 @@ constexpr std::array ComboAmmoPeriods{ }; } // Anonymous namespace -CPlayerState::CPlayerState() : x188_staticIntf(5) { - x0_24_alive = true; +CPlayerState::CPlayerState() +: x0_24_alive(true), x0_25_firingComboBeam(false), x0_26_fusion(false), x188_staticIntf(5) { x24_powerups.resize(41); } -CPlayerState::CPlayerState(CBitStreamReader& stream) : x188_staticIntf(5) { - x0_24_alive = true; +CPlayerState::CPlayerState(CBitStreamReader& stream) +: x0_24_alive(true), x0_25_firingComboBeam(false), x0_26_fusion(false), x188_staticIntf(5) { x4_enabledItems = u32(stream.ReadEncoded(32)); const u32 integralHP = u32(stream.ReadEncoded(32)); diff --git a/Runtime/CPlayerState.hpp b/Runtime/CPlayerState.hpp index 22134070d..192095668 100644 --- a/Runtime/CPlayerState.hpp +++ b/Runtime/CPlayerState.hpp @@ -94,15 +94,9 @@ private: constexpr CPowerUp() = default; constexpr CPowerUp(u32 amount, u32 capacity) : x0_amount(amount), x4_capacity(capacity) {} }; - union { - struct { - bool x0_24_alive : 1; - bool x0_25_firingComboBeam : 1; - bool x0_26_fusion : 1; - }; - u32 dummy = 0; - }; - + bool x0_24_alive : 1; + bool x0_25_firingComboBeam : 1; + bool x0_26_fusion : 1; u32 x4_enabledItems = 0; EBeamId x8_currentBeam = EBeamId::Power; CHealthInfo xc_health = {99.f, 50.f}; diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index fda9eeb25..45cad7fc9 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -62,7 +62,14 @@ CStateManager::CStateManager(const std::weak_ptr& relayTracker, , x8bc_relayTracker(relayTracker) , x8c0_mapWorldInfo(mwInfo) , x8c4_worldTransManager(wtMgr) -, x8c8_worldLayerState(layerState) { +, x8c8_worldLayerState(layerState) +, xf94_24_readyToRender(false) +, xf94_25_quitGame(false) +, xf94_26_generatingObject(false) +, xf94_27_inMapScreen(false) +, xf94_28_inSaveUI(false) +, xf94_29_cinematicPause(false) +, xf94_30_fullThreat(false) { x86c_stateManagerContainer = std::make_unique(); x870_cameraManager = &x86c_stateManagerContainer->x0_cameraManager; x874_sortedListManager = &x86c_stateManagerContainer->x3c0_sortedListManager; diff --git a/Runtime/CStateManager.hpp b/Runtime/CStateManager.hpp index 225c79e07..1b138b7b7 100644 --- a/Runtime/CStateManager.hpp +++ b/Runtime/CStateManager.hpp @@ -202,19 +202,13 @@ private: CAssetId xf88_; float xf8c_ = 0.f; EStateManagerTransition xf90_deferredTransition = EStateManagerTransition::InGame; - - union { - struct { - bool xf94_24_readyToRender : 1; - bool xf94_25_quitGame : 1; - bool xf94_26_generatingObject : 1; - bool xf94_27_inMapScreen : 1; - bool xf94_28_inSaveUI : 1; - bool xf94_29_cinematicPause : 1; - bool xf94_30_fullThreat : 1; - }; - u32 xf94_ = 0; - }; + bool xf94_24_readyToRender : 1; + bool xf94_25_quitGame : 1; + bool xf94_26_generatingObject : 1; + bool xf94_27_inMapScreen : 1; + bool xf94_28_inSaveUI : 1; + bool xf94_29_cinematicPause : 1; + bool xf94_30_fullThreat : 1; CColoredQuadFilter m_deathWhiteout{EFilterType::Add}; CColoredQuadFilter m_escapeWhiteout{EFilterType::Add}; From 8e691d0f73384f13ae3491b60867c105cf818038 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:02:55 -0400 Subject: [PATCH 02/16] Runtime/Audio: Replace bitfield unions with constructor initializers --- Runtime/Audio/CStreamAudioManager.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Runtime/Audio/CStreamAudioManager.cpp b/Runtime/Audio/CStreamAudioManager.cpp index 51ee8d788..ba6c4db21 100644 --- a/Runtime/Audio/CStreamAudioManager.cpp +++ b/Runtime/Audio/CStreamAudioManager.cpp @@ -446,14 +446,9 @@ public: private: dspadpcm_header x0_header; std::string x60_fileName; // arg1 - union { - u32 dummy = 0; - struct { - bool x70_24_unclaimed : 1; - bool x70_25_headerReadCancelled : 1; - u8 x70_26_headerReadState : 2; // 0: not read 1: reading 2: read - }; - }; + bool x70_24_unclaimed : 1; + bool x70_25_headerReadCancelled : 1; + u8 x70_26_headerReadState : 2; // 0: not read 1: reading 2: read s8 x71_companionRight = -1; s8 x72_companionLeft = -1; float x73_volume = 0.f; @@ -465,13 +460,16 @@ private: static std::array g_Streams; public: - CDSPStreamManager() { x70_24_unclaimed = true; } + CDSPStreamManager() : x70_24_unclaimed(true), x70_25_headerReadCancelled(false), x70_26_headerReadState(0) {} CDSPStreamManager(std::string_view fileName, s32 handle, float volume, bool oneshot) - : x60_fileName(fileName), x73_volume(volume), x74_oneshot(oneshot), x78_handleId(handle) { - if (!CDvdFile::FileExists(fileName)) - x70_24_unclaimed = true; - } + : x60_fileName(fileName) + , x70_24_unclaimed(!CDvdFile::FileExists(fileName)) + , x70_25_headerReadCancelled(false) + , x70_26_headerReadState(0) + , x73_volume(volume) + , x74_oneshot(oneshot) + , x78_handleId(handle) {} static s32 FindUnclaimedStreamIdx() { for (size_t i = 0; i < g_Streams.size(); ++i) { From 496bb3e62459920ccfaef674953945d06eea3da0 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:03:05 -0400 Subject: [PATCH 03/16] Runtime/Camera: Replace bitfield unions with constructor initializers --- Runtime/Camera/CCameraManager.cpp | 12 +++++++++--- Runtime/Camera/CCameraManager.hpp | 24 +++++------------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/Runtime/Camera/CCameraManager.cpp b/Runtime/Camera/CCameraManager.cpp index a2fd101e7..f2a61f4f7 100644 --- a/Runtime/Camera/CCameraManager.cpp +++ b/Runtime/Camera/CCameraManager.cpp @@ -21,9 +21,15 @@ namespace urde { float CCameraManager::sFirstPersonFOV = 55.f; -CCameraManager::CCameraManager(TUniqueId curCameraId) : x0_curCameraId(curCameraId) { - CSfxManager::AddListener(CSfxManager::ESfxChannels::Game, zeus::skZero3f, zeus::skZero3f, - {1.f, 0.f, 0.f}, {0.f, 0.f, 1.f}, 50.f, 50.f, 1000.f, 1, 1.f); +CCameraManager::CCameraManager(TUniqueId curCameraId) +: x0_curCameraId(curCameraId) +, xa0_24_pendingRumble(false) +, xa0_25_rumbling(false) +, xa0_26_inWater(false) +, x3b8_24_(false) +, x3b8_25_(false) { + CSfxManager::AddListener(CSfxManager::ESfxChannels::Game, zeus::skZero3f, zeus::skZero3f, {1.f, 0.f, 0.f}, + {0.f, 0.f, 1.f}, 50.f, 50.f, 1000.f, 1, 1.f); sFirstPersonFOV = g_tweakGame->GetFirstPersonFOV(); } diff --git a/Runtime/Camera/CCameraManager.hpp b/Runtime/Camera/CCameraManager.hpp index 7268b6bf8..60b5edd40 100644 --- a/Runtime/Camera/CCameraManager.hpp +++ b/Runtime/Camera/CCameraManager.hpp @@ -40,16 +40,9 @@ class CCameraManager { float x94_fogDensityFactor = 1.f; float x98_fogDensitySpeed = 0.f; float x9c_fogDensityFactorTarget = 1.f; - - union { - struct { - bool xa0_24_pendingRumble : 1; - bool xa0_25_rumbling : 1; - bool xa0_26_inWater : 1; - }; - u8 _dummy1 = 0; - }; - + bool xa0_24_pendingRumble : 1; + bool xa0_25_rumbling : 1; + bool xa0_26_inWater : 1; TUniqueId xa2_spindleCamId = kInvalidUniqueId; TUniqueId xa4_pathCamId = kInvalidUniqueId; TUniqueId xa6_camHintId = kInvalidUniqueId; @@ -57,15 +50,8 @@ class CCameraManager { rstl::reserved_vector, 64> xac_cameraHints; rstl::reserved_vector x2b0_inactiveCameraHints; rstl::reserved_vector x334_activeCameraHints; - - union { - struct { - bool x3b8_24_ : 1; - bool x3b8_25_ : 1; - }; - u8 _dummy2; - }; - + bool x3b8_24_ : 1; + bool x3b8_25_ : 1; float x3bc_curFov = 60.f; void SetPathCamera(TUniqueId id, CStateManager& mgr); From 4a3ce8453fc28f1fec08c14d62f116cd0bf789c4 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:03:15 -0400 Subject: [PATCH 04/16] Runtime/Graphics: Replace bitfield unions with constructor initializers --- Runtime/Character/CActorLights.cpp | 22 +++++++------- Runtime/Character/CActorLights.hpp | 28 +++++++----------- Runtime/Character/CAnimData.cpp | 12 ++++++-- Runtime/Character/CAnimData.hpp | 23 ++++++--------- Runtime/Character/CBodyController.cpp | 11 +++++-- Runtime/Character/CBodyController.hpp | 15 ++++------ Runtime/Character/CBodyState.hpp | 41 +++++++++++---------------- Runtime/Character/CBoneTracking.cpp | 4 ++- Runtime/Character/CBoneTracking.hpp | 19 +++++-------- Runtime/Character/CIkChain.hpp | 10 ++----- Runtime/Character/CModelData.cpp | 16 ++++++----- Runtime/Character/CModelData.hpp | 9 ++---- Runtime/Character/CRagDoll.cpp | 14 +++++---- Runtime/Character/CRagDoll.hpp | 17 ++++------- 14 files changed, 110 insertions(+), 131 deletions(-) diff --git a/Runtime/Character/CActorLights.cpp b/Runtime/Character/CActorLights.cpp index 3317c506e..4144aa614 100644 --- a/Runtime/Character/CActorLights.cpp +++ b/Runtime/Character/CActorLights.cpp @@ -18,20 +18,22 @@ s32 CActorLights::sFrameSchedulerCount = 0; CActorLights::CActorLights(u32 areaUpdateFramePeriod, const zeus::CVector3f& actorPosBias, int maxDynamicLights, int maxAreaLights, bool ambientChannelOverflow, bool layer2, bool disableWorldLights, float positionUpdateThreshold) -: x2a8_areaUpdateFramePeriod(areaUpdateFramePeriod) +: x298_24_dirty(true) +, x298_25_castShadows(true) +, x298_26_hasAreaLights(false) +, x298_27_findShadowLight(false) +, x298_28_inArea(!disableWorldLights && maxAreaLights > 0) +, x298_29_ambienceGenerated(ambientChannelOverflow) +, x298_30_layer2(layer2) +, x298_31_disableWorldLights(disableWorldLights) +, x299_24_inBrightLight(true) +, x299_25_useBrightLightLag(false) +, x299_26_ambientOnly(false) +, x2a8_areaUpdateFramePeriod(areaUpdateFramePeriod) , x2ac_actorPosBias(actorPosBias) , x2b8_maxAreaLights(maxAreaLights) , x2bc_maxDynamicLights(maxDynamicLights) , x2cc_actorPositionDeltaUpdateThreshold(positionUpdateThreshold * positionUpdateThreshold) { - x298_24_dirty = true; - x298_25_castShadows = true; - - x298_28_inArea = !disableWorldLights && maxAreaLights > 0; - x298_29_ambienceGenerated = ambientChannelOverflow; - x298_30_layer2 = layer2; - x298_31_disableWorldLights = disableWorldLights; - x299_24_inBrightLight = true; - sFrameSchedulerCount++; sFrameSchedulerCount &= 7; } diff --git a/Runtime/Character/CActorLights.hpp b/Runtime/Character/CActorLights.hpp index a6af5e8bd..4a5044786 100644 --- a/Runtime/Character/CActorLights.hpp +++ b/Runtime/Character/CActorLights.hpp @@ -20,23 +20,17 @@ class CActorLights { std::vector x144_dynamicLights; zeus::CColor x288_ambientColor = zeus::skBlack; TAreaId x294_aid = kInvalidAreaId; - - union { - struct { - bool x298_24_dirty : 1; - bool x298_25_castShadows : 1; - bool x298_26_hasAreaLights : 1; - bool x298_27_findShadowLight : 1; - bool x298_28_inArea : 1; - bool x298_29_ambienceGenerated : 1; - bool x298_30_layer2 : 1; - bool x298_31_disableWorldLights : 1; - bool x299_24_inBrightLight : 1; - bool x299_25_useBrightLightLag : 1; - bool x299_26_ambientOnly : 1; - }; - u16 _dummy = 0; - }; + bool x298_24_dirty : 1; + bool x298_25_castShadows : 1; + bool x298_26_hasAreaLights : 1; + bool x298_27_findShadowLight : 1; + bool x298_28_inArea : 1; + bool x298_29_ambienceGenerated : 1; + bool x298_30_layer2 : 1; + bool x298_31_disableWorldLights : 1; + bool x299_24_inBrightLight : 1; + bool x299_25_useBrightLightLag : 1; + bool x299_26_ambientOnly : 1; bool x29a_findNearestDynamicLights = false; s32 x29c_shadowLightArrIdx = -1; s32 x2a0_shadowLightIdx = -1; diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index f201b064b..111a50726 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -45,9 +45,9 @@ CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAn const std::weak_ptr& ctx, std::shared_ptr animMgr, std::shared_ptr transMgr, TLockedToken charFactory, int drawInstCount) -: x0_charFactory(std::move(charFactory)) +: x0_charFactory(charFactory) , xc_charInfo(character) -, xcc_layoutData(std::move(layout)) +, xcc_layoutData(layout) , xd8_modelData(std::move(model)) , xfc_animCtx(ctx.lock()) , x100_animMgr(std::move(animMgr)) @@ -55,6 +55,14 @@ CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAn , x1fc_transMgr(std::move(transMgr)) , x204_charIdx(charIdx) , x208_defaultAnim(defaultAnim) +, x220_24_animating(false) +, x220_25_loop(false) +, x220_26_aligningPos(false) +, x220_27_(false) +, x220_28_(false) +, x220_29_animationJustStarted(false) +, x220_30_poseBuilt(false) +, x220_31_poseCached(false) , x224_pose(layout->GetSegIdList().GetList().size()) , x2fc_poseBuilder(CLayoutDescription{layout}) , m_drawInstCount(drawInstCount) { diff --git a/Runtime/Character/CAnimData.hpp b/Runtime/Character/CAnimData.hpp index 184874263..ce488f2a2 100644 --- a/Runtime/Character/CAnimData.hpp +++ b/Runtime/Character/CAnimData.hpp @@ -124,21 +124,14 @@ private: u32 x214_passedParticleCount = 0; u32 x218_passedSoundCount = 0; s32 x21c_particleLightIdx = 0; - - union { - u32 x220_flags = 0; - struct { - bool x220_24_animating : 1; - bool x220_25_loop : 1; - bool x220_26_aligningPos : 1; - bool x220_27_ : 1; - bool x220_28_ : 1; - bool x220_29_animationJustStarted : 1; - bool x220_30_poseBuilt : 1; - bool x220_31_poseCached : 1; - }; - }; - + bool x220_24_animating : 1; + bool x220_25_loop : 1; + bool x220_26_aligningPos : 1; + bool x220_27_ : 1; + bool x220_28_ : 1; + bool x220_29_animationJustStarted : 1; + bool x220_30_poseBuilt : 1; + bool x220_31_poseCached : 1; CPoseAsTransforms x224_pose; CHierarchyPoseBuilder x2fc_poseBuilder; diff --git a/Runtime/Character/CBodyController.cpp b/Runtime/Character/CBodyController.cpp index ddd92cf35..94f86a935 100644 --- a/Runtime/Character/CBodyController.cpp +++ b/Runtime/Character/CBodyController.cpp @@ -12,8 +12,15 @@ namespace urde { CBodyController::CBodyController(CActor& actor, float turnSpeed, EBodyType bodyType) -: x0_actor(actor), x2a4_bodyStateInfo(actor, bodyType), x2f4_bodyType(bodyType), x2fc_turnSpeed(turnSpeed) { - x300_28_playDeathAnims = true; +: x0_actor(actor) +, x2a4_bodyStateInfo(actor, bodyType) +, x2f4_bodyType(bodyType) +, x2fc_turnSpeed(turnSpeed) +, x300_24_animationOver(false) +, x300_25_active(false) +, x300_26_frozen(false) +, x300_27_hasBeenFrozen(false) +, x300_28_playDeathAnims(true) { x2a4_bodyStateInfo.x18_bodyController = this; } diff --git a/Runtime/Character/CBodyController.hpp b/Runtime/Character/CBodyController.hpp index ac9839dae..a50d2663d 100644 --- a/Runtime/Character/CBodyController.hpp +++ b/Runtime/Character/CBodyController.hpp @@ -28,16 +28,11 @@ class CBodyController { EBodyType x2f4_bodyType; s32 x2f8_curAnim = -1; float x2fc_turnSpeed; - union { - struct { - bool x300_24_animationOver : 1; - bool x300_25_active : 1; - bool x300_26_frozen : 1; - bool x300_27_hasBeenFrozen : 1; - bool x300_28_playDeathAnims : 1; - }; - u32 _dummy = 0; - }; + bool x300_24_animationOver : 1; + bool x300_25_active : 1; + bool x300_26_frozen : 1; + bool x300_27_hasBeenFrozen : 1; + bool x300_28_playDeathAnims : 1; float x304_intoFreezeDur = 0.f; float x308_frozenDur = 0.f; float x30c_breakoutDur = 0.f; diff --git a/Runtime/Character/CBodyState.hpp b/Runtime/Character/CBodyState.hpp index 9dfce3539..17b83075a 100644 --- a/Runtime/Character/CBodyState.hpp +++ b/Runtime/Character/CBodyState.hpp @@ -202,22 +202,23 @@ class CBSJump : public CBodyState { zeus::CVector3f xc_waypoint1; zeus::CVector3f x18_velocity; zeus::CVector3f x24_waypoint2; - union { - struct { - bool x30_24_bodyForceSet : 1; - bool x30_25_wallJump : 1; - bool x30_26_wallBounceRight : 1; - bool x30_27_wallBounceComplete : 1; - bool x30_28_startInJumpLoop : 1; - }; - u32 _dummy = 0; - }; + bool x30_24_bodyForceSet : 1; + bool x30_25_wallJump : 1; + bool x30_26_wallBounceRight : 1; + bool x30_27_wallBounceComplete : 1; + bool x30_28_startInJumpLoop : 1; pas::EAnimationState GetBodyStateTransition(float dt, const CBodyController& bc) const; bool CheckForWallJump(CBodyController& bc, CStateManager& mgr); void CheckForLand(CBodyController& bc, CStateManager& mgr); void PlayJumpLoop(CStateManager& mgr, CBodyController& bc); public: + CBSJump() + : x30_24_bodyForceSet(false) + , x30_25_wallJump(false) + , x30_26_wallBounceRight(false) + , x30_27_wallBounceComplete(false) + , x30_28_startInJumpLoop(false) {} bool IsMoving() const override { return true; } bool ApplyHeadTracking() const override { return false; } bool CanShoot() const override; @@ -277,17 +278,13 @@ public: }; class CBSScripted : public CBodyState { - union { - struct { - bool x4_24_loopAnim : 1; - bool x4_25_timedLoop : 1; - }; - u32 _dummy = 0; - }; + bool x4_24_loopAnim : 1; + bool x4_25_timedLoop : 1; float x8_remTime = 0.f; pas::EAnimationState GetBodyStateTransition(float dt, const CBodyController& bc) const; public: + CBSScripted() : x4_24_loopAnim(false), x4_25_timedLoop(false) {} bool ApplyHeadTracking() const override { return false; } void Start(CBodyController& bc, CStateManager& mgr) override; pas::EAnimationState UpdateBody(float dt, CBodyController& bc, CStateManager& mgr) override; @@ -313,13 +310,8 @@ class CBSWallHang : public CBodyState { pas::EWallHangState x4_state = pas::EWallHangState::Invalid; TUniqueId x8_wpId = kInvalidUniqueId; zeus::CVector3f xc_launchVel; - union { - struct { - bool x18_24_launched : 1; - bool x18_25_needsExit : 1; - }; - u32 _dummy = 0; - }; + bool x18_24_launched : 1; + bool x18_25_needsExit : 1; pas::EAnimationState GetBodyStateTransition(float dt, const CBodyController& bc) const; void FixInPlace(CBodyController& bc); bool CheckForLand(CBodyController& bc, CStateManager& mgr); @@ -327,6 +319,7 @@ class CBSWallHang : public CBodyState { void SetLaunchVelocity(CBodyController& bc); public: + CBSWallHang() : x18_24_launched(false), x18_25_needsExit(false) {} bool IsMoving() const override { return true; } bool CanShoot() const override { return x4_state == pas::EWallHangState::WallHang; } bool IsInAir(const CBodyController& bc) const override; diff --git a/Runtime/Character/CBoneTracking.cpp b/Runtime/Character/CBoneTracking.cpp index 0814f4be2..b6afda934 100644 --- a/Runtime/Character/CBoneTracking.cpp +++ b/Runtime/Character/CBoneTracking.cpp @@ -15,6 +15,8 @@ CBoneTracking::CBoneTracking(const CAnimData& animData, std::string_view bone, : x14_segId(animData.GetCharLayoutInfo().GetSegIdFromString(bone)) , x1c_maxTrackingAngle(maxTrackingAngle) , x20_angSpeed(angSpeed) +, x36_24_active(false) +, x36_25_hasTrackedRotation(false) , x36_26_noParent(True(flags & EBoneTrackingFlags::NoParent)) , x36_27_noParentOrigin(True(flags & EBoneTrackingFlags::NoParentOrigin)) , x36_28_noHorizontalAim(True(flags & EBoneTrackingFlags::NoHorizontalAim)) @@ -107,4 +109,4 @@ void CBoneTracking::UnsetTarget() { x34_target = kInvalidUniqueId; } void CBoneTracking::SetTargetPosition(const zeus::CVector3f& targetPos) { x24_targetPosition = targetPos; } void CBoneTracking::SetNoHorizontalAim(bool b) { x36_28_noHorizontalAim = b; } -} // namespace urde \ No newline at end of file +} // namespace urde diff --git a/Runtime/Character/CBoneTracking.hpp b/Runtime/Character/CBoneTracking.hpp index 148c8de06..94d9456aa 100644 --- a/Runtime/Character/CBoneTracking.hpp +++ b/Runtime/Character/CBoneTracking.hpp @@ -33,17 +33,12 @@ class CBoneTracking { float x20_angSpeed; std::optional x24_targetPosition; TUniqueId x34_target = kInvalidUniqueId; - union { - struct { - bool x36_24_active : 1; - bool x36_25_hasTrackedRotation : 1; - bool x36_26_noParent : 1; - bool x36_27_noParentOrigin : 1; - bool x36_28_noHorizontalAim : 1; - bool x36_29_parentIk : 1; - }; - u32 _dummy = 0; - }; + bool x36_24_active : 1; + bool x36_25_hasTrackedRotation : 1; + bool x36_26_noParent : 1; + bool x36_27_noParentOrigin : 1; + bool x36_28_noHorizontalAim : 1; + bool x36_29_parentIk : 1; public: CBoneTracking(const CAnimData& animData, std::string_view bone, @@ -60,4 +55,4 @@ public: void SetNoHorizontalAim(bool b); }; -} // namespace urde \ No newline at end of file +} // namespace urde diff --git a/Runtime/Character/CIkChain.hpp b/Runtime/Character/CIkChain.hpp index 4df48d3b2..c572dc836 100644 --- a/Runtime/Character/CIkChain.hpp +++ b/Runtime/Character/CIkChain.hpp @@ -21,16 +21,10 @@ class CIkChain { zeus::CQuaternion x24_holdRot; zeus::CVector3f x34_holdPos; float x40_time = 0.f; - - union { - struct { - bool x44_24_activated : 1; - }; - u32 x44_dummy = 0; - }; + bool x44_24_activated : 1; public: - CIkChain() = default; + CIkChain() : x44_24_activated(false) {} bool GetActive() const { return x44_24_activated; } void Update(float); diff --git a/Runtime/Character/CModelData.cpp b/Runtime/Character/CModelData.cpp index b5ee3efda..98c0119be 100644 --- a/Runtime/Character/CModelData.cpp +++ b/Runtime/Character/CModelData.cpp @@ -25,14 +25,16 @@ CModelData::~CModelData() = default; CModelData::CModelData() {} CModelData CModelData::CModelDataNull() { return CModelData(); } -CModelData::CModelData(const CStaticRes& res, int instCount) : x0_scale(res.GetScale()), m_drawInstCount(instCount) { +CModelData::CModelData(const CStaticRes& res, int instCount) +: x0_scale(res.GetScale()), x14_24_renderSorted(false), x14_25_sortThermal(false), m_drawInstCount(instCount) { x1c_normalModel = g_SimplePool->GetObj({SBIG('CMDL'), res.GetId()}); if (!x1c_normalModel) Log.report(logvisor::Fatal, fmt("unable to find CMDL {}"), res.GetId()); m_normalModelInst = x1c_normalModel->MakeNewInstance(0, instCount); } -CModelData::CModelData(const CAnimRes& res, int instCount) : x0_scale(res.GetScale()), m_drawInstCount(instCount) { +CModelData::CModelData(const CAnimRes& res, int instCount) +: x0_scale(res.GetScale()), x14_24_renderSorted(false), x14_25_sortThermal(false), m_drawInstCount(instCount) { TToken factory = g_CharFactoryBuilder->GetFactory(res); x10_animData = factory->CreateCharacter(res.GetCharacterNodeId(), res.CanLoop(), factory, res.GetDefaultAnim(), instCount); @@ -76,13 +78,13 @@ bool CModelData::IsLoaded(int shaderIdx) const { } u32 CModelData::GetNumMaterialSets() const { - if (x10_animData) - return x10_animData->GetModelData()->GetModel()->GetNumMaterialSets(); + if (x10_animData) + return x10_animData->GetModelData()->GetModel()->GetNumMaterialSets(); - if (x1c_normalModel) - return x1c_normalModel->GetNumMaterialSets(); + if (x1c_normalModel) + return x1c_normalModel->GetNumMaterialSets(); - return 1; + return 1; } CModelData::EWhichModel CModelData::GetRenderingModel(const CStateManager& stateMgr) { diff --git a/Runtime/Character/CModelData.hpp b/Runtime/Character/CModelData.hpp index ab746220f..57e1680c7 100644 --- a/Runtime/Character/CModelData.hpp +++ b/Runtime/Character/CModelData.hpp @@ -62,13 +62,8 @@ class CModelData { zeus::CVector3f x0_scale; bool xc_ = false; std::unique_ptr x10_animData; - union { - struct { - bool x14_24_renderSorted : 1; - bool x14_25_sortThermal : 1; - }; - u32 _flags = 0; - }; + bool x14_24_renderSorted : 1; + bool x14_25_sortThermal : 1; zeus::CColor x18_ambientColor; TLockedToken x1c_normalModel; diff --git a/Runtime/Character/CRagDoll.cpp b/Runtime/Character/CRagDoll.cpp index 77f6a7f43..0ca6d8b0a 100644 --- a/Runtime/Character/CRagDoll.cpp +++ b/Runtime/Character/CRagDoll.cpp @@ -59,11 +59,15 @@ void CRagDoll::CRagDollPlaneConstraint::Update() { } CRagDoll::CRagDoll(float normalGravity, float floatingGravity, float overTime, u32 flags) -: x44_normalGravity(normalGravity), x48_floatingGravity(floatingGravity), x50_overTimer(overTime) { - x68_27_continueSmallMovements = bool(flags & 0x1); - x68_28_noOverTimer = bool(flags & 0x2); - x68_29_noAiCollision = bool(flags & 0x4); -} +: x44_normalGravity(normalGravity) +, x48_floatingGravity(floatingGravity) +, x50_overTimer(overTime) +, x68_24_prevMovingSlowly(false) +, x68_25_over(false) +, x68_26_primed(false) +, x68_27_continueSmallMovements(bool(flags & 0x1)) +, x68_28_noOverTimer(bool(flags & 0x2)) +, x68_29_noAiCollision(bool(flags & 0x4)) {} void CRagDoll::AccumulateForces(float dt, float waterTop) { float fps = 1.f / dt; diff --git a/Runtime/Character/CRagDoll.hpp b/Runtime/Character/CRagDoll.hpp index 678861df7..3f383e68b 100644 --- a/Runtime/Character/CRagDoll.hpp +++ b/Runtime/Character/CRagDoll.hpp @@ -94,17 +94,12 @@ protected: float x54_impactVel = 0.f; zeus::CVector3f x58_averageVel; float x64_angTimer = 0.f; - union { - struct { - bool x68_24_prevMovingSlowly : 1; - bool x68_25_over : 1; - bool x68_26_primed : 1; - bool x68_27_continueSmallMovements : 1; - bool x68_28_noOverTimer : 1; - bool x68_29_noAiCollision : 1; - }; - u32 _dummy = 0; - }; + bool x68_24_prevMovingSlowly : 1; + bool x68_25_over : 1; + bool x68_26_primed : 1; + bool x68_27_continueSmallMovements : 1; + bool x68_28_noOverTimer : 1; + bool x68_29_noAiCollision : 1; void AccumulateForces(float dt, float waterTop); void SetNumParticles(int num) { x4_particles.reserve(num); } void AddParticle(CSegId id, const zeus::CVector3f& prevPos, const zeus::CVector3f& curPos, float radius); From f83b970e75027952a2aa315578705a52a5fc484f Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:03:24 -0400 Subject: [PATCH 05/16] Runtime/Collision: Replace bitfield unions with constructor initializers --- Runtime/Collision/CMetroidAreaCollider.hpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Runtime/Collision/CMetroidAreaCollider.hpp b/Runtime/Collision/CMetroidAreaCollider.hpp index 7f34f557c..97a0a9e6d 100644 --- a/Runtime/Collision/CMetroidAreaCollider.hpp +++ b/Runtime/Collision/CMetroidAreaCollider.hpp @@ -173,16 +173,12 @@ public: class CAreaCollisionCache { zeus::CAABox x0_aabb; rstl::reserved_vector x18_leafCaches; - union { - struct { - bool x1b40_24_leafOverflow : 1; - bool x1b40_25_cacheOverflow : 1; - }; - u32 _dummy = 0; - }; + bool x1b40_24_leafOverflow : 1; + bool x1b40_25_cacheOverflow : 1; public: - explicit CAreaCollisionCache(const zeus::CAABox& aabb) : x0_aabb(aabb) {} + explicit CAreaCollisionCache(const zeus::CAABox& aabb) + : x0_aabb(aabb), x1b40_24_leafOverflow(false), x1b40_25_cacheOverflow(false) {} void ClearCache(); const zeus::CAABox& GetCacheBounds() const { return x0_aabb; } void SetCacheBounds(const zeus::CAABox& aabb) { x0_aabb = aabb; } From 232823ae697657cdb4651e4a9e03a0b9951dde7d Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:03:31 -0400 Subject: [PATCH 06/16] Runtime/Graphics: Replace bitfield unions with constructor initializers --- Runtime/Graphics/CBooRenderer.cpp | 11 ++++++++++- Runtime/Graphics/CBooRenderer.hpp | 23 +++++++++-------------- Runtime/Graphics/CMoviePlayer.cpp | 10 ++++++---- Runtime/Graphics/CMoviePlayer.hpp | 14 ++++---------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index a0f9b4f14..4b23e81da 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -681,7 +681,16 @@ void CBooRenderer::LoadBallFade() { } CBooRenderer::CBooRenderer(IObjectStore& store, IFactory& resFac) -: x8_factory(resFac), xc_store(store), x2a8_thermalRand(20) { +: x8_factory(resFac), xc_store(store), x2a8_thermalRand(20) +, x318_24_refectionDirty(false) +, x318_25_drawWireframe(false) +, x318_26_requestRGBA6(false) +, x318_27_currentRGBA6(false) +, x318_28_disableFog(false) +, x318_29_thermalVisor(false) +, x318_30_inAreaDraw(false) +, x318_31_persistRGBA6(false) +, m_thermalHotPass(false) { g_Renderer = this; xee_24_ = true; diff --git a/Runtime/Graphics/CBooRenderer.hpp b/Runtime/Graphics/CBooRenderer.hpp index 7c3016297..81e4e47cb 100644 --- a/Runtime/Graphics/CBooRenderer.hpp +++ b/Runtime/Graphics/CBooRenderer.hpp @@ -152,20 +152,15 @@ class CBooRenderer final : public IRenderer { // std::unique_ptr x314_phazonSuitMask; CPhazonSuitFilter m_phazonSuitFilter; - union { - struct { - bool x318_24_refectionDirty : 1; - bool x318_25_drawWireframe : 1; - bool x318_26_requestRGBA6 : 1; - bool x318_27_currentRGBA6 : 1; - bool x318_28_disableFog : 1; - bool x318_29_thermalVisor : 1; - bool x318_30_inAreaDraw : 1; - bool x318_31_persistRGBA6 : 1; - bool m_thermalHotPass : 1; - }; - u16 dummy = 0; - }; + bool x318_24_refectionDirty : 1; + bool x318_25_drawWireframe : 1; + bool x318_26_requestRGBA6 : 1; + bool x318_27_currentRGBA6 : 1; + bool x318_28_disableFog : 1; + bool x318_29_thermalVisor : 1; + bool x318_30_inAreaDraw : 1; + bool x318_31_persistRGBA6 : 1; + bool m_thermalHotPass : 1; void GenerateFogVolumeRampTex(boo::IGraphicsDataFactory::Context& ctx); void GenerateSphereRampTex(boo::IGraphicsDataFactory::Context& ctx); diff --git a/Runtime/Graphics/CMoviePlayer.cpp b/Runtime/Graphics/CMoviePlayer.cpp index f4af28744..6771971e0 100644 --- a/Runtime/Graphics/CMoviePlayer.cpp +++ b/Runtime/Graphics/CMoviePlayer.cpp @@ -140,10 +140,12 @@ u32 CMoviePlayer::THPAudioDecode(s16* buffer, const u8* audioFrame, bool stereo) } CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bool deinterlace) -: CDvdFile(path), xec_preLoadSeconds(preLoadSeconds) { - xf4_24_loop = loop; - m_deinterlace = deinterlace; - +: CDvdFile(path) +, xec_preLoadSeconds(preLoadSeconds) +, xf4_24_loop(loop) +, xf4_25_hasAudio(false) +, xf4_26_fieldFlip(false) +, m_deinterlace(deinterlace) { /* Read THP header information */ u8 buf[64]; SyncRead(buf, 64); diff --git a/Runtime/Graphics/CMoviePlayer.hpp b/Runtime/Graphics/CMoviePlayer.hpp index f32d47fe1..7d74267cf 100644 --- a/Runtime/Graphics/CMoviePlayer.hpp +++ b/Runtime/Graphics/CMoviePlayer.hpp @@ -99,21 +99,15 @@ private: float xe8_curSeconds = 0.f; float xec_preLoadSeconds; u32 xf0_preLoadFrames = 0; + bool xf4_24_loop : 1; + bool xf4_25_hasAudio : 1; + bool xf4_26_fieldFlip : 1; + bool m_deinterlace : 1; u32 xf8_ = 0; u32 xfc_fieldIndex = 0; std::unique_ptr m_yuvBuf; - union { - u32 m_dummy = 0; - struct { - bool xf4_24_loop : 1; - bool xf4_25_hasAudio : 1; - bool xf4_26_fieldFlip : 1; - bool m_deinterlace : 1; - }; - }; - specter::View::ViewBlock m_viewVertBlock; boo::ObjToken m_blockBuf; boo::ObjToken m_vertBuf; From e38a7f97bdd3ba4df032d7cdf4c6856c979da352 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:11:10 -0400 Subject: [PATCH 07/16] Runtime/GuiSys: Replace bitfield unions with constructor initializers --- Runtime/GuiSys/CErrorOutputWindow.cpp | 1 + Runtime/GuiSys/CErrorOutputWindow.hpp | 15 +++++---------- Runtime/GuiSys/CGuiSliderGroup.cpp | 5 ++++- Runtime/GuiSys/CGuiSliderGroup.hpp | 11 +++-------- Runtime/GuiSys/CHudEnergyInterface.cpp | 13 ++++++------- Runtime/GuiSys/CHudEnergyInterface.hpp | 13 ++++--------- Runtime/GuiSys/CHudFreeLookInterface.cpp | 12 ++++++------ Runtime/GuiSys/CHudFreeLookInterface.hpp | 15 +++++---------- Runtime/GuiSys/CHudHelmetInterface.cpp | 11 ++++++----- Runtime/GuiSys/CHudHelmetInterface.hpp | 15 +++++---------- Runtime/GuiSys/CHudMissileInterface.cpp | 9 ++++----- Runtime/GuiSys/CHudMissileInterface.hpp | 15 +++++---------- 12 files changed, 54 insertions(+), 81 deletions(-) diff --git a/Runtime/GuiSys/CErrorOutputWindow.cpp b/Runtime/GuiSys/CErrorOutputWindow.cpp index 04596dd20..aae8942d9 100644 --- a/Runtime/GuiSys/CErrorOutputWindow.cpp +++ b/Runtime/GuiSys/CErrorOutputWindow.cpp @@ -5,6 +5,7 @@ namespace urde { CErrorOutputWindow::CErrorOutputWindow(bool flag) : CIOWin("Error Output Window") { + x18_24_ = false; x18_25_ = true; x18_26_ = true; x18_27_ = true; diff --git a/Runtime/GuiSys/CErrorOutputWindow.hpp b/Runtime/GuiSys/CErrorOutputWindow.hpp index 85b2231d6..b6088a9ba 100644 --- a/Runtime/GuiSys/CErrorOutputWindow.hpp +++ b/Runtime/GuiSys/CErrorOutputWindow.hpp @@ -11,16 +11,11 @@ public: private: State x14_state = State::Zero; - union { - struct { - bool x18_24_; - bool x18_25_; - bool x18_26_; - bool x18_27_; - bool x18_28_; - }; - u16 dummy = 0; - }; + bool x18_24_; + bool x18_25_; + bool x18_26_; + bool x18_27_; + bool x18_28_; const wchar_t* x1c_msg; public: diff --git a/Runtime/GuiSys/CGuiSliderGroup.cpp b/Runtime/GuiSys/CGuiSliderGroup.cpp index bdb3e49d7..74bbe0ff2 100644 --- a/Runtime/GuiSys/CGuiSliderGroup.cpp +++ b/Runtime/GuiSys/CGuiSliderGroup.cpp @@ -11,7 +11,10 @@ CGuiSliderGroup::CGuiSliderGroup(const CGuiWidgetParms& parms, float min, float , xbc_maxVal(max) , xc0_roundedCurVal(def) , xc4_curVal(def) -, xc8_increment(inc) {} +, xc8_increment(inc) +, xf4_24_inputPending(false) +, m_mouseInside(false) +, m_mouseDown(false) {} void CGuiSliderGroup::SetSelectionChangedCallback(std::function&& func) { xd8_changeCallback = std::move(func); diff --git a/Runtime/GuiSys/CGuiSliderGroup.hpp b/Runtime/GuiSys/CGuiSliderGroup.hpp index 3c13f783b..da3578d24 100644 --- a/Runtime/GuiSys/CGuiSliderGroup.hpp +++ b/Runtime/GuiSys/CGuiSliderGroup.hpp @@ -22,14 +22,9 @@ private: std::array xcc_sliderRangeWidgets{}; std::function xd8_changeCallback; EState xf0_state = EState::None; - union { - struct { - bool xf4_24_inputPending : 1; - mutable bool m_mouseInside : 1; - bool m_mouseDown : 1; - }; - u32 _dummy = 0; - }; + bool xf4_24_inputPending : 1; + mutable bool m_mouseInside : 1; + bool m_mouseDown : 1; mutable float m_mouseT = 0.f; diff --git a/Runtime/GuiSys/CHudEnergyInterface.cpp b/Runtime/GuiSys/CHudEnergyInterface.cpp index e664f2bed..8109e51de 100644 --- a/Runtime/GuiSys/CHudEnergyInterface.cpp +++ b/Runtime/GuiSys/CHudEnergyInterface.cpp @@ -27,12 +27,11 @@ CHudEnergyInterface::CHudEnergyInterface(CGuiFrame& selHud, float tankEnergy, in : x0_hudType(hudType) , xc_tankEnergy(tankEnergy) , x10_totalEnergyTanks(totalEnergyTanks) -, x14_numTanksFilled(numTanksFilled) { - x1c_24_ = true; - x1c_25_ = true; - x1c_26_barDirty = true; - x1c_27_energyLow = energyLow; - +, x14_numTanksFilled(numTanksFilled) +, x1c_24_(true) +, x1c_25_(true) +, x1c_26_barDirty(true) +, x1c_27_energyLow(energyLow) { x20_textpane_energydigits = static_cast(selHud.FindWidget("textpane_energydigits")); x24_meter_energytanks = static_cast(selHud.FindWidget("meter_energytanks")); x28_textpane_energywarning = static_cast(selHud.FindWidget("textpane_energywarning")); @@ -100,7 +99,7 @@ void CHudEnergyInterface::Update(float dt, float energyLowPulse) { x1c_26_barDirty = false; x18_cachedBarEnergy = x2c_energybart01_energybar->GetFilledEnergy(); std::string string = - fmt::format(fmt("{:02d}"), int(std::fmod(x18_cachedBarEnergy, CPlayerState::GetEnergyTankCapacity()))); + fmt::format(fmt("{:02d}"), int(std::fmod(x18_cachedBarEnergy, CPlayerState::GetEnergyTankCapacity()))); x20_textpane_energydigits->TextSupport().SetText(string); } diff --git a/Runtime/GuiSys/CHudEnergyInterface.hpp b/Runtime/GuiSys/CHudEnergyInterface.hpp index 2c2fda089..7ad71557b 100644 --- a/Runtime/GuiSys/CHudEnergyInterface.hpp +++ b/Runtime/GuiSys/CHudEnergyInterface.hpp @@ -19,15 +19,10 @@ class CHudEnergyInterface { int x10_totalEnergyTanks; int x14_numTanksFilled; float x18_cachedBarEnergy = 0.f; - union { - struct { - bool x1c_24_ : 1; - bool x1c_25_ : 1; - bool x1c_26_barDirty : 1; - bool x1c_27_energyLow : 1; - }; - u16 _dummy = 0; - }; + bool x1c_24_ : 1; + bool x1c_25_ : 1; + bool x1c_26_barDirty : 1; + bool x1c_27_energyLow : 1; CGuiTextPane* x20_textpane_energydigits; CAuiMeter* x24_meter_energytanks; CGuiTextPane* x28_textpane_energywarning; diff --git a/Runtime/GuiSys/CHudFreeLookInterface.cpp b/Runtime/GuiSys/CHudFreeLookInterface.cpp index 75d86e18b..94a6395f5 100644 --- a/Runtime/GuiSys/CHudFreeLookInterface.cpp +++ b/Runtime/GuiSys/CHudFreeLookInterface.cpp @@ -8,12 +8,12 @@ namespace urde { CHudFreeLookInterface::CHudFreeLookInterface(CGuiFrame& selHud, EHudType hudType, bool inFreeLook, bool lookControlHeld, bool lockedOnObj) -: x4_hudType(hudType) { - x70_24_inFreeLook = inFreeLook; - x70_25_lookControlHeld = lookControlHeld; - x70_26_lockedOnObj = lockedOnObj; - x70_27_visibleDebug = true; - x70_28_visibleGame = true; +: x4_hudType(hudType) +, x70_24_inFreeLook(inFreeLook) +, x70_25_lookControlHeld(lookControlHeld) +, x70_26_lockedOnObj(lockedOnObj) +, x70_27_visibleDebug(true) +, x70_28_visibleGame(true) { x6c_lockOnInterp = (lockedOnObj && hudType == EHudType::Scan) ? 0.f : 1.f; x74_basewidget_freelookleft = selHud.FindWidget("basewidget_freelookleft"); diff --git a/Runtime/GuiSys/CHudFreeLookInterface.hpp b/Runtime/GuiSys/CHudFreeLookInterface.hpp index fedc6931b..d9d41bea1 100644 --- a/Runtime/GuiSys/CHudFreeLookInterface.hpp +++ b/Runtime/GuiSys/CHudFreeLookInterface.hpp @@ -24,16 +24,11 @@ class CHudFreeLookInterface : public IFreeLookInterface { zeus::CTransform x38_freeLookRightXf; float x68_freeLookInterp = 0.f; float x6c_lockOnInterp; - union { - struct { - bool x70_24_inFreeLook : 1; - bool x70_25_lookControlHeld : 1; - bool x70_26_lockedOnObj : 1; - bool x70_27_visibleDebug : 1; - bool x70_28_visibleGame : 1; - }; - u16 _dummy = 0; - }; + bool x70_24_inFreeLook : 1; + bool x70_25_lookControlHeld : 1; + bool x70_26_lockedOnObj : 1; + bool x70_27_visibleDebug : 1; + bool x70_28_visibleGame : 1; CGuiWidget* x74_basewidget_freelookleft; CGuiModel* x78_model_shieldleft; CGuiModel* x7c_model_freelookleft; diff --git a/Runtime/GuiSys/CHudHelmetInterface.cpp b/Runtime/GuiSys/CHudHelmetInterface.cpp index 963ab114d..a9a915e52 100644 --- a/Runtime/GuiSys/CHudHelmetInterface.cpp +++ b/Runtime/GuiSys/CHudHelmetInterface.cpp @@ -7,11 +7,12 @@ namespace urde { -CHudHelmetInterface::CHudHelmetInterface(CGuiFrame& helmetFrame) { - x3c_24_helmetVisibleDebug = true; - x3c_25_helmetVisibleGame = true; - x3c_26_glowVisibleDebug = true; - x3c_27_glowVisibleGame = true; +CHudHelmetInterface::CHudHelmetInterface(CGuiFrame& helmetFrame) +: x3c_24_helmetVisibleDebug(true) +, x3c_25_helmetVisibleGame(true) +, x3c_26_glowVisibleDebug(true) +, x3c_27_glowVisibleGame(true) +, x3c_28_hudLagDirty(false) { x40_camera = helmetFrame.GetFrameCamera(); x44_BaseWidget_Pivot = helmetFrame.FindWidget("BaseWidget_Pivot"); x48_BaseWidget_Helmet = helmetFrame.FindWidget("BaseWidget_Helmet"); diff --git a/Runtime/GuiSys/CHudHelmetInterface.hpp b/Runtime/GuiSys/CHudHelmetInterface.hpp index 534f02fce..0046f540c 100644 --- a/Runtime/GuiSys/CHudHelmetInterface.hpp +++ b/Runtime/GuiSys/CHudHelmetInterface.hpp @@ -12,16 +12,11 @@ class CHudHelmetInterface { zeus::CMatrix3f x0_hudLagRotation; zeus::CVector3f x24_pivotPosition; zeus::CVector3f x30_hudLagPosition; - union { - struct { - bool x3c_24_helmetVisibleDebug : 1; - bool x3c_25_helmetVisibleGame : 1; - bool x3c_26_glowVisibleDebug : 1; - bool x3c_27_glowVisibleGame : 1; - bool x3c_28_hudLagDirty : 1; - }; - u16 _dummy = 0; - }; + bool x3c_24_helmetVisibleDebug : 1; + bool x3c_25_helmetVisibleGame : 1; + bool x3c_26_glowVisibleDebug : 1; + bool x3c_27_glowVisibleGame : 1; + bool x3c_28_hudLagDirty : 1; CGuiCamera* x40_camera; CGuiWidget* x44_BaseWidget_Pivot; CGuiWidget* x48_BaseWidget_Helmet; diff --git a/Runtime/GuiSys/CHudMissileInterface.cpp b/Runtime/GuiSys/CHudMissileInterface.cpp index 36b900a22..6e42b974e 100644 --- a/Runtime/GuiSys/CHudMissileInterface.cpp +++ b/Runtime/GuiSys/CHudMissileInterface.cpp @@ -26,11 +26,10 @@ CHudMissileInterface::CHudMissileInterface(CGuiFrame& selHud, int missileCapacit : x0_hudType(hudType) , x4_missileCapacity(missileCapacity) , x8_numMissles(numMissiles) -, x4c_chargeBeamFactor(chargeFactor) { - x58_24_missilesActive = missilesActive; - x58_25_visibleDebug = true; - x58_26_visibleGame = true; - +, x4c_chargeBeamFactor(chargeFactor) +, x58_24_missilesActive(missilesActive) +, x58_25_visibleDebug(true) +, x58_26_visibleGame(true) { x5c_basewidget_missileicon = selHud.FindWidget("basewidget_missileicon"); x60_textpane_missiledigits = static_cast(selHud.FindWidget("textpane_missiledigits")); x64_energybart01_missilebar = static_cast(selHud.FindWidget("energybart01_missilebar")); diff --git a/Runtime/GuiSys/CHudMissileInterface.hpp b/Runtime/GuiSys/CHudMissileInterface.hpp index df21193ec..da8753dfa 100644 --- a/Runtime/GuiSys/CHudMissileInterface.hpp +++ b/Runtime/GuiSys/CHudMissileInterface.hpp @@ -26,16 +26,11 @@ class CHudMissileInterface { float x4c_chargeBeamFactor; float x50_missileIconAltDeplete = 0.f; float x54_missileIconIncrement = 0.f; - union { - struct { - bool x58_24_missilesActive : 1; - bool x58_25_visibleDebug : 1; - bool x58_26_visibleGame : 1; - bool x58_27_hasArrows : 1; - bool x58_28_notXRay : 1; - }; - u16 _dummy = 0; - }; + bool x58_24_missilesActive : 1; + bool x58_25_visibleDebug : 1; + bool x58_26_visibleGame : 1; + bool x58_27_hasArrows : 1; + bool x58_28_notXRay : 1; CGuiWidget* x5c_basewidget_missileicon; CGuiTextPane* x60_textpane_missiledigits; CAuiEnergyBarT01* x64_energybart01_missilebar; From d23e76db541710bbb8787920803f5e863bf8fc8e Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:12:46 -0400 Subject: [PATCH 08/16] Runtime/Input: Replace bitfield unions with constructor initializers --- Runtime/Input/CRumbleVoice.hpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Runtime/Input/CRumbleVoice.hpp b/Runtime/Input/CRumbleVoice.hpp index 719aab552..b0dd7978a 100644 --- a/Runtime/Input/CRumbleVoice.hpp +++ b/Runtime/Input/CRumbleVoice.hpp @@ -32,15 +32,10 @@ struct SAdsrData { float xc_decayDur = 0.f; float x10_sustainGain = 0.f; float x14_releaseDur = 0.f; - union { - struct { - bool x18_24_hasSustain : 1; - bool x18_25_autoRelease : 1; - }; - u32 dummy = 0; - }; + bool x18_24_hasSustain : 1; + bool x18_25_autoRelease : 1; - constexpr SAdsrData() noexcept { x18_24_hasSustain = false; x18_25_autoRelease = false; }; + constexpr SAdsrData() noexcept : x18_24_hasSustain(false), x18_25_autoRelease(false) {} constexpr SAdsrData(float attackGain, float autoReleaseDur, float attackDur, float decayDur, float sustainGain, float releaseDur, bool hasSustain, bool autoRelease) noexcept : x0_attackGain(attackGain) @@ -48,10 +43,9 @@ struct SAdsrData { , x8_attackDur(attackDur) , xc_decayDur(decayDur) , x10_sustainGain(sustainGain) - , x14_releaseDur(releaseDur) { - x18_24_hasSustain = hasSustain; - x18_25_autoRelease = autoRelease; - } + , x14_releaseDur(releaseDur) + , x18_24_hasSustain(hasSustain) + , x18_25_autoRelease(autoRelease) {} }; struct SAdsrDelta { From 402e45ecb52955f4cca796398a003b5aa764f2db Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:25:40 -0400 Subject: [PATCH 09/16] Runtime/MP1: Replace bitfield unions with constructor initializers --- Runtime/MP1/CFrontEndUI.cpp | 3 +-- Runtime/MP1/CFrontEndUI.hpp | 9 ++------- Runtime/MP1/CInGameGuiManager.cpp | 9 +++++---- Runtime/MP1/CInGameGuiManager.hpp | 14 ++++---------- Runtime/MP1/CLogBookScreen.cpp | 6 ++++-- Runtime/MP1/CLogBookScreen.hpp | 22 +++++++++------------ Runtime/MP1/CMFGame.cpp | 14 +++++++++----- Runtime/MP1/CMFGame.hpp | 19 ++++-------------- Runtime/MP1/CPauseScreenBase.cpp | 19 +++++++++++++++--- Runtime/MP1/CPauseScreenBase.hpp | 32 ++++++++++++++----------------- Runtime/MP1/CPauseScreenBlur.cpp | 5 ++--- Runtime/MP1/CPauseScreenBlur.hpp | 10 +++------- Runtime/MP1/CPlayMovie.cpp | 8 +++++++- Runtime/MP1/CPlayMovie.hpp | 14 +++++--------- Runtime/MP1/CSamusDoll.cpp | 12 +++++++++--- Runtime/MP1/CSamusDoll.hpp | 21 ++++++++------------ Runtime/MP1/CSamusHud.cpp | 6 ++++-- Runtime/MP1/CSamusHud.hpp | 15 ++++----------- Runtime/MP1/CSlideShow.cpp | 20 +++++++++++++------ Runtime/MP1/CSlideShow.hpp | 24 +++++++++-------------- Runtime/MP1/MP1.cpp | 12 +++++++++++- Runtime/MP1/MP1.hpp | 23 +++++++++------------- 22 files changed, 153 insertions(+), 164 deletions(-) diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index 6fedaf6f3..9da2e65db 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -1412,10 +1412,9 @@ void CFrontEndUI::SNesEmulatorFrame::Draw(CSaveGameScreen* saveUi) const { } } -CFrontEndUI::SOptionsFrontEndFrame::SOptionsFrontEndFrame() { +CFrontEndUI::SOptionsFrontEndFrame::SOptionsFrontEndFrame() : x134_24_visible(true), x134_25_exitOptions(false) { x4_frme = g_SimplePool->GetObj("FRME_OptionsFrontEnd"); x10_pauseScreen = g_SimplePool->GetObj("STRG_PauseScreen"); - x134_24_visible = true; } void CFrontEndUI::SOptionsFrontEndFrame::DoSliderChange(CGuiSliderGroup* caller, float value) { diff --git a/Runtime/MP1/CFrontEndUI.hpp b/Runtime/MP1/CFrontEndUI.hpp index b1c2aac75..046f0522a 100644 --- a/Runtime/MP1/CFrontEndUI.hpp +++ b/Runtime/MP1/CFrontEndUI.hpp @@ -279,13 +279,8 @@ public: float x38_rowPitch = 0.f; CSfxHandle x3c_sliderSfx; CRumbleGenerator x40_rumbleGen; - union { - u8 _dummy = 0; - struct { - bool x134_24_visible : 1; - bool x134_25_exitOptions : 1; - }; - }; + bool x134_24_visible : 1; + bool x134_25_exitOptions : 1; std::unique_ptr m_touchBar; bool m_touchBarInValue = false; diff --git a/Runtime/MP1/CInGameGuiManager.cpp b/Runtime/MP1/CInGameGuiManager.cpp index effe4dd60..31a4dd461 100644 --- a/Runtime/MP1/CInGameGuiManager.cpp +++ b/Runtime/MP1/CInGameGuiManager.cpp @@ -178,7 +178,11 @@ CInGameGuiManager::CInGameGuiManager(CStateManager& stateMgr, CArchitectureQueue , x1c_rand(1234) , x20_faceplateDecor(stateMgr) , x50_deathDot(g_SimplePool->GetObj("TXTR_DeathDot")) -, x5c_pauseScreenDGRPs(LockPauseScreenDependencies()) { +, x5c_pauseScreenDGRPs(LockPauseScreenDependencies()) +, x1f8_24_(false) +, x1f8_25_playerAlive(true) +, x1f8_26_deferTransition(false) +, x1f8_27_exitSaveUI(true) { x1e0_helmetVisMode = g_tweakGui->GetHelmetVisMode(); x1e4_enableTargetingManager = g_tweakGui->GetEnableTargetingManager(); x1e8_enableAutoMapper = g_tweakGui->GetEnableAutoMapper(); @@ -187,9 +191,6 @@ CInGameGuiManager::CInGameGuiManager(CStateManager& stateMgr, CArchitectureQueue x1f4_visorStaticAlpha = stateMgr.GetPlayer().GetVisorStaticAlpha(); - x1f8_25_playerAlive = true; - x1f8_27_exitSaveUI = true; - xc8_inGameGuiDGRPs.reserve(InGameGuiDGRPs.size()); for (const char* const dgrp : InGameGuiDGRPs) { xc8_inGameGuiDGRPs.emplace_back(g_SimplePool->GetObj(dgrp)); diff --git a/Runtime/MP1/CInGameGuiManager.hpp b/Runtime/MP1/CInGameGuiManager.hpp index 76ba934f2..3009e4d34 100644 --- a/Runtime/MP1/CInGameGuiManager.hpp +++ b/Runtime/MP1/CInGameGuiManager.hpp @@ -95,6 +95,10 @@ private: EHudVisMode x1ec_hudVisMode; u32 x1f0_enablePlayerVisor; float x1f4_visorStaticAlpha; + bool x1f8_24_ : 1; + bool x1f8_25_playerAlive : 1; + bool x1f8_26_deferTransition : 1; + bool x1f8_27_exitSaveUI : 1; std::optional m_deathRenderTexQuad; std::optional m_deathDotQuad; @@ -102,16 +106,6 @@ private: CColoredQuadFilter m_deathWhiteout{EFilterType::Blend}; CColoredQuadFilter m_deathBlackout{EFilterType::Blend}; - union { - struct { - bool x1f8_24_ : 1; - bool x1f8_25_playerAlive : 1; - bool x1f8_26_deferTransition : 1; - bool x1f8_27_exitSaveUI : 1; - }; - u32 _dummy = 0; - }; - static std::vector> LockPauseScreenDependencies(); bool CheckDGRPLoadComplete() const; void BeginStateTransition(EInGameGuiState state, CStateManager& stateMgr); diff --git a/Runtime/MP1/CLogBookScreen.cpp b/Runtime/MP1/CLogBookScreen.cpp index e665c0c16..e4dc73fff 100644 --- a/Runtime/MP1/CLogBookScreen.cpp +++ b/Runtime/MP1/CLogBookScreen.cpp @@ -14,7 +14,10 @@ namespace urde::MP1 { CLogBookScreen::CLogBookScreen(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg) -: CPauseScreenBase(mgr, frame, pauseStrg, true) { +: CPauseScreenBase(mgr, frame, pauseStrg, true) +, x260_24_loaded(false) +, x260_25_inTextScroll(false) +, x260_26_exitTextScroll(false) { x19c_scanCompletes.resize(5); x200_viewScans.resize(5); x258_artifactDoll = std::make_unique(); @@ -177,7 +180,6 @@ bool CLogBookScreen::IsScanCategoryReady(CSaveWorld::EScanCategory category) con }); } - void CLogBookScreen::UpdateBodyText() { if (x10_mode != EMode::TextScroll) { x174_textpane_body->TextSupport().SetText(u""); diff --git a/Runtime/MP1/CLogBookScreen.hpp b/Runtime/MP1/CLogBookScreen.hpp index 8b2892b7b..f782faf0f 100644 --- a/Runtime/MP1/CLogBookScreen.hpp +++ b/Runtime/MP1/CLogBookScreen.hpp @@ -13,7 +13,7 @@ namespace urde { class CPlayerState; class CScannableObjectInfo; class CStringTable; -} +} // namespace urde namespace urde::MP1 { class CArtifactDoll; @@ -25,18 +25,14 @@ class CLogBookScreen : public CPauseScreenBase { x200_viewScans; float x254_viewInterp = 0.f; std::unique_ptr x258_artifactDoll; - - enum class ELeavePauseState { InPause = 0, LeavingPause = 1, LeftPause = 2 }; - - ELeavePauseState x25c_leavePauseState = ELeavePauseState::InPause; - union { - struct { - bool x260_24_loaded : 1; - bool x260_25_inTextScroll : 1; - bool x260_26_exitTextScroll : 1; - }; - s32 _dummy = 0; - }; + enum class ELeavePauseState { + InPause = 0, + LeavingPause = 1, + LeftPause = 2 + } x25c_leavePauseState = ELeavePauseState::InPause; + bool x260_24_loaded : 1; + bool x260_25_inTextScroll : 1; + bool x260_26_exitTextScroll : 1; void InitializeLogBook(); void UpdateRightTitles(); diff --git a/Runtime/MP1/CMFGame.cpp b/Runtime/MP1/CMFGame.cpp index affd3f57e..1691b80f7 100644 --- a/Runtime/MP1/CMFGame.cpp +++ b/Runtime/MP1/CMFGame.cpp @@ -14,13 +14,16 @@ namespace urde::MP1 { CMFGame::CMFGame(const std::weak_ptr& stateMgr, const std::weak_ptr& guiMgr, const CArchitectureQueue&) -: CMFGameBase("CMFGame"), x14_stateManager(stateMgr.lock()), x18_guiManager(guiMgr.lock()) { - x2a_25_samusAlive = true; +: CMFGameBase("CMFGame") +, x14_stateManager(stateMgr.lock()) +, x18_guiManager(guiMgr.lock()) +, x2a_24_initialized(false) +, x2a_25_samusAlive(true) { static_cast(*g_Main).SetMFGameBuilt(true); } CMFGame::~CMFGame() { - CMain& main = static_cast(*g_Main); + auto& main = static_cast(*g_Main); main.SetMFGameBuilt(false); main.SetScreenFading(false); CDecalManager::Reinitialize(); @@ -253,8 +256,9 @@ void CMFGame::EnterMapScreen() { x14_stateManager->SetInMapScreen(true); } -CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader") { - CMain* m = static_cast(g_Main); +CMFGameLoader::CMFGameLoader() +: CMFGameLoaderBase("CMFGameLoader"), x2c_24_initialized(false), x2c_25_transitionFinished(false) { + auto* m = static_cast(g_Main); switch (m->GetFlowState()) { case EFlowState::Default: case EFlowState::StateSetter: { diff --git a/Runtime/MP1/CMFGame.hpp b/Runtime/MP1/CMFGame.hpp index fe7d70ca3..d491089b1 100644 --- a/Runtime/MP1/CMFGame.hpp +++ b/Runtime/MP1/CMFGame.hpp @@ -23,13 +23,8 @@ class CMFGame : public CMFGameBase { float x20_cineSkipTime; u32 x24_ = 0; TUniqueId x28_skippedCineCam = kInvalidUniqueId; - union { - struct { - bool x2a_24_initialized : 1; - bool x2a_25_samusAlive : 1; - }; - u8 _dummy = 0; - }; + bool x2a_24_initialized : 1; + bool x2a_25_samusAlive : 1; CColoredQuadFilter m_fadeToBlack{EFilterType::Multiply}; @@ -57,14 +52,8 @@ class CMFGameLoader : public CMFGameLoaderBase { std::shared_ptr x14_stateMgr; std::shared_ptr x18_guiMgr; std::vector x1c_loadList; - - union { - struct { - bool x2c_24_initialized : 1; - bool x2c_25_transitionFinished : 1; - }; - u8 _dummy = 0; - }; + bool x2c_24_initialized : 1; + bool x2c_25_transitionFinished : 1; void MakeLoadDependencyList(); diff --git a/Runtime/MP1/CPauseScreenBase.cpp b/Runtime/MP1/CPauseScreenBase.cpp index 1f9e662c8..f8d4adde5 100644 --- a/Runtime/MP1/CPauseScreenBase.cpp +++ b/Runtime/MP1/CPauseScreenBase.cpp @@ -18,9 +18,22 @@ namespace urde::MP1 { CPauseScreenBase::CPauseScreenBase(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg, bool isLogBook) -: x4_mgr(mgr), x8_frame(frame), xc_pauseStrg(pauseStrg) { - m_isLogBook = isLogBook; - m_playRightTableSfx = true; +: x4_mgr(mgr) +, x8_frame(frame) +, xc_pauseStrg(pauseStrg) +, x198_24_ready(false) +, x198_25_handledInput(false) +, x198_26_exitPauseScreen(false) +, x198_27_canDraw(false) +, x198_28_pulseTextArrowTop(false) +, x198_29_pulseTextArrowBottom(false) +, m_isLogBook(isLogBook) +, m_bodyUpClicked(false) +, m_bodyDownClicked(false) +, m_bodyClicked(false) +, m_leftClicked(false) +, m_rightClicked(false) +, m_playRightTableSfx(true) { InitializeFrameGlue(); } diff --git a/Runtime/MP1/CPauseScreenBase.hpp b/Runtime/MP1/CPauseScreenBase.hpp index 7b9937143..95178d5e2 100644 --- a/Runtime/MP1/CPauseScreenBase.hpp +++ b/Runtime/MP1/CPauseScreenBase.hpp @@ -74,24 +74,20 @@ protected: CGuiSliderGroup* x18c_slidergroup_slider = nullptr; CGuiTableGroup* x190_tablegroup_double = nullptr; CGuiTableGroup* x194_tablegroup_triple = nullptr; - union { - struct { - bool x198_24_ready : 1; - bool x198_25_handledInput : 1; - bool x198_26_exitPauseScreen : 1; - bool x198_27_canDraw : 1; - bool x198_28_pulseTextArrowTop : 1; - bool x198_29_pulseTextArrowBottom : 1; - bool m_isLogBook : 1; - bool m_bodyUpClicked : 1; - bool m_bodyDownClicked : 1; - bool m_bodyClicked : 1; - bool m_leftClicked : 1; - bool m_rightClicked : 1; - bool m_playRightTableSfx : 1; - }; - u32 _dummy = 0; - }; + bool x198_24_ready : 1; + bool x198_25_handledInput : 1; + bool x198_26_exitPauseScreen : 1; + bool x198_27_canDraw : 1; + bool x198_28_pulseTextArrowTop : 1; + bool x198_29_pulseTextArrowBottom : 1; + bool m_isLogBook : 1; + bool m_bodyUpClicked : 1; + bool m_bodyDownClicked : 1; + bool m_bodyClicked : 1; + bool m_leftClicked : 1; + bool m_rightClicked : 1; + bool m_playRightTableSfx : 1; + void InitializeFrameGlue(); void ChangeMode(EMode mode, bool playSfx = true); void UpdateSideTable(CGuiTableGroup* table); diff --git a/Runtime/MP1/CPauseScreenBlur.cpp b/Runtime/MP1/CPauseScreenBlur.cpp index 37dbacbef..f750dba69 100644 --- a/Runtime/MP1/CPauseScreenBlur.cpp +++ b/Runtime/MP1/CPauseScreenBlur.cpp @@ -6,9 +6,8 @@ namespace urde::MP1 { -CPauseScreenBlur::CPauseScreenBlur() : x4_mapLightQuarter(g_SimplePool->GetObj("TXTR_MapLightQuarter")) { - x50_25_gameDraw = true; -} +CPauseScreenBlur::CPauseScreenBlur() +: x4_mapLightQuarter(g_SimplePool->GetObj("TXTR_MapLightQuarter")), x50_24_blurring(false), x50_25_gameDraw(true) {} void CPauseScreenBlur::OnNewInGameGuiState(EInGameGuiState state, CStateManager& stateMgr) { switch (state) { diff --git a/Runtime/MP1/CPauseScreenBlur.hpp b/Runtime/MP1/CPauseScreenBlur.hpp index e96b2eafc..69a7e4951 100644 --- a/Runtime/MP1/CPauseScreenBlur.hpp +++ b/Runtime/MP1/CPauseScreenBlur.hpp @@ -20,16 +20,12 @@ class CPauseScreenBlur { EState x14_nextState = EState::InGame; float x18_blurAmt = 0.f; CCameraBlurPass x1c_camBlur; + bool x50_24_blurring : 1; + bool x50_25_gameDraw : 1; + CTexturedQuadFilter m_quarterFilter{EFilterType::Multiply, x4_mapLightQuarter}; CScanLinesFilterEven m_linesFilter{EFilterType::Multiply}; - union { - struct { - bool x50_24_blurring : 1; - bool x50_25_gameDraw : 1; - }; - u32 _dummy = 0; - }; void OnBlurComplete(bool); void SetState(EState state); diff --git a/Runtime/MP1/CPlayMovie.cpp b/Runtime/MP1/CPlayMovie.cpp index fcffdaf28..9d9494fc8 100644 --- a/Runtime/MP1/CPlayMovie.cpp +++ b/Runtime/MP1/CPlayMovie.cpp @@ -8,7 +8,13 @@ const char* kMovies[] = {"Video/wingame.thp", "Video/wingame_best.thp", " bool CPlayMovie::IsResultsScreen(EWhichMovie which) { return int(which) <= 2; } -CPlayMovie::CPlayMovie(EWhichMovie which) : CPlayMovieBase("CPlayMovie", kMovies[int(which)]), x18_which(which) { +CPlayMovie::CPlayMovie(EWhichMovie which) +: CPlayMovieBase("CPlayMovie", kMovies[int(which)]) +, x18_which(which) +, x78_24_(false) +, x78_25_(false) +, x78_26_resultsScreen(false) +, x78_27_(false) { (void)x18_which; } diff --git a/Runtime/MP1/CPlayMovie.hpp b/Runtime/MP1/CPlayMovie.hpp index f881461e1..8e40a9f85 100644 --- a/Runtime/MP1/CPlayMovie.hpp +++ b/Runtime/MP1/CPlayMovie.hpp @@ -20,15 +20,11 @@ public: private: EWhichMovie x18_which; - union { - struct { - bool x78_24_ : 1; - bool x78_25_ : 1; - bool x78_26_resultsScreen : 1; - bool x78_27_ : 1; - }; - u16 _dummy = 0; - }; + bool x78_24_ : 1; + bool x78_25_ : 1; + bool x78_26_resultsScreen : 1; + bool x78_27_ : 1; + static bool IsResultsScreen(EWhichMovie which); public: diff --git a/Runtime/MP1/CSamusDoll.cpp b/Runtime/MP1/CSamusDoll.cpp index a4ca9f2cb..74fbbd177 100644 --- a/Runtime/MP1/CSamusDoll.cpp +++ b/Runtime/MP1/CSamusDoll.cpp @@ -98,7 +98,15 @@ CSamusDoll::CSamusDoll(const CDependencyGroup& suitDgrp, const CDependencyGroup& bool hasGrappleBeam) : x10_ballXf(zeus::CTransform::Translate(0.f, 0.f, 0.625f * g_tweakPlayer->GetPlayerBallHalfExtent())) , x44_suit(suit) -, x48_beam(beam) { +, x48_beam(beam) +, x270_24_hasSpiderBall(hasSpiderBall) +, x270_25_hasGrappleBeam(hasGrappleBeam) +, x270_26_pulseSuit(false) +, x270_27_pulseBeam(false) +, x270_28_pulseGrapple(false) +, x270_29_pulseBoots(false) +, x270_30_pulseVisor(false) +, x270_31_loaded(false) { x70_fixedRot.rotateZ(M_PIF); x90_userInterpRot = xb0_userRot = x70_fixedRot; x1d4_spiderBallGlass = g_SimplePool->GetObj(SpiderBallGlassModels[size_t(suit)].first); @@ -115,8 +123,6 @@ CSamusDoll::CSamusDoll(const CDependencyGroup& suitDgrp, const CDependencyGroup& x230_ballTransitionFlash = g_SimplePool->GetObj("MorphBallTransitionFlash"); x23c_lights.push_back(CLight::BuildDirectional(zeus::skForward, zeus::skWhite)); x24c_actorLights = std::make_unique(8, zeus::skZero3f, 4, 4, false, false, false, 0.1f); - x270_24_hasSpiderBall = hasSpiderBall; - x270_25_hasGrappleBeam = hasGrappleBeam; x22c_ballInnerGlowGen->SetGlobalScale(zeus::CVector3f(0.625f)); x0_depToks.reserve(suitDgrp.GetObjectTagVector().size() + ballDgrp.GetObjectTagVector().size()); for (const SObjectTag& tag : suitDgrp.GetObjectTagVector()) { diff --git a/Runtime/MP1/CSamusDoll.hpp b/Runtime/MP1/CSamusDoll.hpp index ac0ddd645..6833a75e6 100644 --- a/Runtime/MP1/CSamusDoll.hpp +++ b/Runtime/MP1/CSamusDoll.hpp @@ -71,19 +71,14 @@ class CSamusDoll { CSfxHandle x264_offsetSfx; CSfxHandle x268_rotateSfx; CSfxHandle x26c_zoomSfx; - union { - struct { - bool x270_24_hasSpiderBall : 1; - bool x270_25_hasGrappleBeam : 1; - bool x270_26_pulseSuit : 1; - bool x270_27_pulseBeam : 1; - bool x270_28_pulseGrapple : 1; - bool x270_29_pulseBoots : 1; - bool x270_30_pulseVisor : 1; - bool x270_31_loaded : 1; - }; - u32 _dummy = 0; - }; + bool x270_24_hasSpiderBall : 1; + bool x270_25_hasGrappleBeam : 1; + bool x270_26_pulseSuit : 1; + bool x270_27_pulseBeam : 1; + bool x270_28_pulseGrapple : 1; + bool x270_29_pulseBoots : 1; + bool x270_30_pulseVisor : 1; + bool x270_31_loaded : 1; static constexpr zeus::CVector3f skInitialOffset{0.0f, 0.0f, 0.8f}; static CModelData BuildSuitModelData1(CPlayerState::EPlayerSuit suit); diff --git a/Runtime/MP1/CSamusHud.cpp b/Runtime/MP1/CSamusHud.cpp index 5681b8c86..8d003aa98 100644 --- a/Runtime/MP1/CSamusHud.cpp +++ b/Runtime/MP1/CSamusHud.cpp @@ -23,9 +23,11 @@ CSamusHud::CSamusHud(CStateManager& stateMgr) : x8_targetingMgr(stateMgr) , x258_frmeHelmet(g_SimplePool->GetObj("FRME_Helmet")) , x268_frmeBaseHud(g_SimplePool->GetObj("FRME_BaseHud")) +, x2e0_24_inFreeLook(false) +, x2e0_25_lookControlHeld(false) +, x2e0_26_latestFirstPerson(true) +, x2e0_27_energyLow(stateMgr.GetPlayer().IsEnergyLow(stateMgr)) , m_energyDrainFilter(g_tweakGui->GetEnergyDrainFilterAdditive() ? EFilterType::Add : EFilterType::Blend) { - x2e0_26_latestFirstPerson = true; - x2e0_27_energyLow = stateMgr.GetPlayer().IsEnergyLow(stateMgr); x33c_lights = std::make_unique(8, zeus::skZero3f, 4, 1, true, 0, 0, 0.1f); x340_hudLights.resize(3, SCachedHudLight(zeus::skZero3f, zeus::skWhite, 0.f, 0.f, 0.f, 0.f)); x46c_.resize(3); diff --git a/Runtime/MP1/CSamusHud.hpp b/Runtime/MP1/CSamusHud.hpp index 47baf9248..c140ba43d 100644 --- a/Runtime/MP1/CSamusHud.hpp +++ b/Runtime/MP1/CSamusHud.hpp @@ -95,17 +95,10 @@ class CSamusHud { u32 x2d4_totalEnergyTanks = 0; u32 x2d8_missileAmount = 0; u32 x2dc_missileCapacity = 0; - - union { - struct { - bool x2e0_24_inFreeLook : 1; - bool x2e0_25_lookControlHeld : 1; - bool x2e0_26_latestFirstPerson : 1; - bool x2e0_27_energyLow : 1; - }; - u16 _dummy = 0; - }; - + bool x2e0_24_inFreeLook : 1; + bool x2e0_25_lookControlHeld : 1; + bool x2e0_26_latestFirstPerson : 1; + bool x2e0_27_energyLow : 1; u32 x2e4_ = 0; u32 x2e8_ = 0; CPlayerGun::EMissleMode x2ec_missileMode = CPlayerGun::EMissleMode::Inactive; diff --git a/Runtime/MP1/CSlideShow.cpp b/Runtime/MP1/CSlideShow.cpp index 40b0d9571..9c588f7cd 100644 --- a/Runtime/MP1/CSlideShow.cpp +++ b/Runtime/MP1/CSlideShow.cpp @@ -6,12 +6,20 @@ namespace urde { -CSlideShow::CSlideShow() : CIOWin("SlideShow"), x5c_slideA(*this), x90_slideB(*this) { - x130_ = g_tweakSlideShow->GetX54(); - x134_24_ = true; - x134_30_ = true; - x135_24_ = true; - +CSlideShow::CSlideShow() +: CIOWin("SlideShow") +, x5c_slideA(*this) +, x90_slideB(*this) +, x130_(g_tweakSlideShow->GetX54()) +, x134_24_(true) +, x134_25_(false) +, x134_26_(false) +, x134_27_(false) +, x134_28_disableInput(false) +, x134_29_(false) +, x134_30_(true) +, x134_31_(false) +, x135_24_(true) { const SObjectTag* font = g_ResFactory->GetResourceIdByName(g_tweakSlideShow->GetFont()); if (font) { CGuiTextProperties propsA(false, true, EJustification::Center, EVerticalJustification::Bottom); diff --git a/Runtime/MP1/CSlideShow.hpp b/Runtime/MP1/CSlideShow.hpp index 11087684f..20bed1176 100644 --- a/Runtime/MP1/CSlideShow.hpp +++ b/Runtime/MP1/CSlideShow.hpp @@ -87,21 +87,15 @@ private: float x12c_ = 32.f; */ float x130_; - - union { - struct { - bool x134_24_ : 1; - bool x134_25_ : 1; - bool x134_26_ : 1; - bool x134_27_ : 1; - bool x134_28_disableInput : 1; - bool x134_29_ : 1; - bool x134_30_ : 1; - bool x134_31_ : 1; - bool x135_24_ : 1; - }; - u32 dummy = 0; - }; + bool x134_24_ : 1; + bool x134_25_ : 1; + bool x134_26_ : 1; + bool x134_27_ : 1; + bool x134_28_disableInput : 1; + bool x134_29_ : 1; + bool x134_30_ : 1; + bool x134_31_ : 1; + bool x135_24_ : 1; bool LoadTXTRDep(std::string_view name); static bool AreAllDepsLoaded(const std::vector>& deps); diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 3c1735d0d..eb89c9578 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -240,7 +240,17 @@ void CGameArchitectureSupport::specialKeyUp(boo::ESpecialKey key, boo::EModifier CMain::CMain(IFactory* resFactory, CSimplePool* resStore, boo::IGraphicsDataFactory* gfxFactory, boo::IGraphicsCommandQueue* cmdQ, const boo::ObjToken& spareTex) -: m_booSetter(gfxFactory, cmdQ, spareTex), x128_globalObjects(resFactory, resStore) { +: m_booSetter(gfxFactory, cmdQ, spareTex) +, x128_globalObjects(resFactory, resStore) +, x160_24_finished(false) +, x160_25_mfGameBuilt(false) +, x160_26_screenFading(false) +, x160_27_(false) +, x160_28_manageCard(false) +, x160_29_(false) +, x160_30_(false) +, x160_31_cardBusy(false) +, x161_24_gameFrameDrawn(false) { xe4_gameplayResult = EGameplayResult::Playing; g_Main = this; } diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index cf25985ec..f805dff6a 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -227,20 +227,15 @@ private: u32 x130_[10] = {1000000}; - union { - struct { - bool x160_24_finished : 1; - bool x160_25_mfGameBuilt : 1; - bool x160_26_screenFading : 1; - bool x160_27_ : 1; - bool x160_28_manageCard : 1; - bool x160_29_ : 1; - bool x160_30_ : 1; - bool x160_31_cardBusy : 1; - bool x161_24_gameFrameDrawn : 1; - }; - u16 _dummy = 0; - }; + bool x160_24_finished : 1; + bool x160_25_mfGameBuilt : 1; + bool x160_26_screenFading : 1; + bool x160_27_ : 1; + bool x160_28_manageCard : 1; + bool x160_29_ : 1; + bool x160_30_ : 1; + bool x160_31_cardBusy : 1; + bool x161_24_gameFrameDrawn : 1; std::unique_ptr x164_archSupport; From 153004faee48fb9a12d0a696339fdb932d89a613 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:33:05 -0400 Subject: [PATCH 10/16] 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); From f483f5c1e6717e3cdb1de847ab7d1ad051de2751 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2020 15:47:36 -0400 Subject: [PATCH 11/16] CPersistentOptions: Initialize bitfields in default constructor --- Runtime/CGameOptions.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Runtime/CGameOptions.hpp b/Runtime/CGameOptions.hpp index a77e3e849..01513df55 100644 --- a/Runtime/CGameOptions.hpp +++ b/Runtime/CGameOptions.hpp @@ -64,7 +64,13 @@ class CPersistentOptions { bool xd0_29_allItemsCollected : 1; public: - CPersistentOptions() = default; + CPersistentOptions() + : xd0_24_fusionLinked(false) + , xd0_25_normalModeBeat(false) + , xd0_26_hardModeBeat(false) + , xd0_27_fusionBeat(false) + , xd0_28_fusionSuitActive(false) + , xd0_29_allItemsCollected(false) {} explicit CPersistentOptions(CBitStreamReader& stream); bool GetCinematicState(CAssetId mlvlId, TEditorId cineId) const; From c7ca8dc3a746c0f4c7ccbc3ce5c701f35b707cf2 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 11 Apr 2020 00:39:49 -0400 Subject: [PATCH 12/16] Runtime/Particle: Replace bitfield unions with constructor initializers --- Runtime/Particle/CDecal.cpp | 2 +- Runtime/Particle/CDecal.hpp | 22 +++------ Runtime/Particle/CDecalDescription.hpp | 11 ++--- Runtime/Particle/CElementGen.cpp | 19 ++++++-- Runtime/Particle/CElementGen.hpp | 33 +++++-------- Runtime/Particle/CGenDescription.hpp | 63 +++++++++++++++---------- Runtime/Particle/CParticleElectric.cpp | 11 +++-- Runtime/Particle/CParticleElectric.hpp | 18 +++---- Runtime/Particle/CParticleSwoosh.cpp | 12 ++++- Runtime/Particle/CParticleSwoosh.hpp | 24 ++++------ Runtime/Particle/CSwooshDescription.hpp | 40 +++++++++------- 11 files changed, 134 insertions(+), 121 deletions(-) diff --git a/Runtime/Particle/CDecal.cpp b/Runtime/Particle/CDecal.cpp index c18156852..a5c3d41b8 100644 --- a/Runtime/Particle/CDecal.cpp +++ b/Runtime/Particle/CDecal.cpp @@ -9,7 +9,7 @@ CRandom16 CDecal::sDecalRandom; bool CDecal::sMoveRedToAlphaBuffer = false; CDecal::CDecal(const TToken& desc, const zeus::CTransform& xf) -: x0_description(desc), xc_transform(xf) { +: x0_description(desc), xc_transform(xf), x5c_29_modelInvalid(false) { CGlobalRandom gr(sDecalRandom); CDecalDescription& desco = *x0_description; diff --git a/Runtime/Particle/CDecal.hpp b/Runtime/Particle/CDecal.hpp index 224658da1..6417e052e 100644 --- a/Runtime/Particle/CDecal.hpp +++ b/Runtime/Particle/CDecal.hpp @@ -13,17 +13,12 @@ namespace urde { struct SQuadDescr; struct CQuadDecal { - union { - struct { - bool x0_24_invalid : 1; - }; - u32 _dummy = 0; - }; + bool x0_24_invalid : 1; s32 x4_lifetime = 0; float x8_rotation = 0.f; const SQuadDescr* m_desc = nullptr; - CQuadDecal() = default; - CQuadDecal(s32 i, float f) : x4_lifetime(i), x8_rotation(f) { x0_24_invalid = true; } + CQuadDecal() : x0_24_invalid(true) {} + CQuadDecal(s32 i, float f) : x0_24_invalid(true), x4_lifetime(i), x8_rotation(f) {} boo::ObjToken m_instBuf; boo::ObjToken m_uniformBuf; @@ -41,14 +36,9 @@ class CDecal { std::array x3c_decalQuads; s32 x54_modelLifetime = 0; s32 x58_frameIdx = 0; - union { - struct { - bool x5c_31_quad1Invalid : 1; - bool x5c_30_quad2Invalid : 1; - bool x5c_29_modelInvalid : 1; - }; - u32 x5c_dummy = 0; - }; + bool x5c_31_quad1Invalid : 1; + bool x5c_30_quad2Invalid : 1; + bool x5c_29_modelInvalid : 1; zeus::CVector3f x60_rotation; bool InitQuad(CQuadDecal& quad, const SQuadDescr& desc); diff --git a/Runtime/Particle/CDecalDescription.hpp b/Runtime/Particle/CDecalDescription.hpp index ff1d74afa..7d0038a2e 100644 --- a/Runtime/Particle/CDecalDescription.hpp +++ b/Runtime/Particle/CDecalDescription.hpp @@ -23,6 +23,8 @@ struct SQuadDescr { class CDecalDescription { public: + CDecalDescription() : x5c_24_DMAB(false), x5c_25_DMOO(false) {} + SQuadDescr x0_Quads[2]; SParticleModel x38_DMDL; std::unique_ptr x48_DLFT; @@ -30,13 +32,8 @@ public: std::unique_ptr x50_DMRT; std::unique_ptr x54_DMSC; std::unique_ptr x58_DMCL; - union { - struct { - bool x5c_24_DMAB : 1; - bool x5c_25_DMOO : 1; - }; - u32 dummy = 0; - }; + bool x5c_24_DMAB : 1; + bool x5c_25_DMOO : 1; }; } // namespace urde diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index 1353886a9..479d44e56 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -54,12 +54,25 @@ void CElementGen::Initialize() { void CElementGen::Shutdown() { CElementGenShaders::Shutdown(); } CElementGen::CElementGen(TToken gen, EModelOrientationType orientType, EOptionalSystemFlags flags) -: x1c_genDesc(std::move(gen)), x2c_orientType(orientType), x27c_randState(x94_randomSeed) { +: x1c_genDesc(std::move(gen)) +, x2c_orientType(orientType) +, x26c_24_translationDirty(false) +, x26c_25_LIT_(false) +, x26c_26_AAPH(false) +, x26c_27_ZBUF(false) +, x26c_28_zTest(false) +, x26c_29_ORNT(false) +, x26c_30_MBLR(false) +, x26c_31_LINE(false) +, x26d_24_FXLL(false) +, x26d_25_warmedUp(false) +, x26d_26_modelsUseLights(false) +, x26d_27_enableOPTS(True(flags & EOptionalSystemFlags::Two)) +, x26d_28_enableADV(false) +, x27c_randState(x94_randomSeed) { CGenDescription* desc = x1c_genDesc.GetObj(); x28_loadedGenDesc = desc; - x26d_27_enableOPTS = True(flags & EOptionalSystemFlags::Two); - if (desc->x54_x40_TEXR) desc->x54_x40_TEXR->GetValueTexture(0).GetObj(); if (desc->x58_x44_TIND) diff --git a/Runtime/Particle/CElementGen.hpp b/Runtime/Particle/CElementGen.hpp index 26ec47598..6e585539a 100644 --- a/Runtime/Particle/CElementGen.hpp +++ b/Runtime/Particle/CElementGen.hpp @@ -87,26 +87,19 @@ private: u32 x260_cumulativeParticles = 0; u32 x264_recursiveParticleCount = 0; int x268_PSLT; - - union { - struct { - bool x26c_24_translationDirty : 1; - bool x26c_25_LIT_ : 1; - bool x26c_26_AAPH : 1; - bool x26c_27_ZBUF : 1; - bool x26c_28_zTest : 1; - bool x26c_29_ORNT : 1; - bool x26c_30_MBLR : 1; - bool x26c_31_LINE : 1; - bool x26d_24_FXLL : 1; - bool x26d_25_warmedUp : 1; - bool x26d_26_modelsUseLights : 1; - bool x26d_27_enableOPTS : 1; - bool x26d_28_enableADV : 1; - }; - u32 _dummy = 0; - }; - + bool x26c_24_translationDirty : 1; + bool x26c_25_LIT_ : 1; + bool x26c_26_AAPH : 1; + bool x26c_27_ZBUF : 1; + bool x26c_28_zTest : 1; + bool x26c_29_ORNT : 1; + bool x26c_30_MBLR : 1; + bool x26c_31_LINE : 1; + bool x26d_24_FXLL : 1; + bool x26d_25_warmedUp : 1; + bool x26d_26_modelsUseLights : 1; + bool x26d_27_enableOPTS : 1; + bool x26d_28_enableADV : 1; int x270_MBSP = 0; int m_maxMBSP = 0; ERglLightBits x274_backupLightActive = ERglLightBits::None; diff --git a/Runtime/Particle/CGenDescription.hpp b/Runtime/Particle/CGenDescription.hpp index bde4b376d..5661d62c4 100644 --- a/Runtime/Particle/CGenDescription.hpp +++ b/Runtime/Particle/CGenDescription.hpp @@ -39,30 +39,25 @@ public: // std::unique_ptr x38_ILOC; // std::unique_ptr x3c_IVEC; std::unique_ptr x40_x2c_EMTR; - union { - struct { - bool x44_28_x30_28_SORT : 1; - bool x44_30_x31_24_MBLR : 1; - bool x44_24_x30_24_LINE : 1; - bool x44_29_x30_29_LIT_ : 1; - bool x44_26_x30_26_AAPH : 1; - bool x44_27_x30_27_ZBUF : 1; - bool x44_25_x30_25_FXLL : 1; - bool x44_31_x31_25_PMAB : 1; - bool x45_29_x31_31_VMD4 : 1; - bool x45_28_x31_30_VMD3 : 1; - bool x45_27_x31_29_VMD2 : 1; - bool x45_26_x31_28_VMD1 : 1; - bool x45_31_x32_25_OPTS : 1; - bool x45_24_x31_26_PMUS : 1; - bool x45_25_x31_27_PMOO : 1; - bool x45_30_x32_24_CIND : 1; - /* 0-00 additions */ - bool x30_30_ORNT : 1; - bool x30_31_RSOP : 1; - }; - u32 dummy1 = 0; - }; + bool x44_28_x30_28_SORT : 1; + bool x44_30_x31_24_MBLR : 1; + bool x44_24_x30_24_LINE : 1; + bool x44_29_x30_29_LIT_ : 1; + bool x44_26_x30_26_AAPH : 1; + bool x44_27_x30_27_ZBUF : 1; + bool x44_25_x30_25_FXLL : 1; + bool x44_31_x31_25_PMAB : 1; + bool x45_29_x31_31_VMD4 : 1; + bool x45_28_x31_30_VMD3 : 1; + bool x45_27_x31_29_VMD2 : 1; + bool x45_26_x31_28_VMD1 : 1; + bool x45_31_x32_25_OPTS : 1; + bool x45_24_x31_26_PMUS : 1; + bool x45_25_x31_27_PMOO : 1; + bool x45_30_x32_24_CIND : 1; + /* 0-00 additions */ + bool x30_30_ORNT : 1; + bool x30_31_RSOP : 1; std::unique_ptr x48_x34_MBSP; std::unique_ptr x4c_x38_SIZE; std::unique_ptr x50_x3c_ROTA; @@ -112,7 +107,25 @@ public: /* Custom additions */ std::unique_ptr m_bevelGradient; /* FourCC BGCL */ - CGenDescription() { x45_25_x31_27_PMOO = true; } + CGenDescription() + : x44_28_x30_28_SORT(false) + , x44_30_x31_24_MBLR(false) + , x44_24_x30_24_LINE(false) + , x44_29_x30_29_LIT_(false) + , x44_26_x30_26_AAPH(false) + , x44_27_x30_27_ZBUF(false) + , x44_25_x30_25_FXLL(false) + , x44_31_x31_25_PMAB(false) + , x45_29_x31_31_VMD4(false) + , x45_28_x31_30_VMD3(false) + , x45_27_x31_29_VMD2(false) + , x45_26_x31_28_VMD1(false) + , x45_31_x32_25_OPTS(false) + , x45_24_x31_26_PMUS(false) + , x45_25_x31_27_PMOO(true) + , x45_30_x32_24_CIND(false) + , x30_30_ORNT(false) + , x30_31_RSOP(false) {} }; } // namespace urde diff --git a/Runtime/Particle/CParticleElectric.cpp b/Runtime/Particle/CParticleElectric.cpp index 355b8aaaa..679f6a773 100644 --- a/Runtime/Particle/CParticleElectric.cpp +++ b/Runtime/Particle/CParticleElectric.cpp @@ -19,11 +19,16 @@ namespace urde { u16 CParticleElectric::g_GlobalSeed = 99; CParticleElectric::CParticleElectric(const TToken& token) -: x1c_elecDesc(token), x14c_randState(g_GlobalSeed++) { +: x1c_elecDesc(token) +, x14c_randState(g_GlobalSeed++) +, x450_24_emitting(true) +, x450_25_haveGPSM(false) +, x450_26_haveEPSM(false) +, x450_27_haveSSWH(false) +, x450_28_haveLWD(false) +, x450_29_transformDirty(true) { x1bc_allocated.resize(32); - x450_24_emitting = true; - x450_29_transformDirty = true; CElectricDescription* desc = x1c_elecDesc.GetObj(); if (CIntElement* sseg = desc->x10_SSEG.get()) diff --git a/Runtime/Particle/CParticleElectric.hpp b/Runtime/Particle/CParticleElectric.hpp index 880ec2be3..d69e66f86 100644 --- a/Runtime/Particle/CParticleElectric.hpp +++ b/Runtime/Particle/CParticleElectric.hpp @@ -85,22 +85,16 @@ private: std::vector x420_calculatedVerts; std::vector x430_fractalMags; std::vector x440_fractalOffsets; + bool x450_24_emitting : 1; + bool x450_25_haveGPSM : 1; + bool x450_26_haveEPSM : 1; + bool x450_27_haveSSWH : 1; + bool x450_28_haveLWD : 1; + bool x450_29_transformDirty : 1; size_t m_nextLineRenderer = 0; std::vector> m_lineRenderers; - union { - struct { - bool x450_24_emitting : 1; - bool x450_25_haveGPSM : 1; - bool x450_26_haveEPSM : 1; - bool x450_27_haveSSWH : 1; - bool x450_28_haveLWD : 1; - bool x450_29_transformDirty : 1; - }; - u32 dummy = 0; - }; - void SetupLineGXMaterial(); void DrawLineStrip(const std::vector& verts, float width, const zeus::CColor& color); void RenderLines(); diff --git a/Runtime/Particle/CParticleSwoosh.cpp b/Runtime/Particle/CParticleSwoosh.cpp index 6ab26b711..2017a328d 100644 --- a/Runtime/Particle/CParticleSwoosh.cpp +++ b/Runtime/Particle/CParticleSwoosh.cpp @@ -16,8 +16,16 @@ CParticleSwoosh::CParticleSwoosh(const TToken& desc, int len , x1c0_rand(x1c_desc->x45_26_CRND ? std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()) .count() - : 99) { - x1d0_24_emitting = true; + : 99) +, x1d0_24_emitting(true) +, x1d0_25_AALP(false) +, x1d0_26_forceOneUpdate(false) +, x1d0_27_renderGaps(false) +, x1d0_28_LLRD(false) +, x1d0_29_VLS1(false) +, x1d0_30_VLS2(false) +, x1d0_31_constantTex(false) +, x1d1_24_constantUv(false) { ++g_ParticleSystemAliveCount; if (leng > 0) diff --git a/Runtime/Particle/CParticleSwoosh.hpp b/Runtime/Particle/CParticleSwoosh.hpp index ed421eeca..e913e1ec8 100644 --- a/Runtime/Particle/CParticleSwoosh.hpp +++ b/Runtime/Particle/CParticleSwoosh.hpp @@ -83,21 +83,15 @@ class CParticleSwoosh : public CParticleGen { float x1c4_ = 0.f; float x1c8_ = 0.f; float x1cc_TSPN; - - union { - struct { - bool x1d0_24_emitting : 1; - bool x1d0_25_AALP : 1; - bool x1d0_26_forceOneUpdate : 1; - bool x1d0_27_renderGaps : 1; - bool x1d0_28_LLRD : 1; - bool x1d0_29_VLS1 : 1; - bool x1d0_30_VLS2 : 1; - bool x1d0_31_constantTex : 1; - bool x1d1_24_constantUv : 1; - }; - u32 _dummy = 0; - }; + bool x1d0_24_emitting : 1; + bool x1d0_25_AALP : 1; + bool x1d0_26_forceOneUpdate : 1; + bool x1d0_27_renderGaps : 1; + bool x1d0_28_LLRD : 1; + bool x1d0_29_VLS1 : 1; + bool x1d0_30_VLS2 : 1; + bool x1d0_31_constantTex : 1; + bool x1d1_24_constantUv : 1; SUVElementSet x1d4_uvs = {}; CTexture* x1e4_tex = nullptr; diff --git a/Runtime/Particle/CSwooshDescription.hpp b/Runtime/Particle/CSwooshDescription.hpp index 084ac1971..67217d80f 100644 --- a/Runtime/Particle/CSwooshDescription.hpp +++ b/Runtime/Particle/CSwooshDescription.hpp @@ -31,23 +31,29 @@ public: std::unique_ptr x38_SPLN; std::unique_ptr x3c_TEXR; std::unique_ptr x40_TSPN; - union { - struct { - bool x44_24_LLRD : 1; - bool x44_25_CROS : 1; - bool x44_26_VLS1 : 1; - bool x44_27_VLS2 : 1; - bool x44_28_SROT : 1; - bool x44_29_WIRE : 1; - bool x44_30_TEXW : 1; - bool x44_31_AALP : 1; - bool x45_24_ZBUF : 1; - bool x45_25_ORNT : 1; - bool x45_26_CRND : 1; - }; - u32 dummy = 0; - }; + bool x44_24_LLRD : 1; + bool x44_25_CROS : 1; + bool x44_26_VLS1 : 1; + bool x44_27_VLS2 : 1; + bool x44_28_SROT : 1; + bool x44_29_WIRE : 1; + bool x44_30_TEXW : 1; + bool x44_31_AALP : 1; + bool x45_24_ZBUF : 1; + bool x45_25_ORNT : 1; + bool x45_26_CRND : 1; - CSwooshDescription() { x44_25_CROS = true; } + CSwooshDescription() + : x44_24_LLRD(false) + , x44_25_CROS(true) + , x44_26_VLS1(false) + , x44_27_VLS2(false) + , x44_28_SROT(false) + , x44_29_WIRE(false) + , x44_30_TEXW(false) + , x44_31_AALP(false) + , x45_24_ZBUF(false) + , x45_25_ORNT(false) + , x45_26_CRND(false) {} }; } // namespace urde From 22880abb7e706558aa76187a38483998709b9ee4 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 11 Apr 2020 00:49:02 -0400 Subject: [PATCH 13/16] Runtime/Weapon: Replace bitfield unions with constructor initializers --- Runtime/Weapon/CBurstFire.cpp | 3 +- Runtime/Weapon/CBurstFire.hpp | 9 +-- Runtime/Weapon/CEnergyProjectile.cpp | 12 ++-- Runtime/Weapon/CEnergyProjectile.hpp | 13 ++--- Runtime/Weapon/CFlameThrower.cpp | 6 +- Runtime/Weapon/CFlameThrower.hpp | 14 ++--- Runtime/Weapon/CGSComboFire.hpp | 12 ++-- Runtime/Weapon/CGameProjectile.cpp | 21 +++---- Runtime/Weapon/CGameProjectile.hpp | 19 +++---- Runtime/Weapon/CGrappleArm.cpp | 8 ++- Runtime/Weapon/CGrappleArm.hpp | 17 ++---- Runtime/Weapon/CGunWeapon.cpp | 8 ++- Runtime/Weapon/CGunWeapon.hpp | 19 +++---- Runtime/Weapon/CPlasmaProjectile.cpp | 14 +++-- Runtime/Weapon/CPlasmaProjectile.hpp | 17 ++---- Runtime/Weapon/CPlayerGun.cpp | 37 ++++++++++-- Runtime/Weapon/CPlayerGun.hpp | 84 +++++++++++++--------------- Runtime/Weapon/CProjectileWeapon.cpp | 11 +++- Runtime/Weapon/CProjectileWeapon.hpp | 21 +++---- 19 files changed, 174 insertions(+), 171 deletions(-) diff --git a/Runtime/Weapon/CBurstFire.cpp b/Runtime/Weapon/CBurstFire.cpp index fe5af34e8..4d0cc7334 100644 --- a/Runtime/Weapon/CBurstFire.cpp +++ b/Runtime/Weapon/CBurstFire.cpp @@ -9,7 +9,8 @@ #include 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; diff --git a/Runtime/Weapon/CBurstFire.hpp b/Runtime/Weapon/CBurstFire.hpp index a46bed4fd..3ed99890a 100644 --- a/Runtime/Weapon/CBurstFire.hpp +++ b/Runtime/Weapon/CBurstFire.hpp @@ -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; - }; + bool x14_24_shouldFire : 1; + bool x14_25_avoidAccuracy : 1; const SBurst* x18_curBursts = nullptr; rstl::reserved_vector x1c_burstDefs; diff --git a/Runtime/Weapon/CEnergyProjectile.cpp b/Runtime/Weapon/CEnergyProjectile.cpp index cfc6e12d0..bd0c83d8f 100644 --- a/Runtime/Weapon/CEnergyProjectile.cpp +++ b/Runtime/Weapon/CEnergyProjectile.cpp @@ -20,13 +20,17 @@ CEnergyProjectile::CEnergyProjectile(bool active, const TToken>& visorParticle, - u16 visorSfx, bool sendCollideMsg) + const std::optional>& 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; } diff --git a/Runtime/Weapon/CEnergyProjectile.hpp b/Runtime/Weapon/CEnergyProjectile.hpp index 6156e0e0f..0413f086a 100644 --- a/Runtime/Weapon/CEnergyProjectile.hpp +++ b/Runtime/Weapon/CEnergyProjectile.hpp @@ -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; - }; + bool x3d0_24_dead : 1; + bool x3d0_25_ : 1; + bool x3d0_26_ : 1; + bool x3d0_27_camShakeDirty : 1; float x3d4_curTime = 0.f; void StopProjectile(CStateManager& mgr); diff --git a/Runtime/Weapon/CFlameThrower.cpp b/Runtime/Weapon/CFlameThrower.cpp index 154c80e31..14d8b799a 100644 --- a/Runtime/Weapon/CFlameThrower.cpp +++ b/Runtime/Weapon/CFlameThrower.cpp @@ -33,10 +33,8 @@ CFlameThrower::CFlameThrower(const TToken& 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); } diff --git a/Runtime/Weapon/CFlameThrower.hpp b/Runtime/Weapon/CFlameThrower.hpp index 423f8e7d4..2b824cc40 100644 --- a/Runtime/Weapon/CFlameThrower.hpp +++ b/Runtime/Weapon/CFlameThrower.hpp @@ -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; - }; + 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 */ void CreateFlameParticles(CStateManager&); void SetFlameLightActive(CStateManager&, bool); diff --git a/Runtime/Weapon/CGSComboFire.hpp b/Runtime/Weapon/CGSComboFire.hpp index bdac15732..2c789475d 100644 --- a/Runtime/Weapon/CGSComboFire.hpp +++ b/Runtime/Weapon/CGSComboFire.hpp @@ -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; - }; + bool x10_24_over : 1; + bool x10_25_idle : 1; 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; } diff --git a/Runtime/Weapon/CGameProjectile.cpp b/Runtime/Weapon/CGameProjectile.cpp index 312c3cb32..83dc6a2ac 100644 --- a/Runtime/Weapon/CGameProjectile.cpp +++ b/Runtime/Weapon/CGameProjectile.cpp @@ -1,5 +1,7 @@ #include "Runtime/Weapon/CGameProjectile.hpp" +#include + #include "Runtime/CStateManager.hpp" #include "Runtime/Collision/CCollisionActor.hpp" #include "Runtime/Collision/CInternalRayCastStructure.hpp" @@ -19,15 +21,15 @@ CGameProjectile::CGameProjectile(bool active, const TToken& const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner, TUniqueId homingTarget, EProjectileAttrib attribs, bool underwater, const zeus::CVector3f& scale, - const std::optional>& visorParticle, - u16 visorSfx, bool sendCollideMsg) + std::optional> 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& , 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); } diff --git a/Runtime/Weapon/CGameProjectile.hpp b/Runtime/Weapon/CGameProjectile.hpp index c3ea5e75d..06748ee5a 100644 --- a/Runtime/Weapon/CGameProjectile.hpp +++ b/Runtime/Weapon/CGameProjectile.hpp @@ -49,23 +49,18 @@ protected: CAssetId x2cc_wpscId; std::vector 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; - }; - }; + 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&, 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>& visorParticle, u16 visorSfx, - bool sendCollideMsg); + const zeus::CVector3f& scale, std::optional> visorParticle, + u16 visorSfx, bool sendCollideMsg); void Accept(IVisitor& visitor) override; virtual void ResolveCollisionWithActor(const CRayCastResult& res, CActor& act, CStateManager& mgr); diff --git a/Runtime/Weapon/CGrappleArm.cpp b/Runtime/Weapon/CGrappleArm.cpp index 9f6985968..2f1d90efa 100644 --- a/Runtime/Weapon/CGrappleArm.cpp +++ b/Runtime/Weapon/CGrappleArm.cpp @@ -37,7 +37,13 @@ CGrappleArm::CGrappleArm(const zeus::CVector3f& scale) , x398_grappleHitGen(std::make_unique(x36c_grappleHitDesc)) , x39c_grappleMuzzleGen(std::make_unique(x378_grappleMuzzleDesc)) , x3a0_grappleSwooshGen(std::make_unique(x384_grappleSwooshDesc, 0)) -, x3a4_rainSplashGenerator(std::make_unique(scale, 20, 2, 0.f, 0.125f)) { +, x3a4_rainSplashGenerator(std::make_unique(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); diff --git a/Runtime/Weapon/CGrappleArm.hpp b/Runtime/Weapon/CGrappleArm.hpp index 87873faf5..f3192ee14 100644 --- a/Runtime/Weapon/CGrappleArm.hpp +++ b/Runtime/Weapon/CGrappleArm.hpp @@ -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; - }; + 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; static float g_GrappleBeamAnglePhaseDelta; static float g_GrappleBeamXWaveAmplitude; diff --git a/Runtime/Weapon/CGunWeapon.cpp b/Runtime/Weapon/CGunWeapon.cpp index 5ff1215c1..803d3afb6 100644 --- a/Runtime/Weapon/CGunWeapon.cpp +++ b/Runtime/Weapon/CGunWeapon.cpp @@ -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); } diff --git a/Runtime/Weapon/CGunWeapon.hpp b/Runtime/Weapon/CGunWeapon.hpp index 30328d686..a4d099cde 100644 --- a/Runtime/Weapon/CGunWeapon.hpp +++ b/Runtime/Weapon/CGunWeapon.hpp @@ -84,18 +84,13 @@ 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; - // Initialize in selected beam's pose, rather than power beam's pose - bool x218_27_subtypeBasePose : 1; - bool x218_28_suitArmLocked : 1; - bool x218_29_drawHologram : 1; - }; - u32 _dummy = 0; - }; + bool x218_24 : 1; + bool x218_25_enableCharge : 1; + bool x218_26_loaded : 1; + // Initialize in selected beam's pose, rather than power beam's pose + bool x218_27_subtypeBasePose : 1; + bool x218_28_suitArmLocked : 1; + bool x218_29_drawHologram : 1; void AllocResPools(CPlayerState::EBeamId beam); void FreeResPools(); diff --git a/Runtime/Weapon/CPlasmaProjectile.cpp b/Runtime/Weapon/CPlasmaProjectile.cpp index fd999d5bd..dfb559bec 100644 --- a/Runtime/Weapon/CPlasmaProjectile.cpp +++ b/Runtime/Weapon/CPlasmaProjectile.cpp @@ -29,8 +29,8 @@ CPlasmaProjectile::CPlasmaProjectile(const TToken& 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& 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& 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); diff --git a/Runtime/Weapon/CPlasmaProjectile.hpp b/Runtime/Weapon/CPlasmaProjectile.hpp index 6634ca849..a0a0747ee 100644 --- a/Runtime/Weapon/CPlasmaProjectile.hpp +++ b/Runtime/Weapon/CPlasmaProjectile.hpp @@ -67,17 +67,12 @@ private: TToken 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; - }; + 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; struct RenderObjects { CColoredStripShader m_beamStrip1; diff --git a/Runtime/Weapon/CPlayerGun.cpp b/Runtime/Weapon/CPlayerGun.cpp index 8a279abc3..b0159965d 100644 --- a/Runtime/Weapon/CPlayerGun.cpp +++ b/Runtime/Weapon/CPlayerGun.cpp @@ -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(256, 256, true); - x832_31_inRestPose = true; - x833_24_notFidgeting = true; - x833_30_canShowAuxMuzzleEffect = true; x6e0_rightHandModel.SetSortThermal(true); kVerticalAngleTable[2] = g_tweakPlayerGun->GetUpLookAngle(); diff --git a/Runtime/Weapon/CPlayerGun.hpp b/Runtime/Weapon/CPlayerGun.hpp index 8140fbb99..fb88549cb 100644 --- a/Runtime/Weapon/CPlayerGun.hpp +++ b/Runtime/Weapon/CPlayerGun.hpp @@ -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; - }; + bool x24_24_morphing : 1; + bool x24_25_weaponChanged : 1; 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,46 +222,41 @@ private: std::unique_ptr x82c_shadow; s16 x830_chargeRumbleHandle = -1; - union { - struct { - bool x832_24_coolingCharge : 1; - bool x832_25_chargeEffectVisible : 1; - bool x832_26_comboFiring : 1; - bool x832_27_chargeAnimStarted : 1; - bool x832_28_readyForShot : 1; - bool x832_29_lockedOn : 1; - bool x832_30_requestReturnToDefault : 1; - bool x832_31_inRestPose : 1; + bool x832_24_coolingCharge : 1; + bool x832_25_chargeEffectVisible : 1; + bool x832_26_comboFiring : 1; + bool x832_27_chargeAnimStarted : 1; + bool x832_28_readyForShot : 1; + bool x832_29_lockedOn : 1; + bool x832_30_requestReturnToDefault : 1; + bool x832_31_inRestPose : 1; - bool x833_24_notFidgeting : 1; - bool x833_25_ : 1; - bool x833_26_ : 1; - bool x833_27_ : 1; - bool x833_28_phazonBeamActive : 1; - bool x833_29_pointBlankWorldSurface : 1; - bool x833_30_canShowAuxMuzzleEffect : 1; - bool x833_31_inFreeLook : 1; + bool x833_24_notFidgeting : 1; + bool x833_25_ : 1; + bool x833_26_ : 1; + bool x833_27_ : 1; + bool x833_28_phazonBeamActive : 1; + bool x833_29_pointBlankWorldSurface : 1; + bool x833_30_canShowAuxMuzzleEffect : 1; + bool x833_31_inFreeLook : 1; - bool x834_24_charging : 1; - bool x834_25_gunMotionFidgeting : 1; - bool x834_26_animPlaying : 1; - bool x834_27_underwater : 1; - bool x834_28_requestImmediateRecharge : 1; - bool x834_29_frozen : 1; - bool x834_30_inBigStrike : 1; - bool x834_31_gunMotionInFidgetBasePosition : 1; + bool x834_24_charging : 1; + bool x834_25_gunMotionFidgeting : 1; + bool x834_26_animPlaying : 1; + bool x834_27_underwater : 1; + bool x834_28_requestImmediateRecharge : 1; + bool x834_29_frozen : 1; + bool x834_30_inBigStrike : 1; + bool x834_31_gunMotionInFidgetBasePosition : 1; - bool x835_24_canFirePhazon : 1; - bool x835_25_inPhazonBeam : 1; - bool x835_26_phazonBeamMorphing : 1; - bool x835_27_intoPhazonBeam : 1; - bool x835_28_bombReady : 1; - bool x835_29_powerBombReady : 1; - bool x835_30_inPhazonPool : 1; - bool x835_31_actorAttached : 1; - }; - u32 _dummy = 0; - }; + bool x835_24_canFirePhazon : 1; + bool x835_25_inPhazonBeam : 1; + bool x835_26_phazonBeamMorphing : 1; + bool x835_27_intoPhazonBeam : 1; + bool x835_28_bombReady : 1; + bool x835_29_powerBombReady : 1; + bool x835_30_inPhazonPool : 1; + bool x835_31_actorAttached : 1; CTexturedQuadFilter m_screenQuad{EFilterType::Blend, CGraphics::g_SpareTexture.get(), CTexturedQuadFilter::ZTest::GEqualZWrite}; diff --git a/Runtime/Weapon/CProjectileWeapon.cpp b/Runtime/Weapon/CProjectileWeapon.cpp index f3b816c04..f73090744 100644 --- a/Runtime/Weapon/CProjectileWeapon.cpp +++ b/Runtime/Weapon/CProjectileWeapon.cpp @@ -15,8 +15,15 @@ CProjectileWeapon::CProjectileWeapon(const TToken& 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; diff --git a/Runtime/Weapon/CProjectileWeapon.hpp b/Runtime/Weapon/CProjectileWeapon.hpp index 1b83e1816..6ff083fde 100644 --- a/Runtime/Weapon/CProjectileWeapon.hpp +++ b/Runtime/Weapon/CProjectileWeapon.hpp @@ -53,19 +53,14 @@ class CProjectileWeapon { std::unique_ptr x118_swoosh1; std::unique_ptr x11c_swoosh2; std::unique_ptr x120_swoosh3; - union { - struct { - bool x124_24_active : 1; - bool x124_25_APSO : 1; - bool x124_26_AP11 : 1; - bool x124_27_AP21 : 1; - bool x124_28_AS11 : 1; - bool x124_29_AS12 : 1; - bool x124_30_AS13 : 1; - bool x124_31_VMD2 : 1; - }; - u32 _dummy = 0; - }; + bool x124_24_active : 1; + bool x124_25_APSO : 1; + bool x124_26_AP11 : 1; + bool x124_27_AP21 : 1; + bool x124_28_AS11 : 1; + bool x124_29_AS12 : 1; + bool x124_30_AS13 : 1; + bool x124_31_VMD2 : 1; public: CProjectileWeapon(const TToken& wDesc, const zeus::CVector3f& worldOffset, From bb7e94f30487b09dc0185d36e89f0a4a96d02519 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 11 Apr 2020 01:50:10 -0400 Subject: [PATCH 14/16] Runtime/World: Replace bitfield unions with constructor initializers --- Runtime/World/CActor.cpp | 42 ++++++----- Runtime/World/CActor.hpp | 53 +++++++------- Runtime/World/CActorModelParticles.cpp | 7 +- Runtime/World/CActorModelParticles.hpp | 9 +-- Runtime/World/CActorParameters.hpp | 13 ++-- Runtime/World/CAmbientAI.cpp | 4 +- Runtime/World/CAmbientAI.hpp | 10 +-- Runtime/World/CEntity.cpp | 9 +-- Runtime/World/CEntity.hpp | 14 ++-- Runtime/World/CFishCloud.cpp | 13 ++-- Runtime/World/CFishCloud.hpp | 21 +++--- Runtime/World/CGameArea.hpp | 28 ++++---- Runtime/World/CKnockBackController.cpp | 22 +++--- Runtime/World/CKnockBackController.hpp | 37 +++++----- Runtime/World/CPatterned.cpp | 46 +++++++++--- Runtime/World/CPatterned.hpp | 83 +++++++++------------- Runtime/World/CPlayer.cpp | 32 +++++++-- Runtime/World/CPlayer.hpp | 59 +++++++-------- Runtime/World/CScriptActorKeyframe.cpp | 15 ++-- Runtime/World/CScriptActorKeyframe.hpp | 17 ++--- Runtime/World/CScriptActorRotate.hpp | 14 ++-- Runtime/World/CScriptAiJumpPoint.cpp | 3 +- Runtime/World/CScriptAiJumpPoint.hpp | 7 +- Runtime/World/CScriptCameraHintTrigger.cpp | 9 +-- Runtime/World/CScriptCameraHintTrigger.hpp | 13 ++-- Runtime/World/CScriptCameraPitchVolume.cpp | 4 +- Runtime/World/CScriptCameraPitchVolume.hpp | 10 +-- Runtime/World/CScriptColorModulate.cpp | 21 +++--- Runtime/World/CScriptColorModulate.hpp | 23 +++--- Runtime/World/CScriptControllerAction.cpp | 10 +-- Runtime/World/CScriptControllerAction.hpp | 11 +-- Runtime/World/CScriptCoverPoint.cpp | 9 ++- Runtime/World/CScriptCoverPoint.hpp | 21 ++---- Runtime/World/CScriptDamageableTrigger.cpp | 8 ++- Runtime/World/CScriptDamageableTrigger.hpp | 16 ++--- Runtime/World/CScriptDebris.cpp | 26 ++++--- Runtime/World/CScriptDebris.hpp | 23 +++--- Runtime/World/CScriptDock.cpp | 13 ++-- Runtime/World/CScriptDock.hpp | 11 +-- Runtime/World/CScriptEffect.cpp | 23 +++--- Runtime/World/CScriptEffect.hpp | 27 +++---- Runtime/World/CScriptGenerator.hpp | 9 +-- Runtime/World/CScriptGunTurret.cpp | 18 ++--- Runtime/World/CScriptGunTurret.hpp | 21 +++--- Runtime/World/CScriptMazeNode.cpp | 7 +- Runtime/World/CScriptMazeNode.hpp | 11 +-- Runtime/World/CScriptMemoryRelay.hpp | 11 +-- Runtime/World/CScriptPlayerActor.cpp | 14 ++-- Runtime/World/CScriptPlayerActor.hpp | 23 +++--- Runtime/World/CScriptShadowProjector.cpp | 8 +-- Runtime/World/CScriptShadowProjector.hpp | 10 +-- Runtime/World/CScriptSound.cpp | 19 ++--- Runtime/World/CScriptSound.hpp | 25 +++---- Runtime/World/CScriptSpawnPoint.hpp | 9 +-- Runtime/World/CScriptSpecialFunction.cpp | 14 +++- Runtime/World/CScriptSpecialFunction.hpp | 27 +++---- Runtime/World/CScriptTargetingPoint.cpp | 3 +- Runtime/World/CScriptTargetingPoint.hpp | 7 +- Runtime/World/CScriptTrigger.cpp | 14 ++-- Runtime/World/CScriptTrigger.hpp | 18 ++--- Runtime/World/CScriptWater.cpp | 12 ++-- Runtime/World/CScriptWater.hpp | 20 +++--- Runtime/World/CScriptWorldTeleporter.hpp | 12 +--- Runtime/World/CStateMachine.hpp | 9 +-- Runtime/World/CWallCrawlerSwarm.cpp | 8 +-- Runtime/World/CWallCrawlerSwarm.hpp | 30 ++++---- Runtime/World/CWorld.cpp | 9 ++- Runtime/World/CWorld.hpp | 14 ++-- Runtime/World/CWorldTransManager.hpp | 22 +++--- 69 files changed, 583 insertions(+), 657 deletions(-) diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index 37fa2b6d4..1d538dfc8 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -34,27 +34,37 @@ CActor::CActor(TUniqueId uid, bool active, std::string_view name, const CEntityI , x34_transform(xf) , x68_material(MakeActorMaterialList(list, params)) , x70_materialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {0ull})) -, xc6_nextDrawNode(otherUid) { +, xc6_nextDrawNode(otherUid) +, xe4_24_nextNonLoopingSfxHandle(0) +, xe4_27_notInSortedLists(true) +, xe4_28_transformDirty(true) +, xe4_29_actorLightsDirty(true) +, xe4_30_outOfFrustum(false) +, xe4_31_calculateLighting(true) +, xe5_24_shadowEnabled(false) +, xe5_25_shadowDirty(false) +, xe5_26_muted(false) +, xe5_27_useInSortedLists(true) +, xe5_28_callTouch(true) +, xe5_29_globalTimeProvider(params.x58_24_globalTimeProvider) +, xe5_30_renderUnsorted(params.x58_26_renderUnsorted) +, xe5_31_pointGeneratorParticles(false) +, xe6_24_fluidCounter(0) +, xe6_27_thermalVisorFlags(u8(params.x58_25_thermalHeat ? 2 : 1)) +, xe6_29_renderParticleDBInside(true) +, xe6_30_enablePitchBend(false) +, xe6_31_targetableVisorFlags(params.GetVisorParameters().GetMask()) +, xe7_27_enableRender(true) +, xe7_28_worldLightingDirty(false) +, xe7_29_drawEnabled(active) +, xe7_30_doTargetDistanceTest(true) +, xe7_31_targetable(true) { x90_actorLights = mData.IsNull() ? nullptr : params.x0_lightParms.MakeActorLights(); if (mData.x10_animData || mData.x1c_normalModel) x64_modelData = std::make_unique(std::move(mData)); xd0_damageMag = params.x64_thermalMag; xd8_nonLoopingSfxHandles.resize(2); - xe4_27_notInSortedLists = true; - xe4_28_transformDirty = true; - xe4_29_actorLightsDirty = true; - xe4_31_calculateLighting = true; - xe5_27_useInSortedLists = true; - xe5_28_callTouch = true; - xe5_29_globalTimeProvider = params.x58_24_globalTimeProvider; - xe5_30_renderUnsorted = params.x58_26_renderUnsorted; - xe6_27_thermalVisorFlags = u8(params.x58_25_thermalHeat ? 2 : 1); - xe6_29_renderParticleDBInside = true; - xe6_31_targetableVisorFlags = params.GetVisorParameters().GetMask(); - xe7_27_enableRender = true; - xe7_29_drawEnabled = active; - xe7_30_doTargetDistanceTest = true; - xe7_31_targetable = true; + if (x64_modelData) { if (params.x44_xrayAssets.first.IsValid()) x64_modelData->SetXRayModel(params.x44_xrayAssets); diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index 69e0abbd4..5913d3279 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -48,35 +48,30 @@ protected: float xd0_damageMag; float xd4_maxVol = 1.f; rstl::reserved_vector xd8_nonLoopingSfxHandles; - union { - struct { - u8 xe4_24_nextNonLoopingSfxHandle : 3; - bool xe4_27_notInSortedLists : 1; - bool xe4_28_transformDirty : 1; - bool xe4_29_actorLightsDirty : 1; - bool xe4_30_outOfFrustum : 1; - bool xe4_31_calculateLighting : 1; - bool xe5_24_shadowEnabled : 1; - bool xe5_25_shadowDirty : 1; - bool xe5_26_muted : 1; - bool xe5_27_useInSortedLists : 1; - bool xe5_28_callTouch : 1; - bool xe5_29_globalTimeProvider : 1; - bool xe5_30_renderUnsorted : 1; - bool xe5_31_pointGeneratorParticles : 1; - u8 xe6_24_fluidCounter : 3; - u8 xe6_27_thermalVisorFlags : 2; // 1: thermal cold, 2: thermal hot - bool xe6_29_renderParticleDBInside : 1; - bool xe6_30_enablePitchBend : 1; - u8 xe6_31_targetableVisorFlags : 4; - bool xe7_27_enableRender : 1; - bool xe7_28_worldLightingDirty : 1; - bool xe7_29_drawEnabled : 1; - bool xe7_30_doTargetDistanceTest : 1; - bool xe7_31_targetable : 1; - }; - u32 dummy = 0; - }; + u8 xe4_24_nextNonLoopingSfxHandle : 3; + bool xe4_27_notInSortedLists : 1; + bool xe4_28_transformDirty : 1; + bool xe4_29_actorLightsDirty : 1; + bool xe4_30_outOfFrustum : 1; + bool xe4_31_calculateLighting : 1; + bool xe5_24_shadowEnabled : 1; + bool xe5_25_shadowDirty : 1; + bool xe5_26_muted : 1; + bool xe5_27_useInSortedLists : 1; + bool xe5_28_callTouch : 1; + bool xe5_29_globalTimeProvider : 1; + bool xe5_30_renderUnsorted : 1; + bool xe5_31_pointGeneratorParticles : 1; + u8 xe6_24_fluidCounter : 3; + u8 xe6_27_thermalVisorFlags : 2; // 1: thermal cold, 2: thermal hot + bool xe6_29_renderParticleDBInside : 1; + bool xe6_30_enablePitchBend : 1; + u8 xe6_31_targetableVisorFlags : 4; + bool xe7_27_enableRender : 1; + bool xe7_28_worldLightingDirty : 1; + bool xe7_29_drawEnabled : 1; + bool xe7_30_doTargetDistanceTest : 1; + bool xe7_31_targetable : 1; boo::ObjToken m_reflectionCube; diff --git a/Runtime/World/CActorModelParticles.cpp b/Runtime/World/CActorModelParticles.cpp index ceb99f7d5..d531b7670 100644 --- a/Runtime/World/CActorModelParticles.cpp +++ b/Runtime/World/CActorModelParticles.cpp @@ -25,7 +25,12 @@ static bool IsMediumOrLarge(CActor& act) { } CActorModelParticles::CItem::CItem(const CEntity& ent, CActorModelParticles& parent) -: x0_id(ent.GetUniqueId()), x4_areaId(ent.GetAreaIdAlways()), xdc_ashy(parent.x48_ashy), x128_parent(parent) { +: x0_id(ent.GetUniqueId()) +, x4_areaId(ent.GetAreaIdAlways()) +, xdc_ashy(parent.x48_ashy) +, x128_parent(parent) +, x12c_24_thermalCold(false) +, x12c_25_thermalHot(false) { x8_onFireGens.resize(8); } diff --git a/Runtime/World/CActorModelParticles.hpp b/Runtime/World/CActorModelParticles.hpp index df191ab5d..bb27fa909 100644 --- a/Runtime/World/CActorModelParticles.hpp +++ b/Runtime/World/CActorModelParticles.hpp @@ -56,13 +56,8 @@ public: zeus::CVector3f xec_particleOffsetScale = zeus::skOne3f; zeus::CTransform xf8_iceXf; CActorModelParticles& x128_parent; - union { - struct { - bool x12c_24_thermalCold : 1; - bool x12c_25_thermalHot : 1; - }; - u16 _dummy = 0; - }; + bool x12c_24_thermalCold : 1; + bool x12c_25_thermalHot : 1; float x130_remTime = 10.f; mutable u8 x134_lockDeps = 0; bool UpdateOnFire(float dt, CActor* actor, CStateManager& mgr); diff --git a/Runtime/World/CActorParameters.hpp b/Runtime/World/CActorParameters.hpp index b7b395b43..8ab6be70f 100644 --- a/Runtime/World/CActorParameters.hpp +++ b/Runtime/World/CActorParameters.hpp @@ -18,15 +18,10 @@ class CActorParameters { std::pair x44_xrayAssets = {}; std::pair x4c_thermalAssets = {}; CVisorParameters x54_visorParms; - union { - struct { - bool x58_24_globalTimeProvider : 1; - bool x58_25_thermalHeat : 1; - bool x58_26_renderUnsorted : 1; - bool x58_27_noSortThermal : 1; - }; - u32 _dummy = 0; - }; + bool x58_24_globalTimeProvider : 1; + bool x58_25_thermalHeat : 1; + bool x58_26_renderUnsorted : 1; + bool x58_27_noSortThermal : 1; float x5c_fadeInTime = 0.f; float x60_fadeOutTime = 0.f; float x64_thermalMag = 0.f; diff --git a/Runtime/World/CAmbientAI.cpp b/Runtime/World/CAmbientAI.cpp index 4fc4ae2e9..462854a0b 100644 --- a/Runtime/World/CAmbientAI.cpp +++ b/Runtime/World/CAmbientAI.cpp @@ -19,7 +19,9 @@ CAmbientAI::CAmbientAI(TUniqueId uid, std::string_view name, const CEntityInfo& , x2d8_impactRange(impactRange) , x2dc_defaultAnim(GetModelData()->GetAnimationData()->GetDefaultAnimation()) , x2e0_alertAnim(alertAnim) -, x2e4_impactAnim(impactAnim) { +, x2e4_impactAnim(impactAnim) +, x2e8_24_dead(false) +, x2e8_25_animating(false) { GetModelData()->GetAnimationData()->EnableLooping(true); } diff --git a/Runtime/World/CAmbientAI.hpp b/Runtime/World/CAmbientAI.hpp index 8ba3dbb03..37c979955 100644 --- a/Runtime/World/CAmbientAI.hpp +++ b/Runtime/World/CAmbientAI.hpp @@ -26,14 +26,8 @@ class CAmbientAI : public CPhysicsActor { s32 x2dc_defaultAnim; s32 x2e0_alertAnim; s32 x2e4_impactAnim; - - union { - struct { - bool x2e8_24_dead : 1; - bool x2e8_25_animating : 1; - }; - u32 _dummy = 0; - }; + bool x2e8_24_dead : 1; + bool x2e8_25_animating : 1; public: CAmbientAI(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&, diff --git a/Runtime/World/CEntity.cpp b/Runtime/World/CEntity.cpp index 850b3ec5e..0194ca907 100644 --- a/Runtime/World/CEntity.cpp +++ b/Runtime/World/CEntity.cpp @@ -10,10 +10,11 @@ CEntity::CEntity(TUniqueId uniqueId, const CEntityInfo& info, bool active, std:: , x8_uid(uniqueId) , xc_editorId(info.GetEditorId()) , x10_name(name) -, x20_conns(info.GetConnectionList()) { - x30_24_active = active; - x30_27_inUse = x4_areaId != kInvalidAreaId; -} +, x20_conns(info.GetConnectionList()) +, x30_24_active(active) +, x30_25_inGraveyard(false) +, x30_26_scriptingBlocked(false) +, x30_27_inUse(x4_areaId != kInvalidAreaId) {} void CEntity::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) { switch (msg) { diff --git a/Runtime/World/CEntity.hpp b/Runtime/World/CEntity.hpp index fd8dd406a..debd13f68 100644 --- a/Runtime/World/CEntity.hpp +++ b/Runtime/World/CEntity.hpp @@ -21,16 +21,10 @@ protected: TEditorId xc_editorId; std::string x10_name; std::vector x20_conns; - - union { - struct { - bool x30_24_active : 1; - bool x30_25_inGraveyard : 1; - bool x30_26_scriptingBlocked : 1; - bool x30_27_inUse : 1; - }; - u8 _dummy = 0; - }; + bool x30_24_active : 1; + bool x30_25_inGraveyard : 1; + bool x30_26_scriptingBlocked : 1; + bool x30_27_inUse : 1; public: static const std::vector NullConnectionList; diff --git a/Runtime/World/CFishCloud.cpp b/Runtime/World/CFishCloud.cpp index 16f86f27d..80d16c219 100644 --- a/Runtime/World/CFishCloud.cpp +++ b/Runtime/World/CFishCloud.cpp @@ -46,11 +46,16 @@ CFishCloud::CFishCloud(TUniqueId uid, bool active, std::string_view name, const , x16c_color(color) , x170_weaponKillRadius(weaponKillRadius) , x174_containmentRadius(containmentRadius) -, x234_deathSfx(deathSfx != 0xffffffff ? CSfxManager::TranslateSFXID(u16(deathSfx & 0xffff)) : u16(0xffff)) { - x250_28_killable = killable; - x250_29_repelFromThreats = repelFromThreats; +, x234_deathSfx(deathSfx != 0xffffffff ? CSfxManager::TranslateSFXID(u16(deathSfx & 0xffff)) : u16(0xffff)) +, x250_24_randomMovement(false) +, x250_25_worldSpace(true) // The result of a close_enough paradox (weird inlined test?) +, x250_26_enableWeaponRepelDamping(false) +, x250_27_validModel(false) +, x250_28_killable(killable) +, x250_29_repelFromThreats(repelFromThreats) +, x250_30_enablePlayerRepelDamping(false) +, x250_31_updateWithoutPartitions(false) { x108_modifierSources.reserve(10); - x250_25_worldSpace = true; // The result of a close_enough paradox (weird inlined test?) if (aRes.GetId().IsValid()) { x1b0_models.emplace_back(std::make_unique(aRes)); x1b0_models.emplace_back(std::make_unique(aRes)); diff --git a/Runtime/World/CFishCloud.hpp b/Runtime/World/CFishCloud.hpp index f6c13f3bf..a26eaef6f 100644 --- a/Runtime/World/CFishCloud.hpp +++ b/Runtime/World/CFishCloud.hpp @@ -84,19 +84,14 @@ class CFishCloud : public CActor { u16 x234_deathSfx; zeus::CVector3f x238_partitionPitch; zeus::CVector3f x244_ooPartitionPitch; - union { - struct { - bool x250_24_randomMovement : 1; - bool x250_25_worldSpace : 1; - bool x250_26_enableWeaponRepelDamping : 1; - bool x250_27_validModel : 1; - bool x250_28_killable : 1; - bool x250_29_repelFromThreats : 1; - bool x250_30_enablePlayerRepelDamping : 1; - bool x250_31_updateWithoutPartitions : 1; - }; - u32 _dummy = 0; - }; + bool x250_24_randomMovement : 1; + bool x250_25_worldSpace : 1; + bool x250_26_enableWeaponRepelDamping : 1; + bool x250_27_validModel : 1; + bool x250_28_killable : 1; + bool x250_29_repelFromThreats : 1; + bool x250_30_enablePlayerRepelDamping : 1; + bool x250_31_updateWithoutPartitions : 1; void UpdateParticles(float dt); void UpdatePartitionList(); diff --git a/Runtime/World/CGameArea.hpp b/Runtime/World/CGameArea.hpp index ea0ae48c0..b8571699c 100644 --- a/Runtime/World/CGameArea.hpp +++ b/Runtime/World/CGameArea.hpp @@ -229,18 +229,13 @@ public: // std::vector x10f0_tokens; u32 x1100_ = 0; u32 x1104_ = 0; - union { - struct { - bool x1108_24_ : 1; - bool x1108_25_modelsConstructed : 1; - bool x1108_26_ : 1; - bool x1108_27_ : 1; - bool x1108_28_occlusionPinged : 1; - bool x1108_29_pvsHasActors : 1; - bool x1108_30_ : 1; - }; - u32 _dummy = 0; - }; + bool x1108_24_ : 1; + bool x1108_25_modelsConstructed : 1; + bool x1108_26_ : 1; + bool x1108_27_ : 1; + bool x1108_28_occlusionPinged : 1; + bool x1108_29_pvsHasActors : 1; + bool x1108_30_ : 1; std::vector> x110c_layerPtrs; float x111c_thermalCurrent = 0.f; float x1120_thermalSpeed = 0.f; @@ -251,6 +246,15 @@ public: float x1134_weaponWorldLightingSpeed = 0.f; float x1138_weaponWorldLightingTarget = 1.f; u32 x113c_playerActorsLoading = 0; + + CPostConstructed() + : x1108_24_(false) + , x1108_25_modelsConstructed(false) + , x1108_26_(false) + , x1108_27_(false) + , x1108_28_occlusionPinged(false) + , x1108_29_pvsHasActors(false) + , x1108_30_(false) {} }; private: diff --git a/Runtime/World/CKnockBackController.cpp b/Runtime/World/CKnockBackController.cpp index 9c56b6042..4815c56d7 100644 --- a/Runtime/World/CKnockBackController.cpp +++ b/Runtime/World/CKnockBackController.cpp @@ -357,15 +357,19 @@ static const CKnockBackController::KnockBackParms KnockBackParmsTable[3][19][4] }, }; -CKnockBackController::CKnockBackController(EKnockBackVariant variant) : x0_variant(variant) { - x81_24_autoResetImpulse = true; - x81_25_enableFreeze = true; - x81_27_enableBurn = true; - x81_28_enableBurnDeath = true; - x81_29_enableExplodeDeath = true; - x81_30_enableLaggedBurnDeath = true; - x81_31_ = true; - x82_24_ = true; +CKnockBackController::CKnockBackController(EKnockBackVariant variant) +: x0_variant(variant) +, x81_24_autoResetImpulse(true) +, x81_25_enableFreeze(true) +, x81_26_enableShock(false) +, x81_27_enableBurn(true) +, x81_28_enableBurnDeath(true) +, x81_29_enableExplodeDeath(true) +, x81_30_enableLaggedBurnDeath(true) +, x81_31_(true) +, x82_24_(true) +, x82_25_inDeferredKnockBack(false) +, x82_26_locomotionDuringElectrocution(false) { for (int i = 0; i < 5; ++i) { x24_.push_back(std::make_pair(0.f, FLT_MAX)); x80_availableStates.set(i); diff --git a/Runtime/World/CKnockBackController.hpp b/Runtime/World/CKnockBackController.hpp index e3f4339ac..b4a9601e9 100644 --- a/Runtime/World/CKnockBackController.hpp +++ b/Runtime/World/CKnockBackController.hpp @@ -61,16 +61,16 @@ enum class EKnockBackAnimationFollowUp { class CKnockBackController { public: struct KnockBackParms { - EKnockBackAnimationState x0_animState; - EKnockBackAnimationFollowUp x4_animFollowup; - float x8_followupDuration; - float xc_intoFreezeDur; + EKnockBackAnimationState x0_animState = EKnockBackAnimationState::None; + EKnockBackAnimationFollowUp x4_animFollowup = EKnockBackAnimationFollowUp::None; + float x8_followupDuration = 0.f; + float xc_intoFreezeDur = 0.f; }; private: friend class CPatterned; EKnockBackVariant x0_variant; - KnockBackParms x4_activeParms; + KnockBackParms x4_activeParms{}; EWeaponType x14_deferWeaponType = EWeaponType::None; EKnockBackAnimationState x18_minAnimState = EKnockBackAnimationState::None; EKnockBackAnimationState x1c_maxAnimState = EKnockBackAnimationState::Fall; @@ -86,22 +86,17 @@ private: u32 x74_ = 0; pas::ESeverity x7c_severity = pas::ESeverity::One; std::bitset<5> x80_availableStates; - union { - struct { - bool x81_24_autoResetImpulse : 1; // t - bool x81_25_enableFreeze : 1; // t - bool x81_26_enableShock : 1; - bool x81_27_enableBurn : 1; // t - bool x81_28_enableBurnDeath : 1; // t - bool x81_29_enableExplodeDeath : 1; // t - bool x81_30_enableLaggedBurnDeath : 1; // t - bool x81_31_ : 1; // t - bool x82_24_ : 1; // t - bool x82_25_inDeferredKnockBack : 1; - bool x82_26_locomotionDuringElectrocution : 1; - }; - u32 dummy = 0; - }; + bool x81_24_autoResetImpulse : 1; // t + bool x81_25_enableFreeze : 1; // t + bool x81_26_enableShock : 1; + bool x81_27_enableBurn : 1; // t + bool x81_28_enableBurnDeath : 1; // t + bool x81_29_enableExplodeDeath : 1; // t + bool x81_30_enableLaggedBurnDeath : 1; // t + bool x81_31_ : 1; // t + bool x82_24_ : 1; // t + bool x82_25_inDeferredKnockBack : 1; + bool x82_26_locomotionDuringElectrocution : 1; void ApplyImpulse(float dt, CPatterned& parent); bool TickDeferredTimer(float dt); EKnockBackCharacterState GetKnockBackCharacterState(CPatterned& parent); diff --git a/Runtime/World/CPatterned.cpp b/Runtime/World/CPatterned.cpp index 1360075e3..d1f502c2c 100644 --- a/Runtime/World/CPatterned.cpp +++ b/Runtime/World/CPatterned.cpp @@ -47,6 +47,15 @@ CPatterned::CPatterned(ECharacter character, TUniqueId uid, std::string_view nam , x300_maxAttackRange(pInfo.x1c_maxAttackRange) , x304_averageAttackTime(pInfo.x20_averageAttackTime) , x308_attackTimeVariation(pInfo.x24_attackTimeVariation) +, x328_24_inPosition(false) +, x328_25_verticalMovement(moveType == EMovementType::Flyer) +, x328_26_solidCollision(false) +, x328_27_onGround(moveType != EMovementType::Flyer) +, x328_28_prevOnGround(true) +, x328_29_noPatternShagging(false) +, x328_30_lookAtDeathDir(true) +, x328_31_energyAttractor(false) +, x329_24_(true) , x34c_character(character) , x388_anim(pInfo.GetAnimationParameters().GetInitialAnimation()) , x3b4_speed(pInfo.x4_speed) @@ -61,18 +70,33 @@ CPatterned::CPatterned(ECharacter character, TUniqueId uid, std::string_view nam , x3dc_frozenXDamageThreshold(pInfo.xe0_frozenXDamage) , x3e0_xDamageDelay(pInfo.xe4_xDamageDelay) , x3fc_flavor(flavor) +, x400_24_hitByPlayerProjectile(false) +, x400_25_alive(true) +, x400_26_(false) +, x400_27_fadeToDeath(false) +, x400_28_pendingMassiveDeath(false) +, x400_29_pendingMassiveFrozenDeath(false) +, x400_30_patternShagged(false) +, x400_31_isFlyer(moveType == CPatterned::EMovementType::Flyer) +, x401_24_pathOverCount(0) +, x401_26_disableMove(false) +, x401_27_phazingOut(false) +, x401_28_burning(false) +, x401_29_laggedBurnDeath(false) +, x401_30_pendingDeath(false) +, x401_31_nextPendingShock(false) +, x402_24_pendingShock(false) +, x402_25_lostMassiveFrozenHP(false) +, x402_26_dieIf80PercFrozen(false) +, x402_27_noXrayModel(false) +, x402_28_isMakingBigStrike(false) +, x402_29_drawParticles(true) +, x402_30_updateThermalFrozenState(x402_31_thawed = actorParms.HasThermalHeat()) +, x402_31_thawed(false) +, x403_24_keepThermalVisorState(false) +, x403_25_enableStateMachine(true) // t +, x403_26_stateControlledMassiveDeath(true) , x460_knockBackController(kbVariant) { - x328_25_verticalMovement = moveType == EMovementType::Flyer; - x328_27_onGround = moveType != EMovementType::Flyer; - x328_28_prevOnGround = true; - x328_30_lookAtDeathDir = true; - x329_24_ = true; - x400_25_alive = true; - x400_31_isFlyer = moveType == CPatterned::EMovementType::Flyer; - x402_29_drawParticles = true; - x402_30_updateThermalFrozenState = x402_31_thawed = actorParms.HasThermalHeat(); - x403_25_enableStateMachine = true; - x403_26_stateControlledMassiveDeath = true; x404_contactDamage = pInfo.x34_contactDamageInfo; x424_damageWaitTime = pInfo.x50_damageWaitTime; x454_deathSfx = pInfo.xe8_deathSfx; diff --git a/Runtime/World/CPatterned.hpp b/Runtime/World/CPatterned.hpp index 812675b6e..e008cfdd1 100644 --- a/Runtime/World/CPatterned.hpp +++ b/Runtime/World/CPatterned.hpp @@ -125,21 +125,15 @@ protected: EBehaviourOrient x30c_behaviourOrient = EBehaviourOrient::MoveDir; zeus::CVector3f x310_moveVec; zeus::CVector3f x31c_faceVec; - union { - struct { - bool x328_24_inPosition : 1; - bool x328_25_verticalMovement : 1; - bool x328_26_solidCollision : 1; - bool x328_27_onGround : 1; - bool x328_28_prevOnGround : 1; - bool x328_29_noPatternShagging : 1; - bool x328_30_lookAtDeathDir : 1; - bool x328_31_energyAttractor : 1; - bool x329_24_ : 1; - }; - u32 _dummy = 0; - }; - + bool x328_24_inPosition : 1; + bool x328_25_verticalMovement : 1; + bool x328_26_solidCollision : 1; + bool x328_27_onGround : 1; + bool x328_28_prevOnGround : 1; + bool x328_29_noPatternShagging : 1; + bool x328_30_lookAtDeathDir : 1; + bool x328_31_energyAttractor : 1; + bool x329_24_ : 1; EAnimState x32c_animState = EAnimState::NotReady; CStateMachineState x330_stateMachineState; ECharacter x34c_character; @@ -176,39 +170,32 @@ protected: float x3f4_burnThinkRateTimer = 0.f; EMoveState x3f8_moveState = EMoveState::Zero; EFlavorType x3fc_flavor; - - union { - struct { - bool x400_24_hitByPlayerProjectile : 1; - bool x400_25_alive : 1; // t - bool x400_26_ : 1; - bool x400_27_fadeToDeath : 1; - bool x400_28_pendingMassiveDeath : 1; - bool x400_29_pendingMassiveFrozenDeath : 1; - bool x400_30_patternShagged : 1; - bool x400_31_isFlyer : 1; - uint32_t x401_24_pathOverCount : 2; - bool x401_26_disableMove : 1; - bool x401_27_phazingOut : 1; - bool x401_28_burning : 1; - bool x401_29_laggedBurnDeath : 1; - bool x401_30_pendingDeath : 1; - bool x401_31_nextPendingShock : 1; - bool x402_24_pendingShock : 1; - bool x402_25_lostMassiveFrozenHP : 1; - bool x402_26_dieIf80PercFrozen : 1; - bool x402_27_noXrayModel : 1; - bool x402_28_isMakingBigStrike : 1; - bool x402_29_drawParticles : 1; // t - bool x402_30_updateThermalFrozenState : 1; - bool x402_31_thawed : 1; - bool x403_24_keepThermalVisorState : 1; - bool x403_25_enableStateMachine : 1; // t - bool x403_26_stateControlledMassiveDeath : 1; // t - }; - u32 _dummy2 = 0; - }; - + bool x400_24_hitByPlayerProjectile : 1; + bool x400_25_alive : 1; // t + bool x400_26_ : 1; + bool x400_27_fadeToDeath : 1; + bool x400_28_pendingMassiveDeath : 1; + bool x400_29_pendingMassiveFrozenDeath : 1; + bool x400_30_patternShagged : 1; + bool x400_31_isFlyer : 1; + uint32_t x401_24_pathOverCount : 2; + bool x401_26_disableMove : 1; + bool x401_27_phazingOut : 1; + bool x401_28_burning : 1; + bool x401_29_laggedBurnDeath : 1; + bool x401_30_pendingDeath : 1; + bool x401_31_nextPendingShock : 1; + bool x402_24_pendingShock : 1; + bool x402_25_lostMassiveFrozenHP : 1; + bool x402_26_dieIf80PercFrozen : 1; + bool x402_27_noXrayModel : 1; + bool x402_28_isMakingBigStrike : 1; + bool x402_29_drawParticles : 1; // t + bool x402_30_updateThermalFrozenState : 1; + bool x402_31_thawed : 1; + bool x403_24_keepThermalVisorState : 1; + bool x403_25_enableStateMachine : 1; // t + bool x403_26_stateControlledMassiveDeath : 1; // t CDamageInfo x404_contactDamage; float x420_curDamageRemTime = 0.f; float x424_damageWaitTime; diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index 812085fe1..ea281b5e8 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -221,17 +221,39 @@ CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox& stepDown) , x2d8_fpBounds(aabb) , x7d0_animRes(resId, 0, playerScale, 0, true) -, x7d8_beamScale(playerScale) { +, x7d8_beamScale(playerScale) +, x9c4_24_visorChangeRequested(false) +, x9c4_25_showCrosshairs(false) +, x9c4_26_(true) +, x9c4_27_canEnterMorphBall(true) +, x9c4_28_canLeaveMorphBall(true) +, x9c4_29_spiderBallControlXY(false) +, x9c4_30_controlDirOverride(false) +, x9c4_31_inWaterMovement(false) +, x9c5_24_(false) +, x9c5_25_splashUpdated(false) +, x9c5_26_(false) +, x9c5_27_camSubmerged(false) +, x9c5_28_slidingOnWall(false) +, x9c5_29_hitWall(false) +, x9c5_30_selectFluidBallSound(false) +, x9c5_31_stepCameraZBiasDirty(true) +, x9c6_24_extendTargetDistance(false) +, x9c6_25_interpolatingControlDir(false) +, x9c6_26_outOfBallLookAtHint(false) +, x9c6_27_aimingAtProjectile(false) +, x9c6_28_aligningGrappleSwingTurn(false) +, x9c6_29_disableInput(false) +, x9c6_30_newScanScanning(false) +, x9c6_31_overrideRadarRadius(false) +, x9c7_24_noDamageLoopSfx(false) +, x9c7_25_outOfBallLookAtHintActor(false) { x490_gun = std::make_unique(uid); x49c_gunHolsterRemTime = g_tweakPlayerGun->GetGunNotFiringTime(); x4a0_failsafeTest = std::make_unique(); x76c_cameraBob = std::make_unique(CPlayerCameraBob::ECameraBobType::One, CPlayerCameraBob::GetCameraBobExtent(), CPlayerCameraBob::GetCameraBobPeriod()); - x9c4_26_ = true; - x9c4_27_canEnterMorphBall = true; - x9c4_28_canLeaveMorphBall = true; - x9c5_31_stepCameraZBiasDirty = true; const CAssetId beamId = g_tweakPlayerRes->GetBeamBallTransitionModel(x7ec_beam); x7f0_ballTransitionBeamModel = std::make_unique(CStaticRes(beamId, playerScale)); x730_transitionModels.reserve(3); diff --git a/Runtime/World/CPlayer.hpp b/Runtime/World/CPlayer.hpp index bbe098bd5..b36616ea7 100644 --- a/Runtime/World/CPlayer.hpp +++ b/Runtime/World/CPlayer.hpp @@ -285,39 +285,32 @@ private: rstl::reserved_vector, 32> x838_playerHints; rstl::reserved_vector x93c_playerHintsToRemove; rstl::reserved_vector x980_playerHintsToAdd; - - union { - struct { - bool x9c4_24_visorChangeRequested : 1; - bool x9c4_25_showCrosshairs : 1; - bool x9c4_26_ : 1; - bool x9c4_27_canEnterMorphBall : 1; - bool x9c4_28_canLeaveMorphBall : 1; - bool x9c4_29_spiderBallControlXY : 1; - bool x9c4_30_controlDirOverride : 1; - bool x9c4_31_inWaterMovement : 1; - bool x9c5_24_ : 1; - bool x9c5_25_splashUpdated : 1; - bool x9c5_26_ : 1; - bool x9c5_27_camSubmerged : 1; - bool x9c5_28_slidingOnWall : 1; - bool x9c5_29_hitWall : 1; - bool x9c5_30_selectFluidBallSound : 1; - bool x9c5_31_stepCameraZBiasDirty : 1; - bool x9c6_24_extendTargetDistance : 1; - bool x9c6_25_interpolatingControlDir : 1; - bool x9c6_26_outOfBallLookAtHint : 1; - bool x9c6_27_aimingAtProjectile : 1; - bool x9c6_28_aligningGrappleSwingTurn : 1; - bool x9c6_29_disableInput : 1; - bool x9c6_30_newScanScanning : 1; - bool x9c6_31_overrideRadarRadius : 1; - bool x9c7_24_noDamageLoopSfx : 1; - bool x9c7_25_outOfBallLookAtHintActor : 1; - }; - u32 _dummy = 0; - }; - + bool x9c4_24_visorChangeRequested : 1; + bool x9c4_25_showCrosshairs : 1; + bool x9c4_26_ : 1; + bool x9c4_27_canEnterMorphBall : 1; + bool x9c4_28_canLeaveMorphBall : 1; + bool x9c4_29_spiderBallControlXY : 1; + bool x9c4_30_controlDirOverride : 1; + bool x9c4_31_inWaterMovement : 1; + bool x9c5_24_ : 1; + bool x9c5_25_splashUpdated : 1; + bool x9c5_26_ : 1; + bool x9c5_27_camSubmerged : 1; + bool x9c5_28_slidingOnWall : 1; + bool x9c5_29_hitWall : 1; + bool x9c5_30_selectFluidBallSound : 1; + bool x9c5_31_stepCameraZBiasDirty : 1; + bool x9c6_24_extendTargetDistance : 1; + bool x9c6_25_interpolatingControlDir : 1; + bool x9c6_26_outOfBallLookAtHint : 1; + bool x9c6_27_aimingAtProjectile : 1; + bool x9c6_28_aligningGrappleSwingTurn : 1; + bool x9c6_29_disableInput : 1; + bool x9c6_30_newScanScanning : 1; + bool x9c6_31_overrideRadarRadius : 1; + bool x9c7_24_noDamageLoopSfx : 1; + bool x9c7_25_outOfBallLookAtHintActor : 1; float x9c8_eyeZBias = 0.f; float x9cc_stepCameraZBias = 0.f; u32 x9d0_bombJumpCount = 0; diff --git a/Runtime/World/CScriptActorKeyframe.cpp b/Runtime/World/CScriptActorKeyframe.cpp index ef5237923..4da536cfd 100644 --- a/Runtime/World/CScriptActorKeyframe.cpp +++ b/Runtime/World/CScriptActorKeyframe.cpp @@ -15,14 +15,13 @@ CScriptActorKeyframe::CScriptActorKeyframe(TUniqueId uid, std::string_view name, , x34_animationId(animId) , x38_initialLifetime(lifetime) , x3c_playbackRate(totalPlayback) -, x40_lifetime(lifetime) { - x44_24_looping = looping; - x44_25_isPassive = isPassive; - x44_26_fadeOut = fadeOut; - x44_27_timedLoop = fadeOut; - x44_28_playing = false; - x44_29_ = false; -} +, x40_lifetime(lifetime) +, x44_24_looping(looping) +, x44_25_isPassive(isPassive) +, x44_26_fadeOut(fadeOut != 0u) +, x44_27_timedLoop(fadeOut != 0u) +, x44_28_playing(false) +, x44_29_(false) {} void CScriptActorKeyframe::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CScriptActorKeyframe.hpp b/Runtime/World/CScriptActorKeyframe.hpp index 659ff4f36..ac6b78aed 100644 --- a/Runtime/World/CScriptActorKeyframe.hpp +++ b/Runtime/World/CScriptActorKeyframe.hpp @@ -12,17 +12,12 @@ private: float x38_initialLifetime; float x3c_playbackRate; float x40_lifetime; - union { - struct { - bool x44_24_looping : 1; - bool x44_25_isPassive : 1; - bool x44_26_fadeOut : 1; - bool x44_27_timedLoop : 1; - bool x44_28_playing : 1; - bool x44_29_ : 1; - }; - u8 _dummy = 0; - }; + bool x44_24_looping : 1; + bool x44_25_isPassive : 1; + bool x44_26_fadeOut : 1; + bool x44_27_timedLoop : 1; + bool x44_28_playing : 1; + bool x44_29_ : 1; public: CScriptActorKeyframe(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 animId, bool looping, diff --git a/Runtime/World/CScriptActorRotate.hpp b/Runtime/World/CScriptActorRotate.hpp index 8f1893679..89c03d50d 100644 --- a/Runtime/World/CScriptActorRotate.hpp +++ b/Runtime/World/CScriptActorRotate.hpp @@ -18,16 +18,10 @@ class CScriptActorRotate : public CEntity { float x40_maxTime; float x44_currentTime = 0.f; std::map x48_actors; - - union { - struct { - bool x58_24_updateRotation : 1; - bool x58_25_skipSpiderBallWaypoints : 1; - bool x58_26_updateActors : 1; - bool x58_27_updateOnCreation : 1; - }; - u32 dummy = 0; - }; + bool x58_24_updateRotation : 1; + bool x58_25_skipSpiderBallWaypoints : 1; + bool x58_26_updateActors : 1; + bool x58_27_updateOnCreation : 1; void UpdateActors(bool, CStateManager&); void UpdateSpiderBallWaypoints(CStateManager&); diff --git a/Runtime/World/CScriptAiJumpPoint.cpp b/Runtime/World/CScriptAiJumpPoint.cpp index 934e7371c..f49f08566 100644 --- a/Runtime/World/CScriptAiJumpPoint.cpp +++ b/Runtime/World/CScriptAiJumpPoint.cpp @@ -12,7 +12,8 @@ CScriptAiJumpPoint::CScriptAiJumpPoint(TUniqueId uid, std::string_view name, con : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::NoStepLogic), CActorParameters::None(), kInvalidUniqueId) , xe8_apex(apex) -, xec_touchBounds(xf.origin, xf.origin) {} +, xec_touchBounds(xf.origin, xf.origin) +, x108_24(false) {} void CScriptAiJumpPoint::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CScriptAiJumpPoint.hpp b/Runtime/World/CScriptAiJumpPoint.hpp index 1f62259a8..74a8224fd 100644 --- a/Runtime/World/CScriptAiJumpPoint.hpp +++ b/Runtime/World/CScriptAiJumpPoint.hpp @@ -12,12 +12,7 @@ class CScriptAiJumpPoint : public CActor { private: float xe8_apex; zeus::CAABox xec_touchBounds; - union { - struct { - bool x108_24 : 1; - }; - u8 dummy = 0; - }; + bool x108_24 : 1; TUniqueId x10a_occupant = kInvalidUniqueId; TUniqueId x10c_currentWaypoint = kInvalidUniqueId; TUniqueId x10e_nextWaypoint = kInvalidUniqueId; diff --git a/Runtime/World/CScriptCameraHintTrigger.cpp b/Runtime/World/CScriptCameraHintTrigger.cpp index 0498fb39d..d52ed6b0f 100644 --- a/Runtime/World/CScriptCameraHintTrigger.cpp +++ b/Runtime/World/CScriptCameraHintTrigger.cpp @@ -14,10 +14,11 @@ CScriptCameraHintTrigger::CScriptCameraHintTrigger(TUniqueId uid, bool active, s : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Trigger), CActorParameters::None(), kInvalidUniqueId) , xe8_obb(xf, scale) -, x124_scale(scale) { - x130_24_deactivateOnEnter = deactivateOnEnter; - x130_25_deactivateOnExit = deactivateOnExit; -} +, x124_scale(scale) +, x130_24_deactivateOnEnter(deactivateOnEnter) +, x130_25_deactivateOnExit(deactivateOnExit) +, x130_26_playerInside(false) +, x130_27_playerWasInside(false) {} void CScriptCameraHintTrigger::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CScriptCameraHintTrigger.hpp b/Runtime/World/CScriptCameraHintTrigger.hpp index 68497d278..b1a0067f2 100644 --- a/Runtime/World/CScriptCameraHintTrigger.hpp +++ b/Runtime/World/CScriptCameraHintTrigger.hpp @@ -12,15 +12,10 @@ namespace urde { class CScriptCameraHintTrigger : public CActor { zeus::COBBox xe8_obb; zeus::CVector3f x124_scale; - union { - struct { - bool x130_24_deactivateOnEnter : 1; - bool x130_25_deactivateOnExit : 1; - bool x130_26_playerInside : 1; - bool x130_27_playerWasInside : 1; - }; - u32 _dummy = 0; - }; + bool x130_24_deactivateOnEnter : 1; + bool x130_25_deactivateOnExit : 1; + bool x130_26_playerInside : 1; + bool x130_27_playerWasInside : 1; public: CScriptCameraHintTrigger(TUniqueId uid, bool active, std::string_view name, diff --git a/Runtime/World/CScriptCameraPitchVolume.cpp b/Runtime/World/CScriptCameraPitchVolume.cpp index 7bbbc76a9..ac19a0e77 100644 --- a/Runtime/World/CScriptCameraPitchVolume.cpp +++ b/Runtime/World/CScriptCameraPitchVolume.cpp @@ -22,7 +22,9 @@ CScriptCameraPitchVolume::CScriptCameraPitchVolume(TUniqueId uid, bool active, s , x124_upPitch(upPitch) , x128_downPitch(downPitch) , x12c_scale(scale * skScaleFactor) -, x138_maxInterpDistance(maxInterpDistance) {} +, x138_maxInterpDistance(maxInterpDistance) +, x13c_24_entered(false) +, x13c_25_occupied(false) {} void CScriptCameraPitchVolume::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CScriptCameraPitchVolume.hpp b/Runtime/World/CScriptCameraPitchVolume.hpp index 2b84d2816..b50dfa3ad 100644 --- a/Runtime/World/CScriptCameraPitchVolume.hpp +++ b/Runtime/World/CScriptCameraPitchVolume.hpp @@ -17,14 +17,8 @@ class CScriptCameraPitchVolume : public CActor { zeus::CRelAngle x128_downPitch; zeus::CVector3f x12c_scale; float x138_maxInterpDistance; - - union { - struct { - bool x13c_24_entered : 1; - bool x13c_25_occupied : 1; - }; - u32 _dummy = 0; - }; + bool x13c_24_entered : 1; + bool x13c_25_occupied : 1; public: CScriptCameraPitchVolume(TUniqueId, bool, std::string_view, const CEntityInfo&, const zeus::CVector3f&, diff --git a/Runtime/World/CScriptColorModulate.cpp b/Runtime/World/CScriptColorModulate.cpp index b194417ba..7c9226dd6 100644 --- a/Runtime/World/CScriptColorModulate.cpp +++ b/Runtime/World/CScriptColorModulate.cpp @@ -15,17 +15,16 @@ CScriptColorModulate::CScriptColorModulate(TUniqueId uid, std::string_view name, , x44_colorB(colorB) , x48_blendMode(blendMode) , x4c_timeA2B(timeA2B) -, x50_timeB2A(timeB2A) { - x54_24_doReverse = doReverse; - x54_25_resetTargetWhenDone = resetTargetWhenDone; - x54_26_depthCompare = depthCompare; - x54_27_depthUpdate = depthUpdate; - x54_28_depthBackwards = depthBackwards; - x54_29_reversing = false; - x54_30_enable = false; - x54_31_dieOnEnd = false; - x55_24_isFadeOutHelper = false; -} +, x50_timeB2A(timeB2A) +, x54_24_doReverse(doReverse) +, x54_25_resetTargetWhenDone(resetTargetWhenDone) +, x54_26_depthCompare(depthCompare) +, x54_27_depthUpdate(depthUpdate) +, x54_28_depthBackwards(depthBackwards) +, x54_29_reversing(false) +, x54_30_enable(false) +, x54_31_dieOnEnd(false) +, x55_24_isFadeOutHelper(false) {} void CScriptColorModulate::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CScriptColorModulate.hpp b/Runtime/World/CScriptColorModulate.hpp index bd60316f9..750fbb46a 100644 --- a/Runtime/World/CScriptColorModulate.hpp +++ b/Runtime/World/CScriptColorModulate.hpp @@ -30,20 +30,15 @@ private: EBlendMode x48_blendMode; float x4c_timeA2B; float x50_timeB2A; - union { - struct { - bool x54_24_doReverse : 1; - bool x54_25_resetTargetWhenDone : 1; - bool x54_26_depthCompare : 1; - bool x54_27_depthUpdate : 1; - bool x54_28_depthBackwards : 1; - bool x54_29_reversing : 1; - bool x54_30_enable : 1; - bool x54_31_dieOnEnd : 1; - bool x55_24_isFadeOutHelper : 1; - }; - u32 _dummy = 0; - }; + bool x54_24_doReverse : 1; + bool x54_25_resetTargetWhenDone : 1; + bool x54_26_depthCompare : 1; + bool x54_27_depthUpdate : 1; + bool x54_28_depthBackwards : 1; + bool x54_29_reversing : 1; + bool x54_30_enable : 1; + bool x54_31_dieOnEnd : 1; + bool x55_24_isFadeOutHelper : 1; public: CScriptColorModulate(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CColor& colorA, diff --git a/Runtime/World/CScriptControllerAction.cpp b/Runtime/World/CScriptControllerAction.cpp index c1f5b4fa0..57c89676b 100644 --- a/Runtime/World/CScriptControllerAction.cpp +++ b/Runtime/World/CScriptControllerAction.cpp @@ -10,10 +10,12 @@ namespace urde { CScriptControllerAction::CScriptControllerAction(TUniqueId uid, std::string_view name, const CEntityInfo& info, bool active, ControlMapper::ECommands command, bool mapScreenResponse, u32 w1, bool deactivateOnClose) -: CEntity(uid, info, active, name), x34_command(command), x38_mapScreenSubaction(w1) { - x3c_24_mapScreenResponse = mapScreenResponse; - x3c_25_deactivateOnClose = deactivateOnClose; -} +: CEntity(uid, info, active, name) +, x34_command(command) +, x38_mapScreenSubaction(w1) +, x3c_24_mapScreenResponse(mapScreenResponse) +, x3c_25_deactivateOnClose(deactivateOnClose) +, x3c_26_pressed(false) {} void CScriptControllerAction::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CScriptControllerAction.hpp b/Runtime/World/CScriptControllerAction.hpp index a18dd5838..e7e0c2486 100644 --- a/Runtime/World/CScriptControllerAction.hpp +++ b/Runtime/World/CScriptControllerAction.hpp @@ -11,14 +11,9 @@ namespace urde { class CScriptControllerAction : public CEntity { ControlMapper::ECommands x34_command; u32 x38_mapScreenSubaction; - union { - struct { - bool x3c_24_mapScreenResponse : 1; - bool x3c_25_deactivateOnClose : 1; - bool x3c_26_pressed : 1; - }; - u8 _dummy = 0; - }; + bool x3c_24_mapScreenResponse : 1; + bool x3c_25_deactivateOnClose : 1; + bool x3c_26_pressed : 1; public: CScriptControllerAction(TUniqueId uid, std::string_view name, const CEntityInfo& info, bool active, diff --git a/Runtime/World/CScriptCoverPoint.cpp b/Runtime/World/CScriptCoverPoint.cpp index 44af6ac16..f55cc93b1 100644 --- a/Runtime/World/CScriptCoverPoint.cpp +++ b/Runtime/World/CScriptCoverPoint.cpp @@ -11,9 +11,12 @@ CScriptCoverPoint::CScriptCoverPoint(TUniqueId uid, std::string_view name, const float coverTime) : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::NoStepLogic), CActorParameters::None(), kInvalidUniqueId) -, xe8_flags(flags) -, xf4_coverTime(coverTime) { - xf8_24_crouch = crouch; +, xe8_26_landHere((flags & 0x20) != 0u) +, xe8_27_wallHang((flags & 0x10) != 0u) +, xe8_28_stay((flags & 0x8) != 0u) +, xf4_coverTime(coverTime) +, xf8_24_crouch(crouch) +, xf8_25_inUse(false) { xec_cosHorizontalAngle = std::cos(zeus::degToRad(horizontalAngle) * 0.5f); xf0_sinVerticalAngle = std::sin(zeus::degToRad(verticalAngle) * 0.5f); x100_touchBounds.emplace(xf.origin, xf.origin); diff --git a/Runtime/World/CScriptCoverPoint.hpp b/Runtime/World/CScriptCoverPoint.hpp index 176636db9..98f938c29 100644 --- a/Runtime/World/CScriptCoverPoint.hpp +++ b/Runtime/World/CScriptCoverPoint.hpp @@ -10,25 +10,14 @@ namespace urde { class CScriptCoverPoint : public CActor { - union { - struct { - bool xe8_26_landHere : 1; - bool xe8_27_wallHang : 1; - bool xe8_28_stay : 1; - }; - u32 xe8_flags; - }; - + bool xe8_26_landHere : 1; + bool xe8_27_wallHang : 1; + bool xe8_28_stay : 1; float xec_cosHorizontalAngle; float xf0_sinVerticalAngle; float xf4_coverTime; - union { - struct { - bool xf8_24_crouch : 1; - bool xf8_25_inUse : 1; - }; - u32 xf8_flags = 0; - }; + bool xf8_24_crouch : 1; + bool xf8_25_inUse : 1; TUniqueId xfa_occupant = kInvalidUniqueId; TUniqueId xfc_retreating = kInvalidUniqueId; std::optional x100_touchBounds; diff --git a/Runtime/World/CScriptDamageableTrigger.cpp b/Runtime/World/CScriptDamageableTrigger.cpp index 3b0a6040b..71fd94ef8 100644 --- a/Runtime/World/CScriptDamageableTrigger.cpp +++ b/Runtime/World/CScriptDamageableTrigger.cpp @@ -36,8 +36,12 @@ CScriptDamageableTrigger::CScriptDamageableTrigger(TUniqueId uid, std::string_vi , x16c_hInfo(hInfo) , x174_dVuln(dVuln) , x1dc_faceFlag(faceFlag) -, x254_fluidPlane(patternTex1, patternTex2, colorTex, 1.f, 2, EFluidType::NormalWater, 1.f, CFluidUVMotion(6.f, 0.f)) { - x300_28_canOrbit = canOrbit == ECanOrbit::Orbit; +, x254_fluidPlane(patternTex1, patternTex2, colorTex, 1.f, 2, EFluidType::NormalWater, 1.f, CFluidUVMotion(6.f, 0.f)) +, x300_24_notOccluded(false) +, x300_25_alphaOut(false) +, x300_26_outOfFrustum(false) +, x300_27_invulnerable(false) +, x300_28_canOrbit(canOrbit == ECanOrbit::Orbit) { if (x1dc_faceFlag & 0x1) { x244_faceTranslate = zeus::CVector3f(0.f, x14c_bounds.max.y(), 0.f); x1e4_faceDir = zeus::CTransform::RotateX(-M_PIF / 2.f); diff --git a/Runtime/World/CScriptDamageableTrigger.hpp b/Runtime/World/CScriptDamageableTrigger.hpp index 991bbdb0b..378385231 100644 --- a/Runtime/World/CScriptDamageableTrigger.hpp +++ b/Runtime/World/CScriptDamageableTrigger.hpp @@ -30,16 +30,12 @@ private: zeus::CVector3f x244_faceTranslate; float x250_alphaTimer = 0.f; CFluidPlaneDoor x254_fluidPlane; - union { - struct { - bool x300_24_notOccluded : 1; - bool x300_25_alphaOut : 1; - bool x300_26_outOfFrustum : 1; - bool x300_27_invulnerable : 1; - bool x300_28_canOrbit : 1; - }; - u32 _dummy = 0; - }; + bool x300_24_notOccluded : 1; + bool x300_25_alphaOut : 1; + bool x300_26_outOfFrustum : 1; + bool x300_27_invulnerable : 1; + bool x300_28_canOrbit : 1; + void SetLinkedObjectAlpha(float a, CStateManager& mgr); float GetPuddleAlphaScale() const; diff --git a/Runtime/World/CScriptDebris.cpp b/Runtime/World/CScriptDebris.cpp index 740c2bda1..7cdc46d56 100644 --- a/Runtime/World/CScriptDebris.cpp +++ b/Runtime/World/CScriptDebris.cpp @@ -27,9 +27,17 @@ CScriptDebris::CScriptDebris(TUniqueId uid, std::string_view name, const CEntity , x278_ooDuration(1.f / x274_duration) , x27c_restitution(restitution) , x280_scaleType(scaleType) +, x281_24_randomAngImpulse(randomAngImpulse) +, x281_25_particle1GlobalTranslation(false) +, x281_26_deferDeleteTillParticle1Done(false) +, x281_27_particle2GlobalTranslation(false) +, x281_28_deferDeleteTillParticle2Done(false) +, x281_29_particle3Active(false) +, x281_30_debrisExtended(false) +, x281_31_dieOnProjectile(false) +, x282_24_noBounce(false) , x2b0_scale(mData.GetScale()) , x2e0_speedAvg(2.f) { - x281_24_randomAngImpulse = randomAngImpulse; if (scaleType == EScaleType::NoScale) x2bc_endScale = mData.GetScale(); else if (scaleType == EScaleType::EndsToZero) @@ -80,6 +88,15 @@ CScriptDebris::CScriptDebris(TUniqueId uid, std::string_view name, const CEntity , x264_color(color) , x268_endsColor(endsColor) , x27c_restitution(restitution) +, x281_24_randomAngImpulse(false) +, x281_25_particle1GlobalTranslation(particle1GlobalTranslation) +, x281_26_deferDeleteTillParticle1Done(deferDeleteTillParticle1Done) +, x281_27_particle2GlobalTranslation(particle2GlobalTranslation) +, x281_28_deferDeleteTillParticle2Done(deferDeleteTillParticle2Done) +, x281_29_particle3Active(false) +, x281_30_debrisExtended(true) +, x281_31_dieOnProjectile(false) +, x282_24_noBounce(noBounce) , x288_linConeAngle(linConeAngle) , x28c_linMinMag(linMinMag) , x290_linMaxMag(linMaxMag) @@ -93,13 +110,6 @@ CScriptDebris::CScriptDebris(TUniqueId uid, std::string_view name, const CEntity , x2b0_scale(scale) , x2bc_endScale(scale * endScale) , x2e0_speedAvg(2.f) { - x281_25_particle1GlobalTranslation = particle1GlobalTranslation; - x281_26_deferDeleteTillParticle1Done = deferDeleteTillParticle1Done; - x281_27_particle2GlobalTranslation = particle2GlobalTranslation; - x281_28_deferDeleteTillParticle2Done = deferDeleteTillParticle2Done; - x281_30_debrisExtended = true; - x281_31_dieOnProjectile = dieOnProjectile; - x282_24_noBounce = noBounce; x283_particleOrs[0] = particle1Or; x283_particleOrs[1] = particle2Or; x283_particleOrs[2] = particle3Or; diff --git a/Runtime/World/CScriptDebris.hpp b/Runtime/World/CScriptDebris.hpp index bf7ca8cfa..3fe94ac1a 100644 --- a/Runtime/World/CScriptDebris.hpp +++ b/Runtime/World/CScriptDebris.hpp @@ -27,20 +27,15 @@ private: float x278_ooDuration = 0.f; float x27c_restitution; CScriptDebris::EScaleType x280_scaleType = CScriptDebris::EScaleType::NoScale; - union { - struct { - bool x281_24_randomAngImpulse : 1; - bool x281_25_particle1GlobalTranslation : 1; - bool x281_26_deferDeleteTillParticle1Done : 1; - bool x281_27_particle2GlobalTranslation : 1; - bool x281_28_deferDeleteTillParticle2Done : 1; - bool x281_29_particle3Active : 1; - bool x281_30_debrisExtended : 1; - bool x281_31_dieOnProjectile : 1; - bool x282_24_noBounce : 1; - }; - u32 _dummy = 0; - }; + bool x281_24_randomAngImpulse : 1; + bool x281_25_particle1GlobalTranslation : 1; + bool x281_26_deferDeleteTillParticle1Done : 1; + bool x281_27_particle2GlobalTranslation : 1; + bool x281_28_deferDeleteTillParticle2Done : 1; + bool x281_29_particle3Active : 1; + bool x281_30_debrisExtended : 1; + bool x281_31_dieOnProjectile : 1; + bool x282_24_noBounce : 1; EOrientationType x283_particleOrs[3] = {}; float x288_linConeAngle = 0.f; float x28c_linMinMag = 0.f; diff --git a/Runtime/World/CScriptDock.cpp b/Runtime/World/CScriptDock.cpp index 9440242a9..8b5707568 100644 --- a/Runtime/World/CScriptDock.cpp +++ b/Runtime/World/CScriptDock.cpp @@ -23,14 +23,15 @@ CMaterialList MakeDockMaterialList() { CScriptDock::CScriptDock(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CVector3f& position, const zeus::CVector3f& extents, s32 dock, TAreaId area, bool active, s32 dockReferenceCount, bool loadConnected) -: CPhysicsActor(uid, active, name, info, zeus::CTransform(zeus::CMatrix3f(), position), - CModelData::CModelDataNull(), MakeDockMaterialList(), zeus::CAABox(-extents * 0.5f, extents * 0.5f), - SMoverData(1.f), CActorParameters::None(), 0.3f, 0.1f) +: CPhysicsActor(uid, active, name, info, zeus::CTransform(zeus::CMatrix3f(), position), CModelData::CModelDataNull(), + MakeDockMaterialList(), zeus::CAABox(-extents * 0.5f, extents * 0.5f), SMoverData(1.f), + CActorParameters::None(), 0.3f, 0.1f) , x258_dockReferenceCount(dockReferenceCount) , x25c_dock(dock) -, x260_area(area) { - x268_25_loadConnected = loadConnected; -} +, x260_area(area) +, x268_24_dockReferenced(false) +, x268_25_loadConnected(loadConnected) +, x268_26_areaPostConstructed(false) {} void CScriptDock::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CScriptDock.hpp b/Runtime/World/CScriptDock.hpp index 42d7605e8..f34d71a73 100644 --- a/Runtime/World/CScriptDock.hpp +++ b/Runtime/World/CScriptDock.hpp @@ -15,14 +15,9 @@ class CScriptDock : public CPhysicsActor { s32 x25c_dock; TAreaId x260_area; EDockState x264_dockState = EDockState::Three; - union { - struct { - bool x268_24_dockReferenced : 1; - bool x268_25_loadConnected : 1; - bool x268_26_areaPostConstructed : 1; - }; - u8 dummy = 0; - }; + bool x268_24_dockReferenced : 1; + bool x268_25_loadConnected : 1; + bool x268_26_areaPostConstructed : 1; public: CScriptDock(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CVector3f& position, diff --git a/Runtime/World/CScriptEffect.cpp b/Runtime/World/CScriptEffect.cpp index 523ae2ace..f5a84c874 100644 --- a/Runtime/World/CScriptEffect.cpp +++ b/Runtime/World/CScriptEffect.cpp @@ -32,6 +32,17 @@ CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntity : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None().HotInThermal(hotInThermal), kInvalidUniqueId) , x10c_partId(partId) +, x110_24_enable(active) +, x110_25_noTimerUnlessAreaOccluded(noTimerUnlessAreaOccluded) +, x110_26_rebuildSystemsOnActivate(rebuildSystemsOnActivate) +, x110_27_useRateInverseCamDist(useRateInverseCamDist) +, x110_28_combatVisorVisible(combatVisorVisible) +, x110_29_thermalVisorVisible(thermalVisorVisible) +, x110_30_xrayVisorVisible(xrayVisorVisible) +, x110_31_anyVisorVisible(xrayVisorVisible && thermalVisorVisible && combatVisorVisible) +, x111_24_useRateCamDistRange(useRateCamDistRange) +, x111_25_dieWhenSystemsDone(dieWhenSystemsDone) +, x111_26_canRender(false) , x114_rateInverseCamDist(rateInverseCamDist) , x118_rateInverseCamDistSq(rateInverseCamDist * rateInverseCamDist) , x11c_rateInverseCamDistRate(rateInverseCamDistRate) @@ -42,18 +53,6 @@ CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntity , x130_duration(duration) , x134_durationResetWhileVisible(durationResetWhileVisible) , x138_actorLights(lParms.MakeActorLights()) { - x110_24_enable = active; - x110_25_noTimerUnlessAreaOccluded = noTimerUnlessAreaOccluded; - x110_26_rebuildSystemsOnActivate = rebuildSystemsOnActivate; - x110_27_useRateInverseCamDist = useRateInverseCamDist; - x110_28_combatVisorVisible = combatVisorVisible; - x110_29_thermalVisorVisible = thermalVisorVisible; - x110_30_xrayVisorVisible = xrayVisorVisible; - x110_31_anyVisorVisible = xrayVisorVisible && thermalVisorVisible && combatVisorVisible; - x111_24_useRateCamDistRange = useRateCamDistRange; - x111_25_dieWhenSystemsDone = dieWhenSystemsDone; - x111_26_canRender = false; - if (partId.IsValid()) { xf8_particleSystemToken = g_SimplePool->GetObj({FOURCC('PART'), partId}); x104_particleSystem = std::make_unique(xf8_particleSystemToken); diff --git a/Runtime/World/CScriptEffect.hpp b/Runtime/World/CScriptEffect.hpp index 384b62130..261486754 100644 --- a/Runtime/World/CScriptEffect.hpp +++ b/Runtime/World/CScriptEffect.hpp @@ -19,22 +19,17 @@ class CScriptEffect : public CActor { std::unique_ptr x104_particleSystem; TUniqueId x108_lightId = kInvalidUniqueId; CAssetId x10c_partId; - union { - struct { - bool x110_24_enable : 1; - bool x110_25_noTimerUnlessAreaOccluded : 1; - bool x110_26_rebuildSystemsOnActivate : 1; - bool x110_27_useRateInverseCamDist : 1; - bool x110_28_combatVisorVisible : 1; - bool x110_29_thermalVisorVisible : 1; - bool x110_30_xrayVisorVisible : 1; - bool x110_31_anyVisorVisible : 1; - bool x111_24_useRateCamDistRange : 1; - bool x111_25_dieWhenSystemsDone : 1; - bool x111_26_canRender : 1; - }; - u32 _dummy = 0; - }; + bool x110_24_enable : 1; + bool x110_25_noTimerUnlessAreaOccluded : 1; + bool x110_26_rebuildSystemsOnActivate : 1; + bool x110_27_useRateInverseCamDist : 1; + bool x110_28_combatVisorVisible : 1; + bool x110_29_thermalVisorVisible : 1; + bool x110_30_xrayVisorVisible : 1; + bool x110_31_anyVisorVisible : 1; + bool x111_24_useRateCamDistRange : 1; + bool x111_25_dieWhenSystemsDone : 1; + bool x111_26_canRender : 1; float x114_rateInverseCamDist; float x118_rateInverseCamDistSq; float x11c_rateInverseCamDistRate; diff --git a/Runtime/World/CScriptGenerator.hpp b/Runtime/World/CScriptGenerator.hpp index 3b98b7101..76b154b20 100644 --- a/Runtime/World/CScriptGenerator.hpp +++ b/Runtime/World/CScriptGenerator.hpp @@ -11,13 +11,8 @@ namespace urde { class CScriptGenerator : public CEntity { u32 x34_spawnCount; - union { - struct { - bool x38_24_noReuseFollowers : 1; - bool x38_25_noInheritTransform : 1; - }; - u8 dummy1 = 0; - }; + bool x38_24_noReuseFollowers : 1; + bool x38_25_noInheritTransform : 1; zeus::CVector3f x3c_offset; float x48_minScale; float x4c_maxScale; diff --git a/Runtime/World/CScriptGunTurret.cpp b/Runtime/World/CScriptGunTurret.cpp index 774a4319e..dde720de5 100644 --- a/Runtime/World/CScriptGunTurret.cpp +++ b/Runtime/World/CScriptGunTurret.cpp @@ -158,7 +158,15 @@ CScriptGunTurret::CScriptGunTurret(TUniqueId uid, std::string_view name, ETurret , x428_targettingLightDesc(g_SimplePool->GetObj({SBIG('PART'), turretData.GetTargettingLightRes()})) , x434_frozenEffectDesc(g_SimplePool->GetObj({SBIG('PART'), turretData.GetFrozenEffectRes()})) , x440_chargingEffectDesc(g_SimplePool->GetObj({SBIG('PART'), turretData.GetChargingEffectRes()})) -, x44c_panningEffectDesc(g_SimplePool->GetObj({SBIG('PART'), turretData.GetPanningEffectRes()})) { +, x44c_panningEffectDesc(g_SimplePool->GetObj({SBIG('PART'), turretData.GetPanningEffectRes()})) +, x560_24_dead(false) +, x560_25_frozen(false) +, x560_26_firedWithSetBurst(false) +, x560_27_burstSet(false) +, x560_28_hasBeenActivated(false) +, x560_29_scriptedStart(false) +, x560_30_needsStopClankSound(true) +, x560_31_frenzyReverse(false) { if (turretData.GetVisorEffectRes().IsValid()) x458_visorEffectDesc = g_SimplePool->GetObj({SBIG('PART'), turretData.GetVisorEffectRes()}); x468_idleLight = std::make_unique(x410_idleLightDesc); @@ -171,14 +179,6 @@ CScriptGunTurret::CScriptGunTurret(TUniqueId uid, std::string_view name, ETurret x514_lastFrontVector = xf.frontVector(); x544_originalFrontVec = xf.frontVector(); x550_originalRightVec = xf.rightVector(); - x560_24_dead = false; - x560_25_frozen = false; - x560_26_firedWithSetBurst = false; - x560_27_burstSet = false; - x560_28_hasBeenActivated = false; - x560_29_scriptedStart = false; - x560_30_needsStopClankSound = true; - x560_31_frenzyReverse = false; if (comp == ETurretComponent::Base && HasModelData() && GetModelData()->HasAnimData()) GetModelData()->EnableLooping(true); diff --git a/Runtime/World/CScriptGunTurret.hpp b/Runtime/World/CScriptGunTurret.hpp index 779005a86..47935993a 100644 --- a/Runtime/World/CScriptGunTurret.hpp +++ b/Runtime/World/CScriptGunTurret.hpp @@ -170,19 +170,14 @@ private: zeus::CVector3f x544_originalFrontVec; zeus::CVector3f x550_originalRightVec; s32 x55c_additiveChargeAnim = -1; - union { - struct { - bool x560_24_dead : 1; - bool x560_25_frozen : 1; - bool x560_26_firedWithSetBurst : 1; - bool x560_27_burstSet : 1; - bool x560_28_hasBeenActivated : 1; - bool x560_29_scriptedStart : 1; - bool x560_30_needsStopClankSound : 1; - bool x560_31_frenzyReverse : 1; - }; - u32 _dummy = 0; - }; + bool x560_24_dead : 1; + bool x560_25_frozen : 1; + bool x560_26_firedWithSetBurst : 1; + bool x560_27_burstSet : 1; + bool x560_28_hasBeenActivated : 1; + bool x560_29_scriptedStart : 1; + bool x560_30_needsStopClankSound : 1; + bool x560_31_frenzyReverse : 1; private: void SetupCollisionManager(CStateManager&); diff --git a/Runtime/World/CScriptMazeNode.cpp b/Runtime/World/CScriptMazeNode.cpp index 2ed75e9b7..198a1f7fe 100644 --- a/Runtime/World/CScriptMazeNode.cpp +++ b/Runtime/World/CScriptMazeNode.cpp @@ -20,9 +20,10 @@ CScriptMazeNode::CScriptMazeNode(TUniqueId uid, std::string_view name, const CEn , xf0_(w2) , x100_(vec1) , x110_(vec2) -, x120_(vec3) { - x13c_24_ = true; -} +, x120_(vec3) +, x13c_24_(true) +, x13c_25_(false) +, x13c_26_(false) {} void CScriptMazeNode::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CScriptMazeNode.hpp b/Runtime/World/CScriptMazeNode.hpp index f9e147d5a..18072f7d0 100644 --- a/Runtime/World/CScriptMazeNode.hpp +++ b/Runtime/World/CScriptMazeNode.hpp @@ -24,14 +24,9 @@ class CScriptMazeNode : public CActor { s32 x130_ = 0; s32 x134_ = 0; s32 x138_ = 0; - union { - struct { - bool x13c_24_ : 1; - bool x13c_25_ : 1; - bool x13c_26_ : 1; - }; - u8 dummy = 0; - }; + bool x13c_24_ : 1; + bool x13c_25_ : 1; + bool x13c_26_ : 1; public: CScriptMazeNode(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, bool, s32, s32, s32, diff --git a/Runtime/World/CScriptMemoryRelay.hpp b/Runtime/World/CScriptMemoryRelay.hpp index 594b6da71..2f0b31c64 100644 --- a/Runtime/World/CScriptMemoryRelay.hpp +++ b/Runtime/World/CScriptMemoryRelay.hpp @@ -7,14 +7,9 @@ namespace urde { class CScriptMemoryRelay : public CEntity { - union { - struct { - bool x34_24_defaultActive; - bool x34_25_skipSendActive; - bool x34_26_ignoreMessages; - }; - u8 dummy = 0; - }; + bool x34_24_defaultActive; + bool x34_25_skipSendActive; + bool x34_26_ignoreMessages; public: CScriptMemoryRelay(TUniqueId, std::string_view name, const CEntityInfo&, bool, bool, bool); diff --git a/Runtime/World/CScriptPlayerActor.cpp b/Runtime/World/CScriptPlayerActor.cpp index 781d72767..d99824f1e 100644 --- a/Runtime/World/CScriptPlayerActor.cpp +++ b/Runtime/World/CScriptPlayerActor.cpp @@ -25,10 +25,16 @@ CScriptPlayerActor::CScriptPlayerActor(TUniqueId uid, std::string_view name, con 0, 1.f, false, false, false, false) , x2e8_suitRes(animRes) , x304_beam(beam) -, x350_flags(flags) { - x354_24_setBoundingBox = setBoundingBox; - x354_29_loading = true; - x354_30_enableLoading = true; +, x350_flags(flags) +, x354_24_setBoundingBox(setBoundingBox) +, x354_25_deferOnlineModelData(false) +, x354_26_deferOfflineModelData(false) +, x354_27_beamModelLoading(false) +, x354_28_suitModelLoading(false) +, x354_29_loading(true) +, x354_30_enableLoading(true) +, x354_31_deferOnlineLoad(false) +, x355_24_areaTrackingLoad(false) { CMaterialList exclude = GetMaterialFilter().GetExcludeList(); CMaterialList include = GetMaterialFilter().GetIncludeList(); include.Add(EMaterialTypes::Player); diff --git a/Runtime/World/CScriptPlayerActor.hpp b/Runtime/World/CScriptPlayerActor.hpp index 041f1a05a..bdbd13890 100644 --- a/Runtime/World/CScriptPlayerActor.hpp +++ b/Runtime/World/CScriptPlayerActor.hpp @@ -25,20 +25,15 @@ class CScriptPlayerActor : public CScriptActor { float x34c_phazonOffsetAngle = 0.f; u32 x350_flags; /* 0x1: suit transition, 0x2: previous suit, 0x4: force reset * 0x8: track in area data, 0x10: keep in state manager */ - union { - struct { - bool x354_24_setBoundingBox : 1; - bool x354_25_deferOnlineModelData : 1; - bool x354_26_deferOfflineModelData : 1; - bool x354_27_beamModelLoading : 1; - bool x354_28_suitModelLoading : 1; - bool x354_29_loading : 1; - bool x354_30_enableLoading : 1; - bool x354_31_deferOnlineLoad : 1; - bool x355_24_areaTrackingLoad : 1; - }; - u32 _dummy = 0; - }; + bool x354_24_setBoundingBox : 1; + bool x354_25_deferOnlineModelData : 1; + bool x354_26_deferOfflineModelData : 1; + bool x354_27_beamModelLoading : 1; + bool x354_28_suitModelLoading : 1; + bool x354_29_loading : 1; + bool x354_30_enableLoading : 1; + bool x354_31_deferOnlineLoad : 1; + bool x355_24_areaTrackingLoad : 1; TUniqueId x356_nextPlayerActor = kInvalidUniqueId; u32 GetSuitCharIdx(const CStateManager& mgr, CPlayerState::EPlayerSuit suit) const; diff --git a/Runtime/World/CScriptShadowProjector.cpp b/Runtime/World/CScriptShadowProjector.cpp index 63831af1c..652d47e76 100644 --- a/Runtime/World/CScriptShadowProjector.cpp +++ b/Runtime/World/CScriptShadowProjector.cpp @@ -10,7 +10,7 @@ namespace urde { CScriptShadowProjector::CScriptShadowProjector(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, bool active, const zeus::CVector3f& offset, - bool b2, float scale, float f2, float opacity, float opacityQ, + bool persistent, float scale, float f2, float opacity, float opacityQ, s32 textureSize) : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId) @@ -19,9 +19,9 @@ CScriptShadowProjector::CScriptShadowProjector(TUniqueId uid, std::string_view n , xf8_zOffsetAdjust(f2) , xfc_opacity(opacity) , x100_opacityRecip(opacity < 0.00001 ? 1.f : opacityQ / opacity) -, x10c_textureSize(textureSize) { - x110_24_persistent = b2; -} +, x10c_textureSize(textureSize) +, x110_24_persistent(persistent) +, x110_25_shadowInvalidated(false) {} void CScriptShadowProjector::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CScriptShadowProjector.hpp b/Runtime/World/CScriptShadowProjector.hpp index 54a521def..2480ca17e 100644 --- a/Runtime/World/CScriptShadowProjector.hpp +++ b/Runtime/World/CScriptShadowProjector.hpp @@ -20,14 +20,8 @@ class CScriptShadowProjector : public CActor { TUniqueId x104_target; std::unique_ptr x108_projectedShadow; u32 x10c_textureSize; - - union { - struct { - bool x110_24_persistent : 1; - bool x110_25_shadowInvalidated : 1; - }; - u8 x110_dummy = 0; - }; + bool x110_24_persistent : 1; + bool x110_25_shadowInvalidated : 1; public: CScriptShadowProjector(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, bool, diff --git a/Runtime/World/CScriptSound.cpp b/Runtime/World/CScriptSound.cpp index 8fcc6504f..39247989a 100644 --- a/Runtime/World/CScriptSound.cpp +++ b/Runtime/World/CScriptSound.cpp @@ -27,14 +27,17 @@ CScriptSound::CScriptSound(TUniqueId uid, std::string_view name, const CEntityIn , x112_prio(s16(prio)) , x114_pan(pan / 64.f - 1.f) , x116_(w6) -, x118_pitch(pitch / 8192.f) { - x11c_25_looped = looped; - x11c_26_nonEmitter = nonEmitter; - x11c_27_autoStart = autoStart; - x11c_28_occlusionTest = occlusionTest; - x11c_29_acoustics = acoustics; - x11c_30_worldSfx = worldSfx; - x11d_24_allowDuplicates = allowDuplicates; +, x118_pitch(pitch / 8192.f) +, x11c_24_playRequested(false) +, x11c_25_looped(looped) +, x11c_26_nonEmitter(nonEmitter) +, x11c_27_autoStart(autoStart) +, x11c_28_occlusionTest(occlusionTest) +, x11c_29_acoustics(acoustics) +, x11c_30_worldSfx(worldSfx) +, x11c_31_selfFree(false) +, x11d_24_allowDuplicates(allowDuplicates) +, x11d_25_processedThisFrame(false) { if (x11c_30_worldSfx && (!x11c_26_nonEmitter || !x11c_25_looped)) x11c_30_worldSfx = false; } diff --git a/Runtime/World/CScriptSound.hpp b/Runtime/World/CScriptSound.hpp index 63e33e989..70addc700 100644 --- a/Runtime/World/CScriptSound.hpp +++ b/Runtime/World/CScriptSound.hpp @@ -28,21 +28,16 @@ class CScriptSound : public CActor { float x114_pan; bool x116_; float x118_pitch; - union { - struct { - bool x11c_24_playRequested : 1; - bool x11c_25_looped : 1; - bool x11c_26_nonEmitter : 1; - bool x11c_27_autoStart : 1; - bool x11c_28_occlusionTest : 1; - bool x11c_29_acoustics : 1; - bool x11c_30_worldSfx : 1; - bool x11c_31_selfFree : 1; - bool x11d_24_allowDuplicates : 1; - bool x11d_25_processedThisFrame : 1; - }; - u32 x11c_dummy = 0; - }; + bool x11c_24_playRequested : 1; + bool x11c_25_looped : 1; + bool x11c_26_nonEmitter : 1; + bool x11c_27_autoStart : 1; + bool x11c_28_occlusionTest : 1; + bool x11c_29_acoustics : 1; + bool x11c_30_worldSfx : 1; + bool x11c_31_selfFree : 1; + bool x11d_24_allowDuplicates : 1; + bool x11d_25_processedThisFrame : 1; static float GetOccludedVolumeAmount(const zeus::CVector3f& pos, const CStateManager& mgr); diff --git a/Runtime/World/CScriptSpawnPoint.hpp b/Runtime/World/CScriptSpawnPoint.hpp index ab867ec6c..20a488de5 100644 --- a/Runtime/World/CScriptSpawnPoint.hpp +++ b/Runtime/World/CScriptSpawnPoint.hpp @@ -14,13 +14,8 @@ namespace urde { class CScriptSpawnPoint : public CEntity { zeus::CTransform x34_xf; rstl::reserved_vector x64_itemCounts; - union { - struct { - bool x10c_24_firstSpawn : 1; - bool x10c_25_morphed : 1; - }; - u8 _dummy = 0; - }; + bool x10c_24_firstSpawn : 1; + bool x10c_25_morphed : 1; public: CScriptSpawnPoint(TUniqueId, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, diff --git a/Runtime/World/CScriptSpecialFunction.cpp b/Runtime/World/CScriptSpecialFunction.cpp index 460612f5a..dacc04370 100644 --- a/Runtime/World/CScriptSpecialFunction.cpp +++ b/Runtime/World/CScriptSpecialFunction.cpp @@ -45,8 +45,18 @@ CScriptSpecialFunction::CScriptSpecialFunction(TUniqueId uid, std::string_view n , x184_(0.f) , x1bc_areaSaveId(aId1) , x1c0_layerIdx(aId2) -, x1c4_item(itemType) { - x1e4_26_sfx2Played = true; +, x1c4_item(itemType) +, x1e4_24_(false) +, x1e4_25_spinnerCanMove(false) +, x1e4_26_sfx2Played(true) +, x1e4_27_sfx3Played(false) +, x1e4_28_frustumEntered(false) +, x1e4_29_frustumExited(false) +, x1e4_30_(false) +, x1e4_31_inAreaDamage(false) +, x1e5_24_doSave(false) +, x1e5_25_playerInArea(false) +, x1e5_26_displayBillboard(false) { if (xe8_function == ESpecialFunction::HUDTarget) x1c8_touchBounds = {-1.f, 1.f}; } diff --git a/Runtime/World/CScriptSpecialFunction.hpp b/Runtime/World/CScriptSpecialFunction.hpp index 0d5dc7935..f001d8abe 100644 --- a/Runtime/World/CScriptSpecialFunction.hpp +++ b/Runtime/World/CScriptSpecialFunction.hpp @@ -99,22 +99,17 @@ private: s32 x1c0_layerIdx; CPlayerState::EItemType x1c4_item; std::optional x1c8_touchBounds; - union { - struct { - bool x1e4_24_ : 1; - bool x1e4_25_spinnerCanMove : 1; - bool x1e4_26_sfx2Played : 1; - bool x1e4_27_sfx3Played : 1; - bool x1e4_28_frustumEntered : 1; - bool x1e4_29_frustumExited : 1; - bool x1e4_30_ : 1; - bool x1e4_31_inAreaDamage : 1; - bool x1e5_24_doSave : 1; - bool x1e5_25_playerInArea : 1; - bool x1e5_26_displayBillboard : 1; - }; - u32 x1e4_dummy = 0; - }; + bool x1e4_24_ : 1; + bool x1e4_25_spinnerCanMove : 1; + bool x1e4_26_sfx2Played : 1; + bool x1e4_27_sfx3Played : 1; + bool x1e4_28_frustumEntered : 1; + bool x1e4_29_frustumExited : 1; + bool x1e4_30_ : 1; + bool x1e4_31_inAreaDamage : 1; + bool x1e5_24_doSave : 1; + bool x1e5_25_playerInArea : 1; + bool x1e5_26_displayBillboard : 1; TLockedToken x1e8_; // Used to be optional public: CScriptSpecialFunction(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, ESpecialFunction, diff --git a/Runtime/World/CScriptTargetingPoint.cpp b/Runtime/World/CScriptTargetingPoint.cpp index bc7e59b6f..3924b0cc3 100644 --- a/Runtime/World/CScriptTargetingPoint.cpp +++ b/Runtime/World/CScriptTargetingPoint.cpp @@ -9,7 +9,8 @@ namespace urde { CScriptTargetingPoint::CScriptTargetingPoint(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, bool active) : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::NoStepLogic), - CActorParameters::None(), kInvalidUniqueId) {} + CActorParameters::None(), kInvalidUniqueId) +, xe8_e4_(false) {} void CScriptTargetingPoint::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CScriptTargetingPoint.hpp b/Runtime/World/CScriptTargetingPoint.hpp index 672f7366e..0cbf6132e 100644 --- a/Runtime/World/CScriptTargetingPoint.hpp +++ b/Runtime/World/CScriptTargetingPoint.hpp @@ -8,12 +8,7 @@ namespace urde { class CScriptTargetingPoint : public CActor { private: - union { - struct { - bool xe8_e4_ : 1; - }; - u8 xe8_dummy = 0; - }; + bool xe8_e4_ : 1; TUniqueId xea_; float xec_time = 0.f; diff --git a/Runtime/World/CScriptTrigger.cpp b/Runtime/World/CScriptTrigger.cpp index 666c990ec..5c0dd3f12 100644 --- a/Runtime/World/CScriptTrigger.cpp +++ b/Runtime/World/CScriptTrigger.cpp @@ -20,13 +20,13 @@ CScriptTrigger::CScriptTrigger(TUniqueId uid, std::string_view name, const CEnti , x11c_forceField(forceField) , x128_forceMagnitude(forceField.magnitude()) , x12c_flags(triggerFlags) -, x130_bounds(bounds) { - x148_24_detectCamera = false; - x148_25_camSubmerged = false; - x148_26_deactivateOnEntered = deactivateOnEntered; - x148_27_deactivateOnExited = deactivateOnExited; - x148_28_playerTriggerProc = false; - x148_29_didPhazonDamage = false; +, x130_bounds(bounds) +, x148_24_detectCamera(false) +, x148_25_camSubmerged(false) +, x148_26_deactivateOnEntered(deactivateOnEntered) +, x148_27_deactivateOnExited(deactivateOnExited) +, x148_28_playerTriggerProc(false) +, x148_29_didPhazonDamage(false) { SetCallTouch(false); } diff --git a/Runtime/World/CScriptTrigger.hpp b/Runtime/World/CScriptTrigger.hpp index 038ab41f0..f399d6b28 100644 --- a/Runtime/World/CScriptTrigger.hpp +++ b/Runtime/World/CScriptTrigger.hpp @@ -54,18 +54,12 @@ protected: float x128_forceMagnitude; ETriggerFlags x12c_flags; zeus::CAABox x130_bounds; - - union { - struct { - bool x148_24_detectCamera : 1; - bool x148_25_camSubmerged : 1; - bool x148_26_deactivateOnEntered : 1; - bool x148_27_deactivateOnExited : 1; - bool x148_28_playerTriggerProc : 1; - bool x148_29_didPhazonDamage : 1; - }; - u8 dummy = 0; - }; + bool x148_24_detectCamera : 1; + bool x148_25_camSubmerged : 1; + bool x148_26_deactivateOnEntered : 1; + bool x148_27_deactivateOnExited : 1; + bool x148_28_playerTriggerProc : 1; + bool x148_29_didPhazonDamage : 1; public: CScriptTrigger(TUniqueId, std::string_view name, const CEntityInfo& info, const zeus::CVector3f& pos, diff --git a/Runtime/World/CScriptWater.cpp b/Runtime/World/CScriptWater.cpp index 92e1ba2d0..af24d5d80 100644 --- a/Runtime/World/CScriptWater.cpp +++ b/Runtime/World/CScriptWater.cpp @@ -61,14 +61,18 @@ CScriptWater::CScriptWater( , x2b4_alphaInRecip((alphaInTime != 0.f) ? 1.f / alphaInTime : 0.f) , x2b8_alphaOutRecip((alphaOutTime != 0.f) ? 1.f / alphaOutTime : 0.f) , x2bc_alpha(alpha) -, x2c0_tileSize(tileSize) { +, x2c0_tileSize(tileSize) +, x2e8_24_b4(b4) +, x2e8_25_morphIn(false) +, x2e8_26_morphing(false) +, x2e8_27_allowRender(allowRender) +, x2e8_28_recomputeClipping(true) +, x2e8_29_alphaIn(false) +, x2e8_30_alphaOut(false) { zeus::CAABox triggerAABB = GetTriggerBoundsWR(); x2c4_gridDimX = u32((x2c0_tileSize + triggerAABB.max.x() - triggerAABB.min.x() - 0.01f) / x2c0_tileSize); x2c8_gridDimY = u32((x2c0_tileSize + triggerAABB.max.y() - triggerAABB.min.y() - 0.01f) / x2c0_tileSize); x2cc_gridCellCount = (x2c4_gridDimX + 1) * (x2c8_gridDimY + 1); - x2e8_24_b4 = b4; - x2e8_27_allowRender = allowRender; - x2e8_28_recomputeClipping = true; uint32_t maxPatchSize; if (CGraphics::g_BooFactory->isTessellationSupported(maxPatchSize)) diff --git a/Runtime/World/CScriptWater.hpp b/Runtime/World/CScriptWater.hpp index 3751aef0a..0bbe7785e 100644 --- a/Runtime/World/CScriptWater.hpp +++ b/Runtime/World/CScriptWater.hpp @@ -66,18 +66,14 @@ class CScriptWater : public CScriptTrigger { std::unique_ptr x2dc_vertIntersects; std::unique_ptr x2e0_patchIntersects; // 0: all clear, 1: all intersect, 2: partial intersect int x2e4_computedGridCellCount = 0; - union { - struct { - bool x2e8_24_b4 : 1; - bool x2e8_25_morphIn : 1; - bool x2e8_26_morphing : 1; - bool x2e8_27_allowRender : 1; - bool x2e8_28_recomputeClipping : 1; - bool x2e8_29_alphaIn : 1; - bool x2e8_30_alphaOut : 1; - }; - u32 _dummy = 0; - }; + bool x2e8_24_b4 : 1; + bool x2e8_25_morphIn : 1; + bool x2e8_26_morphing : 1; + bool x2e8_27_allowRender : 1; + bool x2e8_28_recomputeClipping : 1; + bool x2e8_29_alphaIn : 1; + bool x2e8_30_alphaOut : 1; + void SetupGrid(bool recomputeClipping); void SetupGridClipping(CStateManager& mgr, int computeVerts); void UpdateSplashInhabitants(CStateManager& mgr); diff --git a/Runtime/World/CScriptWorldTeleporter.hpp b/Runtime/World/CScriptWorldTeleporter.hpp index f76a21763..dc66d9f63 100644 --- a/Runtime/World/CScriptWorldTeleporter.hpp +++ b/Runtime/World/CScriptWorldTeleporter.hpp @@ -16,15 +16,9 @@ class CScriptWorldTeleporter : public CEntity { CAssetId x34_worldId; CAssetId x38_areaId; ETeleporterType x3c_type = ETeleporterType::NoTransition; - union { - struct { - bool x40_24_upElevator : 1; - bool x40_25_inTransition : 1; - bool x40_27_fadeWhite : 1; - }; - u8 _dummy = 0; - }; - + bool x40_24_upElevator : 1; + bool x40_25_inTransition : 1; + bool x40_27_fadeWhite : 1; float x44_charFadeIn = 0.1f; float x48_charsPerSecond = 8.0f; float x4c_showDelay = 0.0f; diff --git a/Runtime/World/CStateMachine.hpp b/Runtime/World/CStateMachine.hpp index 0ddecca84..5de15655a 100644 --- a/Runtime/World/CStateMachine.hpp +++ b/Runtime/World/CStateMachine.hpp @@ -89,15 +89,10 @@ class CStateMachineState { float xc_random = 0.f; float x10_delay = 0.f; float x14_; - union { - struct { - bool x18_24_codeTrigger : 1; - }; - u32 dummy = 0; - }; + bool x18_24_codeTrigger : 1; public: - CStateMachineState() = default; + CStateMachineState() : x18_24_codeTrigger(false) {} CAiState* GetActorState() const { return x4_state; } diff --git a/Runtime/World/CWallCrawlerSwarm.cpp b/Runtime/World/CWallCrawlerSwarm.cpp index 57f9658bb..5faec5c3f 100644 --- a/Runtime/World/CWallCrawlerSwarm.cpp +++ b/Runtime/World/CWallCrawlerSwarm.cpp @@ -69,13 +69,13 @@ CWallCrawlerSwarm::CWallCrawlerSwarm(TUniqueId uid, bool active, std::string_vie , x548_numBoids(numBoids) , x54c_maxCreatedBoids(maxCreatedBoids) , x554_maxLaunches(maxLaunches) -, x558_flavor(flavor) { +, x558_flavor(flavor) +, x560_24_enableLighting(true) +, x560_25_useSoftwareLight(true) +, x560_26_modelAssetDirty(false) { x168_partitionedBoidLists.resize(125); x55c_launchSfx = CSfxManager::TranslateSFXID(launchSfx != -1 ? u16(launchSfx) : u16(0xffff)); x55e_scatterSfx = CSfxManager::TranslateSFXID(scatterSfx != -1 ? u16(scatterSfx) : u16(0xffff)); - x560_24_enableLighting = true; - x560_25_useSoftwareLight = true; - x560_26_modelAssetDirty = false; CAnimRes attractAnimRes(animRes); attractAnimRes.SetCanLoop(true); attractAnimRes.SetDefaultAnim(attractAnim != -1 ? attractAnim : 0); diff --git a/Runtime/World/CWallCrawlerSwarm.hpp b/Runtime/World/CWallCrawlerSwarm.hpp index a7c934f2a..8bc77ee5e 100644 --- a/Runtime/World/CWallCrawlerSwarm.hpp +++ b/Runtime/World/CWallCrawlerSwarm.hpp @@ -42,23 +42,23 @@ public: int x7c_framesNotOnSurface : 8; int x7c_idx : 10; int x7c_remainingLaunchNotOnSurfaceFrames : 8; - - union { - struct { - bool x80_24_active : 1; - bool x80_25_inFrustum : 1; - bool x80_26_launched : 1; - bool x80_27_scarabExplodeTimerEnabled : 1; - bool x80_28_nearPlayer : 1; - }; - u32 x80_ = 0; - }; + bool x80_24_active : 1; + bool x80_25_inFrustum : 1; + bool x80_26_launched : 1; + bool x80_27_scarabExplodeTimerEnabled : 1; + bool x80_28_nearPlayer : 1; public: - CBoid(const zeus::CTransform& xf, int idx) : x0_xf(xf) { - x7c_framesNotOnSurface = 0; - x7c_idx = idx; - } + CBoid(const zeus::CTransform& xf, int idx) + : x0_xf(xf) + , x7c_framesNotOnSurface(0) + , x7c_idx(idx) + , x80_24_active(false) + , x80_25_inFrustum(false) + , x80_26_launched(false) + , x80_27_scarabExplodeTimerEnabled(false) + , x80_28_nearPlayer(false) {} + zeus::CTransform& Transform() { return x0_xf; } zeus::CVector3f& Translation() { return x0_xf.origin; } const zeus::CTransform& GetTransform() const { return x0_xf; } diff --git a/Runtime/World/CWorld.cpp b/Runtime/World/CWorld.cpp index f2499f3ca..3566ac5d7 100644 --- a/Runtime/World/CWorld.cpp +++ b/Runtime/World/CWorld.cpp @@ -184,8 +184,13 @@ std::string CDummyWorld::IGetDefaultAudioTrack() const { return {}; } int CDummyWorld::IGetAreaCount() const { return x18_areas.size(); } CWorld::CWorld(IObjectStore& objStore, IFactory& resFactory, CAssetId mlvlId) -: x8_mlvlId(mlvlId), x60_objectStore(objStore), x64_resFactory(resFactory) { - x70_24_currentAreaNeedsAllocation = true; +: x8_mlvlId(mlvlId) +, x60_objectStore(objStore) +, x64_resFactory(resFactory) +, x70_24_currentAreaNeedsAllocation(true) +, x70_25_loadPaused(false) +, x70_26_skyboxActive(false) +, x70_27_skyboxVisible(false) { SObjectTag tag{FOURCC('MLVL'), mlvlId}; x44_bufSz = resFactory.ResourceSize(tag); x40_loadBuf.reset(new u8[x44_bufSz]); diff --git a/Runtime/World/CWorld.hpp b/Runtime/World/CWorld.hpp index 2b662179d..17e815ff4 100644 --- a/Runtime/World/CWorld.hpp +++ b/Runtime/World/CWorld.hpp @@ -130,16 +130,10 @@ private: IFactory& x64_resFactory; TAreaId x68_curAreaId = kInvalidAreaId; u32 x6c_loadedAudioGrpCount = 0; - - union { - struct { - bool x70_24_currentAreaNeedsAllocation : 1; - bool x70_25_loadPaused : 1; - bool x70_26_skyboxActive : 1; - bool x70_27_skyboxVisible : 1; - }; - u32 dummy = 0; - }; + bool x70_24_currentAreaNeedsAllocation : 1; + bool x70_25_loadPaused : 1; + bool x70_26_skyboxActive : 1; + bool x70_27_skyboxVisible : 1; std::vector x74_soundGroupData; std::string x84_defAudioTrack; std::optional> x94_skyboxWorld; diff --git a/Runtime/World/CWorldTransManager.hpp b/Runtime/World/CWorldTransManager.hpp index 978d0f447..92f09bed9 100644 --- a/Runtime/World/CWorldTransManager.hpp +++ b/Runtime/World/CWorldTransManager.hpp @@ -69,16 +69,11 @@ private: float x38_textStartTime = 0.f; float x3c_sfxInterval; bool x40_strIdx; - union { - struct { - bool x44_24_transFinished : 1; - bool x44_25_stopSoon : 1; - bool x44_26_goingUp : 1; - bool x44_27_fadeWhite : 1; - bool x44_28_textDirty : 1; - }; - u8 dummy = 0; - }; + bool x44_24_transFinished : 1; + bool x44_25_stopSoon : 1; + bool x44_26_goingUp : 1; + bool x44_27_fadeWhite : 1; + bool x44_28_textDirty : 1; CColoredQuadFilter m_fadeToBlack{EFilterType::Blend}; CTexturedQuadFilter m_dissolve{EFilterType::Blend, CGraphics::g_SpareTexture.get()}; @@ -101,7 +96,12 @@ private: void DrawText(); public: - CWorldTransManager() { x44_24_transFinished = true; } + CWorldTransManager() + : x44_24_transFinished(true) + , x44_25_stopSoon(false) + , x44_26_goingUp(false) + , x44_27_fadeWhite(false) + , x44_28_textDirty(false) {} void Update(float); void Draw(); From 0339c16e201dca3d0183e55fe232dd385af43c7e Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 11 Apr 2020 02:02:28 -0400 Subject: [PATCH 15/16] CScriptCoverPoint: Fix GetAttackDirection --- Runtime/MP1/World/CSpacePirate.cpp | 2 +- Runtime/World/CActor.cpp | 2 +- Runtime/World/CScriptCoverPoint.cpp | 2 ++ Runtime/World/CScriptCoverPoint.hpp | 7 ++++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Runtime/MP1/World/CSpacePirate.cpp b/Runtime/MP1/World/CSpacePirate.cpp index f95beba06..5fe62cdf7 100644 --- a/Runtime/MP1/World/CSpacePirate.cpp +++ b/Runtime/MP1/World/CSpacePirate.cpp @@ -2082,7 +2082,7 @@ void CSpacePirate::Cover(CStateManager& mgr, EStateMsg msg, float dt) { case EStateMsg::Activate: if (x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Cover) { if (CScriptCoverPoint* cp = GetCoverPoint(mgr, x640_coverPoint)) { - x79c_coverDir = (cp->GetAttackDirection() & 0x2) ? pas::ECoverDirection::Left : pas::ECoverDirection::Right; + x79c_coverDir = cp->GetAttackDirection(); x32c_animState = EAnimState::Ready; x2e0_destPos = cp->GetTranslation(); TryCommand(mgr, pas::EAnimationState::Cover, &CPatterned::TryCover, int(x79c_coverDir)); diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index 1d538dfc8..cf6b100e5 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -104,7 +104,7 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana else RemoveMaterial(EMaterialTypes::Scannable, mgr); - if (HasModelData() && x64_modelData->GetAnimationData()) { + if (HasModelData() && x64_modelData->HasAnimData()) { TAreaId aid = GetAreaId(); x64_modelData->GetAnimationData()->InitializeEffects(mgr, aid, x64_modelData->GetScale()); } diff --git a/Runtime/World/CScriptCoverPoint.cpp b/Runtime/World/CScriptCoverPoint.cpp index f55cc93b1..479a1318f 100644 --- a/Runtime/World/CScriptCoverPoint.cpp +++ b/Runtime/World/CScriptCoverPoint.cpp @@ -14,6 +14,8 @@ CScriptCoverPoint::CScriptCoverPoint(TUniqueId uid, std::string_view name, const , xe8_26_landHere((flags & 0x20) != 0u) , xe8_27_wallHang((flags & 0x10) != 0u) , xe8_28_stay((flags & 0x8) != 0u) +, xe8_29_((flags & 0x4) != 0u) +, xe8_30_attackDirection((flags & 0x2) != 0u) , xf4_coverTime(coverTime) , xf8_24_crouch(crouch) , xf8_25_inUse(false) { diff --git a/Runtime/World/CScriptCoverPoint.hpp b/Runtime/World/CScriptCoverPoint.hpp index 98f938c29..5b55aeb5b 100644 --- a/Runtime/World/CScriptCoverPoint.hpp +++ b/Runtime/World/CScriptCoverPoint.hpp @@ -4,6 +4,7 @@ #include #include "Runtime/GCNTypes.hpp" +#include "Runtime/Character/CharacterCommon.hpp" #include "Runtime/World/CActor.hpp" #include @@ -13,6 +14,8 @@ class CScriptCoverPoint : public CActor { bool xe8_26_landHere : 1; bool xe8_27_wallHang : 1; bool xe8_28_stay : 1; + bool xe8_29_ : 1; + bool xe8_30_attackDirection : 1; float xec_cosHorizontalAngle; float xf0_sinVerticalAngle; float xf4_coverTime; @@ -42,7 +45,9 @@ public: bool Blown(const zeus::CVector3f& pos) const; float GetSinSqVerticalAngle() const; float GetCosHorizontalAngle() const { return xec_cosHorizontalAngle; } - u32 GetAttackDirection() const { return xe8_flags; } + pas::ECoverDirection GetAttackDirection() const { + return xe8_30_attackDirection ? pas::ECoverDirection::Left : pas::ECoverDirection::Right; + } void Reserve(TUniqueId id) { xfa_occupant = id; } }; } // namespace urde From 22ac7d809973cb40ee6c546b4bfe491b8d388aa0 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 11 Apr 2020 02:09:58 -0400 Subject: [PATCH 16/16] CScriptCoverPoint: Fix GetAttackDirection return value --- Runtime/World/CScriptCoverPoint.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Runtime/World/CScriptCoverPoint.hpp b/Runtime/World/CScriptCoverPoint.hpp index 5b55aeb5b..2a62a12ca 100644 --- a/Runtime/World/CScriptCoverPoint.hpp +++ b/Runtime/World/CScriptCoverPoint.hpp @@ -46,7 +46,7 @@ public: float GetSinSqVerticalAngle() const; float GetCosHorizontalAngle() const { return xec_cosHorizontalAngle; } pas::ECoverDirection GetAttackDirection() const { - return xe8_30_attackDirection ? pas::ECoverDirection::Left : pas::ECoverDirection::Right; + return xe8_30_attackDirection ? pas::ECoverDirection::Right : pas::ECoverDirection::Left; } void Reserve(TUniqueId id) { xfa_occupant = id; } };