From 55fb36863cd9e6ad2a98cc01c216ed742e95dcf4 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Thu, 1 Aug 2019 09:37:33 -0500 Subject: [PATCH] fix copy paste error in penalty loader start allowing color codes from ingame --- Application/EventParsers/BaseEventParser.cs | 4 ++-- Application/IW4MServer.cs | 16 +++++++--------- Application/RconParsers/BaseRConParser.cs | 19 +++++++++++++------ Plugins/Stats/Helpers/StatManager.cs | 1 - SharedLibraryCore/Commands/NativeCommands.cs | 2 +- SharedLibraryCore/Utilities.cs | 4 ++-- WebfrontCore/wwwroot/js/penalty.js | 4 ++-- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Application/EventParsers/BaseEventParser.cs b/Application/EventParsers/BaseEventParser.cs index 3dac27003..94f92f46a 100644 --- a/Application/EventParsers/BaseEventParser.cs +++ b/Application/EventParsers/BaseEventParser.cs @@ -175,7 +175,7 @@ namespace IW4MAdmin.Application.EventParsers { CurrentAlias = new EFAlias() { - Name = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginName]].ToString().StripColors(), + Name = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginName]].ToString(), }, NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(), ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()), @@ -199,7 +199,7 @@ namespace IW4MAdmin.Application.EventParsers { CurrentAlias = new EFAlias() { - Name = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginName]].ToString().StripColors() + Name = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginName]].ToString() }, NetworkId = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(), ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()), diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index 7d5e5937a..cc6b3e87e 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -405,8 +405,6 @@ namespace IW4MAdmin if (E.Type == GameEvent.EventType.Say) { - E.Data = E.Data.StripColors(); - if (E.Data?.Length > 0) { string message = E.Data; @@ -447,10 +445,10 @@ namespace IW4MAdmin else { - Gametype = dict["gametype"].StripColors(); - Hostname = dict["hostname"]?.StripColors(); + Gametype = dict["gametype"]; + Hostname = dict["hostname"]; - string mapname = dict["mapname"]?.StripColors() ?? CurrentMap.Name; + string mapname = dict["mapname"] ?? CurrentMap.Name; CurrentMap = Maps.Find(m => m.Name == mapname) ?? new Map() { Alias = mapname, Name = mapname }; } } @@ -458,11 +456,11 @@ namespace IW4MAdmin else { var dict = (Dictionary)E.Extra; - Gametype = dict["g_gametype"].StripColors(); - Hostname = dict["sv_hostname"].StripColors(); + Gametype = dict["g_gametype"]; + Hostname = dict["sv_hostname"]; MaxClients = int.Parse(dict["sv_maxclients"]); - string mapname = dict["mapname"].StripColors(); + string mapname = dict["mapname"]; CurrentMap = Maps.Find(m => m.Name == mapname) ?? new Map() { Alias = mapname, @@ -827,7 +825,7 @@ namespace IW4MAdmin InitializeMaps(); - this.Hostname = hostname.StripColors(); + this.Hostname = hostname; this.CurrentMap = Maps.Find(m => m.Name == mapname) ?? new Map() { Alias = mapname, Name = mapname }; this.MaxClients = maxplayers; this.FSGame = game; diff --git a/Application/RconParsers/BaseRConParser.cs b/Application/RconParsers/BaseRConParser.cs index 562338773..3a01662f4 100644 --- a/Application/RconParsers/BaseRConParser.cs +++ b/Application/RconParsers/BaseRConParser.cs @@ -79,17 +79,24 @@ namespace IW4MAdmin.Application.RconParsers throw new DvarException(Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_DVAR"].FormatExt(dvarName)); } - string value = match.Groups[Configuration.Dvar.GroupMapping[ParserRegex.GroupType.RConDvarValue]].Value.StripColors(); - string defaultValue = match.Groups[Configuration.Dvar.GroupMapping[ParserRegex.GroupType.RConDvarDefaultValue]].Value.StripColors(); - string latchedValue = match.Groups[Configuration.Dvar.GroupMapping[ParserRegex.GroupType.RConDvarLatchedValue]].Value.StripColors(); + string value = match.Groups[Configuration.Dvar.GroupMapping[ParserRegex.GroupType.RConDvarValue]].Value; + string defaultValue = match.Groups[Configuration.Dvar.GroupMapping[ParserRegex.GroupType.RConDvarDefaultValue]].Value; + string latchedValue = match.Groups[Configuration.Dvar.GroupMapping[ParserRegex.GroupType.RConDvarLatchedValue]].Value; + + string removeTrailingColorCode(string input) => Regex.Replace(input, @"\^7$", ""); + + + value = removeTrailingColorCode(value); + defaultValue = removeTrailingColorCode(defaultValue); + latchedValue = removeTrailingColorCode(latchedValue); return new Dvar() { - Name = match.Groups[Configuration.Dvar.GroupMapping[ParserRegex.GroupType.RConDvarName]].Value.StripColors(), + Name = match.Groups[Configuration.Dvar.GroupMapping[ParserRegex.GroupType.RConDvarName]].Value, Value = string.IsNullOrEmpty(value) ? default : (T)Convert.ChangeType(value, typeof(T)), DefaultValue = string.IsNullOrEmpty(defaultValue) ? default : (T)Convert.ChangeType(defaultValue, typeof(T)), LatchedValue = string.IsNullOrEmpty(latchedValue) ? default : (T)Convert.ChangeType(latchedValue, typeof(T)), - Domain = match.Groups[Configuration.Dvar.GroupMapping[ParserRegex.GroupType.RConDvarDomain]].Value.StripColors() + Domain = match.Groups[Configuration.Dvar.GroupMapping[ParserRegex.GroupType.RConDvarDomain]].Value }; } @@ -145,7 +152,7 @@ namespace IW4MAdmin.Application.RconParsers continue; } - string name = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConName]].Value.StripColors().Trim(); + string name = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConName]].Value.Trim(); int? ip = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConIpAddress]].Value.Split(':')[0].ConvertToIP(); var client = new EFClient() diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index c22449786..9f56523d6 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -498,7 +498,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers AttackerId = attacker.ClientId, VictimId = victim.ClientId, ServerId = serverId, - //Map = ParseEnum.Get(map, typeof(IW4Info.MapName)), DeathOrigin = vDeathOrigin, KillOrigin = vKillOrigin, DeathType = ParseEnum.Get(type, typeof(IW4Info.MeansOfDeath)), diff --git a/SharedLibraryCore/Commands/NativeCommands.cs b/SharedLibraryCore/Commands/NativeCommands.cs index 9c4ec1263..4879e2e3e 100644 --- a/SharedLibraryCore/Commands/NativeCommands.cs +++ b/SharedLibraryCore/Commands/NativeCommands.cs @@ -1032,7 +1032,7 @@ namespace SharedLibraryCore.Commands var Response = await E.Owner.ExecuteCommandAsync(E.Data.Trim()); foreach (string S in Response) { - E.Origin.Tell(S.StripColors()); + E.Origin.Tell(S); } if (Response.Length == 0) diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs index 35039fc01..1b898b60e 100644 --- a/SharedLibraryCore/Utilities.cs +++ b/SharedLibraryCore/Utilities.cs @@ -138,7 +138,7 @@ namespace SharedLibraryCore /// /// String containing color codes /// - public static String StripColors(this string str) + public static string StripColors(this string str) { if (str == null) { @@ -860,7 +860,7 @@ namespace SharedLibraryCore var queryCompilationContext = databaseDependencies.QueryCompilationContextFactory.Create(false); var modelVisitor = (RelationalQueryModelVisitor)queryCompilationContext.CreateQueryModelVisitor(); modelVisitor.CreateQueryExecutor(queryModel); - var sql = modelVisitor.Queries.First().ToString().Replace("\"", "`"); + var sql = modelVisitor.Queries.First().ToString(); return sql; } diff --git a/WebfrontCore/wwwroot/js/penalty.js b/WebfrontCore/wwwroot/js/penalty.js index db42da9f1..91987e98d 100644 --- a/WebfrontCore/wwwroot/js/penalty.js +++ b/WebfrontCore/wwwroot/js/penalty.js @@ -67,8 +67,8 @@ if ($('#penalty_table').length === 1) { $document.ready(function () { $window - .off('scroll', PenaltyScrollHandle) - .on('scroll', PenaltyScrollHandle); + .off('scroll', PenaltyScrollHandler) + .on('scroll', PenaltyScrollHandler); $('#load_penalties_button').click(function () { loadMorePenalties();