@@ -10,6 +10,8 @@ CpAIWorker.SPEC_NAME = CpAIWorker.MOD_NAME .. CpAIWorker.NAME
1010CpAIWorker .KEY = " ." .. CpAIWorker .MOD_NAME .. CpAIWorker .NAME .. " ."
1111CpAIWorker .LAST_JOB_KEY = " vehicles.vehicle(?).aiJobVehicle.lastJob"
1212
13+ local logger = Logger (' CpAIWorker' , Logger .level .debug , CpUtil .DBG_AI_DRIVER )
14+
1315function CpAIWorker .initSpecialization ()
1416 local schema = Vehicle .xmlSchemaSavegame
1517 --- Registers the last job key.
@@ -248,15 +250,15 @@ end
248250
249251--- Directly starts a cp job or stops a currently active job.
250252function CpAIWorker :cpStartStopDriver (isStartedByHud )
251- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , " Start/stop cp helper" )
253+ logger : debug ( self , " Start/stop cp helper" )
252254 if self :getIsAIActive () then
253255 self :stopCurrentAIJob (AIMessageSuccessStoppedByUser .new ())
254- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , " Stopped current helper." )
256+ logger : debug ( self , " Stopped current helper." )
255257 else
256258 self :updateAIFieldWorkerImplementData ()
257259 local job = self :getCpStartableJob (isStartedByHud )
258260 if job == nil then
259- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , " Could not find a CP job to start!" )
261+ logger : debug ( self , " Could not find a CP job to start!" )
260262 return
261263 end
262264 if self :getCanStartCp () and job then
@@ -266,15 +268,15 @@ function CpAIWorker:cpStartStopDriver(isStartedByHud)
266268 local success , message = job :validate ()
267269 if success then
268270 g_client :getServerConnection ():sendEvent (AIJobStartRequestEvent .new (job , self :getOwnerFarmId ()))
269- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , " Cp helper started." )
271+ logger : debug ( self , " Cp helper started." )
270272 else
271- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , " Could not start CP helper: %s" , tostring (message ))
273+ logger : debug ( self , " Could not start CP helper: %s" , tostring (message ))
272274 if message then
273275 g_currentMission :showBlinkingWarning (" CP: " .. message , 5000 )
274276 end
275277 end
276278 else
277- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , " Could not start CP helper!" )
279+ logger : debug ( self , " Could not start CP helper!" )
278280 end
279281 end
280282end
@@ -352,10 +354,10 @@ function CpAIWorker:stopCurrentAIJob(superFunc, message, ...)
352354 -- since we often stop for instance in convoy mode when waiting for another vehicle to turn
353355 -- (when we do this, we set our maxSpeed to 0). So we also check our maxSpeed, this way the Giants timer will
354356 -- fire if we are blocked (thus have a maxSpeed > 0 but not moving)
355- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , ' Overriding the Giants did not move timer, with speed: %.2f' , maxSpeed )
357+ logger : debug ( self , ' Overriding the Giants did not move timer, with speed: %.2f' , maxSpeed )
356358 return
357359 else
358- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , ' Giants did not move timer triggered, with speed: %.2f!' , maxSpeed )
360+ logger : debug ( self , ' Giants did not move timer triggered, with speed: %.2f!' , maxSpeed )
359361 end
360362 end
361363 end
@@ -364,7 +366,7 @@ function CpAIWorker:stopCurrentAIJob(superFunc, message, ...)
364366 return
365367 end
366368 end
367- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , " stop message: %s" , message :getI18NText ())
369+ logger : debug ( self , " stop message: %s" , message :getI18NText ())
368370 superFunc (self , message ,... )
369371end
370372
@@ -385,6 +387,7 @@ function CpAIWorker:onUpdate(dt)
385387 return
386388 end
387389 local tX , tZ , moveForwards , maxSpeedStrategy = spec .driveStrategy :getDriveData (dt )
390+ logger :debug (' Speed %.1f' , maxSpeedStrategy )
388391 local maxSpeed = math.min (maxSpeedStrategy or math.huge , self :getCruiseControlMaxSpeed ())
389392 if not spec .driveStrategy then
390393 return
@@ -533,13 +536,13 @@ end
533536--- Auto drive stop
534537function CpAIWorker :onStopAutoDrive (isPassingToCP , isStartingAIVE )
535538 if g_server then
536- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , " isPassingToCP: %s, isStartingAIVE: %s" , tostring (isPassingToCP ), tostring (isStartingAIVE ))
539+ logger : debug ( self , " isPassingToCP: %s, isStartingAIVE: %s" , tostring (isPassingToCP ), tostring (isStartingAIVE ))
537540 if self .ad .restartCP then
538541 --- Is restarted for refilling or unloading.
539- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , " Was refilled/unloaded by AD." )
542+ logger : debug ( self , " Was refilled/unloaded by AD." )
540543 else
541544 --- Is sent to a field.
542- CpUtil . debugVehicle ( CpDebug . DBG_FIELDWORK , self , " Was sent to field by AD." )
545+ logger : debug ( self , " Was sent to field by AD." )
543546 end
544547 end
545548end
0 commit comments