Clean up
authorLiza Carvelli <liza@carvel.li>
Mon, 18 Aug 2025 14:37:35 +0000 (16:37 +0200)
committerLiza Carvelli <liza@carvel.li>
Mon, 18 Aug 2025 16:53:32 +0000 (18:53 +0200)
14 files changed:
Questionable/Controller/CommandHandler.cs
Questionable/Controller/Steps/Gathering/DoGather.cs
Questionable/Controller/Steps/Shared/Gather.cs
Questionable/Controller/Steps/TaskCreator.cs
Questionable/Functions/AetheryteFunctions.cs
Questionable/Functions/QuestFunctions.cs
Questionable/Validation/Validators/BasicSequenceValidator.cs
Questionable/Validation/Validators/CompletionFlagsValidator.cs
Questionable/Validation/Validators/DialogueChoiceValidator.cs
Questionable/Validation/Validators/NextQuestValidator.cs
Questionable/Validation/Validators/SayValidator.cs
Questionable/Validation/Validators/UniqueSinglePlayerInstanceValidator.cs
Questionable/Validation/Validators/UniqueStartStopValidator.cs
Questionable/Windows/QuestComponents/ActiveQuestComponent.cs

index 391e727..7eb7e5f 100644 (file)
@@ -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);
index c7636f6..d1e4c05 100644 (file)
@@ -133,7 +133,6 @@ internal static class DoGather
 
         private unsafe List<SlotInfo> ReadSlots(AddonGathering* addonGathering)
         {
-            var atkValues = addonGathering->AtkValues;
             List<SlotInfo> slots = new List<SlotInfo>();
             for (int i = 0; i < 8; ++i)
             {
index 04f0be3..e908279 100644 (file)
@@ -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);
             }
         }
     }
index 9df249a..c70b7be 100644 (file)
@@ -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;
index 14f011a..6852f6f 100644 (file)
@@ -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;
index ded8287..dede033 100644 (file)
@@ -445,10 +445,11 @@ internal sealed unsafe class QuestFunctions
 
     private int EstimateTeleportCosts(Quest quest)
     {
-        Dictionary<EAetheryteLocation, float> 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<EAetheryteLocation, float> 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;
index 0c2bee2..7fd4af8 100644 (file)
@@ -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,
index dc36bcc..5da7fb0 100644 (file)
@@ -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,
index ee6d6f5..a921548 100644 (file)
@@ -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,
index d08bea6..22981e8 100644 (file)
@@ -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,
index 9425488..7a0b59f 100644 (file)
@@ -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,
index 684e876..eeb8c13 100644 (file)
@@ -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,
index ed3e008..3ecd36f 100644 (file)
@@ -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,
index d9b156a..64ce967 100644 (file)
@@ -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);