From 067bb41820d24175fcfa22ac0c3d128589478668 Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Thu, 11 May 2023 11:27:54 +0100 Subject: [PATCH] Bugfix Stack Overflow on Adding Reward Items --- Source/the_twilight_abyss/Quest/QuestSystem.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/the_twilight_abyss/Quest/QuestSystem.cpp b/Source/the_twilight_abyss/Quest/QuestSystem.cpp index cf23d06..216d284 100644 --- a/Source/the_twilight_abyss/Quest/QuestSystem.cpp +++ b/Source/the_twilight_abyss/Quest/QuestSystem.cpp @@ -54,12 +54,13 @@ void UQuestSystem::TickComponent(float DeltaTime, ELevelTick TickType, FActorCom void UQuestSystem::CheckActiveQuestConditions() { + TArray JustCompletedQuests; for (UQuest* Quest : ActiveQuests) { if (Quest->CheckConditions(GetWorldState())) { CompletedQuests.Add(Quest); - Quest->ApplyRewards(PlayerInventory); + JustCompletedQuests.Add(Quest); for (TTuple QuestFlag : Quest->QuestFlagsOnComplete) { QuestFlags.Add(QuestFlag.Key, QuestFlag.Value); @@ -79,6 +80,11 @@ void UQuestSystem::CheckActiveQuestConditions() } UpdateQuestGoalsUI(Quest); } + for (UQuest* Quest : JustCompletedQuests) + { + ActiveQuests.Remove(Quest); + Quest->ApplyRewards(PlayerInventory); + } } UWorldState* UQuestSystem::GetWorldState() const