Skip to content

Commit 8206230

Browse files
committed
docs: item name/GetItem/by-name APIs return the decorated (suffixed) name
Follow-up to the random-suffix work (aa0279a, e8a9003, 2a218a0). API.md still described the old base-name behavior in five places; update them: - GameTooltip:GetItem() example: name is now the decorated name that agrees with the returned link ("Superior Cloak of the Eagle"). - C_Item.GetItemName: split the two forms -- location returns the decorated name (live instance, via the engine name builder), ByID returns the base name (an itemID has no instance/suffix). - C_Item.IsEquippedItem / EquipItemByName / UseItemByName: name matching is against the decorated name (a suffixed item matches its full name, not the base), noting the one shared predicate behind all three. Left the C_Item.GetItemData return-table `name` row as base m_name[0] on purpose: that table is a static itemID-keyed record dump (same contract as GetItemInfoInstant, which doesn't decorate either).
1 parent 2a218a0 commit 8206230

1 file changed

Lines changed: 34 additions & 15 deletions

File tree

docs/API.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,7 +3476,7 @@ local name, link, id = GameTooltip:GetItem()
34763476
-- SetInventoryItem — full dressed link with enchant + random suffix
34773477
GameTooltip:SetInventoryItem("player", INVSLOT_BACK)
34783478
local name, link, id = GameTooltip:GetItem()
3479-
-- name = "Superior Cloak"
3479+
-- name = "Superior Cloak of the Eagle" -- decorated name, agrees with the link
34803480
-- link = "|cff1eff00|Hitem:9805:247:843:0|h[Superior Cloak of the Eagle]|h|r"
34813481
-- id = 9805
34823482
```
@@ -4430,7 +4430,9 @@ the item's inventory type.
44304430
`itemInfo` accepts the same shapes as
44314431
[`C_Item.IsEquippedItem`](#c_itemisequippeditemitem) — itemID number,
44324432
bare `"item:N"` string, full chat link, or a localized item name. Name
4433-
matches are case-insensitive against the cached `m_name[0]`.
4433+
matching is case-insensitive against each candidate's *decorated* name
4434+
(random suffix included — a suffixed item matches its full name, not the
4435+
base), the same shared predicate `C_Item.IsEquippedItem` uses.
44344436

44354437
Returns nothing. Silently no-ops when:
44364438

@@ -4963,16 +4965,27 @@ after `GET_ITEM_INFO_RECEIVED`.
49634965

49644966
### `C_Item.GetItemName(itemLocation)` / `C_Item.GetItemNameByID(item)`
49654967

4966-
Returns the cached display name as a string, or `nil` for empty /
4967-
uncached / invalid inputs. Reads `m_name[0]` straight off the
4968-
`ItemStats_C` cache record (`+0x08`) — no `GetItemInfo` round-trip.
4968+
Returns the item's display name as a string, or `nil` for empty /
4969+
uncached / invalid inputs.
49694970

4970-
Cache miss on the `ByID` form returns `nil` and fires the cache fill
4971-
so the next call (after `GET_ITEM_INFO_RECEIVED`) succeeds.
4971+
The **location** form points at a live item instance, so it returns the
4972+
*decorated* name — random suffix included (`"Iridium Chain of the Owl"`,
4973+
not the base `"Iridium Chain"`) — built off the `CGItem` via the engine's
4974+
own name builder, matching modern WoW and the bracketed name in
4975+
[`C_Item.GetItemLink`](#c_itemgetitemlinkitemlocation). (It falls back to
4976+
the base `ItemStats_C.m_name[0]` name if the instance build yields
4977+
nothing.)
4978+
4979+
The **ByID** form has no instance — an itemID can't carry a random suffix
4980+
— so it returns the base `m_name[0]` name only. Cache miss on the `ByID`
4981+
form returns `nil` and fires the cache fill so the next call (after
4982+
`GET_ITEM_INFO_RECEIVED`) succeeds.
49724983

49734984
```lua
4974-
local name = C_Item.GetItemName({bagID = 0, slotIndex = 1})
4975-
local name = C_Item.GetItemNameByID(6948) -- "Hearthstone"
4985+
-- location form → decorated name (random suffix included)
4986+
local name = C_Item.GetItemName({equipmentSlotIndex = 2}) -- "Iridium Chain of the Owl"
4987+
-- ByID form → base name only (no instance → no suffix)
4988+
local name = C_Item.GetItemNameByID(6948) -- "Hearthstone"
49764989
```
49774990

49784991
### `C_Item.GetItemQuality(itemLocation)` / `C_Item.GetItemQualityByID(item)`
@@ -5382,14 +5395,19 @@ short-circuits on the first match.
53825395
| itemID | `2589` | exact `itemID` equality |
53835396
| bare link | `"item:2589:0:0:0"` | parses the first numeric field |
53845397
| chat link | `\124cffffffff\124Hitem:2589:0:0:0\124h[Linen Cloth]\124h\124r` | extracts itemID after `\124Hitem:` |
5385-
| name | `"Linen Cloth"` | case-insensitive match against the cached `m_name[0]` of each equipped item |
5398+
| name | `"Linen Cloth"` | case-insensitive match against each equipped item's *decorated* name (random suffix included) |
53865399

53875400
Returns `false` (no Lua error) for invalid input — `nil`, empty string,
53885401
or a string that doesn't parse as any of the above.
53895402

5390-
The name-match path requires the candidate equipped item to be in the
5391-
client item cache; equipped items are always cached, so this is a
5392-
non-issue in practice.
5403+
Name matching is against the item's **decorated** name: a random-suffix
5404+
item matches only its full name (`"Krol Blade of the Bear"`), not the
5405+
base (`"Krol Blade"`) — the same behavior as modern WoW (verified
5406+
in-game). Unsuffixed items match their plain name. The candidate must be
5407+
in the client item cache; equipped items always are, so that's a non-issue
5408+
in practice. This match logic is shared with the by-name action APIs
5409+
(`C_Item.UseItemByName` / `EquipItemByName`) — one predicate, one set of
5410+
semantics.
53935411

53945412
```lua
53955413
if C_Item.IsEquippedItem(2589) then
@@ -5707,8 +5725,9 @@ uses it. Returns nothing; silently no-ops when:
57075725
`itemInfo` accepts the same shapes as
57085726
[`C_Item.EquipItemByName`](#c_itemequipitembynameiteminfo--dstslot)
57095727
itemID number, bare `"item:N"` string, full chat link, or a localized
5710-
item name. Name matches are case-insensitive against the cached
5711-
`m_name[0]`.
5728+
item name. Name matching is case-insensitive against each candidate's
5729+
*decorated* name (random suffix included), the same shared predicate
5730+
`C_Item.IsEquippedItem` uses.
57125731

57135732
The optional `unit` argument is a unit token (`"player"`, `"target"`,
57145733
`"focus"`, `"partyN"`, `"raidN"`, `"nameplateN"`, …) used as the cast

0 commit comments

Comments
 (0)