diff --git a/Application/EventParsers/IW3EventParser.cs b/Application/EventParsers/IW3EventParser.cs deleted file mode 100644 index 85643ed4c..000000000 --- a/Application/EventParsers/IW3EventParser.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace IW4MAdmin.Application.EventParsers -{ - class IW3EventParser : BaseEventParser - { - public IW3EventParser() : base() - { - Configuration.GameDirectory = "main"; - } - } -} diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index daa7b9bfe..b49755940 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -665,31 +665,22 @@ namespace IW4MAdmin public async Task Initialize() { - var rconParser = Manager.AdditionalRConParsers + RconParser = Manager.AdditionalRConParsers .FirstOrDefault(_parser => _parser.Version == Manager.GetApplicationSettings().Configuration().CustomParserVersion); - var eventParser = Manager.AdditionalEventParsers + EventParser = Manager.AdditionalEventParsers .FirstOrDefault(_parser => _parser.Version == Manager.GetApplicationSettings().Configuration().CustomParserVersion); - rconParser = rconParser ?? new BaseRConParser(); - eventParser = eventParser ?? new BaseEventParser(); + RconParser = RconParser ?? new BaseRConParser(); + EventParser = EventParser ?? new BaseEventParser(); - RemoteConnection.SetConfiguration(rconParser.Configuration); - - RconParser = rconParser; - EventParser = eventParser; + RemoteConnection.SetConfiguration(RconParser.Configuration); var version = await this.GetDvarAsync("version"); Version = version.Value; GameName = Utilities.GetGame(version?.Value); - if (GameName == Game.IW4) - { - EventParser = new BaseEventParser(); - RconParser = new BaseRConParser(); - } - - else if (GameName == Game.T5M) + if (GameName == Game.T5M) { EventParser = new T5MEventParser(); } @@ -699,18 +690,11 @@ namespace IW4MAdmin EventParser = new T6MEventParser(); } - //else - //{ - // EventParser = new IW3EventParser(); // this uses the 'main' folder for log paths - //} - - //if (GameName == Game.UKN) - //{ - // Logger.WriteWarning($"Game name not recognized: {version}"); - - // EventParser = Manager.AdditionalEventParsers.FirstOrDefault(_parser => _parser.Version == version.Value) ?? EventParser; - // RconParser = Manager.AdditionalRConParsers.FirstOrDefault(_parser => (_parser as DynamicRConParser).Version == version.Value) ?? RconParser; - //} + else if (version.Value.Length != 0) + { + RconParser = Manager.AdditionalRConParsers.FirstOrDefault(_parser => _parser.Version == version.Value) ?? RconParser; + EventParser = Manager.AdditionalEventParsers.First(_parser => _parser.Version == version.Value) ?? EventParser; + } var infoResponse = RconParser.Configuration.CommandPrefixes.RConGetInfo != null ? await this.GetInfoAsync() : null; // this is normally slow, but I'm only doing it because different games have different prefixes diff --git a/Application/RconParsers/IW3RConParser.cs b/Application/RconParsers/IW3RConParser.cs deleted file mode 100644 index d09374ff0..000000000 --- a/Application/RconParsers/IW3RConParser.cs +++ /dev/null @@ -1,25 +0,0 @@ -using SharedLibraryCore; -using SharedLibraryCore.RCon; -using System; -using System.Collections.Generic; -using System.Text; - -namespace IW4MAdmin.Application.RconParsers -{ - class IW3RConParser : BaseRConParser - { - public IW3RConParser() : base() - { - Configuration.CommandPrefixes = new CommandPrefix() - { - Tell = "tell {0} {1}", - Say = "say {0}", - Kick = "clientkick {0} \"{1}\"", - Ban = "clientkick {0} \"{1}\"", - TempBan = "tempbanclient {0} \"{1}\"" - }; - - Configuration.GameName = Server.Game.IW3; - } - } -} diff --git a/IW4MAdmin.sln b/IW4MAdmin.sln index 416768957..547e09913 100644 --- a/IW4MAdmin.sln +++ b/IW4MAdmin.sln @@ -38,6 +38,7 @@ 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\ParserTeknoMW3.js = Plugins\ScriptPlugins\ParserTeknoMW3.js Plugins\ScriptPlugins\SharedGUIDKick.js = Plugins\ScriptPlugins\SharedGUIDKick.js Plugins\ScriptPlugins\VPNDetection.js = Plugins\ScriptPlugins\VPNDetection.js diff --git a/Plugins/ScriptPlugins/ParserIW3.js b/Plugins/ScriptPlugins/ParserIW3.js new file mode 100644 index 000000000..4936fb8bf --- /dev/null +++ b/Plugins/ScriptPlugins/ParserIW3.js @@ -0,0 +1,33 @@ +var rconParser; +var eventParser; + +var plugin = { + author: 'RaidMax', + version: 0.1, + name: 'IW3 Parser', + isParser: true, + + onEventAsync: function (gameEvent, server) { + }, + + onLoadAsync: function (manager) { + rconParser = manager.GenerateDynamicRConParser(); + eventParser = manager.GenerateDynamicEventParser(); + + rconParser.Configuration.CommandPrefixes.Tell = 'tell {0} {1}'; + rconParser.Configuration.CommandPrefixes.Say = 'say {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 = 'main'; + eventParser.Version = 'CoD4 MP 1.8 build 13620 Thu Oct 04 00:43:04 2007 win-x86'; + }, + + onUnloadAsync: function () { + }, + + onTickAsync: function (server) { + } +}; \ No newline at end of file diff --git a/SharedLibraryCore/Helpers/ParserRegex.cs b/SharedLibraryCore/Helpers/ParserRegex.cs index 0582aa204..3848be4af 100644 --- a/SharedLibraryCore/Helpers/ParserRegex.cs +++ b/SharedLibraryCore/Helpers/ParserRegex.cs @@ -71,6 +71,22 @@ namespace SharedLibraryCore.Interfaces GroupMapping.Add((GroupType)key, value); } } + + if (mapKey.GetType() == typeof(GroupType) && mapValue.GetType().ToString() == "System.Int32") + { + GroupType k = (GroupType)Enum.Parse(typeof(GroupType), mapKey.ToString()); + int v = int.Parse(mapValue.ToString()); + + if (GroupMapping.ContainsKey(k)) + { + GroupMapping[k] = v; + } + + else + { + GroupMapping.Add(k, v); + } + } } public ParserRegex()