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.
This commit is contained in:
Brues
2026-08-08 15:12:55 -05:00
parent 8fa344a084
commit 0df8885045
18 changed files with 29 additions and 32 deletions
+9 -12
View File
@@ -198,7 +198,7 @@ enum Offsets {
// Returns an int the caller (Script_GameTooltip_SetUnit) tests, so the
// co-hook must forward the original's return value.
// - GameObject (0x0052aa20, __thiscall(self, guid*), RET 4) — the GO
// hover populator; resolves the GO (OBJ_TYPE_GAMEOBJECT) and writes the
// hover populator; resolves the GO (TYPEMASK_GAMEOBJECT) and writes the
// GO field at +0x370.
FUN_GAMETOOLTIP_BUILD_UNIT = 0x00529FE0,
FUN_GAMETOOLTIP_BUILD_GAMEOBJECT = 0x0052AA20,
@@ -1895,7 +1895,7 @@ enum Offsets {
// gated on the bank-open globals). Returns the CGContainer GUID of the bag
// equipped in that slot, or 0 if none. This is the internal PackBagSlot
// uses to resolve bags 1..4: get the bag GUID here, resolve the container
// via FUN_OBJECT_RESOLVE_BY_GUID(OBJ_TYPE_CONTAINER, guid), then call the
// via FUN_OBJECT_RESOLVE_BY_GUID(TYPEMASK_CONTAINER, guid), then call the
// container's vtable[+OFF_CONTAINER_GET_INVENTORY] to get the inventory
// object GetItemBySlot indexes. Lets us enumerate bag contents in pure C++
// without PackBagSlot's Lua-stack coupling. (Reads GUID arrays at
@@ -1957,14 +1957,8 @@ enum Offsets {
// guidLo/guidHi). All our callers go through `Object::ByGuid`
// (object/Resolve.h), which wraps this single address.
FUN_OBJECT_RESOLVE_BY_GUID = 0x00468460,
// The type arg is a bitmask of object-type bits, not an enum
// index — `1<<1` for items, `1<<2` for containers, `1<<3` for
// units, matching what `FUN_00529FE0` passes for SetUnit (`ECX=8`).
OBJ_TYPE_ITEM = 2,
OBJ_TYPE_CONTAINER = 4,
OBJ_TYPE_UNIT = 8,
OBJ_TYPE_PLAYER = 0x10, // what the engine's bag observer FUN_004F8DB0 passes
OBJ_TYPE_GAMEOBJECT = 0x20, // 1<<5; passed by FUN_0052AA20 (hover-tooltip populator).
// The type arg is a bitmask of object-type bits (see the TYPEMASK_*
// block below), not an enum index.
// `CGObject::GetName` — returns the display-name `const char *` for
// a resolved CGObject (CGUnit / CGPlayer / CGCreature). Internally
@@ -2850,8 +2844,11 @@ enum Offsets {
// each callback invocation, guidLo/guidHi pushed as 8 stack bytes.
FUN_CLNT_OBJ_MGR_ENUM_VISIBLE_OBJECTS = 0x00468380,
// Type-mask flags accepted by FUN_OBJECT_RESOLVE_BY_GUID. Single-bit
// flags can be OR'd together.
// Type-mask flags accepted by FUN_OBJECT_RESOLVE_BY_GUID (and the SetUnit
// path FUN_00529FE0, which passes ECX=8 for UNIT). A bitmask of
// object-type bits, not an enum index — single-bit flags OR together.
// PLAYER (0x10) is what the bag observer FUN_004F8DB0 passes; GAMEOBJECT
// (0x20) what the hover-tooltip populator FUN_0052AA20 passes.
TYPEMASK_OBJECT = 0x01,
TYPEMASK_ITEM = 0x02,
TYPEMASK_CONTAINER = 0x04,
+1 -1
View File
@@ -68,7 +68,7 @@ uint8_t *ResolveByGUID(int type, uint64_t guid) {
// bank bags (linear 63..68) — the only differences are the source of
// the bag's GUID and how the result encodes back into a location.
int WalkBagContents(uint64_t bagGuid, uint64_t targetGuid) {
auto *bag = ResolveByGUID(Offsets::OBJ_TYPE_CONTAINER, bagGuid);
auto *bag = ResolveByGUID(Offsets::TYPEMASK_CONTAINER, bagGuid);
if (bag == nullptr)
return 0;
auto *bagInvMgr =
+1 -1
View File
@@ -70,7 +70,7 @@ static int __fastcall Script_GameTooltipGetGameObject(void *L) {
if (guidLo == 0 && guidHi == 0)
return 0;
void *obj = Object::ByGuid(Offsets::OBJ_TYPE_GAMEOBJECT,
void *obj = Object::ByGuid(Offsets::TYPEMASK_GAMEOBJECT,
(static_cast<uint64_t>(guidHi) << 32) | guidLo,
"GameTooltip:GetGameObject", 0x172);
if (obj == nullptr)
+2 -2
View File
@@ -199,7 +199,7 @@ void WalkGuidArrayRange(const uint8_t *invMgr, int firstSlot, int lastSlot,
if (guidArray == nullptr)
return;
for (int slot = firstSlot; slot <= lastSlot; ++slot) {
const uint8_t *item = ResolveByGuid(Offsets::OBJ_TYPE_ITEM, guidArray[slot]);
const uint8_t *item = ResolveByGuid(Offsets::TYPEMASK_ITEM, guidArray[slot]);
if (item == nullptr)
continue;
CollectBagOrBankItem(item, candidates);
@@ -219,7 +219,7 @@ void WalkBankBags(std::vector<Candidate> &candidates) {
return;
for (int slot = Offsets::INVMGR_BANK_BAG_FIRST_SLOT;
slot <= Offsets::INVMGR_BANK_BAG_LAST_SLOT; ++slot) {
const uint8_t *bag = ResolveByGuid(Offsets::OBJ_TYPE_CONTAINER,
const uint8_t *bag = ResolveByGuid(Offsets::TYPEMASK_CONTAINER,
playerGuidArray[slot]);
if (bag == nullptr)
continue;
+2 -2
View File
@@ -119,7 +119,7 @@ int CountInGuidArray(const uint8_t *invMgr, int firstSlot, int lastSlot,
return 0;
int total = 0;
for (int slot = firstSlot; slot <= lastSlot; slot++) {
const uint8_t *item = ResolveByGuid(Offsets::OBJ_TYPE_ITEM, guidArray[slot]);
const uint8_t *item = ResolveByGuid(Offsets::TYPEMASK_ITEM, guidArray[slot]);
if (item == nullptr)
continue;
if (Item::ID::FromCGItem(item) != targetItemID)
@@ -148,7 +148,7 @@ int CountInBankBags(int targetItemID, bool includeUses) {
int total = 0;
for (int slot = Offsets::INVMGR_BANK_BAG_FIRST_SLOT;
slot <= Offsets::INVMGR_BANK_BAG_LAST_SLOT; slot++) {
const uint8_t *bag = ResolveByGuid(Offsets::OBJ_TYPE_CONTAINER,
const uint8_t *bag = ResolveByGuid(Offsets::TYPEMASK_CONTAINER,
playerGuidArray[slot]);
if (bag == nullptr)
continue;
+2 -2
View File
@@ -107,7 +107,7 @@ void *EquippedBagInventory(int bagID) {
if (bagGuid == 0)
return nullptr; // no bag equipped in that slot
auto *container = static_cast<const uint8_t *>(
Object::ByGuid(Offsets::OBJ_TYPE_CONTAINER, bagGuid, "ItemMgr", 0x172));
Object::ByGuid(Offsets::TYPEMASK_CONTAINER, bagGuid, "ItemMgr", 0x172));
return ContainerInventory(container);
}
@@ -168,7 +168,7 @@ const uint8_t *ResolveByGUID(uint64_t guid) {
if (guid == 0)
return nullptr;
return static_cast<const uint8_t *>(
Object::ByGuid(Offsets::OBJ_TYPE_ITEM, guid, "ItemMgr", 0x172));
Object::ByGuid(Offsets::TYPEMASK_ITEM, guid, "ItemMgr", 0x172));
}
bool FindByItemID(void *L, int itemID, ByGUIDResult *out) {
+1 -1
View File
@@ -70,7 +70,7 @@ const uint8_t *ResolveEquipmentSlot(int slot1Based);
int GetBagSlotCount(int bagID);
// Given a `CGContainer*` (an equipped bag or bank bag, resolved by GUID via
// `FUN_OBJECT_RESOLVE_BY_GUID` with `OBJ_TYPE_CONTAINER`), returns its own
// `FUN_OBJECT_RESOLVE_BY_GUID` with `TYPEMASK_CONTAINER`), returns its own
// inventory-manager object via the container's vtable method at
// `+OFF_CONTAINER_GET_INVENTORY`. The returned object has the same layout as
// the player inventory manager: slot count at `+0x00`, flat GUID array at
+1 -1
View File
@@ -304,7 +304,7 @@ void AppendNonBagOwned(uint64_t *out, int *count) {
return;
for (int slot = Offsets::INVMGR_BANK_BAG_FIRST_SLOT;
slot <= Offsets::INVMGR_BANK_BAG_LAST_SLOT; ++slot) {
const uint8_t *bag = ResolveByGuid(Offsets::OBJ_TYPE_CONTAINER, playerArr[slot]);
const uint8_t *bag = ResolveByGuid(Offsets::TYPEMASK_CONTAINER, playerArr[slot]);
if (bag == nullptr)
continue;
auto *bagInvMgr =
+1 -1
View File
@@ -158,7 +158,7 @@ static const uint8_t *PeekItemRecord(uint32_t itemID) {
static void *ResolveItemByGuid(uint32_t guidLo, uint32_t guidHi) {
if (guidLo == 0 && guidHi == 0)
return nullptr;
return Object::ByGuid(Offsets::OBJ_TYPE_ITEM,
return Object::ByGuid(Offsets::TYPEMASK_ITEM,
(static_cast<uint64_t>(guidHi) << 32) | guidLo,
"GameTooltip:GetItem", 0x172);
}
+1 -1
View File
@@ -129,7 +129,7 @@ static void PushNamePlateForGUID(void *L, uint64_t guid) {
return;
}
auto *unit = static_cast<uint8_t *>(
Object::ByGuid(Offsets::OBJ_TYPE_UNIT, guid, "NamePlate", 0x172));
Object::ByGuid(Offsets::TYPEMASK_UNIT, guid, "NamePlate", 0x172));
if (unit == nullptr) {
Game::Lua::PushNil(L);
return;
+1 -1
View File
@@ -23,7 +23,7 @@
namespace Object {
// Resolve `guid` to its live client object. `typeMask` is a bitmask of
// `Offsets::OBJ_TYPE_*` (e.g. `OBJ_TYPE_UNIT | OBJ_TYPE_PLAYER`, or
// `Offsets::TYPEMASK_*` (e.g. `TYPEMASK_UNIT | TYPEMASK_PLAYER`, or
// `TYPEMASK_UNIT` / `TYPEMASK_OBJECT`). Returns nullptr when the GUID isn't
// currently in the object table (out of range, despawned, pre-world).
// Non-throwing — safe from any context (Lua callback, world tick, packet
+1 -1
View File
@@ -82,7 +82,7 @@ const Event::Custom::AutoReserve _r2{kEvtDurability};
// error thrown from there unwinds through raw engine code.
bool SlotHasItem(uint32_t guidLo, uint32_t guidHi, int slot0Based) {
auto *player = static_cast<const uint8_t *>(Object::ByGuid(
Offsets::OBJ_TYPE_PLAYER,
Offsets::TYPEMASK_PLAYER,
(static_cast<uint64_t>(guidHi) << 32) | guidLo, "ClassicAPI", 0x172));
if (player == nullptr)
return false;
+1 -1
View File
@@ -105,7 +105,7 @@ bool LocationGuid(void *L, int locIdx, uint64_t *out) {
// Resolves a GUID to its currently-synced CGUnit, or null if not resident.
const uint8_t *ResolveUnit(uint64_t guid) {
return static_cast<const uint8_t *>(
Object::ByGuid(Offsets::OBJ_TYPE_UNIT, guid, "ClassicAPI", 0));
Object::ByGuid(Offsets::TYPEMASK_UNIT, guid, "ClassicAPI", 0));
}
// Reads a UNIT_FIELD_BYTES_0 byte: the login-time mirror global when `guid` is
+1 -1
View File
@@ -125,7 +125,7 @@ const uint8_t *ResolveObject(uint64_t guid) {
if (guid == 0)
return nullptr;
return static_cast<const uint8_t *>(
Object::ByGuid(Offsets::OBJ_TYPE_UNIT, guid, "Focus", 0x172));
Object::ByGuid(Offsets::TYPEMASK_UNIT, guid, "Focus", 0x172));
}
// True if `guid` is a current party or raid member. Reads the roster GUID
+1 -1
View File
@@ -109,7 +109,7 @@ const uint8_t *PlayerObject() {
if (guid == 0)
return nullptr;
return static_cast<const uint8_t *>(
Object::ByGuid(Offsets::OBJ_TYPE_PLAYER, guid, "ClassicAPI", 0));
Object::ByGuid(Offsets::TYPEMASK_PLAYER, guid, "ClassicAPI", 0));
}
const uint8_t *PlayerInventoryManager() {
+1 -1
View File
@@ -79,7 +79,7 @@ const uint8_t *ResolveObject(uint64_t guid) {
if (guid == 0)
return nullptr;
return static_cast<const uint8_t *>(
Object::ByGuid(Offsets::OBJ_TYPE_UNIT, guid, "RaidTarget", 0x172));
Object::ByGuid(Offsets::TYPEMASK_UNIT, guid, "RaidTarget", 0x172));
}
// Descriptor-field observer callback for marker slot `Idx` (0-based).
+1 -1
View File
@@ -122,7 +122,7 @@ uint64_t WalkSuffix(uint64_t guid, const char *suffix) {
return 0; // unknown suffix component — modern returns nil
suffix += kSuffixTargetLen;
auto *obj = static_cast<uint8_t *>(
Object::ByGuid(Offsets::OBJ_TYPE_UNIT, guid, "ClassicAPI",
Object::ByGuid(Offsets::TYPEMASK_UNIT, guid, "ClassicAPI",
kResolvePriority));
if (obj == nullptr)
return 0;
+1 -1
View File
@@ -81,7 +81,7 @@ static int __fastcall Script_GameTooltipSetUnitAura(void *L) {
using ObjectGetName_t = const char *(__fastcall *)(void *obj, void *edx_unused, int *outFlags);
static const char *ResolveUnitName(uint32_t guidLo, uint32_t guidHi) {
void *obj = Object::ByGuid(Offsets::OBJ_TYPE_UNIT,
void *obj = Object::ByGuid(Offsets::TYPEMASK_UNIT,
(static_cast<uint64_t>(guidHi) << 32) | guidLo,
"GameTooltip:GetUnitGUID", 0x172);
if (obj == nullptr)