feat: show guild names on player nameplates

Read PLAYER_GUILDID from entity update fields (UNIT_END + 3) and query
guild names via CMSG_GUILD_QUERY. Cache results in guildNameCache_ so
each guild ID is queried only once. Display <Guild Name> in grey below
the player name on nameplates. Fix handleGuildQueryResponse to not
overwrite the local player's guild data when querying other guilds.
This commit is contained in:
Kelsi 2026-03-18 09:44:43 -07:00
parent 003ad8b20c
commit e572cdfb4a
3 changed files with 76 additions and 11 deletions

View file

@ -608,6 +608,13 @@ public:
uint32_t getPetitionCost() const { return petitionCost_; }
uint64_t getPetitionNpcGuid() const { return petitionNpcGuid_; }
// Guild name lookup for other players' nameplates
// Returns the guild name for a given guildId, or empty if unknown.
// Automatically queries the server for unknown guild IDs.
const std::string& lookupGuildName(uint32_t guildId);
// Returns the guildId for a player entity (from PLAYER_GUILDID update field).
uint32_t getEntityGuildId(uint64_t guid) const;
// Ready check
struct ReadyCheckResult {
std::string name;
@ -2952,6 +2959,8 @@ private:
GuildInfoData guildInfoData_;
GuildQueryResponseData guildQueryData_;
bool hasGuildRoster_ = false;
std::unordered_map<uint32_t, std::string> guildNameCache_; // guildId → guild name
std::unordered_set<uint32_t> pendingGuildNameQueries_; // in-flight guild queries
bool pendingGuildInvite_ = false;
std::string pendingGuildInviterName_;
std::string pendingGuildInviteGuildName_;