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

Method OnSaveCodeNetMessage

src/game/client/gameclient.cpp:5169–5240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5167}
5168
5169void CGameClient::OnSaveCodeNetMessage(const CNetMsg_Sv_SaveCode *pMsg)
5170{
5171 char aBuf[512];
5172 if(pMsg->m_pError[0] != '\0')
5173 m_Chat.AddLine(-1, TEAM_ALL, pMsg->m_pError);
5174
5175 int State = pMsg->m_State;
5176 if(State == SAVESTATE_PENDING)
5177 {
5178 if(pMsg->m_pCode[0] == '\0')
5179 {
5180 str_format(aBuf, sizeof(aBuf),
5181 Localize("Team save in progress. You'll be able to load with '/load %s'"),
5182 pMsg->m_pGeneratedCode);
5183 }
5184 else
5185 {
5186 str_format(aBuf, sizeof(aBuf),
5187 Localize("Team save in progress. You'll be able to load with '/load %s' if save is successful or with '/load %s' if it fails"),
5188 pMsg->m_pCode,
5189 pMsg->m_pGeneratedCode);
5190 }
5191 m_Chat.AddLine(-1, TEAM_ALL, aBuf);
5192 }
5193 else if(State == SAVESTATE_DONE)
5194 {
5195 if(pMsg->m_pServerName[0] == '\0')
5196 {
5197 str_format(aBuf, sizeof(aBuf),
5198 "Team successfully saved by %s. Use '/load %s' to continue",
5199 pMsg->m_pSaveRequester,
5200 pMsg->m_pCode[0] ? pMsg->m_pCode : pMsg->m_pGeneratedCode);
5201 }
5202 else
5203 {
5204 str_format(aBuf, sizeof(aBuf),
5205 "Team successfully saved by %s. Use '/load %s' on %s to continue",
5206 pMsg->m_pSaveRequester,
5207 pMsg->m_pCode[0] ? pMsg->m_pCode : pMsg->m_pGeneratedCode,
5208 pMsg->m_pServerName);
5209 }
5210 m_Chat.AddLine(-1, TEAM_ALL, aBuf);
5211 }
5212 else if(State == SAVESTATE_FALLBACKFILE)
5213 {
5214 if(pMsg->m_pServerName[0] == '\0')
5215 {
5216 str_format(aBuf, sizeof(aBuf),
5217 Localize("Team successfully saved by %s. The database connection failed, using generated save code instead to avoid collisions. Use '/load %s' to continue"),
5218 pMsg->m_pSaveRequester,
5219 pMsg->m_pGeneratedCode);
5220 }
5221 else
5222 {
5223 str_format(aBuf, sizeof(aBuf),
5224 Localize("Team successfully saved by %s. The database connection failed, using generated save code instead to avoid collisions. Use '/load %s' on %s to continue"),
5225 pMsg->m_pSaveRequester,
5226 pMsg->m_pGeneratedCode,

Callers

nothing calls this directly

Calls 5

str_formatFunction · 0.85
LocalizeFunction · 0.85
AddLineMethod · 0.80
ClientFunction · 0.50
StateMethod · 0.45

Tested by

no test coverage detected