MCPcopy Create free account
hub / github.com/crossuo/crossuo / ParsePacket

Method ParsePacket

src/ServerList.cpp:46–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void CServerList::ParsePacket(CDataReader &reader)
47{
48 m_Servers.clear();
49 g_ServerList.LastServerIndex = 0;
50
51 reader.Move(1);
52
53 uint16_t numServers = reader.ReadUInt16BE();
54
55 if (numServers == 0)
56 {
57 Warning(Network, "empty server list");
58 }
59
60 for (uint16_t i = 0; i < numServers; i++)
61 {
62 uint16_t id = reader.ReadUInt16BE();
63 auto name = reader.ReadString(32);
64 uint8_t fullPercent = reader.ReadUInt8();
65 uint8_t timezoneType = reader.ReadUInt8();
66 uint32_t ip = reader.ReadUInt32LE(); //little-endian!!!
67
68 const bool selected = (name == g_ServerList.LastServerName);
69 if (selected)
70 {
71 g_ServerList.LastServerIndex = (int)i;
72 }
73 m_Servers.push_back(CServer(id, name, fullPercent, timezoneType, ip, selected));
74
75#if USE_PING
76 if (!g_DisablePing)
77 {
78 char ipString[30] = { 0 };
79 sprintf_s(
80 ipString,
81 "%i.%i.%i.%i",
82 (ip >> 24) & 0xFF,
83 (ip >> 16) & 0xFF,
84 (ip >> 8) & 0xFF,
85 ip & 0xFF);
86 CPingThread *pingThread = new CPingThread(i, ipString, 100);
87 pingThread->Run();
88 }
89#endif // USE_PING
90 }
91
92 if (g_ServerList.LastServerIndex < numServers && g_MainScreen.m_AutoLogin->Checked)
93 {
94 g_Game.ServerSelection(g_ServerList.LastServerIndex);
95 }
96 else
97 {
98 g_Game.InitScreen(GS_SERVER);
99 }
100
101 g_ServerScreen.UpdateContent();
102}
103

Callers 1

PACKET_HANDLERFunction · 0.80

Calls 12

CServerClass · 0.85
ReadUInt16BEMethod · 0.80
ReadStringMethod · 0.80
ReadUInt8Method · 0.80
ReadUInt32LEMethod · 0.80
ServerSelectionMethod · 0.80
InitScreenMethod · 0.80
clearMethod · 0.45
MoveMethod · 0.45
push_backMethod · 0.45
RunMethod · 0.45
UpdateContentMethod · 0.45

Tested by

no test coverage detected