From ee087f1c854e8a9203967d039bad455fc60d614d Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sat, 18 Apr 2020 10:46:55 -0500 Subject: [PATCH] fix T7 extra null bytes in status response fix regression bug with info response on T6 --- Application/RCon/RConConnection.cs | 2 +- SharedLibraryCore/Utilities.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Application/RCon/RConConnection.cs b/Application/RCon/RConConnection.cs index 3520d79c1..ad91246ae 100644 --- a/Application/RCon/RConConnection.cs +++ b/Application/RCon/RConConnection.cs @@ -219,7 +219,7 @@ namespace IW4MAdmin.Application.RCon else { - splitStatusStrings.Add(responseString.Replace(config.CommandPrefixes.RConResponse, "")); + splitStatusStrings.Add(responseString.Replace(config.CommandPrefixes.RConResponse, "").TrimEnd('\0')); } } diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs index a0eb98904..69e7bd96b 100644 --- a/SharedLibraryCore/Utilities.cs +++ b/SharedLibraryCore/Utilities.cs @@ -669,10 +669,10 @@ namespace SharedLibraryCore Dictionary dict = null; - if (values.Length % 2 == 0 && values.Length > 1) + if (values.Length > 1) { dict = new Dictionary(); - for (int i = 0; i < values.Length; i += 2) + for (int i = values.Length % 2 == 0 ? 0 : 1; i < values.Length; i += 2) { dict.Add(values[i], values[i + 1]); } @@ -754,7 +754,9 @@ namespace SharedLibraryCore } var response = await server.RemoteConnection.SendQueryAsync(RCon.StaticHelpers.QueryType.GET_INFO); - string combinedResponse = string.Join('\\', response.Where(r => r.Length > 0 && r[0] == '\\')); + string combinedResponse = response.Length > 1 ? + string.Join('\\', response.Where(r => r.Length > 0 && r[0] == '\\')) : + response[0]; return combinedResponse.DictionaryFromKeyValue(); }