feat(save-manager): ✨ Add incremental save/load support with versioned state handling for world simulation
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
e9b76ecdd6
commit
a29572bfdf
1 changed files with 10 additions and 0 deletions
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue