Better debug print
This commit is contained in:
@@ -47,7 +47,7 @@ end
|
|||||||
---Setup a new toc mod data data class
|
---Setup a new toc mod data data class
|
||||||
---@param key string
|
---@param key string
|
||||||
function DataController:setup(key)
|
function DataController:setup(key)
|
||||||
TOC_DEBUG.print("[DataController] Running setup")
|
TOC_DEBUG.print("Running setup")
|
||||||
|
|
||||||
---@type tocModDataType
|
---@type tocModDataType
|
||||||
self.tocData = {
|
self.tocData = {
|
||||||
@@ -329,7 +329,7 @@ function DataController.ReceiveData(key, data)
|
|||||||
-- During startup the game can return Bob as the player username, adding a useless ModData table
|
-- During startup the game can return Bob as the player username, adding a useless ModData table
|
||||||
if key == "TOC_Bob" then return end
|
if key == "TOC_Bob" then return end
|
||||||
|
|
||||||
TOC_DEBUG.print("[DataController] ReceiveData for " .. key)
|
TOC_DEBUG.print("ReceiveData for " .. key)
|
||||||
if data == {} or data == nil then
|
if data == {} or data == nil then
|
||||||
TOC_DEBUG.print("table is nil... returning")
|
TOC_DEBUG.print("table is nil... returning")
|
||||||
return
|
return
|
||||||
@@ -339,11 +339,11 @@ function DataController.ReceiveData(key, data)
|
|||||||
local username = key:sub(5)
|
local username = key:sub(5)
|
||||||
local handler = DataController.GetInstance(username)
|
local handler = DataController.GetInstance(username)
|
||||||
if handler.isResetForced or data == nil or data == {} or data == false then
|
if handler.isResetForced or data == nil or data == {} or data == false then
|
||||||
TOC_DEBUG.print("[DataController] Setup")
|
TOC_DEBUG.print("Setup")
|
||||||
handler:setup(key)
|
handler:setup(key)
|
||||||
handler.isResetForced = false
|
handler.isResetForced = false
|
||||||
else
|
else
|
||||||
TOC_DEBUG.print("[DataController] Reapply")
|
TOC_DEBUG.print("Reapply")
|
||||||
handler:reapplyTocData(data)
|
handler:reapplyTocData(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -364,7 +364,7 @@ function DataController.ReceiveData(key, data)
|
|||||||
|
|
||||||
-- Transmit it to the server
|
-- Transmit it to the server
|
||||||
ModData.transmit(key)
|
ModData.transmit(key)
|
||||||
TOC_DEBUG.print("[DataController] Transmitting data after receiving it for: " .. handler.username)
|
TOC_DEBUG.print("Transmitting data after receiving it for: " .. handler.username)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -380,7 +380,7 @@ function DataController.GetInstance(username)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if DataController.instances[username] == nil then
|
if DataController.instances[username] == nil then
|
||||||
TOC_DEBUG.print("[DataController] Creating NEW instance for " .. username)
|
TOC_DEBUG.print("Creating NEW instance for " .. username)
|
||||||
return DataController:new(username)
|
return DataController:new(username)
|
||||||
else
|
else
|
||||||
return DataController.instances[username]
|
return DataController.instances[username]
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function LocalPlayerController.InitializePlayer(isForced)
|
|||||||
local playerObj = getPlayer()
|
local playerObj = getPlayer()
|
||||||
local username = playerObj:getUsername()
|
local username = playerObj:getUsername()
|
||||||
|
|
||||||
TOC_DEBUG.print("[LocalPlayerController] Initializing local player: " .. username)
|
TOC_DEBUG.print("Initializing local player: " .. username)
|
||||||
|
|
||||||
DataController:new(username, isForced)
|
DataController:new(username, isForced)
|
||||||
LocalPlayerController.playerObj = playerObj
|
LocalPlayerController.playerObj = playerObj
|
||||||
@@ -281,7 +281,7 @@ end
|
|||||||
|
|
||||||
---Starts safely the loop to update cicatrzation
|
---Starts safely the loop to update cicatrzation
|
||||||
function LocalPlayerController.ToggleUpdateAmputations()
|
function LocalPlayerController.ToggleUpdateAmputations()
|
||||||
TOC_DEBUG.print("[LocalPlayerController] Activating amputation handling loop (if it wasn't active before)")
|
TOC_DEBUG.print("Activating amputation handling loop (if it wasn't active before)")
|
||||||
CommonMethods.SafeStartEvent("EveryHours", LocalPlayerController.UpdateAmputations)
|
CommonMethods.SafeStartEvent("EveryHours", LocalPlayerController.UpdateAmputations)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ CachedDataHandler.amputatedLimbs = {}
|
|||||||
---Calculate the currently amputated limbs for a certain player
|
---Calculate the currently amputated limbs for a certain player
|
||||||
---@param username string
|
---@param username string
|
||||||
function CachedDataHandler.CalculateAmputatedLimbs(username)
|
function CachedDataHandler.CalculateAmputatedLimbs(username)
|
||||||
TOC_DEBUG.print("[CachedDataHandler] Calculating amputated limbs for " .. username)
|
TOC_DEBUG.print("Calculating amputated limbs for " .. username)
|
||||||
CachedDataHandler.amputatedLimbs[username] = {}
|
CachedDataHandler.amputatedLimbs[username] = {}
|
||||||
local dcInst = DataController.GetInstance(username)
|
local dcInst = DataController.GetInstance(username)
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ end
|
|||||||
---@param username string
|
---@param username string
|
||||||
---@param limbName string
|
---@param limbName string
|
||||||
function CachedDataHandler.AddAmputatedLimb(username, limbName)
|
function CachedDataHandler.AddAmputatedLimb(username, limbName)
|
||||||
TOC_DEBUG.print("[CachedDataHandler] Added " .. limbName .. " to known amputated limbs for " .. username)
|
TOC_DEBUG.print("Added " .. limbName .. " to known amputated limbs for " .. username)
|
||||||
|
|
||||||
-- Add it to the generic list
|
-- Add it to the generic list
|
||||||
CachedDataHandler.amputatedLimbs[username][limbName] = limbName
|
CachedDataHandler.amputatedLimbs[username][limbName] = limbName
|
||||||
@@ -57,7 +57,7 @@ CachedDataHandler.highestAmputatedLimbs = {}
|
|||||||
---Calcualate the highest point of amputations achieved by the player
|
---Calcualate the highest point of amputations achieved by the player
|
||||||
---@param username string
|
---@param username string
|
||||||
function CachedDataHandler.CalculateHighestAmputatedLimbs(username)
|
function CachedDataHandler.CalculateHighestAmputatedLimbs(username)
|
||||||
TOC_DEBUG.print("[CachedDataHandler] Triggered CalculateHighestAmputatedLimbs")
|
TOC_DEBUG.print("Triggered CalculateHighestAmputatedLimbs")
|
||||||
local dcInst = DataController.GetInstance(username)
|
local dcInst = DataController.GetInstance(username)
|
||||||
if dcInst == nil then
|
if dcInst == nil then
|
||||||
TOC_DEBUG.print("DataController not found for " .. username)
|
TOC_DEBUG.print("DataController not found for " .. username)
|
||||||
@@ -84,7 +84,7 @@ function CachedDataHandler.CalculateHighestAmputatedLimbs(username)
|
|||||||
local limbName = k
|
local limbName = k
|
||||||
local index = CommonMethods.GetSide(limbName)
|
local index = CommonMethods.GetSide(limbName)
|
||||||
if dcInst:getIsCut(limbName) and dcInst:getIsVisible(limbName) then
|
if dcInst:getIsCut(limbName) and dcInst:getIsVisible(limbName) then
|
||||||
TOC_DEBUG.print("[CachedDataHandler] Added Highest Amputation: " .. limbName)
|
TOC_DEBUG.print("Added Highest Amputation: " .. limbName)
|
||||||
CachedDataHandler.highestAmputatedLimbs[username][index] = limbName
|
CachedDataHandler.highestAmputatedLimbs[username][index] = limbName
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ function Main.Initialize()
|
|||||||
---Looop until we've successfully initialized the mod
|
---Looop until we've successfully initialized the mod
|
||||||
local function TryToInitialize()
|
local function TryToInitialize()
|
||||||
local pl = getPlayer()
|
local pl = getPlayer()
|
||||||
TOC_DEBUG.print("[Main] Current username in TryToInitialize: " .. pl:getUsername())
|
TOC_DEBUG.print("Current username in TryToInitialize: " .. pl:getUsername())
|
||||||
if pl:getUsername() == "Bob" then
|
if pl:getUsername() == "Bob" then
|
||||||
TOC_DEBUG.print("Username is still Bob, waiting")
|
TOC_DEBUG.print("Username is still Bob, waiting")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ end
|
|||||||
else
|
else
|
||||||
if highestAmputations[side] == nil then return end
|
if highestAmputations[side] == nil then return end
|
||||||
local limbName = highestAmputations[side]
|
local limbName = highestAmputations[side]
|
||||||
TOC_DEBUG.print("Drawing " .. tostring(limbName) .. " for " .. username)
|
--TOC_DEBUG.print("Drawing " .. tostring(limbName) .. " for " .. username)
|
||||||
|
|
||||||
local cicTime = DataController.GetInstance(username):getCicatrizationTime(limbName)
|
local cicTime = DataController.GetInstance(username):getCicatrizationTime(limbName)
|
||||||
redColor = GetColorFromCicatrizationTime(cicTime, limbName)
|
redColor = GetColorFromCicatrizationTime(cicTime, limbName)
|
||||||
@@ -185,7 +185,7 @@ end
|
|||||||
local og_ISMedicalCheckAction_perform = ISMedicalCheckAction.perform
|
local og_ISMedicalCheckAction_perform = ISMedicalCheckAction.perform
|
||||||
function ISMedicalCheckAction:perform()
|
function ISMedicalCheckAction:perform()
|
||||||
local username = self.otherPlayer:getUsername()
|
local username = self.otherPlayer:getUsername()
|
||||||
TOC_DEBUG.print("[HealthPanel] Medical Action on " .. username )
|
TOC_DEBUG.print("Medical Action on " .. username )
|
||||||
|
|
||||||
-- We need to recalculate them here before we can create the highest amputations point
|
-- We need to recalculate them here before we can create the highest amputations point
|
||||||
CachedDataHandler.CalculateAmputatedLimbs(username)
|
CachedDataHandler.CalculateAmputatedLimbs(username)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function ServerDataHandler.AddTable(key, table)
|
|||||||
-- Check if key is valid
|
-- Check if key is valid
|
||||||
if not luautils.stringStarts(key, StaticData.MOD_NAME .. "_") then return end
|
if not luautils.stringStarts(key, StaticData.MOD_NAME .. "_") then return end
|
||||||
|
|
||||||
TOC_DEBUG.print("[ServerDataHandler] Received TOC ModData: " .. tostring(key))
|
TOC_DEBUG.print("Received TOC ModData: " .. tostring(key))
|
||||||
ModData.add(key, table) -- Add it to the server mod data
|
ModData.add(key, table) -- Add it to the server mod data
|
||||||
ServerDataHandler.modData[key] = table
|
ServerDataHandler.modData[key] = table
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,10 +14,28 @@ end
|
|||||||
---@param string string
|
---@param string string
|
||||||
function TOC_DEBUG.print(string)
|
function TOC_DEBUG.print(string)
|
||||||
if isDebugEnabled() then
|
if isDebugEnabled() then
|
||||||
print("TOC: " .. tostring(string))
|
local runningFile = TOC_DEBUG.getRunningFile()
|
||||||
|
print("TOC: " .. "[" .. runningFile .. "] " .. tostring(string))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Horrendous but I don't really care about performance for this
|
||||||
|
---@return string
|
||||||
|
function TOC_DEBUG.getRunningFile()
|
||||||
|
local coroutine = getCurrentCoroutine()
|
||||||
|
|
||||||
|
local o = getCoroutineObjStack(coroutine, 0)
|
||||||
|
if o then
|
||||||
|
local s = KahluaUtil.rawTostring2(o)
|
||||||
|
local match = string.match(s, "file: (%w+)%.lua")
|
||||||
|
if match then return match end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return ""
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function TOC_DEBUG.printTable(table, indent)
|
function TOC_DEBUG.printTable(table, indent)
|
||||||
if not table then return end
|
if not table then return end
|
||||||
indent = indent or ""
|
indent = indent or ""
|
||||||
|
|||||||
Reference in New Issue
Block a user