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:
@@ -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)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.19.8.0</version>
|
||||
<version>1.19.9.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# AD Smart Pickup — brugermanual
|
||||
|
||||
Version 1.19.8 · Farming Simulator 25 · tillæg til AutoDrive
|
||||
Version 1.19.9 · Farming Simulator 25 · tillæg til AutoDrive
|
||||
|
||||
*English version: [USER_MANUAL.md](USER_MANUAL.md)*
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# AD Smart Pickup — user manual
|
||||
|
||||
Version 1.19.8 · Farming Simulator 25 · add-on for AutoDrive
|
||||
Version 1.19.9 · Farming Simulator 25 · add-on for AutoDrive
|
||||
|
||||
*Dansk version: [BRUGERMANUAL.md](BRUGERMANUAL.md)*
|
||||
|
||||
|
||||
@@ -92,5 +92,20 @@ check("W6 state driving", task.state, 2)
|
||||
check("W6 setPathTo", stopped.pathTo, 10)
|
||||
check("W6 stopUnloading", stopped.unload, true)
|
||||
|
||||
-- WR: AD's rutesøgning siger nej, men vejnettet har en vej fra traktorens nærmeste waypoint -> godtages
|
||||
-- (in-game 24/9: 'Æg storage' ved Chicken Wait 1, "ingen vej til 'Chicken Storage Unload'" trods vej)
|
||||
do
|
||||
wayPoints[901] = {id = 901, x = 0, z = 0, out = {902}}
|
||||
wayPoints[902] = {id = 902, x = 5, z = 0, out = {903}}
|
||||
wayPoints[903] = {id = 903, x = 10, z = 0, out = {}}
|
||||
wayPoints[904] = {id = 904, x = 20, z = 0, out = {}} -- ingen indgang
|
||||
unreachable[903], unreachable[904] = true, true
|
||||
local vehicle = {getClosestWayPoint = function() return 901, 1 end}
|
||||
check("WR AD nej, vejnettet ja -> nåelig", ADWaitPool.hasRouteTo(adEnv, vehicle, 903), true)
|
||||
check("WR hverken AD eller vejnet -> ikke nåelig", ADWaitPool.hasRouteTo(adEnv, vehicle, 904), false)
|
||||
check("WR uden nærmeste waypoint -> AD's svar", ADWaitPool.hasRouteTo(adEnv, {}, 903), false)
|
||||
unreachable[903], unreachable[904] = nil, nil
|
||||
end
|
||||
|
||||
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
|
||||
os.exit(failures == 0 and 0 or 1)
|
||||
|
||||
Reference in New Issue
Block a user