mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-26 06:11:53 +00:00
chore: implement base skeleton for architecture independent zone loading
This commit is contained in:
@ -32,8 +32,8 @@
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
ContentLoader::ContentLoader(Zone& zone)
|
||||
: ContentLoaderBase(zone),
|
||||
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||
: ContentLoaderBase(zone, stream),
|
||||
varXAsset(nullptr),
|
||||
varScriptStringList(nullptr)
|
||||
{
|
||||
@ -134,10 +134,8 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::Load(ZoneInputStream& stream)
|
||||
void ContentLoader::Load()
|
||||
{
|
||||
m_stream = &stream;
|
||||
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
XAssetList assetList{};
|
||||
|
@ -9,9 +9,8 @@ namespace IW3
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
public:
|
||||
explicit ContentLoader(Zone& zone);
|
||||
|
||||
void Load(ZoneInputStream& stream) override;
|
||||
ContentLoader(Zone& zone, ZoneInputStream& stream);
|
||||
void Load() override;
|
||||
|
||||
private:
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
@ -85,8 +85,14 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
|
||||
zoneLoader->AddLoadingStep(step::CreateStepAllocXBlocks());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(
|
||||
step::CreateStepLoadZoneContent(std::make_unique<ContentLoader>(*zonePtr), ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(step::CreateStepLoadZoneContent(
|
||||
[&zonePtr](ZoneInputStream& stream)
|
||||
{
|
||||
return std::make_unique<ContentLoader>(*zonePtr, stream);
|
||||
},
|
||||
32u,
|
||||
ZoneConstants::OFFSET_BLOCK_BIT_COUNT,
|
||||
ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
return zoneLoader;
|
||||
}
|
||||
|
@ -42,25 +42,38 @@
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
ContentLoader::ContentLoader(Zone& zone)
|
||||
: ContentLoaderBase(zone),
|
||||
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||
: ContentLoaderBase(zone, stream),
|
||||
varXAssetList(nullptr),
|
||||
varXAsset(nullptr),
|
||||
varScriptStringList(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void ContentLoader::FillStruct_XAssetList(const ZoneStreamFillReadAccessor& fillAccessor)
|
||||
{
|
||||
varScriptStringList = &varXAssetList->stringList;
|
||||
FillStruct_ScriptStringList(fillAccessor.AtOffset(0u));
|
||||
|
||||
fillAccessor.Fill(varXAssetList->assetCount, 8u);
|
||||
fillAccessor.FillPtr(varXAssetList->assets, 12u);
|
||||
}
|
||||
|
||||
void ContentLoader::FillStruct_ScriptStringList(const ZoneStreamFillReadAccessor& fillAccessor) const
|
||||
{
|
||||
fillAccessor.Fill(varScriptStringList->count, 0u);
|
||||
fillAccessor.FillPtr(varScriptStringList->strings, 4u);
|
||||
}
|
||||
|
||||
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
{
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<ScriptStringList>(varScriptStringList);
|
||||
assert(!atStreamStart);
|
||||
|
||||
if (varScriptStringList->strings != nullptr)
|
||||
{
|
||||
assert(varScriptStringList->strings == PTR_FOLLOWING);
|
||||
|
||||
varScriptStringList->strings = m_stream->Alloc<const char*>(alignof(const char*));
|
||||
varScriptStringList->strings = m_stream->Alloc<const char*>(4);
|
||||
varXString = varScriptStringList->strings;
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
@ -68,8 +81,6 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
|
||||
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
}
|
||||
|
||||
@ -154,15 +165,15 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::Load(ZoneInputStream& stream)
|
||||
void ContentLoader::Load()
|
||||
{
|
||||
m_stream = &stream;
|
||||
XAssetList assetList{};
|
||||
varXAssetList = &assetList;
|
||||
|
||||
FillStruct_XAssetList(m_stream->LoadWithFill(16u));
|
||||
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
XAssetList assetList{};
|
||||
m_stream->LoadDataRaw(&assetList, sizeof(assetList));
|
||||
|
||||
varScriptStringList = &assetList.stringList;
|
||||
LoadScriptStringList(false);
|
||||
|
||||
|
@ -9,16 +9,19 @@ namespace IW4
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
public:
|
||||
explicit ContentLoader(Zone& zone);
|
||||
|
||||
void Load(ZoneInputStream& stream) override;
|
||||
explicit ContentLoader(Zone& zone, ZoneInputStream& stream);
|
||||
void Load() override;
|
||||
|
||||
private:
|
||||
void FillStruct_XAssetList(const ZoneStreamFillReadAccessor& fillAccessor);
|
||||
void FillStruct_ScriptStringList(const ZoneStreamFillReadAccessor& fillAccessor) const;
|
||||
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
||||
void LoadXAsset(bool atStreamStart) const;
|
||||
void LoadXAssetArray(bool atStreamStart, size_t count);
|
||||
|
||||
XAssetList* varXAssetList;
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
};
|
||||
|
@ -207,8 +207,14 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
|
||||
zoneLoader->AddLoadingStep(step::CreateStepAllocXBlocks());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(
|
||||
step::CreateStepLoadZoneContent(std::make_unique<ContentLoader>(*zonePtr), ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(step::CreateStepLoadZoneContent(
|
||||
[&zonePtr](ZoneInputStream& stream)
|
||||
{
|
||||
return std::make_unique<ContentLoader>(*zonePtr, stream);
|
||||
},
|
||||
32u,
|
||||
ZoneConstants::OFFSET_BLOCK_BIT_COUNT,
|
||||
ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
return zoneLoader;
|
||||
}
|
||||
|
@ -47,8 +47,8 @@
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
ContentLoader::ContentLoader(Zone& zone)
|
||||
: ContentLoaderBase(zone),
|
||||
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||
: ContentLoaderBase(zone, stream),
|
||||
varXAsset(nullptr),
|
||||
varScriptStringList(nullptr)
|
||||
{
|
||||
@ -163,10 +163,8 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::Load(ZoneInputStream& stream)
|
||||
void ContentLoader::Load()
|
||||
{
|
||||
m_stream = &stream;
|
||||
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
XAssetList assetList{};
|
||||
|
@ -9,9 +9,8 @@ namespace IW5
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
public:
|
||||
explicit ContentLoader(Zone& zone);
|
||||
|
||||
void Load(ZoneInputStream& stream) override;
|
||||
explicit ContentLoader(Zone& zone, ZoneInputStream& stream);
|
||||
void Load() override;
|
||||
|
||||
private:
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
@ -184,8 +184,14 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
|
||||
zoneLoader->AddLoadingStep(step::CreateStepAllocXBlocks());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(
|
||||
step::CreateStepLoadZoneContent(std::make_unique<ContentLoader>(*zonePtr), ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(step::CreateStepLoadZoneContent(
|
||||
[&zonePtr](ZoneInputStream& stream)
|
||||
{
|
||||
return std::make_unique<ContentLoader>(*zonePtr, stream);
|
||||
},
|
||||
32u,
|
||||
ZoneConstants::OFFSET_BLOCK_BIT_COUNT,
|
||||
ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
return zoneLoader;
|
||||
}
|
||||
|
@ -39,8 +39,8 @@
|
||||
|
||||
using namespace T5;
|
||||
|
||||
ContentLoader::ContentLoader(Zone& zone)
|
||||
: ContentLoaderBase(zone),
|
||||
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||
: ContentLoaderBase(zone, stream),
|
||||
varXAsset(nullptr),
|
||||
varScriptStringList(nullptr)
|
||||
{
|
||||
@ -147,10 +147,8 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::Load(ZoneInputStream& stream)
|
||||
void ContentLoader::Load()
|
||||
{
|
||||
m_stream = &stream;
|
||||
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
XAssetList assetList{};
|
||||
|
@ -9,9 +9,8 @@ namespace T5
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
public:
|
||||
explicit ContentLoader(Zone& zone);
|
||||
|
||||
void Load(ZoneInputStream& stream) override;
|
||||
explicit ContentLoader(Zone& zone, ZoneInputStream& stream);
|
||||
void Load() override;
|
||||
|
||||
private:
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
@ -85,8 +85,14 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
|
||||
zoneLoader->AddLoadingStep(step::CreateStepAllocXBlocks());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(
|
||||
step::CreateStepLoadZoneContent(std::make_unique<ContentLoader>(*zonePtr), ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(step::CreateStepLoadZoneContent(
|
||||
[&zonePtr](ZoneInputStream& stream)
|
||||
{
|
||||
return std::make_unique<ContentLoader>(*zonePtr, stream);
|
||||
},
|
||||
32u,
|
||||
ZoneConstants::OFFSET_BLOCK_BIT_COUNT,
|
||||
ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
return zoneLoader;
|
||||
}
|
||||
|
@ -55,8 +55,8 @@
|
||||
|
||||
using namespace T6;
|
||||
|
||||
ContentLoader::ContentLoader(Zone& zone)
|
||||
: ContentLoaderBase(zone),
|
||||
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||
: ContentLoaderBase(zone, stream),
|
||||
varXAsset(nullptr),
|
||||
varScriptStringList(nullptr)
|
||||
{
|
||||
@ -176,10 +176,8 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::Load(ZoneInputStream& stream)
|
||||
void ContentLoader::Load()
|
||||
{
|
||||
m_stream = &stream;
|
||||
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
XAssetList assetList{};
|
||||
|
@ -9,9 +9,8 @@ namespace T6
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
public:
|
||||
explicit ContentLoader(Zone& zone);
|
||||
|
||||
void Load(ZoneInputStream& stream) override;
|
||||
explicit ContentLoader(Zone& zone, ZoneInputStream& stream);
|
||||
void Load() override;
|
||||
|
||||
private:
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
@ -203,8 +203,14 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
|
||||
zoneLoader->AddLoadingStep(step::CreateStepAllocXBlocks());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(
|
||||
step::CreateStepLoadZoneContent(std::make_unique<ContentLoader>(*zonePtr), ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(step::CreateStepLoadZoneContent(
|
||||
[&zonePtr](ZoneInputStream& stream)
|
||||
{
|
||||
return std::make_unique<ContentLoader>(*zonePtr, stream);
|
||||
},
|
||||
32u,
|
||||
ZoneConstants::OFFSET_BLOCK_BIT_COUNT,
|
||||
ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
if (isSecure)
|
||||
{
|
||||
|
Reference in New Issue
Block a user