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

Method OnUpdatePlayerServerInfo

src/game/server/gamecontext.cpp:5385–5442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5383}
5384
5385void CGameContext::OnUpdatePlayerServerInfo(CJsonWriter *pJsonWriter, int ClientId)
5386{
5387 if(!m_apPlayers[ClientId])
5388 return;
5389
5390 CTeeInfo &TeeInfo = m_apPlayers[ClientId]->m_TeeInfos;
5391
5392 pJsonWriter->WriteAttribute("skin");
5393 pJsonWriter->BeginObject();
5394
5395 // 0.6
5396 if(!Server()->IsSixup(ClientId))
5397 {
5398 pJsonWriter->WriteAttribute("name");
5399 pJsonWriter->WriteStrValue(TeeInfo.m_aSkinName);
5400
5401 if(TeeInfo.m_UseCustomColor)
5402 {
5403 pJsonWriter->WriteAttribute("color_body");
5404 pJsonWriter->WriteIntValue(TeeInfo.m_ColorBody);
5405
5406 pJsonWriter->WriteAttribute("color_feet");
5407 pJsonWriter->WriteIntValue(TeeInfo.m_ColorFeet);
5408 }
5409 }
5410 // 0.7
5411 else
5412 {
5413 const char *apPartNames[protocol7::NUM_SKINPARTS] = {"body", "marking", "decoration", "hands", "feet", "eyes"};
5414
5415 for(int i = 0; i < protocol7::NUM_SKINPARTS; ++i)
5416 {
5417 pJsonWriter->WriteAttribute(apPartNames[i]);
5418 pJsonWriter->BeginObject();
5419
5420 pJsonWriter->WriteAttribute("name");
5421 pJsonWriter->WriteStrValue(TeeInfo.m_aaSkinPartNames[i]);
5422
5423 if(TeeInfo.m_aUseCustomColors[i])
5424 {
5425 pJsonWriter->WriteAttribute("color");
5426 pJsonWriter->WriteIntValue(TeeInfo.m_aSkinPartColors[i]);
5427 }
5428
5429 pJsonWriter->EndObject();
5430 }
5431 }
5432
5433 pJsonWriter->EndObject();
5434
5435 pJsonWriter->WriteAttribute("afk");
5436 pJsonWriter->WriteBoolValue(m_apPlayers[ClientId]->IsAfk());
5437
5438 const int Team = m_pController->IsTeamPlay() ? m_apPlayers[ClientId]->GetTeam() : (m_apPlayers[ClientId]->GetTeam() == TEAM_SPECTATORS ? -1 : GetDDRaceTeam(ClientId));
5439
5440 pJsonWriter->WriteAttribute("team");
5441 pJsonWriter->WriteIntValue(Team);
5442}

Callers 1

Calls 11

WriteAttributeMethod · 0.80
BeginObjectMethod · 0.80
WriteStrValueMethod · 0.80
WriteIntValueMethod · 0.80
EndObjectMethod · 0.80
WriteBoolValueMethod · 0.80
GetTeamMethod · 0.80
ServerClass · 0.50
IsSixupMethod · 0.45
IsAfkMethod · 0.45
IsTeamPlayMethod · 0.45

Tested by

no test coverage detected