From 22ff9f527387acd6d3e703a1cfe623c4e356fb28 Mon Sep 17 00:00:00 2001 From: Anthony Purchase Date: Mon, 22 Jan 2018 12:29:39 +0000 Subject: [PATCH] Protection against bad conversion output Added a little more relisience to the conversion process. --- LarkatorGUI/ArkReader.cs | 14 +++++++++++--- LarkatorGUI/MainWindow.xaml.cs | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/LarkatorGUI/ArkReader.cs b/LarkatorGUI/ArkReader.cs index f74c548..6cce9c8 100644 --- a/LarkatorGUI/ArkReader.cs +++ b/LarkatorGUI/ArkReader.cs @@ -43,7 +43,6 @@ public async Task PerformConversion(bool force = false) if (force || IsConversionRequired()) { await RunArkTools(); - ClassMapping.Clear(); } if (ClassMapping.Count == 0) @@ -76,8 +75,14 @@ private async Task RunArkTools() } executing = true; - await ExecuteArkTools(Tamed ? "tamed" : "wild", Properties.Settings.Default.SaveFile, outputDir); - executing = false; + try + { + await ExecuteArkTools(Tamed ? "tamed" : "wild", Properties.Settings.Default.SaveFile, outputDir); + } + finally + { + executing = false; + } // Clear previously loaded data ClassMapping.Clear(); @@ -110,6 +115,9 @@ private async Task LoadClassesJson() .Select(mapping => new { Cls = mapping["cls"].Value(), Name = mapping["name"].Value() }) .Where(m => !m.Cls.Contains("BP_Ocean_C")) .ToDictionary(m => m.Name, m => m.Cls); + + if (ClassMapping.Count <= 0) + throw new ExternalToolsException("ARK Tools produced no classes output"); } private async Task LoadSpecies(string speciesName) diff --git a/LarkatorGUI/MainWindow.xaml.cs b/LarkatorGUI/MainWindow.xaml.cs index 7b36b3e..dd955eb 100644 --- a/LarkatorGUI/MainWindow.xaml.cs +++ b/LarkatorGUI/MainWindow.xaml.cs @@ -378,6 +378,8 @@ private async Task UpdateArkToolsData() private async Task ReReadArk(bool force = false) { + if (IsLoading) return; + await PerformConversion(force); await LoadSearchSpecies();