From 58ee16bee7f9d3ef57ba929057d1b846ddc77b9f Mon Sep 17 00:00:00 2001 From: Tyfon <29051038+tyfon7@users.noreply.github.com> Date: Thu, 3 Oct 2024 10:58:56 -0700 Subject: [PATCH] try/catch trader autoswitch --- src/Patches/TradingAutoSwitchPatches.cs | 34 +++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Patches/TradingAutoSwitchPatches.cs b/src/Patches/TradingAutoSwitchPatches.cs index c840046..e89aba9 100644 --- a/src/Patches/TradingAutoSwitchPatches.cs +++ b/src/Patches/TradingAutoSwitchPatches.cs @@ -3,6 +3,7 @@ using EFT.UI; using EFT.UI.DragAndDrop; using HarmonyLib; using SPT.Reflection.Patching; +using System; using System.Reflection; using UnityEngine; using UnityEngine.EventSystems; @@ -83,24 +84,31 @@ public static class TradingAutoSwitchPatches return true; } - if (!___bool_8 && ctrlPressed && assortmentController.QuickFindTradingAppropriatePlace(__instance.Item, null)) + try { - __instance.ItemContext?.CloseDependentWindows(); - __instance.HideTooltip(); - Singleton.Instance.PlayItemSound(__instance.Item.ItemSound, EInventorySoundType.pickup, false); + if (!___bool_8 && ctrlPressed && assortmentController.QuickFindTradingAppropriatePlace(__instance.Item, null)) + { + __instance.ItemContext?.CloseDependentWindows(); + __instance.HideTooltip(); + Singleton.Instance.PlayItemSound(__instance.Item.ItemSound, EInventorySoundType.pickup, false); - SellTab.OnPointerClick(null); + SellTab.OnPointerClick(null); - return false; + return false; + } + + if (___bool_8) + { + assortmentController.SelectItem(__instance.Item); + + BuyTab.OnPointerClick(null); + + return false; + } } - - if (___bool_8) + catch (Exception e) { - assortmentController.SelectItem(__instance.Item); - - BuyTab.OnPointerClick(null); - - return false; + Logger.LogError(e); } return true;