From 64885dd6a236df7e179de7112ec4902d76b9cd17 Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 27 May 2025 16:39:37 +0100 Subject: [PATCH] Surrounded call to `AddTaskConditionCountersToProfile` with null check inside `AcceptQuest` --- .../Controllers/QuestController.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs b/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs index 4e75622d..170f9d4a 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs @@ -90,7 +90,14 @@ public class QuestController( // Note that for starting quests, the correct locale field is "description", not "startedMessageText". var questFromDb = _questHelper.GetQuestFromDb(acceptedQuest.QuestId, pmcData); - AddTaskConditionCountersToProfile(questFromDb.Conditions.AvailableForFinish, pmcData, acceptedQuest.QuestId); + if (questFromDb.Conditions?.AvailableForFinish is not null) + { + AddTaskConditionCountersToProfile( + questFromDb.Conditions.AvailableForFinish, + pmcData, + acceptedQuest.QuestId); + } + // Get messageId of text to send to player as text message in game var messageId = _questHelper.GetMessageIdForQuestStart( @@ -136,14 +143,14 @@ public class QuestController( /// Conditions to iterate over and possibly add to profile /// Players PMC profile /// Quest where conditions originated - protected void AddTaskConditionCountersToProfile(List? questConditions, PmcData pmcData, string questId) + protected void AddTaskConditionCountersToProfile(List questConditions, PmcData pmcData, string questId) { foreach (var condition in questConditions) { if (pmcData.TaskConditionCounters.TryGetValue(condition.Id, out var counter)) { _logger.Error( - $"Unable to add new task condition counter: {condition.ConditionType} for quest: {questId} to profile: {pmcData.SessionId} as it already exists:" + $"Unable to add new task condition counter: {condition.ConditionType} for quest: {questId} to profile: {pmcData.SessionId} as it already exists" ); }