mirror of https://github.com/AxioDL/metaforce.git
Fix CMemoryCardSys
This commit is contained in:
parent
8a974d6e5e
commit
e553a9022f
|
@ -81,10 +81,10 @@ bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector<ExtractReport
|
|||
case ERegion::NTSC_U:
|
||||
regstr = ®E;
|
||||
break;
|
||||
case ERegion::PAL:
|
||||
case ERegion::NTSC_J:
|
||||
regstr = ®J;
|
||||
break;
|
||||
case ERegion::NTSC_J:
|
||||
case ERegion::PAL:
|
||||
regstr = ®P;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -525,7 +525,10 @@ void CMemoryCardSys::CommitToDisk(kabufuda::ECardSlot port) {
|
|||
|
||||
kabufuda::SystemString CMemoryCardSys::CreateDolphinCard(kabufuda::ECardSlot slot) {
|
||||
kabufuda::SystemString path = _CreateDolphinCard(slot);
|
||||
CardProbe(slot);
|
||||
if (CardProbe(slot).x0_error != ECardResult::READY) {
|
||||
return {};
|
||||
}
|
||||
|
||||
MountCard(slot);
|
||||
FormatCard(slot);
|
||||
kabufuda::Card& card = g_CardStates[int(slot)];
|
||||
|
|
|
@ -71,12 +71,6 @@
|
|||
|
||||
#include <discord_rpc.h>
|
||||
|
||||
namespace hecl {
|
||||
extern CVar* com_enableCheats;
|
||||
extern CVar* com_developer;
|
||||
extern CVar* com_cubemaps;
|
||||
}; // namespace hecl
|
||||
|
||||
namespace urde::MP1 {
|
||||
namespace {
|
||||
struct AudioGroupInfo {
|
||||
|
@ -99,7 +93,7 @@ CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoi
|
|||
, x0_audioSys(voiceEngine, backend, 0, 0, 0, 0, 0)
|
||||
, x30_inputGenerator(g_tweakPlayer->GetLeftLogicalThreshold(), g_tweakPlayer->GetRightLogicalThreshold())
|
||||
, x44_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero) {
|
||||
CMain* m = static_cast<CMain*>(g_Main);
|
||||
auto* m = static_cast<CMain*>(g_Main);
|
||||
|
||||
x30_inputGenerator.startScanning();
|
||||
g_InputGenerator = &x30_inputGenerator;
|
||||
|
@ -145,8 +139,9 @@ void CGameArchitectureSupport::Update(float dt) {
|
|||
}
|
||||
|
||||
bool CGameArchitectureSupport::LoadAudio() {
|
||||
if (x88_audioLoadStatus == EAudioLoadStatus::Loaded)
|
||||
if (x88_audioLoadStatus == EAudioLoadStatus::Loaded) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
TToken<CAudioGroupSet>& tok = x8c_pendingAudioGroups[i];
|
||||
|
@ -355,14 +350,17 @@ void CGameGlobalObjects::PostInitialize() {
|
|||
|
||||
void CMain::AddWorldPaks() {
|
||||
CResLoader* loader = g_ResFactory->GetResLoader();
|
||||
if (!loader)
|
||||
if (loader == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto pakPrefix = g_tweakGame->GetWorldPrefix();
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
std::string path(pakPrefix);
|
||||
|
||||
if (i != 0)
|
||||
path += '0' + i;
|
||||
if (i != 0) {
|
||||
path += '0' + char(i);
|
||||
}
|
||||
|
||||
if (CDvdFile::FileExists(path + ".upak")) {
|
||||
loader->AddPakFileAsync(path, false, true);
|
||||
|
@ -373,8 +371,9 @@ void CMain::AddWorldPaks() {
|
|||
|
||||
void CMain::AddOverridePaks() {
|
||||
CResLoader* loader = g_ResFactory->GetResLoader();
|
||||
if (!loader)
|
||||
if (loader == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Inversely load each pak starting at 999, to ensure proper priority order
|
||||
* the higher the number the higer the priority, e.g: Override0 has less priority than Override1 etc.
|
||||
|
@ -391,9 +390,10 @@ void CMain::AddOverridePaks() {
|
|||
/* Attempt to load URDE.upak
|
||||
* NOTE(phil): Should we fatal here if it's not found?
|
||||
*/
|
||||
if (CDvdFile::FileExists("URDE.upak"))
|
||||
if (CDvdFile::FileExists("URDE.upak")) {
|
||||
loader->AddPakFile("URDE", false, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
void CMain::ResetGameState() {
|
||||
CPersistentOptions sysOpts = g_GameState->SystemOptions();
|
||||
|
@ -417,7 +417,7 @@ void CMain::InitializeSubsystems() {
|
|||
}
|
||||
|
||||
void CMain::MemoryCardInitializePump() {
|
||||
if (g_MemoryCardSys) {
|
||||
if (g_MemoryCardSys != nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -438,8 +438,9 @@ void CMain::FillInAssetIDs() {
|
|||
}
|
||||
|
||||
bool CMain::LoadAudio() {
|
||||
if (x164_archSupport)
|
||||
if (x164_archSupport) {
|
||||
return x164_archSupport->LoadAudio();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -449,8 +450,9 @@ void CMain::EnsureWorldPakReady(CAssetId mlvl) { /* TODO: Schedule resource list
|
|||
}
|
||||
|
||||
void CMain::Give(hecl::Console* console, const std::vector<std::string>& args) {
|
||||
if (args.size() < 1 || (!g_GameState || !g_GameState->GetPlayerState()))
|
||||
if (args.empty() || (g_GameState == nullptr || !g_GameState->GetPlayerState())) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string type = args[0];
|
||||
athena::utility::tolower(type);
|
||||
|
@ -475,8 +477,9 @@ void CMain::Give(hecl::Console* console, const std::vector<std::string>& args) {
|
|||
pState->IncrPickup(eType, 9999);
|
||||
console->report(hecl::Console::Level::Info,
|
||||
FMT_STRING("Cheater....., Greatly increasing Metroid encounters, have fun!"));
|
||||
if (g_StateManager)
|
||||
if (g_StateManager != nullptr) {
|
||||
g_StateManager->Player()->AsyncLoadSuit(*g_StateManager);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -493,23 +496,28 @@ void CMain::Give(hecl::Console* console, const std::vector<std::string>& args) {
|
|||
if (eType == CPlayerState::EItemType::Missiles) {
|
||||
u32 tmp = ((u32(itemAmt) / 5) + (itemAmt % 5)) * 5;
|
||||
pState->ReInitalizePowerUp(eType, tmp);
|
||||
} else
|
||||
} else {
|
||||
pState->ReInitalizePowerUp(eType, itemAmt);
|
||||
}
|
||||
}
|
||||
|
||||
if (itemAmt > 0)
|
||||
if (itemAmt > 0) {
|
||||
pState->IncrPickup(eType, u32(itemAmt));
|
||||
else
|
||||
} else {
|
||||
pState->DecrPickup(eType, zeus::clamp(0u, u32(abs(itemAmt)), pState->GetItemAmount(eType)));
|
||||
}
|
||||
if (g_StateManager)
|
||||
}
|
||||
if (g_StateManager != nullptr) {
|
||||
g_StateManager->Player()->AsyncLoadSuit(*g_StateManager);
|
||||
console->report(hecl::Console::Level::Info, FMT_STRING("Cheater....., Greatly increasing Metroid encounters, have fun!"));
|
||||
}
|
||||
console->report(hecl::Console::Level::Info,
|
||||
FMT_STRING("Cheater....., Greatly increasing Metroid encounters, have fun!"));
|
||||
} // namespace MP1
|
||||
|
||||
void CMain::Remove(hecl::Console*, const std::vector<std::string>& args) {
|
||||
if (args.size() < 1 || (!g_GameState || !g_GameState->GetPlayerState()))
|
||||
if (args.empty() || (g_GameState == nullptr || !g_GameState->GetPlayerState())) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string type = args[0];
|
||||
athena::utility::tolower(type);
|
||||
|
@ -522,37 +530,42 @@ void CMain::Remove(hecl::Console*, const std::vector<std::string>& args) {
|
|||
CPlayerState::EItemType eType = CPlayerState::ItemNameToType(type);
|
||||
if (eType != CPlayerState::EItemType::Invalid) {
|
||||
pState->ReInitalizePowerUp(eType, 0);
|
||||
if (g_StateManager)
|
||||
if (g_StateManager != nullptr) {
|
||||
g_StateManager->Player()->AsyncLoadSuit(*g_StateManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMain::God(hecl::Console* con, const std::vector<std::string>&) {
|
||||
if (g_GameState && g_GameState->GetPlayerState()) {
|
||||
if (g_GameState != nullptr && g_GameState->GetPlayerState()) {
|
||||
g_GameState->GetPlayerState()->SetCanTakeDamage(!g_GameState->GetPlayerState()->CanTakeDamage());
|
||||
if (!g_GameState->GetPlayerState()->CanTakeDamage())
|
||||
if (!g_GameState->GetPlayerState()->CanTakeDamage()) {
|
||||
con->report(hecl::Console::Level::Info, FMT_STRING("God Mode Enabled"));
|
||||
else
|
||||
} else {
|
||||
con->report(hecl::Console::Level::Info, FMT_STRING("God Mode Disabled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMain::Teleport(hecl::Console*, const std::vector<std::string>& args) {
|
||||
if (!g_StateManager || args.size() < 3)
|
||||
if (g_StateManager == nullptr || args.size() < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
zeus::CVector3f loc;
|
||||
for (u32 i = 0; i < 3; ++i)
|
||||
for (u32 i = 0; i < 3; ++i) {
|
||||
loc[i] = strtof(args[i].c_str(), nullptr);
|
||||
}
|
||||
|
||||
zeus::CTransform xf = g_StateManager->Player()->GetTransform();
|
||||
xf.origin = loc;
|
||||
|
||||
if (args.size() >= 6) {
|
||||
zeus::CVector3f angle;
|
||||
for (u32 i = 0; i < 3; ++i)
|
||||
for (u32 i = 0; i < 3; ++i) {
|
||||
angle[i] = zeus::degToRad(strtof(args[i + 3].c_str(), nullptr));
|
||||
}
|
||||
xf.setRotation(zeus::CMatrix3f(zeus::CQuaternion(angle)));
|
||||
}
|
||||
g_StateManager->Player()->Teleport(xf, *g_StateManager, false);
|
||||
|
@ -560,41 +573,47 @@ void CMain::Teleport(hecl::Console*, const std::vector<std::string>& args) {
|
|||
|
||||
void CMain::ListWorlds(hecl::Console* con, const std::vector<std::string>&) {
|
||||
|
||||
if (g_ResFactory && g_ResFactory->GetResLoader()) {
|
||||
for (const auto& pak : g_ResFactory->GetResLoader()->GetPaks())
|
||||
if (g_ResFactory != nullptr && g_ResFactory->GetResLoader() != nullptr) {
|
||||
for (const auto& pak : g_ResFactory->GetResLoader()->GetPaks()) {
|
||||
if (pak->IsWorldPak()) {
|
||||
for (const auto& named : pak->GetNameList())
|
||||
for (const auto& named : pak->GetNameList()) {
|
||||
if (named.second.type == SBIG('MLVL')) {
|
||||
con->report(hecl::Console::Level::Info, FMT_STRING("{} '{}'"), named.first, named.second.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMain::Warp(hecl::Console* con, const std::vector<std::string>& args) {
|
||||
if (!g_StateManager)
|
||||
if (g_StateManager == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.size() < 1)
|
||||
if (args.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
TAreaId aId;
|
||||
TAreaId aId = 0;
|
||||
std::string worldName;
|
||||
if (args.size() == 2) {
|
||||
worldName = args[0];
|
||||
athena::utility::tolower(worldName);
|
||||
aId = strtol(args[1].c_str(), nullptr, 10);
|
||||
} else
|
||||
} else {
|
||||
aId = strtol(args[0].c_str(), nullptr, 10);
|
||||
}
|
||||
|
||||
if (!worldName.empty() && g_ResFactory && g_ResFactory->GetResLoader()) {
|
||||
if (!worldName.empty() && g_ResFactory != nullptr && g_ResFactory->GetResLoader() != nullptr) {
|
||||
bool found = false;
|
||||
|
||||
for (const auto& pak : g_ResFactory->GetResLoader()->GetPaks()) {
|
||||
if (found)
|
||||
if (found) {
|
||||
break;
|
||||
}
|
||||
if (pak->IsWorldPak()) {
|
||||
for (const auto& named : pak->GetNameList())
|
||||
for (const auto& named : pak->GetNameList()) {
|
||||
if (named.second.type == SBIG('MLVL')) {
|
||||
std::string name = named.first;
|
||||
athena::utility::tolower(name);
|
||||
|
@ -607,11 +626,13 @@ void CMain::Warp(hecl::Console* con, const std::vector<std::string>& args) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_GameState->GetWorldTransitionManager()->DisableTransition();
|
||||
|
||||
if (aId >= g_GameState->CurrentWorldState().GetLayerState()->GetAreaCount())
|
||||
if (aId >= g_GameState->CurrentWorldState().GetLayerState()->GetAreaCount()) {
|
||||
aId = 0;
|
||||
}
|
||||
|
||||
g_GameState->CurrentWorldState().SetAreaId(aId);
|
||||
g_Main->SetFlowState(EFlowState::None);
|
||||
|
@ -678,7 +699,7 @@ void CMain::UpdateDiscordPresence(CAssetId worldSTRG) {
|
|||
updated = true;
|
||||
}
|
||||
|
||||
if (g_GameState) {
|
||||
if (g_GameState != nullptr) {
|
||||
if (CPlayerState* pState = g_GameState->GetPlayerState().get()) {
|
||||
u32 itemPercent = pState->CalculateItemCollectionRate() * 100 / pState->GetPickupTotal();
|
||||
if (DiscordItemPercent != itemPercent) {
|
||||
|
@ -699,7 +720,9 @@ void CMain::UpdateDiscordPresence(CAssetId worldSTRG) {
|
|||
}
|
||||
}
|
||||
|
||||
void CMain::HandleDiscordReady(const DiscordUser* request) { DiscordLog.report(logvisor::Info, FMT_STRING("Discord Ready")); }
|
||||
void CMain::HandleDiscordReady(const DiscordUser* request) {
|
||||
DiscordLog.report(logvisor::Info, FMT_STRING("Discord Ready"));
|
||||
}
|
||||
|
||||
void CMain::HandleDiscordDisconnected(int errorCode, const char* message) {
|
||||
DiscordLog.report(logvisor::Warning, FMT_STRING("Discord Disconnected: {}"), message);
|
||||
|
@ -758,13 +781,15 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana
|
|||
const hecl::SystemChar* worldIdxStr = (*(it + 1)).c_str();
|
||||
const hecl::SystemChar* areaIdxStr = (*(it + 2)).c_str();
|
||||
|
||||
hecl::SystemChar* endptr;
|
||||
hecl::SystemChar* endptr = nullptr;
|
||||
m_warpWorldIdx = TAreaId(hecl::StrToUl(worldIdxStr, &endptr, 0));
|
||||
if (endptr == worldIdxStr)
|
||||
if (endptr == worldIdxStr) {
|
||||
m_warpWorldIdx = 0;
|
||||
}
|
||||
m_warpAreaId = TAreaId(hecl::StrToUl(areaIdxStr, &endptr, 0));
|
||||
if (endptr == areaIdxStr)
|
||||
if (endptr == areaIdxStr) {
|
||||
m_warpAreaId = 0;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
for (const auto& pak : g_ResFactory->GetResLoader()->GetPaks()) {
|
||||
|
@ -787,7 +812,7 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana
|
|||
if (*cur == _SYS_STR('1'))
|
||||
m_warpLayerBits |= u64(1) << (cur - layerStr);
|
||||
} else if (layerStr[0] == _SYS_STR('0') && layerStr[1] == _SYS_STR('x')) {
|
||||
m_warpMemoryRelays.push_back(TAreaId(hecl::StrToUl(layerStr + 2, nullptr, 16)));
|
||||
m_warpMemoryRelays.emplace_back(TAreaId(hecl::StrToUl(layerStr + 2, nullptr, 16)));
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
@ -801,21 +826,22 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana
|
|||
x164_archSupport = std::make_unique<CGameArchitectureSupport>(*this, voiceEngine, backend);
|
||||
g_archSupport = x164_archSupport.get();
|
||||
x164_archSupport->PreloadAudio();
|
||||
std::srand(static_cast<unsigned int>(std::time(nullptr)));
|
||||
std::srand(static_cast<u32>(std::time(nullptr)));
|
||||
// g_TweakManager->ReadFromMemoryCard("AudioTweaks");
|
||||
}
|
||||
|
||||
static logvisor::Module WarmupLog("ShaderWarmup");
|
||||
|
||||
void CMain::WarmupShaders() {
|
||||
if (m_warmupTags.size())
|
||||
if (!m_warmupTags.empty())
|
||||
return;
|
||||
|
||||
m_needsWarmupClear = true;
|
||||
size_t modelCount = 0;
|
||||
g_ResFactory->EnumerateResources([&](const SObjectTag& tag) {
|
||||
if (tag.type == FOURCC('CMDL') || tag.type == FOURCC('MREA'))
|
||||
if (tag.type == FOURCC('CMDL') || tag.type == FOURCC('MREA')) {
|
||||
++modelCount;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
m_warmupTags.reserve(modelCount);
|
||||
|
@ -825,8 +851,9 @@ void CMain::WarmupShaders() {
|
|||
|
||||
g_ResFactory->EnumerateResources([&](const SObjectTag& tag) {
|
||||
if (tag.type == FOURCC('CMDL') || tag.type == FOURCC('MREA')) {
|
||||
if (addedTags.find(tag) != addedTags.end())
|
||||
if (addedTags.find(tag) != addedTags.end()) {
|
||||
return true;
|
||||
}
|
||||
addedTags.insert(tag);
|
||||
m_warmupTags.push_back(tag);
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ class CGameArchitectureSupport
|
|||
std::vector<TToken<CAudioGroupSet>> x8c_pendingAudioGroups;
|
||||
|
||||
boo::SWindowRect m_windowRect;
|
||||
bool m_rectIsDirty;
|
||||
bool m_rectIsDirty = false;
|
||||
|
||||
void destroyed() { x4_archQueue.Push(MakeMsg::CreateRemoveAllIOWins(EArchMsgTarget::IOWinManager)); }
|
||||
|
||||
|
|
|
@ -45,8 +45,10 @@ void CEntity::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateM
|
|||
}
|
||||
|
||||
void CEntity::SendScriptMsgs(EScriptObjectState state, CStateManager& stateMgr, EScriptObjectMessage skipMsg) {
|
||||
for (const SConnection& conn : x20_conns)
|
||||
if (conn.x0_state == state && conn.x4_msg != skipMsg)
|
||||
for (const SConnection& conn : x20_conns) {
|
||||
if (conn.x0_state == state && conn.x4_msg != skipMsg) {
|
||||
stateMgr.SendScriptMsg(x8_uid, conn.x8_objId, conn.x4_msg, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace urde
|
||||
|
|
2
kabufuda
2
kabufuda
|
@ -1 +1 @@
|
|||
Subproject commit 6d8d389459243a38efc585dc03b877b4697cdcf2
|
||||
Subproject commit 4891a9568856bb775d0889b47c3808880803423b
|
Loading…
Reference in New Issue