diff --git a/BunkerSiloAIDriver.lua b/BunkerSiloAIDriver.lua index 0cf9149f3..d07efbbb0 100644 --- a/BunkerSiloAIDriver.lua +++ b/BunkerSiloAIDriver.lua @@ -206,7 +206,7 @@ function BunkerSiloAIDriver:isHeapSearchAllowed() end function BunkerSiloAIDriver:getWorkWidth() - return self.courseGeneratorSettings.workWidth:get() + return math.max(self.courseGeneratorSettings.workWidth:get(),3) end --- If true then the drive into silo course is reverse and diff --git a/base.lua b/base.lua index 7d4c0ddef..a278248c3 100644 --- a/base.lua +++ b/base.lua @@ -401,6 +401,9 @@ function courseplay:onUpdate(dt) ---set correctly at the first courseplay:setAIDriver() call. self.cp.driver:postInit() end + --- The saved value gets applied, before all implements are attached. + --- So only allow automatic changes after all implements are attached on savegame start. + self.cp.courseGeneratorSettings.workWidth:postInit() self.cp.settings.driverMode:postInit() --- Refreshes all field number settings on start, --- as clients might have a corrupted version. diff --git a/course-generator/CourseGeneratorSettings.lua b/course-generator/CourseGeneratorSettings.lua index ee9328eea..e53efe33a 100644 --- a/course-generator/CourseGeneratorSettings.lua +++ b/course-generator/CourseGeneratorSettings.lua @@ -125,13 +125,20 @@ function WorkWidthSetting:init(vehicle) -- and parentName is not set. -- TODO: move creating the course gen (or others too?) settings to onPostLoad() (instead of onLoad()) -- TODO: add parentName to the constructor of the settings instead of the explicit setter. - self:setToDefault(true) self:refresh() self.WORK_WIDTH_EVENT = self:registerFloatEvent(self.setWorkWidthFromNetwork) self.AUTO_WORK_WIDTH_EVENT = self:registerFloatEvent(self.setAutoWorkWidthFromNetwork) if g_server then self:updateAutoWorkWidth() + self:setToDefault(true) end + self.loaded = false +end + +--- The saved value gets applied, before all implements are attached. +--- So only allow automatic changes after all implements are attached on savegame start. +function WorkWidthSetting:postInit() + self.loaded = true end function WorkWidthSetting:loadFromXml(xml, parentKey) @@ -234,9 +241,13 @@ end --- so we update it on a attach/detach of an implement and --- send the changed value with an event to the client. function WorkWidthSetting:updateAutoWorkWidth() + if g_server == nil then return end local value = WorkWidthUtil.getAutomaticWorkWidth(self.vehicle) or 0 self.automaticValue:set(value,true) - self.value:set(value,true) + if self.loaded then + self.value:set(value,true) + end + self:refresh() self:sendAutoWorkWidthEvent(value) end diff --git a/modDesc.xml b/modDesc.xml index 61fb5226f..3af56289b 100644 --- a/modDesc.xml +++ b/modDesc.xml @@ -1,6 +1,6 @@ - 6.4.1.2 + 6.4.1.3 <en>CoursePlay</en> diff --git a/toolManager.lua b/toolManager.lua index 912b3e8cb..ffe5a1fcc 100644 --- a/toolManager.lua +++ b/toolManager.lua @@ -556,7 +556,7 @@ end ---@param object table ---@param logPrefix string function WorkWidthUtil.getShieldWorkWidth(object,logPrefix) - if object.spec_leveler then + if object.spec_leveler and object.spec_leveler.nodes and object.spec_leveler.nodes[1] and object.spec_leveler.nodes[1].maxDropWidth then local width = object.spec_leveler.nodes[1].maxDropWidth * 2 WorkWidthUtil.debug(object,logPrefix,'is a shield with work width: %.1f',width) return width