unmeme a dvar check

This commit is contained in:
RaidMax 2020-04-18 17:48:49 -05:00
parent ee087f1c85
commit 0b643b2099
5 changed files with 12 additions and 4 deletions

View File

@ -929,7 +929,7 @@ namespace IW4MAdmin
infoResponse["mapname"];
int maxplayers = (GameName == Game.IW4) ? // gotta love IW4 idiosyncrasies
(await this.GetDvarAsync<int>("party_maxplayers")).Value :
infoResponse == null ?
infoResponse == null || !infoResponse.ContainsKey("sv_maxclients") ?
(await this.GetDvarAsync<int>("sv_maxclients")).Value :
Convert.ToInt32(infoResponse["sv_maxclients"]);
var gametype = infoResponse == null ?

View File

@ -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");
}

View File

@ -33,6 +33,7 @@ namespace IW4MAdmin.Application.RconParsers
RConGetStatus = "ÿÿÿÿgetstatus",
RConGetInfo = "ÿÿÿÿgetinfo",
RConResponse = "ÿÿÿÿprint",
RconGetInfoResponseHeader = "ÿÿÿÿinfoResponse"
},
ServerNotRunningResponse = "Server is not running."
};

View File

@ -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);

View File

@ -15,5 +15,6 @@
public string RConGetStatus { get; set; }
public string RConGetInfo { get; set; }
public string RConResponse { get; set; }
public string RconGetInfoResponseHeader { get; set; }
}
}