From 64fac95556917cae7b69b1843dc358f02fbe2df8 Mon Sep 17 00:00:00 2001 From: Beu Date: Wed, 28 Sep 2022 17:47:43 +0200 Subject: [PATCH] Add the possibility to dump Structs + prevent log being too big --- TM_DebugMode.Script.txt | 141 ++++++++++++++++++++++++++++------------ 1 file changed, 100 insertions(+), 41 deletions(-) diff --git a/TM_DebugMode.Script.txt b/TM_DebugMode.Script.txt index e777967..cf5721a 100644 --- a/TM_DebugMode.Script.txt +++ b/TM_DebugMode.Script.txt @@ -4,6 +4,7 @@ * To use it, you just have to change the line below to put the path of your mode: */ #Extends "Modes/TrackMania/TM_TimeAttack_Online.Script.txt" + // #RequireContext CSmMode #Setting S_DebugLib_RestrictUIto "" as "Restrict UI Admin to comma separated logins (all if empty)" @@ -140,18 +141,18 @@ foreach (Event in UIManager.PendingEvents) { } } } - case "DebugMode.ForVars.Dump.Teams0": { + case "DebugMode.VarInsp.Dump.Teams0": { declare Text tmp = Net_DebugMode_Logs; Net_DebugMode_Logs = ""; Net_DebugMode_Logs = Prefix ^ "Teams[0] dump:\n" ^ Dbg_DumpDeclareForVariables(Teams[0], False) ^"\n" ^ tmp; } - case "DebugMode.ForVars.Dump.UIAll": { + case "DebugMode.VarInsp.Dump.UIAll": { Net_DebugMode_Logs = Prefix ^ "UIAll dump:\n" ^ Dbg_DumpDeclareForVariables(UIManager.UIAll, False) ^"\n" ^ Net_DebugMode_Logs; } - case "DebugMode.ForVars.Dump.This": { + case "DebugMode.VarInsp.Dump.This": { Net_DebugMode_Logs = Prefix ^ "This dump:\n" ^ Dbg_DumpDeclareForVariables(This, False) ^"\n" ^ Net_DebugMode_Logs; } - case "DebugMode.ForVars.Dump.Player": { + case "DebugMode.VarInsp.ForVars.Dump.Player": { declare CSmPlayer Player; if (TL::Length(Event.CustomEventData[0]) == 36) { Player <=> ModeUtils::GetPlayerFromAccountId(Event.CustomEventData[0]); @@ -183,8 +184,40 @@ foreach (Event in UIManager.PendingEvents) { Net_DebugMode_Logs = Prefix ^ "ForVars dump: player not found\n" ^ Net_DebugMode_Logs; } } + case "DebugMode.VarInsp.Struct.Dump.Player": { + declare CSmPlayer Player; + if (TL::Length(Event.CustomEventData[0]) == 36) { + Player <=> ModeUtils::GetPlayerFromAccountId(Event.CustomEventData[0]); + } else if (TL::Length(Event.CustomEventData[0]) == 22) { + Player <=> GetPlayer(Event.CustomEventData[0]); + } else { + foreach (TmpPlayer in AllPlayers) { + if (TL::ToLowerCase(Event.CustomEventData[0]) == TL::ToLowerCase(TmpPlayer.User.Name)) { + Player <=> TmpPlayer; + break; + } + } + } + + if (Player != Null) { + if (Event.CustomEventData[1] == "player") { + Net_DebugMode_Logs = Prefix ^ "Player Struct dump for " ^ Player.User.Name ^ ":\n" ^ Player ^"\n" ^ Net_DebugMode_Logs; + } else if (Event.CustomEventData[1] == "score") { + Net_DebugMode_Logs = Prefix ^ "Score Struct dump for " ^ Player.User.Name ^ ":\n" ^ Player.Score ^"\n" ^ Net_DebugMode_Logs; + } else { + declare CUIConfig UI = UIManager.GetUI(Player); + if (UI != Null) { + Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ":\n" ^ UI ^"\n" ^ Net_DebugMode_Logs; + } else { + Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ": no UI found (it's a bot?)\n" ^ Net_DebugMode_Logs; + } + } + } else { + Net_DebugMode_Logs = Prefix ^ "Struct dump: player not found\n" ^ Net_DebugMode_Logs; + } + } default: { - Net_DebugMode_Logs = Prefix ^ "Custom Event received: " ^ Event.CustomEventType ^"\n" ^ Net_DebugMode_Logs; + Net_DebugMode_Logs = Prefix ^ "Struct Event received: " ^ Event.CustomEventType ^"\n" ^ Net_DebugMode_Logs; } } } @@ -242,6 +275,11 @@ else Prefix ^= Seconds; Prefix ^= "] "; declare netwrite Text Net_DebugMode_Logs for Teams[0]; +if (TL::Length(Net_DebugMode_Logs) > 1000000) { + Net_DebugMode_Logs = TL::SubString(Net_DebugMode_Logs, 0, 1000000); +} + + declare netwrite Integer Net_DebugMode_Logs_Serial for Teams[0]; Net_DebugMode_Logs_Serial += 1; *** @@ -309,8 +347,8 @@ Text GetManialink() {