Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Types | Public Member Functions | Private Types | Private Attributes | Friends | List of all members
cScoreboard Class Reference

#include <Scoreboard.h>

Collaboration diagram for cScoreboard:
Collaboration graph
[legend]

Public Types

enum  eDisplaySlot { dsList = 0 , dsSidebar , dsName , dsCount }
 

Public Member Functions

void AddPlayerScore (const AString &a_Name, cObjective::eType a_Type, cObjective::Score a_Value=1)
 
 cScoreboard (cWorld *a_World)
 
bool ForEachObjective (cObjectiveCallback a_Callback)
 Execute callback for each objective. More...
 
bool ForEachObjectiveWith (cObjective::eType a_Type, cObjectiveCallback a_Callback)
 Execute callback for each objective with the specified type Returns true if all objectives processed, false if the callback aborted by returning true. More...
 
bool ForEachTeam (cTeamCallback a_Callback)
 Execute callback for each team. More...
 
size_t GetNumObjectives (void) const
 
size_t GetNumTeams (void) const
 
cObjectiveGetObjective (const AString &a_Name)
 Retrieves the objective with the specified name, nullptr if not found. More...
 
cObjectiveGetObjectiveIn (eDisplaySlot a_Slot)
 
cTeamGetTeam (const AString &a_Name)
 Retrieves the team with the specified name, nullptr if not found. More...
 
AStringVector GetTeamNames ()
 Retrieves the list of team names. More...
 
cTeamQueryPlayerTeam (const AString &a_Name)
 
cObjectiveRegisterObjective (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. More...
 
cTeamRegisterTeam (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. More...
 
bool RemoveObjective (const AString &a_Name)
 Removes a registered objective, returns true if operation was successful. More...
 
bool RemoveTeam (const AString &a_Name)
 Removes a registered team, returns true if operation was successful. More...
 
void SendTo (cClientHandle &a_Client)
 Send this scoreboard to the specified client. More...
 
void SetDisplay (cObjective *a_Objective, eDisplaySlot a_Slot)
 
void SetDisplay (const AString &a_Objective, eDisplaySlot a_Slot)
 

Private Types

typedef std::pair< AString, cObjectivecNamedObjective
 
typedef std::pair< AString, cTeamcNamedTeam
 
typedef std::map< AString, cObjectivecObjectiveMap
 
typedef std::map< AString, cTeamcTeamMap
 

Private Attributes

cCriticalSection m_CSObjectives
 
cCriticalSection m_CSTeams
 
cObjectivem_Display [dsCount]
 
cObjectiveMap m_Objectives
 
cTeamMap m_Teams
 
cWorldm_World
 

Friends

class cScoreboardSerializer
 

Detailed Description

Definition at line 199 of file Scoreboard.h.

Member Typedef Documentation

◆ cNamedObjective

typedef std::pair<AString, cObjective> cScoreboard::cNamedObjective
private

Definition at line 276 of file Scoreboard.h.

◆ cNamedTeam

typedef std::pair<AString, cTeam> cScoreboard::cNamedTeam
private

Definition at line 277 of file Scoreboard.h.

◆ cObjectiveMap

typedef std::map<AString, cObjective> cScoreboard::cObjectiveMap
private

Definition at line 279 of file Scoreboard.h.

◆ cTeamMap

typedef std::map<AString, cTeam> cScoreboard::cTeamMap
private

Definition at line 280 of file Scoreboard.h.

Member Enumeration Documentation

◆ eDisplaySlot

Enumerator
dsList 
dsSidebar 
dsName 
dsCount 

Definition at line 203 of file Scoreboard.h.

Constructor & Destructor Documentation

◆ cScoreboard()

cScoreboard::cScoreboard ( cWorld a_World)

Definition at line 273 of file Scoreboard.cpp.

Member Function Documentation

◆ AddPlayerScore()

void cScoreboard::AddPlayerScore ( const AString a_Name,
cObjective::eType  a_Type,
cObjective::Score  a_Value = 1 
)

Definition at line 550 of file Scoreboard.cpp.

◆ ForEachObjective()

bool cScoreboard::ForEachObjective ( cObjectiveCallback  a_Callback)

Execute callback for each objective.

Returns true if all objectives have been processed, false if the callback aborted by returning true.

Definition at line 512 of file Scoreboard.cpp.

◆ ForEachObjectiveWith()

bool cScoreboard::ForEachObjectiveWith ( cObjective::eType  a_Type,
cObjectiveCallback  a_Callback 
)

Execute callback for each objective with the specified type Returns true if all objectives processed, false if the callback aborted by returning true.

Definition at line 490 of file Scoreboard.cpp.

◆ ForEachTeam()

bool cScoreboard::ForEachTeam ( cTeamCallback  a_Callback)

Execute callback for each team.

Returns true if all teams have been processed, false if the callback aborted by returning true.

Definition at line 531 of file Scoreboard.cpp.

◆ GetNumObjectives()

size_t cScoreboard::GetNumObjectives ( void  ) const

Definition at line 592 of file Scoreboard.cpp.

◆ GetNumTeams()

size_t cScoreboard::GetNumTeams ( void  ) const

Definition at line 601 of file Scoreboard.cpp.

◆ GetObjective()

cObjective * cScoreboard::GetObjective ( const AString a_Name)

Retrieves the objective with the specified name, nullptr if not found.

Definition at line 339 of file Scoreboard.cpp.

◆ GetObjectiveIn()

cObjective * cScoreboard::GetObjectiveIn ( eDisplaySlot  a_Slot)

Definition at line 479 of file Scoreboard.cpp.

◆ GetTeam()

cTeam * cScoreboard::GetTeam ( const AString a_Name)

Retrieves the team with the specified name, nullptr if not found.

Definition at line 399 of file Scoreboard.cpp.

◆ GetTeamNames()

AStringVector cScoreboard::GetTeamNames ( )

Retrieves the list of team names.

Definition at line 419 of file Scoreboard.cpp.

◆ QueryPlayerTeam()

cTeam * cScoreboard::QueryPlayerTeam ( const AString a_Name)

Definition at line 435 of file Scoreboard.cpp.

◆ RegisterObjective()

cObjective * cScoreboard::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.

Definition at line 285 of file Scoreboard.cpp.

◆ RegisterTeam()

cTeam * cScoreboard::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.

Definition at line 359 of file Scoreboard.cpp.

◆ RemoveObjective()

bool cScoreboard::RemoveObjective ( const AString a_Name)

Removes a registered objective, returns true if operation was successful.

Definition at line 308 of file Scoreboard.cpp.

◆ RemoveTeam()

bool cScoreboard::RemoveTeam ( const AString a_Name)

Removes a registered team, returns true if operation was successful.

Definition at line 379 of file Scoreboard.cpp.

◆ SendTo()

void cScoreboard::SendTo ( cClientHandle a_Client)

Send this scoreboard to the specified client.

Definition at line 567 of file Scoreboard.cpp.

◆ SetDisplay() [1/2]

void cScoreboard::SetDisplay ( cObjective a_Objective,
eDisplaySlot  a_Slot 
)

Definition at line 467 of file Scoreboard.cpp.

◆ SetDisplay() [2/2]

void cScoreboard::SetDisplay ( const AString a_Objective,
eDisplaySlot  a_Slot 
)

Definition at line 454 of file Scoreboard.cpp.

Friends And Related Function Documentation

◆ cScoreboardSerializer

friend class cScoreboardSerializer
friend

Definition at line 293 of file Scoreboard.h.

Member Data Documentation

◆ m_CSObjectives

cCriticalSection cScoreboard::m_CSObjectives
private

Definition at line 283 of file Scoreboard.h.

◆ m_CSTeams

cCriticalSection cScoreboard::m_CSTeams
private

Definition at line 286 of file Scoreboard.h.

◆ m_Display

cObjective* cScoreboard::m_Display[dsCount]
private

Definition at line 291 of file Scoreboard.h.

◆ m_Objectives

cObjectiveMap cScoreboard::m_Objectives
private

Definition at line 284 of file Scoreboard.h.

◆ m_Teams

cTeamMap cScoreboard::m_Teams
private

Definition at line 287 of file Scoreboard.h.

◆ m_World

cWorld* cScoreboard::m_World
private

Definition at line 289 of file Scoreboard.h.


The documentation for this class was generated from the following files: