modules: placement — where a thing can legally stand, answered once - #8632
Draft
keithharvey wants to merge 1 commit into
Draft
modules: placement — where a thing can legally stand, answered once#8632keithharvey wants to merge 1 commit into
keithharvey wants to merge 1 commit into
Conversation
Contributor
Integration Test Results20 tests ±0 8 ✅ ±0 16s ⏱️ ±0s For more details on these failures, see this check. Results for commit dd027ca. ± Comparison against base commit 82eaef6. ♻️ This comment has been updated with latest results. |
This was referenced Aug 4, 2026
keithharvey
force-pushed
the
placement
branch
2 times, most recently
from
August 8, 2026 02:19
8b10248 to
47e166d
Compare
Three systems put units on the map and each answered "is this ground I can
use" differently. The wave director had a careful cascade. The mission
roster had nothing at all — it took a map fraction, converted it, and called
CreateUnit, so a roster written for any map could put a lab in the sea on
this one. And the mission API's move action teleports blind: no ground test,
a square offset called a radius, and the unit's OLD height carried to the
new x and z, which leaves it floating or buried on any slope.
So the question gets a module. Ask it where something can stand and it
answers, or says what refused.
local x, y, z, why = Placement.NearestValid(wantX, wantZ, {
radius = 400, footprint = 64, surface = "land",
})
DETERMINISTIC, which is the point. The walk is an integer lattice — rings of
increasing distance, sorted by true distance inside each ring — so there is
no floating point for two clients to disagree about and no die to roll. The
same request on the same map gives the same answer on every client, in a
replay, and in a spec that asserts exact coordinates. It is also why the
answer is the CLOSEST match: a caller gets the point they asked for, or the
nearest place the terrain allows, rather than somewhere random that happened
to be legal.
The tests are not reimplemented. damgam_lib/position_checks.lua already
knows how to ask about flatness, occupancy, surface and bounds; this wraps
them into one question, records which one refused, and hands back the ground
height so no caller has to remember to ask for it.
"solid" is a surface mode the wrapped checks did not have a name for: land
or sea, but never the shoreline between them. A burrow may sit on either and
not across the line, or half its spawns drown.
position_checks reads the world when it loads, so it is pulled in on first
USE. A module that explodes at require time takes every consumer's spec down
with it, and nothing here needs the map until asked a question about it.
No consumers in this commit — the modules that use it declare and wire it in
their own, which is where a reviewer can see the call in context.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three systems put units on the map and each decided "is this ground usable" separately. The wave director had a careful cascade, the mission roster had no check at all, and the mission move action teleported blind.
One place to ask now:
The search walks an integer lattice outward in rings, no RNG and no trig, so the same request gives the same answer on every client and in a replay. It returns the nearest valid spot rather than an arbitrary legal one.
It wraps
damgam_lib/position_checks.luainstead of reimplementing it, reports which check refused, and returns the ground height so callers don't have to look it up. One surface mode is new:solidmeans land or sea but not the shoreline between, which a burrow can't straddle.position_checksreads the world when it loads, so it's pulled in on first use — loading it eagerly took every consumer's specs down.No consumers in this commit. waves (#8576) and missions wire it in theirs, where the call is visible in context.