Comments and documentation update

This commit is contained in:
2025-09-27 21:00:45 +04:00
parent 821d9aa42c
commit 0cf76d595f
4 changed files with 102 additions and 29 deletions

View File

@@ -1,3 +1,9 @@
## Save Manager - Secure Game Data Persistence System
##
## Provides secure save/load functionality with tamper detection, race condition protection,
## and permissive validation. Features backup/restore, version migration, and data integrity.
## Implements multi-layered security: checksums, size limits, type validation, and bounds checking.
extends Node
const SAVE_FILE_PATH: String = "user://savegame.save"
@@ -8,7 +14,7 @@ const MAX_SCORE: int = 999999999
const MAX_GAMES_PLAYED: int = 100000
const MAX_FILE_SIZE: int = 1048576 # 1MB limit
# Save operation protection
# Save operation protection - prevents race conditions
var _save_in_progress: bool = false
var _restore_in_progress: bool = false
@@ -28,10 +34,12 @@ var game_data: Dictionary = {
func _ready() -> void:
"""Initialize SaveManager and load existing save data on startup"""
load_game()
func save_game() -> bool:
"""Save current game data with race condition protection and error handling"""
# Prevent concurrent saves
if _save_in_progress:
DebugManager.log_warn("Save already in progress, skipping", "SaveManager")
@@ -82,6 +90,7 @@ func _perform_save() -> bool:
func load_game() -> void:
"""Load game data from disk with comprehensive validation and error recovery"""
if not FileAccess.file_exists(SAVE_FILE_PATH):
DebugManager.log_info("No save file found, using defaults", "SaveManager")
return