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

Some MP, mode9 and baler improvements #6381

Merged
merged 2 commits into from
Nov 27, 2020
Merged

Some MP, mode9 and baler improvements #6381

merged 2 commits into from
Nov 27, 2020

Conversation

schwiti6190
Copy link
Contributor

@schwiti6190 schwiti6190 commented Nov 26, 2020

-fix mode 2/3 in MP
-reduce network load by only sending updated values
-improved mode 9 raycast
-improved baler handling
-diff small changes
-enabled fueling by trailer
-mode 1/4 wait while they get loaded

-closes #6350, closes #6308, closes #6213, closes #6167, closes #5701, closes #6317, closes #6263, closes #6384

@@ -201,25 +201,42 @@ end

function AIDriver:writeUpdateStream(streamId, connection, dirtyMask)
self.triggerHandler:writeUpdateStream(streamId)
streamWriteString(streamId,self.state.name)
if self.active then
if self.state ~= self.stateSend then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we call these stateSent (or lastStateSent) (in past tense) to make it clear what it is

@@ -34,6 +37,19 @@ function BalerAIDriver:driveFieldwork(dt)
return UnloadableFieldworkAIDriver.driveFieldwork(self, dt)
end

function BalerAIDriver:start(startingPoint)
UnloadableFieldworkAIDriver.start(self,startingPoint)
--use giants automaticDrop, so we don't have to do it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

@@ -54,7 +54,7 @@ function CombineUnloadManager:addNewCombines()
-- this isn't needed as combines will be added when an CombineAIDriver is created for them
-- but we want to be able to reload this file on the fly when developing/troubleshooting
for _, vehicle in pairs(g_currentMission.vehicles) do
if vehicle.cp.driver and vehicle.cp.driver:is_a(CombineAIDriver) and not self.combines[vehicle] then
if vehicle.cp.driver and vehicle.cp.driver.is_a and vehicle.cp.driver:is_a(CombineAIDriver) and not self.combines[vehicle] then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember these errors but still have no idea how can is_a not be defined if there is a driver.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might have something to do with this one :
status,driver,err,errDriverName = xpcall(AIDriver, function(err) printCallstack(); return self,err,"AIDriver" end, vehicle)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in courseplay:setAIDriver(vehicle, mode)

@@ -307,6 +307,13 @@ function FieldworkAIDriver:writeUpdateStream(streamId, connection, dirtyMask)
streamWriteIntN(streamId,self.convoyCurrentPosition,5)
streamWriteIntN(streamId,self.convoyTotalMembers,5)
end
if self.fieldworkState and self.fieldworkState ~= self.fieldworkStateSend then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sent

Also wondering if it would make sense to create a wrapper function to set states (instead of directly setting them) and that could also take care of syncing it on MP so there is no need for this check

-- not full/empty anymore, maybe because Refilling to a trailer, go back to work
self:clearInfoText(self:getFillLevelInfoText())
self:changeToFieldwork()
if g_updateLoopIndex % 5 == 0 then --small delay, to make sure no more fillLevel change is happening
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this rather a delay which could be anything between 0 and 4 loops? When it first comes here in loop 35, there'll be no delay.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is used, to make sure that in between to circles the fillunit already has been updated by giants

--there seems to be a bug, where "vehicle" is not always set once start is pressed
if vehicle and vehicle:isa(Vehicle) then
self:findPipeAndTrailer(vehicle)
end
CombineUnloadAIDriver.init(self, vehicle)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should set self.vehicle
still puzzled how this can happen

self.nearOverloadPoint = false
end

function OverloaderAIDriver:findPipeAndTrailer()
local implementWithPipe = AIDriverUtil.getImplementWithSpecialization(self.vehicle, Pipe)
function OverloaderAIDriver:findPipeAndTrailer(vehicle)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but isn't this only because we call it before CombineUnloadAIDriver.init(self, vehicle), which initializes self.vehicle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findPipeAndTrailer() has to be called before OverloaderAIDriver:setHudContent() so courseplay.hud:setOverloaderAIDriverContent(self.vehicle) can be called

@@ -27,17 +27,20 @@ OverloaderAIDriver.myStates = {
}

function OverloaderAIDriver:init(vehicle)
--there seems to be a bug, where "vehicle" is not always set once start is pressed
if vehicle and vehicle:isa(Vehicle) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this, if I self.vehicle is not set, nothing is going to work. Where do we set self.vehicle? or vehicle is not a vehicle when this is first called?

@@ -178,10 +176,27 @@ function TriggerHandler:onContinue()
end

function TriggerHandler:writeUpdateStream(streamId)
streamWriteString(streamId,self.loadingState.name)
if self.loadingState ~= self.loadingStateSend then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t

local ok = self:isLevelOk(workTool, index, fillUnit)
if not ok then
function UnloadableFieldworkAIDriver:areFillLevelsOk(fillLevelInfo)
for fillType, info in pairs(fillLevelInfo) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, I always wanted to do this...

-fix mode 2/3 in MP
-reduce network load by only sending updated values
-improved mode 9 raycast
-improved baler handling
-diff small changes
-enabled fueling by trailer
-mode 1/4 wait while they get loaded
-fixes mode 4
-improved shovelPositions
-mode 3 code cleanUp
-StateModule only for TriggerHandler for now
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.