From d9e6c36f6d027023f458417786c35e5628cb1ed5 Mon Sep 17 00:00:00 2001 From: OkaMoez <43766412+OkaMoez@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:38:57 -0800 Subject: [PATCH] Fix null check and improve logging --- .../Progression/MidRaidQuestChangePatch.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Source/AkiSupport/Singleplayer/Patches/Progression/MidRaidQuestChangePatch.cs b/Source/AkiSupport/Singleplayer/Patches/Progression/MidRaidQuestChangePatch.cs index 1a81ad88..fa24bf0b 100644 --- a/Source/AkiSupport/Singleplayer/Patches/Progression/MidRaidQuestChangePatch.cs +++ b/Source/AkiSupport/Singleplayer/Patches/Progression/MidRaidQuestChangePatch.cs @@ -25,8 +25,9 @@ protected override MethodBase GetTargetMethod() [PatchPostfix] private static void PatchPostfix() { + Logger.LogDebug($"[MidRaidQuestChangePatch] PatchPostfix"); var gameWorld = Singleton.Instance; - if (gameWorld != null) + if (gameWorld == null) { Logger.LogError($"[MidRaidQuestChangePatch] gameWorld instance was null"); @@ -34,15 +35,18 @@ private static void PatchPostfix() } var player = gameWorld.MainPlayer; - Logger.LogDebug($"[MidRaidQuestChangePatch] PatchPostfix"); var questController = (QuestController)ReflectionHelpers.GetFieldFromType(player.GetType(), "_questController").GetValue(player); - if (questController != null) + if (questController == null) + { + Logger.LogError($"[MidRaidQuestChangePatch] questController instance was null"); + + return; + } + + foreach (var quest in questController.Quests.ToList()) { - foreach (var quest in questController.Quests.ToList()) - { - quest.CheckForStatusChange(true, true); - } + quest.CheckForStatusChange(true, true); } } }