Skip to content

Commit

Permalink
Merge pull request #1346 from Courseplay/Issue-1329
Browse files Browse the repository at this point in the history
Band aid for #1329, as ad changed something and isn't willing to fix …
  • Loading branch information
Tensuko committed Apr 8, 2022
2 parents 4ae535b + a34185d commit 43718e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/ai/jobs/CpAIJobFieldWork.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ function CpAIJobFieldWork:validate(farmId)
if not isValid then
return isValid, errorMessage
end
self.cpJobParameters:validateSettings()
local vehicle = self.vehicleParameter:getVehicle()

--- Only check the valid field position in the in game menu.
Expand All @@ -138,6 +137,7 @@ function CpAIJobFieldWork:validate(farmId)
if not isValid then
return isValid, errorMessage
end
self.cpJobParameters:validateSettings()
end

if not vehicle:hasCpCourse() then
Expand Down
7 changes: 6 additions & 1 deletion scripts/specializations/CpAIFieldWorker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function CpAIFieldWorker:startCpAtFirstWp()
if self:hasCpCourse() and self:getCanStartCpFieldWork() then
spec.cpJobStartAtFirstWp:applyCurrentState(self, g_currentMission, g_currentMission.player.farmId, true)
--- Applies the lane offset set in the hud, so ad can start with the correct lane offset.
spec.cpJobStartAtFirstWp:getCpJobParameters().laneOffset:setValue(spec.cpJob:getCpJobParameters().laneOffset:getValue())
spec.cpJobStartAtFirstWp:getCpJobParameters().laneOffset:setValue(self:getCpLaneOffsetSetting():getValue())
spec.cpJobStartAtFirstWp:setValues()
local success = spec.cpJobStartAtFirstWp:validate(false)
if success then
Expand All @@ -217,8 +217,13 @@ function CpAIFieldWorker:startCpAtLastWp()
self:updateAIFieldWorkerImplementData()
if self:hasCpCourse() and self:getCanStartCpFieldWork() then
spec.cpJobStartAtLastWp:applyCurrentState(self, g_currentMission, g_currentMission.player.farmId, true)
--- Applies the lane offset set in the hud, so ad can start with the correct lane offset.
--- TODO: This should only be applied, if the driver was started for the first time by ad and not every time.
spec.cpJobStartAtLastWp:getCpJobParameters().laneOffset:setValue(self:getCpLaneOffsetSetting():getValue())
spec.cpJobStartAtLastWp:setValues()
CpUtil.debugVehicle(CpDebug.DBG_FIELDWORK, self, "lane offset: %s", spec.cpJobStartAtLastWp:getCpJobParameters().laneOffset:getString())
local success = spec.cpJobStartAtLastWp:validate(false)
CpUtil.debugVehicle(CpDebug.DBG_FIELDWORK, self, "lane offset: %s", spec.cpJobStartAtLastWp:getCpJobParameters().laneOffset:getString())
if success then
g_client:getServerConnection():sendEvent(AIJobStartRequestEvent.new(spec.cpJobStartAtLastWp, self:getOwnerFarmId()))
return true
Expand Down

0 comments on commit 43718e4

Please sign in to comment.