mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 09:33:51 +00:00
refactor: name GUID type and LFG role constants, add why-comments
- world_packets: name kGuidTypeMask/kGuidTypePet/kGuidTypeVehicle for chat receiver GUID type detection, with why-comment explaining WoW's bits-48-63 entity type encoding and 0xF0FF mask purpose - lua_engine: name kRoleTank/kRoleHealer/kRoleDamager (0x02/0x04/0x08) for WotLK LFG role bitmask, add context on Leader bit (0x01) and source packets (SMSG_GROUP_LIST / SMSG_LFG_ROLE_CHECK_UPDATE)
This commit is contained in:
parent
ff72d23db9
commit
b39f0f3605
2 changed files with 17 additions and 6 deletions
|
|
@ -696,10 +696,14 @@ static int lua_UnitGroupRolesAssigned(lua_State* L) {
|
|||
const auto& pd = gh->getPartyData();
|
||||
for (const auto& m : pd.members) {
|
||||
if (m.guid == guid) {
|
||||
// WotLK roles bitmask: 0x02=Tank, 0x04=Healer, 0x08=DPS
|
||||
if (m.roles & 0x02) { lua_pushstring(L, "TANK"); return 1; }
|
||||
if (m.roles & 0x04) { lua_pushstring(L, "HEALER"); return 1; }
|
||||
if (m.roles & 0x08) { lua_pushstring(L, "DAMAGER"); return 1; }
|
||||
// WotLK LFG roles bitmask (from SMSG_GROUP_LIST / SMSG_LFG_ROLE_CHECK_UPDATE).
|
||||
// Bit 0x01 = Leader (not a combat role), 0x02 = Tank, 0x04 = Healer, 0x08 = DPS.
|
||||
constexpr uint8_t kRoleTank = 0x02;
|
||||
constexpr uint8_t kRoleHealer = 0x04;
|
||||
constexpr uint8_t kRoleDamager = 0x08;
|
||||
if (m.roles & kRoleTank) { lua_pushstring(L, "TANK"); return 1; }
|
||||
if (m.roles & kRoleHealer) { lua_pushstring(L, "HEALER"); return 1; }
|
||||
if (m.roles & kRoleDamager) { lua_pushstring(L, "DAMAGER"); return 1; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1579,10 +1579,17 @@ bool MessageChatParser::parse(network::Packet& packet, MessageChatData& data) {
|
|||
// Read receiver GUID (NamedGuid: guid + optional name for non-player targets)
|
||||
data.receiverGuid = packet.readUInt64();
|
||||
if (data.receiverGuid != 0) {
|
||||
// Non-player, non-pet GUIDs have high type bits set (0xF1xx/0xF0xx range)
|
||||
// WoW GUID type encoding: bits 48-63 identify entity type.
|
||||
// Players have highGuid=0x0000. Pets use 0xF040 (active pet) or
|
||||
// 0xF014 (creature treated as pet). Mask 0xF0FF isolates the type
|
||||
// nibbles while ignoring the server-specific middle bits.
|
||||
constexpr uint16_t kGuidTypeMask = 0xF0FF;
|
||||
constexpr uint16_t kGuidTypePet = 0xF040;
|
||||
constexpr uint16_t kGuidTypeVehicle = 0xF014;
|
||||
uint16_t highGuid = static_cast<uint16_t>(data.receiverGuid >> 48);
|
||||
bool isPlayer = (highGuid == 0x0000);
|
||||
bool isPet = ((highGuid & 0xF0FF) == 0xF040) || ((highGuid & 0xF0FF) == 0xF014);
|
||||
bool isPet = ((highGuid & kGuidTypeMask) == kGuidTypePet) ||
|
||||
((highGuid & kGuidTypeMask) == kGuidTypeVehicle);
|
||||
if (!isPlayer && !isPet) {
|
||||
// Read receiver name (SizedCString)
|
||||
uint32_t recvNameLen = packet.readUInt32();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue