Refactor save manager validation and update state structure

- Updated the save manager to enforce a new format version (2) and improved validation checks for the save data structure.
- Enhanced the `validate_data` function to ensure all required fields are present and valid.
- Adjusted the handling of legacy saves and introduced new checks for various state fields.
- Improved number formatting in the global script for better readability of large numbers.
- Updated tests to reflect changes in the save manager and validation logic, ensuring compatibility with the new state structure.
- Added new tests for group indexing and production transactions to ensure correctness of entity management and resource production.
This commit is contained in:
Kirill
2026-09-20 20:56:15 +03:00
parent 26347fca30
commit a09e3df220
15 changed files with 295 additions and 154 deletions
+6 -6
View File
@@ -86,7 +86,10 @@ var locked_items: Array = []
func set_datetime(value: float):
date_time.text = Global.format_number(value, 5) if value != 0.0 else "0.0"
# Simulation time advances in tenths of a year; displaying five decimal
# places only adds zeroes and suggests precision the simulation does not
# have.
date_time.text = Global.format_number(value, 1) if value != 0.0 else "0.0"
#region Item manipulations: update and visibility
@@ -403,12 +406,9 @@ func load_data() -> bool:
SaveManager.blocked_saves["owniverse"] = true
push_error("Save is missing the current entity: " + id)
return false
var complete: Dictionary = owniverse.state.duplicate(true)
complete.merge(restored, true)
owniverse.state = complete
owniverse.new_state = complete
owniverse.state = restored
owniverse.new_state = restored.duplicate(true)
owniverse.initialize_life_batches()
owniverse.migrate_time_precision()
owniverse.refresh_item_amounts()
pending_page = clampi(int(game_data.get("ui", {}).get("current_page", 0)), 0, PAGE_COUNT - 1)
_restore_page.call_deferred()