fix(rute): reserve-søgning gennem vejnettet fra traktorens nærmeste waypoint når AD's getPathTo siger nej trods vej (Æg storage -> Chicken Storage Unload) (v1.19.9.0)

This commit is contained in:
2026-09-24 23:42:33 +02:00
parent 5c7f7ba072
commit 3111033805
5 changed files with 61 additions and 4 deletions
+43 -1
View File
@@ -92,12 +92,54 @@ end
-- Sendes AutoDrive mod et punkt uden rute, viser den "cannot reach" og slukker sig selv.
-- getPathTo/pathFromTo er rene opslag uden bivirkninger.
-- Reserve: bredde-først gennem vejnettets udgange fra traktorens nærmeste waypoint. AD's getPathTo kan
-- sige nej trods en vej (set ved et Wait-punkt: ruten fandtes fra alle omkringliggende waypoints).
ADWaitPool.GRAPH_SEARCH_LIMIT = 50000
local loggedFallback = {}
local function graphReaches(adEnv, vehicle, targetId)
local graph = adEnv.ADGraphManager
if vehicle.getClosestWayPoint == nil or graph.getWayPointById == nil then
return false
end
local ok, startId = pcall(vehicle.getClosestWayPoint, vehicle)
if not ok or startId == nil then
return false
end
local seen, queue, head = {[startId] = true}, {startId}, 1
while queue[head] ~= nil and head <= ADWaitPool.GRAPH_SEARCH_LIMIT do
local id = queue[head]
head = head + 1
if id == targetId then
return true
end
local wayPoint = graph:getWayPointById(id)
for _, nextId in ipairs(wayPoint ~= nil and wayPoint.out or {}) do
if not seen[nextId] then
seen[nextId] = true
table.insert(queue, nextId)
end
end
end
return false
end
function ADWaitPool.hasRouteTo(adEnv, vehicle, wayPointId)
local graph = adEnv.ADGraphManager
if graph.getPathTo == nil then
return true
end
return pathReaches(graph:getPathTo(vehicle, wayPointId), wayPointId)
if pathReaches(graph:getPathTo(vehicle, wayPointId), wayPointId) then
return true
end
if graphReaches(adEnv, vehicle, wayPointId) then
if not loggedFallback[wayPointId] and Logging ~= nil and Logging.info ~= nil then
loggedFallback[wayPointId] = true
Logging.info("ADSmartPickup: AutoDrives rutesøgning fandt ingen vej til markør %s, men vejnettet har en — godtages", tostring(wayPointId))
end
return true
end
return false
end
function ADWaitPool.hasRouteBothWays(adEnv, vehicle, toWayPointId, homeWayPointId)