|
group2 0.1.0
CSE 125 Group 2
|
Replicated player display name. More...
#include <PlayerName.hpp>
Public Member Functions | |
| void | set (const char *src) |
| Copy a NUL-terminated source into the bounded buffer. | |
| const char * | c_str () const |
| Read the name as a C string. Always NUL-terminated. | |
| bool | empty () const |
| Whether this nickname slot has any text in it. | |
Public Attributes | |
| std::array< char, k_maxLen+1 > | name {} |
| NUL-terminated UTF-8. All zeros = unset. | |
| bool | isCustom = false |
| True once the player picks their own name. | |
Static Public Attributes | |
| static constexpr std::size_t | k_maxLen = 23 |
Replicated player display name.
Server picks an unused entry from player_nicknames::k_nicknames on connect and stores it here. Clients read it for the kill feed, scoreboard, world-space enemy bars, death cards, etc., so players always see human-friendly handles ("WOLF kills FOX") instead of raw Player #3 style fallbacks.
isCustom is reserved for the future "user sets their own nickname" flow: when true the server preserves the buffer instead of re-rolling on respawn / reconnect, and the auto-assigner skips this player.
Stored as a fixed-size buffer so the component stays trivially copyable — the existing OutputArchive / InputArchive only handle trivially-copyable types, so a std::string field would not replicate. Names are clamped to k_maxLen chars + NUL.
|
inlinenodiscard |
Read the name as a C string. Always NUL-terminated.
|
inlinenodiscard |
Whether this nickname slot has any text in it.
|
inline |
Copy a NUL-terminated source into the bounded buffer.
Truncates silently and always writes a terminating NUL.
| bool PlayerName::isCustom = false |
True once the player picks their own name.
|
staticconstexpr |
| std::array<char, k_maxLen + 1> PlayerName::name {} |
NUL-terminated UTF-8. All zeros = unset.