MCPcopy Create free account
hub / github.com/ddnet/ddnet / LoadDDNetInfoJson

Method LoadDDNetInfoJson

src/engine/client/serverbrowser.cpp:1383–1411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1381}
1382
1383void CServerBrowser::LoadDDNetInfoJson()
1384{
1385 void *pBuf;
1386 unsigned Length;
1387 if(!m_pStorage->ReadFile(DDNET_INFO_FILE, IStorage::TYPE_SAVE, &pBuf, &Length))
1388 {
1389 // Keep old info if available
1390 return;
1391 }
1392
1393 m_DDNetInfoSha256 = sha256(pBuf, Length);
1394
1395 json_value_free(m_pDDNetInfo);
1396 json_settings JsonSettings{};
1397 char aError[256];
1398 m_pDDNetInfo = json_parse_ex(&JsonSettings, static_cast<json_char *>(pBuf), Length, aError);
1399 free(pBuf);
1400
1401 if(m_pDDNetInfo == nullptr)
1402 {
1403 log_error("serverbrowser", "invalid info json: '%s'", aError);
1404 }
1405 else if(m_pDDNetInfo->type != json_object)
1406 {
1407 log_error("serverbrowser", "invalid info root");
1408 json_value_free(m_pDDNetInfo);
1409 m_pDDNetInfo = nullptr;
1410 }
1411}
1412
1413void CServerBrowser::LoadDDNetLocation()
1414{

Callers

nothing calls this directly

Calls 4

sha256Function · 0.85
json_value_freeFunction · 0.85
json_parse_exFunction · 0.85
ReadFileMethod · 0.80

Tested by

no test coverage detected