1
0

Fix missing prev quests

This commit is contained in:
Liza 2024-01-01 03:59:52 +01:00
parent e4c55f7086
commit 97e802f9fb
Signed by: liza
GPG Key ID: 7199F8D727D55F67
2 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets; using Lumina.Excel.GeneratedSheets;
namespace QuestMap { namespace QuestMap {
@ -101,7 +102,8 @@ namespace QuestMap {
} }
} }
internal static (List<Node<Quest>>, Dictionary<uint, Node<Quest>>) BuildTree(Dictionary<uint, Quest> layouts) { internal static (List<Node<Quest>>, Dictionary<uint, Node<Quest>>) BuildTree(Dictionary<uint, Quest> layouts,
IDataManager dataManager) {
var lookup = new Dictionary<uint, Node<Quest>>(); var lookup = new Dictionary<uint, Node<Quest>>();
var rootNodes = new List<Node<Quest>>(); var rootNodes = new List<Node<Quest>>();
var allNodes = new Dictionary<uint, Node<Quest>>(); var allNodes = new Dictionary<uint, Node<Quest>>();
@ -115,7 +117,7 @@ namespace QuestMap {
allNodes[item.Key] = ourNode; allNodes[item.Key] = ourNode;
} }
var previous = item.Value.PreviousQuests().ToList(); var previous = item.Value.PreviousQuests(dataManager).ToList();
if (previous.Count == 0) { if (previous.Count == 0) {
rootNodes.Add(ourNode); rootNodes.Add(ourNode);
} else { } else {
@ -150,12 +152,19 @@ namespace QuestMap {
return null; return null;
} }
internal static IEnumerable<Quest> PreviousQuests(this Quest quest) { internal static IEnumerable<Quest> PreviousQuests(this Quest quest, IDataManager dataManager) {
foreach (var previous in quest.PreviousQuest) { foreach (var previous in quest.PreviousQuest) {
if (previous != null && previous.Row != 0) { if (previous != null && previous.Row != 0) {
yield return previous.Value!; yield return previous.Value!;
} }
} }
if (quest.Unknown12 != 0)
{
var previous = dataManager.GetExcelSheet<Quest>()!.GetRow(quest.Unknown12);
if (previous != null)
yield return previous;
}
} }
} }
} }

View File

@ -112,7 +112,7 @@ namespace QuestMap {
this.BeastRewards = beastRewards; this.BeastRewards = beastRewards;
this.JobRewards = jobRewards; this.JobRewards = jobRewards;
var (_, nodes) = Node<Quest>.BuildTree(allQuests); var (_, nodes) = Node<Quest>.BuildTree(allQuests, this.Plugin.DataManager);
this.AllNodes = nodes; this.AllNodes = nodes;
} }