feat: cache player class/race from name queries for UnitClass/UnitRace

Add playerClassRaceCache_ that stores classId and raceId from
SMSG_NAME_QUERY_RESPONSE. This enables UnitClass and UnitRace to return
correct data for players who were previously seen but are now out of
UPDATE_OBJECT range.

Fallback chain for UnitClass/UnitRace is now:
1. Entity update fields (UNIT_FIELD_BYTES_0) — for nearby entities
2. Name query cache — for previously queried players
3. getPlayerClass/Race() — for the local player

This improves class-colored names in chat, unit frames, and nameplates
for players who move out of view range.
This commit is contained in:
Kelsi 2026-03-21 04:11:48 -07:00
parent d6a25ca8f2
commit cfb9e09e1d
3 changed files with 21 additions and 7 deletions

View file

@ -14819,6 +14819,10 @@ void GameHandler::handleNameQueryResponse(network::Packet& packet) {
if (data.isValid()) {
playerNameCache[data.guid] = data.name;
// Cache class/race from name query for UnitClass/UnitRace fallback
if (data.classId != 0 || data.race != 0) {
playerClassRaceCache_[data.guid] = {data.classId, data.race};
}
// Update entity name
auto entity = entityManager.getEntity(data.guid);
if (entity && entity->getType() == ObjectType::PLAYER) {