Persist Ground Zero tile registry baseline
This commit is contained in:
@@ -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
|
||||
persistent actor classes and, when `bLoadWorldOnServerStart` is enabled,
|
||||
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 recovery plan for corrupted save.
|
||||
- [ ] Document persistence limitations.
|
||||
|
||||
@@ -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
|
||||
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
|
||||
subsystem captures it from `AAgrarianGameState::WorldHours` during world save
|
||||
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()
|
||||
@@ -106,6 +106,27 @@ struct FAgrarianSavedContainer
|
||||
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()
|
||||
class UAgrarianSaveGame : public USaveGame
|
||||
{
|
||||
@@ -138,4 +159,7 @@ public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Save")
|
||||
TArray<FAgrarianSavedContainer> Containers;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Save")
|
||||
FAgrarianSavedTileRegistryState TileRegistry;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user