diff --git a/TM_DebugMode.Script.txt b/TM_DebugMode.Script.txt index 9b0da64..bccc2d8 100644 --- a/TM_DebugMode.Script.txt +++ b/TM_DebugMode.Script.txt @@ -3,7 +3,7 @@ * This mode is used to debug your modes during development. * 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" +#Extends "Modes/TM_TeamsCup.Script.txt" // #RequireContext CSmMode @@ -30,12 +30,12 @@ Layers::SetType(C_DebugMode_MainUI, CUILayer::EUILayerType::Normal); ***Match_InitMap*** *** if (S_DebugLib_RestrictUIto == "") { - Layers::Attach(C_DebugMode_MainUI); + Layers::Attach(C_DebugMode_MainUI); } else { - foreach (Login in TL::Split(",", S_DebugLib_RestrictUIto)) { - declare CSmPlayer Player = GetPlayer(Login); - if (Player != Null) Layers::Attach(C_DebugMode_MainUI, Player); - } + foreach (Login in TL::Split(",", S_DebugLib_RestrictUIto)) { + declare CSmPlayer Player = GetPlayer(Login); + if (Player != Null) Layers::Attach(C_DebugMode_MainUI, Player); + } } *** @@ -43,221 +43,221 @@ if (S_DebugLib_RestrictUIto == "") { *** // Manage Custom UI Events foreach (Event in UIManager.PendingEvents) { - +++DebugMode_LogFormat+++ - switch (Event.CustomEventType) { - case "DebugMode.ClearLogs": { - Net_DebugMode_Logs = Prefix ^ "Logs cleared"; - } - case "DebugMode.Bots.DelBots": { - declare Text Name = Event.CustomEventData[0]; - declare Integer NumberOfBots = TL::ToInteger(Event.CustomEventData[1]); - if (NumberOfBots == -1) { - Users_DestroyAllFakes(); - } else { - foreach (Player in AllPlayers) { - if (Player.IsFakePlayer) { - if (Name == "" || TL::ToLowerCase(Player.User.Name) == TL::ToLowerCase(Name)) { - Net_DebugMode_Logs = Prefix ^ "Bots: Remove bot \"" ^ Player.User.Name ^ "\"\n" ^ Net_DebugMode_Logs; - Users_DestroyFake(Player.User); - NumberOfBots -= 1; - } else { - Net_DebugMode_Logs = Prefix ^ "Bots: Player not found\n" ^ Net_DebugMode_Logs; - } - } - if (NumberOfBots == 0) break; - } - } - } - case "DebugMode.Bots.AddBots": { - declare Text Name = Event.CustomEventData[0]; - declare Integer TeamId = TL::ToInteger(Event.CustomEventData[1]); - if (TeamId == -1 && Event.CustomEventData[1] == "") TeamId = 0; - declare Integer NumberOfBots = TL::ToInteger(Event.CustomEventData[2]); - if (TeamId != -1 && Teams.existskey(TeamId)) { - for (I, 1, NumberOfBots) { - declare CUser User = Users_CreateFake(Name, TeamId); - if (User != Null) { - Net_DebugMode_Logs = Prefix ^ "Bots: Add bot \"" ^ User.Name ^ "\"\n" ^ Net_DebugMode_Logs; - } else { - Net_DebugMode_Logs = Prefix ^ "Bots: unknown error while adding bot \"" ^ Name ^ "\"\n" ^ Net_DebugMode_Logs; - } - } - } else { - Net_DebugMode_Logs = Prefix ^ "Bots: Invalid TeamId\n" ^ Net_DebugMode_Logs; - } - } - case "DebugMode.PlayersControl.Set": { - declare Text TargetText = Event.CustomEventData[2]; - declare CSmPlayer[] Targets; - if (TargetText == "allbots" || TargetText == "allplayers") { - foreach (Player in Players) { - if (TargetText == "allbots" && !Player.IsFakePlayer) continue; - Targets.add(Player); - } - } else { - declare CSmPlayer TmpPlayer = GetPlayer(TargetText); - if (TmpPlayer != Null) { - Targets.add(TmpPlayer); - } - } - declare Real[] Speed; - foreach (SpeedText in TL::Split(",", Event.CustomEventData[0])) { - Speed.add(ML::Clamp(TL::ToReal(SpeedText), -999., 999.)); - } - if (Speed.count > 0) { - declare Real[] Steer; - foreach (SteerText in TL::Split(",", Event.CustomEventData[1])) { - Steer.add(ML::Clamp(TL::ToReal(SteerText), -1., 1.)); - } - - foreach (Target in Targets) { - if (Target.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned) continue; - - Target.TrustClientSimu = False; - SetPlayerVehicle_ControlledByMode(Target, True); - - declare Real SteerValue; - if (Steer.count == 2) { - SteerValue = ML::Rand(Steer[0] , Steer[1]); - } else if (Steer.count == 1) { - SteerValue = Steer[0]; - } else { - SteerValue = 0.; - } - SetPlayerVehicle_SteerValue(Target, SteerValue); - - declare Real SpeedValue; - if (Speed.count == 1) { - SpeedValue = Speed[0]; - } else { - SpeedValue = ML::Rand(Speed[0], Speed[1]); - } - SetPlayerVehicle_TargetSpeedValue(Target, SpeedValue); - - Net_DebugMode_Logs = Prefix ^ "PlayersControl: Set Player " ^ Target.User.Name ^ " speed to " ^ SpeedValue ^ " & steer to " ^ SteerValue ^ "\n" ^ Net_DebugMode_Logs; - } - } else { - foreach (Target in Targets) { - if (Target.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned) continue; - - SetPlayerVehicle_ControlledByMode(Target, False); - Race::ApplyNetworkMode(Target); //< Restore TrustClientSimu to its default value - } - } - } - 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.VarInsp.Dump.UIAll": { - Net_DebugMode_Logs = Prefix ^ "UIAll dump:\n" ^ Dbg_DumpDeclareForVariables(UIManager.UIAll, False) ^"\n" ^ Net_DebugMode_Logs; - } - case "DebugMode.VarInsp.Dump.This": { - Net_DebugMode_Logs = Prefix ^ "This dump:\n" ^ Dbg_DumpDeclareForVariables(This, False) ^"\n" ^ Net_DebugMode_Logs; - } - case "DebugMode.VarInsp.ForVars.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 ForVars dump for " ^ Player.User.Name ^ ":\n" ^ Dbg_DumpDeclareForVariables(Player, False) ^"\n" ^ Net_DebugMode_Logs; - } else if (Event.CustomEventData[1] == "score") { - Net_DebugMode_Logs = Prefix ^ "Score ForVars dump for " ^ Player.User.Name ^ ":\n" ^ Dbg_DumpDeclareForVariables(Player.Score, False) ^"\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" ^ Dbg_DumpDeclareForVariables(UI, False) ^"\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 ^ "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 ^ "Struct Event received: " ^ Event.CustomEventType ^"\n" ^ Net_DebugMode_Logs; - } - } + +++DebugMode_LogFormat+++ + switch (Event.CustomEventType) { + case "DebugMode.ClearLogs": { + Net_DebugMode_Logs = Prefix ^ "Logs cleared"; + } + case "DebugMode.Bots.DelBots": { + declare Text Name = Event.CustomEventData[0]; + declare Integer NumberOfBots = TL::ToInteger(Event.CustomEventData[1]); + if (NumberOfBots == -1) { + Users_DestroyAllFakes(); + } else { + foreach (Player in AllPlayers) { + if (Player.IsFakePlayer) { + if (Name == "" || TL::ToLowerCase(Player.User.Name) == TL::ToLowerCase(Name)) { + Net_DebugMode_Logs = Prefix ^ "Bots: Remove bot \"" ^ Player.User.Name ^ "\"\n" ^ Net_DebugMode_Logs; + Users_DestroyFake(Player.User); + NumberOfBots -= 1; + } else { + Net_DebugMode_Logs = Prefix ^ "Bots: Player not found\n" ^ Net_DebugMode_Logs; + } + } + if (NumberOfBots == 0) break; + } + } + } + case "DebugMode.Bots.AddBots": { + declare Text Name = Event.CustomEventData[0]; + declare Integer TeamId = TL::ToInteger(Event.CustomEventData[1]); + if (TeamId == -1 && Event.CustomEventData[1] == "") TeamId = 0; + declare Integer NumberOfBots = TL::ToInteger(Event.CustomEventData[2]); + if (TeamId != -1 && Teams.existskey(TeamId)) { + for (I, 1, NumberOfBots) { + declare CUser User = Users_CreateFake(Name, TeamId); + if (User != Null) { + Net_DebugMode_Logs = Prefix ^ "Bots: Add bot \"" ^ User.Name ^ "\"\n" ^ Net_DebugMode_Logs; + } else { + Net_DebugMode_Logs = Prefix ^ "Bots: unknown error while adding bot \"" ^ Name ^ "\"\n" ^ Net_DebugMode_Logs; + } + } + } else { + Net_DebugMode_Logs = Prefix ^ "Bots: Invalid TeamId\n" ^ Net_DebugMode_Logs; + } + } + case "DebugMode.PlayersControl.Set": { + declare Text TargetText = Event.CustomEventData[2]; + declare CSmPlayer[] Targets; + if (TargetText == "allbots" || TargetText == "allplayers") { + foreach (Player in Players) { + if (TargetText == "allbots" && !Player.IsFakePlayer) continue; + Targets.add(Player); + } + } else { + declare CSmPlayer TmpPlayer = GetPlayer(TargetText); + if (TmpPlayer != Null) { + Targets.add(TmpPlayer); + } + } + declare Real[] Speed; + foreach (SpeedText in TL::Split(",", Event.CustomEventData[0])) { + Speed.add(ML::Clamp(TL::ToReal(SpeedText), -999., 999.)); + } + if (Speed.count > 0) { + declare Real[] Steer; + foreach (SteerText in TL::Split(",", Event.CustomEventData[1])) { + Steer.add(ML::Clamp(TL::ToReal(SteerText), -1., 1.)); + } + + foreach (Target in Targets) { + if (Target.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned) continue; + + Target.TrustClientSimu = False; + SetPlayerVehicle_ControlledByMode(Target, True); + + declare Real SteerValue; + if (Steer.count == 2) { + SteerValue = ML::Rand(Steer[0] , Steer[1]); + } else if (Steer.count == 1) { + SteerValue = Steer[0]; + } else { + SteerValue = 0.; + } + SetPlayerVehicle_SteerValue(Target, SteerValue); + + declare Real SpeedValue; + if (Speed.count == 1) { + SpeedValue = Speed[0]; + } else { + SpeedValue = ML::Rand(Speed[0], Speed[1]); + } + SetPlayerVehicle_TargetSpeedValue(Target, SpeedValue); + + Net_DebugMode_Logs = Prefix ^ "PlayersControl: Set Player " ^ Target.User.Name ^ " speed to " ^ SpeedValue ^ " & steer to " ^ SteerValue ^ "\n" ^ Net_DebugMode_Logs; + } + } else { + foreach (Target in Targets) { + if (Target.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned) continue; + + SetPlayerVehicle_ControlledByMode(Target, False); + Race::ApplyNetworkMode(Target); //< Restore TrustClientSimu to its default value + } + } + } + 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.VarInsp.Dump.UIAll": { + Net_DebugMode_Logs = Prefix ^ "UIAll dump:\n" ^ Dbg_DumpDeclareForVariables(UIManager.UIAll, False) ^"\n" ^ Net_DebugMode_Logs; + } + case "DebugMode.VarInsp.Dump.This": { + Net_DebugMode_Logs = Prefix ^ "This dump:\n" ^ Dbg_DumpDeclareForVariables(This, False) ^"\n" ^ Net_DebugMode_Logs; + } + case "DebugMode.VarInsp.ForVars.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 ForVars dump for " ^ Player.User.Name ^ ":\n" ^ Dbg_DumpDeclareForVariables(Player, False) ^"\n" ^ Net_DebugMode_Logs; + } else if (Event.CustomEventData[1] == "score") { + Net_DebugMode_Logs = Prefix ^ "Score ForVars dump for " ^ Player.User.Name ^ ":\n" ^ Dbg_DumpDeclareForVariables(Player.Score, False) ^"\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" ^ Dbg_DumpDeclareForVariables(UI, False) ^"\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 ^ "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 ^ "Struct Event received: " ^ Event.CustomEventType ^"\n" ^ Net_DebugMode_Logs; + } + } } foreach (Event in PendingEvents) { - +++DebugMode_LogFormat+++ - Net_DebugMode_Logs = Prefix ^ "CSmMode PendingEvent: " ^ Event.Type ^"\n" ^ Net_DebugMode_Logs; - if (Event.Type == CSmModeEvent::EType::OnPlayerAdded) { - if (Event.Player != Null && TL::Split(",", S_DebugLib_RestrictUIto).exists(Event.Player.User.Login)) { - Layers::Attach(C_DebugMode_MainUI, Event.Player); - } - } + +++DebugMode_LogFormat+++ + Net_DebugMode_Logs = Prefix ^ "CSmMode PendingEvent: " ^ Event.Type ^"\n" ^ Net_DebugMode_Logs; + if (Event.Type == CSmModeEvent::EType::OnPlayerAdded) { + if (Event.Player != Null && TL::Split(",", S_DebugLib_RestrictUIto).exists(Event.Player.User.Login)) { + Layers::Attach(C_DebugMode_MainUI, Event.Player); + } + } } foreach (Event in XmlRpc.PendingEvents) { - +++DebugMode_LogFormat+++ - if (Event.Type == CXmlRpcEvent::EType::CallbackArray) { - Net_DebugMode_Logs = Prefix ^ "XmlRpc PendingEvent: " ^ Event.ParamArray1 ^"\n" ^ Net_DebugMode_Logs; - } else { - Net_DebugMode_Logs = Prefix ^ "XmlRpc PendingEvent: " ^ Event.Param1 ^"\n" ^ Net_DebugMode_Logs; - } + +++DebugMode_LogFormat+++ + if (Event.Type == CXmlRpcEvent::EType::CallbackArray) { + Net_DebugMode_Logs = Prefix ^ "XmlRpc PendingEvent: " ^ Event.ParamArray1 ^"\n" ^ Net_DebugMode_Logs; + } else { + Net_DebugMode_Logs = Prefix ^ "XmlRpc PendingEvent: " ^ Event.Param1 ^"\n" ^ Net_DebugMode_Logs; + } } declare RacePendingEvents = Race::GetPendingEvents(); foreach (Event in RacePendingEvents) { - +++DebugMode_LogFormat+++ - declare Text Type = "Unknown"; - switch (Event.Type) { - case 1: Type = "Waypoint"; - case 2: Type = "GiveUp"; - case 3: Type = "Respawn"; - case 4: Type = "SkipOutro"; - case 5: Type = "StartLine"; - case 6: Type = "Eliminated"; - } - Net_DebugMode_Logs = Prefix ^ "Race Pending Event: " ^ Type ^"\n" ^ Net_DebugMode_Logs; + +++DebugMode_LogFormat+++ + declare Text Type = "Unknown"; + switch (Event.Type) { + case 1: Type = "Waypoint"; + case 2: Type = "GiveUp"; + case 3: Type = "Respawn"; + case 4: Type = "SkipOutro"; + case 5: Type = "StartLine"; + case 6: Type = "Eliminated"; + } + Net_DebugMode_Logs = Prefix ^ "Race Pending Event: " ^ Type ^"\n" ^ Net_DebugMode_Logs; } *** @@ -280,7 +280,7 @@ 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); + Net_DebugMode_Logs = TL::SubString(Net_DebugMode_Logs, 0, 1000000); } @@ -289,611 +289,620 @@ Net_DebugMode_Logs_Serial += 1; *** Text GetManialink() { - return """ - - - -