it should not be possible to build on top of an existing building #224

Closed
opened 2026-09-08 19:45:42 +00:00 by metaheavens · 1 comment
Owner
No description provided.
Author
Owner

Done in 840f9aa.

BuildingField.place() dropped a structure at the fleet centroid with no overlap check of any kind, so they could be stacked freely.

It reads worse than it looks. BuildingField decides which structure the fleet is standing on by testing the centroid against interact_radius and returning the first match — so two structures inside one another made that a question of list order rather than of where you flew. You could fly to your workshop and open the crafter.

The rule. A new structure must be at least 150 units from an existing one. That is Building.interact_radius itself rather than a new constant, because it is exactly the circle the ambiguity comes from. Buildings draw to a radius of roughly 60, so this leaves a visible gap rather than letting them touch. For scale: a chunk is 1200 units and a planet's landing radius is 140, so this is "fly off the thing you are standing on", not a trek.

Gated in three places — the info popup (button greys out and names what is in the way), _confirm_build, and _try_place, since the preview goes stale as the fleet keeps moving.

One ordering trap. A unique structure replaces itself by demolishing the old one before placing the new one, so a placement refused afterwards would have left the player with neither. The check runs before the demolition and excludes the structure being replaced. Case D of the new test pins exactly that.

Tests. test_building_separation.gd covers the rule, the build path, unique-rebuild-in-place, and the destructive-ordering case. Verified in both directions — with the rule neutered it fails on the first assertion.

Two existing tests encoded the old permissive behaviour and now fly clear first; neither is about placement:

  • test_build_info_popup builds every menu option from one position, so each structure blocked the next
  • test_payments_use_fleet_hold builds a mothership on the ship lab an earlier case injects at the origin

New games start with no buildings, so the first structure is unconstrained, and quests only require that a structure exists, never where — the chain is unaffected.

175/175.

Done in 840f9aa. `BuildingField.place()` dropped a structure at the fleet centroid with no overlap check of any kind, so they could be stacked freely. It reads worse than it looks. `BuildingField` decides which structure the fleet is standing on by testing the centroid against `interact_radius` and returning the **first** match — so two structures inside one another made that a question of list order rather than of where you flew. You could fly to your workshop and open the crafter. **The rule.** A new structure must be at least 150 units from an existing one. That is `Building.interact_radius` itself rather than a new constant, because it is exactly the circle the ambiguity comes from. Buildings draw to a radius of roughly 60, so this leaves a visible gap rather than letting them touch. For scale: a chunk is 1200 units and a planet's landing radius is 140, so this is "fly off the thing you are standing on", not a trek. Gated in three places — the info popup (button greys out and names what is in the way), `_confirm_build`, and `_try_place`, since the preview goes stale as the fleet keeps moving. **One ordering trap.** A unique structure replaces itself by demolishing the old one *before* placing the new one, so a placement refused afterwards would have left the player with neither. The check runs before the demolition and excludes the structure being replaced. Case D of the new test pins exactly that. **Tests.** `test_building_separation.gd` covers the rule, the build path, unique-rebuild-in-place, and the destructive-ordering case. Verified in both directions — with the rule neutered it fails on the first assertion. Two existing tests encoded the old permissive behaviour and now fly clear first; neither is about placement: - `test_build_info_popup` builds every menu option from one position, so each structure blocked the next - `test_payments_use_fleet_hold` builds a mothership on the ship lab an earlier case injects at the origin New games start with no buildings, so the first structure is unconstrained, and quests only require that a structure exists, never where — the chain is unaffected. 175/175.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
metaheavens/spaceship#224
No description provided.