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

Method SendSaveCode

src/game/server/gamecontext.cpp:4854–4958  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4852}
4853
4854void CGameContext::SendSaveCode(int Team, int TeamSize, int State, const char *pError, const char *pSaveRequester, const char *pServerName, const char *pGeneratedCode, const char *pCode)
4855{
4856 char aBuf[512];
4857
4858 CMsgPacker Msg(NETMSGTYPE_SV_SAVECODE);
4859 Msg.AddInt(State);
4860 Msg.AddString(pError);
4861 Msg.AddString(pSaveRequester);
4862 Msg.AddString(pServerName);
4863 Msg.AddString(pGeneratedCode);
4864 Msg.AddString(pCode);
4865 char aTeamMembers[1024];
4866 aTeamMembers[0] = '\0';
4867 int NumMembersSent = 0;
4868 for(int MemberId = 0; MemberId < MAX_CLIENTS; MemberId++)
4869 {
4870 if(!m_apPlayers[MemberId])
4871 continue;
4872 if(GetDDRaceTeam(MemberId) != Team)
4873 continue;
4874 if(NumMembersSent++ > 10)
4875 {
4876 str_format(aBuf, sizeof(aBuf), " and %d others", (TeamSize - NumMembersSent) + 1);
4877 str_append(aTeamMembers, aBuf);
4878 break;
4879 }
4880
4881 if(NumMembersSent > 1)
4882 str_append(aTeamMembers, ", ");
4883 str_append(aTeamMembers, Server()->ClientName(MemberId));
4884 }
4885 Msg.AddString(aTeamMembers);
4886
4887 for(int MemberId = 0; MemberId < MAX_CLIENTS; MemberId++)
4888 {
4889 if(!m_apPlayers[MemberId])
4890 continue;
4891 if(GetDDRaceTeam(MemberId) != Team)
4892 continue;
4893
4894 if(GetClientVersion(MemberId) >= VERSION_DDNET_SAVE_CODE)
4895 {
4896 Server()->SendMsg(&Msg, MSGFLAG_VITAL, MemberId);
4897 }
4898 else
4899 {
4900 switch(State)
4901 {
4902 case SAVESTATE_PENDING:
4903 if(pCode[0] == '\0')
4904 {
4905 str_format(aBuf,
4906 sizeof(aBuf),
4907 "Team save in progress. You'll be able to load with '/load %s'",
4908 pGeneratedCode);
4909 }
4910 else
4911 {

Callers 2

ProcessSaveTeamMethod · 0.80
SaveTeamMethod · 0.80

Calls 9

str_formatFunction · 0.85
str_compFunction · 0.85
AddIntMethod · 0.80
ClientNameMethod · 0.80
str_appendFunction · 0.50
ServerClass · 0.50
str_copyFunction · 0.50
AddStringMethod · 0.45
SendMsgMethod · 0.45

Tested by

no test coverage detected