diff --git a/Deliveroo/DeliverooPlugin.GameFunctions.cs b/Deliveroo/DeliverooPlugin.GameFunctions.cs
index 161ee1a..562cd26 100644
--- a/Deliveroo/DeliverooPlugin.GameFunctions.cs
+++ b/Deliveroo/DeliverooPlugin.GameFunctions.cs
@@ -120,6 +120,9 @@ partial class DeliverooPlugin
return 1;
}
+ ///
+ /// This returns ALL items that can be turned in, regardless of filter settings.
+ ///
private unsafe List BuildTurnInList(AgentGrandCompanySupply* agent)
{
List list = new();
diff --git a/Deliveroo/DeliverooPlugin.Supply.cs b/Deliveroo/DeliverooPlugin.Supply.cs
index 07ea99a..9caddaa 100644
--- a/Deliveroo/DeliverooPlugin.Supply.cs
+++ b/Deliveroo/DeliverooPlugin.Supply.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Logging;
+using Dalamud.Memory;
using Deliveroo.GameData;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
@@ -72,11 +73,13 @@ partial class DeliverooPlugin
return;
AtkUnitBase* addon = GetAddonById(addonId);
- if (addon == null || !IsAddonReady(addon) || addon->UldManager.NodeListCount <= 20 ||
- !addon->UldManager.NodeList[5]->IsVisible)
+ if (addon == null || !IsAddonReady(addon) || addon->UldManager.NodeListCount <= 20)
return;
var addonGc = (AddonGrandCompanySupplyList*)addon;
+ if (addonGc->ExpertDeliveryList == null || !addonGc->ExpertDeliveryList->AtkComponentBase.OwnerNode->AtkResNode.IsVisible)
+ return;
+
if (addonGc->SelectedTab != 2)
{
_turnInWindow.Error = "Wrong tab selected";
@@ -90,16 +93,42 @@ partial class DeliverooPlugin
return;
}
- var agent = (AgentGrandCompanySupply*)agentInterface;
- List items = BuildTurnInList(agent);
- _turnInWindow.EstimatedGcSeals = GetCurrentSealCount() + items.Sum(x => x.SealsWithBonus);
- if (items.Count == 0 || addon->UldManager.NodeList[20]->IsVisible)
+ if (addonGc->ListEmptyTextNode->AtkResNode.IsVisible)
{
CurrentStage = Stage.CloseGcSupplyThenStop;
addon->FireCallbackInt(-1);
return;
}
+ var agent = (AgentGrandCompanySupply*)agentInterface;
+ List items = BuildTurnInList(agent);
+ if (items.Count == 0)
+ {
+ // probably shouldn't happen with the previous node visibility check
+ CurrentStage = Stage.CloseGcSupplyThenStop;
+ addon->FireCallbackInt(-1);
+ return;
+ }
+
+ // TODO The way the items are handled above, we don't actually know if items[0] is the first visible item
+ // in the list, it is "only" the highest-value item to turn in.
+ //
+ // For example, if you have
+ // - Trojan Ring, SealsWithoutBonus = 1887, part of a gear set
+ // - Radiant Battleaxe, SealsWithoutBonus = 1879, not part of a gear set
+ // then this algorithm will ensure that you have enough space for the highest-value item (trojan ring), even
+ // though it turn in the Radiant Battleaxe.
+ //
+ // Alternatively, and probably easier:
+ // - look up how many seals the first item gets
+ // - find *any* item in the list with that seal count (and possibly matching the name) to determine the
+ // seals with bonus + whether it exists
+ // - use that item instead of items[0] here
+ //
+ // However, since this never over-caps seals, this isn't a very high priority.
+ // ---------------------------------------------------------------------------------------------------------
+ // TODO If we ever manage to obtain a mapping name to itemId here, we can try and exclude e.g. Red Onion
+ // Helms from being turned in.
if (GetCurrentSealCount() + items[0].SealsWithBonus > GetSealCap())
{
CurrentStage = Stage.CloseGcSupply;
diff --git a/Deliveroo/DeliverooPlugin.cs b/Deliveroo/DeliverooPlugin.cs
index 9e49b72..1ab7f96 100644
--- a/Deliveroo/DeliverooPlugin.cs
+++ b/Deliveroo/DeliverooPlugin.cs
@@ -1,32 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Numerics;
-using System.Runtime.InteropServices;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Objects;
-using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Gui;
using Dalamud.Interface.Windowing;
using Dalamud.Logging;
-using Dalamud.Memory;
using Dalamud.Plugin;
using Deliveroo.External;
using Deliveroo.GameData;
using Deliveroo.Windows;
-using FFXIVClientStructs.FFXIV.Client.Game;
-using FFXIVClientStructs.FFXIV.Client.Game.Control;
-using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.UI;
-using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Excel.GeneratedSheets;
-using Character = Dalamud.Game.ClientState.Objects.Types.Character;
-using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
-using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
namespace Deliveroo;
diff --git a/Deliveroo/Windows/TurnInWindow.cs b/Deliveroo/Windows/TurnInWindow.cs
index 8563b32..2d70e90 100644
--- a/Deliveroo/Windows/TurnInWindow.cs
+++ b/Deliveroo/Windows/TurnInWindow.cs
@@ -47,7 +47,6 @@ internal sealed class TurnInWindow : Window
public bool State { get; set; }
public decimal Multiplier { private get; set; }
- public int EstimatedGcSeals { private get; set; }
public string Error { private get; set; } = string.Empty;
public List SelectedItems
@@ -135,15 +134,6 @@ internal sealed class TurnInWindow : Window
ImGui.Separator();
ImGui.Text($"Debug (State): {_plugin.CurrentStage}");
- switch (_plugin.CurrentStage)
- {
- case Stage.SelectItemToTurnIn:
- case Stage.TurnInSelected:
- case Stage.FinalizeTurnIn:
- case Stage.CloseGcSupply:
- ImGui.Text($"Estimated Total Seal Count: {EstimatedGcSeals:N0}");
- break;
- }
}
private void DrawItemsToBuy(GrandCompany grandCompany)