ObjLoading: Be able to load and index IWD files

This commit is contained in:
Jan
2020-01-01 18:46:33 +01:00
parent a4d55ffae7
commit 0abdb64832
27 changed files with 667 additions and 252 deletions

View File

@ -1,9 +1,10 @@
#include "ObjLoaderT6.h"
#include "Game/T6/GameT6.h"
#include "Game/T6/GameAssetPoolT6.h"
#include "ObjContainer/IPak/IPak.h"
const int ObjLoaderT6::IPAK_READ_HASH = ObjLoaderT6::Com_HashKey("ipak_read", 64);
const int ObjLoaderT6::GLOBAL_HASH = ObjLoaderT6::Com_HashKey("GLOBAL", 64);
const int ObjLoaderT6::IPAK_READ_HASH = Com_HashKey("ipak_read", 64);
const int ObjLoaderT6::GLOBAL_HASH = Com_HashKey("GLOBAL", 64);
int ObjLoaderT6::Com_HashKey(const char* str, const int maxLen)
{
@ -27,10 +28,18 @@ bool ObjLoaderT6::SupportsZone(Zone* zone)
return zone->m_game == &g_GameT6;
}
void ObjLoaderT6::LoadIPakForZone(const std::string& ipakName, Zone* zone)
void ObjLoaderT6::LoadIPakForZone(ISearchPath* searchPath, const std::string& ipakName, Zone* zone)
{
printf("Loading ipak '%s' for zone '%s'\n", ipakName.c_str(), zone->m_name.c_str());
// TODO
const std::string ipakFilename = ipakName + ".ipak";
auto* file = searchPath->Open(ipakFilename);
if(file && file->IsOpen())
{
}
}
void ObjLoaderT6::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone)
@ -48,13 +57,18 @@ void ObjLoaderT6::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone*
if(variable->namespaceHash == zoneNameHash && variable->keyHash == IPAK_READ_HASH)
{
LoadIPakForZone(variable->value, zone);
LoadIPakForZone(searchPath, variable->value, zone);
}
}
}
}
}
void ObjLoaderT6::UnloadContainersOfZone(Zone* zone)
{
IPak::Repository.RemoveContainerReferences(zone);
}
void ObjLoaderT6::LoadObjDataForZone(ISearchPath* searchPath, Zone* zone)
{
// TODO

View File

@ -1,6 +1,7 @@
#pragma once
#include "IObjLoader.h"
#include "SearchPath/ISearchPath.h"
class ObjLoaderT6 final : public IObjLoader
{
@ -8,10 +9,13 @@ class ObjLoaderT6 final : public IObjLoader
static const int GLOBAL_HASH;
static int Com_HashKey(const char* str, int maxLen);
static void LoadIPakForZone(const std::string& ipakName, Zone* zone);
static void LoadIPakForZone(ISearchPath* searchPath, const std::string& ipakName, Zone* zone);
public:
bool SupportsZone(Zone* zone) override;
void LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) override;
void UnloadContainersOfZone(Zone* zone) override;
void LoadObjDataForZone(ISearchPath* searchPath, Zone* zone) override;
};