public override void SettingsLoadedEvent() { if (DASettingsManager.GetSettings(SettingsFilename) == null) { Engine.ConsoleOutput($"[{nameof(PackageServer)}]: Missing settings file '{SettingsFilename}'\n"); } }
public override void SettingsLoadedEvent() { lock (stateObject) { StopTimer(FetchIPTimerNumber); currentFetchURLIndex = 0; IDASettingsClass settings = DASettingsManager.GetSettings(PackageServerSettingsManager.SettingsFilename); if (settings == null) { return; } IPFetchURLs = new Uri[0]; IINISection ipFetchURLsSection = settings.GetSection(nameof(IPFetchURLs)); if (ipFetchURLsSection != null) { ICollection <Uri> urls = new LinkedList <Uri>(); foreach (IINIEntry entry in ipFetchURLsSection.EntryList) { string currentValue = entry.Value; if (currentValue != null && Uri.TryCreate(currentValue.Trim(), UriKind.Absolute, out Uri currentIPFetchURL)) { urls.Add(currentIPFetchURL); } } IPFetchURLs = new Uri[urls.Count]; urls.CopyTo(IPFetchURLs, 0); } if (IPFetchURLs.Length <= 0) { Engine.ConsoleOutput($"[{nameof(PackageServer)}]: No valid IP fetch URLs defined\n"); } IPFetchSecondsInterval = settings.GetInt(nameof(IPFetchSecondsInterval), DefaultIPFetchSecondsInterval); if (IPFetchSecondsInterval <= 0) { Engine.ConsoleOutput($"[{nameof(PackageServer)}]: No valid IP fetch interval defined, defaulting to {DefaultIPFetchSecondsInterval} second(s)\n"); IPFetchSecondsInterval = DefaultIPFetchSecondsInterval; } if (LastIPAddress == null) { FetchIPAsync(); } if (IPFetchURLs.Length > 0) { StartTimer(FetchIPTimerNumber, TimeSpan.FromSeconds(IPFetchSecondsInterval), true); } } }
public override void SettingsLoadedEvent() { // Reload the map definitions mappedDefinitions.Clear(); // Load global/per map stuff IDASettingsClass settings = DASettingsManager.GetSettings(SettingsFilename); BRFEnabled = settings.GetBool(GeneralSectionName, $"{nameof(BRFEnabled)}", BRFEnabledDefaultValue); BRFScaleWithPlayerCount = settings.GetBool(GeneralSectionName, $"{nameof(BRFScaleWithPlayerCount)}", BRFScaleWithPlayerCountDefaultValue); BRFScale = settings.GetFloat(GeneralSectionName, $"{nameof(BRFScale)}", BRFScaleDefaultValue); BRFMaxRestoreCount = settings.GetInt(GeneralSectionName, $"{nameof(BRFMaxRestoreCount)}", BRFMaxRestoreCountDefaultValue); BRFRestoreCost = settings.GetFloat(GeneralSectionName, $"{nameof(BRFRestoreCost)}", BRFRestoreCostDefaultValue); BRFAllowRefund = settings.GetBool(GeneralSectionName, $"{nameof(BRFAllowRefund)}", BRFAllowRefundDefaultValue); // Parse all mappings of preset name = acronym IINISection defsSection = settings.GetSection(DefsSectionName); if (defsSection != null) { foreach (IINIEntry currentEntry in defsSection.EntryList) { ParseDefinitionEntry(currentEntry); } } // Check if we have per acronym settings foreach (var mappedDefinitionPair in mappedDefinitions) { mappedDefinitionPair.Value.ScaleWithPlayerCount = settings.GetBool(GeneralSectionName, $"{nameof(BRFScaleWithPlayerCount)}_{mappedDefinitionPair.Key}", BRFScaleWithPlayerCount); mappedDefinitionPair.Value.Scale = settings.GetFloat(GeneralSectionName, $"{nameof(BRFScale)}_{mappedDefinitionPair.Key}", BRFScale); mappedDefinitionPair.Value.MaxRestoreCount = settings.GetInt(GeneralSectionName, $"{nameof(BRFMaxRestoreCount)}_{mappedDefinitionPair.Key}", BRFMaxRestoreCount); mappedDefinitionPair.Value.RestoreCost = settings.GetFloat(GeneralSectionName, $"{nameof(BRFRestoreCost)}_{mappedDefinitionPair.Key}", BRFRestoreCost); } // If this is called during gameplay and some settings changed that allows to restore a building we have to check it now TryRestoreAllBuildings(); }
public override void SettingsLoadedEvent() { IDASettingsClass settings = DASettingsManager.GetSettings("da.ini"); IINISection section = settings.GetSection("ConnectionLostDetector"); foreach (IINIEntry entry in section.EntryList) { switch (entry.Entry) { case "Message": Message = entry.Value; break; case "GameLog": GameLogEnabled = Convert.ToBoolean(entry.Value); break; default: Engine.ConsoleOutput($"[Connection Lost Detector] Invalid entry detected under Connection Lost Detector section in configuration file!\n" + $"[Connection Lost Detector] Key: \"{entry.Entry}\" | Value: \"{entry.Value}\"\n"); break; } } }
public override void SettingsLoadedEvent() { IDASettingsClass settings = DASettingsManager.GetSettings("da.ini"); UnregisterChatCommand(ACmdTriggers); UnregisterChatCommand(CmdTriggers); IINISection section = settings.GetSection("JoinSounds"); foreach (IINIEntry entry in section.EntryList) { switch (entry.Entry) { case "CommandsTriggers": CmdTriggers = entry.Value; break; case "AdminCommandsTriggers": ACmdTriggers = entry.Value; break; case "DatabaseFile": DBFile = entry.Value; break; case "MaxDelay": MaxDelay = (float)Convert.ToDouble(entry.Value.Replace(".", ",")); break; case "MinDelay": MinDelay = (float)Convert.ToDouble(entry.Value.Replace(".", ",")); break; case "DisableList": //DA.HostMessage(entry.Value); DisableList = entry.Value.Split('|').ToList(); break; case "AdminLevel": AdminLevel = Convert.ToInt32(entry.Value); break; case "ClearLevel": ClearLevel = Convert.ToInt32(entry.Value); break; case "GameLog": GameLogEnabled = Convert.ToBoolean(entry.Value); break; default: Engine.ConsoleOutput($"[Join Sounds] Invalid entry detected under Join Sounds section in configuration file!\n" + $"[Join Sounds] Key: \"{entry.Entry}\" | Value: \"{entry.Value}\"\n"); break; } } if (!File.Exists(JoinSounds.DBFile)) { File.WriteAllText(JoinSounds.DBFile, "[\r\n\r\n]"); } PlayersDatabase.ReloadSettings(); RegisterChatCommand(JoinSoundsGenericCommand, CmdTriggers, 1); RegisterChatCommand(JoinSoundsAdminGenericCommand, ACmdTriggers, 1); }
public override void SettingsLoadedEvent() { MimeTypes.Clear(); ErrorPages.Clear(); IDASettingsClass settings = DASettingsManager.GetSettings("RenWeb.ini"); if (settings != null) { IINISection section = settings.GetSection("RenWeb"); foreach (IINIEntry entry in section.EntryList) { switch (entry.Entry) { case "Port": if (int.TryParse(entry.Value, out int port)) { Port = port; } else { Engine.ConsoleOutput($"[RenWeb] Port value is invalid! Using default port 7550...\n"); Log(LogSeverity.Warning, $"Port value is invalid! Supplied value: \"{port}\". Using default port \"7550\""); Port = 7550; } break; case "RootHTTPFolder": RootHTTPFolder = entry.Value; break; case "IndexFile": IndexFile = entry.Value; break; case "LogFile": LogFile = entry.Value; break; case "MaxPendingConnections": if (int.TryParse(entry.Value, out int max)) { MaxPendingConnections = max; } else { Engine.ConsoleOutput($"[RenWeb] Max pending conections value is invalid! Using default 5...\n"); Log(LogSeverity.Warning, $"Max pending conections value is invalid! Supplied value: \"{max}\". Using default \"5\""); MaxPendingConnections = 5; } break; case "GameLog": if (bool.TryParse(entry.Value, out bool isit)) { GameLog = isit; } else { Engine.ConsoleOutput($"[RenWeb] Game log value is invalid! Using default true...\n"); Log(LogSeverity.Warning, $"Game log value is invalid! Supplied value: \"{isit}\". Using default \"true\""); GameLog = true; } break; default: Engine.ConsoleOutput($"[RenWeb] Invalid entry detected under RenWeb section in configuration file!\n" + $"[RenWeb] Key: \"{entry.Entry}\" | Value: \"{entry.Value}\"\n"); Log(LogSeverity.Warning, $"Invalid config value detected under [RenWeb]. Key: \"{entry.Entry}\" | Value: \"{entry.Value}\""); break; } } IINISection Mime = settings.GetSection("RenWeb_MimeTypes"); foreach (IINIEntry entry in Mime.EntryList) { MimeTypes.Add(entry.Entry, entry.Value); } IINISection Page = settings.GetSection("RenWeb_ErrorPages"); foreach (IINIEntry entry in Page.EntryList) { string[] Errors = entry.Entry.Split('|'); System.Collections.Generic.List <int> ErrCodes = new System.Collections.Generic.List <int>(); foreach (string s in Errors) { if (int.TryParse(s, out int Code)) { ErrCodes.Add(Code); } else { Engine.ConsoleOutput($"[RenWeb] Invalid error code detected under RenWeb_ErrorPages! Value: {s}\n"); Log(LogSeverity.Warning, $"Invalid error code under RenWeb_ErrorPages! Value: {s}. Skipping this code...\n"); } } ErrorPages.Add(ErrCodes, entry.Value); } if (!Directory.Exists(Main.RootHTTPFolder)) { Directory.CreateDirectory(Main.RootHTTPFolder); Setup(Main.RootHTTPFolder); } if (!File.Exists(Main.LogFile)) { MakeFile(Main.LogFile); } RestartServer(); //Start server if not running, restart if running. } else { string ServerRoot = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "RenWeb.ini"); if (!File.Exists(ServerRoot)) { Engine.ConsoleOutput("[RenWeb] Could not find RenWeb.ini in server folder. Creating a one with default settings...\n"); File.Create(ServerRoot).Close(); File.WriteAllBytes(ServerRoot, FileStorage.Config); DASettingsManager.AddSettings("RenWeb.ini"); Engine.ConsoleInput("reload"); } else { Engine.ConsoleOutput("[RenWeb] FATAL ERROR! Failed to load RenWeb settings file. Attempting to register configuration file into DA...\n"); DASettingsManager.AddSettings("RenWeb.ini"); Engine.ConsoleInput("reload"); } } }