Problem
validate_save_schema() in scripts/game_state.gd validates save data but uses a hardcoded expected_sizes array for grid dimensions instead of deriving them from LayoutMath:
The validation checks that tile arrays match expected grid sizes, but those sizes are hardcoded rather than computed from the anchor family logic in scripts/layout_math.gd. If the layout math changes grid dimensions, the save validator would reject valid saves or accept invalid ones.
Additionally, the validator checks field types and bounds but does not validate:
active_goal has valid values (references a real goal template)
completed_goal_ids contains valid goal IDs
active_rewards have valid structures
colony_stance is a known stance value
- Tile count internally matches
grid_w * grid_h
Fix
- Import
LayoutMath in game_state.gd or accept grid dimensions as parameters
- Compute expected tile counts from the anchor/layout configuration
- Add internal consistency checks:
state.tiles.size() == state.grid_w * state.grid_h
- Goal references are valid
- Colony stance is a known value
Acceptance criteria
Problem
validate_save_schema()inscripts/game_state.gdvalidates save data but uses a hardcodedexpected_sizesarray for grid dimensions instead of deriving them fromLayoutMath:The validation checks that tile arrays match expected grid sizes, but those sizes are hardcoded rather than computed from the anchor family logic in
scripts/layout_math.gd. If the layout math changes grid dimensions, the save validator would reject valid saves or accept invalid ones.Additionally, the validator checks field types and bounds but does not validate:
active_goalhas valid values (references a real goal template)completed_goal_idscontains valid goal IDsactive_rewardshave valid structurescolony_stanceis a known stance valuegrid_w * grid_hFix
LayoutMathingame_state.gdor accept grid dimensions as parametersstate.tiles.size() == state.grid_w * state.grid_hAcceptance criteria
tests/test_save_backup.gdupdated with edge cases