From 3a1e8359c22294d3e17abf3f3d72b10a54f8709e Mon Sep 17 00:00:00 2001 From: RaidMax Date: Mon, 7 Jun 2021 16:58:36 -0500 Subject: [PATCH] add one log indicator for games (Pluto IW5) that don't log to mods folder even when fs_game is specified. --- Application/IW4MServer.cs | 12 ++++++------ Application/Misc/LogPathGeneratorInfo.cs | 6 ++++++ Application/RConParsers/BaseRConParser.cs | 3 ++- Plugins/ScriptPlugins/ParserPIW5.js | 3 ++- SharedLibraryCore/Commands/NativeCommands.cs | 8 ++++---- SharedLibraryCore/Interfaces/IRConParser.cs | 6 ++++++ 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index a430117ae..671f0aa4d 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -1177,12 +1177,12 @@ namespace IW4MAdmin GameDirectory = EventParser.Configuration.GameDirectory ?? "", ModDirectory = game.Value ?? "", LogFile = logfile.Value, - IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows), + IsOneLog = RconParser.IsOneLog }; LogPath = GenerateLogPath(logInfo); ServerLogger.LogInformation("Game log information {@logInfo}", logInfo); - if (!File.Exists(LogPath) && ServerConfig.GameLogServerUrl == null) { Console.WriteLine(loc["SERVER_ERROR_DNE"].FormatExt(LogPath)); @@ -1223,12 +1223,12 @@ namespace IW4MAdmin public static string GenerateLogPath(LogPathGeneratorInfo logInfo) { string logPath; - string workingDirectory = logInfo.BasePathDirectory; + var workingDirectory = logInfo.BasePathDirectory; - bool baseGameIsDirectory = !string.IsNullOrWhiteSpace(logInfo.BaseGameDirectory) && + var baseGameIsDirectory = !string.IsNullOrWhiteSpace(logInfo.BaseGameDirectory) && logInfo.BaseGameDirectory.IndexOfAny(Utilities.DirectorySeparatorChars) != -1; - bool baseGameIsRelative = logInfo.BaseGameDirectory.FixDirectoryCharacters() + var baseGameIsRelative = logInfo.BaseGameDirectory.FixDirectoryCharacters() .Equals(logInfo.GameDirectory.FixDirectoryCharacters(), StringComparison.InvariantCultureIgnoreCase); // we want to see if base game is provided and it 'looks' like a directory @@ -1237,7 +1237,7 @@ namespace IW4MAdmin workingDirectory = logInfo.BaseGameDirectory; } - if (string.IsNullOrWhiteSpace(logInfo.ModDirectory)) + if (string.IsNullOrWhiteSpace(logInfo.ModDirectory) || logInfo.IsOneLog) { logPath = Path.Combine(workingDirectory, logInfo.GameDirectory, logInfo.LogFile); } diff --git a/Application/Misc/LogPathGeneratorInfo.cs b/Application/Misc/LogPathGeneratorInfo.cs index d2cc778f0..6b3539b09 100644 --- a/Application/Misc/LogPathGeneratorInfo.cs +++ b/Application/Misc/LogPathGeneratorInfo.cs @@ -41,5 +41,11 @@ namespace IW4MAdmin.Application.Misc /// indicates if running on windows /// public bool IsWindows { get; set; } = true; + + /// + /// indicates that the game does not log to the mods folder (when mod is loaded), + /// but rather always to the fs_basegame directory + /// + public bool IsOneLog { get; set; } } } diff --git a/Application/RConParsers/BaseRConParser.cs b/Application/RConParsers/BaseRConParser.cs index 5fea33edd..5df6cf728 100644 --- a/Application/RConParsers/BaseRConParser.cs +++ b/Application/RConParsers/BaseRConParser.cs @@ -75,11 +75,12 @@ namespace IW4MAdmin.Application.RConParsers public bool CanGenerateLogPath { get; set; } = true; public string Name { get; set; } = "Call of Duty"; public string RConEngine { get; set; } = "COD"; + public bool IsOneLog { get; set; } public async Task ExecuteCommandAsync(IRConConnection connection, string command) { var response = await connection.SendQueryAsync(StaticHelpers.QueryType.COMMAND, command); - return response.Skip(1).ToArray(); + return response.Where(item => item != Configuration.CommandPrefixes.RConResponse).ToArray(); } public async Task> GetDvarAsync(IRConConnection connection, string dvarName, T fallbackValue = default) diff --git a/Plugins/ScriptPlugins/ParserPIW5.js b/Plugins/ScriptPlugins/ParserPIW5.js index 7b51318e5..4bce2ec43 100644 --- a/Plugins/ScriptPlugins/ParserPIW5.js +++ b/Plugins/ScriptPlugins/ParserPIW5.js @@ -3,7 +3,7 @@ var eventParser; var plugin = { author: 'RaidMax', - version: 0.7, + version: 0.8, name: 'Plutonium IW5 Parser', isParser: true, @@ -35,6 +35,7 @@ var plugin = { rconParser.Configuration.Status.AddMapping(103, 5); rconParser.Configuration.Status.AddMapping(104, 6); + rconParser.IsOneLog = true; rconParser.Version = 'IW5 MP 1.9 build 388110 Fri Sep 14 00:04:28 2012 win-x86'; rconParser.GameName = 3; // IW5 eventParser.Version = 'IW5 MP 1.9 build 388110 Fri Sep 14 00:04:28 2012 win-x86'; diff --git a/SharedLibraryCore/Commands/NativeCommands.cs b/SharedLibraryCore/Commands/NativeCommands.cs index 59ffd158a..03ed5aec1 100644 --- a/SharedLibraryCore/Commands/NativeCommands.cs +++ b/SharedLibraryCore/Commands/NativeCommands.cs @@ -1359,13 +1359,13 @@ namespace SharedLibraryCore.Commands public override async Task ExecuteAsync(GameEvent E) { - var Response = await E.Owner.ExecuteCommandAsync(E.Data.Trim()); - foreach (string S in Response) + var response = await E.Owner.ExecuteCommandAsync(E.Data.Trim()); + foreach (var item in response) { - E.Origin.Tell(S); + E.Origin.Tell(item); } - if (Response.Length == 0) + if (response.Length == 0) { E.Origin.Tell(_translationLookup["COMMANDS_RCON_SUCCESS"]); } diff --git a/SharedLibraryCore/Interfaces/IRConParser.cs b/SharedLibraryCore/Interfaces/IRConParser.cs index 7fd8046c3..20eb8f749 100644 --- a/SharedLibraryCore/Interfaces/IRConParser.cs +++ b/SharedLibraryCore/Interfaces/IRConParser.cs @@ -71,6 +71,12 @@ namespace SharedLibraryCore.Interfaces /// eg: COD, Source /// string RConEngine { get; } + + /// + /// indicates that the game does not log to the mods folder (when mod is loaded), + /// but rather always to the fs_basegame directory + /// + bool IsOneLog { get; } /// /// retrieves the value of given dvar key if it exists in the override dict