fix: genkend markmaskinens mark efter genindlæsning med margen og husket waypoint (v1.62.51)
This commit is contained in:
@@ -1317,13 +1317,17 @@ function ADFieldWork.resumeAfterLoad(adEnv)
|
||||
if toStart ~= nil then wasWorking = startSet[rig.id] == true end
|
||||
handled[rig.id] = true
|
||||
local fieldId, distance = nil, nil
|
||||
if wasWorking and toStart ~= nil then
|
||||
fieldId = ADFieldJobs.resumeField(rig.x, rig.z, rig.role, fields)
|
||||
elseif wasWorking then
|
||||
fieldId = ADFieldJobs.resumeField(rig.x, rig.z, rig.role, fields)
|
||||
local course = ADCpBridge.getCourse(vehicle)
|
||||
local okWp, wp = pcall(function() return course ~= nil and course:getWaypoint(vehicle:getCpLastRememberedWaypointIx()) or nil end)
|
||||
if okWp and wp ~= nil and wp.x ~= nil then distance = math.sqrt((wp.x - rig.x) ^ 2 + (wp.z - rig.z) ^ 2) end
|
||||
if wasWorking then
|
||||
local extra = {}
|
||||
local okWp, wp = pcall(function()
|
||||
local course = ADCpBridge.getCourse(vehicle)
|
||||
return course ~= nil and course:getWaypoint(vehicle:getCpLastRememberedWaypointIx()) or nil
|
||||
end)
|
||||
if okWp and type(wp) == "table" and wp.x ~= nil then
|
||||
table.insert(extra, {x = wp.x, z = wp.z})
|
||||
distance = math.sqrt((wp.x - rig.x) ^ 2 + (wp.z - rig.z) ^ 2)
|
||||
end
|
||||
fieldId = ADFieldJobs.resumeField(rig.x, rig.z, rig.role, fields, extra)
|
||||
end
|
||||
if wasWorking and toStart == nil and not rig.busy and not rig.controlled and not ADFieldJobs.shouldResume({fieldId = fieldId, distance = distance}) then
|
||||
Logging.info(ADFieldJobs.LOG_PREFIX .. "'%s' genstartes ikke: husket waypoint fra et gammelt job (%s væk, ikke på en mark i gang)",
|
||||
|
||||
Reference in New Issue
Block a user