feat: engine skeleton (Build Order step 1) and siege_tests

Engine:
- SdlContext and Window: RAII, throwing constructors, non-movable
- FrameClock (real time, clamped dt) and SimClock (fixed 1/60 s steps,
  speed 0 = planning phase, backlog capped per frame)
- Application owns them in lifetime order, exposes EngineContext, and
  runs the fixed-timestep loop; AppConfig::FromArgs parses --frames,
  --seed and --fullscreen
- Temporary window-surface fill so Wayland maps the window until
  RenderDevice lands in step 2

Build:
- Split into the siege_engine static lib and the siege_deck exe
- check_engine_deps fails the build if Engine/ includes Game/
- ctest smoke test: siege_deck --frames 30 on the offscreen driver
- siege_tests on Catch2 v3.15.3 (nixpkgs + CPM pin), with SimClock,
  FrameClock and AppConfig tests

Docs:
- Decision Log: error handling split, Catch2 for unit tests
- Build Order step 1 done; Engine Overview, Main Loop and Time and
  README updated to match
- AGENTS.md with build, conventions and gotchas for coding agents
- .gitignore: .mcp.json (local CLion MCP port) and Obsidian's
  workspace.json (tab/pane state), now untracked

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 00:27:36 +02:00
co-authored by Claude Opus 5.5
parent 45b246c1d7
commit 384f1ed1f2
26 changed files with 1072 additions and 271 deletions
+66
View File
@@ -0,0 +1,66 @@
#include "Engine/Application.h"
#include <catch2/catch_test_macros.hpp>
using namespace SiegeDeck::Engine;
namespace
{
// FromArgs takes a mutable argv, like main's; build one from string literals.
std::expected<AppConfig, string> Parse(std::initializer_list<const char*> args)
{
Vector<string> storage { "siege_deck" };
storage.insert(storage.end(), args.begin(), args.end());
Vector<char*> argv;
for (string& arg : storage)
argv.push_back(arg.data());
return AppConfig::FromArgs(static_cast<int>(argv.size()), argv.data());
}
}
TEST_CASE("AppConfig without arguments keeps the defaults", "[config]")
{
auto config = Parse({});
REQUIRE(config);
CHECK_FALSE(config->MaxFrames);
CHECK(config->Seed == 0);
CHECK_FALSE(config->Fullscreen);
}
TEST_CASE("AppConfig reads every flag", "[config]")
{
auto config = Parse({ "--frames", "30", "--seed", "42", "--fullscreen" });
REQUIRE(config);
CHECK(config->MaxFrames == 30u);
CHECK(config->Seed == 42);
CHECK(config->Fullscreen);
}
TEST_CASE("AppConfig reports bad arguments instead of guessing", "[config]")
{
SECTION("unknown flag")
{
auto config = Parse({ "--bogus" });
REQUIRE_FALSE(config);
CHECK(config.error().find("--bogus") != string::npos);
}
SECTION("missing value")
{
CHECK_FALSE(Parse({ "--frames" }));
}
SECTION("not a number")
{
CHECK_FALSE(Parse({ "--frames", "abc" }));
}
SECTION("trailing garbage")
{
CHECK_FALSE(Parse({ "--seed", "12x" }));
}
SECTION("negative")
{
CHECK_FALSE(Parse({ "--frames", "-1" }));
}
}