upgradeable types!

This commit is contained in:
Asuro
2025-04-06 22:27:01 +02:00
parent 158d59e09e
commit c7edebaeb8
12 changed files with 2005 additions and 197 deletions

View File

@@ -16,6 +16,7 @@ namespace WriteTemplates
constexpr char FileHeaderStart[] =
R"END(#pragma once
#include <cstdint>
#include <cassert>
namespace Gen
{
@@ -101,24 +102,115 @@ namespace Gen
)END";
constexpr char LoadFuncBodyStart1[] = R"END( bool Load(%s* obj, uint32_t count, Deserializer& serializer)
{
)END";
constexpr char LoadFuncBodySetupStart2[] =
R"END( const char* typeName = Meta::Metadata.TypeDefinitions[%s::TypeIdx].Name;
// Quick match
int32_t matchedHashIdx =
serializer.TypeBuf.FindHash(Meta::Metadata.TypeDefinitions[%s::TypeIdx].Hash);
if (matchedHashIdx >= 0)
{
assert(bx::strCmp(serializer.TypeBuf.Defs[matchedHashIdx].Name, typeName) == 0);
bool isOk = true;
for (uint32_t i = 0; i < count; ++i)
{
)END";
constexpr char LoadFuncBodyQuickLoad2[] = R"END( isOk = Load(%sobj[i].%s, %u, serializer) && isOk;
)END";
constexpr char LoadFuncBodySetupEnd[] = R"END( }
// if we're not ok here, something went really wrong
assert(isOk);
return isOk;
}
// Failed to resolve hash, the type definition chaned since the file was saved! try to match by name.
int32_t nameMatchIdx = serializer.TypeBuf.FindDefByName(typeName);
if (nameMatchIdx < 0)
{
// Name match failed, caller has to handle this and potentially skip some bytes
return false;
}
// Successfully matched name, but we need to follow the definition of the file now!
const Meta::TypeDef& matchedDef = serializer.TypeBuf.Defs[nameMatchIdx];
// Figure out new member mapping
uint64_t WriteDestinations[64];
for (int32_t i = 0; i < BX_COUNTOF(WriteDestinations); ++i)
{
WriteDestinations[i] = UINT64_MAX;
}
for (uint32_t i = 0; i < matchedDef.ChildCount; ++i)
{
const bx::StringView memberName = {&serializer.MemberNameBuf[matchedDef.MemberNameIndices[i].Offset], matchedDef.MemberNameIndices[i].Size};
const char* memberTypeName = serializer.TypeBuf.Defs[matchedDef.ChildIndices[i]].Name;
)END";
constexpr char LoadFuncBodyMemberCheck4[] =
R"END( if (bx::strCmp(memberName, "%s") == 0 && bx::strCmp(memberTypeName, "%s") == 0)
{
WriteDestinations[i] = offsetof(%s, %s);
}
)END";
constexpr char LoadFuncBodyTypeUpgradeStart[] = R"END( }
// Start reading in file order, skipping things that we don't know by name and type
bool isOk = true;
for (uint32_t i = 0; i < count; ++i)
{
uint8_t* objBasePtr = reinterpret_cast<uint8_t*>(&obj[i]);
for (uint32_t j = 0; j < matchedDef.ChildCount; ++j)
{
const Meta::TypeDef& childDef = serializer.TypeBuf.Defs[matchedDef.ChildIndices[j]];
const bx::StringView memberName = {&serializer.MemberNameBuf[matchedDef.MemberNameIndices[j].Offset], matchedDef.MemberNameIndices[j].Size};
if (WriteDestinations[j] == UINT64_MAX)
{
// Unknown member name or type changed
serializer.Skip(childDef.Size);
continue;
}
)END";
constexpr char LoadFuncBodyType3[] = R"END( isOk = Load(%sobj[i].%s, %u, serializer) && isOk;
constexpr char LoadFuncBodyTypeUpgradeMember3[] = R"END( if (bx::strCmp(memberName, "%s") == 0)
{
auto* fieldPtr = reinterpret_cast<%s*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, %u, serializer) && isOk;
continue;
}
)END";
constexpr char LoadFuncBodyNative[] = R"END( isOk = serializer.Read(&obj[i], sizeof(obj[i])) && isOk;
)END";
constexpr char LoadFuncBodyEnum2[] = R"END( %s& val = (%s&)obj[i];
isOk = Load(&val, 1, serializer) && isOk;
)END";
constexpr char LoadFuncBodyEnd[] = R"END( }
constexpr char LoadFuncBodyTypeUpgradeEnd[] = R"END( assert(false);
}
}
assert(isOk);
return isOk;
}
)END";
constexpr char LoadFuncBodyNative[] = R"END( bool isOk = true;
for (int32_t i = 0; i < count; ++i)
{
isOk = serializer.Read(&obj[i], sizeof(obj[i])) && isOk;
}
return isOk;
}
)END";
constexpr char LoadFuncBodyEnum2[] = R"END( bool isOk = true;
for (int32_t i = 0; i < count; ++i)
{
%s& val = (%s&)obj[i];
isOk = Load(&val, 1, serializer) && isOk;
}
return isOk;
}
)END";
constexpr char MetadataStart1[] = R"END(
namespace Meta {
struct StrRef
{
uint16_t Offset;
uint16_t Size;
};
struct TypeDef
{
uint32_t Size = 0;
@@ -126,6 +218,7 @@ namespace Gen
char Name[64]{"Dummy"};
uint16_t ChildCount = 0;
uint16_t ChildIndices[64]{0};
StrRef MemberNameIndices[64]{0};
};
struct EnumDef
@@ -140,7 +233,7 @@ namespace Gen
{
)END";
constexpr char MetadataTypeEntry5[] = R"END( TypeDef{sizeof(%s), %u, "%s", %u, {%s}},
constexpr char MetadataTypeEntry6[] = R"END( TypeDef{sizeof(%s), %u, "%s", %u, {%s}, {%s}},
)END";
constexpr char MetadataEnumStart1[] = R"END( };
EnumDef EnumDefinitions[%u]
@@ -148,7 +241,8 @@ namespace Gen
)END";
constexpr char MetadataEnumEntry2[] = R"END( EnumDef{sizeof(%s::Enum), %u},
)END";
constexpr char MetadataEnd[] = R"END( };
constexpr char MetadataEnd1[] = R"END( };
char MemberNameBuffer[64*64*64]{"%s"};
};
constexpr MetadataTable Metadata;
@@ -317,7 +411,6 @@ void CppFileWriter::WriteSaveLoadMethods(const Def::DefinitionFile& definitions)
WriteCpp(WriteTemplates::LoadFuncBodyStart1, nameBuf);
WriteCpp(WriteTemplates::LoadFuncBodyEnum2, fieldBuf, fieldBuf);
WriteCpp(WriteTemplates::LoadFuncBodyEnd);
}
for (uint16_t typeIdx = 0; typeIdx < definitions.TypeCount; ++typeIdx)
{
@@ -329,13 +422,13 @@ void CppFileWriter::WriteSaveLoadMethods(const Def::DefinitionFile& definitions)
Write(WriteTemplates::LoadFuncHeader1, typeName);
WriteCpp(WriteTemplates::SaveFuncBodyStart1, typeName);
for (int32_t fieldIdx = 0; fieldIdx < t.FieldCount; ++fieldIdx)
if ((int32_t)t.TypeFlags & (int32_t)Def::ETypeFlags::IsNative)
{
if (Def::IsFieldNative(definitions, t, fieldIdx))
{
WriteCpp(WriteTemplates::SaveFuncBodyNative);
}
else
WriteCpp(WriteTemplates::SaveFuncBodyNative);
}
else
{
for (int32_t fieldIdx = 0; fieldIdx < t.FieldCount; ++fieldIdx)
{
WriteCpp(WriteTemplates::SaveFuncBodyType3,
t.FieldArraySizes[fieldIdx] > 0 ? "" : "&",
@@ -346,30 +439,55 @@ void CppFileWriter::WriteSaveLoadMethods(const Def::DefinitionFile& definitions)
WriteCpp(WriteTemplates::SaveFuncBodyEnd);
WriteCpp(WriteTemplates::LoadFuncBodyStart1, typeName);
for (int32_t fieldIdx = 0; fieldIdx < t.FieldCount; ++fieldIdx)
if ((int32_t)t.TypeFlags & (int32_t)Def::ETypeFlags::IsNative)
{
if (Def::IsFieldNative(definitions, t, fieldIdx))
WriteCpp(WriteTemplates::LoadFuncBodyNative);
}
else
{
WriteCpp(WriteTemplates::LoadFuncBodySetupStart2, typeName, typeName);
for (int32_t fieldIdx = 0; fieldIdx < t.FieldCount; ++fieldIdx)
{
WriteCpp(WriteTemplates::LoadFuncBodyNative);
}
else
{
WriteCpp(WriteTemplates::LoadFuncBodyType3,
WriteCpp(WriteTemplates::LoadFuncBodyQuickLoad2,
t.FieldArraySizes[fieldIdx] > 0 ? "" : "&",
t.FieldNames[fieldIdx],
bx::max(1, t.FieldArraySizes[fieldIdx]));
}
WriteCpp(WriteTemplates::LoadFuncBodySetupEnd);
char fieldTypeName[Def::MaxNameLength]{0};
for (int32_t fieldIdx = 0; fieldIdx < t.FieldCount; ++fieldIdx)
{
const char* fieldName = t.FieldNames[fieldIdx];
PrintTypeName(fieldTypeName, sizeof(fieldTypeName), t.FieldTypes[fieldIdx], definitions);
WriteCpp(WriteTemplates::LoadFuncBodyMemberCheck4, fieldName, fieldTypeName, typeName, fieldName);
}
WriteCpp(WriteTemplates::LoadFuncBodyTypeUpgradeStart);
for (uint32_t fieldIdx = 0; fieldIdx < t.FieldCount; ++fieldIdx)
{
const char* fieldName = t.FieldNames[fieldIdx];
PrintTypeName(fieldTypeName, sizeof(fieldTypeName), t.FieldTypes[fieldIdx], definitions);
WriteCpp(WriteTemplates::LoadFuncBodyTypeUpgradeMember3,
fieldName,
fieldTypeName,
bx::max(1, t.FieldArraySizes[fieldIdx]));
}
WriteCpp(WriteTemplates::LoadFuncBodyTypeUpgradeEnd);
}
WriteCpp(WriteTemplates::LoadFuncBodyEnd);
}
}
namespace
{
char MemberNameBuffer[64 * 64 * 64]{0};
}
void CppFileWriter::WriteMetadata(const Def::DefinitionFile& definitions)
{
uint32_t memberNameBufferIdx = 0;
Write(WriteTemplates::MetadataStart1, definitions.TypeCount);
for (uint16_t i = 0; i < definitions.TypeCount; ++i)
{
auto& type = definitions.Types[i];
char fieldStr[256]{0};
for (int32_t j = 0; j < type.FieldCount; ++j)
{
@@ -378,16 +496,31 @@ void CppFileWriter::WriteMetadata(const Def::DefinitionFile& definitions)
bx::snprintf(numBuf, sizeof(numBuf), "%u", type.FieldTypes[j].TypeIdx);
bx::strCat(fieldStr, sizeof(fieldStr), numBuf);
}
char typeStr[Def::MaxNameLength]{0};
PrintTypeName(typeStr, sizeof(typeStr), {i, Def::EFieldType::DefinedClass}, definitions);
Write(WriteTemplates::MetadataTypeEntry5, typeStr, type.Hash, type.Name, type.FieldCount, fieldStr);
char memberIdxStr[256]{0};
for (int32_t j = 0; j < type.FieldCount; ++j)
{
if (j != 0) bx::strCat(memberIdxStr, sizeof(memberIdxStr), ", ");
char numBuf[16]{0};
bx::snprintf(numBuf, sizeof(numBuf), "{%u, %u}", memberNameBufferIdx, bx::strLen(type.FieldNames[j]));
bx::strCat(memberIdxStr, sizeof(memberIdxStr), numBuf);
memberNameBufferIdx += bx::strCopy(&MemberNameBuffer[memberNameBufferIdx],
sizeof(MemberNameBuffer) - memberNameBufferIdx,
type.FieldNames[j]);
}
Write(
WriteTemplates::MetadataTypeEntry6, typeStr, type.Hash, type.Name, type.FieldCount, fieldStr, memberIdxStr);
}
Write(WriteTemplates::MetadataEnumStart1, definitions.EnumCount);
for (int32_t i = 0; i < definitions.EnumCount; ++i)
{
Write(WriteTemplates::MetadataEnumEntry2, definitions.Enums[i].Name, definitions.Enums[i].Hash);
}
Write(WriteTemplates::MetadataEnd);
Write(WriteTemplates::MetadataEnd1, MemberNameBuffer);
}
void CppFileWriter::GenerateCpp(const bx::FilePath& outDir, const Def::DefinitionFile& definitions)

View File

@@ -69,10 +69,4 @@ namespace Def
Def::Enum Enums[MaxTypes];
int32_t EnumCount = 0;
};
inline bool IsFieldNative(const DefinitionFile& definitions, const Type& type, int32_t fieldIdx)
{
return ((int32_t)definitions.Types[type.FieldTypes[fieldIdx].TypeIdx].TypeFlags &
(int32_t)ETypeFlags::IsNative) > 0;
}
} // namespace Def

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -98,6 +98,7 @@ type PuzzleVisualSettings
{
Vec4 TileBaseColor
Vec4 TileDotColor
Vec3 Test
Vec4 DisabledCardTint
}

View File

@@ -4,6 +4,7 @@
#include "Generated.h"
#include "bx/string.h"
#include <bx/file.h>
#include <cassert>
#include <cstdint>
namespace Gen
@@ -27,6 +28,43 @@ namespace Gen
Defs[DefCount] = def;
++DefCount;
}
int32_t FindHash(uint32_t hash)
{
for (int32_t i = 0; i < DefCount; ++i)
{
if (Defs[i].Hash == hash)
{
return i;
}
}
return -1;
}
const int32_t FindDefByName(const char* name)
{
for (int32_t i = 0; i < DefCount; ++i)
{
if (bx::strCmp(name, Defs[i].Name) == 0)
{
return i;
}
}
return -1;
}
void PatchChildIndices()
{
for (int32_t i = 0; i < DefCount; ++i)
{
for (int32_t j = 0; j < Defs[i].ChildCount; ++j)
{
int32_t idx = FindHash(Meta::Metadata.TypeDefinitions[Defs[i].ChildIndices[j]].Hash);
assert(idx >= 0);
Defs[i].ChildIndices[j] = idx;
}
}
}
};
struct EmbeddedTypeInfoHeader
@@ -37,6 +75,7 @@ namespace Gen
uint16_t BaseTypeIdx = 0;
uint16_t TypeCount = 0;
uint32_t TypeDataSize = 0;
uint32_t MemberDataSize = 0;
};
struct Serializer
@@ -87,18 +126,21 @@ namespace Gen
typeBuf.AddDef(Meta::Metadata.TypeDefinitions[def.ChildIndices[j]]);
}
}
typeBuf.PatchChildIndices();
EmbeddedTypeInfoHeader header;
header.BaseTypeHash = baseDef.Hash;
header.BaseTypeIdx = 0;
header.TypeCount = typeBuf.DefCount;
header.TypeDataSize = header.TypeCount * sizeof(Meta::TypeDef);
header.MemberDataSize = bx::strLen(Meta::Metadata.MemberNameBuffer);
if (!Write(&header, sizeof(header))) return false;
for (int32_t i = 0; i < typeBuf.DefCount; ++i)
{
if (!Write(&typeBuf.Defs[i], sizeof(typeBuf.Defs[i]))) return false;
}
Write(Meta::Metadata.MemberNameBuffer, header.MemberDataSize);
if (!Save(&data, 1, *this))
{
@@ -132,6 +174,9 @@ namespace Gen
bx::FilePath Path;
bx::FileReader Reader;
char MemberNameBuf[64 * 64 * 64]{0};
EmbeddedTypeTableBuffer TypeBuf;
bool Init(const bx::FilePath& path, const char* _4cc)
{
Path = path;
@@ -185,28 +230,30 @@ namespace Gen
if (header.BaseTypeHash != baseTypeDef.Hash)
{
LOG_WARN("Hash mismatch! %u != %u", header.BaseTypeHash, baseTypeDef.Hash);
// TODO: patch data
data = {};
return false;
}
else
TypeBuf.DefCount = header.TypeCount;
for (int32_t i = 0; i < TypeBuf.DefCount; ++i)
{
LOG("Hash match!");
Read(&TypeBuf.Defs[i], sizeof(TypeBuf.Defs[i]));
}
// Skip definitions, we know they match
Reader.seek(header.TypeDataSize);
Read(MemberNameBuf, header.MemberDataSize);
if (!Load(&data, 1, *this))
{
LOG_ERROR("Failed to load: %s", Err.getMessage().getCPtr());
return false;
}
if (!Load(&data, 1, *this))
{
LOG_ERROR("Failed to load: %s", Err.getMessage().getCPtr());
return false;
}
return true;
}
void Skip(uint32_t byteCount)
{
Reader.seek(byteCount);
}
void Finish()
{
Reader.close();
@@ -218,6 +265,18 @@ namespace Gen
}
};
inline uint32_t FindNameInMetadata(const Meta::MetadataTable& meta, const char* name)
{
for (int32_t i = 0; i < BX_COUNTOF(meta.TypeDefinitions); ++i)
{
if (bx::strCmp(meta.TypeDefinitions[i].Name, name) == 0)
{
return i;
}
}
return -1;
}
template <typename T> bool Save(const T* obj, uint32_t count, Serializer& serializer);
template <typename T> bool Load(T* obj, uint32_t count, Deserializer& serializer);
} // namespace Gen

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <cassert>
namespace Gen
{
@@ -158,6 +159,7 @@ namespace Gen
static constexpr uint16_t TypeIdx = 24;
Vec4 TileBaseColor = {};
Vec4 TileDotColor = {};
Vec3 Test = {};
Vec4 DisabledCardTint = {};
};
struct StaticPuzzleData
@@ -272,6 +274,12 @@ namespace Gen
bool Load(SavedEntityRenderData* obj, uint32_t count, Deserializer& serializer);
namespace Meta {
struct StrRef
{
uint16_t Offset;
uint16_t Size;
};
struct TypeDef
{
uint32_t Size = 0;
@@ -279,6 +287,7 @@ namespace Gen
char Name[64]{"Dummy"};
uint16_t ChildCount = 0;
uint16_t ChildIndices[64]{0};
StrRef MemberNameIndices[64]{0};
};
struct EnumDef
@@ -291,42 +300,43 @@ namespace Gen
{
TypeDef TypeDefinitions[30]
{
TypeDef{sizeof(int8_t), 0, "i8", 0, {}},
TypeDef{sizeof(int16_t), 1, "i16", 0, {}},
TypeDef{sizeof(int32_t), 2, "i32", 0, {}},
TypeDef{sizeof(int64_t), 3, "i64", 0, {}},
TypeDef{sizeof(uint8_t), 4, "u8", 0, {}},
TypeDef{sizeof(uint16_t), 5, "u16", 0, {}},
TypeDef{sizeof(uint32_t), 6, "u32", 0, {}},
TypeDef{sizeof(uint64_t), 7, "u64", 0, {}},
TypeDef{sizeof(bool), 8, "b", 0, {}},
TypeDef{sizeof(float), 9, "f32", 0, {}},
TypeDef{sizeof(double), 10, "f64", 0, {}},
TypeDef{sizeof(char), 11, "str", 0, {}},
TypeDef{sizeof(Vec2), 2667033957, "Vec2", 2, {9, 9}},
TypeDef{sizeof(Vec3), 473740858, "Vec3", 3, {9, 9, 9}},
TypeDef{sizeof(Vec4), 2507696603, "Vec4", 4, {9, 9, 9, 9}},
TypeDef{sizeof(Mat3), 3364737048, "Mat3", 1, {9}},
TypeDef{sizeof(Mat4), 1650094019, "Mat4", 1, {9}},
TypeDef{sizeof(Transform), 4103530190, "Transform", 5, {16, 16, 13, 16, 13}},
TypeDef{sizeof(AssetHandle), 2609735487, "AssetHandle", 1, {6}},
TypeDef{sizeof(ModelHandle), 298089627, "ModelHandle", 2, {5, 18}},
TypeDef{sizeof(TextureHandle), 1633273761, "TextureHandle", 2, {5, 18}},
TypeDef{sizeof(PuzPos), 1834398141, "PuzPos", 2, {0, 0}},
TypeDef{sizeof(StaticPuzzleCard), 3413177578, "StaticPuzzleCard", 3, {0, 19, 20}},
TypeDef{sizeof(StaticPuzzleCardHandle), 1742502768, "StaticPuzzleCardHandle", 1, {5}},
TypeDef{sizeof(PuzzleVisualSettings), 4208425878, "PuzzleVisualSettings", 3, {14, 14, 14}},
TypeDef{sizeof(StaticPuzzleData), 423465540, "StaticPuzzleData", 2, {22, 24}},
TypeDef{sizeof(PuzzleCardStack), 53538532, "PuzzleCardStack", 3, {23, 4, 4}},
TypeDef{sizeof(PlacedPuzzleCard), 3555575973, "PlacedPuzzleCard", 4, {23, 21, 4, 8}},
TypeDef{sizeof(PuzzleData), 3349686056, "PuzzleData", 10, {5, 11, 4, 4, 6, 26, 27, 0, 6, 21}},
TypeDef{sizeof(SavedEntityRenderData), 3172756855, "SavedEntityRenderData", 7, {14, 14, 17, 1, 20, 19, 8}},
TypeDef{sizeof(int8_t), 0, "i8", 0, {}, {}},
TypeDef{sizeof(int16_t), 1, "i16", 0, {}, {}},
TypeDef{sizeof(int32_t), 2, "i32", 0, {}, {}},
TypeDef{sizeof(int64_t), 3, "i64", 0, {}, {}},
TypeDef{sizeof(uint8_t), 4, "u8", 0, {}, {}},
TypeDef{sizeof(uint16_t), 5, "u16", 0, {}, {}},
TypeDef{sizeof(uint32_t), 6, "u32", 0, {}, {}},
TypeDef{sizeof(uint64_t), 7, "u64", 0, {}, {}},
TypeDef{sizeof(bool), 8, "b", 0, {}, {}},
TypeDef{sizeof(float), 9, "f32", 0, {}, {}},
TypeDef{sizeof(double), 10, "f64", 0, {}, {}},
TypeDef{sizeof(char), 11, "str", 0, {}, {}},
TypeDef{sizeof(Vec2), 2667033957, "Vec2", 2, {9, 9}, {{0, 1}, {1, 1}}},
TypeDef{sizeof(Vec3), 473740858, "Vec3", 3, {9, 9, 9}, {{2, 1}, {3, 1}, {4, 1}}},
TypeDef{sizeof(Vec4), 2507696603, "Vec4", 4, {9, 9, 9, 9}, {{5, 1}, {6, 1}, {7, 1}, {8, 1}}},
TypeDef{sizeof(Mat3), 3364737048, "Mat3", 1, {9}, {{9, 1}}},
TypeDef{sizeof(Mat4), 1650094019, "Mat4", 1, {9}, {{10, 1}}},
TypeDef{sizeof(Transform), 4103530190, "Transform", 5, {16, 16, 13, 16, 13}, {{11, 1}, {12, 2}, {14, 8}, {22, 8}, {30, 5}}},
TypeDef{sizeof(AssetHandle), 2609735487, "AssetHandle", 1, {6}, {{35, 3}}},
TypeDef{sizeof(ModelHandle), 298089627, "ModelHandle", 2, {5, 18}, {{38, 8}, {46, 5}}},
TypeDef{sizeof(TextureHandle), 1633273761, "TextureHandle", 2, {5, 18}, {{51, 10}, {61, 5}}},
TypeDef{sizeof(PuzPos), 1834398141, "PuzPos", 2, {0, 0}, {{66, 1}, {67, 1}}},
TypeDef{sizeof(StaticPuzzleCard), 3413177578, "StaticPuzzleCard", 3, {0, 19, 20}, {{68, 8}, {76, 11}, {87, 18}}},
TypeDef{sizeof(StaticPuzzleCardHandle), 1742502768, "StaticPuzzleCardHandle", 1, {5}, {{105, 3}}},
TypeDef{sizeof(PuzzleVisualSettings), 2302077481, "PuzzleVisualSettings", 4, {14, 14, 13, 14}, {{108, 13}, {121, 12}, {133, 4}, {137, 16}}},
TypeDef{sizeof(StaticPuzzleData), 3618749873, "StaticPuzzleData", 2, {22, 24}, {{153, 5}, {158, 7}}},
TypeDef{sizeof(PuzzleCardStack), 53538532, "PuzzleCardStack", 3, {23, 4, 4}, {{165, 7}, {172, 17}, {189, 9}}},
TypeDef{sizeof(PlacedPuzzleCard), 3555575973, "PlacedPuzzleCard", 4, {23, 21, 4, 8}, {{198, 7}, {205, 8}, {213, 8}, {221, 8}}},
TypeDef{sizeof(PuzzleData), 3349686056, "PuzzleData", 10, {5, 11, 4, 4, 6, 26, 27, 0, 6, 21}, {{229, 2}, {231, 10}, {241, 10}, {251, 11}, {262, 18}, {280, 14}, {294, 11}, {305, 15}, {320, 17}, {337, 13}}},
TypeDef{sizeof(SavedEntityRenderData), 3172756855, "SavedEntityRenderData", 7, {14, 14, 17, 1, 20, 19, 8}, {{350, 9}, {359, 14}, {373, 2}, {375, 8}, {383, 7}, {390, 5}, {395, 7}}},
};
EnumDef EnumDefinitions[2]
{
EnumDef{sizeof(PuzzleElementType::Enum), 2983807453},
EnumDef{sizeof(EMaterial::Enum), 2024002654},
};
char MemberNameBuffer[64*64*64]{"xyxyzxyzwMMMMIPositionRotationScaleIdxModelIdxAssetTextureIdxAssetXYElementsModelHandleBoardTextureHandleIdxTileBaseColorTileDotColorTestDisabledCardTintCardsVisualsRefCardMaxAvailableCountUsedCountRefCardPositionRotationIsLockedIDPuzzleNameWidthTilesHeightTilesAvailableCardCountAvailableCardsPlacedCardsBackgroundTilesGoalPositionCountGoalPositionsBaseColorHighlightColorTFMaterialTextureModelVisible"};
};
constexpr MetadataTable Metadata;

View File

@@ -1,24 +1,13 @@
4 bytes: 4cc
File type idendifier
16 bytes: TypeInfoHeader
4 | 4 | 2 | 2 | 4
Version | Base Type Hash | Base Type Idx | Type Count | Type Data Size
// If base type hash matches, skip past type data (using type data size)
// and just load binary blob directly
20 bytes: TypeInfoHeader
4 | 4 | 2 | 2 | 4 | 4
Version | Base Type Hash | Base Type Idx | Type Count | Type Data Size | Member Data Size
TypeDataSize bytes: TypeDefs
// TODO: field table
name | array size
test | 1
a | 1
b | 1
c | 1
d | 32
MemberDataSize bytes: Member data names, indexed from TypeDef
// todo: enum table for upgrading strings?
xxx bytes: BaseType actual data
[blob]
xxx bytes: actual data, Load/Save with BaseType

Binary file not shown.

Binary file not shown.