From c9d9cfb7872f31beb4d9b4c781604be7a3b6bdde Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Thu, 8 Aug 2024 23:58:29 +0200 Subject: [PATCH] Only auto-accept leves --- Questionable/Controller/GameUiController.cs | 2 +- Questionable/Data/LeveData.cs | 7 +++++-- .../Validators/UniqueStartStopValidator.cs | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Questionable/Controller/GameUiController.cs b/Questionable/Controller/GameUiController.cs index 8e92e2310..829953c1e 100644 --- a/Questionable/Controller/GameUiController.cs +++ b/Questionable/Controller/GameUiController.cs @@ -784,7 +784,7 @@ internal sealed class GameUiController : IDisposable AddonJournalResult* addon = (AddonJournalResult*)args.Addon; string questName = addon->AtkTextNode250->NodeText.ToString(); - if (_questController.CurrentQuest != null && + if (_questController.CurrentQuest is { Quest.Id: LeveId } && GameFunctions.GameStringEquals(_questController.CurrentQuest.Quest.Info.Name, questName)) addon->FireCallbackInt(0); else diff --git a/Questionable/Data/LeveData.cs b/Questionable/Data/LeveData.cs index 463f7c439..a8d5835ca 100644 --- a/Questionable/Data/LeveData.cs +++ b/Questionable/Data/LeveData.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using FFXIVClientStructs.FFXIV.Common.Math; using LLib.GameData; @@ -24,7 +25,9 @@ internal sealed class LeveData public void AddQuestSteps(LeveInfo leveInfo, QuestRoot questRoot) { - LeveStepData leveStepData = Leves.Single(x => x.IssuerDataId == leveInfo.IssuerDataId); + LeveStepData leveStepData = Leves.SingleOrDefault(x => x.IssuerDataId == leveInfo.IssuerDataId) + ?? throw new InvalidOperationException( + $"No leve location for issuer data id {leveInfo.IssuerDataId} found"); QuestSequence? startSequence = questRoot.QuestSequence.FirstOrDefault(x => x.Sequence == 0); if (startSequence == null) diff --git a/Questionable/Validation/Validators/UniqueStartStopValidator.cs b/Questionable/Validation/Validators/UniqueStartStopValidator.cs index 60f67b12d..b7e088133 100644 --- a/Questionable/Validation/Validators/UniqueStartStopValidator.cs +++ b/Questionable/Validation/Validators/UniqueStartStopValidator.cs @@ -12,9 +12,10 @@ internal sealed class UniqueStartStopValidator : IQuestValidator if (quest.Id is SatisfactionSupplyNpcId) yield break; - var questAccepts = FindQuestStepsWithInteractionType(quest, EInteractionType.AcceptQuest) - .Where(x => x.Step.PickUpQuestId == null) - .ToList(); + var questAccepts = + FindQuestStepsWithInteractionType(quest, [EInteractionType.AcceptQuest, EInteractionType.AcceptLeve]) + .Where(x => x.Step.PickUpQuestId == null) + .ToList(); foreach (var accept in questAccepts) { if (accept.Sequence.Sequence != 0 || accept.StepId != quest.FindSequence(0)!.Steps.Count - 1) @@ -44,9 +45,10 @@ internal sealed class UniqueStartStopValidator : IQuestValidator }; } - var questCompletes = FindQuestStepsWithInteractionType(quest, EInteractionType.CompleteQuest) - .Where(x => x.Step.TurnInQuestId == null) - .ToList(); + var questCompletes = + FindQuestStepsWithInteractionType(quest, [EInteractionType.CompleteQuest, EInteractionType.CompleteLeve]) + .Where(x => x.Step.TurnInQuestId == null) + .ToList(); foreach (var complete in questCompletes) { if (complete.Sequence.Sequence != 255 || complete.StepId != quest.FindSequence(255)!.Steps.Count - 1) @@ -78,6 +80,6 @@ internal sealed class UniqueStartStopValidator : IQuestValidator } private static IEnumerable<(QuestSequence Sequence, int StepId, QuestStep Step)> FindQuestStepsWithInteractionType( - Quest quest, EInteractionType interactionType) - => quest.AllSteps().Where(x => x.Step.InteractionType == interactionType); + Quest quest, List interactionType) + => quest.AllSteps().Where(x => interactionType.Contains(x.Step.InteractionType)); }