/// <summary> Saves the current world list to worlds.xml. Thread-safe. </summary> public static void SaveWorldList() { const string worldListTempFileName = Paths.WorldListFileName + ".tmp"; // Save world list lock ( SyncRoot ) { XDocument doc = new XDocument(); XElement root = new XElement("fCraftWorldList"); foreach (World world in Worlds) { XElement temp = new XElement("World"); temp.Add(new XAttribute("name", world.Name)); if (world.AccessSecurity.HasRestrictions) { temp.Add(world.AccessSecurity.Serialize(AccessSecurityXmlTagName)); } if (world.BuildSecurity.HasRestrictions) { temp.Add(world.BuildSecurity.Serialize(BuildSecurityXmlTagName)); } if (world.BackupInterval != WorldManager.DefaultBackupInterval) { temp.Add(new XAttribute("backup", world.BackupInterval.ToTickString())); } if (world.NeverUnload) { temp.Add(new XAttribute("noUnload", true)); } if (world.VisitCount > 0) { temp.Add(new XAttribute("visitCount", world.VisitCount)); } if (world.IsHidden) { temp.Add(new XAttribute("hidden", true)); } temp.Add(world.BlockDB.SaveSettings()); temp.Add(Physics.SaveSettings(world)); temp.Add(Physics.SaveOtherSettings(world)); temp.Add(world.SaveRealmState()); if (world.Greeting != null) { temp.Add(new XElement("Greeting", world.Greeting)); } World world1 = world; foreach (Rank mainedRank in RankManager.Ranks.Where(r => r.MainWorld == world1)) { temp.Add(new XElement(RankMainXmlTagName, mainedRank.FullName)); } if (!String.IsNullOrEmpty(world.LoadedBy)) { temp.Add(new XElement("LoadedBy", world.LoadedBy)); } if (world.LoadedOn != DateTime.MinValue) { temp.Add(new XElement("LoadedOn", world.LoadedOn.ToUnixTime())); } if (!String.IsNullOrEmpty(world.MapChangedBy)) { temp.Add(new XElement("MapChangedBy", world.MapChangedBy)); } if (world.MapChangedOn != DateTime.MinValue) { temp.Add(new XElement("MapChangedOn", world.MapChangedOn.ToUnixTime())); } XElement elEnv = new XElement(EnvironmentXmlTagName); if (world.CloudColor > -1) { elEnv.Add(new XAttribute("cloud", world.CloudColor)); } if (world.FogColor > -1) { elEnv.Add(new XAttribute("fog", world.FogColor)); } if (world.SkyColor > -1) { elEnv.Add(new XAttribute("sky", world.SkyColor)); } if (world.EdgeLevel > -1) { elEnv.Add(new XAttribute("level", world.EdgeLevel)); } if (world.Terrain != null) { elEnv.Add(new XAttribute("terrain", world.Terrain)); } if (world.EdgeBlock != Block.Water) { elEnv.Add(new XAttribute("edge", world.EdgeBlock)); } if (elEnv.HasAttributes) { temp.Add(elEnv); } root.Add(temp); } root.Add(new XAttribute("main", MainWorld.Name)); doc.Add(root); doc.Save(worldListTempFileName); Paths.MoveOrReplace(worldListTempFileName, Paths.WorldListFileName); } }