diff --git a/Libraries/SPTarkov.Server.Core/Helpers/DialogueHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/DialogueHelper.cs index fe201c08..cdcc18d3 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/DialogueHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/DialogueHelper.cs @@ -109,21 +109,21 @@ public class DialogueHelper( return profile.DialogueRecords ?? (profile.DialogueRecords = new Dictionary()); } + /// + /// Find and return a profiles dialogue by id + /// + /// Profile to look in + /// Dialog to return + /// Dialogue public Models.Eft.Profile.Dialogue? GetDialogueFromProfile(string profileId, string dialogueId) { - Models.Eft.Profile.Dialogue? returnDialogue = null; var dialogues = GetDialogsForProfile(profileId); - - foreach (var dialogue in dialogues.Values) + if (dialogues.TryGetValue(dialogueId, out var dialogue)) { - if (dialogue.Id == dialogueId) - { - returnDialogue = dialogue; - } - - break; + return dialogue; } - return returnDialogue; + _logger.Error($"Unable to find a dialogue with id: {dialogueId} in profile: {profileId}"); + return null; } }