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

Method TranslateSysMsg

src/engine/client/sixup_translate_system.cpp:3–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include <engine/client/client.h>
2
3int CClient::TranslateSysMsg(int *pMsgId, bool System, CUnpacker *pUnpacker, CPacker *pPacker, CNetChunk *pPacket, bool *pIsExMsg)
4{
5 *pIsExMsg = false;
6 if(!System)
7 return -1;
8
9 // ddnet ex
10 if(*pMsgId > NETMSG_WHATIS && *pMsgId < NETMSG_RCON_CMD_GROUP_END)
11 {
12 *pIsExMsg = true;
13 return 0;
14 }
15
16 pPacker->Reset();
17
18 if(*pMsgId == protocol7::NETMSG_MAP_CHANGE)
19 {
20 *pMsgId = NETMSG_MAP_CHANGE;
21 const char *pMapName = pUnpacker->GetString(CUnpacker::SANITIZE_CC | CUnpacker::SKIP_START_WHITESPACES);
22 int MapCrc = pUnpacker->GetInt();
23 int Size = pUnpacker->GetInt();
24 m_TranslationContext.m_MapDownloadChunksPerRequest = pUnpacker->GetInt();
25 int ChunkSize = pUnpacker->GetInt();
26 // void *pSha256 = pUnpacker->GetRaw(); // probably safe to ignore
27 pPacker->AddString(pMapName, 0);
28 pPacker->AddInt(MapCrc);
29 pPacker->AddInt(Size);
30 m_TranslationContext.m_MapdownloadTotalsize = Size;
31 m_TranslationContext.m_MapDownloadChunkSize = ChunkSize;
32 return 0;
33 }
34 else if(*pMsgId == protocol7::NETMSG_SERVERINFO)
35 {
36 // side effect only
37 // this is a 0.7 only message and not handled in 0.6 code
38 *pMsgId = -1;
39 net_addr_str(&pPacket->m_Address, m_CurrentServerInfo.m_aAddress, sizeof(m_CurrentServerInfo.m_aAddress), true);
40 str_copy(m_CurrentServerInfo.m_aVersion, pUnpacker->GetString(CUnpacker::SANITIZE_CC | CUnpacker::SKIP_START_WHITESPACES));
41 str_copy(m_CurrentServerInfo.m_aName, pUnpacker->GetString(CUnpacker::SANITIZE_CC | CUnpacker::SKIP_START_WHITESPACES));
42 str_clean_whitespaces(m_CurrentServerInfo.m_aName);
43 pUnpacker->GetString(CUnpacker::SANITIZE_CC | CUnpacker::SKIP_START_WHITESPACES); // Hostname
44 str_copy(m_CurrentServerInfo.m_aMap, pUnpacker->GetString(CUnpacker::SANITIZE_CC | CUnpacker::SKIP_START_WHITESPACES));
45 str_copy(m_CurrentServerInfo.m_aGameType, pUnpacker->GetString(CUnpacker::SANITIZE_CC | CUnpacker::SKIP_START_WHITESPACES));
46 int Flags = pUnpacker->GetInt();
47 if(Flags & SERVER_FLAG_PASSWORD)
48 m_CurrentServerInfo.m_Flags |= SERVER_FLAG_PASSWORD;
49 // ddnets http master server handles timescore for us already
50 // if(Flags&SERVER_FLAG_TIMESCORE)
51 // m_CurrentServerInfo.m_Flags |= SERVER_FLAG_TIMESCORE;
52 pUnpacker->GetInt(); // Server level
53 m_CurrentServerInfo.m_NumPlayers = pUnpacker->GetInt();
54 m_CurrentServerInfo.m_MaxPlayers = pUnpacker->GetInt();
55 m_CurrentServerInfo.m_NumClients = pUnpacker->GetInt();
56 m_CurrentServerInfo.m_MaxClients = pUnpacker->GetInt();
57 return 0;
58 }
59 else if(*pMsgId == protocol7::NETMSG_RCON_AUTH_ON)
60 {

Callers

nothing calls this directly

Calls 9

net_addr_strFunction · 0.85
str_clean_whitespacesFunction · 0.85
dbg_msgFunction · 0.85
AddIntMethod · 0.80
str_copyFunction · 0.50
ResetMethod · 0.45
GetStringMethod · 0.45
GetIntMethod · 0.45
AddStringMethod · 0.45

Tested by

no test coverage detected