More race conditions.
This commit is contained in:
parent
061169633d
commit
718764e533
3 changed files with 8 additions and 12 deletions
|
|
@ -68,9 +68,13 @@ namespace TShockAPI
|
||||||
Directory.CreateDirectory(worldpath);
|
Directory.CreateDirectory(worldpath);
|
||||||
|
|
||||||
Tools.Broadcast("Server map saving, potential lag spike");
|
Tools.Broadcast("Server map saving, potential lag spike");
|
||||||
|
Console.WriteLine("Backing up world...");
|
||||||
Thread SaveWorld = new Thread(Tools.SaveWorld);
|
Thread SaveWorld = new Thread(Tools.SaveWorld);
|
||||||
SaveWorld.Start();
|
SaveWorld.Start();
|
||||||
|
|
||||||
|
while (SaveWorld.ThreadState == ThreadState.Running)
|
||||||
|
Thread.Sleep(50);
|
||||||
|
|
||||||
Main.worldPathName = worldname;
|
Main.worldPathName = worldname;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,6 @@ namespace TShockAPI
|
||||||
|
|
||||||
public static IDbConnection Sql;
|
public static IDbConnection Sql;
|
||||||
|
|
||||||
public static bool WorldSaving = false;
|
|
||||||
|
|
||||||
public override Version Version
|
public override Version Version
|
||||||
{
|
{
|
||||||
get { return VersionNum; }
|
get { return VersionNum; }
|
||||||
|
|
@ -540,16 +538,11 @@ namespace TShockAPI
|
||||||
|
|
||||||
private void OnSaveWorld(bool resettime, HandledEventArgs e)
|
private void OnSaveWorld(bool resettime, HandledEventArgs e)
|
||||||
{
|
{
|
||||||
if (!WorldSaving)
|
|
||||||
{
|
|
||||||
WorldSaving = true;
|
|
||||||
Tools.Broadcast("Saving world, might lag.", Color.Red);
|
Tools.Broadcast("Saving world, might lag.", Color.Red);
|
||||||
Thread SaveWorld = new Thread(Tools.SaveWorld);
|
Thread SaveWorld = new Thread(Tools.SaveWorld);
|
||||||
SaveWorld.Start();
|
SaveWorld.Start();
|
||||||
WorldSaving = false;
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Useful stuff:
|
* Useful stuff:
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,6 @@ namespace TShockAPI
|
||||||
WorldGen.RealsaveWorld();
|
WorldGen.RealsaveWorld();
|
||||||
|
|
||||||
Broadcast("World saved.", Color.Yellow);
|
Broadcast("World saved.", Color.Yellow);
|
||||||
Console.WriteLine("World saved.");
|
|
||||||
Log.Info(string.Format("World saved at ({0})", Main.worldPathName));
|
Log.Info(string.Format("World saved at ({0})", Main.worldPathName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue