2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-07-01 13:33:32 +00:00

Various bug fixes, implement CMain::WarpTo

This commit is contained in:
Phillip Stephens 2018-09-20 20:41:57 -07:00
parent 94fd52d0ea
commit 8b25548482
10 changed files with 88 additions and 9 deletions

View File

@ -289,6 +289,9 @@ void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& i
void CMapArea::CMapAreaSurface::Draw(const zeus::CVector3f* verts, const zeus::CColor& surfColor, void CMapArea::CMapAreaSurface::Draw(const zeus::CVector3f* verts, const zeus::CColor& surfColor,
const zeus::CColor& lineColor, float lineWidth, int instIdx) const const zeus::CColor& lineColor, float lineWidth, int instIdx) const
{ {
if (instIdx >= m_instances.size())
return;
Instance& instance = const_cast<Instance&>(m_instances[instIdx]); Instance& instance = const_cast<Instance&>(m_instances[instIdx]);
if (surfColor.a) if (surfColor.a)

View File

@ -204,7 +204,7 @@ void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo,
TLockedToken<CTexture> tex = g_SimplePool->GetObj(SObjectTag{FOURCC('TXTR'), iconRes}); TLockedToken<CTexture> tex = g_SimplePool->GetObj(SObjectTag{FOURCC('TXTR'), iconRes});
if (!m_texQuadFilter || m_texQuadFilter->GetTex().GetObj() != tex.GetObj()) if (!m_texQuadFilter || m_texQuadFilter->GetTex().GetObj() != tex.GetObj())
const_cast<CMappableObject*>(this)->m_texQuadFilter.emplace(EFilterType::Blend, tex); const_cast<CMappableObject*>(this)->m_texQuadFilter.emplace(EFilterType::Add, tex);
CTexturedQuadFilter::Vert verts[4] = CTexturedQuadFilter::Vert verts[4] =
{ {

View File

@ -41,6 +41,7 @@ public:
void InitializeWorldLayers(const std::vector<CWorldLayers::Area>& layers); void InitializeWorldLayers(const std::vector<CWorldLayers::Area>& layers);
u32 GetAreaLayerCount(int areaIdx) const { return x0_areaLayers[areaIdx].m_layerCount; } u32 GetAreaLayerCount(int areaIdx) const { return x0_areaLayers[areaIdx].m_layerCount; }
u32 GetAreaCount() const { return x0_areaLayers.size(); }
void PutTo(CBitStreamWriter& writer) const; void PutTo(CBitStreamWriter& writer) const;
}; };

View File

@ -216,7 +216,7 @@ bool CResLoader::FindResource(CAssetId id) const
return true; return true;
} }
Log.report(logvisor::Fatal, "Unable to find asset %08X", id); Log.report(logvisor::Warning, "Unable to find asset %08X", id);
return false; return false;
} }

View File

@ -2008,8 +2008,11 @@ void CStateManager::Update(float dt)
xf94_27_inMapScreen = false; xf94_27_inMapScreen = false;
} }
if (!m_warping)
{
g_GameState->CurrentWorldState().SetAreaId(x8cc_nextAreaId); g_GameState->CurrentWorldState().SetAreaId(x8cc_nextAreaId);
x850_world->TravelToArea(x8cc_nextAreaId, *this, false); x850_world->TravelToArea(x8cc_nextAreaId, *this, false);
}
ClearGraveyard(); ClearGraveyard();
++x8d8_updateFrameIdx; ++x8d8_updateFrameIdx;

View File

@ -235,6 +235,7 @@ private:
CColoredQuadFilter m_deathWhiteout = { EFilterType::Add }; CColoredQuadFilter m_deathWhiteout = { EFilterType::Add };
CColoredQuadFilter m_escapeWhiteout = { EFilterType::Add }; CColoredQuadFilter m_escapeWhiteout = { EFilterType::Add };
bool m_warping = false;
void UpdateThermalVisor(); void UpdateThermalVisor();
static void RendererDrawCallback(const void*, const void*, int); static void RendererDrawCallback(const void*, const void*, int);
@ -472,6 +473,8 @@ public:
std::shared_ptr<CWorldLayerState>& WorldLayerStateNC() { return x8c8_worldLayerState; } std::shared_ptr<CWorldLayerState>& WorldLayerStateNC() { return x8c8_worldLayerState; }
static float g_EscapeShakeCountdown; static float g_EscapeShakeCountdown;
static bool g_EscapeShakeCountdownInit; static bool g_EscapeShakeCountdownInit;
void SetWarping(bool v) { m_warping = true; }
}; };
} }

View File

@ -282,7 +282,7 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf)
if (!x40_24_texturesLoaded && !g_DummyTextures) if (!x40_24_texturesLoaded && !g_DummyTextures)
return nullptr; return nullptr;
if (m_instances.size() >= 256) if (m_instances.size() >= 512)
Log.report(logvisor::Fatal, "Model buffer overflow"); Log.report(logvisor::Fatal, "Model buffer overflow");
m_instances.emplace_back(); m_instances.emplace_back();
ModelInstance& newInst = m_instances.back(); ModelInstance& newInst = m_instances.back();

View File

@ -386,10 +386,16 @@ void CMain::AddWorldPaks()
for (int i=0 ; i<9 ; ++i) for (int i=0 ; i<9 ; ++i)
{ {
std::string path(pakPrefix); std::string path(pakPrefix);
if (i != 0) if (i != 0)
path += '0' + i; path += '0' + i;
std::string lowerPath(path);
athena::utility::tolower(lowerPath);
if (CDvdFile::FileExists((path + ".upak").c_str())) if (CDvdFile::FileExists((path + ".upak").c_str()))
loader->AddPakFileAsync(path, false, true); loader->AddPakFileAsync(path, false, true);
else if (CDvdFile::FileExists((lowerPath + ".upak").c_str()))
loader->AddPakFileAsync(lowerPath, false, true);
} }
loader->WaitForPakFileLoadingComplete(); loader->WaitForPakFileLoadingComplete();
} }
@ -511,7 +517,7 @@ void CMain::Give(hecl::Console* console, const std::vector<std::string>& args)
else else
pState->DecrPickup(eType, zeus::clamp(0u, u32(abs(itemAmt)), pState->GetItemAmount(eType))); pState->DecrPickup(eType, zeus::clamp(0u, u32(abs(itemAmt)), pState->GetItemAmount(eType)));
} }
g_StateManager->Player()->AsyncLoadSuit(*g_StateManager);
console->report(hecl::Console::Level::Info, "Cheater....., Greatly increasing Metroid encounters, have fun!"); console->report(hecl::Console::Level::Info, "Cheater....., Greatly increasing Metroid encounters, have fun!");
} }
@ -551,6 +557,7 @@ void CMain::Teleport(hecl::Console *, const std::vector<std::string>& args)
void CMain::ListWorlds(hecl::Console* con, const std::vector<std::string> &) void CMain::ListWorlds(hecl::Console* con, const std::vector<std::string> &)
{ {
if (g_ResFactory && g_ResFactory->GetResLoader()) if (g_ResFactory && g_ResFactory->GetResLoader())
{ {
for (const auto& pak : g_ResFactory->GetResLoader()->GetPaks()) for (const auto& pak : g_ResFactory->GetResLoader()->GetPaks())
@ -558,9 +565,68 @@ void CMain::ListWorlds(hecl::Console* con, const std::vector<std::string> &)
{ {
for (const auto& named : pak->GetNameList()) for (const auto& named : pak->GetNameList())
if (named.second.type == SBIG('MLVL')) if (named.second.type == SBIG('MLVL'))
con->report(hecl::Console::Level::Info, "%s '%08X'", named.first.c_str(), named.second.id.Value()); {
con->report(hecl::Console::Level::Info, "%s '%08X'", named.first.c_str(),
named.second.id.Value());
} }
} }
}
}
void CMain::WarpTo(hecl::Console* con, const std::vector<std::string>& args)
{
if (!g_StateManager)
return;
if (args.size() < 1)
return;
TAreaId aId;
std::string worldName;
if (args.size() == 2)
{
worldName = args[0];
athena::utility::tolower(worldName);
aId = strtol(args[1].c_str(), nullptr, 10);
}
else
aId = strtol(args[0].c_str(), nullptr, 10);
if (!worldName.empty() && g_ResFactory && g_ResFactory->GetResLoader())
{
bool found = false;
for (const auto& pak : g_ResFactory->GetResLoader()->GetPaks())
{
if (found)
break;
if (pak->IsWorldPak())
{
for (const auto& named : pak->GetNameList())
if (named.second.type == SBIG('MLVL'))
{
std::string name = named.first;
athena::utility::tolower(name);
if (name.find(worldName) != std::string::npos)
{
g_GameState->SetCurrentWorldId(named.second.id);
found = true;
break;
}
}
}
}
}
g_GameState->GetWorldTransitionManager()->DisableTransition();
if (aId >= g_GameState->CurrentWorldState().GetLayerState()->GetAreaCount())
aId = 0;
g_GameState->CurrentWorldState().SetAreaId(aId);
g_Main->SetFlowState(EFlowState::None);
g_StateManager->SetWarping(true);
g_StateManager->SetShouldQuitGame(true);
} }
void CMain::StreamNewGameState(CBitStreamReader& r, u32 idx) void CMain::StreamNewGameState(CBitStreamReader& r, u32 idx)
@ -664,11 +730,12 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr,
m_mainWindow = window; m_mainWindow = window;
m_cvarMgr = cvarMgr; m_cvarMgr = cvarMgr;
m_console = std::make_unique<hecl::Console>(m_cvarMgr); m_console = std::make_unique<hecl::Console>(m_cvarMgr);
m_console->registerCommand("quit"sv, "Quits the game immediately"sv, ""sv, std::bind(&CMain::quit, this, std::placeholders::_1, std::placeholders::_2)); m_console->registerCommand("Quit"sv, "Quits the game immediately"sv, ""sv, std::bind(&CMain::quit, this, std::placeholders::_1, std::placeholders::_2));
m_console->registerCommand("Give"sv, "Gives the player the specified item, maxing it out"sv, ""sv, std::bind(&CMain::Give, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Cheat); m_console->registerCommand("Give"sv, "Gives the player the specified item, maxing it out"sv, ""sv, std::bind(&CMain::Give, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Cheat);
m_console->registerCommand("Teleport"sv, "Teleports the player to the specified coordinates in worldspace"sv, "x y z [dX dY dZ]"sv, std::bind(&CMain::Teleport, this, std::placeholders::_1, std::placeholders::_2), (hecl::SConsoleCommand::ECommandFlags::Cheat | hecl::SConsoleCommand::ECommandFlags::Developer)); m_console->registerCommand("Teleport"sv, "Teleports the player to the specified coordinates in worldspace"sv, "x y z [dX dY dZ]"sv, std::bind(&CMain::Teleport, this, std::placeholders::_1, std::placeholders::_2), (hecl::SConsoleCommand::ECommandFlags::Cheat | hecl::SConsoleCommand::ECommandFlags::Developer));
m_console->registerCommand("God"sv, "Disables damage given by enemies and objects"sv, ""sv, std::bind(&CMain::God, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Cheat); m_console->registerCommand("God"sv, "Disables damage given by enemies and objects"sv, ""sv, std::bind(&CMain::God, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Cheat);
m_console->registerCommand("listWorlds"sv, "Lists loaded worlds"sv, ""sv, std::bind(&CMain::ListWorlds, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Normal); m_console->registerCommand("ListWorlds"sv, "Lists loaded worlds"sv, ""sv, std::bind(&CMain::ListWorlds, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Normal);
m_console->registerCommand("WarpTo"sv, "Warps to a given area and world"sv, "[worldname] areaId"sv, std::bind(&CMain::WarpTo, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Normal);
InitializeSubsystems(storeMgr); InitializeSubsystems(storeMgr);
x128_globalObjects.PostInitialize(); x128_globalObjects.PostInitialize();

View File

@ -335,6 +335,7 @@ public:
void God(hecl::Console*, const std::vector<std::string>&); void God(hecl::Console*, const std::vector<std::string>&);
void Teleport(hecl::Console*, const std::vector<std::string>&); void Teleport(hecl::Console*, const std::vector<std::string>&);
void ListWorlds(hecl::Console*, const std::vector<std::string>&); void ListWorlds(hecl::Console*, const std::vector<std::string>&);
void WarpTo(hecl::Console*, const std::vector<std::string>&);
hecl::Console* Console() const { return m_console.get(); } hecl::Console* Console() const { return m_console.get(); }
}; };

View File

@ -457,6 +457,7 @@ void CWorldTransManager::StartTextFadeOut()
void CWorldTransManager::DisableTransition() void CWorldTransManager::DisableTransition()
{ {
x30_type = ETransType::Disabled;
x4_modelData.reset(); x4_modelData.reset();
x8_textData.reset(); x8_textData.reset();
x44_26_goingUp = false; x44_26_goingUp = false;