Skip to content
This repository has been archived by the owner on Apr 17, 2021. It is now read-only.

Commit

Permalink
If a save ever failed, no subsequent save would ever be attempted.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Rogers committed Jul 31, 2011
1 parent 9878377 commit 6402476
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Terraria_Server/NetPlay.cs
Expand Up @@ -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;
}
Expand Down
16 changes: 12 additions & 4 deletions Terraria_Server/WorldMod/WorldIO.cs
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 6402476

Please sign in to comment.