10 #include "../Scoreboard.h"
17 m_ScoreBoard(a_ScoreBoard)
43 catch (
const std::exception & Oops)
45 LOGWARNING(
"Failed to load scoreboard from \"%s\": %s",
m_Path.c_str(), Oops.what());
102 for (cObjective::cScoreMap::const_iterator it2 = Objective.
m_Scores.begin(); it2 != Objective.
m_Scores.end(); ++it2)
106 a_Writer.
AddInt(
"Score", it2->second);
109 a_Writer.
AddString(
"Objective", it->first);
121 const cTeam & Team = it->second;
136 for (cTeam::cPlayerNameSet::const_iterator it2 = Team.
m_Players.begin(); it2 != Team.
m_Players.end(); ++it2)
151 a_Writer.
AddString(
"slot_0", (Objective ==
nullptr) ?
"" : Objective->
GetName());
154 a_Writer.
AddString(
"slot_1", (Objective ==
nullptr) ?
"" : Objective->
GetName());
157 a_Writer.
AddString(
"slot_2", (Objective ==
nullptr) ?
"" : Objective->
GetName());
184 AString CriteriaName, DisplayName, Name;
189 CriteriaName = a_NBT.
GetString(CurrLine);
210 if (PlayerScores < 0)
224 Score = a_NBT.
GetInt(CurrLine);
236 ObjectiveName = a_NBT.
GetString(CurrLine);
255 AString Name, DisplayName, Prefix, Suffix;
257 bool AllowsFriendlyFire =
true, CanSeeFriendlyInvisible =
false;
286 AllowsFriendlyFire = (a_NBT.
GetInt(CurrLine) != 0);
292 CanSeeFriendlyInvisible = (a_NBT.
GetInt(CurrLine) != 0);
313 if (DisplaySlots < 0)
void LOGWARNING(std::string_view a_Format, const Args &... args)
void Write(const std::string &a_FileName, ContiguousByteBufferView a_Contents)
Writes a_Contents into file, compressing it along the way.
Compression::Result ReadRestOfFile(const std::string &a_FileName)
Reads the rest of the file and returns the decompressed contents.
static bool CreateFolder(const AString &a_FolderPath)
Creates a new folder with the specified name.
static char PathSeparator()
static eType StringToType(const AString &a_Name)
eType GetType(void) const
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)
const AString & GetDisplayName(void) const
const AString & GetDisplayName(void) const
const AString & GetPrefix(void) const
bool CanSeeFriendlyInvisible(void) const
void SetCanSeeFriendlyInvisible(bool a_Flag)
const AString & GetSuffix(void) const
bool AllowsFriendlyFire(void) const
void SetFriendlyFire(bool a_Flag)
bool AddPlayer(const AString &a_Name)
Adds a new player to the team.
cObjective * GetObjective(const AString &a_Name)
Retrieves the objective with the specified name, nullptr if not found.
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.
cObjectiveMap m_Objectives
cObjective * GetObjectiveIn(eDisplaySlot a_Slot)
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)
Parses and contains the parsed data Also implements data accessor functions for tree traversal and va...
int GetNextSibling(int a_Tag) const
Returns the next sibling of the specified tag, or -1 if none.
int GetFirstChild(int a_Tag) const
Returns the first child of the specified tag, or -1 if none / not applicable.
eTagType GetType(int a_Tag) const
int FindChildByName(int a_Tag, const AString &a_Name) const
Returns the direct child tag of the specified name, or -1 if no such tag.
Int32 GetInt(int a_Tag) const
Returns the value stored in an Int tag.
AString GetString(int a_Tag) const
Returns the value stored in a String tag.
void AddByte(const AString &a_Name, unsigned char a_Value)
void AddInt(const AString &a_Name, Int32 a_Value)
void AddString(const AString &a_Name, std::string_view a_Value)
void BeginList(const AString &a_Name, eTagType a_ChildrenType)
void BeginCompound(const AString &a_Name)
ContiguousByteBufferView GetResult(void) const
cScoreboard * m_ScoreBoard
cScoreboardSerializer(const AString &a_WorldName, cScoreboard *a_ScoreBoard)
bool Load(void)
Try to load the scoreboard.
bool Save(void)
Try to save the scoreboard.
void SaveScoreboardToNBT(cFastNBTWriter &a_Writer)
bool LoadScoreboardFromNBT(const cParsedNBT &a_NBT)