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

Method LoadScoreboardFromNBT

src/WorldStorage/ScoreboardSerializer.cpp:194–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192
193
194bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
195{
196 int Data = a_NBT.FindChildByName(0, "data");
197 if (Data < 0)
198 {
199 return false;
200 }
201
202 int Objectives = a_NBT.FindChildByName(Data, "Objectives");
203 if (Objectives < 0)
204 {
205 return false;
206 }
207
208 for (int Child = a_NBT.GetFirstChild(Objectives); Child >= 0; Child = a_NBT.GetNextSibling(Child))
209 {
210 AString CriteriaName, DisplayName, Name;
211
212 int CurrLine = a_NBT.FindChildByName(Child, "CriteriaName");
213 if (CurrLine >= 0)
214 {
215 CriteriaName = a_NBT.GetString(CurrLine);
216 }
217
218 CurrLine = a_NBT.FindChildByName(Child, "DisplayName");
219 if (CurrLine >= 0)
220 {
221 DisplayName = a_NBT.GetString(CurrLine);
222 }
223
224 CurrLine = a_NBT.FindChildByName(Child, "Name");
225 if (CurrLine >= 0)
226 {
227 Name = a_NBT.GetString(CurrLine);
228 }
229
230 cObjective::eType Type = cObjective::StringToType(CriteriaName);
231
232 m_ScoreBoard->RegisterObjective(Name, DisplayName, Type);
233 }
234
235 int PlayerScores = a_NBT.FindChildByName(Data, "PlayerScores");
236 if (PlayerScores < 0)
237 {
238 return false;
239 }
240
241 for (int Child = a_NBT.GetFirstChild(PlayerScores); Child >= 0; Child = a_NBT.GetNextSibling(Child))
242 {
243 AString Name, ObjectiveName;
244
245 cObjective::Score Score = 0;
246
247 int CurrLine = a_NBT.FindChildByName(Child, "Score");
248 if (CurrLine >= 0)
249 {
250 Score = a_NBT.GetInt(CurrLine);
251 }

Callers

nothing calls this directly

Calls 13

GetFirstChildMethod · 0.80
GetNextSiblingMethod · 0.80
GetStringMethod · 0.80
RegisterObjectiveMethod · 0.80
GetIntMethod · 0.80
GetObjectiveMethod · 0.80
SetScoreMethod · 0.80
RegisterTeamMethod · 0.80
SetFriendlyFireMethod · 0.80
SetDisplayMethod · 0.80
FindChildByNameMethod · 0.45

Tested by

no test coverage detected