From 242f0f1b04c9e6636b89ab948811bbfaa6cf7600 Mon Sep 17 00:00:00 2001 From: Uga Date: Sat, 1 Aug 2026 20:08:26 +0200 Subject: [PATCH] Use the real main bank size instead of hardcoded ones The main bank holds 24 slots on Classic Era and 28 from TBC onwards, but four different places assumed a fixed value, and none of them agreed: - bagSizes[MainBankSlots] was "hasVoidBank and 28 or 98". hasVoidBank is only true between 5.3 and 11.2, so every classic version below MoP fell through to 98, the size of an 11.2 bank tab, and the grid never trimmed its last row - the containers pane passed a literal 28 to UpdateBagIndices(), so it laid out three rows of 12 whatever the character actually has - the backpack tooltip said 16 and the bank tooltip said 28, both literals, which is why the tooltip disagreed with the grid next to it - PlayerBank scanned 28 main slots regardless The size is now taken from NUM_BANKGENERIC_SLOTS, and stored per character on scan so an alt scanned on another version of the game keeps its own size rather than borrowing the one of the running client. GetPlayerBankSize() exposes it, and the containers pane routes the bank through it for the grid, the row layout and the tooltip alike. The backpack tooltip now reads the scanned container size, so it matches the 20 slots shown on the right. Co-Authored-By: Claude Opus 5 --- DataStore_Containers/API/PlayerBank.lua | 17 +++++++++++++---- DataStore_Containers/DataStore_Containers.lua | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/DataStore_Containers/API/PlayerBank.lua b/DataStore_Containers/API/PlayerBank.lua index 8c86eb9..85afdf1 100644 --- a/DataStore_Containers/API/PlayerBank.lua +++ b/DataStore_Containers/API/PlayerBank.lua @@ -14,7 +14,8 @@ local isConsolidatedBank = (interfaceVersion >= 110200) -- using the new 11.2 b local enum = DataStore.Enum.ContainerIDs local bit64 = LibStub("LibBit64") -local NUM_MAIN_SLOTS = 28 +-- 24 on Classic Era, 28 from TBC onwards, until the 11.2 consolidated bank replaced it with tabs +local NUM_MAIN_SLOTS = NUM_BANKGENERIC_SLOTS or 28 local TAB_SIZE = 98 local BANK_TAG = "Bank" @@ -46,7 +47,10 @@ local function ScanMainSlots() local startTime, duration, isEnabled bag.freeslots = C_Container.GetContainerNumFreeSlots(enum.MainBankSlots) - + + -- save the size, an alt scanned on another version of the game does not have the same bank + bag.numSlots = NUM_MAIN_SLOTS + for slotID = 1, NUM_MAIN_SLOTS do link = C_Container.GetContainerItemLink(enum.MainBankSlots, slotID) @@ -160,8 +164,12 @@ local function _GetSlotInfo(bag, slotID) return itemID, link, count, isBattlePet end +local function _GetPlayerBankSize(character) + return character.numSlots or NUM_MAIN_SLOTS +end + local function _IteratePlayerBankSlots(character, callback) - for slotID = 1, NUM_MAIN_SLOTS do + for slotID = 1, _GetPlayerBankSize(character) do local itemID, itemLink, itemCount, isBattlePet = _GetSlotInfo(character, slotID) -- Callback only if there is an item in that slot @@ -208,7 +216,8 @@ AddonFactory:OnAddonLoaded(addonName, function() GetPlayerBank = function(character) return character end, GetPlayerBankItemCount = isRetail and _GetPlayerBankItemCount_Retail or _GetPlayerBankItemCount_NonRetail, - GetPlayerBankInfo = function(character) return NUM_MAIN_SLOTS, character.freeslots end, + GetPlayerBankInfo = function(character) return _GetPlayerBankSize(character), character.freeslots end, + GetPlayerBankSize = _GetPlayerBankSize, GetPlayerBankTabName = isConsolidatedBank and _GetPlayerBankTabName, GetPlayerBankTabIcon = isConsolidatedBank and _GetPlayerBankTabIcon, HasPlayerVisitedBank = isConsolidatedBank and _HasPlayerVisitedBank_Retail or _HasPlayerVisitedBank_NonRetail, diff --git a/DataStore_Containers/DataStore_Containers.lua b/DataStore_Containers/DataStore_Containers.lua index 2a5baaf..6314fde 100644 --- a/DataStore_Containers/DataStore_Containers.lua +++ b/DataStore_Containers/DataStore_Containers.lua @@ -338,7 +338,8 @@ local bagIcons = { local bagSizes = { [enum.VoidStorageTab1] = hasVoidBank and 80, [enum.VoidStorageTab2] = hasVoidBank and 80, - [enum.MainBankSlots] = hasVoidBank and 28 or 98, -- 11.2: void storage removed, and main bank slots upgraded + -- 24 on Classic Era, 28 from TBC onwards. 11.2 replaced the main slots with 98-slot tabs, see below. + [enum.MainBankSlots] = NUM_BANKGENERIC_SLOTS or 28, [enum.ReagentBank] = hasReagentBank and 98, [100] = 28, -- MainBankSlots for MoP }