Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7289 from Courseplay/peter
Browse files Browse the repository at this point in the history
MP fix for WorkWidthSetting (#7285)
  • Loading branch information
schwiti6190 authored Jun 19, 2021
2 parents dba8421 + 8e29623 commit 875b944
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
4 changes: 4 additions & 0 deletions BunkerSiloAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,7 @@ function BunkerSiloAIDriver:doesNotMove()
-- does not move if we are less than 1km/h
return AIDriverUtil.isStopped(self.vehicle) and self.bestTarget.line > self.firstLine+1
end

function BunkerSiloAIDriver:setLightsMask(vehicle)
vehicle:setLightsTypesMask(courseplay.lights.HEADLIGHT_FULL)
end
7 changes: 3 additions & 4 deletions Events/WorkWidthSettingEvent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ end
function WorkWidthSettingEvent:new(vehicle, parentName, name, value)
courseplay:debugFormat(courseplay.DBG_MULTIPLAYER,
"WorkWidthSettingEvent:new(%s, %s, %s, %.1f)",nameNum(vehicle), name, parentName, value)
self.vehicle = nil
self.vehicle = vehicle;
self.vehicle = vehicle
self.parentName = parentName
self.name = name
self.value = value;
return self;
self.value = value
return self
end

-- deserialize received event
Expand Down
4 changes: 0 additions & 4 deletions ShovelAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,4 @@ end

function ShovelAIDriver:isAlignmentCourseNeeded(course, ix)
return AIDriver.isAlignmentCourseNeeded(self,course, ix)
end

function ShovelAIDriver:setLightsMask(vehicle)
vehicle:setLightsTypesMask(courseplay.lights.HEADLIGHT_FULL)
end
7 changes: 4 additions & 3 deletions base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ function courseplay:onLoad(savegame)
self.cp.settings = SettingsContainer.createVehicleSpecificSettings(self)

---@type SettingsContainer

self.cp.courseGeneratorSettings = SettingsContainer.createCourseGeneratorSettings(self)

courseplay.signs:updateWaypointSigns(self);
Expand Down Expand Up @@ -531,8 +530,10 @@ function courseplay:onUpdate(dt)
if self.cp.postInitDone == nil then
--- Reset the current mode, as all implements are now attached.
--- If the vehicle is new, then cp.loadedMode is nil
local mode = self.cp.loadedMode or courseplay.MODE_DEFAULT
courseplay:setCpMode(self, mode, true);
if g_server then
local mode = self.cp.loadedMode or self.cp.mode
courseplay:setCpMode(self, mode, true)
end
if self.cp.driver then
---Post init function, as not all giants variables are
---set correctly at the first courseplay:setAIDriver() call.
Expand Down
10 changes: 7 additions & 3 deletions course-generator/CourseGeneratorSettings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ function WorkWidthSetting:init(vehicle)
SettingList.init(self, 'workWidth', 'COURSEPLAY_WORK_WIDTH', 'COURSEPLAY_WORK_WIDTH', vehicle)
self.value = FloatSetting('workWidth', 'COURSEPLAY_WORK_WIDTH', 'COURSEPLAY_WORK_WIDTH', vehicle, 0)
self.minWidth, self.maxWidth = 1, 50
self:setToDefault()
-- do not attempt to send an event from the constructor as at that point, the vehicle is not completely ready
-- 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()
end

Expand Down Expand Up @@ -176,10 +180,10 @@ function WorkWidthSetting:setFromGuiElement()
end
end

function WorkWidthSetting:setToDefault()
function WorkWidthSetting:setToDefault(noEventSend)
local autoWidth = courseplay:getWorkWidth(self.vehicle)
if autoWidth > 0 then
self:set(courseplay:getWorkWidth(self.vehicle))
self:set(courseplay:getWorkWidth(self.vehicle), noEventSend)
end
end

Expand Down
1 change: 0 additions & 1 deletion settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,6 @@ function courseplay:changeRowAngle( vehicle, changeBy )
end

function courseplay:setMultiTools(vehicle, set)
vehicle:setCpVar('multiTools', set, courseplay.isClient)
if vehicle.cp.courseGeneratorSettings.multiTools:get() % 2 == 0 then
courseplay:changeLaneNumber(vehicle, 1)
else
Expand Down

0 comments on commit 875b944

Please sign in to comment.