Placement Validation System Fix¶
Date: 2025-08-07 Author: AI Assistant Issue: PlacementManager not properly validating rules, indicators stable, and API consistency
Problem Description¶
Recent regressions caused:
1. Validator active_rules cleared after successful setup due to indicator setup calling tear_down()
2. Rule application attempted to call non-existent execute() on rules (should be apply())
3. WithinTilemapBoundsRule used results.problems instead of results.issues
4. Excessively verbose per-indicator logs risked output overflow
Root Cause Analysis¶
PlacementManager.setup_indicators()invokedtear_down(), which clearedactive_rulesright aftertry_setup()succeeded, leading to "No active rules" during validation.- The base
PlacementRuledefinesapply(). Some code still assumedexecute()from older API. - Terminology migration missed one spot in
within_tilemap_bounds_rule.gd. - Debug level was VERBOSE and logging per-indicator masks produced massive output.
Solutions¶
- Preserve validator state during indicator setup
- File:
addons/grid_building/placement/manager/placement_manager.gd -
Change:
setup_indicators()now only resets indicators and redraws; it no longer callstear_down(). -
Use correct rule application method
- File:
addons/grid_building/placement/manager/components/placement_validator.gd -
Change:
apply_rules()now callsrule.apply()for each active rule. -
Fix terminology in bounds rule helper
- File:
addons/grid_building/placement/placement_rules/template_rules/within_tilemap_bounds_rule.gd -
Change:
_is_over_valid_tile()assignsresults.issues = p_indicator.validate()and checksresults.issues.is_empty(). -
Logging guidance to prevent overflow
- Doc:
terminology_conventions.md - Added guidance to reduce message count when logs are too noisy (lower debug level, aggregate duplicates, prefer per-rule summaries).
Files Modified¶
addons/grid_building/placement/manager/placement_manager.gdaddons/grid_building/placement/manager/components/placement_validator.gdaddons/grid_building/placement/placement_rules/template_rules/within_tilemap_bounds_rule.gdterminology_conventions.md
Validation¶
- Indicators now remain active and rules stay set after setup.
- Collision checks pass/fail correctly; zero collisions no longer cause failure unless another rule fails.
- Successful builds trigger
apply()on rules such asSpendMaterialsRuleGenericwithout errors.
Follow-up¶
- Keep per-rule PASS/FAIL logs; disable per-indicator spam when not debugging.
- If further failures occur, inspect
PlacementValidator.validate()rule result reasons to pinpoint the rule.
Vendor runner configuration (GdUnit)¶
- We treat
addons/gdUnit4/GdUnitRunner.cfgas a project-customized artifact (port, runtime flags, enumerated suites). - See
test/grid_building_test/docs/gdunit_runner_customizations.mdfor invariants and regeneration steps.