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

@ -3,10 +3,13 @@
#include "Exception/IPakLoadException.h"
#include <sstream>
#include "Utils/PathUtils.h"
const uint32_t IPak::MAGIC = 'IPAK';
const uint32_t IPak::VERSION = 0x50000;
ObjContainerRepository<IPak, Zone> IPak::Repository;
uint32_t IPak::R_HashString(const char* str, uint32_t hash)
{
for (const char* pos = str; *pos; pos++)
@ -17,8 +20,9 @@ uint32_t IPak::R_HashString(const char* str, uint32_t hash)
return hash;
}
IPak::IPak(FileAPI::IFile* file)
IPak::IPak(std::string path, FileAPI::IFile* file)
{
m_path = std::move(path);
m_file = file;
m_initialized = false;
m_index_section = nullptr;
@ -34,6 +38,11 @@ IPak::~IPak()
m_data_section = nullptr;
}
std::string IPak::GetName()
{
return utils::Path::GetFilename(m_path);
}
void IPak::ReadSection()
{
IPakSection section{};

View File

@ -3,6 +3,8 @@
#include "Utils/FileAPI.h"
#include "ObjContainer/IPak/IPakTypes.h"
#include "ObjContainer/ObjContainerReferenceable.h"
#include "ObjContainer/ObjContainerRepository.h"
#include "Zone/Zone.h"
#include <vector>
@ -11,6 +13,7 @@ class IPak final : public ObjContainerReferenceable
static const uint32_t MAGIC;
static const uint32_t VERSION;
std::string m_path;
FileAPI::IFile* m_file;
bool m_initialized;
@ -26,9 +29,13 @@ class IPak final : public ObjContainerReferenceable
void ReadHeader();
public:
explicit IPak(FileAPI::IFile* file);
static ObjContainerRepository<IPak, Zone> Repository;
IPak(std::string path, FileAPI::IFile* file);
~IPak();
std::string GetName() override;
void Initialize();
FileAPI::IFile* GetEntryData(IPakHash nameHash, IPakHash dataHash);