From e91927eaa3ea73352ee82790fdf7b38fb7615e5a Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sun, 10 Feb 2019 20:05:50 -0600 Subject: [PATCH] actually fix the encoding issue --- Application/Application.csproj | 6 +++--- SharedLibraryCore/RCon/Connection.cs | 4 +++- SharedLibraryCore/Utilities.cs | 20 ++++++++++++++------ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Application/Application.csproj b/Application/Application.csproj index 234d34d1e..de1ecd9ca 100644 --- a/Application/Application.csproj +++ b/Application/Application.csproj @@ -6,7 +6,7 @@ 2.1.5 false RaidMax.IW4MAdmin.Application - 2.2.4.8 + 2.2.4.9 RaidMax Forever None IW4MAdmin @@ -31,8 +31,8 @@ true true - 2.2.4.8 - 2.2.4.8 + 2.2.4.9 + 2.2.4.9 diff --git a/SharedLibraryCore/RCon/Connection.cs b/SharedLibraryCore/RCon/Connection.cs index db129bccd..4a0fe3a7e 100644 --- a/SharedLibraryCore/RCon/Connection.cs +++ b/SharedLibraryCore/RCon/Connection.cs @@ -32,10 +32,12 @@ public class Connection private readonly ILogger Log; private IRConParserConfiguration Config; + private readonly Encoding defaultEncoding; public Connection(string ipAddress, int port, string password, ILogger log, IRConParserConfiguration config) { Endpoint = new IPEndPoint(IPAddress.Parse(ipAddress), port); + defaultEncoding = Encoding.GetEncoding("windows-1252"); RConPassword = password; Log = log; Config = config; @@ -81,7 +83,7 @@ public async Task SendQueryAsync(StaticHelpers.QueryType type, string string convertEncoding(string text) { byte[] convertedBytes = Utilities.EncodingType.GetBytes(text); - return Utilities.EncodingType.GetString(convertedBytes); + return defaultEncoding.GetString(convertedBytes); } string convertedRConPassword = convertEncoding(RConPassword); diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs index 96850087c..aa739937e 100644 --- a/SharedLibraryCore/Utilities.cs +++ b/SharedLibraryCore/Utilities.cs @@ -266,14 +266,19 @@ public static string GetLocalizedGametype(String input) public static long ConvertLong(this string str) { str = str.Substring(0, Math.Min(str.Length, 16)); - if (long.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out long id)) + long id; + + if (str.Length <= 10) { - return id; + if (long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out id)) + { + return (uint)id; + } } - if (long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out id)) + if (long.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out id)) { - return (uint)id; + return id; } var bot = Regex.Match(str, @"bot[0-9]+").Value; @@ -526,7 +531,7 @@ public static Tuple PromptSelection(string question, T defaultValue, selectionIndex--; } - T selection = selections[selectionIndex ]; + T selection = selections[selectionIndex]; return Tuple.Create(selectionIndex, selection); } @@ -650,7 +655,10 @@ public static string GetCommandLine(int pId) /// /// /// - public static bool IsRemoteLog(this string log) => (log ?? "").StartsWith("http"); + public static bool IsRemoteLog(this string log) + { + return (log ?? "").StartsWith("http"); + } public static string ToBase64UrlSafeString(this string src) {