mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-25 13:51:58 +00:00
Merge pull request #459 from Laupetin/refactor/x64-loading-for-all-games
refactor: x64 loading for remaining games
This commit is contained in:
@ -1205,16 +1205,16 @@ namespace
|
|||||||
LINE(MakeCustomActionCall(member->m_post_load_action.get()))
|
LINE(MakeCustomActionCall(member->m_post_load_action.get()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (member->m_type && !member->m_type->m_has_matching_cross_platform_structure && computations.IsInRuntimeBlock())
|
else if (member->m_type && !member->m_type->m_has_matching_cross_platform_structure)
|
||||||
{
|
{
|
||||||
LINEF("const auto runtimeArraySize = static_cast<size_t>({0});", MakeEvaluation(modifier.GetArrayPointerCountEvaluation()))
|
LINEF("const auto fillArraySize = static_cast<size_t>({0});", MakeEvaluation(modifier.GetArrayPointerCountEvaluation()))
|
||||||
LINEF("const auto runtimeFill = m_stream.LoadWithFill({0} * runtimeArraySize);", member->m_member->m_type_declaration->m_type->GetSize())
|
LINEF("const auto fill = m_stream.LoadWithFill({0} * fillArraySize);", member->m_member->m_type_declaration->m_type->GetSize())
|
||||||
LINE("for (auto i = 0uz; i < runtimeArraySize; i++)")
|
LINE("for (auto i = 0uz; i < fillArraySize; i++)")
|
||||||
LINE("{")
|
LINE("{")
|
||||||
m_intendation++;
|
m_intendation++;
|
||||||
LINEF("{0} = &{1}[i];", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier))
|
LINEF("{0} = &{1}[i];", MakeTypeVarName(member->m_type->m_definition), MakeMemberAccess(info, member, modifier))
|
||||||
LINEF("FillStruct_{0}(runtimeFill.AtOffset(i * {1}));",
|
LINEF("FillStruct_{0}(fill.AtOffset(i * {1}));",
|
||||||
MakeSafeTypeName(member->m_member->m_type_declaration->m_type),
|
MakeSafeTypeName(member->m_type->m_definition),
|
||||||
member->m_member->m_type_declaration->m_type->GetSize())
|
member->m_member->m_type_declaration->m_type->GetSize())
|
||||||
m_intendation--;
|
m_intendation--;
|
||||||
LINE("}")
|
LINE("}")
|
||||||
@ -1378,7 +1378,7 @@ namespace
|
|||||||
LINE(MakeCustomActionCall(member->m_post_load_action.get()))
|
LINE(MakeCustomActionCall(member->m_post_load_action.get()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (member->m_type && !member->m_type->m_has_matching_cross_platform_structure && computations.IsInRuntimeBlock())
|
else if (member->m_type && !member->m_type->m_has_matching_cross_platform_structure)
|
||||||
{
|
{
|
||||||
LINEF("{0} = {1};", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier))
|
LINEF("{0} = {1};", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier))
|
||||||
LINEF("FillStruct_{0}(m_stream.LoadWithFill({1}));",
|
LINEF("FillStruct_{0}(m_stream.LoadWithFill({1}));",
|
||||||
|
@ -34,6 +34,7 @@ using namespace IW3;
|
|||||||
|
|
||||||
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||||
: ContentLoaderBase(zone, stream),
|
: ContentLoaderBase(zone, stream),
|
||||||
|
varXAssetList(nullptr),
|
||||||
varXAsset(nullptr),
|
varXAsset(nullptr),
|
||||||
varScriptStringList(nullptr)
|
varScriptStringList(nullptr)
|
||||||
{
|
{
|
||||||
@ -41,16 +42,17 @@ ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
|||||||
|
|
||||||
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||||
{
|
{
|
||||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
assert(!atStreamStart);
|
||||||
|
|
||||||
if (atStreamStart)
|
|
||||||
m_stream.Load<ScriptStringList>(varScriptStringList);
|
|
||||||
|
|
||||||
if (varScriptStringList->strings != nullptr)
|
if (varScriptStringList->strings != nullptr)
|
||||||
{
|
{
|
||||||
assert(GetZonePointerType(varScriptStringList->strings) == ZonePointerType::FOLLOWING);
|
assert(GetZonePointerType(varScriptStringList->strings) == ZonePointerType::FOLLOWING);
|
||||||
|
|
||||||
varScriptStringList->strings = m_stream.Alloc<const char*>(alignof(const char*));
|
#ifdef ARCH_x86
|
||||||
|
varScriptStringList->strings = m_stream.Alloc<const char*>(4);
|
||||||
|
#else
|
||||||
|
varScriptStringList->strings = m_stream.AllocOutOfBlock<const char*>(4, varScriptStringList->count);
|
||||||
|
#endif
|
||||||
varXString = varScriptStringList->strings;
|
varXString = varScriptStringList->strings;
|
||||||
LoadXStringArray(true, varScriptStringList->count);
|
LoadXStringArray(true, varScriptStringList->count);
|
||||||
|
|
||||||
@ -58,8 +60,6 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
|||||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
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);
|
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,21 +125,50 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
|||||||
assert(varXAsset != nullptr);
|
assert(varXAsset != nullptr);
|
||||||
|
|
||||||
if (atStreamStart)
|
if (atStreamStart)
|
||||||
|
{
|
||||||
|
#ifdef ARCH_x86
|
||||||
m_stream.Load<XAsset>(varXAsset, count);
|
m_stream.Load<XAsset>(varXAsset, count);
|
||||||
|
#else
|
||||||
|
const auto fill = m_stream.LoadWithFill(8u * count);
|
||||||
|
|
||||||
|
for (size_t index = 0; index < count; index++)
|
||||||
|
{
|
||||||
|
fill.Fill(varXAsset[index].type, 8u * index);
|
||||||
|
fill.FillPtr(varXAsset[index].header.data, 8u * index + 4u);
|
||||||
|
m_stream.AddPointerLookup(&varXAsset[index].header.data, fill.BlockBuffer(8u * index + 4u));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t index = 0; index < count; index++)
|
for (size_t index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
LoadXAsset(false);
|
LoadXAsset(false);
|
||||||
varXAsset++;
|
varXAsset++;
|
||||||
|
|
||||||
|
#ifdef DEBUG_OFFSETS
|
||||||
|
m_stream.DebugOffsets(index);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLoader::Load()
|
void ContentLoader::Load()
|
||||||
{
|
{
|
||||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
|
||||||
|
|
||||||
XAssetList assetList{};
|
XAssetList assetList{};
|
||||||
|
varXAssetList = &assetList;
|
||||||
|
|
||||||
|
#ifdef ARCH_x86
|
||||||
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
||||||
|
#else
|
||||||
|
const auto fillAccessor = m_stream.LoadWithFill(16u);
|
||||||
|
varScriptStringList = &varXAssetList->stringList;
|
||||||
|
fillAccessor.Fill(varScriptStringList->count, 0u);
|
||||||
|
fillAccessor.FillPtr(varScriptStringList->strings, 4u);
|
||||||
|
|
||||||
|
fillAccessor.Fill(varXAssetList->assetCount, 8u);
|
||||||
|
fillAccessor.FillPtr(varXAssetList->assets, 12u);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||||
|
|
||||||
varScriptStringList = &assetList.stringList;
|
varScriptStringList = &assetList.stringList;
|
||||||
LoadScriptStringList(false);
|
LoadScriptStringList(false);
|
||||||
@ -148,7 +177,11 @@ void ContentLoader::Load()
|
|||||||
{
|
{
|
||||||
assert(GetZonePointerType(assetList.assets) == ZonePointerType::FOLLOWING);
|
assert(GetZonePointerType(assetList.assets) == ZonePointerType::FOLLOWING);
|
||||||
|
|
||||||
assetList.assets = m_stream.Alloc<XAsset>(alignof(XAsset));
|
#ifdef ARCH_x86
|
||||||
|
assetList.assets = m_stream.Alloc<XAsset>(4);
|
||||||
|
#else
|
||||||
|
assetList.assets = m_stream.AllocOutOfBlock<XAsset>(4, assetList.assetCount);
|
||||||
|
#endif
|
||||||
varXAsset = assetList.assets;
|
varXAsset = assetList.assets;
|
||||||
LoadXAssetArray(true, assetList.assetCount);
|
LoadXAssetArray(true, assetList.assetCount);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ namespace IW3
|
|||||||
void LoadXAsset(bool atStreamStart) const;
|
void LoadXAsset(bool atStreamStart) const;
|
||||||
void LoadXAssetArray(bool atStreamStart, size_t count);
|
void LoadXAssetArray(bool atStreamStart, size_t count);
|
||||||
|
|
||||||
|
XAssetList* varXAssetList;
|
||||||
XAsset* varXAsset;
|
XAsset* varXAsset;
|
||||||
ScriptStringList* varScriptStringList;
|
ScriptStringList* varScriptStringList;
|
||||||
};
|
};
|
||||||
|
@ -49,6 +49,7 @@ using namespace IW5;
|
|||||||
|
|
||||||
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||||
: ContentLoaderBase(zone, stream),
|
: ContentLoaderBase(zone, stream),
|
||||||
|
varXAssetList(nullptr),
|
||||||
varXAsset(nullptr),
|
varXAsset(nullptr),
|
||||||
varScriptStringList(nullptr)
|
varScriptStringList(nullptr)
|
||||||
{
|
{
|
||||||
@ -56,16 +57,17 @@ ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
|||||||
|
|
||||||
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||||
{
|
{
|
||||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
assert(!atStreamStart);
|
||||||
|
|
||||||
if (atStreamStart)
|
|
||||||
m_stream.Load<ScriptStringList>(varScriptStringList);
|
|
||||||
|
|
||||||
if (varScriptStringList->strings != nullptr)
|
if (varScriptStringList->strings != nullptr)
|
||||||
{
|
{
|
||||||
assert(GetZonePointerType(varScriptStringList->strings) == ZonePointerType::FOLLOWING);
|
assert(GetZonePointerType(varScriptStringList->strings) == ZonePointerType::FOLLOWING);
|
||||||
|
|
||||||
varScriptStringList->strings = m_stream.Alloc<const char*>(alignof(const char*));
|
#ifdef ARCH_x86
|
||||||
|
varScriptStringList->strings = m_stream.Alloc<const char*>(4);
|
||||||
|
#else
|
||||||
|
varScriptStringList->strings = m_stream.AllocOutOfBlock<const char*>(4, varScriptStringList->count);
|
||||||
|
#endif
|
||||||
varXString = varScriptStringList->strings;
|
varXString = varScriptStringList->strings;
|
||||||
LoadXStringArray(true, varScriptStringList->count);
|
LoadXStringArray(true, varScriptStringList->count);
|
||||||
|
|
||||||
@ -73,8 +75,6 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
|||||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
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);
|
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,21 +154,50 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
|||||||
assert(count == 0 || varXAsset != nullptr);
|
assert(count == 0 || varXAsset != nullptr);
|
||||||
|
|
||||||
if (atStreamStart)
|
if (atStreamStart)
|
||||||
|
{
|
||||||
|
#ifdef ARCH_x86
|
||||||
m_stream.Load<XAsset>(varXAsset, count);
|
m_stream.Load<XAsset>(varXAsset, count);
|
||||||
|
#else
|
||||||
|
const auto fill = m_stream.LoadWithFill(8u * count);
|
||||||
|
|
||||||
|
for (size_t index = 0; index < count; index++)
|
||||||
|
{
|
||||||
|
fill.Fill(varXAsset[index].type, 8u * index);
|
||||||
|
fill.FillPtr(varXAsset[index].header.data, 8u * index + 4u);
|
||||||
|
m_stream.AddPointerLookup(&varXAsset[index].header.data, fill.BlockBuffer(8u * index + 4u));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t index = 0; index < count; index++)
|
for (size_t index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
LoadXAsset(false);
|
LoadXAsset(false);
|
||||||
varXAsset++;
|
varXAsset++;
|
||||||
|
|
||||||
|
#ifdef DEBUG_OFFSETS
|
||||||
|
m_stream.DebugOffsets(index);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLoader::Load()
|
void ContentLoader::Load()
|
||||||
{
|
{
|
||||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
|
||||||
|
|
||||||
XAssetList assetList{};
|
XAssetList assetList{};
|
||||||
|
varXAssetList = &assetList;
|
||||||
|
|
||||||
|
#ifdef ARCH_x86
|
||||||
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
||||||
|
#else
|
||||||
|
const auto fillAccessor = m_stream.LoadWithFill(16u);
|
||||||
|
varScriptStringList = &varXAssetList->stringList;
|
||||||
|
fillAccessor.Fill(varScriptStringList->count, 0u);
|
||||||
|
fillAccessor.FillPtr(varScriptStringList->strings, 4u);
|
||||||
|
|
||||||
|
fillAccessor.Fill(varXAssetList->assetCount, 8u);
|
||||||
|
fillAccessor.FillPtr(varXAssetList->assets, 12u);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||||
|
|
||||||
varScriptStringList = &assetList.stringList;
|
varScriptStringList = &assetList.stringList;
|
||||||
LoadScriptStringList(false);
|
LoadScriptStringList(false);
|
||||||
@ -177,7 +206,11 @@ void ContentLoader::Load()
|
|||||||
{
|
{
|
||||||
assert(GetZonePointerType(assetList.assets) == ZonePointerType::FOLLOWING);
|
assert(GetZonePointerType(assetList.assets) == ZonePointerType::FOLLOWING);
|
||||||
|
|
||||||
assetList.assets = m_stream.Alloc<XAsset>(alignof(XAsset));
|
#ifdef ARCH_x86
|
||||||
|
assetList.assets = m_stream.Alloc<XAsset>(4);
|
||||||
|
#else
|
||||||
|
assetList.assets = m_stream.AllocOutOfBlock<XAsset>(4, assetList.assetCount);
|
||||||
|
#endif
|
||||||
varXAsset = assetList.assets;
|
varXAsset = assetList.assets;
|
||||||
LoadXAssetArray(true, assetList.assetCount);
|
LoadXAssetArray(true, assetList.assetCount);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ namespace IW5
|
|||||||
void LoadXAsset(bool atStreamStart) const;
|
void LoadXAsset(bool atStreamStart) const;
|
||||||
void LoadXAssetArray(bool atStreamStart, size_t count);
|
void LoadXAssetArray(bool atStreamStart, size_t count);
|
||||||
|
|
||||||
|
XAssetList* varXAssetList;
|
||||||
XAsset* varXAsset;
|
XAsset* varXAsset;
|
||||||
ScriptStringList* varScriptStringList;
|
ScriptStringList* varScriptStringList;
|
||||||
};
|
};
|
||||||
|
@ -41,6 +41,7 @@ using namespace T5;
|
|||||||
|
|
||||||
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||||
: ContentLoaderBase(zone, stream),
|
: ContentLoaderBase(zone, stream),
|
||||||
|
varXAssetList(nullptr),
|
||||||
varXAsset(nullptr),
|
varXAsset(nullptr),
|
||||||
varScriptStringList(nullptr)
|
varScriptStringList(nullptr)
|
||||||
{
|
{
|
||||||
@ -48,16 +49,17 @@ ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
|||||||
|
|
||||||
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||||
{
|
{
|
||||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
assert(!atStreamStart);
|
||||||
|
|
||||||
if (atStreamStart)
|
|
||||||
m_stream.Load<ScriptStringList>(varScriptStringList);
|
|
||||||
|
|
||||||
if (varScriptStringList->strings != nullptr)
|
if (varScriptStringList->strings != nullptr)
|
||||||
{
|
{
|
||||||
assert(GetZonePointerType(varScriptStringList->strings) == ZonePointerType::FOLLOWING);
|
assert(GetZonePointerType(varScriptStringList->strings) == ZonePointerType::FOLLOWING);
|
||||||
|
|
||||||
varScriptStringList->strings = m_stream.Alloc<const char*>(alignof(const char*));
|
#ifdef ARCH_x86
|
||||||
|
varScriptStringList->strings = m_stream.Alloc<const char*>(4);
|
||||||
|
#else
|
||||||
|
varScriptStringList->strings = m_stream.AllocOutOfBlock<const char*>(4, varScriptStringList->count);
|
||||||
|
#endif
|
||||||
varXString = varScriptStringList->strings;
|
varXString = varScriptStringList->strings;
|
||||||
LoadXStringArray(true, varScriptStringList->count);
|
LoadXStringArray(true, varScriptStringList->count);
|
||||||
|
|
||||||
@ -65,8 +67,6 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
|||||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
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);
|
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,21 +138,50 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
|||||||
assert(varXAsset != nullptr);
|
assert(varXAsset != nullptr);
|
||||||
|
|
||||||
if (atStreamStart)
|
if (atStreamStart)
|
||||||
|
{
|
||||||
|
#ifdef ARCH_x86
|
||||||
m_stream.Load<XAsset>(varXAsset, count);
|
m_stream.Load<XAsset>(varXAsset, count);
|
||||||
|
#else
|
||||||
|
const auto fill = m_stream.LoadWithFill(8u * count);
|
||||||
|
|
||||||
|
for (size_t index = 0; index < count; index++)
|
||||||
|
{
|
||||||
|
fill.Fill(varXAsset[index].type, 8u * index);
|
||||||
|
fill.FillPtr(varXAsset[index].header.data, 8u * index + 4u);
|
||||||
|
m_stream.AddPointerLookup(&varXAsset[index].header.data, fill.BlockBuffer(8u * index + 4u));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t index = 0; index < count; index++)
|
for (size_t index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
LoadXAsset(false);
|
LoadXAsset(false);
|
||||||
varXAsset++;
|
varXAsset++;
|
||||||
|
|
||||||
|
#ifdef DEBUG_OFFSETS
|
||||||
|
m_stream.DebugOffsets(index);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLoader::Load()
|
void ContentLoader::Load()
|
||||||
{
|
{
|
||||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
|
||||||
|
|
||||||
XAssetList assetList{};
|
XAssetList assetList{};
|
||||||
|
varXAssetList = &assetList;
|
||||||
|
|
||||||
|
#ifdef ARCH_x86
|
||||||
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
||||||
|
#else
|
||||||
|
const auto fillAccessor = m_stream.LoadWithFill(16u);
|
||||||
|
varScriptStringList = &varXAssetList->stringList;
|
||||||
|
fillAccessor.Fill(varScriptStringList->count, 0u);
|
||||||
|
fillAccessor.FillPtr(varScriptStringList->strings, 4u);
|
||||||
|
|
||||||
|
fillAccessor.Fill(varXAssetList->assetCount, 8u);
|
||||||
|
fillAccessor.FillPtr(varXAssetList->assets, 12u);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||||
|
|
||||||
varScriptStringList = &assetList.stringList;
|
varScriptStringList = &assetList.stringList;
|
||||||
LoadScriptStringList(false);
|
LoadScriptStringList(false);
|
||||||
@ -161,7 +190,11 @@ void ContentLoader::Load()
|
|||||||
{
|
{
|
||||||
assert(GetZonePointerType(assetList.assets) == ZonePointerType::FOLLOWING);
|
assert(GetZonePointerType(assetList.assets) == ZonePointerType::FOLLOWING);
|
||||||
|
|
||||||
assetList.assets = m_stream.Alloc<XAsset>(alignof(XAsset));
|
#ifdef ARCH_x86
|
||||||
|
assetList.assets = m_stream.Alloc<XAsset>(4);
|
||||||
|
#else
|
||||||
|
assetList.assets = m_stream.AllocOutOfBlock<XAsset>(4, assetList.assetCount);
|
||||||
|
#endif
|
||||||
varXAsset = assetList.assets;
|
varXAsset = assetList.assets;
|
||||||
LoadXAssetArray(true, assetList.assetCount);
|
LoadXAssetArray(true, assetList.assetCount);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ namespace T5
|
|||||||
void LoadXAsset(bool atStreamStart) const;
|
void LoadXAsset(bool atStreamStart) const;
|
||||||
void LoadXAssetArray(bool atStreamStart, size_t count);
|
void LoadXAssetArray(bool atStreamStart, size_t count);
|
||||||
|
|
||||||
|
XAssetList* varXAssetList;
|
||||||
XAsset* varXAsset;
|
XAsset* varXAsset;
|
||||||
ScriptStringList* varScriptStringList;
|
ScriptStringList* varScriptStringList;
|
||||||
};
|
};
|
||||||
|
@ -57,6 +57,7 @@ using namespace T6;
|
|||||||
|
|
||||||
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||||
: ContentLoaderBase(zone, stream),
|
: ContentLoaderBase(zone, stream),
|
||||||
|
varXAssetList(nullptr),
|
||||||
varXAsset(nullptr),
|
varXAsset(nullptr),
|
||||||
varScriptStringList(nullptr)
|
varScriptStringList(nullptr)
|
||||||
{
|
{
|
||||||
@ -64,16 +65,17 @@ ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
|||||||
|
|
||||||
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||||
{
|
{
|
||||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
assert(!atStreamStart);
|
||||||
|
|
||||||
if (atStreamStart)
|
|
||||||
m_stream.Load<ScriptStringList>(varScriptStringList);
|
|
||||||
|
|
||||||
if (varScriptStringList->strings != nullptr)
|
if (varScriptStringList->strings != nullptr)
|
||||||
{
|
{
|
||||||
assert(GetZonePointerType(varScriptStringList->strings) == ZonePointerType::FOLLOWING);
|
assert(GetZonePointerType(varScriptStringList->strings) == ZonePointerType::FOLLOWING);
|
||||||
|
|
||||||
varScriptStringList->strings = m_stream.Alloc<const char*>(alignof(const char*));
|
#ifdef ARCH_x86
|
||||||
|
varScriptStringList->strings = m_stream.Alloc<const char*>(4);
|
||||||
|
#else
|
||||||
|
varScriptStringList->strings = m_stream.AllocOutOfBlock<const char*>(4, varScriptStringList->count);
|
||||||
|
#endif
|
||||||
varXString = varScriptStringList->strings;
|
varXString = varScriptStringList->strings;
|
||||||
LoadXStringArray(true, varScriptStringList->count);
|
LoadXStringArray(true, varScriptStringList->count);
|
||||||
|
|
||||||
@ -81,8 +83,6 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
|||||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
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);
|
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,21 +167,52 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
|||||||
assert(varXAsset != nullptr);
|
assert(varXAsset != nullptr);
|
||||||
|
|
||||||
if (atStreamStart)
|
if (atStreamStart)
|
||||||
|
{
|
||||||
|
#ifdef ARCH_x86
|
||||||
m_stream.Load<XAsset>(varXAsset, count);
|
m_stream.Load<XAsset>(varXAsset, count);
|
||||||
|
#else
|
||||||
|
const auto fill = m_stream.LoadWithFill(8u * count);
|
||||||
|
|
||||||
|
for (size_t index = 0; index < count; index++)
|
||||||
|
{
|
||||||
|
fill.Fill(varXAsset[index].type, 8u * index);
|
||||||
|
fill.FillPtr(varXAsset[index].header.data, 8u * index + 4u);
|
||||||
|
m_stream.AddPointerLookup(&varXAsset[index].header.data, fill.BlockBuffer(8u * index + 4u));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t index = 0; index < count; index++)
|
for (size_t index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
LoadXAsset(false);
|
LoadXAsset(false);
|
||||||
varXAsset++;
|
varXAsset++;
|
||||||
|
|
||||||
|
#ifdef DEBUG_OFFSETS
|
||||||
|
m_stream.DebugOffsets(index);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLoader::Load()
|
void ContentLoader::Load()
|
||||||
{
|
{
|
||||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
|
||||||
|
|
||||||
XAssetList assetList{};
|
XAssetList assetList{};
|
||||||
|
varXAssetList = &assetList;
|
||||||
|
|
||||||
|
#ifdef ARCH_x86
|
||||||
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
||||||
|
#else
|
||||||
|
const auto fillAccessor = m_stream.LoadWithFill(24u);
|
||||||
|
varScriptStringList = &varXAssetList->stringList;
|
||||||
|
fillAccessor.Fill(varScriptStringList->count, 0u);
|
||||||
|
fillAccessor.FillPtr(varScriptStringList->strings, 4u);
|
||||||
|
|
||||||
|
fillAccessor.Fill(varXAssetList->dependCount, 8u);
|
||||||
|
fillAccessor.FillPtr(varXAssetList->depends, 12u);
|
||||||
|
fillAccessor.Fill(varXAssetList->assetCount, 16u);
|
||||||
|
fillAccessor.FillPtr(varXAssetList->assets, 20u);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||||
|
|
||||||
varScriptStringList = &assetList.stringList;
|
varScriptStringList = &assetList.stringList;
|
||||||
LoadScriptStringList(false);
|
LoadScriptStringList(false);
|
||||||
@ -190,7 +221,11 @@ void ContentLoader::Load()
|
|||||||
{
|
{
|
||||||
assert(GetZonePointerType(assetList.depends) == ZonePointerType::FOLLOWING);
|
assert(GetZonePointerType(assetList.depends) == ZonePointerType::FOLLOWING);
|
||||||
|
|
||||||
assetList.depends = m_stream.Alloc<const char*>(alignof(const char*));
|
#ifdef ARCH_x86
|
||||||
|
assetList.depends = m_stream.Alloc<const char*>(4);
|
||||||
|
#else
|
||||||
|
assetList.depends = m_stream.AllocOutOfBlock<const char*>(4, assetList.dependCount);
|
||||||
|
#endif
|
||||||
varXString = assetList.depends;
|
varXString = assetList.depends;
|
||||||
LoadXStringArray(true, assetList.dependCount);
|
LoadXStringArray(true, assetList.dependCount);
|
||||||
}
|
}
|
||||||
@ -199,7 +234,11 @@ void ContentLoader::Load()
|
|||||||
{
|
{
|
||||||
assert(GetZonePointerType(assetList.assets) == ZonePointerType::FOLLOWING);
|
assert(GetZonePointerType(assetList.assets) == ZonePointerType::FOLLOWING);
|
||||||
|
|
||||||
assetList.assets = m_stream.Alloc<XAsset>(alignof(XAsset));
|
#ifdef ARCH_x86
|
||||||
|
assetList.assets = m_stream.Alloc<XAsset>(4);
|
||||||
|
#else
|
||||||
|
assetList.assets = m_stream.AllocOutOfBlock<XAsset>(4, assetList.assetCount);
|
||||||
|
#endif
|
||||||
varXAsset = assetList.assets;
|
varXAsset = assetList.assets;
|
||||||
LoadXAssetArray(true, assetList.assetCount);
|
LoadXAssetArray(true, assetList.assetCount);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ namespace T6
|
|||||||
void LoadXAsset(bool atStreamStart) const;
|
void LoadXAsset(bool atStreamStart) const;
|
||||||
void LoadXAssetArray(bool atStreamStart, size_t count);
|
void LoadXAssetArray(bool atStreamStart, size_t count);
|
||||||
|
|
||||||
|
XAssetList* varXAssetList;
|
||||||
XAsset* varXAsset;
|
XAsset* varXAsset;
|
||||||
ScriptStringList* varScriptStringList;
|
ScriptStringList* varScriptStringList;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user