Skip to content

Commit

Permalink
Display debug text instead of dbg channel number
Browse files Browse the repository at this point in the history
  • Loading branch information
schwiti6190 committed Sep 15, 2023
1 parent 025e3cd commit 7f2e442
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
38 changes: 19 additions & 19 deletions config/DebugChannels.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
text : is the tooltip shown in the hud.
-->
<DebugChannels>
<DebugChannel active="true" name="DBG_FIELDWORK" text="field work"/>
<DebugChannel active="true" name="DBG_FIND_BALES" text="bale collector"/>
<DebugChannel active="true" name="DBG_UNLOAD_COMBINE" text="unload combine"/>
<DebugChannel active="false" name="DBG_MODE_8" text="mode 8 - field supply"/>
<DebugChannel active="false" name="DBG_MODE_9" text="mode 9 - shovel fill/empty"/>
<DebugChannel active="true" name="DBG_PATHFINDER" text="pathfinder"/>
<DebugChannel active="true" name="DBG_SILO" text="bunker silo"/>
<DebugChannel active="false" name="DBG_TRIGGERS" text="triggers"/>
<DebugChannel active="true" name="DBG_REVERSE" text="reverse driving"/>
<DebugChannel active="true" name="DBG_TURN" text="turns"/>
<DebugChannel active="true" name="DBG_PPC" text="pure pursuit controller"/>
<DebugChannel active="true" name="DBG_TRAFFIC" text="traffic collision/proximity"/>
<DebugChannel active="true" name="DBG_COURSES" text="course save/load/generation"/>
<DebugChannel active="false" name="DBG_HUD" text="hud action"/>
<DebugChannel active="false" name="DBG_MULTIPLAYER" text="multiplayer"/>
<DebugChannel active="true" name="DBG_IMPLEMENTS" text="implements"/>
<DebugChannel active="false" name="DBG_UNCATEGORIZED" text="other"/>
<DebugChannel active="false" name="DBG_AI_DRIVER" text="AIDriver common"/>
<DebugChannel active="true" name="DBG_FIELDWORK" text="field work"/>
<DebugChannel active="true" name="DBG_FIND_BALES" text="bale collector"/>
<DebugChannel active="true" name="DBG_UNLOAD_COMBINE" text="unload combine"/>
<DebugChannel active="false" name="DBG_MODE_8" text="field supply"/>
<DebugChannel active="false" name="DBG_MODE_9" text="shovel mode"/>
<DebugChannel active="true" name="DBG_PATHFINDER" text="pathfinder"/>
<DebugChannel active="true" name="DBG_SILO" text="bunker silo"/>
<DebugChannel active="false" name="DBG_TRIGGERS" text="triggers"/>
<DebugChannel active="true" name="DBG_REVERSE" text="reverse driving"/>
<DebugChannel active="true" name="DBG_TURN" text="turns"/>
<DebugChannel active="true" name="DBG_PPC" text="ppc controller"/>
<DebugChannel active="true" name="DBG_TRAFFIC" text="collision/proximity"/>
<DebugChannel active="true" name="DBG_COURSES" text="courses"/>
<DebugChannel active="false" name="DBG_HUD" text="hud action"/>
<DebugChannel active="false" name="DBG_MULTIPLAYER" text="multiplayer"/>
<DebugChannel active="true" name="DBG_IMPLEMENTS" text="implements"/>
<DebugChannel active="false" name="DBG_UNCATEGORIZED" text="other"/>
<DebugChannel active="false" name="DBG_AI_DRIVER" text="AIDriver common"/>
<!-- this is to prevent spamming the log if not necessary (e.g. raycasts)-->
<DebugChannel active="false" name="DBG_CYCLIC" text="activate cyclic prints"/>
<DebugChannel active="false" name="DBG_CYCLIC" text="cyclic prints"/>
</DebugChannels>
4 changes: 2 additions & 2 deletions scripts/CpUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ end
---@param channel number
function CpUtil.debugFormat(channel, ...)
if CpDebug and CpDebug:isChannelActive(channel) then
CpUtil.internalPrint("dbg"..channel, ...)
CpUtil.internalPrint(CpDebug:getText(channel), ...)
end
end

Expand All @@ -162,7 +162,7 @@ function CpUtil.debugVehicle(channel, vehicle, ...)
local rootVehicle = vehicle and vehicle.rootVehicle
local active = rootVehicle == nil or rootVehicle.getCpSettings == nil or CpUtil.isVehicleDebugActive(rootVehicle)
if CpDebug and active and CpDebug:isChannelActive(channel) then
CpUtil.internalPrintVehicle(vehicle, "dbg"..channel, ...)
CpUtil.internalPrintVehicle(vehicle, CpDebug:getText(channel), ...)
end
end

Expand Down
11 changes: 8 additions & 3 deletions scripts/debug/CpDebug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function CpDebug:init()
self.isEnabled = true
--- Is the debug channel menu active ?
self.menuVisible = false

self.activatedColor = {1, 0.5, 0, 1.0}
self.disabledColor = {1, 1, 1, 1}
end
Expand Down Expand Up @@ -62,9 +61,15 @@ function CpDebug:isChannelActive(ix, vehicle)
if self.channels[ix] then
return self.channels[ix].active and vehicleDebugEnabled
else
CpUtil.info('Error: debug channel %s not found!', tostring(ix))
printCallstack()
CpUtil.error('Error: debug channel %s not found!', tostring(ix))
end
end

function CpDebug:getText(ix)
if not self.channels[ix] then
return "---"
end
return self.channels[ix].text
end

function CpDebug:setChannelActive(ix, active)
Expand Down

0 comments on commit 7f2e442

Please sign in to comment.