mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-07-04 06:39:58 +00:00
refactor: make ZoneInputStream a reference in zone loading
This commit is contained in:
@@ -41,16 +41,16 @@ ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||
|
||||
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
{
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<ScriptStringList>(varScriptStringList);
|
||||
m_stream.Load<ScriptStringList>(varScriptStringList);
|
||||
|
||||
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*>(alignof(const char*));
|
||||
varXString = varScriptStringList->strings;
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
@@ -58,7 +58,7 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
m_stream.PopBlock();
|
||||
|
||||
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, *m_stream); \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
@@ -79,7 +79,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset);
|
||||
m_stream.Load<XAsset>(varXAsset);
|
||||
|
||||
switch (varXAsset->type)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset, count);
|
||||
m_stream.Load<XAsset>(varXAsset, count);
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
@@ -136,10 +136,10 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
|
||||
void ContentLoader::Load()
|
||||
{
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
XAssetList assetList{};
|
||||
m_stream->LoadDataRaw(&assetList, sizeof(assetList));
|
||||
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
||||
|
||||
varScriptStringList = &assetList.stringList;
|
||||
LoadScriptStringList(false);
|
||||
@@ -148,10 +148,10 @@ void ContentLoader::Load()
|
||||
{
|
||||
assert(assetList.assets == PTR_FOLLOWING);
|
||||
|
||||
assetList.assets = m_stream->Alloc<XAsset>(alignof(XAsset));
|
||||
assetList.assets = m_stream.Alloc<XAsset>(alignof(XAsset));
|
||||
varXAsset = assetList.assets;
|
||||
LoadXAssetArray(true, assetList.assetCount);
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
m_stream.PopBlock();
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
{
|
||||
assert(varScriptStringList->strings == PTR_FOLLOWING);
|
||||
|
||||
varScriptStringList->strings = m_stream->Alloc<const char*>(4);
|
||||
varScriptStringList->strings = m_stream.Alloc<const char*>(4);
|
||||
varXString = varScriptStringList->strings;
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
@@ -89,7 +89,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, *m_stream); \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
@@ -100,7 +100,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset);
|
||||
m_stream.Load<XAsset>(varXAsset);
|
||||
|
||||
switch (varXAsset->type)
|
||||
{
|
||||
@@ -156,7 +156,7 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset, count);
|
||||
m_stream.Load<XAsset>(varXAsset, count);
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
@@ -170,9 +170,9 @@ void ContentLoader::Load()
|
||||
XAssetList assetList{};
|
||||
varXAssetList = &assetList;
|
||||
|
||||
FillStruct_XAssetList(m_stream->LoadWithFill(16u));
|
||||
FillStruct_XAssetList(m_stream.LoadWithFill(16u));
|
||||
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
varScriptStringList = &assetList.stringList;
|
||||
LoadScriptStringList(false);
|
||||
@@ -181,10 +181,10 @@ void ContentLoader::Load()
|
||||
{
|
||||
assert(assetList.assets == PTR_FOLLOWING);
|
||||
|
||||
assetList.assets = m_stream->Alloc<XAsset>(alignof(XAsset));
|
||||
assetList.assets = m_stream.Alloc<XAsset>(alignof(XAsset));
|
||||
varXAsset = assetList.assets;
|
||||
LoadXAssetArray(true, assetList.assetCount);
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
m_stream.PopBlock();
|
||||
}
|
||||
|
||||
@@ -56,16 +56,16 @@ ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||
|
||||
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
{
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<ScriptStringList>(varScriptStringList);
|
||||
m_stream.Load<ScriptStringList>(varScriptStringList);
|
||||
|
||||
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*>(alignof(const char*));
|
||||
varXString = varScriptStringList->strings;
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
@@ -73,7 +73,7 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
m_stream.PopBlock();
|
||||
|
||||
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, *m_stream); \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
@@ -94,7 +94,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset);
|
||||
m_stream.Load<XAsset>(varXAsset);
|
||||
|
||||
switch (varXAsset->type)
|
||||
{
|
||||
@@ -154,7 +154,7 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
assert(count == 0 || varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset, count);
|
||||
m_stream.Load<XAsset>(varXAsset, count);
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
@@ -165,10 +165,10 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
|
||||
void ContentLoader::Load()
|
||||
{
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
XAssetList assetList{};
|
||||
m_stream->LoadDataRaw(&assetList, sizeof(assetList));
|
||||
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
||||
|
||||
varScriptStringList = &assetList.stringList;
|
||||
LoadScriptStringList(false);
|
||||
@@ -177,10 +177,10 @@ void ContentLoader::Load()
|
||||
{
|
||||
assert(assetList.assets == PTR_FOLLOWING);
|
||||
|
||||
assetList.assets = m_stream->Alloc<XAsset>(alignof(XAsset));
|
||||
assetList.assets = m_stream.Alloc<XAsset>(alignof(XAsset));
|
||||
varXAsset = assetList.assets;
|
||||
LoadXAssetArray(true, assetList.assetCount);
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
m_stream.PopBlock();
|
||||
}
|
||||
|
||||
@@ -48,16 +48,16 @@ ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||
|
||||
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
{
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<ScriptStringList>(varScriptStringList);
|
||||
m_stream.Load<ScriptStringList>(varScriptStringList);
|
||||
|
||||
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*>(alignof(const char*));
|
||||
varXString = varScriptStringList->strings;
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
@@ -65,7 +65,7 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
m_stream.PopBlock();
|
||||
|
||||
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, *m_stream); \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
@@ -86,7 +86,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset);
|
||||
m_stream.Load<XAsset>(varXAsset);
|
||||
|
||||
switch (varXAsset->type)
|
||||
{
|
||||
@@ -138,7 +138,7 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset, count);
|
||||
m_stream.Load<XAsset>(varXAsset, count);
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
@@ -149,10 +149,10 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
|
||||
void ContentLoader::Load()
|
||||
{
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
XAssetList assetList{};
|
||||
m_stream->LoadDataRaw(&assetList, sizeof(assetList));
|
||||
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
||||
|
||||
varScriptStringList = &assetList.stringList;
|
||||
LoadScriptStringList(false);
|
||||
@@ -161,10 +161,10 @@ void ContentLoader::Load()
|
||||
{
|
||||
assert(assetList.assets == PTR_FOLLOWING);
|
||||
|
||||
assetList.assets = m_stream->Alloc<XAsset>(alignof(XAsset));
|
||||
assetList.assets = m_stream.Alloc<XAsset>(alignof(XAsset));
|
||||
varXAsset = assetList.assets;
|
||||
LoadXAssetArray(true, assetList.assetCount);
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
m_stream.PopBlock();
|
||||
}
|
||||
|
||||
@@ -64,16 +64,16 @@ ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||
|
||||
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
{
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<ScriptStringList>(varScriptStringList);
|
||||
m_stream.Load<ScriptStringList>(varScriptStringList);
|
||||
|
||||
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*>(alignof(const char*));
|
||||
varXString = varScriptStringList->strings;
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
@@ -81,7 +81,7 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
m_stream.PopBlock();
|
||||
|
||||
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, *m_stream); \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
@@ -99,7 +99,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset);
|
||||
m_stream.Load<XAsset>(varXAsset);
|
||||
|
||||
switch (varXAsset->type)
|
||||
{
|
||||
@@ -167,7 +167,7 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset, count);
|
||||
m_stream.Load<XAsset>(varXAsset, count);
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
@@ -178,10 +178,10 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
|
||||
void ContentLoader::Load()
|
||||
{
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
XAssetList assetList{};
|
||||
m_stream->LoadDataRaw(&assetList, sizeof(assetList));
|
||||
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
||||
|
||||
varScriptStringList = &assetList.stringList;
|
||||
LoadScriptStringList(false);
|
||||
@@ -190,7 +190,7 @@ void ContentLoader::Load()
|
||||
{
|
||||
assert(assetList.depends == PTR_FOLLOWING);
|
||||
|
||||
assetList.depends = m_stream->Alloc<const char*>(alignof(const char*));
|
||||
assetList.depends = m_stream.Alloc<const char*>(alignof(const char*));
|
||||
varXString = assetList.depends;
|
||||
LoadXStringArray(true, assetList.dependCount);
|
||||
}
|
||||
@@ -199,10 +199,10 @@ void ContentLoader::Load()
|
||||
{
|
||||
assert(assetList.assets == PTR_FOLLOWING);
|
||||
|
||||
assetList.assets = m_stream->Alloc<XAsset>(alignof(XAsset));
|
||||
assetList.assets = m_stream.Alloc<XAsset>(alignof(XAsset));
|
||||
varXAsset = assetList.assets;
|
||||
LoadXAssetArray(true, assetList.assetCount);
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
m_stream.PopBlock();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user