Skip to content

Commit

Permalink
Fieldpolygon might be nil for fieldwork, so regenerate it from the co…
Browse files Browse the repository at this point in the history
…urse.
  • Loading branch information
schwiti6190 committed Dec 10, 2023
1 parent 9889590 commit 0191504
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions scripts/ai/AIDriveStrategyFieldWorkCourse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,10 @@ end

function AIDriveStrategyFieldWorkCourse:setFieldPolygon(polygon)
self.fieldPolygon = polygon
if self.fieldPolygon == nil then
self:debug("No field polygon received, so regenerate it by the course.")
self.fieldPolygon = self.fieldWorkCourse:getFieldPolygon()
end
end

-----------------------------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion scripts/ai/jobs/CpAIJobFieldWork.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ function CpAIJobFieldWork:validateFieldSetup(isValid, errorMessage)
self.hasValidPosition = false
self.foundVines = nil
local fieldPolygon, isCustomField = CpFieldUtil.getFieldPolygonAtWorldPosition(tx, tz)
self:setFieldPolygon(fieldPolygon)
if fieldPolygon then
self.hasValidPosition = true
self.foundVines = g_vineScanner:findVineNodesInField(fieldPolygon, tx, tz, self.customField ~= nil)
if self.foundVines then
CpUtil.debugVehicle(CpDebug.DBG_FIELDWORK, vehicle, "Found vine nodes, generating a vine field border.")
fieldPolygon = g_vineScanner:getCourseGeneratorVertices(0, tx, tz)
end
self:setFieldPolygon(fieldPolygon)
self.selectedFieldPlot:setWaypoints(fieldPolygon)
self.selectedFieldPlot:setVisible(true)
self.selectedFieldPlot:setBrightColor(true)
Expand Down

0 comments on commit 0191504

Please sign in to comment.