MCPcopy Create free account
hub / github.com/assaultcube/AC / parsemessages

Function parsemessages

source/src/clients2c.cpp:260–1399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258int srvgamesalt;
259
260void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false)
261{
262 static char text[MAXTRANS];
263 int type, joining = 0;
264
265 while(p.remaining())
266 {
267 type = getint(p);
268
269 #ifdef _DEBUG
270 if(type!=SV_POS && type!=SV_CLIENTPING && type!=SV_PING && type!=SV_PONG && type!=SV_CLIENT)
271 {
272 DEBUGVAR(cn);
273 ASSERT(type>=0 && type<SV_NUM);
274 DEBUGVAR(messagenames[type]);
275 protocoldebug(DEBUGCOND);
276 }
277 else protocoldebug(false);
278 #endif
279
280 switch(type)
281 {
282 case SV_SERVINFO: // welcome message from the server
283 {
284 string tmp1, tmp2;
285 session_s *s = &session;
286 memset(s, 0, sizeof(session_s));
287
288 s->cn = getint(p);
289 int prot = getint(p);
290 if(prot!=CUR_PROTOCOL_VERSION && !(watchingdemo && prot == -PROTOCOL_VERSION))
291 {
292 conoutf("\f3incompatible game protocol (local protocol: %d :: server protocol: %d)", CUR_PROTOCOL_VERSION, prot);
293 conoutf("\f3if this occurs a lot, obtain an upgrade from \f1http://assault.cubers.net");
294 if(watchingdemo) conoutf("breaking loop : \f3this demo is using a different protocol\f5 : end it now!"); // SVN-WiP-bug: causes endless retry loop else!
295 else disconnect();
296 return;
297 }
298 int req_auth = getint(p);
299 if(!sk && req_auth)
300 {
301 conoutf("\f3server requires a valid game account to connect");
302 conoutf("\f3please authenticate or create a new game account");
303 disconnect();
304 return;
305 }
306 if(getint(p) > 0) conoutf("INFO: this server is password protected");
307 sessionid = getint(p); // salt
308 s->serverip = getip4(p);
309 s->clientip = getip4(p);
310 s->clientipcensored = getip4(p);
311 s->serverclock = getint(p);
312 char cc[3] = { (char)getint(p), (char)getint(p), 0 };
313 filtercountrycode(cc, cc);
314 p.get(s->serverpubkey, 32);
315 entropy_get((uchar *)&(s->clientsalt), sizeof(int));
316 s->clientclock = (int) (time(NULL) / (time_t) 60);
317 int clockoffset = s->serverclock - s->clientclock;

Callers 2

receivefileFunction · 0.85
servertoclientFunction · 0.85

Calls 15

getintFunction · 0.85
protocoldebugFunction · 0.85
disconnectFunction · 0.85
getip4Function · 0.85
filtercountrycodeFunction · 0.85
entropy_getFunction · 0.85
iabsFunction · 0.85
clientlogfFunction · 0.85
iptoaFunction · 0.85
concatformatstringFunction · 0.85
bin2hexFunction · 0.85
ed25519_signFunction · 0.85

Tested by

no test coverage detected