ZoneCodeGenerator: Fixup templates and structs to be able to generate code for AddonMapEnts

This commit is contained in:
Jan 2019-12-05 02:56:35 +01:00
parent 42e571427b
commit 5853950888
9 changed files with 137 additions and 88 deletions

View File

@ -420,6 +420,47 @@ use clipMap_t;
set string name;
set name name;
// ClipInfo
use ClipInfo;
set reusable planes;
set count planes planeCount;
set reusable materials;
set count materials numMaterials;
set reusable brushsides;
set count brushsides numBrushSides;
set reusable leafbrushNodes;
set count leafbrushNodes leafbrushNodesCount;
set reusable leafbrushes;
set count leafbrushes numLeafBrushes;
set count brushVerts numBrushVerts;
set count uinds nuinds;
set reusable brushes;
set count brushes numBrushes;
set reusable brushBounds;
set count brushBounds numBrushes;
set reusable brushContents;
set count brushContents numBrushes;
// ClipMaterial
set string ClipMaterial::name;
// cbrushside_t
set reusable cbrushside_t::plane;
// cLeafBrushNode_s
use cLeafBrushNode_s;
set condition data::leaf leafBrushCount > 0;
set reusable data::leaf::brushes;
set count data::leaf::brushes leafBrushCount;
// cbrush_t
use cbrush_t;
set reusable sides;
set reusable verts;
// cmodel_t
set reusable cmodel_t::info;
// =========================================
// ComWorld
// =========================================

View File

@ -36,6 +36,11 @@ namespace ZoneCodeGenerator.Generating
private readonly IDictionary<DataType, UsedType> usedTypes;
public IEnumerable<UsedType> UsedTypes => usedTypes.Values;
public IEnumerable<StructureInformation> UsedStructures => UsedTypes
.Select(type => type.Information)
.Where(information => information != null)
.Distinct();
public IEnumerable<UsedType> ReferencedAssets => UsedTypes.Where(type => type.Information != null && type.Information.IsAsset && type.Information != Asset);
public IList<FastFileBlock> Blocks { get; private set; }

View File

@ -5,8 +5,8 @@ Lower(name) ::= "$name; format=\"lower\"$"
TypeDeclaration(typeDecl) ::= "$if(typeDecl.IsConst)$const $endif$$typeDecl.Type.FullName$"
TypeVarName(structure) ::= "var$SafeTypeName(structure.Type)$"
TypePtrVarName(structure) ::= "var$SafeTypeName(structure.Type)$Ptr"
TypeVarName(type) ::= "var$SafeTypeName(type)$"
TypePtrVarName(type) ::= "var$SafeTypeName(type)$Ptr"
SafeTypeName(type) ::= "$type; format=\"safe_name\"$"
@ -33,7 +33,7 @@ $endif$
%>
PrintOperandDynamic(op) ::= <%
$TypeVarName(op.Structure)$
$TypeVarName(op.Structure.Type)$
->$first(op.ReferencedMemberChain):{member | $member.Member.Name$}$
$rest(op.ReferencedMemberChain):{member | .$member.Member.Name$}$
$op.ArrayIndices:{ arrayIndex | [$arrayIndex$]}$

View File

@ -3,24 +3,28 @@ delimiters "$", "$"
// Everything related to loading a pointer with a count that can be larger than 1
LoadArrayPointer_Loading(context, structure, member, reference) ::= <%
$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));$\n$
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));
// $member.Member.VariableType.Type.Alignment$
$\n$
$if(member.StructureType && !member.StructureType.IsLeaf)$
$TypeVarName(member.StructureType)$ = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
$TypeVarName(member.Member.VariableType.Type)$ = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadArray_$member.Member.VariableType.Type.Name$(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$else$
m_stream->Load<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
m_stream->Load<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$endif$
%>
LoadArrayPointer_ScriptString(context, structure, member, reference) ::= <%
$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));$\n$
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));
// $member.Member.VariableType.Type.Alignment$
$\n$
varScriptString = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
varScriptString = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadScriptStringArray(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
%>
@ -34,16 +38,16 @@ $endif$
%>
LoadArrayPointer_PointerCheck(context, structure, member, reference) ::= <<
if ($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$)
if ($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$)
{
$if(member.IsReusable)$
if($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ == PTR_FOLLOWING)
if($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ == PTR_FOLLOWING)
{
$LoadArrayPointer_TypeCheck(context, structure, member, reference)$
}
else
{
$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$);
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$);
}
$else$
$LoadArrayPointer_TypeCheck(context, structure, member, reference)$

View File

@ -3,28 +3,42 @@ delimiters "$", "$"
// Everything related to loading an embedded reference
LoadEmbedded_Load(context, structure, member, reference) ::= <<
$TypeVarName(member.StructureType)$ = &$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;
$TypeVarName(member.Member.VariableType.Type)$ = &$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;
Load_$member.Member.VariableType.Type.Name$(false);
>>
LoadEmbedded_TypeCheck(context, structure, member, reference) ::= <%
$if(member.IsScriptString)$
$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ = UseScriptString($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$);
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = UseScriptString($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$);
$else$
$LoadEmbedded_Load(context, structure, member, reference)$
$endif$
%>
LoadEmbedded_Condition(context, structure, member, reference) ::= <<
$if(member.Condition)$
if($PrintEvaluation(member.Condition)$)
{
$LoadEmbedded_TypeCheck(context, structure, member, reference)$
$if(structure.IsUnion)$
return;
$endif$
}
$else$$\\$
$LoadEmbedded_TypeCheck(context, structure, member, reference)$$\\$
$endif$
>>
LoadEmbedded(context, structure, member, reference) ::= <%
$LoadEmbedded_TypeCheck(context, structure, member, reference)$
$LoadEmbedded_Condition(context, structure, member, reference)$
%>
LoadEmbeddedArray_TypeCheck(context, structure, member, reference) ::= <%
$if(member.IsScriptString)$
varScriptString = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
varScriptString = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadScriptStringArray(false, $reference.ArraySize$);
$else$
$TypeVarName(member.StructureType)$ = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
$TypeVarName(member.Member.VariableType.Type)$ = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadArray_$member.Member.VariableType.Type.Name$(false, $reference.ArraySize$);
$endif$
%>

View File

@ -2,21 +2,23 @@ delimiters "$", "$"
LoadPointerArray_Loading(context, structure, member, reference) ::= <%
$if(member.Computations.IsArray)$
$TypePtrVarName(member.Member.VariableType)$ = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
$TypePtrVarName(member.Member.VariableType.Type)$ = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadPtrArray_$SafeTypeName(member.Member.VariableType.Type)$(false, $reference.ArraySize$);
$else$
$TypePtrVarName(member.Member.VariableType)$ = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
$TypePtrVarName(member.Member.VariableType.Type)$ = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadPtrArray_$SafeTypeName(member.Member.VariableType.Type)$(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$endif$
%>
LoadPointerArray_String(context, structure, member, reference) ::= <%
$if(reference.IsArray)$
varXString = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
varXString = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadXStringArray(false, $reference.ArraySize$);
$else$
$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));$\n$
varXString = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));
// $member.Member.VariableType.Alignment$
$\n$
varXString = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadXStringArray(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$endif$
%>

View File

@ -3,39 +3,41 @@ delimiters "$", "$"
// Everything related to loading a pointer with a count that is statically 1
LoadSinglePointerInner(context, structure, member, reference) ::= <%
$TypeVarName(structure)$->$member.Member.Name$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));$\n$
$TypeVarName(structure.Type)$->$member.Member.Name$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));
// $member.Member.VariableType.Type.Alignment$
$\n$
$if(member.StructureType && !member.StructureType.IsLeaf)$
$TypeVarName(member.StructureType)$ = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
$TypeVarName(member.Member.VariableType.Type)$ = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
Load_$member.Member.VariableType.Type.Name$(true);
$else$
m_stream->Load<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$);
m_stream->Load<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$);
$endif$
%>
LoadSinglePointerAsset(context, structure, member, reference) ::= <<
$LoaderClassName(member.StructureType)$ loader(m_script_string_provider, m_zone, m_stream);
loader.Load(&$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$);
loader.Load(&$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$);
>>
LoadSinglePointer_PointerCheck(context, structure, member, reference) ::= <<
if ($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$)
if ($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$)
{
$if(member.StructureType && member.StructureType.IsAsset)$
$LoadSinglePointerAsset(context, structure, member, reference)$
$else$
$if(member.IsReusable)$
if($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ == PTR_FOLLOWING)
if($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ == PTR_FOLLOWING)
{
$LoadSinglePointerInner(context, structure, member, reference)$
}
else
{
$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$);
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$);
}
$else$
$LoadSinglePointerInner(context, structure, member, reference)$
@ -46,9 +48,9 @@ if ($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$
LoadSinglePointer_String(context, structure, member, reference) ::= <%
$if(member.Member.VariableType.IsConst)$
varXString = &$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
varXString = &$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
$else$
varXString = const_cast<const char**>(&$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$);$\n$
varXString = const_cast<const char**>(&$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$);$\n$
$endif$
LoadXString(false);
%>

View File

@ -14,7 +14,7 @@ LoaderClassName(asset) ::= "Loader_$asset.Type.Name$"
HeaderConstructor(context) ::= "$LoaderClassName(context.Asset)$(IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream);"
HeaderSinglePtrLoadMethodDeclaration(structure) ::= "void LoadPtr_$structure.Type.Name$(bool atStreamStart);"
HeaderArrayLoadMethodDeclaration(structure) ::= "void LoadArray_$structure.Type.Name$(bool atStreamStart, size_t count);"
HeaderArrayLoadMethodDeclaration(type) ::= "void LoadArray_$SafeTypeName(type)$(bool atStreamStart, size_t count);"
HeaderPtrArrayLoadMethodDeclaration(type) ::= "void LoadPtrArray_$SafeTypeName(type)$(bool atStreamStart, size_t count);"
HeaderLoadMethodDeclaration(structure) ::= "void Load_$structure.Type.Name$(bool atStreamStart);"
@ -30,21 +30,6 @@ PointerVariableDeclaration(type) ::= <<
$type.FullName$** var$SafeTypeName(type)$Ptr;
>>
HeaderMethodDeclarations(usedType) ::= <%
$if(usedType.PointerArrayReferenceExists)$
$HeaderPtrArrayLoadMethodDeclaration(usedType.Type)$
$\n$
$endif$
$if(usedType.ArrayReferenceExists && usedType.Information && !usedType.Information.IsLeaf)$
$HeaderArrayLoadMethodDeclaration(usedType.Information)$
$\n$
$endif$
$if(usedType.Information && !usedType.Information.IsLeaf && !usedType.Information.IsAsset)$
$HeaderLoadMethodDeclaration(usedType.Information)$
$\n$
$endif$
%>
// =======================
// Header file entry point
// =======================
@ -73,7 +58,9 @@ namespace $context.Game$
$context.UsedTypes:{type | $if(type.PointerArrayReferenceExists && !type.IsContextAsset)$$PointerVariableDeclaration(type.Type)$
$endif$}$$\\$
$context.UsedTypes:{usedType | $HeaderMethodDeclarations(usedType)$}$
$context.UsedTypes:{usedType | $if(usedType.PointerArrayReferenceExists)$$HeaderPtrArrayLoadMethodDeclaration(usedType.Type)$$\n$$endif$}$
$context.UsedTypes:{usedType | $if(usedType.ArrayReferenceExists && usedType.Information && !usedType.Information.IsLeaf)$$HeaderArrayLoadMethodDeclaration(usedType.Type)$$\n$$endif$}$
$context.UsedStructures:{usedStructure | $if(!usedStructure.IsLeaf && !usedStructure.IsAsset)$$HeaderLoadMethodDeclaration(usedStructure)$$\n$$endif$}$
$HeaderLoadMethodDeclaration(context.Asset)$
$HeaderSinglePtrLoadMethodDeclaration(context.Asset)$
$HeaderAssetLoadMethodDeclaration(context.Asset)$
@ -129,49 +116,49 @@ $endif$
LoadSinglePtrMethod(context, structure) ::= <<
void $LoaderClassName(context.Asset)$::LoadPtr_$structure.Type.Name$(const bool atStreamStart)
{
assert($TypePtrVarName(structure)$ != nullptr);
assert($TypePtrVarName(structure.Type)$ != nullptr);
if(atStreamStart)
m_stream->Load<$structure.Type.FullName$*>($TypePtrVarName(structure)$);
m_stream->Load<$structure.Type.FullName$*>($TypePtrVarName(structure.Type)$);
m_stream->PushBlock($structure.Block.Name$);
if(*$TypePtrVarName(structure)$ != nullptr)
if(*$TypePtrVarName(structure.Type)$ != nullptr)
{
$if(structure.Block.IsTemp)$
if(*$TypePtrVarName(structure)$ == PTR_FOLLOWING || *$TypePtrVarName(structure)$ == PTR_INSERT)
if(*$TypePtrVarName(structure.Type)$ == PTR_FOLLOWING || *$TypePtrVarName(structure.Type)$ == PTR_INSERT)
$else$
if(*$TypePtrVarName(structure)$ == PTR_FOLLOWING)
if(*$TypePtrVarName(structure.Type)$ == PTR_FOLLOWING)
$endif$
{
$if(structure.Block.IsTemp)$
$structure.Type.FullName$** toInsert = nullptr;
if(*$TypePtrVarName(structure)$ == PTR_INSERT)
if(*$TypePtrVarName(structure.Type)$ == PTR_INSERT)
toInsert = m_stream->InsertPointer<$structure.Type.FullName$>();
$endif$
*$TypePtrVarName(structure)$ = m_stream->Alloc<$structure.Type.FullName$>(alignof($structure.Type.FullName$));
*$TypePtrVarName(structure.Type)$ = m_stream->Alloc<$structure.Type.FullName$>(alignof($structure.Type.FullName$));
$if(!structure.IsLeaf)$
$TypeVarName(structure)$ = *$TypePtrVarName(structure)$;
$TypeVarName(structure.Type)$ = *$TypePtrVarName(structure.Type)$;
Load_$structure.Type.Name$(true);
$endif$
$if(structure.IsAsset)$
LoadAsset_$structure.Type.Name$($TypePtrVarName(structure)$);
LoadAsset_$structure.Type.Name$($TypePtrVarName(structure.Type)$);
$endif$
$if(structure.Block.IsTemp)$
if(toInsert != nullptr)
*toInsert = *$TypePtrVarName(structure)$;
*toInsert = *$TypePtrVarName(structure.Type)$;
$endif$
}
else
{
$if(structure.Block.IsTemp)$
*$TypePtrVarName(structure)$ = m_stream->ConvertOffsetToAlias(*$TypePtrVarName(structure)$);
*$TypePtrVarName(structure.Type)$ = m_stream->ConvertOffsetToAlias(*$TypePtrVarName(structure.Type)$);
$else$
*$TypePtrVarName(structure)$ = m_stream->ConvertOffsetToPointer(*$TypePtrVarName(structure)$);
*$TypePtrVarName(structure.Type)$ = m_stream->ConvertOffsetToPointer(*$TypePtrVarName(structure.Type)$);
$endif$
}
}
@ -187,18 +174,21 @@ void $LoaderClassName(context.Asset)$::LoadPtrArray_$SafeTypeName(type)$(const b
}
>>
LoadArrayMethod(context, structure) ::= <<
void $LoaderClassName(context.Asset)$::LoadArray_$structure.Type.Name$(const bool atStreamStart, const size_t count)
LoadArrayMethod(context, type, structure) ::= <<
void $LoaderClassName(context.Asset)$::LoadArray_$type.Name$(const bool atStreamStart, const size_t count)
{
assert($TypeVarName(structure)$ != nullptr);
assert($TypeVarName(type)$ != nullptr);
if(atStreamStart)
m_stream->Load<$structure.Type.FullName$>($TypeVarName(structure)$, count);
m_stream->Load<$type.FullName$>($TypeVarName(type)$, count);
for(size_t index = 0; index < count; index++)
{
$if(!type.Members)$
$TypeVarName(structure.Type)$ = $TypeVarName(type)$;
$endif$
Load_$structure.Type.Name$(false);
$TypeVarName(structure)$++;
$TypeVarName(type)$++;
}
}
>>
@ -206,10 +196,10 @@ void $LoaderClassName(context.Asset)$::LoadArray_$structure.Type.Name$(const boo
LoadMethod(context, structure) ::= <<
void $LoaderClassName(context.Asset)$::Load_$structure.Type.Name$(const bool atStreamStart)
{
assert($TypeVarName(structure)$ != nullptr);
assert($TypeVarName(structure.Type)$ != nullptr);
if(atStreamStart)
m_stream->Load<$structure.Type.FullName$>($TypeVarName(structure)$);$\\$
m_stream->Load<$structure.Type.FullName$>($TypeVarName(structure.Type)$);$\\$
$if(structure.Block.IsTemp)$
m_stream->PushBlock($context.DefaultNormalBlock.Name$);$\\$
@ -222,21 +212,6 @@ void $LoaderClassName(context.Asset)$::Load_$structure.Type.Name$(const bool atS
}
>>
SourceDefinition(context, usedType) ::= <%
$if(usedType.PointerArrayReferenceExists)$
$LoadPointerArrayMethod(context, usedType.Type, usedType.Information)$
$\n$$\n$
$endif$
$if(usedType.ArrayReferenceExists && usedType.Information && !usedType.Information.IsLeaf)$
$LoadArrayMethod(context, usedType.Information)$
$\n$$\n$
$endif$
$if(usedType.Information && !usedType.Information.IsLeaf && !usedType.Information.IsAsset)$
$LoadMethod(context, usedType.Information)$
$\n$$\n$
$endif$
%>
VariableInitialization(type) ::= <<
var$type.Name$ = nullptr;
>>
@ -272,7 +247,7 @@ void $LoaderClassName(context.Asset)$::Load($context.Asset.Type.FullName$** pAss
{
assert(pAsset != nullptr);
$TypePtrVarName(context.Asset)$ = pAsset;
$TypePtrVarName(context.Asset.Type)$ = pAsset;
LoadPtr_$context.Asset.Type.Name$(false);
}
>>
@ -313,7 +288,9 @@ using namespace $context.Game$;
$ConstructorMethod(context)$
$context.UsedTypes:{usedType | $SourceDefinition(context, usedType)$}$
$context.UsedTypes:{usedType | $if(usedType.PointerArrayReferenceExists)$$LoadPointerArrayMethod(context, usedType.Type, usedType.Information)$$\n$$\n$$endif$}$
$context.UsedTypes:{usedType | $if(usedType.ArrayReferenceExists && usedType.Information && !usedType.Information.IsLeaf)$$LoadArrayMethod(context, usedType.Type, usedType.Information)$$\n$$\n$$endif$}$
$context.UsedStructures:{usedStructure | $if(!usedStructure.IsLeaf && !usedStructure.IsAsset)$$LoadMethod(context, usedStructure)$$\n$$\n$$endif$}$
$LoadMethod(context, context.Asset)$
$LoadSinglePtrMethod(context, context.Asset)$

View File

@ -794,6 +794,10 @@ struct SndPatch
unsigned int *elements;
};
typedef unsigned short LeafBrush;
typedef __declspec(align(128)) cbrush_t cbrush_array_t;
typedef __declspec(align(128)) Bounds BoundsArray;
struct ClipInfo
{
int planeCount;
@ -805,14 +809,14 @@ struct ClipInfo
unsigned int leafbrushNodesCount;
cLeafBrushNode_s *leafbrushNodes;
unsigned int numLeafBrushes;
unsigned __int16 *leafbrushes;
LeafBrush* leafbrushes;
unsigned int numBrushVerts;
vec3_t *brushVerts;
unsigned int nuinds;
unsigned __int16 *uinds;
unsigned __int16 numBrushes;
cbrush_t *brushes;
Bounds *brushBounds;
cbrush_array_t *brushes;
BoundsArray *brushBounds;
int *brushContents;
};
@ -2667,7 +2671,7 @@ struct cbrushside_t
struct cLeafBrushNodeLeaf_t
{
unsigned __int16 *brushes;
LeafBrush *brushes;
};
struct cLeafBrushNodeChildren_t
@ -3253,7 +3257,7 @@ struct GfxBrushModelWritable
float padding2;
};
struct GfxBrushModel
struct __declspec(align(16)) GfxBrushModel
{
GfxBrushModelWritable writable;
vec3_t bounds[2];