grab gametype from status for T7

This commit is contained in:
RaidMax 2020-08-05 09:30:02 -05:00
parent ed2b01f229
commit b59504a882
8 changed files with 48 additions and 7 deletions

View File

@ -703,6 +703,7 @@ namespace IW4MAdmin
var updatedClients = polledClients.Except(connectingClients).Except(disconnectingClients); var updatedClients = polledClients.Except(connectingClients).Except(disconnectingClients);
UpdateMap(statusResponse.Item2); UpdateMap(statusResponse.Item2);
UpdateGametype(statusResponse.Item3);
return new List<EFClient>[] return new List<EFClient>[]
{ {
@ -724,6 +725,14 @@ namespace IW4MAdmin
} }
} }
private void UpdateGametype(string gameType)
{
if (!string.IsNullOrEmpty(gameType))
{
Gametype = gameType;
}
}
private async Task ShutdownInternal() private async Task ShutdownInternal()
{ {
foreach (var client in GetClientsAsList()) foreach (var client in GetClientsAsList())

View File

@ -52,6 +52,7 @@ namespace IW4MAdmin.Application.RconParsers
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarDomain, 5); Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarDomain, 5);
Configuration.StatusHeader.Pattern = "num +score +ping +guid +name +lastmsg +address +qport +rate *"; Configuration.StatusHeader.Pattern = "num +score +ping +guid +name +lastmsg +address +qport +rate *";
Configuration.GametypeStatus.Pattern = "";
Configuration.MapStatus.Pattern = @"map: (([a-z]|_|\d)+)"; Configuration.MapStatus.Pattern = @"map: (([a-z]|_|\d)+)";
Configuration.MapStatus.AddMapping(ParserRegex.GroupType.RConStatusMap, 1); Configuration.MapStatus.AddMapping(ParserRegex.GroupType.RConStatusMap, 1);
@ -114,7 +115,7 @@ namespace IW4MAdmin.Application.RconParsers
}; };
} }
public virtual async Task<(List<EFClient>, string)> GetStatusAsync(IRConConnection connection) public virtual async Task<(List<EFClient>, string, string)> GetStatusAsync(IRConConnection connection)
{ {
string[] response = await connection.SendQueryAsync(StaticHelpers.QueryType.COMMAND_STATUS); string[] response = await connection.SendQueryAsync(StaticHelpers.QueryType.COMMAND_STATUS);
#if DEBUG #if DEBUG
@ -123,7 +124,7 @@ namespace IW4MAdmin.Application.RconParsers
Console.WriteLine(line); Console.WriteLine(line);
} }
#endif #endif
return (ClientsFromStatus(response), MapFromStatus(response)); return (ClientsFromStatus(response), MapFromStatus(response), GameTypeFromStatus(response));
} }
private string MapFromStatus(string[] response) private string MapFromStatus(string[] response)
@ -141,6 +142,26 @@ namespace IW4MAdmin.Application.RconParsers
return map; return map;
} }
private string GameTypeFromStatus(string[] response)
{
if (string.IsNullOrWhiteSpace(Configuration.GametypeStatus.Pattern))
{
return null;
}
string gametype = null;
foreach (var line in response)
{
var regex = Regex.Match(line, Configuration.GametypeStatus.Pattern);
if (regex.Success)
{
gametype = regex.Groups[Configuration.GametypeStatus.GroupMapping[ParserRegex.GroupType.RConStatusGametype]].ToString();
}
}
return gametype;
}
public async Task<bool> SetDvarAsync(IRConConnection connection, string dvarName, object dvarValue) public async Task<bool> SetDvarAsync(IRConConnection connection, string dvarName, object dvarValue)
{ {
string dvarString = (dvarValue is string str) string dvarString = (dvarValue is string str)

View File

@ -14,6 +14,7 @@ namespace IW4MAdmin.Application.RconParsers
public CommandPrefix CommandPrefixes { get; set; } public CommandPrefix CommandPrefixes { get; set; }
public ParserRegex Status { get; set; } public ParserRegex Status { get; set; }
public ParserRegex MapStatus { get; set; } public ParserRegex MapStatus { get; set; }
public ParserRegex GametypeStatus { get; set; }
public ParserRegex Dvar { get; set; } public ParserRegex Dvar { get; set; }
public ParserRegex StatusHeader { get; set; } public ParserRegex StatusHeader { get; set; }
public string ServerNotRunningResponse { get; set; } public string ServerNotRunningResponse { get; set; }
@ -26,6 +27,7 @@ namespace IW4MAdmin.Application.RconParsers
{ {
Status = parserRegexFactory.CreateParserRegex(); Status = parserRegexFactory.CreateParserRegex();
MapStatus = parserRegexFactory.CreateParserRegex(); MapStatus = parserRegexFactory.CreateParserRegex();
GametypeStatus = parserRegexFactory.CreateParserRegex();
Dvar = parserRegexFactory.CreateParserRegex(); Dvar = parserRegexFactory.CreateParserRegex();
StatusHeader = parserRegexFactory.CreateParserRegex(); StatusHeader = parserRegexFactory.CreateParserRegex();
} }

View File

@ -3,7 +3,7 @@ var eventParser;
var plugin = { var plugin = {
author: 'RaidMax', author: 'RaidMax',
version: 0.2, version: 0.3,
name: 'Black Ops 3 Parser', name: 'Black Ops 3 Parser',
isParser: true, isParser: true,
@ -23,6 +23,8 @@ var plugin = {
rconParser.Configuration.CommandPrefixes.RConGetDvar = '\xff\xff\xff\xff\x00{0} {1}'; rconParser.Configuration.CommandPrefixes.RConGetDvar = '\xff\xff\xff\xff\x00{0} {1}';
rconParser.Configuration.CommandPrefixes.RConSetDvar = '\xff\xff\xff\xff\x00{0} set {1}'; rconParser.Configuration.CommandPrefixes.RConSetDvar = '\xff\xff\xff\xff\x00{0} set {1}';
rconParser.Configuration.CommandPrefixes.RConResponse = '\xff\xff\xff\xff\x01'; rconParser.Configuration.CommandPrefixes.RConResponse = '\xff\xff\xff\xff\x01';
rconParser.Configuration.GametypeStatus.Pattern = 'Gametype: (.+)';
rconParser.Configuration.MapStatus.Pattern = 'Map: (.+)';
rconParser.Configuration.CommandPrefixes.RConGetInfo = undefined; // disables this, because it's useless on T7 rconParser.Configuration.CommandPrefixes.RConGetInfo = undefined; // disables this, because it's useless on T7
rconParser.Configuration.ServerNotRunningResponse = 'this is here to prevent a hiberating server from being detected as not running'; rconParser.Configuration.ServerNotRunningResponse = 'this is here to prevent a hiberating server from being detected as not running';
@ -34,6 +36,7 @@ var plugin = {
rconParser.Configuration.DefaultDvarValues.Add('fs_game', ''); rconParser.Configuration.DefaultDvarValues.Add('fs_game', '');
rconParser.Configuration.Status.AddMapping(105, 6); // ip address rconParser.Configuration.Status.AddMapping(105, 6); // ip address
rconParser.Configuration.GametypeStatus.AddMapping(112, 1); // gametype
rconParser.Version = '[local] ship win64 CODBUILD8-764 (3421987) Mon Dec 16 10:44:20 2019 10d27bef'; rconParser.Version = '[local] ship win64 CODBUILD8-764 (3421987) Mon Dec 16 10:44:20 2019 10d27bef';
rconParser.GameName = 8; // BO3 rconParser.GameName = 8; // BO3
rconParser.CanGenerateLogPath = false; rconParser.CanGenerateLogPath = false;
@ -49,4 +52,4 @@ var plugin = {
onTickAsync: function (server) { onTickAsync: function (server) {
} }
}; };

View File

@ -37,6 +37,7 @@ namespace SharedLibraryCore.Interfaces
RConDvarLatchedValue = 109, RConDvarLatchedValue = 109,
RConDvarDomain = 110, RConDvarDomain = 110,
RConStatusMap = 111, RConStatusMap = 111,
RConStatusGametype = 112,
AdditionalGroup = 200 AdditionalGroup = 200
} }

View File

@ -38,8 +38,8 @@ namespace SharedLibraryCore.Interfaces
/// get the list of connected clients from status response /// get the list of connected clients from status response
/// </summary> /// </summary>
/// <param name="connection">RCon connection to use</param> /// <param name="connection">RCon connection to use</param>
/// <returns>list of clients, and current map</returns> /// <returns>list of clients, current map, and current gametype</returns>
Task<(List<EFClient>, string)> GetStatusAsync(IRConConnection connection); Task<(List<EFClient>, string, string)> GetStatusAsync(IRConConnection connection);
/// <summary> /// <summary>
/// stores the RCon configuration /// stores the RCon configuration

View File

@ -21,6 +21,11 @@ namespace SharedLibraryCore.Interfaces
/// </summary> /// </summary>
ParserRegex MapStatus { get; set; } ParserRegex MapStatus { get; set; }
/// <summary>
/// stores regex info for parsing the gametype line from rcon status response
/// </summary>
ParserRegex GametypeStatus { get; set; }
/// <summary> /// <summary>
/// stores the regex info for parsing get DVAR responses /// stores the regex info for parsing get DVAR responses
/// </summary> /// </summary>

View File

@ -786,7 +786,7 @@ namespace SharedLibraryCore
return await server.RconParser.ExecuteCommandAsync(server.RemoteConnection, commandName); return await server.RconParser.ExecuteCommandAsync(server.RemoteConnection, commandName);
} }
public static Task<(List<EFClient>, string)> GetStatusAsync(this Server server) public static Task<(List<EFClient>, string, string)> GetStatusAsync(this Server server)
{ {
return server.RconParser.GetStatusAsync(server.RemoteConnection); return server.RconParser.GetStatusAsync(server.RemoteConnection);
} }