From 0c4272c0308f9795708171555220be57eda00dbf Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Wed, 7 Sep 2022 13:18:11 -0700 Subject: [PATCH] Fix quest dialog crash when requesting NPC id is missing --- EndlessClient/Dialogs/QuestDialog.cs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/EndlessClient/Dialogs/QuestDialog.cs b/EndlessClient/Dialogs/QuestDialog.cs index 96dd0b6f5..0b0b489d4 100644 --- a/EndlessClient/Dialogs/QuestDialog.cs +++ b/EndlessClient/Dialogs/QuestDialog.cs @@ -86,15 +86,22 @@ private void UpdateDialogControls(QuestDialogData repoData) private void UpdateTitle(QuestDialogData repoData) { - var npcName = _enfFileProvider.ENFFile[_questDataProvider.RequestedNPC.ID].Name; - var titleText = npcName; - if (!repoData.DialogTitles.ContainsKey(repoData.VendorID) && repoData.DialogTitles.Count == 1) - titleText += $" - {repoData.DialogTitles.Single().Value}"; - else if (repoData.DialogTitles.ContainsKey(repoData.VendorID)) - titleText += $" - {repoData.DialogTitles[repoData.VendorID]}"; - - _titleText.Text = titleText; - _titleText.ResizeBasedOnText(); + if (_questDataProvider.RequestedNPC != null) + { + var npcName = _enfFileProvider.ENFFile[_questDataProvider.RequestedNPC.ID].Name; + var titleText = npcName; + if (!repoData.DialogTitles.ContainsKey(repoData.VendorID) && repoData.DialogTitles.Count == 1) + titleText += $" - {repoData.DialogTitles.Single().Value}"; + else if (repoData.DialogTitles.ContainsKey(repoData.VendorID)) + titleText += $" - {repoData.DialogTitles[repoData.VendorID]}"; + + _titleText.Text = titleText; + _titleText.ResizeBasedOnText(); + } + else + { + _titleText.Text = string.Empty; + } } private void UpdateDialogDisplayText(QuestDialogData repoData)