Runtime/MP1: Replace bitfield unions with constructor initializers

This commit is contained in:
Luke Street 2020-04-10 15:25:40 -04:00
parent d23e76db54
commit 402e45ecb5
22 changed files with 153 additions and 164 deletions

View File

@ -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) {

View File

@ -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;
};
};
std::unique_ptr<CGameOptionsTouchBar> m_touchBar;
bool m_touchBarInValue = false;

View File

@ -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));

View File

@ -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<CTexturedQuadFilter> m_deathRenderTexQuad;
std::optional<CTexturedQuadFilter> 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<TLockedToken<CDependencyGroup>> LockPauseScreenDependencies();
bool CheckDGRPLoadComplete() const;
void BeginStateTransition(EInGameGuiState state, CStateManager& stateMgr);

View File

@ -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<CArtifactDoll>();
@ -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"");

View File

@ -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<CArtifactDoll> x258_artifactDoll;
enum class ELeavePauseState { InPause = 0, LeavingPause = 1, LeftPause = 2 };
ELeavePauseState x25c_leavePauseState = ELeavePauseState::InPause;
union {
struct {
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;
};
s32 _dummy = 0;
};
void InitializeLogBook();
void UpdateRightTitles();

View File

@ -14,13 +14,16 @@ namespace urde::MP1 {
CMFGame::CMFGame(const std::weak_ptr<CStateManager>& stateMgr, const std::weak_ptr<CInGameGuiManager>& 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<CMain&>(*g_Main).SetMFGameBuilt(true);
}
CMFGame::~CMFGame() {
CMain& main = static_cast<CMain&>(*g_Main);
auto& main = static_cast<CMain&>(*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<CMain*>(g_Main);
CMFGameLoader::CMFGameLoader()
: CMFGameLoaderBase("CMFGameLoader"), x2c_24_initialized(false), x2c_25_transitionFinished(false) {
auto* m = static_cast<CMain*>(g_Main);
switch (m->GetFlowState()) {
case EFlowState::Default:
case EFlowState::StateSetter: {

View File

@ -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;
};
CColoredQuadFilter m_fadeToBlack{EFilterType::Multiply};
@ -57,14 +52,8 @@ class CMFGameLoader : public CMFGameLoaderBase {
std::shared_ptr<CStateManager> x14_stateMgr;
std::shared_ptr<CInGameGuiManager> x18_guiMgr;
std::vector<CToken> x1c_loadList;
union {
struct {
bool x2c_24_initialized : 1;
bool x2c_25_transitionFinished : 1;
};
u8 _dummy = 0;
};
void MakeLoadDependencyList();

View File

@ -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();
}

View File

@ -74,8 +74,6 @@ 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;
@ -89,9 +87,7 @@ protected:
bool m_leftClicked : 1;
bool m_rightClicked : 1;
bool m_playRightTableSfx : 1;
};
u32 _dummy = 0;
};
void InitializeFrameGlue();
void ChangeMode(EMode mode, bool playSfx = true);
void UpdateSideTable(CGuiTableGroup* table);

View File

@ -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) {

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
};
static bool IsResultsScreen(EWhichMovie which);
public:

View File

@ -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<CActorLights>(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()) {

View File

@ -71,8 +71,6 @@ 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;
@ -81,9 +79,6 @@ class CSamusDoll {
bool x270_29_pulseBoots : 1;
bool x270_30_pulseVisor : 1;
bool x270_31_loaded : 1;
};
u32 _dummy = 0;
};
static constexpr zeus::CVector3f skInitialOffset{0.0f, 0.0f, 0.8f};
static CModelData BuildSuitModelData1(CPlayerState::EPlayerSuit suit);

View File

@ -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<CActorLights>(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);

View File

@ -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;
};
u32 x2e4_ = 0;
u32 x2e8_ = 0;
CPlayerGun::EMissleMode x2ec_missileMode = CPlayerGun::EMissleMode::Inactive;

View File

@ -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);

View File

@ -87,9 +87,6 @@ private:
float x12c_ = 32.f;
*/
float x130_;
union {
struct {
bool x134_24_ : 1;
bool x134_25_ : 1;
bool x134_26_ : 1;
@ -99,9 +96,6 @@ private:
bool x134_30_ : 1;
bool x134_31_ : 1;
bool x135_24_ : 1;
};
u32 dummy = 0;
};
bool LoadTXTRDep(std::string_view name);
static bool AreAllDepsLoaded(const std::vector<TLockedToken<CDependencyGroup>>& deps);

View File

@ -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<boo::ITextureR>& 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;
}

View File

@ -227,8 +227,6 @@ private:
u32 x130_[10] = {1000000};
union {
struct {
bool x160_24_finished : 1;
bool x160_25_mfGameBuilt : 1;
bool x160_26_screenFading : 1;
@ -238,9 +236,6 @@ private:
bool x160_30_ : 1;
bool x160_31_cardBusy : 1;
bool x161_24_gameFrameDrawn : 1;
};
u16 _dummy = 0;
};
std::unique_ptr<CGameArchitectureSupport> x164_archSupport;