From a655a07ff95f253ea154df110940ac4383c20797 Mon Sep 17 00:00:00 2001 From: MaikyM <51415805+MaikyM@users.noreply.github.com> Date: Wed, 18 Sep 2019 12:54:56 -0600 Subject: [PATCH] Fixed a bug when extracting rewards that do not exist (encrypted) in challenges. --- .../ChallengeGenerator/BundleDesign.cs | 20 +++++++++++++------ .../ChallengeGenerator/DrawingRewards.cs | 6 +++++- FModel/Methods/JohnWick/JohnWick.cs | 3 +++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/FModel/Methods/IconGenerator/ChallengeGenerator/BundleDesign.cs b/FModel/Methods/IconGenerator/ChallengeGenerator/BundleDesign.cs index 7ef7b6de..7707999f 100644 --- a/FModel/Methods/IconGenerator/ChallengeGenerator/BundleDesign.cs +++ b/FModel/Methods/IconGenerator/ChallengeGenerator/BundleDesign.cs @@ -76,10 +76,14 @@ namespace FModel { isSXBanner = true; string textureFile = Path.GetFileName(assetPathName.Value()).Substring(0, Path.GetFileName(assetPathName.Value()).LastIndexOf('.')); - Image challengeIcon; - using (Bitmap bmpTemp = new Bitmap(JohnWick.AssetToTexture2D(textureFile))) + Image challengeIcon = Resources.unknown512; + string textureAsset = JohnWick.AssetToTexture2D(textureFile);; + if (!string.IsNullOrEmpty(textureAsset)) { - challengeIcon = new Bitmap(bmpTemp); + using (var bmpTemp = new Bitmap(textureAsset)) + { + challengeIcon = new Bitmap(bmpTemp); + } } toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257)); @@ -105,10 +109,14 @@ namespace FModel if (assetPathName != null) { string textureFile = Path.GetFileName(assetPathName.Value()).Substring(0, Path.GetFileName(assetPathName.Value()).LastIndexOf('.')); - Image challengeIcon; - using (var bmpTemp = new Bitmap(JohnWick.AssetToTexture2D(textureFile))) + Image challengeIcon = Resources.unknown512; + string textureAsset = JohnWick.AssetToTexture2D(textureFile); + if (!string.IsNullOrEmpty(textureAsset)) { - challengeIcon = new Bitmap(bmpTemp); + using (var bmpTemp = new Bitmap(textureAsset)) + { + challengeIcon = new Bitmap(bmpTemp); + } } toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257)); diff --git a/FModel/Methods/IconGenerator/ChallengeGenerator/DrawingRewards.cs b/FModel/Methods/IconGenerator/ChallengeGenerator/DrawingRewards.cs index 8f329c2d..4736fe66 100644 --- a/FModel/Methods/IconGenerator/ChallengeGenerator/DrawingRewards.cs +++ b/FModel/Methods/IconGenerator/ChallengeGenerator/DrawingRewards.cs @@ -79,7 +79,11 @@ namespace FModel } } } + else + drawIcon(); } + else + drawIcon(); } /// @@ -144,7 +148,7 @@ namespace FModel private static void drawIcon() { Image itemIcon = null; - if (File.Exists(ItemIcon.ItemIconPath)) + if (!string.IsNullOrEmpty(ItemIcon.ItemIconPath) && File.Exists(ItemIcon.ItemIconPath)) { using (var bmpTemp = new Bitmap(ItemIcon.ItemIconPath)) { diff --git a/FModel/Methods/JohnWick/JohnWick.cs b/FModel/Methods/JohnWick/JohnWick.cs index 1bb8650b..3dd2c96c 100644 --- a/FModel/Methods/JohnWick/JohnWick.cs +++ b/FModel/Methods/JohnWick/JohnWick.cs @@ -72,6 +72,9 @@ namespace FModel /// the path to the png image public static string AssetToTexture2D(string AssetName) { + if (!ThePak.AllpaksDictionary.ContainsKey(AssetName)) + return string.Empty; + string textureFilePath = ExtractAsset(ThePak.AllpaksDictionary[AssetName], AssetName); string TexturePath = string.Empty; if (!string.IsNullOrEmpty(textureFilePath))