diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index 63306b672..0cca3c739 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -929,7 +929,7 @@ namespace IW4MAdmin infoResponse["mapname"]; int maxplayers = (GameName == Game.IW4) ? // gotta love IW4 idiosyncrasies (await this.GetDvarAsync("party_maxplayers")).Value : - infoResponse == null ? + infoResponse == null || !infoResponse.ContainsKey("sv_maxclients") ? (await this.GetDvarAsync("sv_maxclients")).Value : Convert.ToInt32(infoResponse["sv_maxclients"]); var gametype = infoResponse == null ? diff --git a/Application/RCon/RConConnection.cs b/Application/RCon/RConConnection.cs index ad91246ae..9e9634b79 100644 --- a/Application/RCon/RConConnection.cs +++ b/Application/RCon/RConConnection.cs @@ -167,6 +167,12 @@ namespace IW4MAdmin.Application.RCon } } + if (response.Length == 0) + { + _log.WriteWarning($"Received empty response for request [{type.ToString()}, {parameters}, {Endpoint.ToString()}]"); + return new string[0]; + } + string responseString = type == StaticHelpers.QueryType.COMMAND_STATUS ? ReassembleSegmentedStatus(response) : _gameEncoding.GetString(response[0]) + '\n'; @@ -187,9 +193,9 @@ namespace IW4MAdmin.Application.RCon throw new ServerException(Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_NOT_RUNNING"].FormatExt(Endpoint.ToString())); } - string[] headerSplit = responseString.Split(config.CommandPrefixes.RConResponse); + string[] headerSplit = responseString.Split(type == StaticHelpers.QueryType.GET_INFO ? config.CommandPrefixes.RconGetInfoResponseHeader : config.CommandPrefixes.RConResponse); - if (headerSplit.Length != 2 && type != StaticHelpers.QueryType.GET_INFO) + if (headerSplit.Length != 2) { throw new NetworkException("Unexpected response header from server"); } diff --git a/Application/RconParsers/BaseRConParser.cs b/Application/RconParsers/BaseRConParser.cs index e559e95e1..d2554cdb4 100644 --- a/Application/RconParsers/BaseRConParser.cs +++ b/Application/RconParsers/BaseRConParser.cs @@ -33,6 +33,7 @@ namespace IW4MAdmin.Application.RconParsers RConGetStatus = "ÿÿÿÿgetstatus", RConGetInfo = "ÿÿÿÿgetinfo", RConResponse = "ÿÿÿÿprint", + RconGetInfoResponseHeader = "ÿÿÿÿinfoResponse" }, ServerNotRunningResponse = "Server is not running." }; diff --git a/Plugins/ScriptPlugins/ParserPT6.js b/Plugins/ScriptPlugins/ParserPT6.js index c3ac8b7c2..b1aa28320 100644 --- a/Plugins/ScriptPlugins/ParserPT6.js +++ b/Plugins/ScriptPlugins/ParserPT6.js @@ -26,7 +26,7 @@ var plugin = { rconParser.Configuration.Dvar.AddMapping(107, 2); rconParser.Configuration.WaitForResponse = false; - rconParser.Configuration.StatusHeader.Patter = 'num +score +bot +ping +guid +name +lastmsg +address +qport +rate *'; + rconParser.Configuration.StatusHeader.Pattern = 'num +score +bot +ping +guid +name +lastmsg +address +qport +rate *'; rconParser.Configuration.Status.Pattern = '^ *([0-9]+) +([0-9]+) +(?:[0-1]{1}) +([0-9]+) +([A-F0-9]+) +(.+?) +(?:[0-9]+) +(\\d+\\.\\d+\\.\\d+\\.\\d+\\:-?\\d{1,5}|0+\\.0+:-?\\d{1,5}|loopback) +(?:-?[0-9]+) +(?:[0-9]+) *$'; rconParser.Configuration.Status.AddMapping(100, 1); rconParser.Configuration.Status.AddMapping(101, 2); diff --git a/SharedLibraryCore/RCon/CommandPrefix.cs b/SharedLibraryCore/RCon/CommandPrefix.cs index 2d2a1734a..0f4d8324c 100644 --- a/SharedLibraryCore/RCon/CommandPrefix.cs +++ b/SharedLibraryCore/RCon/CommandPrefix.cs @@ -15,5 +15,6 @@ public string RConGetStatus { get; set; } public string RConGetInfo { get; set; } public string RConResponse { get; set; } + public string RconGetInfoResponseHeader { get; set; } } }