bool CslGameAssaultCube::ParseDefaultPong(ucharbuf& buf, CslServerInfo& info) const { wxInt32 i, l, q; char text[MAXSTRLEN]; bool wasfull=info.IsFull(); if ((wxUint32)getint(buf)!=m_fourcc) return false; q=getint(buf); if (q==AC_EXTPING_SERVERINFO) loopi(2) getint(buf); info.Protocol=getint(buf); info.Version=GetVersionName(info.Protocol); wxInt32 mode=getint(buf); info.GameMode=GetModeName(mode); i=getint(buf); if (info.HasRegisteredEvent(CslServerEvents::EVENT_EMPTY) && info.Players>0 && !i) info.SetEvents(CslServerEvents::EVENT_EMPTY); else if (info.HasRegisteredEvent(CslServerEvents::EVENT_NOT_EMPTY) && !info.Players && i>0) info.SetEvents(CslServerEvents::EVENT_NOT_EMPTY); info.Players=i; info.TimeRemain=max(0, getint(buf)); if (info.Protocol<1126) // <= 0.93 info.TimeRemain++; if (info.Protocol>=1200) // <= 1.2.0.x info.TimeRemain*=60; getstring(text, buf); info.Map=C2U(FilterCubeString(text, 1)); getstring(text, buf); info.SetDescription(C2U(FilterCubeString(text, 1))); info.PlayersMax=getint(buf); if (info.HasRegisteredEvent(CslServerEvents::EVENT_FULL) && !wasfull && info.IsFull()) info.SetEvents(CslServerEvents::EVENT_FULL); else if (info.HasRegisteredEvent(CslServerEvents::EVENT_NOT_FULL) && wasfull && !info.IsFull()) info.SetEvents(CslServerEvents::EVENT_NOT_FULL); l=info.MM; info.MMDescription.Empty(); info.MM=CSL_SERVER_OPEN; if (info.Protocol>=1128 && buf.remaining()) // >=1.0.x { i = getint(buf); wxInt32 mm = i>>PONGFLAG_MASTERMODE; if (mm==1) { if (info.HasRegisteredEvent(CslServerEvents::EVENT_PRIVATE) && CSL_MM_IS_VALID(l) && !CSL_SERVER_IS_PRIVATE(l)) info.SetEvents(CslServerEvents::EVENT_PRIVATE); info.MMDescription=wxT("P"); info.MM=CSL_SERVER_PRIVATE; } else if (mm==2) { if (info.HasRegisteredEvent(CslServerEvents::EVENT_LOCKED) && CSL_MM_IS_VALID(l) && !CSL_SERVER_IS_LOCKED(l)) info.SetEvents(CslServerEvents::EVENT_LOCKED); info.MMDescription=wxT("L"); info.MM=CSL_SERVER_LOCKED; } else info.MMDescription=wxT("O"); if (i&(1<<PONGFLAG_BANNED)) { info.MMDescription<<wxT("/BAN"); CSL_FLAG_SET(info.MM, CSL_SERVER_BAN); } if (i&(1<<PONGFLAG_BLACKLIST)) { info.MMDescription<<wxT("/BLACK"); CSL_FLAG_SET(info.MM, CSL_SERVER_BLACKLIST); } if (i&(1<<PONGFLAG_PASSWORD)) { info.MMDescription<<wxT("/PASS"); CSL_FLAG_SET(info.MM, CSL_SERVER_PASSWORD); } if (buf.remaining() && getint(buf)==q) // >=1.0.2 { switch (q) { case AC_EXTPING_SERVERINFO: // >=1.0.4 { if (getstring(text, buf)==2) { i=0; info.InfoText.Empty(); while (buf.remaining()) { getstring(text, buf); if (!*text) break; if (i++) info.InfoText<<CSL_NEWLINE_WX; if (strcmp(text, ".")) info.InfoText<<C2U(FilterCubeString(text, 1, true, false, true)); } } break; } default: break; } } }
bool CslGameRedEclipse::ParseDefaultPong(ucharbuf& buf,CslServerInfo& info) const { vector<int>attr; wxUint32 l,numattr; char text[_MAXDEFSTR]; bool wasfull=info.IsFull(); l=getint(buf); if (info.HasRegisteredEvent(CslServerEvents::EVENT_EMPTY) && info.Players>0 && !l) info.SetEvents(CslServerEvents::EVENT_EMPTY); else if (info.HasRegisteredEvent(CslServerEvents::EVENT_NOT_EMPTY) && !info.Players && l>0) info.SetEvents(CslServerEvents::EVENT_NOT_EMPTY); info.Players=l; numattr=getint(buf); loopj(numattr) attr.add(getint(buf)); if (numattr>=1) { info.Protocol=attr[0]; info.Version=GetVersionName(info.Protocol); } if (numattr>=2) info.GameMode=GetModeName(attr[1],attr[2]); if (numattr>=4) info.TimeRemain=attr[3]; if (numattr>=5) { info.PlayersMax=attr[4]; if (info.HasRegisteredEvent(CslServerEvents::EVENT_FULL) && !wasfull && info.IsFull()) info.SetEvents(CslServerEvents::EVENT_FULL); else if (info.HasRegisteredEvent(CslServerEvents::EVENT_NOT_FULL) && wasfull && !info.IsFull()) info.SetEvents(CslServerEvents::EVENT_NOT_FULL); } l=info.MM; info.MM=CSL_SERVER_OPEN; info.MMDescription.Empty(); if (numattr>=6) { if (attr[5]==MM_PASSWORD) { info.MMDescription<<wxT("PASS"); info.MM|=CSL_SERVER_PASSWORD; } else { info.MMDescription=wxString::Format(wxT("%d"),attr[5]); if (attr[5]==MM_OPEN) info.MMDescription<<wxT(" (O)"); else if (attr[5]==MM_VETO) { info.MMDescription<<wxT(" (V)"); info.MM=CSL_SERVER_VETO; } else if (attr[5]==MM_LOCKED) { if (info.HasRegisteredEvent(CslServerEvents::EVENT_LOCKED) && CSL_MM_IS_VALID(l) && !CSL_SERVER_IS_LOCKED(l)) info.SetEvents(CslServerEvents::EVENT_LOCKED); info.MMDescription<<wxT(" (L)"); info.MM=CSL_SERVER_LOCKED; } else if (attr[5]==MM_PRIVATE) { if (info.HasRegisteredEvent(CslServerEvents::EVENT_PRIVATE) && CSL_MM_IS_VALID(l) && !CSL_SERVER_IS_PRIVATE(l)) info.SetEvents(CslServerEvents::EVENT_PRIVATE); info.MMDescription<<wxT(" (P)"); info.MM=CSL_SERVER_PRIVATE; } } } getstring(text,buf); info.Map=A2U(text); getstring(text,buf); l=(wxInt32)strlen(text); FixString(text,&l,1); info.SetDescription(A2U(text)); return !buf.overread(); }