Skip to content

Commit 0df8885

Browse files
committed
refactor(offsets): collapse duplicate object type-mask enum (OBJ_TYPE_* -> TYPEMASK_*)
OBJ_TYPE_* was a partial second naming of the same object-type bits as the complete TYPEMASK_* set (OBJ_TYPE_ITEM=2=TYPEMASK_ITEM, ... GAMEOBJECT =0x20 both) -- a single-source-of-truth violation. Repoint all ~18 references to TYPEMASK_* (identical values, behavior-preserving) and delete the OBJ_TYPE_* definitions, folding their derivation notes (bitmask semantics, FUN_004F8DB0 for PLAYER, FUN_0052AA20 for GAMEOBJECT, FUN_00529FE0 SetUnit) into the surviving TYPEMASK_* comment.
1 parent 8fa344a commit 0df8885

18 files changed

Lines changed: 29 additions & 32 deletions

src/Offsets.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ enum Offsets {
198198
// Returns an int the caller (Script_GameTooltip_SetUnit) tests, so the
199199
// co-hook must forward the original's return value.
200200
// - GameObject (0x0052aa20, __thiscall(self, guid*), RET 4) — the GO
201-
// hover populator; resolves the GO (OBJ_TYPE_GAMEOBJECT) and writes the
201+
// hover populator; resolves the GO (TYPEMASK_GAMEOBJECT) and writes the
202202
// GO field at +0x370.
203203
FUN_GAMETOOLTIP_BUILD_UNIT = 0x00529FE0,
204204
FUN_GAMETOOLTIP_BUILD_GAMEOBJECT = 0x0052AA20,
@@ -1895,7 +1895,7 @@ enum Offsets {
18951895
// gated on the bank-open globals). Returns the CGContainer GUID of the bag
18961896
// equipped in that slot, or 0 if none. This is the internal PackBagSlot
18971897
// uses to resolve bags 1..4: get the bag GUID here, resolve the container
1898-
// via FUN_OBJECT_RESOLVE_BY_GUID(OBJ_TYPE_CONTAINER, guid), then call the
1898+
// via FUN_OBJECT_RESOLVE_BY_GUID(TYPEMASK_CONTAINER, guid), then call the
18991899
// container's vtable[+OFF_CONTAINER_GET_INVENTORY] to get the inventory
19001900
// object GetItemBySlot indexes. Lets us enumerate bag contents in pure C++
19011901
// without PackBagSlot's Lua-stack coupling. (Reads GUID arrays at
@@ -1957,14 +1957,8 @@ enum Offsets {
19571957
// guidLo/guidHi). All our callers go through `Object::ByGuid`
19581958
// (object/Resolve.h), which wraps this single address.
19591959
FUN_OBJECT_RESOLVE_BY_GUID = 0x00468460,
1960-
// The type arg is a bitmask of object-type bits, not an enum
1961-
// index — `1<<1` for items, `1<<2` for containers, `1<<3` for
1962-
// units, matching what `FUN_00529FE0` passes for SetUnit (`ECX=8`).
1963-
OBJ_TYPE_ITEM = 2,
1964-
OBJ_TYPE_CONTAINER = 4,
1965-
OBJ_TYPE_UNIT = 8,
1966-
OBJ_TYPE_PLAYER = 0x10, // what the engine's bag observer FUN_004F8DB0 passes
1967-
OBJ_TYPE_GAMEOBJECT = 0x20, // 1<<5; passed by FUN_0052AA20 (hover-tooltip populator).
1960+
// The type arg is a bitmask of object-type bits (see the TYPEMASK_*
1961+
// block below), not an enum index.
19681962

19691963
// `CGObject::GetName` — returns the display-name `const char *` for
19701964
// a resolved CGObject (CGUnit / CGPlayer / CGCreature). Internally
@@ -2850,8 +2844,11 @@ enum Offsets {
28502844
// each callback invocation, guidLo/guidHi pushed as 8 stack bytes.
28512845
FUN_CLNT_OBJ_MGR_ENUM_VISIBLE_OBJECTS = 0x00468380,
28522846

2853-
// Type-mask flags accepted by FUN_OBJECT_RESOLVE_BY_GUID. Single-bit
2854-
// flags can be OR'd together.
2847+
// Type-mask flags accepted by FUN_OBJECT_RESOLVE_BY_GUID (and the SetUnit
2848+
// path FUN_00529FE0, which passes ECX=8 for UNIT). A bitmask of
2849+
// object-type bits, not an enum index — single-bit flags OR together.
2850+
// PLAYER (0x10) is what the bag observer FUN_004F8DB0 passes; GAMEOBJECT
2851+
// (0x20) what the hover-tooltip populator FUN_0052AA20 passes.
28552852
TYPEMASK_OBJECT = 0x01,
28562853
TYPEMASK_ITEM = 0x02,
28572854
TYPEMASK_CONTAINER = 0x04,

src/equipmentset/Locations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ uint8_t *ResolveByGUID(int type, uint64_t guid) {
6868
// bank bags (linear 63..68) — the only differences are the source of
6969
// the bag's GUID and how the result encodes back into a location.
7070
int WalkBagContents(uint64_t bagGuid, uint64_t targetGuid) {
71-
auto *bag = ResolveByGUID(Offsets::OBJ_TYPE_CONTAINER, bagGuid);
71+
auto *bag = ResolveByGUID(Offsets::TYPEMASK_CONTAINER, bagGuid);
7272
if (bag == nullptr)
7373
return 0;
7474
auto *bagInvMgr =

src/gameobject/Tooltip.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int __fastcall Script_GameTooltipGetGameObject(void *L) {
7070
if (guidLo == 0 && guidHi == 0)
7171
return 0;
7272

73-
void *obj = Object::ByGuid(Offsets::OBJ_TYPE_GAMEOBJECT,
73+
void *obj = Object::ByGuid(Offsets::TYPEMASK_GAMEOBJECT,
7474
(static_cast<uint64_t>(guidHi) << 32) | guidLo,
7575
"GameTooltip:GetGameObject", 0x172);
7676
if (obj == nullptr)

src/item/AverageLevel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ void WalkGuidArrayRange(const uint8_t *invMgr, int firstSlot, int lastSlot,
199199
if (guidArray == nullptr)
200200
return;
201201
for (int slot = firstSlot; slot <= lastSlot; ++slot) {
202-
const uint8_t *item = ResolveByGuid(Offsets::OBJ_TYPE_ITEM, guidArray[slot]);
202+
const uint8_t *item = ResolveByGuid(Offsets::TYPEMASK_ITEM, guidArray[slot]);
203203
if (item == nullptr)
204204
continue;
205205
CollectBagOrBankItem(item, candidates);
@@ -219,7 +219,7 @@ void WalkBankBags(std::vector<Candidate> &candidates) {
219219
return;
220220
for (int slot = Offsets::INVMGR_BANK_BAG_FIRST_SLOT;
221221
slot <= Offsets::INVMGR_BANK_BAG_LAST_SLOT; ++slot) {
222-
const uint8_t *bag = ResolveByGuid(Offsets::OBJ_TYPE_CONTAINER,
222+
const uint8_t *bag = ResolveByGuid(Offsets::TYPEMASK_CONTAINER,
223223
playerGuidArray[slot]);
224224
if (bag == nullptr)
225225
continue;

src/item/Count.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ int CountInGuidArray(const uint8_t *invMgr, int firstSlot, int lastSlot,
119119
return 0;
120120
int total = 0;
121121
for (int slot = firstSlot; slot <= lastSlot; slot++) {
122-
const uint8_t *item = ResolveByGuid(Offsets::OBJ_TYPE_ITEM, guidArray[slot]);
122+
const uint8_t *item = ResolveByGuid(Offsets::TYPEMASK_ITEM, guidArray[slot]);
123123
if (item == nullptr)
124124
continue;
125125
if (Item::ID::FromCGItem(item) != targetItemID)
@@ -148,7 +148,7 @@ int CountInBankBags(int targetItemID, bool includeUses) {
148148
int total = 0;
149149
for (int slot = Offsets::INVMGR_BANK_BAG_FIRST_SLOT;
150150
slot <= Offsets::INVMGR_BANK_BAG_LAST_SLOT; slot++) {
151-
const uint8_t *bag = ResolveByGuid(Offsets::OBJ_TYPE_CONTAINER,
151+
const uint8_t *bag = ResolveByGuid(Offsets::TYPEMASK_CONTAINER,
152152
playerGuidArray[slot]);
153153
if (bag == nullptr)
154154
continue;

src/item/Location.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void *EquippedBagInventory(int bagID) {
107107
if (bagGuid == 0)
108108
return nullptr; // no bag equipped in that slot
109109
auto *container = static_cast<const uint8_t *>(
110-
Object::ByGuid(Offsets::OBJ_TYPE_CONTAINER, bagGuid, "ItemMgr", 0x172));
110+
Object::ByGuid(Offsets::TYPEMASK_CONTAINER, bagGuid, "ItemMgr", 0x172));
111111
return ContainerInventory(container);
112112
}
113113

@@ -168,7 +168,7 @@ const uint8_t *ResolveByGUID(uint64_t guid) {
168168
if (guid == 0)
169169
return nullptr;
170170
return static_cast<const uint8_t *>(
171-
Object::ByGuid(Offsets::OBJ_TYPE_ITEM, guid, "ItemMgr", 0x172));
171+
Object::ByGuid(Offsets::TYPEMASK_ITEM, guid, "ItemMgr", 0x172));
172172
}
173173

174174
bool FindByItemID(void *L, int itemID, ByGUIDResult *out) {

src/item/Location.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const uint8_t *ResolveEquipmentSlot(int slot1Based);
7070
int GetBagSlotCount(int bagID);
7171

7272
// Given a `CGContainer*` (an equipped bag or bank bag, resolved by GUID via
73-
// `FUN_OBJECT_RESOLVE_BY_GUID` with `OBJ_TYPE_CONTAINER`), returns its own
73+
// `FUN_OBJECT_RESOLVE_BY_GUID` with `TYPEMASK_CONTAINER`), returns its own
7474
// inventory-manager object via the container's vtable method at
7575
// `+OFF_CONTAINER_GET_INVENTORY`. The returned object has the same layout as
7676
// the player inventory manager: slot count at `+0x00`, flat GUID array at

src/item/NewItems.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ void AppendNonBagOwned(uint64_t *out, int *count) {
304304
return;
305305
for (int slot = Offsets::INVMGR_BANK_BAG_FIRST_SLOT;
306306
slot <= Offsets::INVMGR_BANK_BAG_LAST_SLOT; ++slot) {
307-
const uint8_t *bag = ResolveByGuid(Offsets::OBJ_TYPE_CONTAINER, playerArr[slot]);
307+
const uint8_t *bag = ResolveByGuid(Offsets::TYPEMASK_CONTAINER, playerArr[slot]);
308308
if (bag == nullptr)
309309
continue;
310310
auto *bagInvMgr =

src/item/Tooltip.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static const uint8_t *PeekItemRecord(uint32_t itemID) {
158158
static void *ResolveItemByGuid(uint32_t guidLo, uint32_t guidHi) {
159159
if (guidLo == 0 && guidHi == 0)
160160
return nullptr;
161-
return Object::ByGuid(Offsets::OBJ_TYPE_ITEM,
161+
return Object::ByGuid(Offsets::TYPEMASK_ITEM,
162162
(static_cast<uint64_t>(guidHi) << 32) | guidLo,
163163
"GameTooltip:GetItem", 0x172);
164164
}

src/nameplate/Info.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static void PushNamePlateForGUID(void *L, uint64_t guid) {
129129
return;
130130
}
131131
auto *unit = static_cast<uint8_t *>(
132-
Object::ByGuid(Offsets::OBJ_TYPE_UNIT, guid, "NamePlate", 0x172));
132+
Object::ByGuid(Offsets::TYPEMASK_UNIT, guid, "NamePlate", 0x172));
133133
if (unit == nullptr) {
134134
Game::Lua::PushNil(L);
135135
return;

0 commit comments

Comments
 (0)