mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
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:
parent
100d66d18b
commit
1af5acba3f
1 changed files with 3 additions and 7 deletions
|
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue