MP1/CMain: Add missing fields

This commit is contained in:
Luke Street 2020-05-07 23:20:23 -04:00
parent 1c775a7ea7
commit 34b2383dfd
3 changed files with 69 additions and 23 deletions

View File

@ -236,7 +236,8 @@ 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(std::make_unique<CGameGlobalObjects>(resFactory, resStore)) {
xe4_gameplayResult = EGameplayResult::Playing;
g_Main = this;
}
@ -388,7 +389,7 @@ void CMain::AddOverridePaks() {
void CMain::ResetGameState() {
CPersistentOptions sysOpts = g_GameState->SystemOptions();
CGameOptions gameOpts = g_GameState->GameOptions();
x128_globalObjects.ResetGameState();
x128_globalObjects->ResetGameState();
g_GameState->ImportPersistentOptions(sysOpts);
g_GameState->SetGameOptions(gameOpts);
g_GameState->GetPlayerState()->SetIsFusionEnabled(g_GameState->SystemOptions().GetPlayerFusionSuitActive());
@ -411,7 +412,7 @@ void CMain::MemoryCardInitializePump() {
return;
}
std::unique_ptr<CMemoryCardSys>& memSys = x128_globalObjects.x0_memoryCardSys;
std::unique_ptr<CMemoryCardSys>& memSys = x128_globalObjects->x0_memoryCardSys;
if (!memSys) {
memSys = std::make_unique<CMemoryCardSys>();
}
@ -632,8 +633,8 @@ void CMain::Warp(hecl::Console* con, const std::vector<std::string>& args) {
void CMain::StreamNewGameState(CBitStreamReader& r, u32 idx) {
bool fusionBackup = g_GameState->SystemOptions().GetPlayerFusionSuitActive();
x128_globalObjects.x134_gameState = std::make_unique<CGameState>(r, idx);
g_GameState = x128_globalObjects.x134_gameState.get();
x128_globalObjects->x134_gameState = std::make_unique<CGameState>(r, idx);
g_GameState = x128_globalObjects->x134_gameState.get();
g_GameState->SystemOptions().SetPlayerFusionSuitActive(fusionBackup);
g_GameState->GetPlayerState()->SetIsFusionEnabled(fusionBackup);
g_GameState->HintOptions().SetNextHintTime();
@ -645,7 +646,7 @@ void CMain::RefreshGameState() {
std::vector<u8> saveData = g_GameState->BackupBuf();
CGameOptions gameOpts = g_GameState->GameOptions();
CBitStreamReader r(saveData.data(), saveData.size());
x128_globalObjects.StreamInGameState(r, g_GameState->GetFileIdx());
x128_globalObjects->StreamInGameState(r, g_GameState->GetFileIdx());
g_GameState->SetPersistentOptions(sysOpts);
g_GameState->SetGameOptions(gameOpts);
g_GameState->GameOptions().EnsureSettings();
@ -776,7 +777,7 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana
InitializeSubsystems();
AddOverridePaks();
x128_globalObjects.PostInitialize();
x128_globalObjects->PostInitialize();
x70_tweaks.RegisterTweaks(m_cvarMgr);
x70_tweaks.RegisterResourceTweaks(m_cvarMgr);
AddWorldPaks();
@ -788,8 +789,9 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana
}
hecl::SystemStringConv conv(GetVersionString());
boo::SystemStringView versionView(conv.sys_str());
MainLog.report(logvisor::Level::Info, FMT_STRING(_SYS_STR("Loading data from Metroid Prime version {} from region {}{}")),
versionView, boo::SystemChar(GetRegion()), IsTrilogy() ? _SYS_STR(" from trilogy") : _SYS_STR(""));
MainLog.report(logvisor::Level::Info,
FMT_STRING(_SYS_STR("Loading data from Metroid Prime version {} from region {}{}")), versionView,
boo::SystemChar(GetRegion()), IsTrilogy() ? _SYS_STR(" from trilogy") : _SYS_STR(""));
} else {
MainLog.report(logvisor::Level::Fatal, FMT_STRING("Unable to load version info"));
}
@ -889,7 +891,7 @@ bool CMain::Proc() {
if (m_warmupTags.size())
return false;
if (!m_loadedPersistentResources) {
x128_globalObjects.m_gameResFactory->LoadPersistentResources(*g_SimplePool);
x128_globalObjects->m_gameResFactory->LoadPersistentResources(*g_SimplePool);
m_loadedPersistentResources = true;
}
@ -977,7 +979,7 @@ void CMain::ShutdownSubsystems() {
void CMain::Shutdown() {
m_console->unregisterCommand("Give");
x128_globalObjects.m_gameResFactory->UnloadPersistentResources();
x128_globalObjects->m_gameResFactory->UnloadPersistentResources();
x164_archSupport.reset();
ShutdownSubsystems();
CParticleSwooshShaders::Shutdown();
@ -1012,6 +1014,37 @@ void CMain::Shutdown() {
boo::IWindow* CMain::GetMainWindow() const { return m_mainWindow; }
#if 0
int CMain::RsMain(int argc, boo::SystemChar** argv, boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend) {
// PPCSetFpIEEEMode();
// uVar21 = OSGetTime();
// LCEnable();
x128_globalObjects = std::make_unique<CGameGlobalObjects>(nullptr, nullptr);
xf0_.resize(4, 0.3f);
x104_.resize(4, 0.2f);
x118_ = 0.3f;
x11c_ = 0.2f;
InitializeSubsystems();
x128_globalObjects->PostInitialize(); // COsContext*, CMemorySys*
x70_tweaks.RegisterTweaks(m_cvarMgr);
AddWorldPaks();
std::string msg;
if (!g_TweakManager->ReadFromMemoryCard("AudioTweaks"sv)) {
msg = "Loaded audio tweaks from memory card\n"s;
} else {
msg = "FAILED to load audio tweaks from memory card\n";
}
FillInAssetIDs();
x164_archSupport = std::make_unique<CGameArchitectureSupport>(*this, voiceEngine, backend);
x164_archSupport->PreloadAudio();
return 0;
}
#endif
#if MP1_USE_BOO
int CMain::appMain(boo::IApplication* app) {

View File

@ -206,17 +206,32 @@ private:
const boo::ObjToken<boo::ITextureR>& spareTex);
} m_booSetter;
// COsContext x0_osContext;
// CMemorySys x6c_memSys;
CTweaks x70_tweaks;
EGameplayResult xe4_gameplayResult;
/* urde addition: these are simply initialized along with everything else */
CGameGlobalObjects x128_globalObjects;
double xe8_;
rstl::reserved_vector<float, 4> xf0_;
rstl::reserved_vector<float, 4> x104_;
float x118_;
float x11c_;
float x120_;
float x124_;
std::unique_ptr<CGameGlobalObjects> x128_globalObjects;
EFlowState x12c_flowState = EFlowState::Default;
u32 x130_[10] = {1000000};
rstl::reserved_vector<u32, 10> x130_{{
1000000,
1000000,
1000000,
1000000,
1000000,
1000000,
1000000,
1000000,
1000000,
1000000,
}};
// u32 x15c_ = 0;
bool x160_24_finished : 1 = false;
bool x160_25_mfGameBuilt : 1 = false;
bool x160_26_screenFading : 1 = false;
@ -226,11 +241,9 @@ private:
bool x160_30_ : 1 = false;
bool x160_31_cardBusy : 1 = false;
bool x161_24_gameFrameDrawn : 1 = false;
std::unique_ptr<CGameArchitectureSupport> x164_archSupport;
boo::IWindow* m_mainWindow = nullptr;
hecl::CVarManager* m_cvarMgr = nullptr;
std::unique_ptr<hecl::CVarCommons> m_cvarCommons;
std::unique_ptr<hecl::Console> m_console;
@ -269,7 +282,7 @@ public:
static void UpdateDiscordPresence(CAssetId worldSTRG = {});
// int RsMain(int argc, const boo::SystemChar* argv[]);
// int RsMain(int argc, boo::SystemChar** argv, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend);
void Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarManager* cvarManager, boo::IWindow* window,
boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) override;
void WarmupShaders() override;
@ -318,7 +331,7 @@ public:
bool IsTrilogy() const override { return m_version.isTrilogy; }
ERegion GetRegion() const override { return m_version.region; }
EGame GetGame() const override { return m_version.game; }
std::string_view GetVersionString() const override{ return m_version.version; }
std::string_view GetVersionString() const override { return m_version.version; }
int m_warpWorldIdx = -1;
TAreaId m_warpAreaId = 0;

View File

@ -186,7 +186,7 @@ void CScriptSound::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
}
void CScriptSound::PlaySound(CStateManager& mgr) {
if (!x11d_24_allowDuplicates && xec_sfxHandle && !xec_sfxHandle->IsClosed() || x11d_25_processedThisFrame) {
if ((!x11d_24_allowDuplicates && xec_sfxHandle && !xec_sfxHandle->IsClosed()) || x11d_25_processedThisFrame) {
return;
}