From 38011f636456fc3593df1bbc87ade053f1876eb7 Mon Sep 17 00:00:00 2001 From: Zack Piispanen Date: Sun, 15 Jan 2012 17:46:38 -0500 Subject: [PATCH] added a bool to the world save mechanism. This should prevent it from saving 3 times at once. Hopefully thats what was causing server crashes --- TShockAPI/TShock.cs | 9 ++++++--- TShockAPI/Utils.cs | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 5c2f32b4..e0a9fc39 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -972,9 +972,12 @@ namespace TShockAPI void OnSaveWorld(bool resettime, HandledEventArgs e) { - Utils.Broadcast("Saving world. Momentary lag might result from this.", Color.Red); - var SaveWorld = new Thread(Utils.SaveWorld); - SaveWorld.Start(); + if (!Utils.saving) + { + Utils.Broadcast("Saving world. Momentary lag might result from this.", Color.Red); + var SaveWorld = new Thread(Utils.SaveWorld); + SaveWorld.Start(); + } e.Handled = true; } diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index a03a0439..b9e3eedc 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -29,6 +29,8 @@ namespace TShockAPI { public class Utils { + public static bool saving = false; + public Utils() { } @@ -110,9 +112,11 @@ namespace TShockAPI /// public void SaveWorld() { - WorldGen.realsaveWorld(); - Broadcast("World saved.", Color.Yellow); - Log.Info(string.Format("World saved at ({0})", Main.worldPathName)); + saving = true; + WorldGen.realsaveWorld(); + Broadcast("World saved.", Color.Yellow); + Log.Info(string.Format("World saved at ({0})", Main.worldPathName)); + saving = false; } ///