refactor: make ZoneInputStream a reference in zone loading

This commit is contained in:
Jan
2025-05-03 16:29:36 +01:00
parent f6d7831e6e
commit 78d8fba6f8
8 changed files with 92 additions and 92 deletions

View File

@ -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();
}