diff --git a/media/lua/client/TOC/Controllers/DataController.lua b/media/lua/client/TOC/Controllers/DataController.lua index 42034ae..0c5194a 100644 --- a/media/lua/client/TOC/Controllers/DataController.lua +++ b/media/lua/client/TOC/Controllers/DataController.lua @@ -47,7 +47,7 @@ end ---Setup a new toc mod data data class ---@param key string function DataController:setup(key) - TOC_DEBUG.print("[DataController] Running setup") + TOC_DEBUG.print("Running setup") ---@type tocModDataType 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 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 TOC_DEBUG.print("table is nil... returning") return @@ -339,11 +339,11 @@ function DataController.ReceiveData(key, data) local username = key:sub(5) local handler = DataController.GetInstance(username) 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.isResetForced = false else - TOC_DEBUG.print("[DataController] Reapply") + TOC_DEBUG.print("Reapply") handler:reapplyTocData(data) end @@ -364,7 +364,7 @@ function DataController.ReceiveData(key, data) -- Transmit it to the server 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 @@ -380,7 +380,7 @@ function DataController.GetInstance(username) end 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) else return DataController.instances[username] diff --git a/media/lua/client/TOC/Controllers/LocalPlayerController.lua b/media/lua/client/TOC/Controllers/LocalPlayerController.lua index 9aef0b3..d14700a 100644 --- a/media/lua/client/TOC/Controllers/LocalPlayerController.lua +++ b/media/lua/client/TOC/Controllers/LocalPlayerController.lua @@ -23,7 +23,7 @@ function LocalPlayerController.InitializePlayer(isForced) local playerObj = getPlayer() local username = playerObj:getUsername() - TOC_DEBUG.print("[LocalPlayerController] Initializing local player: " .. username) + TOC_DEBUG.print("Initializing local player: " .. username) DataController:new(username, isForced) LocalPlayerController.playerObj = playerObj @@ -281,7 +281,7 @@ end ---Starts safely the loop to update cicatrzation 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) end diff --git a/media/lua/client/TOC/Handlers/CachedDataHandler.lua b/media/lua/client/TOC/Handlers/CachedDataHandler.lua index 79c0482..a12d8b3 100644 --- a/media/lua/client/TOC/Handlers/CachedDataHandler.lua +++ b/media/lua/client/TOC/Handlers/CachedDataHandler.lua @@ -19,7 +19,7 @@ CachedDataHandler.amputatedLimbs = {} ---Calculate the currently amputated limbs for a certain player ---@param username string function CachedDataHandler.CalculateAmputatedLimbs(username) - TOC_DEBUG.print("[CachedDataHandler] Calculating amputated limbs for " .. username) + TOC_DEBUG.print("Calculating amputated limbs for " .. username) CachedDataHandler.amputatedLimbs[username] = {} local dcInst = DataController.GetInstance(username) @@ -38,7 +38,7 @@ end ---@param username string ---@param limbName string 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 CachedDataHandler.amputatedLimbs[username][limbName] = limbName @@ -57,7 +57,7 @@ CachedDataHandler.highestAmputatedLimbs = {} ---Calcualate the highest point of amputations achieved by the player ---@param username string function CachedDataHandler.CalculateHighestAmputatedLimbs(username) - TOC_DEBUG.print("[CachedDataHandler] Triggered CalculateHighestAmputatedLimbs") + TOC_DEBUG.print("Triggered CalculateHighestAmputatedLimbs") local dcInst = DataController.GetInstance(username) if dcInst == nil then TOC_DEBUG.print("DataController not found for " .. username) @@ -84,7 +84,7 @@ function CachedDataHandler.CalculateHighestAmputatedLimbs(username) local limbName = k local index = CommonMethods.GetSide(limbName) 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 end end diff --git a/media/lua/client/TOC/Main.lua b/media/lua/client/TOC/Main.lua index edd3ea7..c8e2188 100644 --- a/media/lua/client/TOC/Main.lua +++ b/media/lua/client/TOC/Main.lua @@ -58,7 +58,7 @@ function Main.Initialize() ---Looop until we've successfully initialized the mod local function TryToInitialize() 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 TOC_DEBUG.print("Username is still Bob, waiting") return diff --git a/media/lua/client/TOC/UI/HealthPanel.lua b/media/lua/client/TOC/UI/HealthPanel.lua index 6b5421e..89e2eda 100644 --- a/media/lua/client/TOC/UI/HealthPanel.lua +++ b/media/lua/client/TOC/UI/HealthPanel.lua @@ -107,7 +107,7 @@ end else if highestAmputations[side] == nil then return end 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) redColor = GetColorFromCicatrizationTime(cicTime, limbName) @@ -185,7 +185,7 @@ end local og_ISMedicalCheckAction_perform = ISMedicalCheckAction.perform function ISMedicalCheckAction:perform() 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 CachedDataHandler.CalculateAmputatedLimbs(username) diff --git a/media/lua/server/TOC/ServerDataHandler.lua b/media/lua/server/TOC/ServerDataHandler.lua index 7228007..0975c26 100644 --- a/media/lua/server/TOC/ServerDataHandler.lua +++ b/media/lua/server/TOC/ServerDataHandler.lua @@ -20,7 +20,7 @@ function ServerDataHandler.AddTable(key, table) -- Check if key is valid 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 ServerDataHandler.modData[key] = table end diff --git a/media/lua/shared/TOC/Debug.lua b/media/lua/shared/TOC/Debug.lua index 7d321e1..796e485 100644 --- a/media/lua/shared/TOC/Debug.lua +++ b/media/lua/shared/TOC/Debug.lua @@ -14,10 +14,28 @@ end ---@param string string function TOC_DEBUG.print(string) if isDebugEnabled() then - print("TOC: " .. tostring(string)) + local runningFile = TOC_DEBUG.getRunningFile() + print("TOC: " .. "[" .. runningFile .. "] " .. tostring(string)) 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) if not table then return end indent = indent or ""