diff --git a/Application/ApplicationManager.cs b/Application/ApplicationManager.cs index bc6519036..0430c2def 100644 --- a/Application/ApplicationManager.cs +++ b/Application/ApplicationManager.cs @@ -283,6 +283,24 @@ namespace IW4MAdmin.Application config.WebfrontBindUrl = "http://0.0.0.0:1624"; await ConfigHandler.Save(); } + + foreach (var serverConfig in config.Servers) + { + if (serverConfig.RConParserVersion == null || serverConfig.EventParserVersion == null) + { + foreach (var parser in AdditionalRConParsers) + { + serverConfig.AddRConParser(parser); + } + + foreach (var parser in AdditionalEventParsers) + { + serverConfig.AddEventParser(parser); + } + + serverConfig.ModifyParsers(); + } + } } else if (config.Servers.Count == 0) diff --git a/Application/EventParsers/BaseEventParser.cs b/Application/EventParsers/BaseEventParser.cs index a8a123d1d..a41faa640 100644 --- a/Application/EventParsers/BaseEventParser.cs +++ b/Application/EventParsers/BaseEventParser.cs @@ -13,7 +13,7 @@ namespace IW4MAdmin.Application.EventParsers { Configuration = new DynamicEventParserConfiguration() { - GameDirectory = "userraw", + GameDirectory = "main", }; Configuration.Say.Pattern = @"^(say|sayteam);(.{8,32});([0-9]+);(.+);(.*)$"; @@ -68,7 +68,7 @@ namespace IW4MAdmin.Application.EventParsers public IEventParserConfiguration Configuration { get; set; } - public string Version { get; set; } = "IW4x (v0.6.0)"; + public string Version { get; set; } = "CoD"; public virtual GameEvent GetEvent(Server server, string logLine) { @@ -215,6 +215,8 @@ namespace IW4MAdmin.Application.EventParsers var regexMatch = Regex.Match(logLine, Configuration.Join.Pattern); if (regexMatch.Success) { + bool isBot = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().Contains("bot"); + return new GameEvent() { Type = GameEvent.EventType.PreConnect, @@ -230,7 +232,8 @@ namespace IW4MAdmin.Application.EventParsers NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertLong(), ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()), State = EFClient.ClientState.Connecting, - CurrentServer = server + CurrentServer = server, + IsBot = isBot } }; } diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index b976a3035..363c27467 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -667,10 +667,10 @@ namespace IW4MAdmin public async Task Initialize() { RconParser = Manager.AdditionalRConParsers - .FirstOrDefault(_parser => _parser.Version == ServerConfig.CustomParserVersion); + .FirstOrDefault(_parser => _parser.Version == ServerConfig.RConParserVersion); EventParser = Manager.AdditionalEventParsers - .FirstOrDefault(_parser => _parser.Version == ServerConfig.CustomParserVersion); + .FirstOrDefault(_parser => _parser.Version == ServerConfig.EventParserVersion); RconParser = RconParser ?? new BaseRConParser(); EventParser = EventParser ?? new BaseEventParser(); diff --git a/Application/RconParsers/BaseRConParser.cs b/Application/RconParsers/BaseRConParser.cs index b84ff0eff..71e96cf7e 100644 --- a/Application/RconParsers/BaseRConParser.cs +++ b/Application/RconParsers/BaseRConParser.cs @@ -19,8 +19,8 @@ namespace IW4MAdmin.Application.RconParsers { CommandPrefixes = new CommandPrefix() { - Tell = "tellraw {0} {1}", - Say = "sayraw {0}", + Tell = "tell {0} {1}", + Say = "say {0}", Kick = "clientkick {0} \"{1}\"", Ban = "clientkick {0} \"{1}\"", TempBan = "tempbanclient {0} \"{1}\"", @@ -42,7 +42,7 @@ namespace IW4MAdmin.Application.RconParsers Configuration.Status.AddMapping(ParserRegex.GroupType.RConName, 5); Configuration.Status.AddMapping(ParserRegex.GroupType.RConIpAddress, 7); - Configuration.Dvar.Pattern = "^\"(.+)\" is: \"(.+)\" default: \"(.+)?\"\n(?:latched: \"(.+)?\"\n)? *(.+)$"; + Configuration.Dvar.Pattern = "^\"(.+)\" is: \"(.+)?\" default: \"(.+)?\"\n(?:latched: \"(.+)?\"\n)? *(.+)$"; Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarName, 1); Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarValue, 2); Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarDefaultValue, 3); @@ -52,7 +52,7 @@ namespace IW4MAdmin.Application.RconParsers public IRConParserConfiguration Configuration { get; set; } - public string Version { get; set; } = "IW4x (v0.6.0)"; + public string Version { get; set; } = "CoD"; public async Task ExecuteCommandAsync(Connection connection, string command) { diff --git a/IW4MAdmin.sln b/IW4MAdmin.sln index a2b910a69..4f3dc0133 100644 --- a/IW4MAdmin.sln +++ b/IW4MAdmin.sln @@ -38,7 +38,8 @@ Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "DiscordWebhook", "DiscordWe EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlugins", "{3F9ACC27-26DB-49FA-BCD2-50C54A49C9FA}" ProjectSection(SolutionItems) = preProject - Plugins\ScriptPlugins\ParserIW3.js = Plugins\ScriptPlugins\ParserIW3.js + Plugins\ScriptPlugins\ParserCoD4x.js = Plugins\ScriptPlugins\ParserCoD4x.js + Plugins\ScriptPlugins\ParserIW4x.js = Plugins\ScriptPlugins\ParserIW4x.js Plugins\ScriptPlugins\ParserPT6.js = Plugins\ScriptPlugins\ParserPT6.js Plugins\ScriptPlugins\ParserTeknoMW3.js = Plugins\ScriptPlugins\ParserTeknoMW3.js Plugins\ScriptPlugins\SharedGUIDKick.js = Plugins\ScriptPlugins\SharedGUIDKick.js diff --git a/Plugins/ScriptPlugins/ParserCoD4x.js b/Plugins/ScriptPlugins/ParserCoD4x.js new file mode 100644 index 000000000..5e29675be --- /dev/null +++ b/Plugins/ScriptPlugins/ParserCoD4x.js @@ -0,0 +1,30 @@ +var rconParser; +var eventParser; + +var plugin = { + author: 'FrenchFry, RaidMax', + version: 0.2, + name: 'CoD4x Parser', + isParser: true, + + onEventAsync: function (gameEvent, server) { + }, + + onLoadAsync: function (manager) { + rconParser = manager.GenerateDynamicRConParser(); + eventParser = manager.GenerateDynamicEventParser(); + + rconParser.Configuration.Dvar.Pattern = '^"(.+)" is: "(.+)?" default: "(.+)?" info: "(.+)?"$'; + rconParser.Configuration.Dvar.AddMapping(110, 4); + rconParser.Version = 'CoD4 X 1.8 win_mingw-x86 build 2055 May 2 2017'; + + eventParser.Configuration.GameDirectory = 'main'; + eventParser.Version = 'CoD4 X 1.8 win_mingw-x86 build 2055 May 2 2017'; + }, + + onUnloadAsync: function () { + }, + + onTickAsync: function (server) { + } +}; \ No newline at end of file diff --git a/Plugins/ScriptPlugins/ParserIW3.js b/Plugins/ScriptPlugins/ParserIW4x.js similarity index 70% rename from Plugins/ScriptPlugins/ParserIW3.js rename to Plugins/ScriptPlugins/ParserIW4x.js index 4936fb8bf..5fd8af502 100644 --- a/Plugins/ScriptPlugins/ParserIW3.js +++ b/Plugins/ScriptPlugins/ParserIW4x.js @@ -14,15 +14,15 @@ var plugin = { rconParser = manager.GenerateDynamicRConParser(); eventParser = manager.GenerateDynamicEventParser(); - rconParser.Configuration.CommandPrefixes.Tell = 'tell {0} {1}'; - rconParser.Configuration.CommandPrefixes.Say = 'say {0}'; + rconParser.Configuration.CommandPrefixes.Tell = 'tellraw {0} {1}'; + rconParser.Configuration.CommandPrefixes.Say = 'sayraw {0}'; rconParser.Configuration.CommandPrefixes.Kick = 'clientkick {0} "{1}"'; rconParser.Configuration.CommandPrefixes.Ban = 'clientkick {0} "{1}"'; rconParser.Configuration.CommandPrefixes.TempBan = 'tempbanclient {0} "{1}"'; - rconParser.Version = 'CoD4 MP 1.8 build 13620 Thu Oct 04 00:43:04 2007 win-x86'; + eventParser.Configuration.GameDirectory = 'userraw'; - eventParser.Configuration.GameDirectory = 'main'; - eventParser.Version = 'CoD4 MP 1.8 build 13620 Thu Oct 04 00:43:04 2007 win-x86'; + rconParser.Version = 'IW4x (v0.6.0)'; + eventParser.Version = 'IW4x (v0.6.0)'; }, onUnloadAsync: function () { diff --git a/SharedLibraryCore/Configuration/ServerConfiguration.cs b/SharedLibraryCore/Configuration/ServerConfiguration.cs index a302787bc..8e98b9ef0 100644 --- a/SharedLibraryCore/Configuration/ServerConfiguration.cs +++ b/SharedLibraryCore/Configuration/ServerConfiguration.cs @@ -13,7 +13,8 @@ namespace SharedLibraryCore.Configuration public IList Rules { get; set; } public IList AutoMessages { get; set; } public string ManualLogPath { get; set; } - public string CustomParserVersion { get; set; } + public string RConParserVersion { get; set; } + public string EventParserVersion { get; set; } public int ReservedSlotNumber { get; set; } private readonly IList rconParsers; @@ -28,6 +29,27 @@ namespace SharedLibraryCore.Configuration public void AddRConParser(IRConParser parser) => rconParsers.Add(parser); public void AddEventParser(IEventParser parser) => eventParsers.Add(parser); + public void ModifyParsers() + { + var loc = Utilities.CurrentLocalization.LocalizationIndex; + var parserVersions = rconParsers.Select(_parser => _parser.Version).ToArray(); + var selection = Utilities.PromptSelection($"{loc["SETUP_SERVER_RCON_PARSER_VERSION"]} ({IPAddress}:{Port})", $"{loc["SETUP_PROMPT_DEFAULT"]} (Call of Duty)", null, parserVersions); + + if (selection.Item1 > 0) + { + RConParserVersion = selection.Item2; + } + + parserVersions = eventParsers.Select(_parser => _parser.Version).ToArray(); + Console.WriteLine($"{IPAddress}:{Port}"); + selection = Utilities.PromptSelection($"{loc["SETUP_SERVER_EVENT_PARSER_VERSION"]} ({IPAddress}:{Port})", $"{loc["SETUP_PROMPT_DEFAULT"]} (Call of Duty)", null, parserVersions); + + if (selection.Item1 > 0) + { + EventParserVersion = selection.Item2; + } + } + public IBaseConfiguration Generate() { var loc = Utilities.CurrentLocalization.LocalizationIndex; @@ -52,21 +74,7 @@ namespace SharedLibraryCore.Configuration Rules = new List(); ReservedSlotNumber = loc["SETUP_SERVER_RESERVEDSLOT"].PromptInt(null, 0, 32); - var parserVersions = rconParsers.Select(_parser => _parser.Version).ToArray(); - var selection = Utilities.PromptSelection(loc["SETUP_SERVER_RCON_PARSER_VERSION"], $"{loc["SETUP_PROMPT_DEFAULT"]} (IW4x)", null, parserVersions); - - if (selection.Item1 > 0) - { - CustomParserVersion = selection.Item2; - } - - parserVersions = eventParsers.Select(_parser => _parser.Version).ToArray(); - selection = Utilities.PromptSelection(loc["SETUP_SERVER_EVENT_PARSER_VERSION"], $"{loc["SETUP_PROMPT_DEFAULT"]} (IW4x)", null, parserVersions); - - if (selection.Item1 > 0) - { - CustomParserVersion = selection.Item2; - } + ModifyParsers(); return this; }