void SaveCore(string path) { if (blocks == null) { return; } if (File.Exists(path)) { string prevPath = LevelInfo.PrevPath(name); if (File.Exists(prevPath)) { File.Delete(prevPath); } File.Copy(path, prevPath, true); File.Delete(path); } IMapExporter.Formats[0].Write(path + ".backup", this); File.Copy(path + ".backup", path); SaveSettings(this); Logger.Log(LogType.SystemActivity, "SAVED: Level \"{0}\". ({1}/{2}/{3})", name, players.Count, PlayerInfo.Online.Count, ServerConfig.MaxPlayers); Changed = false; }
static Level ReadLevel(Player p, string map) { Level lvl = Level.Load(map); if (lvl != null) { return(lvl); } string path = LevelInfo.MapPath(map) + ".backup"; if (!File.Exists(path)) { p.Message("Level \"{0}\" does not exist", map); return(lvl); } lvl = ReadBackup(p, map, path, "backup copy"); if (lvl != null) { return(lvl); } path = LevelInfo.PrevPath(map); lvl = ReadBackup(p, map, path, "previous save"); if (lvl != null) { return(lvl); } string backupDir = LevelInfo.BackupBasePath(map); if (Directory.Exists(backupDir)) { int latest = LevelInfo.LatestBackup(map); path = LevelInfo.BackupFilePath(map, latest.ToString()); lvl = ReadBackup(p, map, path, "latest backup"); } else { p.Message("%WLatest backup of {0} does not exist.", map); } return(lvl); }