mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Load levels from different path instead of just replacing file
This commit is contained in:
parent
de19b7acdb
commit
288d5c63fc
@ -100,7 +100,6 @@ namespace MCGalaxy.Commands.World {
|
||||
if (pl.level != p.level) continue;
|
||||
pl.SendCurrentMapAppearance();
|
||||
}
|
||||
p.level.Save();
|
||||
Level.SaveSettings(p.level);
|
||||
}
|
||||
|
||||
|
@ -86,28 +86,23 @@ namespace MCGalaxy.Commands.World {
|
||||
Player.Message(p, "Backup of {0} does not exist.", name); return null;
|
||||
}
|
||||
|
||||
if (LevelInfo.MapExists(name)) {
|
||||
Server.s.Log(name + ".lvl file is corrupt. Deleting and replacing with " + name + ".lvl.backup file.");
|
||||
File.Delete(LevelInfo.MapPath(name));
|
||||
}
|
||||
Server.s.Log("Attempting to load backup");
|
||||
File.Copy(LevelInfo.MapPath(name) + ".backup", LevelInfo.MapPath(name), true);
|
||||
level = Level.Load(name, LevelInfo.MapPath(name) + ".backup", 0);
|
||||
if (level != null) return level;
|
||||
|
||||
level = Level.Load(name);
|
||||
if (level == null) {
|
||||
Player.Message(p, "Loading backup failed.");
|
||||
string backupPath = Server.backupLocation;
|
||||
if (Directory.Exists(backupPath + "/" + name)) {
|
||||
int backupNumber = Directory.GetDirectories(backupPath + "/" + name).Length;
|
||||
Server.s.Log("Attempting to load latest backup, number " + backupNumber + " instead.");
|
||||
File.Copy(LevelInfo.BackupPath(name, backupNumber.ToString()), LevelInfo.MapPath(name), true);
|
||||
level = Level.Load(name);
|
||||
if (level == null) {
|
||||
Player.Message(p, "Loading latest backup failed as well.");
|
||||
}
|
||||
} else {
|
||||
Player.Message(p, "Latest backup of {0} does not exist.", name);
|
||||
}
|
||||
Player.Message(p, "Loading backup failed.");
|
||||
string backupPath = Server.backupLocation;
|
||||
|
||||
if (Directory.Exists(backupPath + "/" + name)) {
|
||||
int num = Directory.GetDirectories(backupPath + "/" + name).Length;
|
||||
Server.s.Log("Attempting to load latest backup, number " + num + " instead.");
|
||||
|
||||
string path = LevelInfo.BackupPath(name, num.ToString());
|
||||
level = Level.Load(name, path, 0);
|
||||
if (level == null)
|
||||
Player.Message(p, "Loading latest backup failed as well.");
|
||||
} else {
|
||||
Player.Message(p, "Latest backup of {0} does not exist.", name);
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
@ -334,14 +334,15 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
public static Level Load(string name) { return Load(name, 0); }
|
||||
public static Level Load(string name) { return Load(name, LevelInfo.MapPath(name), 0); }
|
||||
|
||||
public static Level Load(string name, byte phys) {
|
||||
public static Level Load(string name, byte phys) { return Load(name, LevelInfo.MapPath(name), phys); }
|
||||
|
||||
public static Level Load(string name, string path, byte phys) {
|
||||
if (LevelLoad != null) LevelLoad(name);
|
||||
OnLevelLoadEvent.Call(name);
|
||||
if (cancelload) { cancelload = false; return null; }
|
||||
|
||||
string path = LevelInfo.MapPath(name);
|
||||
if (!File.Exists(path)) {
|
||||
Server.s.Log("Attempted to load " + name + ", but the level file does not exist.");
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user