From a29572bfdfa2ffd497b42a2dab6a00d58fe84223 Mon Sep 17 00:00:00 2001 From: autocommit Date: Sat, 6 Jun 2026 17:46:38 -0700 Subject: [PATCH] =?UTF-8?q?feat(save-manager):=20=E2=9C=A8=20Add=20increme?= =?UTF-8?q?ntal=20save/load=20support=20with=20versioned=20state=20handlin?= =?UTF-8?q?g=20for=20world=20simulation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- src/game/engine/src/core/save_manager.gd | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/game/engine/src/core/save_manager.gd b/src/game/engine/src/core/save_manager.gd index 129a6a70..ab7c7fa2 100644 --- a/src/game/engine/src/core/save_manager.gd +++ b/src/game/engine/src/core/save_manager.gd @@ -149,6 +149,9 @@ static func load_from_path(abs_path: String) -> Error: return ERR_FILE_CORRUPT GameState.deserialize(envelope.get("game_state", {})) GameState.rebuild_layer_references() + # Increment 3b: restore worldsim eco-damage map (rebuild fresh + inject). + WorldsimState.reset() + WorldsimState.restore_from_save_json(String(envelope.get("worldsim_state", ""))) return _validate_controllers_after_load(abs_path) @@ -215,6 +218,10 @@ static func save_to_path(abs_path: String, indented: bool = false) -> Error: "version": SCHEMA_VERSION, "timestamp": int(Time.get_unix_time_from_system()), "game_state": GameState.serialize(), + # Increment 3b: worldsim eco-damage map (opaque JSON, mirrors the Rust + # `mc_save::SaveFile.worldsim_state` field). Absent in old saves; the + # loader treats a missing key as "rebuild from scratch". + "worldsim_state": WorldsimState.to_save_json(), } # Sorted keys always on so re-saving the same state is byte-identical. @@ -266,6 +273,9 @@ static func _read_slot(slot_name: String) -> Error: var state_entry: Dictionary = envelope.get("game_state", {}) GameState.deserialize(state_entry) GameState.rebuild_layer_references() + # Increment 3b: restore worldsim eco-damage map (rebuild fresh + inject). + WorldsimState.reset() + WorldsimState.restore_from_save_json(String(envelope.get("worldsim_state", ""))) return _validate_controllers_after_load(slot_name)