Skip to content

Commit

Permalink
[merge]
Browse files Browse the repository at this point in the history
  • Loading branch information
yretenai committed Oct 14, 2020
2 parents 61c682d + a5e19a6 commit 0336368
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions DataTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using TACTLib.Client.HandlerArgs;
using TACTLib.Core.Product.Tank;
using TACTLib.Exceptions;
using TankLib.Helpers;
using static DataTool.Helper.Logger;
using static DataTool.Helper.STUHelper;
using Logger = TankLib.Helpers.Logger;
Expand Down Expand Up @@ -136,12 +135,12 @@ private static void Main() {

if (!targetToolAttributes.UtilNoArchiveNeeded) {
try {
InitStorage(Flags.Online);
InitStorage();
} catch (Exception ex) {
Logger.Log24Bit(ConsoleSwatch.XTermColor.OrangeRed, true, Console.Error, "CASC",
"=================\nError initializing CASC!\n" +
"Please Scan & Repair your game, launch it for a minute, and try the tools again before reporting a bug!\n" +
"========================");
Logger.Error("CASC",
"=================\nError initializing CASC!\n" +
"Please Scan & Repair your game, launch it for a minute, and try the tools again before reporting a bug!\n" +
"========================");
throw;
}

Expand Down Expand Up @@ -222,7 +221,7 @@ public static void InitStorage(bool online = false) { // turnin offline off agai
var args = new ClientCreateArgs {
SpeechLanguage = Flags.SpeechLanguage,
TextLanguage = Flags.Language,
HandlerArgs = new ClientCreateArgs_Tank { CacheAPM = Flags.UseCache, ManifestRegion = Flags.RCN ? ProductHandler_Tank.REGION_CN : ProductHandler_Tank.REGION_DEV },
HandlerArgs = new ClientCreateArgs_Tank { CacheAPM = Flags.UseCache },
Online = online
};

Expand Down Expand Up @@ -307,27 +306,13 @@ private static void TryFetchLocaleFromRegistry() {
}
}

private static void HandleSingleException(Exception ex) {
if (ex is TargetInvocationException fex) {
ex = fex.InnerException ?? ex;
}

Logger.Log24Bit(ConsoleSwatch.XTermColor.HotPink3, true, Console.Error, null, ex.Message);
Logger.Log24Bit(ConsoleSwatch.XTermColor.MediumPurple, true, Console.Error, null, ex.StackTrace);

if (ex is BLTEDecoderException decoder) {
File.WriteAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"BLTEDump-{AppDomain.CurrentDomain.FriendlyName}_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}.blte"), decoder.GetBLTEData());
}

if (ex.InnerException != null) {
HandleSingleException(ex.InnerException);
}
}

[DebuggerStepThrough]
private static void ExceptionHandler(object sender, UnhandledExceptionEventArgs e) {
if (e.ExceptionObject is Exception ex) {
HandleSingleException(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;
}
Expand Down

0 comments on commit 0336368

Please sign in to comment.