Skip to content

Commit

Permalink
Merge pull request #139 from OkaMoez/midQuest/nullCheck
Browse files Browse the repository at this point in the history
Fix MidRaidQuestChangePatch null check and improve logging
  • Loading branch information
paulov-t authored Feb 5, 2024
2 parents 4a6963f + d9e6c36 commit f87a5bc
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,28 @@ protected override MethodBase GetTargetMethod()
[PatchPostfix]
private static void PatchPostfix()
{
Logger.LogDebug($"[MidRaidQuestChangePatch] PatchPostfix");
var gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld != null)
if (gameWorld == null)
{
Logger.LogError($"[MidRaidQuestChangePatch] gameWorld instance was null");

return;
}

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);
}
}
}
Expand Down

0 comments on commit f87a5bc

Please sign in to comment.