fix: show real player names on nameplates instead of "Player"

Player class declared its own 'name' member and getName()/setName()
that shadowed the inherited Unit::name. Since getName() is non-virtual,
code using Unit* pointers (nameplates, target frame, entity list) read
Unit::name (always empty) while Player::setName() wrote to the shadowed
Player::name. Removed the redundant declaration so Player inherits
name storage from Unit.
This commit is contained in:
Kelsi 2026-03-18 08:49:16 -07:00
parent 100d66d18b
commit 1af5acba3f

View file

@ -284,18 +284,14 @@ protected:
/**
* Player entity
* Name is inherited from Unit do NOT redeclare it here or the
* shadowed field will diverge from Unit::name, causing nameplates
* and other Unit*-based lookups to read an empty string.
*/
class Player : public Unit {
public:
Player() { type = ObjectType::PLAYER; }
explicit Player(uint64_t guid) : Unit(guid) { type = ObjectType::PLAYER; }
// Name
const std::string& getName() const { return name; }
void setName(const std::string& n) { name = n; }
protected:
std::string name;
};
/**