fix: Duplicate BAG_UPDATE handlers
This commit is contained in:
+27
-13
@@ -12,8 +12,9 @@ SortEngine.sortingInProgress = false
|
|||||||
-- Performance: Max items to move per cycle
|
-- Performance: Max items to move per cycle
|
||||||
-- Baganator uses 5 for manual transfers, but sorting needs more for smooth operation
|
-- Baganator uses 5 for manual transfers, but sorting needs more for smooth operation
|
||||||
local MAX_MOVES_PER_CYCLE = 20
|
local MAX_MOVES_PER_CYCLE = 20
|
||||||
-- Bank uses fewer moves per cycle to avoid lock conflicts (bank ops are slower)
|
-- Bank needs more moves per cycle due to larger capacity (240 vs 160 slots)
|
||||||
local MAX_BANK_MOVES_PER_CYCLE = 15
|
-- But not too many to avoid server-side lock conflicts
|
||||||
|
local MAX_BANK_MOVES_PER_CYCLE = 25
|
||||||
|
|
||||||
-- Current sort context (set by ExecuteSort, used by ApplySort)
|
-- Current sort context (set by ExecuteSort, used by ApplySort)
|
||||||
local currentSortType = "bags"
|
local currentSortType = "bags"
|
||||||
@@ -1117,22 +1118,35 @@ local function ApplySort(bagIDs, items, targetPositions)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Execute swaps with occupied slots (if we haven't hit the limit)
|
-- Execute swaps with occupied slots (if we haven't hit the limit)
|
||||||
|
-- Be conservative with swaps - they can cause chain reactions
|
||||||
|
-- Limit swaps to half of max moves to leave room for next pass corrections
|
||||||
|
local maxSwaps = math.floor(maxMoves / 2)
|
||||||
|
local swapCount = 0
|
||||||
|
|
||||||
for _, move in ipairs(swapOccupied) do
|
for _, move in ipairs(swapOccupied) do
|
||||||
-- Limit moves per cycle
|
-- Limit total moves and swaps separately
|
||||||
if moveCount >= maxMoves then
|
if moveCount >= maxMoves or swapCount >= maxSwaps then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
local _, _, sourceLocked = GetContainerItemInfo(move.sourceBag, move.sourceSlot)
|
-- Verify source item is still there (previous swaps may have moved it)
|
||||||
local _, _, targetLocked = GetContainerItemInfo(move.targetBag, move.targetSlot)
|
local sourceLink = GetContainerItemLink(move.sourceBag, move.sourceSlot)
|
||||||
|
if not sourceLink then
|
||||||
if not sourceLocked and not targetLocked then
|
-- Source slot is now empty, skip this swap (will be handled next pass)
|
||||||
PickupContainerItem(move.sourceBag, move.sourceSlot)
|
addon:DebugSort("Swap skipped: source slot now empty (%d:%d)", move.sourceBag, move.sourceSlot)
|
||||||
PickupContainerItem(move.targetBag, move.targetSlot)
|
|
||||||
ClearCursor()
|
|
||||||
moveCount = moveCount + 1
|
|
||||||
else
|
else
|
||||||
lockedCount = lockedCount + 1
|
local _, _, sourceLocked = GetContainerItemInfo(move.sourceBag, move.sourceSlot)
|
||||||
|
local _, _, targetLocked = GetContainerItemInfo(move.targetBag, move.targetSlot)
|
||||||
|
|
||||||
|
if not sourceLocked and not targetLocked then
|
||||||
|
PickupContainerItem(move.sourceBag, move.sourceSlot)
|
||||||
|
PickupContainerItem(move.targetBag, move.targetSlot)
|
||||||
|
ClearCursor()
|
||||||
|
moveCount = moveCount + 1
|
||||||
|
swapCount = swapCount + 1
|
||||||
|
else
|
||||||
|
lockedCount = lockedCount + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+3
-5
@@ -1714,11 +1714,9 @@ function BankFrame:Initialize()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
addon.Modules.Events:OnBagUpdate(function()
|
-- NOTE: BAG_UPDATE for bank bags (5-10) is handled by the updateFrame below
|
||||||
if addon.Modules.BankScanner:IsBankOpen() and not currentViewChar then
|
-- which provides incremental update logic. We don't need a separate OnBagUpdate
|
||||||
ScheduleBankFrameUpdate(0.1)
|
-- handler here as it would cause duplicate processing.
|
||||||
end
|
|
||||||
end, "BankFrameUI")
|
|
||||||
|
|
||||||
-- Update when items get locked/unlocked (debounced for trading, mailing, etc.)
|
-- Update when items get locked/unlocked (debounced for trading, mailing, etc.)
|
||||||
addon.Modules.Events:Register("ITEM_LOCK_CHANGED", function()
|
addon.Modules.Events:Register("ITEM_LOCK_CHANGED", function()
|
||||||
|
|||||||
Reference in New Issue
Block a user