From 2e5ffe91fca9e3f7914580f9b9b699194c218814 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 12 Feb 2020 15:11:43 -0600 Subject: [PATCH] fix a small bug with new line truncation missing --- Application/EventParsers/BaseEventParser.cs | 4 ++-- Application/RconParsers/BaseRConParser.cs | 2 +- SharedLibraryCore/Utilities.cs | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Application/EventParsers/BaseEventParser.cs b/Application/EventParsers/BaseEventParser.cs index 765b7bb74..c58d71c6c 100644 --- a/Application/EventParsers/BaseEventParser.cs +++ b/Application/EventParsers/BaseEventParser.cs @@ -195,7 +195,7 @@ namespace IW4MAdmin.Application.EventParsers { CurrentAlias = new EFAlias() { - Name = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginName]].ToString(), + Name = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginName]].ToString().TrimNewLine(), }, NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(Configuration.GuidNumberStyle), ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()), @@ -221,7 +221,7 @@ namespace IW4MAdmin.Application.EventParsers { CurrentAlias = new EFAlias() { - Name = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginName]].ToString() + Name = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginName]].ToString().TrimNewLine() }, NetworkId = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(Configuration.GuidNumberStyle), ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()), diff --git a/Application/RconParsers/BaseRConParser.cs b/Application/RconParsers/BaseRConParser.cs index 55cd23074..44ec4ce71 100644 --- a/Application/RconParsers/BaseRConParser.cs +++ b/Application/RconParsers/BaseRConParser.cs @@ -178,7 +178,7 @@ namespace IW4MAdmin.Application.RconParsers continue; } - string name = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConName]].Value.Trim(); + string name = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConName]].Value.TrimNewLine(); int? ip = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConIpAddress]].Value.Split(':')[0].ConvertToIP(); var client = new EFClient() diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs index 6892ed8b4..00ddae4d7 100644 --- a/SharedLibraryCore/Utilities.cs +++ b/SharedLibraryCore/Utilities.cs @@ -831,6 +831,13 @@ namespace SharedLibraryCore return Regex.IsMatch(message, @"^\u0014(?:[A-Z]|_)+$"); } + /// + /// trims new line and whitespace from string + /// + /// source string + /// + public static string TrimNewLine(this string str) => str.Trim().TrimEnd('\r', '\n'); + public static Vector3 FixIW4Angles(this Vector3 vector) { float X = vector.X >= 0 ? vector.X : 360.0f + vector.X;