MCPcopy Create free account
hub / github.com/cuberite/cuberite / SaveScoreboardToNBT

Method SaveScoreboardToNBT

src/WorldStorage/ScoreboardSerializer.cpp:100–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98
99
100void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer)
101{
102 a_Writer.BeginCompound("data");
103
104 a_Writer.BeginList("Objectives", TAG_Compound);
105
106 for (cScoreboard::cObjectiveMap::const_iterator it = m_ScoreBoard->m_Objectives.begin(); it != m_ScoreBoard->m_Objectives.end(); ++it)
107 {
108 const cObjective & Objective = it->second;
109
110 a_Writer.BeginCompound("");
111
112 a_Writer.AddString("CriteriaName", cObjective::TypeToString(Objective.GetType()));
113
114 a_Writer.AddString("DisplayName", Objective.GetDisplayName());
115 a_Writer.AddString("Name", it->first);
116
117 a_Writer.EndCompound();
118 }
119
120 a_Writer.EndList(); // Objectives
121
122 a_Writer.BeginList("PlayerScores", TAG_Compound);
123
124 for (cScoreboard::cObjectiveMap::const_iterator it = m_ScoreBoard->m_Objectives.begin(); it != m_ScoreBoard->m_Objectives.end(); ++it)
125 {
126 const cObjective & Objective = it->second;
127
128 for (cObjective::cScoreMap::const_iterator it2 = Objective.m_Scores.begin(); it2 != Objective.m_Scores.end(); ++it2)
129 {
130 a_Writer.BeginCompound("");
131
132 a_Writer.AddInt("Score", it2->second);
133
134 a_Writer.AddString("Name", it2->first);
135 a_Writer.AddString("Objective", it->first);
136
137 a_Writer.EndCompound();
138 }
139 }
140
141 a_Writer.EndList(); // PlayerScores
142
143 a_Writer.BeginList("Teams", TAG_Compound);
144
145 for (cScoreboard::cTeamMap::const_iterator it = m_ScoreBoard->m_Teams.begin(); it != m_ScoreBoard->m_Teams.end(); ++it)
146 {
147 const cTeam & Team = it->second;
148
149 a_Writer.BeginCompound("");
150
151 a_Writer.AddByte("AllowFriendlyFire", Team.AllowsFriendlyFire() ? 1 : 0);
152 a_Writer.AddByte("SeeFriendlyInvisibles", Team.CanSeeFriendlyInvisible() ? 1 : 0);
153
154 a_Writer.AddString("DisplayName", Team.GetDisplayName());
155 a_Writer.AddString("Name", it->first);
156
157 a_Writer.AddString("Prefix", Team.GetPrefix());

Callers

nothing calls this directly

Calls 14

BeginCompoundMethod · 0.80
BeginListMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
AddStringMethod · 0.80
EndCompoundMethod · 0.80
EndListMethod · 0.80
AddIntMethod · 0.80
AddByteMethod · 0.80
AllowsFriendlyFireMethod · 0.80
GetObjectiveInMethod · 0.80

Tested by

no test coverage detected