fix: salgsmarkør skal køre gennem stationens trigger (v1.62.50)

This commit is contained in:
2026-10-06 19:40:31 +02:00
parent c9792950f0
commit 2b36303756
5 changed files with 44 additions and 8 deletions
+4 -4
View File
@@ -753,7 +753,7 @@ end
ADFieldWork.THROUGH_TRIGGER_M = 3 -- AD-vejen før markøren kører gennem triggeren, hvis et punkt er så tæt på
-- Kører AD-vejen ind til markøren gennem en af triggerne? marker.approach = {{x, z}} (punkter bagud fra markøren).
local function drivesThrough(marker, points)
function ADFieldWork.drivesThrough(marker, points)
local limit = ADFieldWork.THROUGH_TRIGGER_M ^ 2
for _, p in ipairs(marker.approach or {}) do
for _, point in ipairs(points) do
@@ -777,7 +777,7 @@ function ADFieldWork.nearestStationMarker(markers, points, maxDistance)
nearest = math.min(nearest, (marker.x - point.x) ^ 2 + (marker.z - point.z) ^ 2)
end
if nearest <= maxDistance * maxDistance then
local through = drivesThrough(marker, points)
local through = ADFieldWork.drivesThrough(marker, points)
if (through and not bestThrough) or (through == bestThrough and nearest < bestDistance) then
best, bestDistance, bestThrough = marker.id, nearest, through
end
@@ -805,7 +805,7 @@ end
ADFieldWork.APPROACH_M = 40 -- så langt bagud ad AD-vejen ledes der efter triggeren
-- Punkterne AD kører igennem ind til markøren (bagud ad incoming, op til APPROACH_M).
local function approachPoints(adEnv, startId)
function ADFieldWork.approachPoints(adEnv, startId)
local points, seen, queue = {}, {[startId] = true}, {{id = startId, d = 0}}
local head = 1
while head <= #queue and #points < 600 do
@@ -841,7 +841,7 @@ local function markerList(adEnv, points, nearM)
local entry = {id = marker.id, name = marker.name, group = marker.group, x = wayPoint.x, z = wayPoint.z}
for _, point in ipairs(points or {}) do
if (wayPoint.x - point.x) ^ 2 + (wayPoint.z - point.z) ^ 2 <= (nearM or 0) ^ 2 then
entry.approach = approachPoints(adEnv, marker.id)
entry.approach = ADFieldWork.approachPoints(adEnv, marker.id)
break
end
end