mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-11-08 10:29:00 +00:00
Area.getClosestPointTo scans every point of the water search area, and it was called up to count * retryFactor times in placeDocks. The nearest point of a set to a point outside of it is always a boundary point, so compute the boundary once and scan only that. The logic lives in two small helpers, getBoundaryPoints (Uint8Array mask based) and getClosestPointInList, so it can be reused and read apart from placeDocks. getBoundaryPoints returns the original point objects, while getClosestPointInList returns a clone of the point it finds, so callers cannot mutate the points stored in the list.