From 67c1df84153d43c5b454249b920b40888a841566 Mon Sep 17 00:00:00 2001
From: Chomp <jr@spt.com>
Date: Mon, 21 Aug 2023 13:41:30 +0100
Subject: [PATCH] Fix bad reward ids

---
 GenerateQuestFile/Program.cs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/GenerateQuestFile/Program.cs b/GenerateQuestFile/Program.cs
index d08e0ef..1027872 100644
--- a/GenerateQuestFile/Program.cs
+++ b/GenerateQuestFile/Program.cs
@@ -4,6 +4,7 @@ using QuestValidator.Common.Helpers;
 using QuestValidator.Common.Models;
 using QuestValidator.Helpers;
 using QuestValidator.Models;
+using QuestValidator.Models.Output;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -348,6 +349,12 @@ namespace GenerateQuestFile
                         item._id = originalItem._id;
                         item.parentId = originalItem.parentId;
                     }
+
+                    // Above changes can cause the target and first items id to become mismatched
+                    if (reward.items.FirstOrDefault()._id != reward.target)
+                    {
+                        reward.target = reward.items.FirstOrDefault()._id;
+                    }
                 }
             }
         }