group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
PlayerName Struct Reference

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

Detailed Description

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.

Member Function Documentation

◆ c_str()

const char * PlayerName::c_str ( ) const
inlinenodiscard

Read the name as a C string. Always NUL-terminated.

◆ empty()

bool PlayerName::empty ( ) const
inlinenodiscard

Whether this nickname slot has any text in it.

◆ set()

void PlayerName::set ( const char * src)
inline

Copy a NUL-terminated source into the bounded buffer.

Truncates silently and always writes a terminating NUL.

Here is the caller graph for this function:

Member Data Documentation

◆ isCustom

bool PlayerName::isCustom = false

True once the player picks their own name.

◆ k_maxLen

std::size_t PlayerName::k_maxLen = 23
staticconstexpr

◆ name

std::array<char, k_maxLen + 1> PlayerName::name {}

NUL-terminated UTF-8. All zeros = unset.


The documentation for this struct was generated from the following file: