From 90cd2087a47d1a65c235fd05cf98027eda24fa37 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 3 Dec 2024 10:05:46 -0500 Subject: [PATCH] fix: Add checks for null when setting prioirty quests Added some checks and logs round prioirty quests to help track down some bugs which cause a NPE to occur. --- .../Handler/QuestSetPriorityQuestHandler.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Arrowgene.Ddon.GameServer/Handler/QuestSetPriorityQuestHandler.cs b/Arrowgene.Ddon.GameServer/Handler/QuestSetPriorityQuestHandler.cs index 2251c2a85..b928ced49 100644 --- a/Arrowgene.Ddon.GameServer/Handler/QuestSetPriorityQuestHandler.cs +++ b/Arrowgene.Ddon.GameServer/Handler/QuestSetPriorityQuestHandler.cs @@ -3,6 +3,7 @@ using Arrowgene.Ddon.Shared.Entity.PacketStructure; using Arrowgene.Ddon.Shared.Network; using Arrowgene.Logging; +using System.Reflection.Metadata.Ecma335; namespace Arrowgene.Ddon.GameServer.Handler { @@ -34,8 +35,26 @@ public override S2CQuestSetPriorityQuestRes Handle(GameClient client, C2SQuestSe } var quest = QuestManager.GetQuestByScheduleId(questScheduleId); + if (quest == null) + { + Logger.Error(client, $"No quest object exists for ${questScheduleId}"); + continue; + } + var questStateManager = QuestManager.GetQuestStateManager(client, quest); + if (questStateManager == null) + { + Logger.Error(client, $"Unable to fetch the quest state manager for ${questScheduleId}"); + continue; + } + var questState = questStateManager.GetQuestState(questScheduleId); + if (questState == null) + { + Logger.Error(client, $"Failed to find quest state for ${questScheduleId}"); + continue; + } + ntc.PriorityQuestList.Add(quest.ToCDataPriorityQuest(questState.Step)); }