fix(udkørsel): 'Wait at: All' vælger det ledige Wait-punkt nærmest flowets kilder, ikke nærmest traktoren (v1.57.1.0)
This commit is contained in:
@@ -493,7 +493,17 @@ local function startHold(adEnv, vehicle, run, reasons, sourcesById)
|
|||||||
local isReachable = function(candidate)
|
local isReachable = function(candidate)
|
||||||
return ADWaitPool.hasRouteTo(adEnv, vehicle, candidate.marker.id)
|
return ADWaitPool.hasRouteTo(adEnv, vehicle, candidate.marker.id)
|
||||||
end
|
end
|
||||||
local candidate = ADWaitPool.pickFree(adEnv, vehicle, run.waitPoolGroup, isReachable)
|
-- "All": nærmest flowets egne kilder, ikke nærmest traktoren (in-game 29/9: Milk Store ved sukkerroeknuseren)
|
||||||
|
local anchorX, anchorZ = nil, nil
|
||||||
|
if run.waitPoolGroup == nil then
|
||||||
|
local points = {}
|
||||||
|
for _, id in ipairs(run.sourceWayPointIds or {}) do
|
||||||
|
local wayPoint = adEnv.ADGraphManager:getWayPointById(id)
|
||||||
|
if wayPoint ~= nil then table.insert(points, {x = wayPoint.x, z = wayPoint.z}) end
|
||||||
|
end
|
||||||
|
anchorX, anchorZ = ADWaitPool.anchorOf(points)
|
||||||
|
end
|
||||||
|
local candidate = ADWaitPool.pickFree(adEnv, vehicle, run.waitPoolGroup, isReachable, anchorX, anchorZ)
|
||||||
local marker, source = nil, nil
|
local marker, source = nil, nil
|
||||||
if candidate ~= nil then
|
if candidate ~= nil then
|
||||||
ADWaitPool.claim(candidate.marker.id, vehicle)
|
ADWaitPool.claim(candidate.marker.id, vehicle)
|
||||||
|
|||||||
@@ -97,8 +97,18 @@ local function otherVehiclePositions(vehicle)
|
|||||||
return positions
|
return positions
|
||||||
end
|
end
|
||||||
|
|
||||||
function ADWaitPool.pickFree(adEnv, vehicle, poolGroup, isReachable)
|
-- Midtpunkt af punkter {x, z} (fx flowets kilde-markører) -> x, z eller nil.
|
||||||
|
function ADWaitPool.anchorOf(points)
|
||||||
|
if points == nil or #points == 0 then return nil end
|
||||||
|
local sx, sz = 0, 0
|
||||||
|
for _, point in ipairs(points) do sx, sz = sx + point.x, sz + point.z end
|
||||||
|
return sx / #points, sz / #points
|
||||||
|
end
|
||||||
|
|
||||||
|
-- anchorX/anchorZ (valgfri): vælg nærmest dette punkt i stedet for traktoren (flow med "All": nærmest kilderne).
|
||||||
|
function ADWaitPool.pickFree(adEnv, vehicle, poolGroup, isReachable, anchorX, anchorZ)
|
||||||
local x, z = getVehiclePosition(vehicle)
|
local x, z = getVehiclePosition(vehicle)
|
||||||
|
if anchorX ~= nil and anchorZ ~= nil then x, z = anchorX, anchorZ end
|
||||||
if x == nil then
|
if x == nil then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
<modDesc descVersion="107">
|
<modDesc descVersion="107">
|
||||||
<author>masterdraco</author>
|
<author>masterdraco</author>
|
||||||
<version>1.57.0.0</version>
|
<version>1.57.1.0</version>
|
||||||
<title>
|
<title>
|
||||||
<en>AD Smart Pickup</en>
|
<en>AD Smart Pickup</en>
|
||||||
</title>
|
</title>
|
||||||
|
|||||||
@@ -156,5 +156,11 @@ do
|
|||||||
netGetTime = savedClock
|
netGetTime = savedClock
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ankerpunkt for "All": midt mellem flowets kilder (in-game 29/9: Milk Store ventede ved sukkerroeknuseren)
|
||||||
|
local ax, az = ADWaitPool.anchorOf({{x = 0, z = 0}, {x = 100, z = 50}})
|
||||||
|
check("anker: midtpunkt x", ax, 50)
|
||||||
|
check("anker: midtpunkt z", az, 25)
|
||||||
|
check("anker: ingen punkter", ADWaitPool.anchorOf({}), nil)
|
||||||
|
check("anker: nil", ADWaitPool.anchorOf(nil), nil)
|
||||||
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
|
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
|
||||||
os.exit(failures == 0 and 0 or 1)
|
os.exit(failures == 0 and 0 or 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user