/* =============== SV_UpdateConfigstrings Called when a client goes from CS_PRIMED to CS_ACTIVE. Updates all Configstring indexes that have changed while the client was in CS_PRIMED =============== */ void SV_UpdateConfigstrings(client_t *client) { int index; for( index = 0; index <= MAX_CONFIGSTRINGS; index++ ) { // if the CS hasn't changed since we went to CS_PRIMED, ignore if(!client->csUpdated[index]) continue; SV_SendConfigstring(client, index); client->csUpdated[index] = qfalse; } }
/* =============== SV_SetConfigstring =============== */ void SV_SetConfigstring( int index, const char *val ) { int i; client_t *client; if ( index < 0 || index >= MAX_CONFIGSTRINGS ) { Com_Error (ERR_DROP, "SV_SetConfigstring: bad index %i", index); } if ( !val ) { val = ""; } // don't bother broadcasting an update if no change if ( !strcmp( val, sv.configstrings[ index ] ) ) { return; } // change the string in sv Z_Free( sv.configstrings[index] ); sv.configstrings[index] = CopyString( val ); // send it to all the clients if we aren't // spawning a new server if ( sv.state == SS_GAME || sv.restarting ) { // SV_SendServerCommand( NULL, "cs %i \"%s\"\n", index, val ); // send the data to all relevent clients for ( i = 0, client = svs.clients; i < sv_maxclients->integer ; i++, client++ ) { if ( client->state < CS_ACTIVE ) { if ( client->state == CS_PRIMED ) client->csUpdated[ index ] = qtrue; continue; } // do not always send server info to all clients if ( index == CS_SERVERINFO && client->gentity && ( client->gentity->r.svFlags & SVF_NOSERVERINFO ) ) { continue; } // RF, don't send to bot/AI if ( sv_gametype->integer == GT_SINGLE_PLAYER && client->gentity && ( client->gentity->r.svFlags & SVF_CASTAI ) ) { continue; } // SV_SendServerCommand( client, "cs %i \"%s\"\n", index, val ); SV_SendConfigstring(client, index); } } }
/* =============== SV_SetConfigstringRestrictions =============== */ void SV_SetConfigstringRestrictions (int index, const clientList_t* clientList) { int i; clientList_t oldClientList = sv.configstrings[index].clientList; sv.configstrings[index].clientList = *clientList; sv.configstrings[index].restricted = qtrue; for ( i = 0 ; i < sv_maxclients->integer ; i++ ) { if ( svs.clients[i].state >= CS_CONNECTED ) { if ( Com_ClientListContains( &oldClientList, i ) != Com_ClientListContains( clientList, i ) ) { // A client has left or joined the restricted list, so update SV_SendConfigstring(&svs.clients[i], index); } } } }
// Called when a client goes from CS_PRIMED to CS_ACTIVE. // Updates all configstring indexes that have changed while the client was in CS_PRIMED void SV_UpdateConfigstrings(client_t *client) { int index; for( index = 0; index <= MAX_CONFIGSTRINGS; index++ ) { // if the CS hasn't changed since we went to CS_PRIMED, ignore if(!client->csUpdated[index]) continue; // do not always send server info to all clients if ( index == CS_SERVERINFO && client->gentity && (client->gentity->r.svFlags & SVF_NOSERVERINFO) ) { continue; } SV_SendConfigstring(client, index); client->csUpdated[index] = qfalse; } }
/* =============== SV_SetConfigstring =============== */ void SV_SetConfigstring( int index, const char* val ) { int i; client_t* client; if ( index < 0 || index >= MAX_CONFIGSTRINGS ) { Com_Error( ERR_DROP, "SV_SetConfigstring: bad index %i", index ); } if ( !val ) { val = ""; } // don't bother broadcasting an update if no change if ( !strcmp( val, sv.configstrings[ index ] ) ) { return; } // change the string in sv free( sv.configstrings[index] ); sv.configstrings[index] = strdup( val ); // send it to all the clients if we aren't // spawning a new server if ( sv.state == SS_GAME || sv.restarting ) { // send the data to all relevent clients for ( i = 0, client = svs.clients; i < sv_maxclients->integer ; i++, client++ ) { if ( client->state < CS_ACTIVE ) { if ( client->state == CS_PRIMED ) client->csUpdated[ index ] = true; continue; } SV_SendConfigstring( client, index ); } } }