public void SaveSettings() { XDocument doc = new XDocument(new XElement("serversettings")); SerializableProperty.SerializeProperties(this, doc.Root, true); doc.Root.SetAttributeValue("name", ServerName); doc.Root.SetAttributeValue("public", isPublic); doc.Root.SetAttributeValue("port", GameMain.Server.NetPeerConfiguration.Port); if (Steam.SteamManager.USE_STEAM) { doc.Root.SetAttributeValue("queryport", QueryPort); } doc.Root.SetAttributeValue("maxplayers", maxPlayers); doc.Root.SetAttributeValue("enableupnp", GameMain.Server.NetPeerConfiguration.EnableUPnP); doc.Root.SetAttributeValue("autorestart", autoRestart); doc.Root.SetAttributeValue("SubSelection", SubSelectionMode.ToString()); doc.Root.SetAttributeValue("ModeSelection", ModeSelectionMode.ToString()); doc.Root.SetAttributeValue("LevelDifficulty", ((int)selectedLevelDifficulty).ToString()); doc.Root.SetAttributeValue("TraitorsEnabled", TraitorsEnabled.ToString()); /*doc.Root.SetAttributeValue("BotCount", BotCount); * doc.Root.SetAttributeValue("MaxBotCount", MaxBotCount);*/ doc.Root.SetAttributeValue("BotSpawnMode", BotSpawnMode.ToString()); doc.Root.SetAttributeValue("AllowedRandomMissionTypes", string.Join(",", AllowedRandomMissionTypes)); doc.Root.SetAttributeValue("AllowedClientNameChars", string.Join(",", AllowedClientNameChars.Select(c => c.First + "-" + c.Second))); doc.Root.SetAttributeValue("ServerMessage", ServerMessageText); XmlWriterSettings settings = new XmlWriterSettings { Indent = true, NewLineOnAttributes = true }; using (var writer = XmlWriter.Create(SettingsFile, settings)) { doc.Save(writer); } if (KarmaPreset == "custom") { GameMain.Server?.KarmaManager?.SaveCustomPreset(); } GameMain.Server?.KarmaManager?.Save(); }
public void SaveSettings() { XDocument doc = new XDocument(new XElement("serversettings")); doc.Root.SetAttributeValue("name", ServerName); doc.Root.SetAttributeValue("public", IsPublic); doc.Root.SetAttributeValue("port", Port); #if USE_STEAM doc.Root.SetAttributeValue("queryport", QueryPort); #endif doc.Root.SetAttributeValue("password", password ?? ""); doc.Root.SetAttributeValue("enableupnp", EnableUPnP); doc.Root.SetAttributeValue("autorestart", autoRestart); doc.Root.SetAttributeValue("LevelDifficulty", ((int)selectedLevelDifficulty).ToString()); doc.Root.SetAttributeValue("ServerMessage", ServerMessageText); doc.Root.SetAttributeValue("AllowedRandomMissionTypes", string.Join(",", AllowedRandomMissionTypes)); doc.Root.SetAttributeValue("AllowedClientNameChars", string.Join(",", AllowedClientNameChars.Select(c => c.First + "-" + c.Second))); SerializableProperty.SerializeProperties(this, doc.Root, true); System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings { Indent = true, NewLineOnAttributes = true }; using (var writer = XmlWriter.Create(SettingsFile, settings)) { doc.SaveSafe(writer); } if (KarmaPreset == "custom") { GameMain.Server?.KarmaManager?.SaveCustomPreset(); } GameMain.Server?.KarmaManager?.Save(); }