From c34c641d1e5c50e8d27d237b7edd019c51f6fd7b Mon Sep 17 00:00:00 2001 From: schwiti6190 <58079399+schwiti6190@users.noreply.github.com> Date: Wed, 27 Oct 2021 18:07:22 +0200 Subject: [PATCH 1/2] Fixes #7578 --- toolManager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolManager.lua b/toolManager.lua index ff51dc9b7..912b3e8cb 100644 --- a/toolManager.lua +++ b/toolManager.lua @@ -566,7 +566,7 @@ end ---@param object table ---@param logPrefix string function WorkWidthUtil.getShovelWorkWidth(object,logPrefix) - if object.spec_shovel then + if object.spec_shovel and object.spec_shovel.shovelNodes and object.spec_shovel.shovelNodes[1] then local width = object.spec_shovel.shovelNodes[1].width WorkWidthUtil.debug(object,logPrefix,'is a shovel with work width: %.1f',width) return width From 9cfa318a0e93bc2dadc4ee290fccd09e51b539b6 Mon Sep 17 00:00:00 2001 From: schwiti6190 <58079399+schwiti6190@users.noreply.github.com> Date: Wed, 27 Oct 2021 18:15:46 +0200 Subject: [PATCH 2/2] Might fix Mode7 field selection on clients. --- base.lua | 3 +++ settings.lua | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/base.lua b/base.lua index 87eb28534..7d4c0ddef 100644 --- a/base.lua +++ b/base.lua @@ -402,6 +402,9 @@ function courseplay:onUpdate(dt) self.cp.driver:postInit() end self.cp.settings.driverMode:postInit() + --- Refreshes all field number settings on start, + --- as clients might have a corrupted version. + FieldNumberSetting.refreshOnStart() self.cp.postInitDone = true end diff --git a/settings.lua b/settings.lua index ccc3bae47..364d7c8be 100644 --- a/settings.lua +++ b/settings.lua @@ -2021,9 +2021,13 @@ end --- Setting to select a field ---@class FieldNumberSetting : SettingList FieldNumberSetting = CpObject(SettingList) +FieldNumberSetting.Settings = {} function FieldNumberSetting:init(name, label, toolTip, vehicle) local values, texts = self:loadFields() SettingList.init(self, name, label, toolTip, vehicle, values, texts) + --- Store all instances of this setting in a global table, + --- for direct access to update their manual tool positions. + table.insert(FieldNumberSetting.Settings,self) end function FieldNumberSetting:loadFields() @@ -2053,6 +2057,14 @@ function FieldNumberSetting:refresh() self.current = math.min(self.current, #self.values) end +--- Refreshes all field number settings on start, +--- as clients might have a corrupted version. +function FieldNumberSetting.refreshOnStart() + for _,setting in pairs(FieldNumberSetting.Settings) do + setting:refresh() + end +end + -- see above, refresh in case it was not initialized function FieldNumberSetting:get() if #self.values == 0 or self.current > #self.values then