From c23d6a02d4349fd9aa39f5d8aa4b621fe237a2f8 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Mon, 18 Aug 2025 16:37:35 +0200 Subject: [PATCH] Clean up --- Questionable/Controller/CommandHandler.cs | 2 +- Questionable/Controller/Steps/Gathering/DoGather.cs | 1 - Questionable/Controller/Steps/Shared/Gather.cs | 2 +- Questionable/Controller/Steps/TaskCreator.cs | 1 - Questionable/Functions/AetheryteFunctions.cs | 11 +++++++++-- Questionable/Functions/QuestFunctions.cs | 5 +++-- .../Validation/Validators/BasicSequenceValidator.cs | 2 +- .../Validation/Validators/CompletionFlagsValidator.cs | 2 +- .../Validation/Validators/DialogueChoiceValidator.cs | 4 ++-- .../Validation/Validators/NextQuestValidator.cs | 2 +- Questionable/Validation/Validators/SayValidator.cs | 2 +- .../Validators/UniqueSinglePlayerInstanceValidator.cs | 2 +- .../Validation/Validators/UniqueStartStopValidator.cs | 4 ++-- .../Windows/QuestComponents/ActiveQuestComponent.cs | 4 ++-- 14 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Questionable/Controller/CommandHandler.cs b/Questionable/Controller/CommandHandler.cs index 391e727a..7eb7e5f4 100644 --- a/Questionable/Controller/CommandHandler.cs +++ b/Questionable/Controller/CommandHandler.cs @@ -307,7 +307,7 @@ internal sealed class CommandHandler : IDisposable QuestSequence? sequence = quest.FindSequence(parsedSequence); if (sequence != null) { - sequenceId = (byte)sequence.Sequence; + sequenceId = sequence.Sequence; if (arguments.Length >= 3 && int.TryParse(arguments[2], out int parsedStep)) { QuestStep? step = sequence.FindStep(parsedStep); diff --git a/Questionable/Controller/Steps/Gathering/DoGather.cs b/Questionable/Controller/Steps/Gathering/DoGather.cs index c7636f6d..d1e4c05d 100644 --- a/Questionable/Controller/Steps/Gathering/DoGather.cs +++ b/Questionable/Controller/Steps/Gathering/DoGather.cs @@ -133,7 +133,6 @@ internal static class DoGather private unsafe List ReadSlots(AddonGathering* addonGathering) { - var atkValues = addonGathering->AtkValues; List slots = new List(); for (int i = 0; i < 8; ++i) { diff --git a/Questionable/Controller/Steps/Shared/Gather.cs b/Questionable/Controller/Steps/Shared/Gather.cs index 04f0be3d..e9082796 100644 --- a/Questionable/Controller/Steps/Shared/Gather.cs +++ b/Questionable/Controller/Steps/Shared/Gather.cs @@ -28,7 +28,7 @@ internal static class Gather foreach (var itemToGather in step.ItemsToGather) { - yield return new DelayedGatheringTask(itemToGather, quest, (byte)sequence.Sequence); + yield return new DelayedGatheringTask(itemToGather, quest, sequence.Sequence); } } } diff --git a/Questionable/Controller/Steps/TaskCreator.cs b/Questionable/Controller/Steps/TaskCreator.cs index 9df249a3..c70b7be9 100644 --- a/Questionable/Controller/Steps/TaskCreator.cs +++ b/Questionable/Controller/Steps/TaskCreator.cs @@ -4,7 +4,6 @@ using System.Linq; using Dalamud.Plugin.Services; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Questionable.Controller.Steps.Common; using Questionable.Controller.Steps.Interactions; using Questionable.Controller.Steps.Shared; using Questionable.Data; diff --git a/Questionable/Functions/AetheryteFunctions.cs b/Questionable/Functions/AetheryteFunctions.cs index 14f011a6..6852f6fe 100644 --- a/Questionable/Functions/AetheryteFunctions.cs +++ b/Questionable/Functions/AetheryteFunctions.cs @@ -94,6 +94,14 @@ internal sealed unsafe class AetheryteFunctions public bool TeleportAetheryte(EAetheryteLocation aetheryteLocation) => TeleportAetheryte((uint)aetheryteLocation); + public bool IsFreeAetheryte(EAetheryteLocation aetheryteLocation) + { + var playerState = PlayerState.Instance(); + return playerState != null && + (playerState->FreeAetheryteId == (uint)aetheryteLocation || + playerState->FreeAetherytePlayStationPlus == (uint)aetheryteLocation); + } + public AetheryteRegistrationResult CanRegisterFreeOrFavoriteAetheryte(EAetheryteLocation aetheryteLocation) { if (_clientState.LocalPlayer == null) @@ -105,8 +113,7 @@ internal sealed unsafe class AetheryteFunctions // if we have a free or favored aetheryte assigned to this location, we don't override it (and don't upgrade // favored to free, either). - if (playerState->FreeAetheryteId == (uint)aetheryteLocation || - playerState->FreeAetherytePlayStationPlus == (uint)aetheryteLocation) + if (IsFreeAetheryte(aetheryteLocation)) return AetheryteRegistrationResult.NotPossible; bool freeFavoredSlotsAvailable = false; diff --git a/Questionable/Functions/QuestFunctions.cs b/Questionable/Functions/QuestFunctions.cs index ded8287e..dede0335 100644 --- a/Questionable/Functions/QuestFunctions.cs +++ b/Questionable/Functions/QuestFunctions.cs @@ -445,10 +445,11 @@ internal sealed unsafe class QuestFunctions private int EstimateTeleportCosts(Quest quest) { - Dictionary cheapTeleports = _aetheryteList.Where(x => x.IsFavourite || x.GilCost == 0) + // TODO (probably in 7.4): clientstructs' aetheryte list has an 'IsFreeAetheryte' field, dalamud doesn't + Dictionary cheapTeleports = _aetheryteList.Where(x => x.IsFavourite || _aetheryteFunctions.IsFreeAetheryte((EAetheryteLocation)x.AetheryteId)) .ToDictionary(x => (EAetheryteLocation)x.AetheryteId, x => { - if (x.GilCost == 0) + if (_aetheryteFunctions.IsFreeAetheryte((EAetheryteLocation)x.AetheryteId)) return 0; else return 0.5f; diff --git a/Questionable/Validation/Validators/BasicSequenceValidator.cs b/Questionable/Validation/Validators/BasicSequenceValidator.cs index 0c2bee27..7fd4af8c 100644 --- a/Questionable/Validation/Validators/BasicSequenceValidator.cs +++ b/Questionable/Validation/Validators/BasicSequenceValidator.cs @@ -38,7 +38,7 @@ internal sealed class BasicSequenceValidator : IQuestValidator yield return new ValidationIssue { ElementId = quest.Id, - Sequence = (byte)sequence.Sequence, + Sequence = sequence.Sequence, Step = null, Type = EIssueType.InstantQuestWithMultipleSteps, Severity = EIssueSeverity.Error, diff --git a/Questionable/Validation/Validators/CompletionFlagsValidator.cs b/Questionable/Validation/Validators/CompletionFlagsValidator.cs index dc36bcc1..5da7fb00 100644 --- a/Questionable/Validation/Validators/CompletionFlagsValidator.cs +++ b/Questionable/Validation/Validators/CompletionFlagsValidator.cs @@ -50,7 +50,7 @@ internal sealed class CompletionFlagsValidator : IQuestValidator yield return new ValidationIssue { ElementId = quest.Id, - Sequence = (byte)sequence.Sequence, + Sequence = sequence.Sequence, Step = i, Type = EIssueType.DuplicateCompletionFlags, Severity = EIssueSeverity.Error, diff --git a/Questionable/Validation/Validators/DialogueChoiceValidator.cs b/Questionable/Validation/Validators/DialogueChoiceValidator.cs index ee6d6f5b..a9215484 100644 --- a/Questionable/Validation/Validators/DialogueChoiceValidator.cs +++ b/Questionable/Validation/Validators/DialogueChoiceValidator.cs @@ -54,7 +54,7 @@ internal sealed class DialogueChoiceValidator : IQuestValidator return new ValidationIssue { ElementId = quest.Id, - Sequence = (byte)sequence.Sequence, + Sequence = sequence.Sequence, Step = stepId, Type = EIssueType.InvalidExcelRef, Severity = EIssueSeverity.Error, @@ -69,7 +69,7 @@ internal sealed class DialogueChoiceValidator : IQuestValidator return new ValidationIssue { ElementId = quest.Id, - Sequence = (byte)sequence.Sequence, + Sequence = sequence.Sequence, Step = stepId, Type = EIssueType.InvalidExcelRef, Severity = EIssueSeverity.Error, diff --git a/Questionable/Validation/Validators/NextQuestValidator.cs b/Questionable/Validation/Validators/NextQuestValidator.cs index d08bea61..22981e86 100644 --- a/Questionable/Validation/Validators/NextQuestValidator.cs +++ b/Questionable/Validation/Validators/NextQuestValidator.cs @@ -13,7 +13,7 @@ internal sealed class NextQuestValidator : IQuestValidator yield return new ValidationIssue { ElementId = quest.Id, - Sequence = (byte)invalidNextQuest.Sequence.Sequence, + Sequence = invalidNextQuest.Sequence.Sequence, Step = invalidNextQuest.StepId, Type = EIssueType.InvalidNextQuestId, Severity = EIssueSeverity.Error, diff --git a/Questionable/Validation/Validators/SayValidator.cs b/Questionable/Validation/Validators/SayValidator.cs index 94254889..7a0b59f3 100644 --- a/Questionable/Validation/Validators/SayValidator.cs +++ b/Questionable/Validation/Validators/SayValidator.cs @@ -34,7 +34,7 @@ internal sealed class SayValidator : IQuestValidator yield return new ValidationIssue { ElementId = quest.Id, - Sequence = (byte)data.Sequence.Sequence, + Sequence = data.Sequence.Sequence, Step = data.StepId, Type = EIssueType.InvalidChatMessage, Severity = EIssueSeverity.Error, diff --git a/Questionable/Validation/Validators/UniqueSinglePlayerInstanceValidator.cs b/Questionable/Validation/Validators/UniqueSinglePlayerInstanceValidator.cs index 684e876b..eeb8c136 100644 --- a/Questionable/Validation/Validators/UniqueSinglePlayerInstanceValidator.cs +++ b/Questionable/Validation/Validators/UniqueSinglePlayerInstanceValidator.cs @@ -20,7 +20,7 @@ internal sealed class UniqueSinglePlayerInstanceValidator : IQuestValidator yield return new ValidationIssue { ElementId = quest.Id, - Sequence = (byte)singlePlayerInstance.Sequence.Sequence, + Sequence = singlePlayerInstance.Sequence.Sequence, Step = singlePlayerInstance.StepId, Type = EIssueType.DuplicateSinglePlayerInstance, Severity = EIssueSeverity.Error, diff --git a/Questionable/Validation/Validators/UniqueStartStopValidator.cs b/Questionable/Validation/Validators/UniqueStartStopValidator.cs index ed3e0083..3ecd36f0 100644 --- a/Questionable/Validation/Validators/UniqueStartStopValidator.cs +++ b/Questionable/Validation/Validators/UniqueStartStopValidator.cs @@ -23,7 +23,7 @@ internal sealed class UniqueStartStopValidator : IQuestValidator yield return new ValidationIssue { ElementId = quest.Id, - Sequence = (byte)accept.Sequence.Sequence, + Sequence = accept.Sequence.Sequence, Step = accept.StepId, Type = EIssueType.UnexpectedAcceptQuestStep, Severity = EIssueSeverity.Error, @@ -56,7 +56,7 @@ internal sealed class UniqueStartStopValidator : IQuestValidator yield return new ValidationIssue { ElementId = quest.Id, - Sequence = (byte)complete.Sequence.Sequence, + Sequence = complete.Sequence.Sequence, Step = complete.StepId, Type = EIssueType.UnexpectedCompleteQuestStep, Severity = EIssueSeverity.Error, diff --git a/Questionable/Windows/QuestComponents/ActiveQuestComponent.cs b/Questionable/Windows/QuestComponents/ActiveQuestComponent.cs index d9b156ad..64ce9678 100644 --- a/Questionable/Windows/QuestComponents/ActiveQuestComponent.cs +++ b/Questionable/Windows/QuestComponents/ActiveQuestComponent.cs @@ -401,7 +401,7 @@ internal sealed partial class ActiveQuestComponent byte oldSequence = simulatedQuest.Sequence; byte newSequence = simulatedQuest.Quest.Root.QuestSequence - .Select(x => (byte)x.Sequence) + .Select(x => x.Sequence) .LastOrDefault(x => x < oldSequence, byte.MinValue); _questController.SimulatedQuest.SetSequence(newSequence); @@ -418,7 +418,7 @@ internal sealed partial class ActiveQuestComponent byte oldSequence = simulatedQuest.Sequence; byte newSequence = simulatedQuest.Quest.Root.QuestSequence - .Select(x => (byte)x.Sequence) + .Select(x => x.Sequence) .FirstOrDefault(x => x > oldSequence, byte.MaxValue); simulatedQuest.SetSequence(newSequence); -- 2.20.1