MCPcopy Index your code
hub / github.com/assaultcube/AC / welcomepacket

Function welcomepacket

source/src/server.cpp:2920–2993  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2918}
2919
2920void welcomepacket(packetbuf &p, int n)
2921{
2922 if(!sg->smapname[0]) maprot.next(false);
2923
2924 client *c = valid_client(n) ? clients[n] : NULL;
2925 int numcl = numclients();
2926
2927 putint(p, SV_WELCOME);
2928 putint(p, sg->smapname[0] && !m_demo ? numcl : -1);
2929 if(sg->smapname[0] && !m_demo)
2930 {
2931 putint(p, SV_MAPCHANGE);
2932 sendstring(sg->smapname, p);
2933 putint(p, sg->smode);
2934 putint(p, sg->curmap && sg->curmap->isdistributable() ? sg->curmap->cgzlen : 0);
2935 putint(p, sg->curmap && sg->curmap->isdistributable() ? sg->curmap->maprevision : 0);
2936 putint(p, sg->srvgamesalt);
2937 if(sg->smode>1 || (sg->smode==0 && numnonlocalclients()>0))
2938 {
2939 putint(p, SV_TIMEUP);
2940 putint(p, (sg->gamemillis>=sg->gamelimit || sg->forceintermission) ? sg->gamelimit : sg->gamemillis);
2941 putint(p, sg->gamelimit);
2942 //putint(p, sg->minremain*60);
2943 }
2944 send_item_list(p); // this includes the flags
2945 }
2946 savedscore *sc = NULL;
2947 if(c)
2948 {
2949 if(c->type == ST_TCPIP && serveroperator() != -1) sendserveropinfo(n);
2950 c->team = sg->mastermode == MM_MATCH && sc ? team_tospec(sc->team) : TEAM_SPECT;
2951 putint(p, SV_SETTEAM);
2952 putint(p, n);
2953 putint(p, c->team | (FTR_INFO << 4));
2954
2955 putint(p, SV_FORCEDEATH);
2956 putint(p, n);
2957 sendf(-1, 1, "ri2x", SV_FORCEDEATH, n, n);
2958 }
2959 if(!c || clients.length()>1)
2960 {
2961 putint(p, SV_RESUME);
2962 loopv(clients)
2963 {
2964 client &c = *clients[i];
2965 if(c.type!=ST_TCPIP || c.clientnum==n) continue;
2966 putint(p, c.clientnum);
2967 putint(p, c.state.state);
2968 putint(p, c.state.lifesequence);
2969 putint(p, c.state.primary);
2970 putint(p, c.state.gunselect);
2971 putint(p, c.state.flagscore);
2972 putint(p, c.state.frags);
2973 putint(p, c.state.deaths);
2974 putint(p, c.state.health);
2975 putint(p, c.state.armour);
2976 putint(p, c.state.teamkills);
2977 loopi(NUMGUNS) putint(p, c.state.ammo[i]);

Callers 2

setupdemorecordFunction · 0.85
sendwelcomeFunction · 0.85

Calls 15

valid_clientFunction · 0.85
numclientsFunction · 0.85
putintFunction · 0.85
sendstringFunction · 0.85
numnonlocalclientsFunction · 0.85
send_item_listFunction · 0.85
serveroperatorFunction · 0.85
sendserveropinfoFunction · 0.85
sendfFunction · 0.85
welcomeinitclientFunction · 0.85
sendservermodeFunction · 0.85
nextMethod · 0.80

Tested by

no test coverage detected