1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 23:31:13 -05:00

Fix bug with webfront spamming issues when running

Remove IW5 parser
Begin implementation of dynamic parsers
This commit is contained in:
RaidMax
2019-01-26 20:33:37 -06:00
parent f933db2895
commit 88992d1a7b
29 changed files with 223 additions and 325 deletions

View File

@ -9,7 +9,21 @@ namespace IW4MAdmin.Application.EventParsers
{
class IW4EventParser : IEventParser
{
private const string SayRegex = @"(say|sayteam);(.{1,32});([0-9]+)(.*);(.*)";
private IEventParserConfiguration _configuration;
public IW4EventParser()
{
_configuration = new DynamicEventParserConfiguration()
{
GameDirectory = "userraw",
SayRegex = "(say|sayteam);(.{1,32});([0-9]+)(.*);(.*)",
QuitRegex = @"^(Q;)(.{1,32});([0-9]+);(.*)$",
JoinRegex = @"^(J;)(.{1,32});([0-9]+);(.*)$",
DamageRegex = @"^(D);((?:bot[0-9]+)|(?:[A-Z]|[0-9])+);([0-9]+);(axis|allies);(.+);((?:[A-Z]|[0-9])+);([0-9]+);(axis|allies);(.+);((?:[0-9]+|[a-z]+|_)+);([0-9]+);((?:[A-Z]|_)+);((?:[a-z]|_)+)$"
};
}
public IEventParserConfiguration Configuration { get => _configuration; set => _configuration = value; }
public virtual GameEvent GetEvent(Server server, string logLine)
{
@ -32,7 +46,7 @@ namespace IW4MAdmin.Application.EventParsers
if (eventType == "say" || eventType == "sayteam")
{
var matchResult = Regex.Match(logLine, SayRegex);
var matchResult = Regex.Match(logLine, _configuration.SayRegex);
if (matchResult.Success)
{
@ -117,7 +131,7 @@ namespace IW4MAdmin.Application.EventParsers
{
if (!server.CustomCallback)
{
if (Regex.Match(eventType, @"^(D);((?:bot[0-9]+)|(?:[A-Z]|[0-9])+);([0-9]+);(axis|allies);(.+);((?:[A-Z]|[0-9])+);([0-9]+);(axis|allies);(.+);((?:[0-9]+|[a-z]+|_)+);([0-9]+);((?:[A-Z]|_)+);((?:[a-z]|_)+)$").Success)
if (Regex.Match(eventType, _configuration.DamageRegex).Success)
{
var origin = server.GetClientsAsList().First(c => c.NetworkId == lineSplit[5].ConvertLong());
var target = server.GetClientsAsList().First(c => c.NetworkId == lineSplit[1].ConvertLong());
@ -137,7 +151,7 @@ namespace IW4MAdmin.Application.EventParsers
// join
if (eventType == "J")
{
var regexMatch = Regex.Match(logLine, @"^(J;)(.{1,32});([0-9]+);(.*)$");
var regexMatch = Regex.Match(logLine, _configuration.JoinRegex);
if (regexMatch.Success)
{
return new GameEvent()
@ -163,7 +177,7 @@ namespace IW4MAdmin.Application.EventParsers
if (eventType == "Q")
{
var regexMatch = Regex.Match(logLine, @"^(Q;)(.{1,32});([0-9]+);(.*)$");
var regexMatch = Regex.Match(logLine, _configuration.QuitRegex);
if (regexMatch.Success)
{
return new GameEvent()
@ -221,11 +235,5 @@ namespace IW4MAdmin.Application.EventParsers
Owner = server
};
}
// other parsers can derive from this parser so we make it virtual
public virtual string GetGameDir()
{
return "userraw";
}
}
}