MCPcopy Create free account
hub / github.com/JACoders/OpenJK / SVC_Status

Function SVC_Status

code/server/sv_main.cpp:176–214  ·  view source on GitHub ↗

================ SVC_Status Responds with all the info that qplug or qspy can see about the server and all connected players. Used for getting detailed information after the simple info query. ================ */

Source from the content-addressed store, hash-verified

174================
175*/
176void SVC_Status( netadr_t from ) {
177 char player[1024];
178 char status[MAX_MSGLEN];
179 int i;
180 client_t *cl;
181 int statusLength;
182 int playerLength;
183 int score;
184 char infostring[MAX_INFO_STRING];
185
186 strcpy( infostring, Cvar_InfoString( CVAR_SERVERINFO ) );
187
188 // echo back the parameter to status. so servers can use it as a challenge
189 // to prevent timed spoofed reply packets that add ghost servers
190 Info_SetValueForKey( infostring, "challenge", Cmd_Argv(1) );
191
192 status[0] = 0;
193 statusLength = 0;
194
195 for (i=0 ; i < 1 ; i++) {
196 cl = &svs.clients[i];
197 if ( cl->state >= CS_CONNECTED ) {
198 if ( cl->gentity && cl->gentity->client ) {
199 score = cl->gentity->client->persistant[PERS_SCORE];
200 } else {
201 score = 0;
202 }
203 Com_sprintf( player, sizeof( player ), "%i %i \"%s\"\n", score, cl->name );
204 playerLength = strlen(player);
205 if (statusLength + playerLength >= (int)sizeof(status) ) {
206 break; // can't hold any more
207 }
208 strcpy (status + statusLength, player);
209 statusLength += playerLength;
210 }
211 }
212
213 NET_OutOfBandPrint( NS_SERVER, from, "statusResponse\n%s\n%s", infostring, status );
214}
215
216/*
217================

Callers 1

SV_ConnectionlessPacketFunction · 0.70

Calls 5

Cvar_InfoStringFunction · 0.50
Info_SetValueForKeyFunction · 0.50
Cmd_ArgvFunction · 0.50
Com_sprintfFunction · 0.50
NET_OutOfBandPrintFunction · 0.50

Tested by

no test coverage detected