Runtime: Replace bitfield unions with constructor initializers

This commit is contained in:
Luke Street 2020-04-10 15:02:36 -04:00
parent 89e2e65100
commit 346d110b79
10 changed files with 50 additions and 74 deletions

View File

@ -212,10 +212,12 @@ void CGameOptions::PutTo(CBitStreamWriter& writer) const {
writer.WriteEncoded(x68_27_swapBeamsControls, 1); writer.WriteEncoded(x68_27_swapBeamsControls, 1);
} }
CGameOptions::CGameOptions() { CGameOptions::CGameOptions()
x68_24_hudLag = true; : x68_24_hudLag(true)
x68_26_rumble = true; , x68_25_invertY(false)
x68_28_hintSystem = true; , x68_26_rumble(true)
, x68_27_swapBeamsControls(false)
, x68_28_hintSystem(true) {
InitSoundMode(); InitSoundMode();
} }

View File

@ -56,18 +56,12 @@ class CPersistentOptions {
u32 xc4_frozenBallCount = 0; u32 xc4_frozenBallCount = 0;
u32 xc8_powerBombAmmoCount = 0; u32 xc8_powerBombAmmoCount = 0;
u32 xcc_logScanPercent = 0; u32 xcc_logScanPercent = 0;
bool xd0_24_fusionLinked : 1;
union { bool xd0_25_normalModeBeat : 1;
struct { bool xd0_26_hardModeBeat : 1;
bool xd0_24_fusionLinked : 1; bool xd0_27_fusionBeat : 1;
bool xd0_25_normalModeBeat : 1; bool xd0_28_fusionSuitActive : 1;
bool xd0_26_hardModeBeat : 1; bool xd0_29_allItemsCollected : 1;
bool xd0_27_fusionBeat : 1;
bool xd0_28_fusionSuitActive : 1;
bool xd0_29_allItemsCollected : 1;
};
u16 _dummy = 0;
};
public: public:
CPersistentOptions() = default; CPersistentOptions() = default;
@ -116,22 +110,15 @@ class CGameOptions {
u32 x5c_musicVol = 0x7f; u32 x5c_musicVol = 0x7f;
u32 x60_hudAlpha = 0xff; u32 x60_hudAlpha = 0xff;
u32 x64_helmetAlpha = 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<std::pair<CAssetId, CAssetId>> x6c_controlTxtrMap;
s32 m_gamma = 0; 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<std::pair<CAssetId, CAssetId>> x6c_controlTxtrMap;
public: public:
CGameOptions(); CGameOptions();
explicit CGameOptions(CBitStreamReader& stream); explicit CGameOptions(CBitStreamReader& stream);

View File

@ -137,6 +137,7 @@ CGameState::GameFileStateInfo CGameState::LoadGameFileState(const u8* data) {
CGameState::CGameState() { CGameState::CGameState() {
x98_playerState = std::make_shared<CPlayerState>(); x98_playerState = std::make_shared<CPlayerState>();
x9c_transManager = std::make_shared<CWorldTransManager>(); x9c_transManager = std::make_shared<CWorldTransManager>();
x228_24_hardMode = false;
x228_25_initPowerupsAtFirstSpawn = true; x228_25_initPowerupsAtFirstSpawn = true;
if (g_MemoryCardSys) if (g_MemoryCardSys)
InitializeMemoryStates(); InitializeMemoryStates();
@ -144,6 +145,7 @@ CGameState::CGameState() {
CGameState::CGameState(CBitStreamReader& stream, u32 saveIdx) : x20c_saveFileIdx(saveIdx) { CGameState::CGameState(CBitStreamReader& stream, u32 saveIdx) : x20c_saveFileIdx(saveIdx) {
x9c_transManager = std::make_shared<CWorldTransManager>(); x9c_transManager = std::make_shared<CWorldTransManager>();
x228_24_hardMode = false;
x228_25_initPowerupsAtFirstSpawn = true; x228_25_initPowerupsAtFirstSpawn = true;
for (bool& value : x0_) { for (bool& value : x0_) {

View File

@ -81,14 +81,8 @@ class CGameState {
u32 x20c_saveFileIdx = 0; u32 x20c_saveFileIdx = 0;
u64 x210_cardSerial = 0; u64 x210_cardSerial = 0;
std::vector<u8> x218_backupBuf; std::vector<u8> x218_backupBuf;
bool x228_24_hardMode : 1;
union { bool x228_25_initPowerupsAtFirstSpawn : 1;
struct {
bool x228_24_hardMode : 1;
bool x228_25_initPowerupsAtFirstSpawn : 1;
};
u8 _dummy = 0;
};
public: public:
CGameState(); CGameState();

View File

@ -8,6 +8,7 @@ CPakFile::CPakFile(std::string_view filename, bool buildDepList, bool worldPak,
Log.report(logvisor::Fatal, fmt("{}: Unable to open"), GetPath()); Log.report(logvisor::Fatal, fmt("{}: Unable to open"), GetPath());
x28_24_buildDepList = buildDepList; x28_24_buildDepList = buildDepList;
//x28_24_buildDepList = true; // Always do this so URDE can rapidly pre-warm shaders //x28_24_buildDepList = true; // Always do this so URDE can rapidly pre-warm shaders
x28_25_aramFile = false;
x28_26_worldPak = worldPak; x28_26_worldPak = worldPak;
x28_27_stashedInARAM = false; x28_27_stashedInARAM = false;
m_override = override; m_override = override;

View File

@ -36,16 +36,11 @@ public:
}; };
private: private:
union { bool x28_24_buildDepList : 1;
struct { bool x28_25_aramFile : 1;
bool x28_24_buildDepList : 1; bool x28_26_worldPak : 1;
bool x28_25_aramFile : 1; bool x28_27_stashedInARAM : 1;
bool x28_26_worldPak : 1; bool m_override : 1;
bool x28_27_stashedInARAM : 1;
bool m_override : 1;
};
u32 _dummy = 0;
};
enum class EAsyncPhase { enum class EAsyncPhase {
Warmup = 0, Warmup = 0,
InitialHeader = 1, InitialHeader = 1,

View File

@ -74,13 +74,13 @@ constexpr std::array<float, 5> ComboAmmoPeriods{
}; };
} // Anonymous namespace } // Anonymous namespace
CPlayerState::CPlayerState() : x188_staticIntf(5) { CPlayerState::CPlayerState()
x0_24_alive = true; : x0_24_alive(true), x0_25_firingComboBeam(false), x0_26_fusion(false), x188_staticIntf(5) {
x24_powerups.resize(41); x24_powerups.resize(41);
} }
CPlayerState::CPlayerState(CBitStreamReader& stream) : x188_staticIntf(5) { CPlayerState::CPlayerState(CBitStreamReader& stream)
x0_24_alive = true; : x0_24_alive(true), x0_25_firingComboBeam(false), x0_26_fusion(false), x188_staticIntf(5) {
x4_enabledItems = u32(stream.ReadEncoded(32)); x4_enabledItems = u32(stream.ReadEncoded(32));
const u32 integralHP = u32(stream.ReadEncoded(32)); const u32 integralHP = u32(stream.ReadEncoded(32));

View File

@ -94,15 +94,9 @@ private:
constexpr CPowerUp() = default; constexpr CPowerUp() = default;
constexpr CPowerUp(u32 amount, u32 capacity) : x0_amount(amount), x4_capacity(capacity) {} constexpr CPowerUp(u32 amount, u32 capacity) : x0_amount(amount), x4_capacity(capacity) {}
}; };
union { bool x0_24_alive : 1;
struct { bool x0_25_firingComboBeam : 1;
bool x0_24_alive : 1; bool x0_26_fusion : 1;
bool x0_25_firingComboBeam : 1;
bool x0_26_fusion : 1;
};
u32 dummy = 0;
};
u32 x4_enabledItems = 0; u32 x4_enabledItems = 0;
EBeamId x8_currentBeam = EBeamId::Power; EBeamId x8_currentBeam = EBeamId::Power;
CHealthInfo xc_health = {99.f, 50.f}; CHealthInfo xc_health = {99.f, 50.f};

View File

@ -62,7 +62,14 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
, x8bc_relayTracker(relayTracker) , x8bc_relayTracker(relayTracker)
, x8c0_mapWorldInfo(mwInfo) , x8c0_mapWorldInfo(mwInfo)
, x8c4_worldTransManager(wtMgr) , 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<CStateManagerContainer>(); x86c_stateManagerContainer = std::make_unique<CStateManagerContainer>();
x870_cameraManager = &x86c_stateManagerContainer->x0_cameraManager; x870_cameraManager = &x86c_stateManagerContainer->x0_cameraManager;
x874_sortedListManager = &x86c_stateManagerContainer->x3c0_sortedListManager; x874_sortedListManager = &x86c_stateManagerContainer->x3c0_sortedListManager;

View File

@ -202,19 +202,13 @@ private:
CAssetId xf88_; CAssetId xf88_;
float xf8c_ = 0.f; float xf8c_ = 0.f;
EStateManagerTransition xf90_deferredTransition = EStateManagerTransition::InGame; EStateManagerTransition xf90_deferredTransition = EStateManagerTransition::InGame;
bool xf94_24_readyToRender : 1;
union { bool xf94_25_quitGame : 1;
struct { bool xf94_26_generatingObject : 1;
bool xf94_24_readyToRender : 1; bool xf94_27_inMapScreen : 1;
bool xf94_25_quitGame : 1; bool xf94_28_inSaveUI : 1;
bool xf94_26_generatingObject : 1; bool xf94_29_cinematicPause : 1;
bool xf94_27_inMapScreen : 1; bool xf94_30_fullThreat : 1;
bool xf94_28_inSaveUI : 1;
bool xf94_29_cinematicPause : 1;
bool xf94_30_fullThreat : 1;
};
u32 xf94_ = 0;
};
CColoredQuadFilter m_deathWhiteout{EFilterType::Add}; CColoredQuadFilter m_deathWhiteout{EFilterType::Add};
CColoredQuadFilter m_escapeWhiteout{EFilterType::Add}; CColoredQuadFilter m_escapeWhiteout{EFilterType::Add};