mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
chore: implement base skeleton for architecture independent zone loading
This commit is contained in:
@ -18,8 +18,9 @@ RenderingUsedType::RenderingUsedType(const DataDefinition* type, StructureInform
|
||||
{
|
||||
}
|
||||
|
||||
RenderingContext::RenderingContext(std::string game, std::vector<const FastFileBlock*> fastFileBlocks)
|
||||
RenderingContext::RenderingContext(std::string game, const Architecture gameArchitecture, std::vector<const FastFileBlock*> fastFileBlocks)
|
||||
: m_game(std::move(game)),
|
||||
m_architecture_mismatch(gameArchitecture != OWN_ARCHITECTURE),
|
||||
m_blocks(std::move(fastFileBlocks)),
|
||||
m_asset(nullptr),
|
||||
m_has_actions(false),
|
||||
@ -190,7 +191,8 @@ bool RenderingContext::UsedTypeHasActions(const RenderingUsedType* usedType) con
|
||||
|
||||
std::unique_ptr<RenderingContext> RenderingContext::BuildContext(const IDataRepository* repository, StructureInformation* asset)
|
||||
{
|
||||
auto context = std::make_unique<RenderingContext>(RenderingContext(repository->GetGameName(), repository->GetAllFastFileBlocks()));
|
||||
auto context =
|
||||
std::make_unique<RenderingContext>(RenderingContext(repository->GetGameName(), repository->GetArchitecture(), repository->GetAllFastFileBlocks()));
|
||||
|
||||
context->MakeAsset(repository, asset);
|
||||
context->CreateUsedTypeCollections();
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
static std::unique_ptr<RenderingContext> BuildContext(const IDataRepository* repository, StructureInformation* asset);
|
||||
|
||||
std::string m_game;
|
||||
bool m_architecture_mismatch;
|
||||
std::vector<const FastFileBlock*> m_blocks;
|
||||
|
||||
StructureInformation* m_asset;
|
||||
@ -43,7 +44,7 @@ public:
|
||||
const FastFileBlock* m_default_temp_block;
|
||||
|
||||
private:
|
||||
RenderingContext(std::string game, std::vector<const FastFileBlock*> fastFileBlocks);
|
||||
RenderingContext(std::string game, Architecture gameArchitecture, std::vector<const FastFileBlock*> fastFileBlocks);
|
||||
|
||||
RenderingUsedType* AddUsedType(std::unique_ptr<RenderingUsedType> usedType);
|
||||
RenderingUsedType* GetBaseType(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||
|
@ -60,6 +60,13 @@ namespace
|
||||
|
||||
// Method Declarations
|
||||
for (const auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_info && type->m_type == type->m_info->m_definition && !type->m_info->m_has_matching_cross_platform_structure)
|
||||
{
|
||||
PrintFillStructMethodDeclaration(type->m_info);
|
||||
}
|
||||
}
|
||||
for (const auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists)
|
||||
{
|
||||
@ -149,6 +156,14 @@ namespace
|
||||
LINE("")
|
||||
PrintMainLoadMethod();
|
||||
|
||||
for (const auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_info && type->m_type == type->m_info->m_definition && !type->m_info->m_has_matching_cross_platform_structure)
|
||||
{
|
||||
LINE("")
|
||||
PrintFillStructMethod(type->m_info);
|
||||
}
|
||||
}
|
||||
for (const auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists)
|
||||
@ -212,6 +227,11 @@ namespace
|
||||
return std::format("{0}** var{1}Ptr;", def->GetFullName(), MakeSafeTypeName(def));
|
||||
}
|
||||
|
||||
void PrintFillStructMethodDeclaration(const StructureInformation* info)
|
||||
{
|
||||
LINEF("void FillStruct_{1}(const ZoneStreamFillReadAccessor& fillAccessor);", LoaderClassName(m_env.m_asset), MakeSafeTypeName(info->m_definition))
|
||||
}
|
||||
|
||||
void PrintHeaderPtrArrayLoadMethodDeclaration(const DataDefinition* def) const
|
||||
{
|
||||
LINEF("void LoadPtrArray_{0}(bool atStreamStart, size_t count);", MakeSafeTypeName(def))
|
||||
@ -297,6 +317,28 @@ namespace
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
void PrintFillStructMethod(const StructureInformation* info)
|
||||
{
|
||||
LINEF("void {0}::FillStruct_{1}(const ZoneStreamFillReadAccessor& fillAccessor)",
|
||||
LoaderClassName(m_env.m_asset),
|
||||
MakeSafeTypeName(info->m_definition))
|
||||
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
{
|
||||
const MemberComputations computations(member.get());
|
||||
if (computations.ShouldIgnore())
|
||||
continue;
|
||||
|
||||
LINEF("// FillStruct_{0}();", MakeSafeTypeName(member->m_member->m_type_declaration->m_type))
|
||||
}
|
||||
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
void PrintLoadPtrArrayMethod_Loading(const DataDefinition* def, const StructureInformation* info) const
|
||||
{
|
||||
LINEF("*{0} = m_stream->Alloc<{1}>({2});", MakeTypePtrVarName(def), def->GetFullName(), def->GetAlignment())
|
||||
@ -339,7 +381,7 @@ namespace
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINEF("*{0} = m_stream->ConvertOffsetToPointer(*{0});", MakeTypePtrVarName(def))
|
||||
LINEF("*{0} = m_stream->ConvertOffsetToPointerNative(*{0});", MakeTypePtrVarName(def))
|
||||
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
@ -765,7 +807,7 @@ namespace
|
||||
LINEF("{0}** toInsert = nullptr;", member->m_member->m_type_declaration->m_type->GetFullName())
|
||||
LINE("if (ptr == PTR_INSERT)")
|
||||
m_intendation++;
|
||||
LINEF("toInsert = m_stream->InsertPointer<{0}>();", member->m_member->m_type_declaration->m_type->GetFullName())
|
||||
LINEF("toInsert = m_stream->InsertPointerNative<{0}>();", member->m_member->m_type_declaration->m_type->GetFullName())
|
||||
m_intendation--;
|
||||
LINE("")
|
||||
}
|
||||
@ -823,7 +865,7 @@ namespace
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINEF("{0} = m_stream->ConvertOffsetToAlias({0});", MakeMemberAccess(info, member, modifier))
|
||||
LINEF("{0} = m_stream->ConvertOffsetToAliasNative({0});", MakeMemberAccess(info, member, modifier))
|
||||
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
@ -842,7 +884,7 @@ namespace
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINEF("{0} = m_stream->ConvertOffsetToPointer({0});", MakeMemberAccess(info, member, modifier))
|
||||
LINEF("{0} = m_stream->ConvertOffsetToPointerNative({0});", MakeMemberAccess(info, member, modifier))
|
||||
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
@ -1080,24 +1122,39 @@ namespace
|
||||
{
|
||||
LINE("")
|
||||
LINE("if (atStreamStart)")
|
||||
m_intendation++;
|
||||
|
||||
if (dynamicMember == nullptr)
|
||||
if (info->m_has_matching_cross_platform_structure)
|
||||
{
|
||||
LINEF("m_stream->Load<{0}>({1}); // Size: {2}",
|
||||
info->m_definition->GetFullName(),
|
||||
MakeTypeVarName(info->m_definition),
|
||||
info->m_definition->GetSize())
|
||||
m_intendation++;
|
||||
|
||||
if (dynamicMember == nullptr)
|
||||
{
|
||||
LINEF("m_stream->Load<{0}>({1}); // Size: {2}",
|
||||
info->m_definition->GetFullName(),
|
||||
MakeTypeVarName(info->m_definition),
|
||||
info->m_definition->GetSize())
|
||||
}
|
||||
else
|
||||
{
|
||||
LINEF("m_stream->LoadPartial<{0}>({1}, offsetof({0}, {2}));",
|
||||
info->m_definition->GetFullName(),
|
||||
MakeTypeVarName(info->m_definition),
|
||||
dynamicMember->m_member->m_name)
|
||||
}
|
||||
|
||||
m_intendation--;
|
||||
}
|
||||
else
|
||||
{
|
||||
LINEF("m_stream->LoadPartial<{0}>({1}, offsetof({0}, {2}));",
|
||||
info->m_definition->GetFullName(),
|
||||
MakeTypeVarName(info->m_definition),
|
||||
dynamicMember->m_member->m_name)
|
||||
}
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
m_intendation--;
|
||||
LINEF("{0} = m_memory.Alloc<{1}>();", MakeTypeVarName(info->m_definition), info->m_definition->m_name)
|
||||
LINEF("FillStruct_{0}(m_stream->LoadWithFill({1}));", MakeSafeTypeName(info->m_definition), info->m_definition->GetSize())
|
||||
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1182,7 +1239,7 @@ namespace
|
||||
LINEF("{0}** toInsert = nullptr;", info->m_definition->GetFullName())
|
||||
LINE("if (ptr == PTR_INSERT)")
|
||||
m_intendation++;
|
||||
LINEF("toInsert = m_stream->InsertPointer<{0}>();", info->m_definition->GetFullName())
|
||||
LINEF("toInsert = m_stream->InsertPointerNative<{0}>();", info->m_definition->GetFullName())
|
||||
m_intendation--;
|
||||
}
|
||||
|
||||
@ -1236,11 +1293,11 @@ namespace
|
||||
|
||||
if (inTemp)
|
||||
{
|
||||
LINEF("*{0} = m_stream->ConvertOffsetToAlias(*{0});", MakeTypePtrVarName(info->m_definition))
|
||||
LINEF("*{0} = m_stream->ConvertOffsetToAliasNative(*{0});", MakeTypePtrVarName(info->m_definition))
|
||||
}
|
||||
else
|
||||
{
|
||||
LINEF("*{0} = m_stream->ConvertOffsetToPointer(*{0});", MakeTypePtrVarName(info->m_definition))
|
||||
LINEF("*{0} = m_stream->ConvertOffsetToPointerNative(*{0});", MakeTypePtrVarName(info->m_definition))
|
||||
}
|
||||
|
||||
m_intendation--;
|
||||
|
Reference in New Issue
Block a user