2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 13:07:42 +00:00
This commit is contained in:
2016-04-10 22:14:02 -07:00
99 changed files with 2668 additions and 408 deletions

View File

@@ -1,13 +1,14 @@
#include "DNACommon.hpp"
#include "PAK.hpp"
#include "boo/ThreadLocalPtr.hpp"
namespace DataSpec
{
logvisor::Module LogDNACommon("urde::DNACommon");
SpecBase* g_curSpec = nullptr;
PAKRouterBase* g_PakRouter = nullptr;
hecl::Database::Project* UniqueIDBridge::s_Project = nullptr;
ThreadLocalPtr<SpecBase> g_curSpec;
ThreadLocalPtr<PAKRouterBase> g_PakRouter;
ThreadLocalPtr<hecl::Database::Project> UniqueIDBridge::s_Project;
UniqueID32 UniqueID32::kInvalidId;
}

View File

@@ -7,13 +7,14 @@
#include "hecl/hecl.hpp"
#include "hecl/Database.hpp"
#include "../SpecBase.hpp"
#include "boo/ThreadLocalPtr.hpp"
namespace DataSpec
{
extern logvisor::Module LogDNACommon;
extern SpecBase* g_curSpec;
extern class PAKRouterBase* g_PakRouter;
extern ThreadLocalPtr<SpecBase> g_curSpec;
extern ThreadLocalPtr<class PAKRouterBase> g_PakRouter;
/* This comes up a great deal */
typedef athena::io::DNA<athena::BigEndian> BigDNA;
@@ -84,22 +85,24 @@ class UniqueIDBridge
friend class UniqueID32;
friend class UniqueID64;
static hecl::Database::Project* s_Project;
static ThreadLocalPtr<hecl::Database::Project> s_Project;
public:
template <class IDType>
static hecl::ProjectPath TranslatePakIdToPath(const IDType& id, bool silenceWarnings=false)
{
if (!g_PakRouter)
PAKRouterBase* pakRouter = g_PakRouter.get();
if (!pakRouter)
LogDNACommon.report(logvisor::Fatal,
"g_Project must be set to non-null before calling UniqueIDBridge::TranslatePakIdToPath");
return g_PakRouter->getWorking(id, silenceWarnings);
return pakRouter->getWorking(id, silenceWarnings);
}
static hecl::ProjectPath MakePathFromString(const std::string& str)
{
if (!s_Project)
hecl::Database::Project* project = s_Project.get();
if (!project)
LogDNACommon.report(logvisor::Fatal,
"UniqueIDBridge::setGlobalProject must be called before MakePathFromString");
return hecl::ProjectPath(*s_Project, str);
return hecl::ProjectPath(*project, str);
}
template <class IDType>
static void TransformOldHashToNewHash(IDType& id)
@@ -109,7 +112,7 @@ public:
static void setGlobalProject(hecl::Database::Project& project)
{
s_Project = &project;
s_Project.reset(&project);
}
};

View File

@@ -224,7 +224,7 @@ void PAKRouter<BRIDGETYPE>::build(std::vector<BRIDGETYPE>& bridges, std::functio
template <class BRIDGETYPE>
void PAKRouter<BRIDGETYPE>::enterPAKBridge(const BRIDGETYPE& pakBridge)
{
g_PakRouter = this;
g_PakRouter.reset(this);
auto pit = m_bridgePaths.begin();
size_t bridgeIdx = 0;
for (const BRIDGETYPE& bridge : *m_bridges)