public World ChangeMap([NotNull] Map newMap) { if (newMap == null) { throw new ArgumentNullException("newMap"); } lock ( SyncRoot ) { World newWorld = new World(Name) { AccessSecurity = (SecurityController)AccessSecurity.Clone(), BuildSecurity = (SecurityController)BuildSecurity.Clone(), IsHidden = IsHidden, BlockDB = BlockDB, lastBackup = lastBackup, BackupInterval = BackupInterval, IsLocked = IsLocked, LockedBy = LockedBy, UnlockedBy = UnlockedBy, LockedOn = LockedOn, UnlockedOn = UnlockedOn, LoadedBy = LoadedBy, LoadedOn = LoadedOn, MapChangedBy = MapChangedBy, MapChangedOn = DateTime.UtcNow, FogColor = FogColor, CloudColor = CloudColor, SkyColor = SkyColor, EdgeLevel = EdgeLevel, EdgeBlock = EdgeBlock }; newMap.World = newWorld; newWorld.Map = newMap; newWorld.Preload = preload; WorldManager.ReplaceWorld(this, newWorld); using (BlockDB.GetWriteLock()) { BlockDB.Clear(); BlockDB.World = newWorld; } foreach (Player player in Players) { player.JoinWorld(newWorld, WorldChangeReason.Rejoin); } return(newWorld); } }
public World ChangeMap([NotNull] Map newMap) { if (newMap == null) { throw new ArgumentNullException("newMap"); } lock ( SyncRoot ) { World newWorld = new World(Name) { AccessSecurity = (SecurityController)AccessSecurity.Clone(), BuildSecurity = (SecurityController)BuildSecurity.Clone(), IsHidden = IsHidden, BlockDB = BlockDB, lastBackup = lastBackup, BackupInterval = BackupInterval, IsLocked = IsLocked, LockedBy = LockedBy, UnlockedBy = UnlockedBy, LockedOn = LockedOn, UnlockedOn = UnlockedOn, LoadedBy = LoadedBy, LoadedOn = LoadedOn, MapChangedBy = MapChangedBy, MapChangedOn = DateTime.UtcNow, Buildable = Buildable, Deletable = Deletable, }; newWorld.CopyENV(this); WorldManager.ParseCPEMetaData(ref newWorld, newMap, Name); newMap.World = newWorld; newWorld.Map = newMap; newWorld.Preload = preload; WorldManager.ReplaceWorld(this, newWorld); using (BlockDB.GetWriteLock()) { BlockDB.Clear(); BlockDB.World = newWorld; } foreach (Player player in Players) { player.JoinWorld(newWorld, WorldChangeReason.Rejoin); } return(newWorld); } }
public World ChangeMap([NotNull] Map newMap) { if (newMap == null) { throw new ArgumentNullException("newMap"); } lock ( SyncRoot ) { World newWorld = new World(Name) { AccessSecurity = (SecurityController)AccessSecurity.Clone(), BuildSecurity = (SecurityController)BuildSecurity.Clone(), IsHidden = IsHidden, BlockDB = BlockDB, lastBackup = lastBackup, BackupInterval = BackupInterval, IsLocked = IsLocked, LockedBy = LockedBy, UnlockedBy = UnlockedBy, LockedOn = LockedOn, UnlockedOn = UnlockedOn, LoadedBy = LoadedBy, LoadedOn = LoadedOn, MapChangedBy = MapChangedBy, MapChangedOn = DateTime.UtcNow, FogColor = FogColor, CloudColor = CloudColor, SkyColor = SkyColor, EdgeLevel = EdgeLevel, SidesOffset = SidesOffset, CloudsHeight = CloudsHeight, MaxFogDistance = MaxFogDistance, EdgeBlock = EdgeBlock, HorizonBlock = HorizonBlock, LightColor = LightColor, ShadowColor = ShadowColor, Weather = Weather, Texture = Texture, CloudsSpeed = CloudsSpeed, WeatherSpeed = WeatherSpeed, WeatherFade = WeatherFade, SkyboxHorSpeed = SkyboxHorSpeed, SkyboxVerSpeed = SkyboxVerSpeed, Buildable = Buildable, Deletable = Deletable, BlockDefs = BlockDefs, }; newMap.World = newWorld; newWorld.Map = newMap; newWorld.Preload = preload; WorldManager.ReplaceWorld(this, newWorld); using (BlockDB.GetWriteLock()) { BlockDB.Clear(); BlockDB.World = newWorld; } foreach (Player player in Players) { player.JoinWorld(newWorld, WorldChangeReason.Rejoin); } return(newWorld); } }
public World ChangeMap([NotNull] Map newMap, [NotNull] string newMapChangedBy) { if (newMap == null) { throw new ArgumentNullException("newMap"); } if (newMapChangedBy == null) { throw new ArgumentNullException("newMapChangedBy"); } lock (SyncRoot) { if (mapWasChanged) { throw new InvalidOperationException("A map change is already pending!"); } World newWorld = new World(Name) { AccessSecurity = (SecurityController)AccessSecurity.Clone(), BuildSecurity = (SecurityController)BuildSecurity.Clone(), IsHidden = IsHidden, BlockDB = BlockDB, lastBackup = lastBackup, BackupInterval = BackupInterval, IsLocked = IsLocked, LockedBy = LockedBy, UnlockedBy = UnlockedBy, LockedOn = LockedOn, UnlockedOn = UnlockedOn, LoadedBy = LoadedBy, LoadedOn = LoadedOn, MapChangedBy = newMapChangedBy, MapChangedOn = DateTime.UtcNow, FogColor = FogColor, CloudColor = CloudColor, SkyColor = SkyColor, EdgeLevel = EdgeLevel, EdgeBlock = EdgeBlock }; newMap.World = newWorld; newWorld.Map = newMap; newWorld.Preload = preload; // save a backup, just in case if (ConfigKey.BackupOnMapChange.Enabled()) { if (Map != null && Map.HasChangedSinceSave) { SaveMap(); } string backupFileName = String.Format(MapChangeBackupFormat, Name, DateTime.Now); // localized SaveBackup(Path.Combine(Paths.BackupPath, backupFileName)); } // register the new world, and unregister this one WorldManager.ReplaceWorld(this, newWorld); mapWasChanged = true; // clear BlockDB for the old map using (BlockDB.GetWriteLock()) { BlockDB.Clear(); BlockDB.World = newWorld; } // tell players to go ahead foreach (Player player in Players) { player.JoinWorld(newWorld, WorldChangeReason.Rejoin); } return(newWorld); } }