diff --git a/Application/RConParsers/BaseRConParser.cs b/Application/RConParsers/BaseRConParser.cs index fbbd9056..1df71cb7 100644 --- a/Application/RConParsers/BaseRConParser.cs +++ b/Application/RConParsers/BaseRConParser.cs @@ -368,15 +368,28 @@ namespace IW4MAdmin.Application.RConParsers (T)Convert.ChangeType(Configuration.DefaultDvarValues[dvarName], typeof(T)) : default; - public TimeSpan OverrideTimeoutForCommand(string command) + public TimeSpan? OverrideTimeoutForCommand(string command) { - if (command.Contains("map_rotate", StringComparison.InvariantCultureIgnoreCase) || - command.StartsWith("map ", StringComparison.InvariantCultureIgnoreCase)) + if (string.IsNullOrEmpty(command)) { - return TimeSpan.FromSeconds(30); + return TimeSpan.Zero; + } + + var commandToken = command.Split(' ', StringSplitOptions.RemoveEmptyEntries).First().ToLower(); + + if (!Configuration.OverrideCommandTimeouts.ContainsKey(commandToken)) + { + return TimeSpan.Zero; } - return TimeSpan.Zero; + var timeoutValue = Configuration.OverrideCommandTimeouts[commandToken]; + + if (timeoutValue.HasValue && timeoutValue.Value != 0) // JINT doesn't seem to be able to properly set nulls on dictionaries + { + return TimeSpan.FromSeconds(timeoutValue.Value); + } + + return null; } } } diff --git a/Application/RConParsers/DynamicRConParserConfiguration.cs b/Application/RConParsers/DynamicRConParserConfiguration.cs index 0324ee32..b5a5225d 100644 --- a/Application/RConParsers/DynamicRConParserConfiguration.cs +++ b/Application/RConParsers/DynamicRConParserConfiguration.cs @@ -26,6 +26,7 @@ namespace IW4MAdmin.Application.RConParsers public NumberStyles GuidNumberStyle { get; set; } = NumberStyles.HexNumber; public IDictionary OverrideDvarNameMapping { get; set; } = new Dictionary(); public IDictionary DefaultDvarValues { get; set; } = new Dictionary(); + public IDictionary OverrideCommandTimeouts { get; set; } = new Dictionary(); public int NoticeMaximumLines { get; set; } = 8; public int NoticeMaxCharactersPerLine { get; set; } = 50; public string NoticeLineSeparator { get; set; } = Environment.NewLine; @@ -58,6 +59,19 @@ namespace IW4MAdmin.Application.RConParsers StatusHeader = parserRegexFactory.CreateParserRegex(); HostnameStatus = parserRegexFactory.CreateParserRegex(); MaxPlayersStatus = parserRegexFactory.CreateParserRegex(); + + + const string mapRotateCommand = "map_rotate"; + const string mapCommand = "map"; + const string fastRestartCommand = "fast_restart"; + + foreach (var command in new[] { mapRotateCommand, mapCommand, fastRestartCommand}) + { + if (!OverrideCommandTimeouts.ContainsKey(command)) + { + OverrideCommandTimeouts.Add(command, 45); + } + } } } } diff --git a/Integrations/Cod/CodRConConnection.cs b/Integrations/Cod/CodRConConnection.cs index 850bb3f6..f1842763 100644 --- a/Integrations/Cod/CodRConConnection.cs +++ b/Integrations/Cod/CodRConConnection.cs @@ -253,8 +253,10 @@ namespace Integrations.Cod try { connectionState.LastQuery = DateTime.Now; + var timeout = _parser.OverrideTimeoutForCommand(parameters); + waitForResponse = waitForResponse && timeout.HasValue; response = await SendPayloadAsync(payload, waitForResponse, - _parser.OverrideTimeoutForCommand(parameters), token); + timeout ?? TimeSpan.Zero, token); if ((response?.Length == 0 || response[0].Length == 0) && waitForResponse) { diff --git a/Plugins/ScriptPlugins/ParserPlutoniumT5.js b/Plugins/ScriptPlugins/ParserPlutoniumT5.js index 02bde3b3..6c12985a 100644 --- a/Plugins/ScriptPlugins/ParserPlutoniumT5.js +++ b/Plugins/ScriptPlugins/ParserPlutoniumT5.js @@ -3,7 +3,7 @@ var eventParser; var plugin = { author: 'RaidMax', - version: 0.1, + version: 0.2, name: 'Plutonium T5 Parser', isParser: true, @@ -23,6 +23,11 @@ var plugin = { rconParser.Configuration.DefaultRConPort = 3074; rconParser.Configuration.CanGenerateLogPath = false; + rconParser.Configuration.OverrideCommandTimeouts.Clear(); + rconParser.Configuration.OverrideCommandTimeouts.Add('map', 0); + rconParser.Configuration.OverrideCommandTimeouts.Add('map_rotate', 0); + rconParser.Configuration.OverrideCommandTimeouts.Add('fast_restart', 0); + rconParser.Version = 'Call of Duty Multiplayer - Ship COD_T5_S MP build 7.0.189 CL(1022875) CODPCAB-V64 CEG Wed Nov 02 18:02:23 2011 win-x86'; rconParser.GameName = 6; // T5 eventParser.Version = 'Call of Duty Multiplayer - Ship COD_T5_S MP build 7.0.189 CL(1022875) CODPCAB-V64 CEG Wed Nov 02 18:02:23 2011 win-x86'; diff --git a/SharedLibraryCore/Interfaces/IRConParser.cs b/SharedLibraryCore/Interfaces/IRConParser.cs index b080b2c4..3737fdba 100644 --- a/SharedLibraryCore/Interfaces/IRConParser.cs +++ b/SharedLibraryCore/Interfaces/IRConParser.cs @@ -110,6 +110,6 @@ namespace SharedLibraryCore.Interfaces /// /// name of command being executed /// - TimeSpan OverrideTimeoutForCommand(string command); + TimeSpan? OverrideTimeoutForCommand(string command); } } diff --git a/SharedLibraryCore/Interfaces/IRConParserConfiguration.cs b/SharedLibraryCore/Interfaces/IRConParserConfiguration.cs index 58977515..e1b9ec19 100644 --- a/SharedLibraryCore/Interfaces/IRConParserConfiguration.cs +++ b/SharedLibraryCore/Interfaces/IRConParserConfiguration.cs @@ -74,6 +74,11 @@ namespace SharedLibraryCore.Interfaces /// IDictionary DefaultDvarValues { get; } + /// + /// contains a setup of commands that have override timeouts + /// + IDictionary OverrideCommandTimeouts { get; } + /// /// specifies how many lines can be used for ingame notice /// @@ -100,7 +105,7 @@ namespace SharedLibraryCore.Interfaces string DefaultInstallationDirectoryHint { get; } ColorCodeMapping ColorCodeMapping { get; } - + short FloodProtectInterval { get; } } }