From 7c6419a16ab3acf0654312e70902060bf19808e0 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 6 Feb 2019 20:12:35 -0600 Subject: [PATCH] finish cod4x parser add IW3 map names --- Application/Application.csproj | 6 +- Application/DefaultSettings.json | 91 ++++++++++++++++++++++- Application/RconParsers/BaseRConParser.cs | 2 +- Plugins/ScriptPlugins/ParserCoD4x.js | 7 +- SharedLibraryCore/RCon/Connection.cs | 23 ++++-- 5 files changed, 118 insertions(+), 11 deletions(-) diff --git a/Application/Application.csproj b/Application/Application.csproj index a95d4414c..0f99fece9 100644 --- a/Application/Application.csproj +++ b/Application/Application.csproj @@ -6,7 +6,7 @@ 2.1.5 false RaidMax.IW4MAdmin.Application - 2.2.4.5 + 2.2.4.6 RaidMax Forever None IW4MAdmin @@ -31,8 +31,8 @@ true true - 2.2.4.5 - 2.2.4.5 + 2.2.4.6 + 2.2.4.6 diff --git a/Application/DefaultSettings.json b/Application/DefaultSettings.json index 90599fbdf..2c609d1c0 100644 --- a/Application/DefaultSettings.json +++ b/Application/DefaultSettings.json @@ -242,7 +242,7 @@ { "Name": "Village", - "Alias": "co_hunted" + "Alias": "co_hunted" } ] }, @@ -402,6 +402,95 @@ "Name": "zm_transit" } ] + }, + { + "Game": "IW3", + "Maps": [ + { + "Alias": "Ambush", + "Name": "mp_convoy" + }, + { + "Alias": "Backlot", + "Name": "mp_backlot" + }, + { + "Alias": "Bloc", + "Name": "mp_bloc" + }, + { + "Alias": "Bog", + "Name": "mp_bog" + }, + { + "Alias": "Countdown", + "Name": "mp_countdown" + }, + { + "Alias": "Crash", + "Name": "mp_crash" + }, + { + "Alias": "Crossfire", + "Name": "mp_crossfire" + }, + { + "Alias": "District", + "Name": "mp_citystreets" + }, + { + "Alias": "Downpour", + "Name": "mp_farm" + }, + { + "Alias": "Overgrown", + "Name": "mp_overgrown" + }, + { + "Alias": "Pipeline", + "Name": "mp_pipeline" + }, + { + "Alias": "Shipment", + "Name": "mp_shipment" + }, + { + "Alias": "Showdown", + "Name": "mp_showdown" + }, + { + "Alias": "Strike", + "Name": "mp_strike" + }, + { + "Alias": "Vacant", + "Name": "mp_vacant" + }, + { + "Alias": "Wet Work", + "Name": "mp_cargoship" + }, + { + "Alias": "Winter Crash", + "Name": "mp_crash_snow" + }, + { + "Alias": "Broadcast", + "Name": "mp_broadcast" + }, + { + "Alias": "Creek", + "Name": "mp_creek" + }, + { + "Alias": "Chinatown", + "Name": "mp_carentan" + }, + { + "Alias": "Killhouse", + "Name": "mp_killhouse" + } + ] } ] } diff --git a/Application/RconParsers/BaseRConParser.cs b/Application/RconParsers/BaseRConParser.cs index a9644bb01..299cc4e97 100644 --- a/Application/RconParsers/BaseRConParser.cs +++ b/Application/RconParsers/BaseRConParser.cs @@ -34,7 +34,7 @@ namespace IW4MAdmin.Application.RconParsers }, }; - Configuration.Status.Pattern = @"^ *([0-9]+) +-?([0-9]+) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]){16}|(?:[a-z]|[0-9]){32}|bot[0-9]+|(?:[0-9]+)) *(.{0,32}) +([0-9]+) +(\d+\.\d+\.\d+.\d+\:-*\d{1,5}|0+.0+:-*\d{1,5}|loopback) +(-*[0-9]+) +([0-9]+) *$"; + Configuration.Status.Pattern = @"^ *([0-9]+) +-?([0-9]+) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]){8,32}|(?:[a-z]|[0-9]){8,32}|bot[0-9]+|(?:[0-9]+)) +(.{0,32}) +([0-9]+) +(\d+\.\d+\.\d+.\d+\:-*\d{1,5}|0+.0+:-*\d{1,5}|loopback) +(-*[0-9]+) +([0-9]+) *$"; Configuration.Status.AddMapping(ParserRegex.GroupType.RConClientNumber, 1); Configuration.Status.AddMapping(ParserRegex.GroupType.RConScore, 2); Configuration.Status.AddMapping(ParserRegex.GroupType.RConPing, 3); diff --git a/Plugins/ScriptPlugins/ParserCoD4x.js b/Plugins/ScriptPlugins/ParserCoD4x.js index b1c83ca53..4850f6460 100644 --- a/Plugins/ScriptPlugins/ParserCoD4x.js +++ b/Plugins/ScriptPlugins/ParserCoD4x.js @@ -14,8 +14,13 @@ var plugin = { rconParser = manager.GenerateDynamicRConParser(); eventParser = manager.GenerateDynamicEventParser(); + rconParser.Configuration.Status.Pattern = '^ *([0-9]+) +-?([0-9]+) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]){16}|(?:[a-z]|[0-9]){32}|bot[0-9]+|(?:[0-9]+)) *(.{0,32}) +([0-9]+) +(\\d+\\.\\d+\\.\\d+.\\d+\\:-*\\d{1,5}|0+.0+:-*\\d{1,5}|loopback) +(-*[0-9]+) +([0-9]+) *$' + rconParser.Configuration.Status.AddMapping(104, 6); // RConName + rconParser.Configuration.Status.AddMapping(105, 8); // RConIPAddress + rconParser.Configuration.Dvar.Pattern = '^"(.+)" is: "(.+)?" default: "(.+)?" info: "(.+)?"$'; - rconParser.Configuration.Dvar.AddMapping(110, 4); + rconParser.Configuration.Dvar.AddMapping(109, 2); // DVAR latched value + rconParser.Configuration.Dvar.AddMapping(110, 4); // dvar info rconParser.Version = 'CoD4 X 1.8 win_mingw-x86 build 2055 May 2 2017'; rconParser.GameName = 1; // IW3 diff --git a/SharedLibraryCore/RCon/Connection.cs b/SharedLibraryCore/RCon/Connection.cs index 5d09f3e3a..d39dd7738 100644 --- a/SharedLibraryCore/RCon/Connection.cs +++ b/SharedLibraryCore/RCon/Connection.cs @@ -5,6 +5,7 @@ using System.Collections.Concurrent; using System.Linq; using System.Net; using System.Net.Sockets; +using System.Text; using System.Threading; using System.Threading.Tasks; @@ -77,17 +78,28 @@ namespace SharedLibraryCore.RCon byte[] payload = null; bool waitForResponse = Config.WaitForResponse; + string converterEncoding(string text) + { + var destinationEncoding = Encoding.GetEncoding("windows-1252"); + byte[] originalEncodedBytes = Utilities.EncodingType.GetBytes(text); + byte[] convertedBytes = Encoding.Convert(Utilities.EncodingType, destinationEncoding, originalEncodedBytes); + return destinationEncoding.GetString(convertedBytes); + } + + string convertedRConPassword = converterEncoding(RConPassword); + string convertedParameters = converterEncoding(parameters); + switch (type) { case StaticHelpers.QueryType.GET_DVAR: waitForResponse |= true; - payload = Utilities.EncodingType.GetBytes(string.Format(Config.CommandPrefixes.RConGetDvar, RConPassword, parameters + '\0')); + payload = string.Format(Config.CommandPrefixes.RConGetDvar, convertedRConPassword, convertedParameters + '\0').Select(Convert.ToByte).ToArray(); break; case StaticHelpers.QueryType.SET_DVAR: - payload = Utilities.EncodingType.GetBytes(string.Format(Config.CommandPrefixes.RConSetDvar, RConPassword, parameters + '\0')); + payload = string.Format(Config.CommandPrefixes.RConSetDvar, convertedRConPassword, convertedParameters + '\0').Select(Convert.ToByte).ToArray(); break; case StaticHelpers.QueryType.COMMAND: - payload = Utilities.EncodingType.GetBytes(string.Format(Config.CommandPrefixes.RConCommand, RConPassword, parameters + '\0')); + payload = string.Format(Config.CommandPrefixes.RConCommand, convertedRConPassword, convertedParameters + '\0').Select(Convert.ToByte).ToArray(); break; case StaticHelpers.QueryType.GET_STATUS: waitForResponse |= true; @@ -144,7 +156,7 @@ namespace SharedLibraryCore.RCon } } - string responseString = Utilities.EncodingType.GetString(response, 0, response.Length) + '\n'; + string responseString = Encoding.GetEncoding("windows-1252").GetString(response, 0, response.Length) + '\n'; if (responseString.Contains("Invalid password")) { @@ -157,7 +169,8 @@ namespace SharedLibraryCore.RCon } string[] splitResponse = responseString.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries) - .Select(line => line.Trim()).ToArray(); + .Select(line => line.Trim()) + .ToArray(); return splitResponse; }