void AutoBackup(object param) { if (lockDown) { return; } if (!firstBackup || config.GetBool("BackupOnStartup")) { map.SaveBackup(String.Format("backups/{0:yyyy-MM-ddTHH-mm}.fcm", DateTime.Now)); } firstBackup = false; }
void SaveTask(SchedulerTask task) { if (Map == null) { return; } lock ( SyncRoot ) { // ReSharper disable ConditionIsAlwaysTrueOrFalse // ReSharper disable HeuristicUnreachableCode if (Map == null) { return; } // ReSharper restore HeuristicUnreachableCode // ReSharper restore ConditionIsAlwaysTrueOrFalse if (BackupInterval != TimeSpan.Zero && DateTime.UtcNow.Subtract(lastBackup) > BackupInterval && (Map.HasChangedSinceBackup || !ConfigKey.BackupOnlyWhenChanged.Enabled())) { string backupFileName = String.Format(TimedBackupFormat, Name, DateTime.Now); // localized Map.SaveBackup(MapFileName, Path.Combine(Paths.BackupPath, backupFileName)); lastBackup = DateTime.UtcNow; } if (Map.HasChangedSinceSave) { SaveMap(); } } }
void SaveTask(SchedulerTask task) { if (!IsLoaded) { return; } lock ( SyncRoot ) { if (Map == null) { return; } lock ( BackupLock ) { if (BackupsEnabled && DateTime.UtcNow.Subtract(lastBackup) > BackupInterval && (Map.HasChangedSinceBackup || !ConfigKey.BackupOnlyWhenChanged.Enabled())) { string backupFileName = String.Format(TimedBackupFormat, Name, DateTime.Now); // localized Map.SaveBackup(MapFileName, Path.Combine(Paths.BackupPath, backupFileName)); lastBackup = DateTime.UtcNow; } } if (Map.HasChangedSinceSave) { SaveMap(); } } }
void BackupTask(SchedulerTask task) { Map tempMap = Map; if (tempMap != null) { tempMap.SaveBackup(Path.Combine(Paths.MapPath, GetMapName()), Path.Combine(Paths.BackupPath, String.Format("{0}_{1:yyyy-MM-dd_HH-mm}.fcm", Name, DateTime.Now)), // localized true); } }
public Map AcceptPlayer([NotNull] Player player, bool announce) { if (player == null) { throw new ArgumentNullException("player"); } lock ( SyncRoot ) { if (IsFull) { if (player.Info.Rank.ReservedSlot) { Player idlestPlayer = Players.Where(p => p.Info.Rank.IdleKickTimer != 0) .OrderBy(p => p.LastActiveTime) .FirstOrDefault(); if (idlestPlayer != null) { idlestPlayer.Kick(Player.Console, "Auto-kicked to make room (idle).", LeaveReason.IdleKick, false, false, false); Server.Message("Player {0}&S was auto-kicked to make room for {1}", idlestPlayer.ClassyName, player.ClassyName); } else { return(null); } } else { return(null); } } if (playerIndex.ContainsKey(player.Name.ToLower())) { Logger.Log(LogType.Error, "This world already contains the player by name ({0}). " + "Some sort of state corruption must have occured.", player.Name); playerIndex.Remove(player.Name.ToLower()); } playerIndex.Add(player.Name.ToLower(), player); // load the map, if it's not yet loaded IsPendingMapUnload = false; Map = LoadMap(); if (ConfigKey.BackupOnJoin.Enabled() && (Map.HasChangedSinceBackup || !ConfigKey.BackupOnlyWhenChanged.Enabled())) { string backupFileName = String.Format(JoinBackupFormat, Name, DateTime.Now, player.Name); // localized Map.SaveBackup(MapFileName, Path.Combine(Paths.BackupPath, backupFileName)); } UpdatePlayerList(); if (announce && ConfigKey.ShowJoinedWorldMessages.Enabled()) { Server.Players.CanSee(player) .Message("&SPlayer {0}&S joined {1}", player.ClassyName, ClassyName); } Logger.Log(LogType.UserActivity, "Player {0} joined world {1}.", player.Name, Name); if (IsLocked) { player.Message("&WThis map is currently locked (read-only)."); } if (player.Info.IsHidden) { player.Message("&8Reminder: You are still hidden."); } return(Map); } }
public Map AcceptPlayer(Player player, bool announce) { if (player == null) { throw new ArgumentNullException("player"); } lock ( WorldLock ) { if (IsFull) { return(null); } if (players.ContainsKey(player.Name.ToLower())) { Logger.Log("This world already contains the player by name ({0}). " + "Some sort of state corruption must have occured.", LogType.Error, player.Name); players.Remove(player.Name.ToLower()); } players.Add(player.Name.ToLower(), player); // load the map, if it's not yet loaded PendingUnload = false; if (Map == null) { LoadMap(); } if (ConfigKey.BackupOnJoin.GetBool()) { string backupFileName = String.Format("{0}_{1:yyyy-MM-dd_HH-mm}_{2}.fcm", Name, DateTime.Now, player.Name); // localized Map.SaveBackup(Path.Combine(Paths.MapPath, GetMapName()), Path.Combine(Paths.BackupPath, backupFileName), true); } AddPlayerForPatrol(player); UpdatePlayerList(); if (announce && ConfigKey.ShowJoinedWorldMessages.GetBool()) { string message = String.Format("&SPlayer {0}&S joined {1}", player.GetClassyName(), GetClassyName()); foreach (Packet packet in PacketWriter.MakeWrappedMessage(">", message, false)) { Server.SendToSeeing(packet, player); } } Logger.Log("Player {0} joined world {1}.", LogType.UserActivity, player.Name, Name); if (OnPlayerJoined != null) { OnPlayerJoined(player, this); } if (IsLocked) { player.Message("&WThis map is currently locked (read-only)."); } if (player.IsHidden) { player.Message("Reminder: You are still hidden."); } return(Map); } }