26 case otStat:
return "stat";
63 for (
size_t i = 0; i <
ARRAYCOUNT(TypeMap); i++)
67 return TypeMap[i].m_Type;
78 : m_DisplayName(a_DisplayName)
105 cScoreMap::const_iterator it =
m_Scores.find(a_Name);
186 for (cScoreMap::const_iterator it =
m_Scores.begin(); it !=
m_Scores.end(); ++it)
200 : m_AllowsFriendlyFire(true)
201 , m_CanSeeFriendlyInvisible(false)
202 , m_DisplayName(a_DisplayName)
233 cPlayerNameSet::const_iterator it =
m_Players.find(a_Name);
275 for (
int i = 0; i < static_cast<int>(
dsCount); ++i)
296 return &Status.first->second;
322 for (
unsigned int i = 0; i < static_cast<unsigned int>(
dsCount); ++i)
364 auto [TeamIterator, TeamExists] =
m_Teams.try_emplace(a_Name, a_Name, a_DisplayName, a_Prefix, a_Suffix);
366 if (!TeamExists &&
GetTeam(a_Name))
368 LOGWARNING(
"Tried to register a team that already exists: %s", a_Name.c_str());
372 return &TeamIterator->second;
383 cTeamMap::iterator it =
m_Teams.find(a_Name);
403 cTeamMap::iterator it =
m_Teams.find(a_Name);
423 for (
const auto & Team:
m_Teams)
425 TeamNames.push_back(Team.first);
439 for (cTeamMap::iterator it =
m_Teams.begin(); it !=
m_Teams.end(); ++it)
441 if (it->second.HasPlayer(a_Name))
496 if (it->second.GetType() == a_Type)
499 if (a_Callback(it->second))
519 if (a_Callback(it->second))
535 for (cTeamMap::iterator it =
m_Teams.begin(); it !=
m_Teams.end(); ++it)
538 if (a_Callback(it->second))
556 if (it->second.GetType() == a_Type)
558 it->second.AddScore(a_Name, a_Value);
573 it->second.SendTo(a_Client);
576 for (
int i = 0; i < static_cast<int>(
dsCount); ++i)
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
void LOGWARNING(std::string_view a_Format, const Args &... args)
int NoCaseCompare(const AString &s1, const AString &s2)
Case-insensitive string comparison.
std::vector< AString > AStringVector
void SendScoreboardObjective(const AString &a_Name, const AString &a_DisplayName, Byte a_Mode)
void SendScoreUpdate(const AString &a_Objective, const AString &a_Player, cObjective::Score a_Score, Byte a_Mode)
void SendDisplayObjective(const AString &a_Objective, cScoreboard::eDisplaySlot a_Display)
RAII for cCriticalSection - locks the CS on creation, unlocks on destruction.
Score AddScore(const AString &a_Name, Score a_Delta)
Adds a_Delta and returns the new score.
void SetDisplayName(const AString &a_Name)
static eType StringToType(const AString &a_Name)
void Reset(void)
Resets the objective.
cObjective(const AString &a_Name, const AString &a_DisplayName, eType a_Type, cWorld *a_World)
void SetScore(const AString &a_Name, Score a_Score)
Sets the score of the specified player.
const AString & GetName(void) const
static AString TypeToString(eType a_Type)
Score SubScore(const AString &a_Name, Score a_Delta)
Subtracts a_Delta and returns the new score.
void ResetScore(const AString &a_Name)
Resets the score of the specified player.
Score GetScore(const AString &a_Name) const
Returns the score of the specified player.
void SendTo(cClientHandle &a_Client)
Send this objective to the specified client.
size_t GetNumPlayers(void) const
Returns the number of registered players.
cTeam(const AString &a_Name, const AString &a_DisplayName, const AString &a_Prefix, const AString &a_Suffix)
void SetDisplayName(const AString &a_Name)
void Reset(void)
Removes all registered players.
bool HasPlayer(const AString &a_Name) const
Returns whether the specified player is in this team.
bool RemovePlayer(const AString &a_Name)
Removes a player from the team.
bool AddPlayer(const AString &a_Name)
Adds a new player to the team.
size_t GetNumObjectives(void) const
cObjective * GetObjective(const AString &a_Name)
Retrieves the objective with the specified name, nullptr if not found.
AStringVector GetTeamNames()
Retrieves the list of team names.
cTeam * RegisterTeam(const AString &a_Name, const AString &a_DisplayName, const AString &a_Prefix, const AString &a_Suffix)
Registers a new team, returns the cTeam instance, nullptr on name collision.
cTeam * QueryPlayerTeam(const AString &a_Name)
size_t GetNumTeams(void) const
cObjectiveMap m_Objectives
cObjective * GetObjectiveIn(eDisplaySlot a_Slot)
bool ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallback a_Callback)
Execute callback for each objective with the specified type Returns true if all objectives processed,...
cTeam * GetTeam(const AString &a_Name)
Retrieves the team with the specified name, nullptr if not found.
bool ForEachTeam(cTeamCallback a_Callback)
Execute callback for each team.
void AddPlayerScore(const AString &a_Name, cObjective::eType a_Type, cObjective::Score a_Value=1)
void SendTo(cClientHandle &a_Client)
Send this scoreboard to the specified client.
cCriticalSection m_CSObjectives
cObjective * m_Display[dsCount]
cScoreboard(cWorld *a_World)
cObjective * RegisterObjective(const AString &a_Name, const AString &a_DisplayName, cObjective::eType a_Type)
Registers a new scoreboard objective, returns the cObjective instance, nullptr on name collision.
void SetDisplay(const AString &a_Objective, eDisplaySlot a_Slot)
bool ForEachObjective(cObjectiveCallback a_Callback)
Execute callback for each objective.
std::pair< AString, cObjective > cNamedObjective
bool RemoveObjective(const AString &a_Name)
Removes a registered objective, returns true if operation was successful.
bool RemoveTeam(const AString &a_Name)
Removes a registered team, returns true if operation was successful.
cCriticalSection m_CSTeams
virtual void BroadcastScoreboardObjective(const AString &a_Name, const AString &a_DisplayName, Byte a_Mode) override
virtual void BroadcastScoreUpdate(const AString &a_Objective, const AString &a_Player, cObjective::Score a_Score, Byte a_Mode) override
virtual void BroadcastDisplayObjective(const AString &a_Objective, cScoreboard::eDisplaySlot a_Display) override