Skip to content

Commit a77d8f3

Browse files
committed
Add Enum.InventoryType
Registers Enum.InventoryType (equip-type enum) as a hardcoded mirror of Blizzard's 0..34 spec, via the same RegisterIntegerEnum path as Enum.PowerType / Enum.AddOnSecurityStatus. Values 0..28 are the ones vanilla items report; 29..34 (profession / equippable-spell types) are post-vanilla, included so backport code referencing those keys resolves. The field names (IndexHeadType, Index2HweaponType, …) aren't present in engine data and don't derive cleanly from the INVTYPE key strings, so a static mirror is the correct approach — it's a fixed API contract, not engine-driven. For the live set of slot keys the engine actually has, use C_Item.GetItemInventorySlotKey. Documented in docs/API.md and the README enum row.
1 parent 766d128 commit a77d8f3

3 files changed

Lines changed: 80 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ when launching with `-console`), not as Lua functions. See the
143143
| Unit stat | `LE_UNIT_STAT_STRENGTH``LE_UNIT_STAT_SPIRIT` |
144144
| Addon security | `Enum.AddOnSecurityStatus.{Secure,Insecure,Banned,NotAvailable}` |
145145
| Power type | `Enum.PowerType.{HealthCost,None,Mana,Rage,Focus,Energy,Happiness}` |
146+
| Inventory type | `Enum.InventoryType.Index*Type` (0–34, e.g. `IndexHeadType`=1 … `IndexRelicType`=28) |
146147

147148
### Unit tokens
148149

docs/API.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ build instructions.
154154
- [`LE_ITEM_QUALITY_*`](#le_item_quality_)
155155
- [`LE_UNIT_STAT_*`](#le_unit_stat_)
156156
- [`Enum.AddOnSecurityStatus`](#enumaddonsecuritystatus)
157+
- [`Enum.InventoryType`](#enuminventorytype)
157158
- [`Enum.PowerType`](#enumpowertype)
158159

159160
- [Gossip](#gossip)
@@ -3616,6 +3617,39 @@ if C_AddOns.GetAddOnSecurity(name) == Enum.AddOnSecurityStatus.Secure then
36163617
end
36173618
```
36183619

3620+
### `Enum.InventoryType`
3621+
3622+
The equip-type enum — the numeric `inventoryType` reported by
3623+
[`C_Item.GetItemInfoInstant`](#c_itemgetiteminfoinstantitem) /
3624+
[`C_Item.GetItemInventoryType`](#c_itemgetiteminventorytypeitemlocation--c_itemgetiteminventorytypebyiditem),
3625+
and the argument the `C_Item.GetItemInventorySlot*` functions take.
3626+
3627+
| Value | Field | Value | Field |
3628+
|------:|-------|------:|-------|
3629+
| 0 | `IndexNonEquipType` | 15 | `IndexRangedType` |
3630+
| 1 | `IndexHeadType` | 16 | `IndexCloakType` |
3631+
| 2 | `IndexNeckType` | 17 | `Index2HweaponType` |
3632+
| 3 | `IndexShoulderType` | 18 | `IndexBagType` |
3633+
| 4 | `IndexBodyType` | 19 | `IndexTabardType` |
3634+
| 5 | `IndexChestType` | 20 | `IndexRobeType` |
3635+
| 6 | `IndexWaistType` | 21 | `IndexWeaponmainhandType` |
3636+
| 7 | `IndexLegsType` | 22 | `IndexWeaponoffhandType` |
3637+
| 8 | `IndexFeetType` | 23 | `IndexHoldableType` |
3638+
| 9 | `IndexWristType` | 24 | `IndexAmmoType` |
3639+
| 10 | `IndexHandType` | 25 | `IndexThrownType` |
3640+
| 11 | `IndexFingerType` | 26 | `IndexRangedrightType` |
3641+
| 12 | `IndexTrinketType` | 27 | `IndexQuiverType` |
3642+
| 13 | `IndexWeaponType` | 28 | `IndexRelicType` |
3643+
| 14 | `IndexShieldType` | | |
3644+
3645+
Values `29..34` (`IndexProfessionToolType`, `IndexProfessionGearType`,
3646+
`IndexEquipablespell{Offensive,Utility,Defensive,Weapon}Type`) are
3647+
post-vanilla and included for parity — vanilla items never report them.
3648+
3649+
```lua
3650+
if C_Item.GetItemInventoryType(loc) == Enum.InventoryType.IndexHeadType then ...
3651+
```
3652+
36193653
### `Enum.PowerType`
36203654

36213655
The integer enum `UnitPowerType` returns and `UnitPower` /

src/item/TypeInfo.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,58 @@ int __fastcall Script_GetItemInventorySlotInfo(void *L) {
142142
return 1;
143143
}
144144

145+
// `Enum.InventoryType` — the modern equip-type enum. Values 0..28 are the
146+
// ones vanilla items actually report; 29..34 (profession / equippable-spell
147+
// types) are post-vanilla but included so backport code that references those
148+
// keys resolves (the comparisons just never match on 1.12 data).
149+
constexpr Game::Lua::EnumIntegerEntry kInventoryTypeEntries[] = {
150+
{"IndexNonEquipType", 0},
151+
{"IndexHeadType", 1},
152+
{"IndexNeckType", 2},
153+
{"IndexShoulderType", 3},
154+
{"IndexBodyType", 4},
155+
{"IndexChestType", 5},
156+
{"IndexWaistType", 6},
157+
{"IndexLegsType", 7},
158+
{"IndexFeetType", 8},
159+
{"IndexWristType", 9},
160+
{"IndexHandType", 10},
161+
{"IndexFingerType", 11},
162+
{"IndexTrinketType", 12},
163+
{"IndexWeaponType", 13},
164+
{"IndexShieldType", 14},
165+
{"IndexRangedType", 15},
166+
{"IndexCloakType", 16},
167+
{"Index2HweaponType", 17},
168+
{"IndexBagType", 18},
169+
{"IndexTabardType", 19},
170+
{"IndexRobeType", 20},
171+
{"IndexWeaponmainhandType", 21},
172+
{"IndexWeaponoffhandType", 22},
173+
{"IndexHoldableType", 23},
174+
{"IndexAmmoType", 24},
175+
{"IndexThrownType", 25},
176+
{"IndexRangedrightType", 26},
177+
{"IndexQuiverType", 27},
178+
{"IndexRelicType", 28},
179+
{"IndexProfessionToolType", 29},
180+
{"IndexProfessionGearType", 30},
181+
{"IndexEquipablespellOffensiveType", 31},
182+
{"IndexEquipablespellUtilityType", 32},
183+
{"IndexEquipablespellDefensiveType", 33},
184+
{"IndexEquipablespellWeaponType", 34},
185+
};
186+
145187
void RegisterLuaFunctions() {
146188
Game::Lua::RegisterTableFunction("C_Item", "GetItemSubClassInfo",
147189
&Script_GetItemSubClassInfo);
148190
Game::Lua::RegisterTableFunction("C_Item", "GetItemInventorySlotKey",
149191
&Script_GetItemInventorySlotKey);
150192
Game::Lua::RegisterTableFunction("C_Item", "GetItemInventorySlotInfo",
151193
&Script_GetItemInventorySlotInfo);
194+
Game::Lua::RegisterIntegerEnum(
195+
"Enum", "InventoryType", kInventoryTypeEntries,
196+
sizeof(kInventoryTypeEntries) / sizeof(kInventoryTypeEntries[0]));
152197
}
153198

154199
const Game::ModuleAutoRegister _autoreg{&RegisterLuaFunctions};

0 commit comments

Comments
 (0)