slight entity rework (todo: memory corruption >.<)

This commit is contained in:
Asuro
2025-05-31 01:39:34 +02:00
parent 383c6f975b
commit 196d119338
16 changed files with 773 additions and 392 deletions

View File

@@ -6,7 +6,7 @@
#include "bgfx/bgfx.h" #include "bgfx/bgfx.h"
#include "rendering/Rendering.h" #include "rendering/Rendering.h"
#include <cstdint> #include <cstdint>
#include <vcruntime_typeinfo.h> #include <typeinfo>
#define ENTITY_HANDLE(X) \ #define ENTITY_HANDLE(X) \
struct X \ struct X \

View File

@@ -63,7 +63,6 @@ namespace Game
uint8_t DebugCardRotation = 0; uint8_t DebugCardRotation = 0;
bool ShortenLogFileNames = true; bool ShortenLogFileNames = true;
bool ShowStats = true; bool ShowStats = true;
bool ShowArenaUsage = false;
}; };
struct GameInstance struct GameInstance

View File

@@ -29,7 +29,12 @@ namespace Game
{ {
void EntityRenderData::Render(const Model* models, const Material* materials, const Texture* textures) void EntityRenderData::Render(const Model* models, const Material* materials, const Texture* textures)
{ {
if (DebugBreakOnRender) bx::debugBreak(); if (DebugBreakOnRender)
{
bx::debugBreak();
DebugBreakOnRender = false;
}
if (models == nullptr || materials == nullptr || textures == nullptr) return; if (models == nullptr || materials == nullptr || textures == nullptr) return;
if (!Gen::IsValid(ModelH) || MaterialHandle >= EMaterial::EntryCount) return; if (!Gen::IsValid(ModelH) || MaterialHandle >= EMaterial::EntryCount) return;
if (!Visible) return; if (!Visible) return;
@@ -201,7 +206,9 @@ namespace Game
} }
PuzzleUI.Setup(); PuzzleUI.Setup();
TabletHandle = UIQuads.New();
ReloadLevelEntities();
UpdatePlayerInputMode(); UpdatePlayerInputMode();
} }
@@ -272,18 +279,6 @@ namespace Game
UpdatePlayerInputMode(); UpdatePlayerInputMode();
} }
// UI Tablet
if (IsValid(TabletHandle))
{
auto& tablet = UIQuads.Get(TabletHandle);
tablet.EData.LoadFromSaved(player.Config.TabletBackgroundRenderData);
UpdateMatrix(player.PlayerCamTransform);
tablet.EData.Transform.Rotation = player.PlayerCamTransform.Rotation;
Rotate(tablet.EData.Transform, {0.5f * bx::kPi, 0.0f, 0.0f});
tablet.EData.Transform.Position =
player.PlayerCamTransform.Position + AxisForward(player.PlayerCamTransform.M) * 1.0f;
}
// Cubes // Cubes
for (uint16_t i = 0; i < Cubes.Count; ++i) for (uint16_t i = 0; i < Cubes.Count; ++i)
{ {
@@ -342,6 +337,7 @@ namespace Game
{ {
UIQuads.Render(models, materials, textures); UIQuads.Render(models, materials, textures);
} }
LevelEntities.Render(models, materials, textures);
} }
void Cube::Setup() void Cube::Setup()
@@ -440,4 +436,16 @@ namespace Game
} }
} }
} }
void Level::ReloadLevelEntities()
{
LevelEntities.Count = 0;
for (int32_t i = 0; i < BX_COUNTOF(BackgroundEntityHandles); ++i)
{
BackgroundEntityHandles[i] = LevelEntities.New();
auto& levelBgEntity = LevelEntities.Get(BackgroundEntityHandles[i]);
levelBgEntity.EData.LoadFromSaved(GetInstance().Player.Config.BackgroundLevelRenderData[i]);
}
}
} // namespace Game } // namespace Game

View File

@@ -1,9 +1,11 @@
#pragma once #pragma once
#include "../engine/Shared.h" #include "../engine/Shared.h"
#include "Entity.h"
#include "Puzzle.h" #include "Puzzle.h"
#include "UI.h" #include "UI.h"
#include "rendering/Rendering.h" #include "rendering/Rendering.h"
#include <bgfx/bgfx.h> #include <bgfx/bgfx.h>
#include <cstdint> #include <cstdint>
namespace Game namespace Game
@@ -35,7 +37,7 @@ namespace Game
EntityManager<LevelEntity, LevelEntityHandle, 64> LevelEntities; EntityManager<LevelEntity, LevelEntityHandle, 64> LevelEntities;
CubeHandle PlayerOutsideViewCube; CubeHandle PlayerOutsideViewCube;
UIQuadEntityHandle TabletHandle; LevelEntityHandle BackgroundEntityHandles[16];
public: public:
Gen::StaticPuzzleData PuzzleData; Gen::StaticPuzzleData PuzzleData;
@@ -46,5 +48,6 @@ namespace Game
void Setup(GameData& data); void Setup(GameData& data);
void Update(); void Update();
void Render(uint16_t ViewID, const Model* models, const Material* materials, const Texture* textures); void Render(uint16_t ViewID, const Model* models, const Material* materials, const Texture* textures);
void ReloadLevelEntities();
}; };
} // namespace Game } // namespace Game

View File

@@ -182,31 +182,18 @@ namespace Tools
return changed; return changed;
} }
void RenderDebugUI(Game::GameRendering& rendering) void RenderLogUI()
{ {
if (!rendering.SetupData.UseImgui) return;
auto& time = Game::GetInstance().Time; auto& time = Game::GetInstance().Time;
auto& shared = Game::GetShared();
auto& debug = Game::GetInstance().DebugData; auto& debug = Game::GetInstance().DebugData;
auto& level = Game::GetInstance().GameLevel;
auto& player = Game::GetInstance().Player;
if (rendering.UIVisible == Game::UIVisibilityState::Debug)
{
ZoneScopedN("DebugUI");
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
{
debug.DebugCardRotation++;
if (debug.DebugCardRotation >= 4) debug.DebugCardRotation = 0;
}
if (ImGui::Begin("Log")) if (ImGui::Begin("Log"))
{ {
ImGui::Checkbox("Shorten File Names", &debug.ShortenLogFileNames); ImGui::Checkbox("Shorten File Names", &debug.ShortenLogFileNames);
ImGui::BeginTable("tbl", ImGui::BeginTable("tbl",
4, 4,
ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable | ImGuiTableFlags_SizingFixedFit |
ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg); ImGuiTableFlags_RowBg);
ImGui::TableSetupColumn("Time", ImGuiTableColumnFlags_NoResize); ImGui::TableSetupColumn("Time", ImGuiTableColumnFlags_NoResize);
ImGui::TableSetupColumn("Log"); ImGui::TableSetupColumn("Log");
ImGui::TableSetupColumn("Line", ImGuiTableColumnFlags_NoResize); ImGui::TableSetupColumn("Line", ImGuiTableColumnFlags_NoResize);
@@ -260,6 +247,16 @@ namespace Tools
if (lineCount > 0) ImGui::PopStyleColor(2); if (lineCount > 0) ImGui::PopStyleColor(2);
} }
ImGui::End(); ImGui::End();
}
void RenderRenderSettingsUI(Game::GameRendering& rendering)
{
auto& time = Game::GetInstance().Time;
auto& shared = Game::GetShared();
auto& debug = Game::GetInstance().DebugData;
auto& level = Game::GetInstance().GameLevel;
auto& player = Game::GetInstance().Player;
if (ImGui::Begin("Rendering")) if (ImGui::Begin("Rendering"))
{ {
if (rendering.LastShaderLoadTime >= 0.0f) if (rendering.LastShaderLoadTime >= 0.0f)
@@ -297,26 +294,44 @@ namespace Tools
ImGui::Checkbox("Tests", &level.Tests.IsEnabled); ImGui::Checkbox("Tests", &level.Tests.IsEnabled);
ImGui::Checkbox("PuzzleTiles", &level.PuzzleTiles.IsEnabled); ImGui::Checkbox("PuzzleTiles", &level.PuzzleTiles.IsEnabled);
ImGui::Checkbox("UIQuads", &level.UIQuads.IsEnabled); ImGui::Checkbox("UIQuads", &level.UIQuads.IsEnabled);
ImGui::Checkbox("Level", &level.LevelEntities.IsEnabled);
ImGui::Separator(); ImGui::Separator();
ImGui::Text("Game Tablet"); bool uiconfigChanged = false;
bool bTabletChanged = false; if (ImGui::TreeNodeEx("Game Tablet"))
bTabletChanged |= Tools::EntityDataSettings(player.Config.TabletBackgroundRenderData); {
uiconfigChanged |= Tools::EntityDataSettings(player.Config.TabletBackgroundRenderData);
ImGui::Separator();
ImGui::Text("Status"); ImGui::Text("Status");
bTabletChanged |= Tools::EntityDataSettings(player.Config.TabletStatusRenderData); uiconfigChanged |= Tools::EntityDataSettings(player.Config.TabletStatusRenderData);
bTabletChanged |= Tools::TextureDropdown(player.Config.TabletStatusSolvedTexture, "Solved Texture"); uiconfigChanged |= Tools::TextureDropdown(player.Config.TabletStatusSolvedTexture, "Solved Texture");
bTabletChanged |= uiconfigChanged |=
Tools::TextureDropdown(player.Config.TabletStatusNotSolvedTexture, "Not Solved Texture"); Tools::TextureDropdown(player.Config.TabletStatusNotSolvedTexture, "Not Solved Texture");
ImGui::Separator();
ImGui::Text("Reset"); ImGui::Text("Reset");
bTabletChanged |= Tools::EntityDataSettings(player.Config.TabletResetRenderData); uiconfigChanged |= Tools::EntityDataSettings(player.Config.TabletResetRenderData);
if (bTabletChanged) ImGui::TreePop();
}
if (ImGui::TreeNodeEx("Background Level"))
{
for (int32_t i = 0; i < BX_COUNTOF(player.Config.BackgroundLevelRenderData); ++i)
{
if (i > 0) ImGui::Separator();
uiconfigChanged |= Tools::EntityDataSettings(player.Config.BackgroundLevelRenderData[i]);
}
ImGui::TreePop();
}
if (uiconfigChanged)
{ {
Serializer s; Serializer s;
s.Init("game/data/static/uiconfig.dat", "UICO"); s.Init("game/data/static/uiconfig.dat", "UICO");
s.WriteT(player.Config); s.WriteT(player.Config);
s.Finish(); s.Finish();
level.PuzzleUI.Reset(); level.PuzzleUI.Reset();
level.ReloadLevelEntities();
} }
ImGui::Separator(); ImGui::Separator();
@@ -337,8 +352,7 @@ namespace Tools
} }
else else
{ {
ImGui::Image( ImGui::Image(rendering.DitherTextures.PreviewTex.idx,
rendering.DitherTextures.PreviewTex.idx,
{(float)rendering.DitherTextures.DitherTexWH, {(float)rendering.DitherTextures.DitherTexWH,
(float)rendering.DitherTextures.DitherTexWH * rendering.DitherTextures.DitherTexDepth}); (float)rendering.DitherTextures.DitherTexWH * rendering.DitherTextures.DitherTexDepth});
} }
@@ -354,6 +368,10 @@ namespace Tools
ImGui::TextWrapped("%s", Game::GetShared().Dev.ShaderLog); ImGui::TextWrapped("%s", Game::GetShared().Dev.ShaderLog);
} }
ImGui::End(); ImGui::End();
}
void RenderTexturesUI(Game::GameRendering& rendering)
{
if (ImGui::Begin("Textures")) if (ImGui::Begin("Textures"))
{ {
if (ImGui::Button("Reload")) if (ImGui::Button("Reload"))
@@ -370,6 +388,13 @@ namespace Tools
} }
} }
ImGui::End(); ImGui::End();
}
void RenderPuzzlesUI()
{
auto& debug = Game::GetInstance().DebugData;
auto& level = Game::GetInstance().GameLevel;
if (ImGui::Begin("Puzzles")) if (ImGui::Begin("Puzzles"))
{ {
char nameBuf[64]{0}; char nameBuf[64]{0};
@@ -388,6 +413,7 @@ namespace Tools
} }
} }
ImGui::End(); ImGui::End();
if (debug.SelectedDebugLevel < BX_COUNTOF(level.Puzzles)) if (debug.SelectedDebugLevel < BX_COUNTOF(level.Puzzles))
{ {
if (!Puzzle::RenderDebugUI(level.Puzzles[debug.SelectedDebugLevel].Data)) if (!Puzzle::RenderDebugUI(level.Puzzles[debug.SelectedDebugLevel].Data))
@@ -395,6 +421,12 @@ namespace Tools
debug.SelectedDebugLevel = UINT16_MAX; debug.SelectedDebugLevel = UINT16_MAX;
} }
} }
}
void RenderCardsUI(Game::GameRendering& rendering)
{
auto& debug = Game::GetInstance().DebugData;
if (ImGui::Begin("Cards")) if (ImGui::Begin("Cards"))
{ {
Gen::StaticPuzzleData& staticData = Puzzle::GetStaticPuzzleData(); Gen::StaticPuzzleData& staticData = Puzzle::GetStaticPuzzleData();
@@ -479,32 +511,26 @@ namespace Tools
} }
} }
ImGui::End(); ImGui::End();
if (ImGui::Begin("Debug"))
{
ImGui::Checkbox("Arenas", &debug.ShowArenaUsage);
ImGui::Checkbox("ImGui Demo", &debug.ShowImguiDemo);
ImGui::SliderFloat("Font Scale", &ImGui::GetIO().FontGlobalScale, 0.5f, 4.0f);
} }
ImGui::End();
if (debug.ShowArenaUsage) void RenderEntitiesUI()
{ {
if (ImGui::Begin("Arenas", &debug.ShowArenaUsage)) auto& level = Game::GetInstance().GameLevel;
{
ProgressBar("Permanent", shared.Game.PermanentArena.Used, shared.Game.PermanentArena.MaxSize);
ProgressBar("Entity", shared.Game.EntityArena.Used, shared.Game.EntityArena.MaxSize);
ProgressBar("Transient", shared.Game.TransientArena.Used, shared.Game.TransientArena.MaxSize);
}
ImGui::End();
}
if (ImGui::Begin("Entities")) if (ImGui::Begin("Entities"))
{ {
ImGui::Text("UIQuads"); if (ImGui::TreeNodeEx("UIQuads"))
{
ImGui::Text("Count: %u", level.UIQuads.Count);
for (uint16_t i = 0; i < level.UIQuads.Count; ++i) for (uint16_t i = 0; i < level.UIQuads.Count; ++i)
{ {
ImGui::Separator();
ImGui::PushID(i); ImGui::PushID(i);
ImGui::Text("%u", i);
ImGui::SameLine();
auto& quad = level.UIQuads.Get({i}); auto& quad = level.UIQuads.Get({i});
ImGui::Checkbox("Debug Break on Render", &quad.EData.DebugBreakOnRender);
ImGui::SameLine();
ImGui::Checkbox("Visible", &quad.EData.Visible); ImGui::Checkbox("Visible", &quad.EData.Visible);
TextureDropdown(quad.EData.TextureHandle); TextureDropdown(quad.EData.TextureHandle);
MaterialDropdown(quad.EData.MaterialHandle); MaterialDropdown(quad.EData.MaterialHandle);
@@ -512,9 +538,37 @@ namespace Tools
ImGui::DragFloat3("UI Pos", &quad.UIPos.x); ImGui::DragFloat3("UI Pos", &quad.UIPos.x);
ImGui::PopID(); ImGui::PopID();
} }
ImGui::TreePop();
}
if (ImGui::TreeNodeEx("Level"))
{
ImGui::Text("Count: %u", level.LevelEntities.Count);
for (uint16_t i = 0; i < level.LevelEntities.Count; ++i)
{
ImGui::Separator();
ImGui::PushID(i);
ImGui::Text("%u", i);
ImGui::SameLine();
auto& levelEnt = level.LevelEntities.Get({i});
ImGui::Checkbox("Debug Break on Render", &levelEnt.EData.DebugBreakOnRender);
ImGui::SameLine();
ImGui::Checkbox("Visible", &levelEnt.EData.Visible);
TextureDropdown(levelEnt.EData.TextureHandle);
MaterialDropdown(levelEnt.EData.MaterialHandle);
ImGui::DragFloat3("Pos", &levelEnt.EData.Transform.Position.x);
ImGui::PopID();
}
ImGui::TreePop();
}
} }
ImGui::End(); ImGui::End();
} }
void RenderStatsUI()
{
auto& time = Game::GetInstance().Time;
auto& debug = Game::GetInstance().DebugData;
if (debug.ShowStats) if (debug.ShowStats)
{ {
ImGui::SetNextWindowPos({0, 0}); ImGui::SetNextWindowPos({0, 0});
@@ -563,6 +617,48 @@ namespace Tools
ImGui::End(); ImGui::End();
} }
} }
void RenderDebugUI(Game::GameRendering& rendering)
{
if (!rendering.SetupData.UseImgui) return;
ZoneScopedN("DebugUI");
auto& time = Game::GetInstance().Time;
auto& shared = Game::GetShared();
auto& debug = Game::GetInstance().DebugData;
auto& level = Game::GetInstance().GameLevel;
auto& player = Game::GetInstance().Player;
if (rendering.UIVisible == Game::UIVisibilityState::Debug)
{
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
{
debug.DebugCardRotation++;
if (debug.DebugCardRotation >= 4) debug.DebugCardRotation = 0;
}
if (ImGui::Begin("Debug"))
{
ImGui::Checkbox("ImGui Demo", &debug.ShowImguiDemo);
ImGui::SliderFloat("Font Scale", &ImGui::GetIO().FontGlobalScale, 0.5f, 4.0f);
ImGui::Separator();
ImGui::Text("Arenas");
ProgressBar("Permanent", shared.Game.PermanentArena.Used, shared.Game.PermanentArena.MaxSize);
ProgressBar("Entity", shared.Game.EntityArena.Used, shared.Game.EntityArena.MaxSize);
ProgressBar("Transient", shared.Game.TransientArena.Used, shared.Game.TransientArena.MaxSize);
}
ImGui::End();
RenderLogUI();
RenderRenderSettingsUI(rendering);
RenderTexturesUI(rendering);
RenderPuzzlesUI();
RenderCardsUI(rendering);
RenderEntitiesUI();
}
RenderStatsUI();
}
void MeasureFrameEnd() void MeasureFrameEnd()
{ {
FrameTimes[FrameTimeIdx] = bx::getHPCounter(); FrameTimes[FrameTimeIdx] = bx::getHPCounter();

View File

@@ -1,5 +1,6 @@
#include "UI.h" #include "UI.h"
#include "Entity.h"
#include "Gen.h" #include "Gen.h"
#include "Global.h" #include "Global.h"
#include "Input.h" #include "Input.h"
@@ -18,10 +19,16 @@ namespace
namespace Game namespace Game
{ {
UIQuadEntityHandle NewQuad(UIQuadEntityManager& manager, const Gen::SavedEntityRenderData& loadData) UIQuadEntityHandle NewQuad(UIQuadEntityManager& manager,
const Gen::SavedEntityRenderData& loadData,
UIQuadEntityHandle oldHandle)
{ {
UIQuadEntityHandle h = manager.New(); UIQuadEntityHandle h = oldHandle;
if (!IsValid(h))
{
h = manager.New();
if (!IsValid(h)) return h; if (!IsValid(h)) return h;
}
UIQuadEntity& entity = manager.Get(h); UIQuadEntity& entity = manager.Get(h);
entity.EData.LoadFromSaved(loadData); entity.EData.LoadFromSaved(loadData);
@@ -85,8 +92,11 @@ namespace Game
void WorldPuzzleUI::Setup() void WorldPuzzleUI::Setup()
{ {
auto& level = GetInstance().GameLevel; auto& level = GetInstance().GameLevel;
SolvedQuad = NewQuad(level.UIQuads, GetInstance().Player.Config.TabletStatusRenderData); auto& player = GetInstance().Player;
ResetQuad = NewQuad(level.UIQuads, GetInstance().Player.Config.TabletResetRenderData);
TabletHandle = NewQuad(level.UIQuads, player.Config.TabletBackgroundRenderData);
SolvedQuad = NewQuad(level.UIQuads, player.Config.TabletStatusRenderData);
ResetQuad = NewQuad(level.UIQuads, player.Config.TabletResetRenderData);
for (int32_t i = 0; i < Puzzle::Config::MaxCardsInPuzzle; ++i) for (int32_t i = 0; i < Puzzle::Config::MaxCardsInPuzzle; ++i)
{ {
@@ -247,15 +257,6 @@ namespace Game
Vec3 boardTilePos = boardPos / UICardOffset; Vec3 boardTilePos = boardPos / UICardOffset;
int32_t xPos = (int32_t)bx::round(boardTilePos.x); int32_t xPos = (int32_t)bx::round(boardTilePos.x);
int32_t yPos = (int32_t)bx::round(boardTilePos.y); int32_t yPos = (int32_t)bx::round(boardTilePos.y);
LOG("boardPos: %f %f %f, offset: %f %f %f, xy: %i %i",
boardPos.x,
boardPos.y,
boardPos.z,
boardOffset.x,
boardOffset.y,
boardOffset.z,
xPos,
yPos);
Gen::PuzPos srcCardPos = {(int8_t)DraggedCard.X, (int8_t)DraggedCard.Y}; Gen::PuzPos srcCardPos = {(int8_t)DraggedCard.X, (int8_t)DraggedCard.Y};
Gen::PlacedPuzzleCard& srcCard = Gen::PlacedPuzzleCard& srcCard =
Data.PlacedCards[srcCardPos.Y * Puzzle::Config::MaxPuzzleSizeCards + srcCardPos.X]; Data.PlacedCards[srcCardPos.Y * Puzzle::Config::MaxPuzzleSizeCards + srcCardPos.X];
@@ -311,19 +312,31 @@ namespace Game
void WorldPuzzleUI::Update(Gen::PuzzleData& Data, bool IsPuzzleSolved) void WorldPuzzleUI::Update(Gen::PuzzleData& Data, bool IsPuzzleSolved)
{ {
auto& level = GetInstance().GameLevel; auto& level = GetInstance().GameLevel;
auto& player = GetInstance().Player;
Transform& camTransform = GetInstance().Player.PlayerCamTransform; Transform& camTransform = player.PlayerCamTransform;
UpdateMatrix(camTransform); UpdateMatrix(camTransform);
StaticData.UITransform = level.UIQuads.Get(level.TabletHandle).EData.Transform; // UI Tablet
if (IsValid(TabletHandle))
{
auto& tablet = level.UIQuads.Get(TabletHandle);
tablet.EData.Transform.Rotation = camTransform.Rotation;
Rotate(tablet.EData.Transform, {0.5f * bx::kPi, 0.0f, 0.0f});
tablet.EData.Transform.Position = camTransform.Position + AxisForward(camTransform.M) * 1.0f;
StaticData.UITransform = tablet.EData.Transform;
tablet.EData.Transform.Position += {0.0f, 0.0f, 0.01f};
}
StaticData.UITransform.Rotation = camTransform.Rotation; StaticData.UITransform.Rotation = camTransform.Rotation;
StaticData.ZAxis = AxisForward(StaticData.UITransform.M); StaticData.ZAxis = AxisForward(StaticData.UITransform.M);
StaticData.UITransform.Position += StaticData.ZAxis * -0.01f; StaticData.UITransform.Position += StaticData.ZAxis * -0.01f;
StaticData.MousePosWorld = GetMousePosWorld(); StaticData.MousePosWorld = GetMousePosWorld();
// TODO: disable warning & check if parentheses make sense like this // NOLINTBEGIN
Vec2 uiOffset = Vec2{static_cast<float>(Data.WidthTiles / Puzzle::Config::CardSize) - 1, Vec2 uiOffset = Vec2{static_cast<float>(Data.WidthTiles / Puzzle::Config::CardSize - 1),
static_cast<float>(Data.HeightTiles / Puzzle::Config::CardSize) - 1}; static_cast<float>(Data.HeightTiles / Puzzle::Config::CardSize - 1)};
// NOLINTEND
uiOffset *= -UICardOffset * 0.5f; uiOffset *= -UICardOffset * 0.5f;
Transform tileOriginTransform = StaticData.UITransform; Transform tileOriginTransform = StaticData.UITransform;
@@ -354,5 +367,9 @@ namespace Game
void WorldPuzzleUI::Reset() void WorldPuzzleUI::Reset()
{ {
auto& level = GetInstance().GameLevel; auto& level = GetInstance().GameLevel;
auto& config = GetInstance().Player.Config;
TabletHandle = NewQuad(level.UIQuads, config.TabletBackgroundRenderData, TabletHandle);
SolvedQuad = NewQuad(level.UIQuads, config.TabletStatusRenderData, SolvedQuad);
ResetQuad = NewQuad(level.UIQuads, config.TabletResetRenderData, ResetQuad);
} }
} // namespace Game } // namespace Game

View File

@@ -19,6 +19,7 @@ namespace Game
static constexpr float UICardOffset = 2.1f * UICardScale; static constexpr float UICardOffset = 2.1f * UICardScale;
static constexpr int32_t UIAvailableCardMaxStackPreview = 3; static constexpr int32_t UIAvailableCardMaxStackPreview = 3;
UIQuadEntityHandle TabletHandle;
UIQuadEntityHandle SolvedQuad; UIQuadEntityHandle SolvedQuad;
UIQuadEntityHandle ResetQuad; UIQuadEntityHandle ResetQuad;
@@ -34,7 +35,9 @@ namespace Game
void Reset(); void Reset();
}; };
UIQuadEntityHandle NewQuad(UIQuadEntityManager& manager, const Gen::SavedEntityRenderData& loadData); UIQuadEntityHandle NewQuad(UIQuadEntityManager& manager,
const Gen::SavedEntityRenderData& loadData,
UIQuadEntityHandle oldHandle = {});
void UpdateQuad(UIQuadEntityManager& manager, UIQuadEntityHandle handle); void UpdateQuad(UIQuadEntityManager& manager, UIQuadEntityHandle handle);
Gen::Vec3 GetMousePosWorld(); Gen::Vec3 GetMousePosWorld();
bool IsQuadHovered(Gen::Transform& quadTransform, Gen::Vec3 mousePosWorld, Gen::Vec3& outQuadPlaneIntersectPos); bool IsQuadHovered(Gen::Transform& quadTransform, Gen::Vec3 mousePosWorld, Gen::Vec3& outQuadPlaneIntersectPos);

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -180,4 +180,5 @@ type SavedPlayerConfig
TextureHandle TabletStatusNotSolvedTexture TextureHandle TabletStatusNotSolvedTexture
TextureHandle TabletStatusSolvedTexture TextureHandle TabletStatusSolvedTexture
SavedEntityRenderData TabletResetRenderData SavedEntityRenderData TabletResetRenderData
SavedEntityRenderData BackgroundLevelRenderData Arr(16)
} }

View File

@@ -363,13 +363,19 @@ namespace Gen
if (bx::strCmp(memberName, "x") == 0) if (bx::strCmp(memberName, "x") == 0)
{ {
auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "y") == 0) if (bx::strCmp(memberName, "y") == 0)
{ {
auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -468,19 +474,28 @@ namespace Gen
if (bx::strCmp(memberName, "x") == 0) if (bx::strCmp(memberName, "x") == 0)
{ {
auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "y") == 0) if (bx::strCmp(memberName, "y") == 0)
{ {
auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "z") == 0) if (bx::strCmp(memberName, "z") == 0)
{ {
auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -585,25 +600,37 @@ namespace Gen
if (bx::strCmp(memberName, "x") == 0) if (bx::strCmp(memberName, "x") == 0)
{ {
auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "y") == 0) if (bx::strCmp(memberName, "y") == 0)
{ {
auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "z") == 0) if (bx::strCmp(memberName, "z") == 0)
{ {
auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "w") == 0) if (bx::strCmp(memberName, "w") == 0)
{ {
auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -690,7 +717,10 @@ namespace Gen
if (bx::strCmp(memberName, "M") == 0) if (bx::strCmp(memberName, "M") == 0)
{ {
auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 9, serializer) && isOk; uint16_t wantedCount = 9;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -777,7 +807,10 @@ namespace Gen
if (bx::strCmp(memberName, "M") == 0) if (bx::strCmp(memberName, "M") == 0)
{ {
auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<float*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 16, serializer) && isOk; uint16_t wantedCount = 16;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -888,31 +921,46 @@ namespace Gen
if (bx::strCmp(memberName, "M") == 0) if (bx::strCmp(memberName, "M") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Mat4*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Mat4*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "MI") == 0) if (bx::strCmp(memberName, "MI") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Mat4*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Mat4*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Position") == 0) if (bx::strCmp(memberName, "Position") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Vec3*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Vec3*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Rotation") == 0) if (bx::strCmp(memberName, "Rotation") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Mat4*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Mat4*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Scale") == 0) if (bx::strCmp(memberName, "Scale") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Vec3*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Vec3*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -999,7 +1047,10 @@ namespace Gen
if (bx::strCmp(memberName, "Idx") == 0) if (bx::strCmp(memberName, "Idx") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint32_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint32_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -1092,13 +1143,19 @@ namespace Gen
if (bx::strCmp(memberName, "ModelIdx") == 0) if (bx::strCmp(memberName, "ModelIdx") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint16_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint16_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Asset") == 0) if (bx::strCmp(memberName, "Asset") == 0)
{ {
auto* fieldPtr = reinterpret_cast<AssetHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<AssetHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -1191,13 +1248,19 @@ namespace Gen
if (bx::strCmp(memberName, "TextureIdx") == 0) if (bx::strCmp(memberName, "TextureIdx") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint16_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint16_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Asset") == 0) if (bx::strCmp(memberName, "Asset") == 0)
{ {
auto* fieldPtr = reinterpret_cast<AssetHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<AssetHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -1290,13 +1353,19 @@ namespace Gen
if (bx::strCmp(memberName, "X") == 0) if (bx::strCmp(memberName, "X") == 0)
{ {
auto* fieldPtr = reinterpret_cast<int8_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<int8_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Y") == 0) if (bx::strCmp(memberName, "Y") == 0)
{ {
auto* fieldPtr = reinterpret_cast<int8_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<int8_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -1389,13 +1458,19 @@ namespace Gen
if (bx::strCmp(memberName, "Model") == 0) if (bx::strCmp(memberName, "Model") == 0)
{ {
auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "ConnectionDirection") == 0) if (bx::strCmp(memberName, "ConnectionDirection") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -1530,55 +1605,82 @@ namespace Gen
if (bx::strCmp(memberName, "Elements") == 0) if (bx::strCmp(memberName, "Elements") == 0)
{ {
auto* fieldPtr = reinterpret_cast<PuzzleElementType::Enum*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<PuzzleElementType::Enum*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 4, serializer) && isOk; uint16_t wantedCount = 4;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "BaseModelHandle") == 0) if (bx::strCmp(memberName, "BaseModelHandle") == 0)
{ {
auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "NorthCoverHandle") == 0) if (bx::strCmp(memberName, "NorthCoverHandle") == 0)
{ {
auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "EastCoverHandle") == 0) if (bx::strCmp(memberName, "EastCoverHandle") == 0)
{ {
auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "SouthCoverHandle") == 0) if (bx::strCmp(memberName, "SouthCoverHandle") == 0)
{ {
auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "WestCoverHandle") == 0) if (bx::strCmp(memberName, "WestCoverHandle") == 0)
{ {
auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Sockets") == 0) if (bx::strCmp(memberName, "Sockets") == 0)
{ {
auto* fieldPtr = reinterpret_cast<CardSocket*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<CardSocket*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 16, serializer) && isOk; uint16_t wantedCount = 16;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "ModelTextureHandle") == 0) if (bx::strCmp(memberName, "ModelTextureHandle") == 0)
{ {
auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "BoardTextureHandle") == 0) if (bx::strCmp(memberName, "BoardTextureHandle") == 0)
{ {
auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -1665,7 +1767,10 @@ namespace Gen
if (bx::strCmp(memberName, "Idx") == 0) if (bx::strCmp(memberName, "Idx") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint16_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint16_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -1770,25 +1875,37 @@ namespace Gen
if (bx::strCmp(memberName, "TileBaseColor") == 0) if (bx::strCmp(memberName, "TileBaseColor") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Vec4*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Vec4*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "TileDotColor") == 0) if (bx::strCmp(memberName, "TileDotColor") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Vec4*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Vec4*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Test") == 0) if (bx::strCmp(memberName, "Test") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Vec3*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Vec3*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "DisabledCardTint") == 0) if (bx::strCmp(memberName, "DisabledCardTint") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Vec4*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Vec4*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -1881,13 +1998,19 @@ namespace Gen
if (bx::strCmp(memberName, "Cards") == 0) if (bx::strCmp(memberName, "Cards") == 0)
{ {
auto* fieldPtr = reinterpret_cast<StaticPuzzleCard*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<StaticPuzzleCard*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 64, serializer) && isOk; uint16_t wantedCount = 64;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Visuals") == 0) if (bx::strCmp(memberName, "Visuals") == 0)
{ {
auto* fieldPtr = reinterpret_cast<PuzzleVisualSettings*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<PuzzleVisualSettings*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -1986,19 +2109,28 @@ namespace Gen
if (bx::strCmp(memberName, "RefCard") == 0) if (bx::strCmp(memberName, "RefCard") == 0)
{ {
auto* fieldPtr = reinterpret_cast<StaticPuzzleCardHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<StaticPuzzleCardHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "MaxAvailableCount") == 0) if (bx::strCmp(memberName, "MaxAvailableCount") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "UsedCount") == 0) if (bx::strCmp(memberName, "UsedCount") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -2103,25 +2235,37 @@ namespace Gen
if (bx::strCmp(memberName, "RefCard") == 0) if (bx::strCmp(memberName, "RefCard") == 0)
{ {
auto* fieldPtr = reinterpret_cast<StaticPuzzleCardHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<StaticPuzzleCardHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Position") == 0) if (bx::strCmp(memberName, "Position") == 0)
{ {
auto* fieldPtr = reinterpret_cast<PuzPos*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<PuzPos*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Rotation") == 0) if (bx::strCmp(memberName, "Rotation") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Flags") == 0) if (bx::strCmp(memberName, "Flags") == 0)
{ {
auto* fieldPtr = reinterpret_cast<PlacedPuzzleCardFlags::Enum*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<PlacedPuzzleCardFlags::Enum*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -2268,67 +2412,100 @@ namespace Gen
if (bx::strCmp(memberName, "ID") == 0) if (bx::strCmp(memberName, "ID") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint16_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint16_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "PuzzleName") == 0) if (bx::strCmp(memberName, "PuzzleName") == 0)
{ {
auto* fieldPtr = reinterpret_cast<char*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<char*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 64, serializer) && isOk; uint16_t wantedCount = 64;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "WidthTiles") == 0) if (bx::strCmp(memberName, "WidthTiles") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "HeightTiles") == 0) if (bx::strCmp(memberName, "HeightTiles") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint8_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "AvailableCardCount") == 0) if (bx::strCmp(memberName, "AvailableCardCount") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint32_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint32_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "AvailableCards") == 0) if (bx::strCmp(memberName, "AvailableCards") == 0)
{ {
auto* fieldPtr = reinterpret_cast<PuzzleCardStack*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<PuzzleCardStack*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 16, serializer) && isOk; uint16_t wantedCount = 16;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "PlacedCards") == 0) if (bx::strCmp(memberName, "PlacedCards") == 0)
{ {
auto* fieldPtr = reinterpret_cast<PlacedPuzzleCard*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<PlacedPuzzleCard*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 256, serializer) && isOk; uint16_t wantedCount = 256;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "InitialPlacedCards") == 0) if (bx::strCmp(memberName, "InitialPlacedCards") == 0)
{ {
auto* fieldPtr = reinterpret_cast<PlacedPuzzleCard*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<PlacedPuzzleCard*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 256, serializer) && isOk; uint16_t wantedCount = 256;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "BackgroundTiles") == 0) if (bx::strCmp(memberName, "BackgroundTiles") == 0)
{ {
auto* fieldPtr = reinterpret_cast<PuzzleElementType::Enum*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<PuzzleElementType::Enum*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1024, serializer) && isOk; uint16_t wantedCount = 1024;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "GoalPositionCount") == 0) if (bx::strCmp(memberName, "GoalPositionCount") == 0)
{ {
auto* fieldPtr = reinterpret_cast<uint32_t*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<uint32_t*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "GoalPositions") == 0) if (bx::strCmp(memberName, "GoalPositions") == 0)
{ {
auto* fieldPtr = reinterpret_cast<PuzPos*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<PuzPos*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 16, serializer) && isOk; uint16_t wantedCount = 16;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -2451,43 +2628,64 @@ namespace Gen
if (bx::strCmp(memberName, "BaseColor") == 0) if (bx::strCmp(memberName, "BaseColor") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Vec4*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Vec4*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "HighlightColor") == 0) if (bx::strCmp(memberName, "HighlightColor") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Vec4*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Vec4*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "TF") == 0) if (bx::strCmp(memberName, "TF") == 0)
{ {
auto* fieldPtr = reinterpret_cast<Transform*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<Transform*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Material") == 0) if (bx::strCmp(memberName, "Material") == 0)
{ {
auto* fieldPtr = reinterpret_cast<EMaterial::Enum*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<EMaterial::Enum*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Texture") == 0) if (bx::strCmp(memberName, "Texture") == 0)
{ {
auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Model") == 0) if (bx::strCmp(memberName, "Model") == 0)
{ {
auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "Visible") == 0) if (bx::strCmp(memberName, "Visible") == 0)
{ {
auto* fieldPtr = reinterpret_cast<bool*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<bool*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);
@@ -2506,6 +2704,7 @@ namespace Gen
isOk = Save(&obj[i].TabletStatusNotSolvedTexture, 1, serializer) && isOk; isOk = Save(&obj[i].TabletStatusNotSolvedTexture, 1, serializer) && isOk;
isOk = Save(&obj[i].TabletStatusSolvedTexture, 1, serializer) && isOk; isOk = Save(&obj[i].TabletStatusSolvedTexture, 1, serializer) && isOk;
isOk = Save(&obj[i].TabletResetRenderData, 1, serializer) && isOk; isOk = Save(&obj[i].TabletResetRenderData, 1, serializer) && isOk;
isOk = Save(obj[i].BackgroundLevelRenderData, 16, serializer) && isOk;
} }
return isOk; return isOk;
} }
@@ -2527,6 +2726,7 @@ namespace Gen
isOk = Load(&obj[i].TabletStatusNotSolvedTexture, 1, serializer) && isOk; isOk = Load(&obj[i].TabletStatusNotSolvedTexture, 1, serializer) && isOk;
isOk = Load(&obj[i].TabletStatusSolvedTexture, 1, serializer) && isOk; isOk = Load(&obj[i].TabletStatusSolvedTexture, 1, serializer) && isOk;
isOk = Load(&obj[i].TabletResetRenderData, 1, serializer) && isOk; isOk = Load(&obj[i].TabletResetRenderData, 1, serializer) && isOk;
isOk = Load(obj[i].BackgroundLevelRenderData, 16, serializer) && isOk;
} }
// if we're not ok here, something went really wrong // if we're not ok here, something went really wrong
assert(isOk); assert(isOk);
@@ -2575,6 +2775,10 @@ namespace Gen
{ {
WriteDestinations[i] = offsetof(SavedPlayerConfig, TabletResetRenderData); WriteDestinations[i] = offsetof(SavedPlayerConfig, TabletResetRenderData);
} }
if (bx::strCmp(memberName, "BackgroundLevelRenderData") == 0 && bx::strCmp(memberTypeName, "SavedEntityRenderData") == 0)
{
WriteDestinations[i] = offsetof(SavedPlayerConfig, BackgroundLevelRenderData);
}
} }
// Start reading in file order, skipping things that we don't know by name and type // Start reading in file order, skipping things that we don't know by name and type
@@ -2598,31 +2802,55 @@ namespace Gen
if (bx::strCmp(memberName, "TabletBackgroundRenderData") == 0) if (bx::strCmp(memberName, "TabletBackgroundRenderData") == 0)
{ {
auto* fieldPtr = reinterpret_cast<SavedEntityRenderData*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<SavedEntityRenderData*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "TabletStatusRenderData") == 0) if (bx::strCmp(memberName, "TabletStatusRenderData") == 0)
{ {
auto* fieldPtr = reinterpret_cast<SavedEntityRenderData*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<SavedEntityRenderData*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "TabletStatusNotSolvedTexture") == 0) if (bx::strCmp(memberName, "TabletStatusNotSolvedTexture") == 0)
{ {
auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "TabletStatusSolvedTexture") == 0) if (bx::strCmp(memberName, "TabletStatusSolvedTexture") == 0)
{ {
auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
if (bx::strCmp(memberName, "TabletResetRenderData") == 0) if (bx::strCmp(memberName, "TabletResetRenderData") == 0)
{ {
auto* fieldPtr = reinterpret_cast<SavedEntityRenderData*>(objBasePtr + WriteDestinations[j]); auto* fieldPtr = reinterpret_cast<SavedEntityRenderData*>(objBasePtr + WriteDestinations[j]);
isOk = Load(fieldPtr, 1, serializer) && isOk; uint16_t wantedCount = 1;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue;
}
if (bx::strCmp(memberName, "BackgroundLevelRenderData") == 0)
{
auto* fieldPtr = reinterpret_cast<SavedEntityRenderData*>(objBasePtr + WriteDestinations[j]);
uint16_t wantedCount = 16;
uint16_t existingCount = matchedDef.ChildArraySizes[j];
isOk = Load(fieldPtr, bx::min(wantedCount, existingCount), serializer) && isOk;
if (existingCount > wantedCount) serializer.Skip((existingCount - wantedCount) * childDef.Size);
continue; continue;
} }
assert(false); assert(false);

View File

@@ -259,6 +259,7 @@ namespace Gen
TextureHandle TabletStatusNotSolvedTexture = {}; TextureHandle TabletStatusNotSolvedTexture = {};
TextureHandle TabletStatusSolvedTexture = {}; TextureHandle TabletStatusSolvedTexture = {};
SavedEntityRenderData TabletResetRenderData = {}; SavedEntityRenderData TabletResetRenderData = {};
SavedEntityRenderData BackgroundLevelRenderData[16] = {};
}; };
bool Save(const PuzzleElementType::Enum* obj, uint32_t count, Serializer& serializer); bool Save(const PuzzleElementType::Enum* obj, uint32_t count, Serializer& serializer);
bool Load(PuzzleElementType::Enum* obj, uint32_t count, Deserializer& serializer); bool Load(PuzzleElementType::Enum* obj, uint32_t count, Deserializer& serializer);
@@ -386,12 +387,12 @@ namespace Gen
TypeDef{sizeof(PlacedPuzzleCard), 838818025, "PlacedPuzzleCard", 4, {24, 21, 4, 33}, {0, 0, 0, 0}, {{313, 7}, {320, 8}, {328, 8}, {336, 5}}}, TypeDef{sizeof(PlacedPuzzleCard), 838818025, "PlacedPuzzleCard", 4, {24, 21, 4, 33}, {0, 0, 0, 0}, {{313, 7}, {320, 8}, {328, 8}, {336, 5}}},
TypeDef{sizeof(PuzzleData), 1562434765, "PuzzleData", 11, {5, 11, 4, 4, 6, 27, 28, 28, 32, 6, 21}, {0, 64, 0, 0, 0, 16, 256, 256, 1024, 0, 16}, {{341, 2}, {343, 10}, {353, 10}, {363, 11}, {374, 18}, {392, 14}, {406, 11}, {417, 18}, {435, 15}, {450, 17}, {467, 13}}}, TypeDef{sizeof(PuzzleData), 1562434765, "PuzzleData", 11, {5, 11, 4, 4, 6, 27, 28, 28, 32, 6, 21}, {0, 64, 0, 0, 0, 16, 256, 256, 1024, 0, 16}, {{341, 2}, {343, 10}, {353, 10}, {363, 11}, {374, 18}, {392, 14}, {406, 11}, {417, 18}, {435, 15}, {450, 17}, {467, 13}}},
TypeDef{sizeof(SavedEntityRenderData), 3172756855, "SavedEntityRenderData", 7, {14, 14, 17, 34, 20, 19, 8}, {0, 0, 0, 0, 0, 0, 0}, {{480, 9}, {489, 14}, {503, 2}, {505, 8}, {513, 7}, {520, 5}, {525, 7}}}, TypeDef{sizeof(SavedEntityRenderData), 3172756855, "SavedEntityRenderData", 7, {14, 14, 17, 34, 20, 19, 8}, {0, 0, 0, 0, 0, 0, 0}, {{480, 9}, {489, 14}, {503, 2}, {505, 8}, {513, 7}, {520, 5}, {525, 7}}},
TypeDef{sizeof(SavedPlayerConfig), 3685229621, "SavedPlayerConfig", 5, {30, 30, 20, 20, 30}, {0, 0, 0, 0, 0}, {{532, 26}, {558, 22}, {580, 28}, {608, 25}, {633, 21}}}, TypeDef{sizeof(SavedPlayerConfig), 1710757245, "SavedPlayerConfig", 6, {30, 30, 20, 20, 30, 30}, {0, 0, 0, 0, 0, 16}, {{532, 26}, {558, 22}, {580, 28}, {608, 25}, {633, 21}, {654, 25}}},
TypeDef{sizeof(PuzzleElementType::Enum), 2983807453, "PuzzleElementType", 0, {}, {}, {}}, TypeDef{sizeof(PuzzleElementType::Enum), 2983807453, "PuzzleElementType", 0, {}, {}, {}},
TypeDef{sizeof(PlacedPuzzleCardFlags::Enum), 2983807453, "PlacedPuzzleCardFlags", 0, {}, {}, {}}, TypeDef{sizeof(PlacedPuzzleCardFlags::Enum), 2983807453, "PlacedPuzzleCardFlags", 0, {}, {}, {}},
TypeDef{sizeof(EMaterial::Enum), 2024002654, "EMaterial", 0, {}, {}, {}}, TypeDef{sizeof(EMaterial::Enum), 2024002654, "EMaterial", 0, {}, {}, {}},
}; };
char MemberNameBuffer[64*64*64]{"xyxyzxyzwMMMMIPositionRotationScaleIdxModelIdxAssetTextureIdxAssetXYModelConnectionDirectionElementsBaseModelHandleNorthCoverHandleEastCoverHandleSouthCoverHandleWestCoverHandleSocketsModelTextureHandleBoardTextureHandleIdxTileBaseColorTileDotColorTestDisabledCardTintCardsVisualsRefCardMaxAvailableCountUsedCountRefCardPositionRotationFlagsIDPuzzleNameWidthTilesHeightTilesAvailableCardCountAvailableCardsPlacedCardsInitialPlacedCardsBackgroundTilesGoalPositionCountGoalPositionsBaseColorHighlightColorTFMaterialTextureModelVisibleTabletBackgroundRenderDataTabletStatusRenderDataTabletStatusNotSolvedTextureTabletStatusSolvedTextureTabletResetRenderData"}; char MemberNameBuffer[64*64*64]{"xyxyzxyzwMMMMIPositionRotationScaleIdxModelIdxAssetTextureIdxAssetXYModelConnectionDirectionElementsBaseModelHandleNorthCoverHandleEastCoverHandleSouthCoverHandleWestCoverHandleSocketsModelTextureHandleBoardTextureHandleIdxTileBaseColorTileDotColorTestDisabledCardTintCardsVisualsRefCardMaxAvailableCountUsedCountRefCardPositionRotationFlagsIDPuzzleNameWidthTilesHeightTilesAvailableCardCountAvailableCardsPlacedCardsInitialPlacedCardsBackgroundTilesGoalPositionCountGoalPositionsBaseColorHighlightColorTFMaterialTextureModelVisibleTabletBackgroundRenderDataTabletStatusRenderDataTabletStatusNotSolvedTextureTabletStatusSolvedTextureTabletResetRenderDataBackgroundLevelRenderData"};
}; };
constexpr MetadataTable Metadata; constexpr MetadataTable Metadata;

Binary file not shown.

BIN
src/models/river.glb LFS Normal file

Binary file not shown.

22
tools/radsession.rad Normal file
View File

@@ -0,0 +1,22 @@
// raddbg 0.9.19 project file
recent_file: path: "../src/game/entity.h"
recent_file: path: "../src/game/level.cpp"
recent_file: path: "../src/game/ui.cpp"
recent_file: path: "../src/gen/generated.cpp"
recent_file: path: "../src/engine/main.cpp"
recent_file: path: "../src/game/setup.cpp"
recent_file: path: "../src/game/rendering/rendering.cpp"
recent_file: path: "../src/dependency/imgui/imgui_widgets.cpp"
recent_file: path: "../src/game/tools.cpp"
recent_file: path: "../src/dependency/bgfx.cmake/bx/src/debug.cpp"
recent_file: path: "../src/gen/def.h"
recent_file: path: "../src/game/global.cpp"
recent_file: path: "../src/game/Log.cpp"
target:
{
executable: "../src/cmake-build/PuzGameEngine.exe"
working_directory: "../src"
enabled: 1
debug_subprocesses: 0
}