Permalink
Browse files

If a save ever failed, no subsequent save would ever be attempted.

  • Loading branch information...
Joshua Rogers
Joshua Rogers committed Jul 31, 2011
1 parent 9878377 commit 6402476311fafe6da40f59727c61a430e6fe9511
Showing with 17 additions and 5 deletions.
  1. +5 −1 Terraria_Server/NetPlay.cs
  2. +12 −4 Terraria_Server/WorldMod/WorldIO.cs
@@ -249,7 +249,11 @@ public static void ServerLoop ()
catch {}
}
WorldIO.saveWorld(Program.server.World.SavePath, true);
if (false == WorldIO.saveWorld(Program.server.World.SavePath, true))
{
WorldIO.saveWorld(Program.server.World.SavePath, true);
ProgramLog.Log("Saving failed. Quitting without saving.");
}
Statics.serverStarted = false;
}
@@ -122,16 +122,18 @@ public static void clearWorld()
worldCleared = true;
}
public static void saveWorld(String savePath, bool resetTime = false)
public static Boolean saveWorld(String savePath, bool resetTime = false)
{
Boolean success = true;
if (savePath == null)
{
return;
return false;
}
if (WorldModify.saveLock)
{
return;
return false;
}
try
@@ -335,13 +337,19 @@ public static void saveWorld(String savePath, bool resetTime = false)
}
stopwatch.Stop();
ProgramLog.Log("Save duration: " + stopwatch.Elapsed.Seconds + " Second(s)");
WorldModify.saveLock = false;
}
}
catch (Exception e)
{
ProgramLog.Log(e, "Exception saving the world");
success = false;
}
finally
{
WorldModify.saveLock = false;
}
return success;
}
public static void loadWorld()

0 comments on commit 6402476

Please sign in to comment.