Persist Ground Zero tile registry baseline

This commit is contained in:
2026-05-18 19:35:00 -07:00
parent 9aa2f8bee3
commit 65599b9d2f
4 changed files with 94 additions and 1 deletions
+4 -1
View File
@@ -774,7 +774,10 @@ Target deliverable: A small group can join a server, spawn into one biome, gathe
- [x] Add load-on-server-start. `AAgrarianGameGameMode` now registers MVP - [x] Add load-on-server-start. `AAgrarianGameGameMode` now registers MVP
persistent actor classes and, when `bLoadWorldOnServerStart` is enabled, persistent actor classes and, when `bLoadWorldOnServerStart` is enabled,
loads the current world on authoritative `BeginPlay` if a save exists. loads the current world on authoritative `BeginPlay` if a save exists.
- [ ] Add initial tile registry persistence for Ground Zero. - [x] Add initial tile registry persistence for Ground Zero. Saves now include
`FAgrarianSavedTileRegistryState` with the active Ground Zero tile ID,
registry path, schema version, generation version, and package version while
keeping the authoritative registry in `Data/Tiles/ground_zero_tiles.json`.
- [ ] Add backup-before-save option. - [ ] Add backup-before-save option.
- [ ] Add recovery plan for corrupted save. - [ ] Add recovery plan for corrupted save.
- [ ] Document persistence limitations. - [ ] Document persistence limitations.
+8
View File
@@ -437,6 +437,14 @@ inventory persistence. The saved container array is intentionally present now
so the first placed-container actor can use the same save format without a so the first placed-container actor can use the same save format without a
schema break. schema break.
Ground Zero tile registry persistence is represented by
`FAgrarianSavedTileRegistryState` on `UAgrarianSaveGame`. The MVP defaults point
to active tile `gz_us_ca_pacifica_utm10n_e544_n4160`, registry source
`Data/Tiles/ground_zero_tiles.json`, registry schema version `1`, generation
version `1`, and package version `0`. This records the active tile baseline
inside the save file while the authoritative tile registry remains the external
JSON registry.
World time is stored in `UAgrarianSaveGame::WorldHours`. The persistence World time is stored in `UAgrarianSaveGame::WorldHours`. The persistence
subsystem captures it from `AAgrarianGameState::WorldHours` during world save subsystem captures it from `AAgrarianGameState::WorldHours` during world save
and restores it only on authority during world load. and restores it only on authority during world load.
@@ -0,0 +1,58 @@
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
GROUND_ZERO_TILE_ID = "gz_us_ca_pacifica_utm10n_e544_n4160"
EXPECTED = {
ROOT / "Source" / "AgrarianGame" / "AgrarianSaveGame.h": [
"struct FAgrarianSavedTileRegistryState",
f"FName ActiveTileId = TEXT(\"{GROUND_ZERO_TILE_ID}\");",
"FString RegistryPath = TEXT(\"Data/Tiles/ground_zero_tiles.json\");",
"int32 RegistrySchemaVersion = 1;",
"int32 GenerationVersion = 1;",
"int32 PackageVersion = 0;",
"FAgrarianSavedTileRegistryState TileRegistry;",
],
ROOT / "Docs" / "PersistenceDesignDocument.md": [
"`FAgrarianSavedTileRegistryState`",
f"active tile `{GROUND_ZERO_TILE_ID}`",
"`Data/Tiles/ground_zero_tiles.json`",
],
ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
"[x] Add initial tile registry persistence for Ground Zero.",
"`FAgrarianSavedTileRegistryState`",
"`Data/Tiles/ground_zero_tiles.json`",
],
}
def main() -> None:
missing = []
registry = json.loads((ROOT / "Data" / "Tiles" / "ground_zero_tiles.json").read_text(encoding="utf-8"))
ground_zero = next((tile for tile in registry.get("tiles", []) if tile.get("tile_id") == GROUND_ZERO_TILE_ID), None)
if not ground_zero:
missing.append("Data/Tiles/ground_zero_tiles.json: Ground Zero tile record")
else:
if registry.get("schema_version") != 1:
missing.append("Data/Tiles/ground_zero_tiles.json: schema_version 1")
if ground_zero.get("generation_version") != 1:
missing.append("Data/Tiles/ground_zero_tiles.json: generation_version 1")
if ground_zero.get("package_version") != 0:
missing.append("Data/Tiles/ground_zero_tiles.json: package_version 0")
for path, snippets in EXPECTED.items():
text = path.read_text(encoding="utf-8")
for snippet in snippets:
if snippet not in text:
missing.append(f"{path.relative_to(ROOT)}: {snippet}")
if missing:
raise RuntimeError("Ground Zero tile registry persistence verification failed: " + "; ".join(missing))
print("PASS: Ground Zero tile registry baseline is represented in save metadata.")
if __name__ == "__main__":
main()
+24
View File
@@ -106,6 +106,27 @@ struct FAgrarianSavedContainer
FString OwnerPlayerId; FString OwnerPlayerId;
}; };
USTRUCT(BlueprintType)
struct FAgrarianSavedTileRegistryState
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Save")
FName ActiveTileId = TEXT("gz_us_ca_pacifica_utm10n_e544_n4160");
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Save")
FString RegistryPath = TEXT("Data/Tiles/ground_zero_tiles.json");
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Save")
int32 RegistrySchemaVersion = 1;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Save")
int32 GenerationVersion = 1;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Save")
int32 PackageVersion = 0;
};
UCLASS() UCLASS()
class UAgrarianSaveGame : public USaveGame class UAgrarianSaveGame : public USaveGame
{ {
@@ -138,4 +159,7 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Save") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Save")
TArray<FAgrarianSavedContainer> Containers; TArray<FAgrarianSavedContainer> Containers;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Save")
FAgrarianSavedTileRegistryState TileRegistry;
}; };