Added unhandled exception logging. Also if server crashes from an unhandled exception it will save the world with .crash appended.

This commit is contained in:
high 2011-06-05 15:15:37 -04:00
parent 73b3def96f
commit 683d45f00c

View file

@ -126,14 +126,26 @@ namespace TShockAPI
NetHooks.OnGreetPlayer += new NetHooks.GreetPlayerD(OnGreetPlayer);
NpcHooks.OnStrikeNpc += new NpcHooks.StrikeNpcD(NpcHooks_OnStrikeNpc);
ServerHooks.OnCommand += new ServerHooks.CommandD(ServerHooks_OnCommand);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Log.Info("Hooks initialized");
Commands.InitCommands();
Log.Info("Commands initialized");
}
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (Main.worldPathName != null)
{
Main.worldPathName += ".crash";
WorldGen.saveWorld();
}
Log.Error(e.ExceptionObject.ToString());
}
void ServerHooks_OnCommand(string cmd, HandledEventArgs e)
{
}
public override void DeInitialize()
@ -762,6 +774,7 @@ namespace TShockAPI
{
public float X;
public float Y;
public Position(float x, float y) { X = x; Y = y; }
}