2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-06-06 19:13:27 +00:00

use -flto=thin as LTO flag; MemoryCardSys work

This commit is contained in:
Jack Andersen 2016-09-30 12:43:19 -10:00
parent 6c765d19fd
commit 9a15f72fc7
25 changed files with 255 additions and 105 deletions

View File

@ -45,8 +45,8 @@ if(USE_LD_GOLD AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_
if("${LD_VERSION}" MATCHES "GNU gold") if("${LD_VERSION}" MATCHES "GNU gold")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto=thin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=thin")
message(STATUS "GNU gold linker enabled.") message(STATUS "GNU gold linker enabled.")
else() else()
message(WARNING "GNU gold linker isn't available, using the default system linker.") message(WARNING "GNU gold linker isn't available, using the default system linker.")

View File

@ -92,18 +92,10 @@ bool ReadMAPAToBlender(hecl::BlenderConnection& conn,
const typename PAKRouter::EntryType& entry, const typename PAKRouter::EntryType& entry,
bool force) bool force)
{ {
hecl::ProjectPath mapaPath; if (!force && outPath.isFile())
if (pakRouter.isShared())
/* Rename MAPA for consistency */
mapaPath = hecl::ProjectPath(outPath.getParentPath(), _S("!map.blend"));
else
/* We're not in a world pak, so lets keep the original name */
mapaPath = outPath;
if (!force && mapaPath.isFile())
return true; return true;
if (!conn.createBlend(mapaPath, hecl::BlenderConnection::BlendType::MapArea)) if (!conn.createBlend(outPath, hecl::BlenderConnection::BlendType::MapArea))
return false; return false;
hecl::BlenderConnection::PyOutStream os = conn.beginPythonOut(true); hecl::BlenderConnection::PyOutStream os = conn.beginPythonOut(true);

View File

@ -17,18 +17,11 @@ bool ReadMLVLToBlender(hecl::BlenderConnection& conn,
bool force, bool force,
std::function<void(const hecl::SystemChar*)> fileChanged) std::function<void(const hecl::SystemChar*)> fileChanged)
{ {
hecl::ProjectPath mlvlPath; if (!force && outPath.isFile())
if (pakRouter.isShared())
/* Rename MLVL for consistency */
mlvlPath = hecl::ProjectPath(outPath.getParentPath(), _S("!world.blend"));
else
/* We're not in a world pak, so lets keep the original name */
mlvlPath = outPath;
if (!force && mlvlPath.isFile())
return true; return true;
/* Create World Blend */ /* Create World Blend */
if (!conn.createBlend(mlvlPath, hecl::BlenderConnection::BlendType::World)) if (!conn.createBlend(outPath, hecl::BlenderConnection::BlendType::World))
return false; return false;
hecl::BlenderConnection::PyOutStream os = conn.beginPythonOut(true); hecl::BlenderConnection::PyOutStream os = conn.beginPythonOut(true);
os.format("import bpy\n" os.format("import bpy\n"

View File

@ -457,6 +457,17 @@ std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const EntryType& entry) cons
for (const BRIDGETYPE& bridge : *m_bridges) for (const BRIDGETYPE& bridge : *m_bridges)
{ {
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK(); const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
if (isShared())
{
if (entry.type == FOURCC('MLVL'))
return "!world";
else if (entry.type == FOURCC('MREA'))
return "!area";
else if (entry.type == FOURCC('MAPA'))
return "!map";
}
bool named; bool named;
name = pak.bestEntryName(entry, named); name = pak.bestEntryName(entry, named);
if (named) if (named)
@ -475,6 +486,17 @@ std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const IDType& entry) const
const typename BRIDGETYPE::PAKType::Entry* e = pak.lookupEntry(entry); const typename BRIDGETYPE::PAKType::Entry* e = pak.lookupEntry(entry);
if (!e) if (!e)
continue; continue;
if (isShared())
{
if (e->type == FOURCC('MLVL'))
return "!world";
else if (e->type == FOURCC('MREA'))
return "!area";
else if (e->type == FOURCC('MAPA'))
return "!map";
}
bool named; bool named;
name = pak.bestEntryName(*e, named); name = pak.bestEntryName(*e, named);
if (named) if (named)

View File

@ -189,7 +189,7 @@ public:
hecl::ProjectPath getWorking(const IDType& id, bool silenceWarnings=false) const; hecl::ProjectPath getWorking(const IDType& id, bool silenceWarnings=false) const;
hecl::ProjectPath getCooked(const EntryType* entry) const; hecl::ProjectPath getCooked(const EntryType* entry) const;
hecl::ProjectPath getCooked(const IDType& id, bool silenceWarnings=false) const; hecl::ProjectPath getCooked(const IDType& id, bool silenceWarnings=false) const;
bool isShared() bool isShared() const
{ {
const PAKType* pak = m_pak.get(); const PAKType* pak = m_pak.get();
return pak ? !pak->m_noShare : false; return pak ? !pak->m_noShare : false;

View File

@ -65,15 +65,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
using RigPair = std::pair<CSKR*, CINF*>; using RigPair = std::pair<CSKR*, CINF*>;
RigPair dummy(nullptr, nullptr); RigPair dummy(nullptr, nullptr);
hecl::ProjectPath mreaPath; if (!force && outPath.isFile())
if (pakRouter.isShared())
/* Rename MREA for consistency */
mreaPath = hecl::ProjectPath(outPath.getParentPath(), _S("!area.blend"));
else
/* We're not in a world pak, so lets keep the original name */
mreaPath = outPath;
if (!force && mreaPath.isFile())
return true; return true;
/* Do extract */ /* Do extract */
@ -82,7 +74,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
rs.seekAlign32(); rs.seekAlign32();
hecl::BlenderConnection& conn = btok.getBlenderConnection(); hecl::BlenderConnection& conn = btok.getBlenderConnection();
if (!conn.createBlend(mreaPath, hecl::BlenderConnection::BlendType::Area)) if (!conn.createBlend(outPath, hecl::BlenderConnection::BlendType::Area))
return false; return false;
/* Open Py Stream and read sections */ /* Open Py Stream and read sections */

View File

@ -169,15 +169,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
using RigPair = std::pair<CSKR*, CINF*>; using RigPair = std::pair<CSKR*, CINF*>;
RigPair dummy(nullptr, nullptr); RigPair dummy(nullptr, nullptr);
hecl::ProjectPath mreaPath; if (!force && outPath.isFile())
if (pakRouter.isShared())
/* Rename MREA for consistency */
mreaPath = hecl::ProjectPath(outPath.getParentPath(), _S("!area.blend"));
else
/* We're not in a world pak, so lets keep the original name */
mreaPath = outPath;
if (!force && mreaPath.isFile())
return true; return true;
/* Do extract */ /* Do extract */
@ -199,7 +191,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
/* Start up blender connection */ /* Start up blender connection */
hecl::BlenderConnection& conn = btok.getBlenderConnection(); hecl::BlenderConnection& conn = btok.getBlenderConnection();
if (!conn.createBlend(mreaPath, hecl::BlenderConnection::BlendType::Area)) if (!conn.createBlend(outPath, hecl::BlenderConnection::BlendType::Area))
return false; return false;
/* Calculate offset to EGMC section */ /* Calculate offset to EGMC section */

View File

@ -78,15 +78,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
using RigPair = std::pair<CSKR*, CINF*>; using RigPair = std::pair<CSKR*, CINF*>;
RigPair dummy(nullptr, nullptr); RigPair dummy(nullptr, nullptr);
hecl::ProjectPath mreaPath; if (!force && outPath.isFile())
if (pakRouter.isShared())
/* Rename MREA for consistency */
mreaPath = hecl::ProjectPath(outPath.getParentPath(), _S("!area.blend"));
else
/* We're not in a world pak, so lets keep the original name */
mreaPath = outPath;
if (!force && mreaPath.isFile())
return true; return true;
/* Do extract */ /* Do extract */
@ -111,7 +103,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
/* Start up blender connection */ /* Start up blender connection */
hecl::BlenderConnection& conn = btok.getBlenderConnection(); hecl::BlenderConnection& conn = btok.getBlenderConnection();
if (!conn.createBlend(mreaPath, hecl::BlenderConnection::BlendType::Area)) if (!conn.createBlend(outPath, hecl::BlenderConnection::BlendType::Area))
return false; return false;
/* Open Py Stream and read sections */ /* Open Py Stream and read sections */

View File

@ -257,6 +257,12 @@ void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& co
cookArea(cookedPath, path, ds, fast, btok, progress); cookArea(cookedPath, path, ds, fast, btok, progress);
break; break;
} }
case hecl::BlenderConnection::BlendType::World:
{
hecl::BlenderConnection::DataStream ds = conn.beginData();
cookWorld(cookedPath, path, ds, fast, btok, progress);
break;
}
default: break; default: break;
} }
} }

View File

@ -67,6 +67,9 @@ struct SpecBase : hecl::Database::IDataSpec
virtual void cookArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in, virtual void cookArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, hecl::BlenderToken& btok, BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)=0; FCookProgress progress)=0;
virtual void cookWorld(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)=0;
virtual void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in, virtual void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
athena::io::IStreamReader& fin, FCookProgress progress)=0; athena::io::IStreamReader& fin, FCookProgress progress)=0;
virtual void cookAudioGroup(const hecl::ProjectPath& out, const hecl::ProjectPath& in, virtual void cookAudioGroup(const hecl::ProjectPath& out, const hecl::ProjectPath& in,

View File

@ -444,6 +444,14 @@ struct SpecMP1 : SpecBase
DNAMP1::MREA::Cook(out, in, meshCompiles, *colMesh, lights); DNAMP1::MREA::Cook(out, in, meshCompiles, *colMesh, lights);
} }
void cookWorld(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
BlendStream::World world = ds.compileWorld();
}
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in, void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
athena::io::IStreamReader& fin, FCookProgress progress) athena::io::IStreamReader& fin, FCookProgress progress)
{ {

View File

@ -321,6 +321,12 @@ struct SpecMP2 : SpecBase
{ {
} }
void cookWorld(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
}
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in, void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
athena::io::IStreamReader& fin, FCookProgress progress) athena::io::IStreamReader& fin, FCookProgress progress)
{ {

View File

@ -507,6 +507,12 @@ struct SpecMP3 : SpecBase
{ {
} }
void cookWorld(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
}
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in, void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
athena::io::IStreamReader& fin, FCookProgress progress) athena::io::IStreamReader& fin, FCookProgress progress)
{ {

View File

@ -1,4 +1,6 @@
#include "CMapWorldInfo.hpp" #include "CMapWorldInfo.hpp"
#include "GameGlobalObjects.hpp"
#include "CMemoryCardSys.hpp"
namespace urde namespace urde
{ {
@ -6,6 +8,15 @@ namespace urde
CMapWorldInfo::CMapWorldInfo(CBitStreamReader& reader, const CSaveWorld& saveWorld, ResId mlvlId) CMapWorldInfo::CMapWorldInfo(CBitStreamReader& reader, const CSaveWorld& saveWorld, ResId mlvlId)
{ {
/* TODO: implement */ /* TODO: implement */
const auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds();
auto saveWorldMem = std::find_if(memWorlds.cbegin(), memWorlds.cend(),
[&](const auto& test) -> bool { return test.first == mlvlId; });
if (saveWorldMem != memWorlds.cend())
{
}
} }
void CMapWorldInfo::SetDoorVisited(TEditorId eid, bool visited) void CMapWorldInfo::SetDoorVisited(TEditorId eid, bool visited)

View File

@ -30,10 +30,10 @@ CPersistentOptions::CPersistentOptions(CBitStreamReader& stream)
auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds(); auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds();
size_t cinematicCount = 0; size_t cinematicCount = 0;
for (const CSaveWorldMemory& world : memWorlds) for (const auto& world : memWorlds)
{ {
TLockedToken<CSaveWorld> saveWorld = TLockedToken<CSaveWorld> saveWorld =
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.GetSaveWorldAssetId()}); g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first});
cinematicCount += saveWorld->GetCinematicCount(); cinematicCount += saveWorld->GetCinematicCount();
} }
@ -42,15 +42,15 @@ CPersistentOptions::CPersistentOptions(CBitStreamReader& stream)
for (size_t i=0 ; i<cinematicCount ; ++i) for (size_t i=0 ; i<cinematicCount ; ++i)
cinematicStates.push_back(stream.ReadEncoded(1)); cinematicStates.push_back(stream.ReadEncoded(1));
for (const CSaveWorldMemory& world : memWorlds) for (const auto& world : memWorlds)
{ {
TLockedToken<CSaveWorld> saveWorld = TLockedToken<CSaveWorld> saveWorld =
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.GetSaveWorldAssetId()}); g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first});
auto stateIt = cinematicStates.cbegin(); auto stateIt = cinematicStates.cbegin();
for (TEditorId cineId : saveWorld->GetCinematics()) for (TEditorId cineId : saveWorld->GetCinematics())
if (*stateIt++) if (*stateIt++)
SetCinematicState(world.GetWorldAssetId(), cineId, true); SetCinematicState(world.first, cineId, true);
} }
} }

View File

@ -33,15 +33,15 @@ CGameState::CGameState(CBitStreamReader& stream)
for (u32 i = 0; i < 128; i++) for (u32 i = 0; i < 128; i++)
stream.ReadEncoded(8); stream.ReadEncoded(8);
u32 tmp = stream.ReadEncoded(32); u32 tmp = stream.ReadEncoded(32);
double val1 = *(reinterpret_cast<float*>(&tmp)); float val1 = reinterpret_cast<float&>(tmp);
bool val2 = stream.ReadEncoded(1); bool val2 = stream.ReadEncoded(1);
stream.ReadEncoded(1); stream.ReadEncoded(1);
tmp = stream.ReadEncoded(32); tmp = stream.ReadEncoded(32);
double val3 = *(reinterpret_cast<float*>(&tmp)); float val3 = reinterpret_cast<float&>(tmp);
tmp = stream.ReadEncoded(32); tmp = stream.ReadEncoded(32);
double val4 = *(reinterpret_cast<float*>(&tmp)); float val4 = reinterpret_cast<float&>(tmp);
tmp = stream.ReadEncoded(32); tmp = stream.ReadEncoded(32);
double val5 = *(reinterpret_cast<float*>(&tmp)); float val5 = reinterpret_cast<float&>(tmp);
x98_playerState = std::make_shared<CPlayerState>(stream); x98_playerState = std::make_shared<CPlayerState>(stream);
float currentHealth = x98_playerState->GetHealthInfo().GetHP(); float currentHealth = x98_playerState->GetHealthInfo().GetHP();
@ -49,13 +49,13 @@ CGameState::CGameState(CBitStreamReader& stream)
x17c_gameOptions = CGameOptions(stream); x17c_gameOptions = CGameOptions(stream);
x1f8_hintOptions = CHintOptions(stream); x1f8_hintOptions = CHintOptions(stream);
const std::vector<CSaveWorldMemory>& memWorlds = g_MemoryCardSys->GetMemoryWorlds(); const auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds();
x88_worldStates.reserve(memWorlds.size()); x88_worldStates.reserve(memWorlds.size());
for (const CSaveWorldMemory& memWorld : memWorlds) for (const auto& memWorld : memWorlds)
{ {
TLockedToken<CSaveWorld> saveWorld = TLockedToken<CSaveWorld> saveWorld =
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), memWorld.GetSaveWorldAssetId()}); g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), memWorld.second.GetSaveWorldAssetId()});
x88_worldStates.emplace_back(stream, memWorld.GetWorldAssetId(), *saveWorld); x88_worldStates.emplace_back(stream, memWorld.first, *saveWorld);
} }
} }

View File

@ -15,6 +15,7 @@ class CSaveWorldMemory;
/* TODO: Figure out */ /* TODO: Figure out */
class CWorldSomethingState class CWorldSomethingState
{ {
friend class CSaveWorldIntermediate;
std::vector<u32> x0_; std::vector<u32> x0_;
u32 x10_bitCount = 0; u32 x10_bitCount = 0;
std::vector<u32> x14_; std::vector<u32> x14_;
@ -50,9 +51,10 @@ public:
CWorldState(CBitStreamReader& reader, ResId mlvlId, const CSaveWorld& saveWorld); CWorldState(CBitStreamReader& reader, ResId mlvlId, const CSaveWorld& saveWorld);
ResId GetWorldAssetId() const {return x0_mlvlId;} ResId GetWorldAssetId() const {return x0_mlvlId;}
void SetAreaId(TAreaId aid) { x4_areaId = aid; } void SetAreaId(TAreaId aid) { x4_areaId = aid; }
const TAreaId& GetCurrentAreaId() const { return x4_areaId; } TAreaId GetCurrentAreaId() const { return x4_areaId; }
std::shared_ptr<CRelayTracker> RelayTracker() { return x8_relayTracker; } const std::shared_ptr<CRelayTracker>& RelayTracker() const { return x8_relayTracker; }
std::shared_ptr<CMapWorldInfo> MapWorldInfo() { return xc_mapWorldInfo; } const std::shared_ptr<CMapWorldInfo>& MapWorldInfo() const { return xc_mapWorldInfo; }
const std::shared_ptr<CWorldSomethingState>& GetSomethingElse() const { return x14_; }
}; };
class CGameState class CGameState

View File

@ -1,35 +1,131 @@
#include "CMemoryCardSys.hpp" #include "CMemoryCardSys.hpp"
#include "GameGlobalObjects.hpp" #include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp" #include "CSimplePool.hpp"
#include "CGameState.hpp"
namespace urde namespace urde
{ {
CSaveWorldMemory::CSaveWorldMemory(ResId mlvl, ResId savw) CSaveWorldIntermediate::CSaveWorldIntermediate(ResId mlvl, ResId savw)
: x0_mlvlId(mlvl), x8_savwId(savw) : x0_mlvlId(mlvl), x8_savwId(savw)
{ {
if (savw == -1) if (savw == -1)
x2c_dummyWorld = std::make_unique<CDummyWorld>(mlvl, false); x2c_dummyWorld = std::make_unique<CDummyWorld>(mlvl, false);
else else
x3c_saveWorld = g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), savw}); x34_saveWorld = g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), savw});
}
bool CSaveWorldIntermediate::InitializePump()
{
if (x2c_dummyWorld)
{
CDummyWorld& wld = *x2c_dummyWorld;
if (!wld.ICheckWorldComplete())
return false;
x4_strgId = wld.IGetStringTableAssetId();
x8_savwId = wld.IGetSaveWorldAssetId();
u32 areaCount = wld.IGetAreaCount();
xc_areaIds.reserve(areaCount);
for (u32 i=0 ; i<areaCount ; ++i)
{
const IGameArea* area = wld.IGetAreaAlways(i);
xc_areaIds.push_back(area->IGetAreaId());
}
ResId mlvlId = wld.IGetWorldAssetId();
CWorldState& mlvlState = g_GameState->StateForWorld(mlvlId);
x1c_ = mlvlState.GetSomethingElse()->x0_;
x34_saveWorld = g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), x8_savwId});
x2c_dummyWorld.reset();
}
else
{
if (!x34_saveWorld)
return true;
if (x34_saveWorld.IsLoaded() && x34_saveWorld.GetObj())
return true;
}
return false;
} }
CMemoryCardSys::CMemoryCardSys() CMemoryCardSys::CMemoryCardSys()
{ {
xc_memoryWorlds.reserve(16); xc_memoryWorlds.reserve(16);
x1c_.reserve(16); x1c_worldInter.emplace();
x1c_worldInter->reserve(16);
g_ResFactory->EnumerateNamedResources([&](const std::string& name, const SObjectTag& tag) -> bool g_ResFactory->EnumerateNamedResources([&](const std::string& name, const SObjectTag& tag) -> bool
{ {
if (tag.type == FOURCC('MLVL')) if (tag.type == FOURCC('MLVL'))
{ {
auto existingSearch = auto existingSearch =
std::find_if(xc_memoryWorlds.cbegin(), xc_memoryWorlds.cend(), [&](const CSaveWorldMemory& wld) std::find_if(xc_memoryWorlds.cbegin(), xc_memoryWorlds.cend(), [&](const auto& wld)
{ return wld.GetWorldAssetId() == tag.id; }); { return wld.first == tag.id; });
if (existingSearch == xc_memoryWorlds.cend()) if (existingSearch == xc_memoryWorlds.cend())
xc_memoryWorlds.emplace_back(tag.id, -1); {
xc_memoryWorlds.emplace_back(tag.id, CSaveWorldMemory{});
x1c_worldInter->emplace_back(tag.id, -1);
}
} }
return true; return true;
}); });
} }
bool CMemoryCardSys::InitializePump()
{
if (!x1c_worldInter)
{
for (const auto& world : xc_memoryWorlds)
{
const CSaveWorldMemory& wld = world.second;
if (!wld.GetWorldName().IsLoaded() ||
!wld.GetWorldName().GetObj())
return false;
}
if (!x0_hints.IsLoaded() || !x0_hints.GetObj())
return false;
return true;
}
bool done = true;
for (CSaveWorldIntermediate& world : *x1c_worldInter)
{
if (world.InitializePump())
{
if (!world.x34_saveWorld)
continue;
auto existingSearch =
std::find_if(xc_memoryWorlds.begin(), xc_memoryWorlds.end(), [&](const auto& test)
{ return test.first == world.x0_mlvlId; });
CSaveWorldMemory& wldMemOut = existingSearch->second;
wldMemOut.x4_savwId = world.x8_savwId;
wldMemOut.x0_strgId = world.x4_strgId;
wldMemOut.xc_areaIds = world.xc_areaIds;
wldMemOut.x1c_ = world.x1c_;
CSaveWorld& savw = *world.x34_saveWorld;
wldMemOut.x8_areaCount = savw.GetAreaCount();
x20_scanStates.reserve(x20_scanStates.size() + savw.GetScans().size());
for (const CSaveWorld::SScanState& scan : savw.GetScans())
x20_scanStates[scan.x0_id] = scan.x4_category;
wldMemOut.x3c_saveWorld = std::move(world.x34_saveWorld);
wldMemOut.x2c_worldName = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), wldMemOut.x0_strgId});
}
else
done = false;
}
if (done)
x1c_worldInter = std::experimental::nullopt;
return false;
}
} }

View File

@ -4,50 +4,61 @@
#include "CToken.hpp" #include "CToken.hpp"
#include "World/CWorld.hpp" #include "World/CWorld.hpp"
#include "CGameHintInfo.hpp" #include "CGameHintInfo.hpp"
#include "CSaveWorld.hpp"
#include <vector> #include <vector>
namespace urde namespace urde
{ {
class CDummyWorld; class CDummyWorld;
class CSaveWorld; class CStringTable;
class CSaveWorldMemory class CSaveWorldMemory
{ {
ResId x0_mlvlId = -1; friend class CMemoryCardSys;
ResId x4_unk = -1; ResId x0_strgId = -1;
ResId x8_savwId; ResId x4_savwId = -1;
std::vector<u32> xc_; u32 x8_areaCount;
std::vector<u32> x1c_; std::vector<TAreaId> xc_areaIds; /* 4 byte element */
std::unique_ptr<CDummyWorld> x2c_dummyWorld; std::vector<u32> x1c_; /* 16 byte element */
TLockedToken<CSaveWorld> x3c_saveWorld; /* Used to be auto_ptr */ TLockedToken<CStringTable> x2c_worldName; /* used to be optional */
TLockedToken<CSaveWorld> x3c_saveWorld; /* used to be optional */
public: public:
ResId GetWorldAssetId() const { return x0_mlvlId; } ResId GetSaveWorldAssetId() const { return x4_savwId; }
ResId GetSaveWorldAssetId() const { return x8_savwId; } u32 GetAreaCount() const { return x8_areaCount; }
CSaveWorldMemory(ResId mlvl, ResId savw);
const TLockedToken<CStringTable>& GetWorldName() const { return x2c_worldName; }
const TLockedToken<CSaveWorld>& GetSaveWorld() const { return x3c_saveWorld; }
}; };
/* TODO: figure out */ class CSaveWorldIntermediate
class CMemorySomethingElse
{ {
u32 x0_; friend class CMemoryCardSys;
u32 x4_; u32 x0_mlvlId;
u32 x8_; u32 x4_strgId;
std::vector<u32> xc_; u32 x8_savwId;
std::vector<TAreaId> xc_areaIds;
std::vector<u32> x1c_; std::vector<u32> x1c_;
std::unique_ptr<u32> x2c_; std::unique_ptr<CDummyWorld> x2c_dummyWorld;
std::unique_ptr<u32> x34_; TLockedToken<CSaveWorld> x34_saveWorld; /* Used to be auto_ptr */
public:
CSaveWorldIntermediate(ResId mlvl, ResId savw);
bool InitializePump();
}; };
class CMemoryCardSys class CMemoryCardSys
{ {
TLockedToken<CGameHintInfo> x0_hints; TLockedToken<CGameHintInfo> x0_hints;
std::vector<CSaveWorldMemory> xc_memoryWorlds; std::vector<std::pair<ResId, CSaveWorldMemory>> xc_memoryWorlds; /* MLVL as key */
std::vector<CMemorySomethingElse> x1c_; /* used to be auto_ptr of vector */ std::experimental::optional<std::vector<CSaveWorldIntermediate>> x1c_worldInter; /* used to be auto_ptr of vector */
std::unordered_map<ResId, CSaveWorld::EScanCategory> x20_scanStates;
public: public:
const std::vector<CGameHintInfo::CGameHint>& GetHints() const { return x0_hints->GetHints(); } const std::vector<CGameHintInfo::CGameHint>& GetHints() const { return x0_hints->GetHints(); }
const std::vector<CSaveWorldMemory>& GetMemoryWorlds() const { return xc_memoryWorlds; } const std::vector<std::pair<ResId, CSaveWorldMemory>>& GetMemoryWorlds() const { return xc_memoryWorlds; }
CMemoryCardSys(); CMemoryCardSys();
bool InitializePump();
}; };
} }

View File

@ -36,6 +36,7 @@ public:
u32 GetCinematicCount() const; u32 GetCinematicCount() const;
s32 GetCinematicIndex(const TEditorId& id) const; s32 GetCinematicIndex(const TEditorId& id) const;
const std::vector<TEditorId>& GetCinematics() const { return x4_cinematics; } const std::vector<TEditorId>& GetCinematics() const { return x4_cinematics; }
const std::vector<SScanState>& GetScans() const { return x44_scans; }
u32 GetRelayCount() const; u32 GetRelayCount() const;
s32 GetRelayIndex(const TEditorId& id) const; s32 GetRelayIndex(const TEditorId& id) const;
TEditorId GetRelayEditorId(u32 idx) const; TEditorId GetRelayEditorId(u32 idx) const;

View File

@ -23,8 +23,9 @@ URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha)
namespace MP1 namespace MP1
{ {
CGameArchitectureSupport::CGameArchitectureSupport(amuse::IBackendVoiceAllocator& backend) CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, amuse::IBackendVoiceAllocator& backend)
: m_audioSys(backend, 0,0,0,0,0), : m_parent(parent),
m_audioSys(backend, 0,0,0,0,0),
m_inputGenerator(g_tweakPlayer->GetLeftLogicalThreshold(), m_inputGenerator(g_tweakPlayer->GetLeftLogicalThreshold(),
g_tweakPlayer->GetRightLogicalThreshold()), g_tweakPlayer->GetRightLogicalThreshold()),
m_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero) m_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero)
@ -51,6 +52,9 @@ CGameArchitectureSupport::CGameArchitectureSupport(amuse::IBackendVoiceAllocator
bool CGameArchitectureSupport::Update() bool CGameArchitectureSupport::Update()
{ {
if (!g_MemoryCardSys)
m_parent.x128_globalObjects.MemoryCardInitializePump();
bool finished = false; bool finished = false;
m_inputGenerator.Update(1.0 / 60.0, m_archQueue); m_inputGenerator.Update(1.0 / 60.0, m_archQueue);
@ -146,7 +150,7 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr,
x128_globalObjects.PostInitialize(); x128_globalObjects.PostInitialize();
x70_tweaks.RegisterTweaks(); x70_tweaks.RegisterTweaks();
x70_tweaks.RegisterResourceTweaks(); x70_tweaks.RegisterResourceTweaks();
m_archSupport.reset(new CGameArchitectureSupport(backend)); m_archSupport.reset(new CGameArchitectureSupport(*this, backend));
g_archSupport = m_archSupport.get(); g_archSupport = m_archSupport.get();
//g_TweakManager->ReadFromMemoryCard("AudioTweaks"); //g_TweakManager->ReadFromMemoryCard("AudioTweaks");
FillInAssetIDs(); FillInAssetIDs();

View File

@ -45,6 +45,8 @@ class IObjectStore;
namespace MP1 namespace MP1
{ {
class CMain;
class CGameGlobalObjects class CGameGlobalObjects
{ {
std::unique_ptr<CMemoryCardSys> x0_memoryCardSys; std::unique_ptr<CMemoryCardSys> x0_memoryCardSys;
@ -72,8 +74,6 @@ public:
: x4_resFactory(resFactory), xcc_simplePool(objStore) : x4_resFactory(resFactory), xcc_simplePool(objStore)
{ {
g_ResFactory = &x4_resFactory; g_ResFactory = &x4_resFactory;
x0_memoryCardSys.reset(new CMemoryCardSys());
g_MemoryCardSys = x0_memoryCardSys.get();
g_SimplePool = &xcc_simplePool; g_SimplePool = &xcc_simplePool;
g_CharFactoryBuilder = &xec_charFactoryBuilder; g_CharFactoryBuilder = &xec_charFactoryBuilder;
g_AiFuncMap = &x110_aiFuncMap; g_AiFuncMap = &x110_aiFuncMap;
@ -86,6 +86,17 @@ public:
LoadStringTable(); LoadStringTable();
m_renderer.reset(AllocateRenderer(xcc_simplePool, x4_resFactory)); m_renderer.reset(AllocateRenderer(xcc_simplePool, x4_resFactory));
} }
void MemoryCardInitializePump()
{
if (!g_MemoryCardSys)
{
if (!x0_memoryCardSys)
x0_memoryCardSys.reset(new CMemoryCardSys());
if (x0_memoryCardSys->InitializePump())
g_MemoryCardSys = x0_memoryCardSys.get();
}
}
}; };
#if MP1_USE_BOO #if MP1_USE_BOO
@ -94,6 +105,7 @@ class CGameArchitectureSupport : public boo::IWindowCallback
class CGameArchitectureSupport class CGameArchitectureSupport
#endif #endif
{ {
CMain& m_parent;
CArchitectureQueue m_archQueue; CArchitectureQueue m_archQueue;
CAudioSys m_audioSys; CAudioSys m_audioSys;
CInputGenerator m_inputGenerator; CInputGenerator m_inputGenerator;
@ -132,7 +144,7 @@ class CGameArchitectureSupport
} }
public: public:
CGameArchitectureSupport(amuse::IBackendVoiceAllocator& backend); CGameArchitectureSupport(CMain& parent, amuse::IBackendVoiceAllocator& backend);
void PreloadAudio(); void PreloadAudio();
bool Update(); bool Update();
void Draw(); void Draw();
@ -151,6 +163,7 @@ class CMain : public boo::IApplicationCallback, public IMain
class CMain : public IMain class CMain : public IMain
#endif #endif
{ {
friend class CGameArchitectureSupport;
#if MP1_USE_BOO #if MP1_USE_BOO
boo::IWindow* mainWindow; boo::IWindow* mainWindow;
int appMain(boo::IApplication* app); int appMain(boo::IApplication* app);

2
hecl

@ -1 +1 @@
Subproject commit 536a8e4f7dfff11695585d910018211718ff7225 Subproject commit 08a14f35bf8a6381f13f1fa4681e59b30eede946

2
nod

@ -1 +1 @@
Subproject commit 2132895242586251712d40405dd755ff703da638 Subproject commit 38de2ec4a1f1974c8a7b02a78c593907886ae3aa

@ -1 +1 @@
Subproject commit 067c86a585cc43513c3e2c667612d82aacf9809f Subproject commit f6318521f9f28de34051f8e519f7ba8069501468