Skip to content

Commit

Permalink
[datatool] dump blte if blte crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
yretenai committed Sep 19, 2020
1 parent f123967 commit a5e19a6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CASCEncDump/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using TACTLib.Container;
using TACTLib.Core;
using TACTLib.Core.Product.Tank;
using TACTLib.Exceptions;

namespace CASCEncDump {
internal class Program {
Expand Down
1 change: 1 addition & 0 deletions DataTool/Helper/IO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Text.RegularExpressions;
using TankLib;
using TACTLib.Core;
using TACTLib.Exceptions;
using static DataTool.Program;

namespace DataTool.Helper {
Expand Down
7 changes: 6 additions & 1 deletion DataTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using TACTLib.Client;
using TACTLib.Client.HandlerArgs;
using TACTLib.Core.Product.Tank;
using TACTLib.Exceptions;
using static DataTool.Helper.Logger;
using static DataTool.Helper.STUHelper;
using Logger = TankLib.Helpers.Logger;
Expand Down Expand Up @@ -309,11 +310,15 @@ private static void TryFetchLocaleFromRegistry() {
private static void ExceptionHandler(object sender, UnhandledExceptionEventArgs e) {
if (e.ExceptionObject is Exception ex) {
Logger.Error(null, ex.ToString());
if (ex is BLTEDecoderException decoder) {
File.WriteAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"BLTEDump-{AppDomain.CurrentDomain.FriendlyName}_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}.blte"), decoder.GetBLTEData());
}

if (Debugger.IsAttached) throw ex;
}

unchecked {
Environment.Exit((int) 0xDEADBEEF);
Environment.Exit(-1);
}
}

Expand Down

0 comments on commit a5e19a6

Please sign in to comment.