forked from liza/Deliveroo
Ensure retainer items are cached
This commit is contained in:
parent
9f91da23b6
commit
0161f3df31
@ -101,8 +101,17 @@ partial class DeliverooPlugin
|
|||||||
{
|
{
|
||||||
InventoryManager* inventoryManager = InventoryManager.Instance();
|
InventoryManager* inventoryManager = InventoryManager.Instance();
|
||||||
int count = inventoryManager->GetInventoryItemCount(itemId, false, false, false);
|
int count = inventoryManager->GetInventoryItemCount(itemId, false, false, false);
|
||||||
|
|
||||||
if (checkRetainerInventory)
|
if (checkRetainerInventory)
|
||||||
count += (int)_externalPluginHandler.GetRetainerItemCount(itemId);
|
{
|
||||||
|
if (!_retainerItemCache.TryGetValue(itemId, out int retainerCount))
|
||||||
|
{
|
||||||
|
_retainerItemCache[itemId] = retainerCount = (int)_externalPluginHandler.GetRetainerItemCount(itemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
count += retainerCount;
|
||||||
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
|||||||
private readonly ConfigWindow _configWindow;
|
private readonly ConfigWindow _configWindow;
|
||||||
private readonly TurnInWindow _turnInWindow;
|
private readonly TurnInWindow _turnInWindow;
|
||||||
private readonly IReadOnlyDictionary<uint, uint> _sealCaps;
|
private readonly IReadOnlyDictionary<uint, uint> _sealCaps;
|
||||||
|
private readonly Dictionary<uint, int> _retainerItemCache = new();
|
||||||
|
|
||||||
private Stage _currentStageInternal = Stage.Stopped;
|
private Stage _currentStageInternal = Stage.Stopped;
|
||||||
private DateTime _continueAt = DateTime.MinValue;
|
private DateTime _continueAt = DateTime.MinValue;
|
||||||
@ -95,6 +96,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
|||||||
_pluginInterface.UiBuilder.OpenConfigUi += _configWindow.Toggle;
|
_pluginInterface.UiBuilder.OpenConfigUi += _configWindow.Toggle;
|
||||||
_clientState.Login += Login;
|
_clientState.Login += Login;
|
||||||
_clientState.Logout += Logout;
|
_clientState.Logout += Logout;
|
||||||
|
_clientState.TerritoryChanged += TerritoryChanged;
|
||||||
_chatGui.ChatMessage += ChatMessage;
|
_chatGui.ChatMessage += ChatMessage;
|
||||||
_commandManager.AddHandler("/deliveroo", new CommandInfo(ProcessCommand)
|
_commandManager.AddHandler("/deliveroo", new CommandInfo(ProcessCommand)
|
||||||
{
|
{
|
||||||
@ -200,6 +202,13 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
|||||||
private void Logout()
|
private void Logout()
|
||||||
{
|
{
|
||||||
CharacterConfiguration = null;
|
CharacterConfiguration = null;
|
||||||
|
_retainerItemCache.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TerritoryChanged(ushort territoryType)
|
||||||
|
{
|
||||||
|
// there is no GC area that is in the same zone as a retainer bell, so this should be often enough.
|
||||||
|
_retainerItemCache.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void FrameworkUpdate(IFramework f)
|
private unsafe void FrameworkUpdate(IFramework f)
|
||||||
@ -348,6 +357,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
|||||||
|
|
||||||
_commandManager.RemoveHandler("/deliveroo");
|
_commandManager.RemoveHandler("/deliveroo");
|
||||||
_chatGui.ChatMessage -= ChatMessage;
|
_chatGui.ChatMessage -= ChatMessage;
|
||||||
|
_clientState.TerritoryChanged -= TerritoryChanged;
|
||||||
_clientState.Logout -= Logout;
|
_clientState.Logout -= Logout;
|
||||||
_clientState.Login -= Login;
|
_clientState.Login -= Login;
|
||||||
_pluginInterface.UiBuilder.OpenConfigUi -= _configWindow.Toggle;
|
_pluginInterface.UiBuilder.OpenConfigUi -= _configWindow.Toggle;
|
||||||
|
Loading…
Reference in New Issue
Block a user