From 39e1472afc8e489529ddc2d0f86529b831a7fceb Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 26 Jan 2025 20:28:54 +0000 Subject: [PATCH] more dictionary safety --- Libraries/Core/Services/MailSendService.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Libraries/Core/Services/MailSendService.cs b/Libraries/Core/Services/MailSendService.cs index 46f6230a..4f8d8d91 100644 --- a/Libraries/Core/Services/MailSendService.cs +++ b/Libraries/Core/Services/MailSendService.cs @@ -301,8 +301,7 @@ public class MailSendService( // TODO: clean up old code here // Offer Sold notifications are now separate from the main notification - if ( - _messageTypes.Contains(senderDialog.Type ?? MessageType.SYSTEM_MESSAGE) && + if (_messageTypes.Contains(senderDialog.Type ?? MessageType.SYSTEM_MESSAGE) && messageDetails?.RagfairDetails is not null ) { @@ -322,8 +321,8 @@ public class MailSendService( public void SendPlayerMessageToNpc(string sessionId, string targetNpcId, string message) { var playerProfile = _saveServer.GetProfile(sessionId); - var dialogWithNpc = playerProfile.DialogueRecords[targetNpcId]; - if (dialogWithNpc is null) + if (playerProfile.DialogueRecords != null || + !playerProfile.DialogueRecords.TryGetValue(targetNpcId, out var dialogWithNpc)) { _logger.Error(_localisationService.GetText("mailsend-missing_npc_dialog", targetNpcId)); return;