Skip to content

Label every bag with the type it really is - #24

Open
uga wants to merge 2 commits into
Thaoky:developmentfrom
uga:fix/bag-type-labels
Open

Label every bag with the type it really is#24
uga wants to merge 2 commits into
Thaoky:developmentfrom
uga:fix/bag-type-labels

Conversation

@uga

@uga uga commented Aug 5, 2026

Copy link
Copy Markdown

A user reported that Altoholic does not recognise some of the higher-end bags, the Satchel of Cenarius (a 24-slot herb bag) among them. It turned out that no bag type was ever resolved correctly, and that the ones which did show a type were showing the wrong one.

On Classic Era, the "Bags" tooltip of the summary showed a warlock's Soul Pouch as (Ammo Pouch), while a hunter's Quickdraw Quiver got no label at all.

Root cause

ScanBag saves the item family as a bit index, because the field is only 5 bits wide and the raw family of a mining bag (1024) would never fit:

if bagType and bagType > 0 then
    bagType = Log2(bagType)
end

but bagTypeStrings was keyed on the raw item family instead:

[4] = ... -- "Soul Bag",
[32] = ... -- "Herb Bag"

so the lookup in _GetContainerInfo could only ever match by accident:

bag saved bagTypeStrings[saved]
Quiver 0 nothing
Ammo Pouch 1 "Quiver"
Soul Bag 2 "Ammo Pouch"
Leatherworking 3 nothing
Inscription 4 "Soul Bag"
Herb (Satchel of Cenarius) 5 nothing
Enchanting / Engineering / Gem / Mining 6, 7, 9, 10 nothing

Plain bags were fine only because they save a 0 that matches nothing.

Fix

Both tables are now keyed on what ScanBag actually saves. The saved value is offset by a new BAG_TYPE_OFFSET, for two reasons:

  • 0 has to keep meaning "no specific type", but a quiver is family 1, whose Log2 is also 0, so every ordinary bag would otherwise become a quiver;
  • data saved by earlier versions holds the plain Log2, 0 to 10. Placing the new range above it means those values match no key and read as "no type", which is what they already displayed, rather than picking up a wrong label until the character is scanned again.

The highest value is now 26, so the 5 bits still hold it and the layout of bag.info is unchanged. Bags are rescanned on any BAG_UPDATE, so each character corrects itself on its next login.

Checked with luac5.1 -p, and with a round-trip harness replicating LibBit64 + ScanBag + _GetContainerInfo: all 11 families come back with the right label, rarity/size/free slots/icon unaffected, and every possible legacy value reads as no type.

uga and others added 2 commits August 5, 2026 19:19
A user reported that Altoholic does not recognise some of the higher-end
bags, the Satchel of Cenarius (a 24-slot herb bag) among them. It turned
out that no bag type was ever resolved correctly, and that the ones which
did show a type were showing the wrong one: a warlock's Soul Pouch was
labelled "(Ammo Pouch)", while a hunter's Quickdraw Quiver got no label
at all.

ScanBag saves the item family as a bit index, because the field is only
5 bits wide and the raw family of a mining bag (1024) would never fit:

	if bagType and bagType > 0 then
		bagType = Log2(bagType)
	end

but bagTypeStrings was keyed on the raw family instead:

	[4] = ... -- "Soul Bag",
	[32] = ... -- "Herb Bag"

so the lookup in _GetContainerInfo could only ever match by accident.
A soul bag saved 2 and picked up "Ammo Pouch", an inscription bag saved 4
and picked up "Soul Bag", and every other type saved a value the table
had no key for, hence no label. Plain bags were fine only because they
save a 0 that matches nothing.

Key both tables on what ScanBag actually saves. The saved value is now
offset by BAG_TYPE_OFFSET, for two reasons:

	- 0 has to keep meaning "no specific type", but a quiver is family 1,
	  whose Log2 is also 0, so every ordinary bag would become a quiver;

	- data saved by earlier versions holds the plain Log2, 0 to 10. Placing
	  the new range above it means those values match no key and read as
	  "no type", which is what they already displayed, rather than picking
	  up a wrong label until the character is scanned again.

The highest value is now 26, so the 5 bits still hold it and the layout of
bag.info is unchanged. Bags are rescanned on any BAG_UPDATE, so each
character corrects itself on its next login.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A hunter carrying a full quiver was reported as having eighty-four slots with
twenty-one free, sixteen of which were quiver slots that hold nothing but
ammunition. A warlock's soul pouch added twenty more of the same kind. The
totals were arithmetically right and told the user something that was not true:
how much room there is for ordinary things.

The bag type is saved correctly now, so the two kinds can be told apart. Bags
and bank bags that only take one family of items no longer count towards the
totals of either. Nothing is hidden: each bag is still listed in the tooltip
with its size, its free slots and, since the type is read properly, its name.

A character's totals are rewritten by the scan that runs a few seconds after
their next login.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant