public async Task Initialize() { RconParser = ServerConfig.UseT6MParser ? (IRConParser) new T6MRConParser() : new IW4RConParser(); if (ServerConfig.UseIW5MParser) { RconParser = new IW5MRConParser(); } var version = await this.GetDvarAsync <string>("version"); GameName = Utilities.GetGame(version.Value); if (GameName == Game.IW4) { EventParser = new IW4EventParser(); } else if (GameName == Game.IW5) { EventParser = new IW5EventParser(); } else if (GameName == Game.T6M) { EventParser = new T6MEventParser(); } else if (GameName == Game.UKN) { Logger.WriteWarning($"Game name not recognized: {version}"); } else { EventParser = new IW4EventParser(); } var shortversion = await this.GetDvarAsync <string>("shortversion"); var hostname = await this.GetDvarAsync <string>("sv_hostname"); var mapname = await this.GetDvarAsync <string>("mapname"); var maxplayers = (GameName == Game.IW4) ? // gotta love IW4 idiosyncrasies await this.GetDvarAsync <int>("party_maxplayers") : await this.GetDvarAsync <int>("sv_maxclients"); var gametype = await this.GetDvarAsync <string>("g_gametype"); var basepath = await this.GetDvarAsync <string>("fs_basepath"); WorkingDirectory = basepath.Value; var game = await this.GetDvarAsync <string>("fs_game"); var logfile = await this.GetDvarAsync <string>("g_log"); var logsync = await this.GetDvarAsync <int>("g_logsync"); try { var website = await this.GetDvarAsync <string>("_website"); Website = website.Value; } catch (DvarException) { Website = loc["SERVER_WEBSITE_GENERIC"]; } InitializeMaps(); this.Hostname = hostname.Value.StripColors(); this.CurrentMap = Maps.Find(m => m.Name == mapname.Value) ?? new Map() { Alias = mapname.Value, Name = mapname.Value }; this.MaxClients = maxplayers.Value; this.FSGame = game.Value; this.Gametype = gametype.Value; //wait this.SetDvarAsync("sv_kickbantime", 60); if (logsync.Value == 0 || logfile.Value == string.Empty) { // this DVAR isn't set until the a map is loaded await this.SetDvarAsync("logfile", 2); await this.SetDvarAsync("g_logsync", 2); // set to 2 for continous in other games, clamps to 1 for IW4 await this.SetDvarAsync("g_log", "games_mp.log"); Logger.WriteWarning("Game log file not properly initialized, restarting map..."); await this.ExecuteCommandAsync("map_restart"); logfile = await this.GetDvarAsync <string>("g_log"); } CustomCallback = await ScriptLoaded(); string mainPath = EventParser.GetGameDir(); #if DEBUG basepath.Value = @"\\192.168.88.253\Call of Duty Black Ops II"; #endif string logPath; if (GameName == Game.IW5) { logPath = ServerConfig.ManualLogPath; } else { logPath = game.Value == string.Empty ? $"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{mainPath}{Path.DirectorySeparatorChar}{logfile.Value}" : $"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{game.Value.Replace('/', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{logfile.Value}"; } // hopefully fix wine drive name mangling if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { logPath = Regex.Replace(logPath, @"[A-Z]:", ""); } if (!File.Exists(logPath)) { Logger.WriteError($"Gamelog {logPath} does not exist!"); #if !DEBUG throw new ServerException($"Invalid gamelog file {logPath}"); #endif } else { LogFile = new IFile(logPath); } Logger.WriteInfo($"Log file is {logPath}"); #if DEBUG // LogFile = new RemoteFile("https://raidmax.org/IW4MAdmin/getlog.php"); #else await Broadcast(loc["BROADCAST_ONLINE"]); #endif }