new save format

This commit is contained in:
Asuro
2025-04-05 18:10:43 +02:00
parent ab5c8a489f
commit 158d59e09e
14 changed files with 509 additions and 191 deletions

View File

@@ -7,9 +7,9 @@ namespace Gen
struct Deserializer;
struct PuzzleElementType
{
static constexpr uint16_t EnumIdx = 0;
static constexpr int32_t EntryCount = 8;
static constexpr uint32_t Hash = 2024002654;
enum Enum : int32_t
enum Enum : uint8_t
{
None,
WaterIn,
@@ -56,8 +56,8 @@ namespace Gen
};
struct EMaterial
{
static constexpr uint16_t EnumIdx = 1;
static constexpr int32_t EntryCount = 2;
static constexpr uint32_t Hash = 2024002654;
enum Enum : int32_t
{
Default,
@@ -71,20 +71,20 @@ namespace Gen
};
struct Vec2
{
static constexpr uint32_t Hash = 2667033957;
static constexpr uint16_t TypeIdx = 12;
float x = {};
float y = {};
};
struct Vec3
{
static constexpr uint32_t Hash = 473740858;
static constexpr uint16_t TypeIdx = 13;
float x = {};
float y = {};
float z = {};
};
struct Vec4
{
static constexpr uint32_t Hash = 2507696603;
static constexpr uint16_t TypeIdx = 14;
float x = {};
float y = {};
float z = {};
@@ -92,7 +92,7 @@ namespace Gen
};
struct Mat3
{
static constexpr uint32_t Hash = 3364737048;
static constexpr uint16_t TypeIdx = 15;
float M[9] = {
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
@@ -101,7 +101,7 @@ namespace Gen
};
struct Mat4
{
static constexpr uint32_t Hash = 1650094019;
static constexpr uint16_t TypeIdx = 16;
float M[16] = {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
@@ -111,7 +111,7 @@ namespace Gen
};
struct Transform
{
static constexpr uint32_t Hash = 4103530190;
static constexpr uint16_t TypeIdx = 17;
Mat4 M = {};
Mat4 MI = {};
Vec3 Position = {};
@@ -120,62 +120,62 @@ namespace Gen
};
struct AssetHandle
{
static constexpr uint32_t Hash = 2609735487;
static constexpr uint16_t TypeIdx = 18;
uint32_t Idx = UINT32_MAX;
};
struct ModelHandle
{
static constexpr uint32_t Hash = 298089627;
static constexpr uint16_t TypeIdx = 19;
uint16_t ModelIdx = UINT16_MAX;
AssetHandle Asset = {};
};
struct TextureHandle
{
static constexpr uint32_t Hash = 1633273761;
static constexpr uint16_t TypeIdx = 20;
uint16_t TextureIdx = UINT16_MAX;
AssetHandle Asset = {};
};
struct PuzPos
{
static constexpr uint32_t Hash = 1834398141;
static constexpr uint16_t TypeIdx = 21;
int8_t X = {};
int8_t Y = {};
};
struct StaticPuzzleCard
{
static constexpr uint32_t Hash = 431895198;
static constexpr uint16_t TypeIdx = 22;
PuzzleElementType::Enum Elements[4] = {};
ModelHandle ModelHandle = {};
TextureHandle BoardTextureHandle = {};
};
struct StaticPuzzleCardHandle
{
static constexpr uint32_t Hash = 1742502768;
static constexpr uint16_t TypeIdx = 23;
uint16_t Idx = UINT16_MAX;
};
struct PuzzleVisualSettings
{
static constexpr uint32_t Hash = 4208425878;
static constexpr uint16_t TypeIdx = 24;
Vec4 TileBaseColor = {};
Vec4 TileDotColor = {};
Vec4 DisabledCardTint = {};
};
struct StaticPuzzleData
{
static constexpr uint32_t Hash = 1076634601;
static constexpr uint16_t TypeIdx = 25;
StaticPuzzleCard Cards[64] = {};
PuzzleVisualSettings Visuals = {};
};
struct PuzzleCardStack
{
static constexpr uint32_t Hash = 53538532;
static constexpr uint16_t TypeIdx = 26;
StaticPuzzleCardHandle RefCard = {};
uint8_t MaxAvailableCount = {};
uint8_t UsedCount = {};
};
struct PlacedPuzzleCard
{
static constexpr uint32_t Hash = 3555575973;
static constexpr uint16_t TypeIdx = 27;
StaticPuzzleCardHandle RefCard = {};
PuzPos Position = {};
uint8_t Rotation = {};
@@ -183,7 +183,7 @@ namespace Gen
};
struct PuzzleData
{
static constexpr uint32_t Hash = 657000000;
static constexpr uint16_t TypeIdx = 28;
uint16_t ID = {};
char PuzzleName[64] = {};
uint8_t WidthTiles = {};
@@ -197,7 +197,7 @@ namespace Gen
};
struct SavedEntityRenderData
{
static constexpr uint32_t Hash = 3172756855;
static constexpr uint16_t TypeIdx = 29;
Vec4 BaseColor = {};
Vec4 HighlightColor = {};
Transform TF = {};
@@ -210,6 +210,30 @@ namespace Gen
bool Load(PuzzleElementType::Enum* obj, uint32_t count, Deserializer& serializer);
bool Save(const EMaterial::Enum* obj, uint32_t count, Serializer& serializer);
bool Load(EMaterial::Enum* obj, uint32_t count, Deserializer& serializer);
bool Save(const int8_t* obj, uint32_t count, Serializer& serializer);
bool Load(int8_t* obj, uint32_t count, Deserializer& serializer);
bool Save(const int16_t* obj, uint32_t count, Serializer& serializer);
bool Load(int16_t* obj, uint32_t count, Deserializer& serializer);
bool Save(const int32_t* obj, uint32_t count, Serializer& serializer);
bool Load(int32_t* obj, uint32_t count, Deserializer& serializer);
bool Save(const int64_t* obj, uint32_t count, Serializer& serializer);
bool Load(int64_t* obj, uint32_t count, Deserializer& serializer);
bool Save(const uint8_t* obj, uint32_t count, Serializer& serializer);
bool Load(uint8_t* obj, uint32_t count, Deserializer& serializer);
bool Save(const uint16_t* obj, uint32_t count, Serializer& serializer);
bool Load(uint16_t* obj, uint32_t count, Deserializer& serializer);
bool Save(const uint32_t* obj, uint32_t count, Serializer& serializer);
bool Load(uint32_t* obj, uint32_t count, Deserializer& serializer);
bool Save(const uint64_t* obj, uint32_t count, Serializer& serializer);
bool Load(uint64_t* obj, uint32_t count, Deserializer& serializer);
bool Save(const bool* obj, uint32_t count, Serializer& serializer);
bool Load(bool* obj, uint32_t count, Deserializer& serializer);
bool Save(const float* obj, uint32_t count, Serializer& serializer);
bool Load(float* obj, uint32_t count, Deserializer& serializer);
bool Save(const double* obj, uint32_t count, Serializer& serializer);
bool Load(double* obj, uint32_t count, Deserializer& serializer);
bool Save(const char* obj, uint32_t count, Serializer& serializer);
bool Load(char* obj, uint32_t count, Deserializer& serializer);
bool Save(const Vec2* obj, uint32_t count, Serializer& serializer);
bool Load(Vec2* obj, uint32_t count, Deserializer& serializer);
bool Save(const Vec3* obj, uint32_t count, Serializer& serializer);
@@ -246,4 +270,65 @@ namespace Gen
bool Load(PuzzleData* obj, uint32_t count, Deserializer& serializer);
bool Save(const SavedEntityRenderData* obj, uint32_t count, Serializer& serializer);
bool Load(SavedEntityRenderData* obj, uint32_t count, Deserializer& serializer);
namespace Meta {
struct TypeDef
{
uint32_t Size = 0;
uint32_t Hash = 0;
char Name[64]{"Dummy"};
uint16_t ChildCount = 0;
uint16_t ChildIndices[64]{0};
};
struct EnumDef
{
uint32_t Size = 0;
uint32_t Hash = 0;
};
struct MetadataTable
{
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}},
};
EnumDef EnumDefinitions[2]
{
EnumDef{sizeof(PuzzleElementType::Enum), 2983807453},
EnumDef{sizeof(EMaterial::Enum), 2024002654},
};
};
constexpr MetadataTable Metadata;
}
}