diff options
author | Tim Angus <tim@ngus.net> | 2009-10-09 22:24:05 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:45 +0000 |
commit | a1f3d889f1eca9b3a670363dd386480ec2b48a76 (patch) | |
tree | 80452d051386e4ca98efed6d2cd6f762416b46e7 /src/server/sv_init.c | |
parent | d28ad7411a91881d168d45d0846adf80a579a02f (diff) |
* (bug #3836) Add [SV|trap]_SetConfigstringRestrictions which prevents some
clients receiving a config string
* Move BG_ClientList* to Com_ClientList*
* Split CS_STAGES into CS_ALIEN_STAGES and CS_HUMAN_STAGES
Diffstat (limited to 'src/server/sv_init.c')
-rw-r--r-- | src/server/sv_init.c | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/src/server/sv_init.c b/src/server/sv_init.c index 34ced5c5..0de275ce 100644 --- a/src/server/sv_init.c +++ b/src/server/sv_init.c @@ -37,7 +37,14 @@ static void SV_SendConfigstring(client_t *client, int index) int maxChunkSize = MAX_STRING_CHARS - 24; int len; - len = strlen(sv.configstrings[index]); + if( sv.configstrings[index].restricted && Com_ClientListContains( + &sv.configstrings[index].clientList, client->gentity->s.number ) ) { + // Send a blank config string for this client if it's listed + SV_SendServerCommand( client, "cs %i \"\"\n", index ); + return; + } + + len = strlen(sv.configstrings[index].s); if( len >= maxChunkSize ) { int sent = 0; @@ -55,7 +62,7 @@ static void SV_SendConfigstring(client_t *client, int index) else { cmd = "bcs1"; } - Q_strncpyz( buf, &sv.configstrings[index][sent], + Q_strncpyz( buf, &sv.configstrings[index].s[sent], maxChunkSize ); SV_SendServerCommand( client, "%s %i \"%s\"\n", cmd, @@ -67,7 +74,7 @@ static void SV_SendConfigstring(client_t *client, int index) } else { // standard cs, just send it SV_SendServerCommand( client, "cs %i \"%s\"\n", index, - sv.configstrings[index] ); + sv.configstrings[index].s ); } } @@ -117,13 +124,13 @@ void SV_SetConfigstring (int index, const char *val) { } // don't bother broadcasting an update if no change - if ( !strcmp( val, sv.configstrings[ index ] ) ) { + if ( !strcmp( val, sv.configstrings[ index ].s ) ) { return; } // change the string in sv - Z_Free( sv.configstrings[index] ); - sv.configstrings[index] = CopyString( val ); + Z_Free( sv.configstrings[index].s ); + sv.configstrings[index].s = CopyString( val ); // send it to all the clients if we aren't // spawning a new server @@ -159,12 +166,35 @@ void SV_GetConfigstring( int index, char *buffer, int bufferSize ) { if ( index < 0 || index >= MAX_CONFIGSTRINGS ) { Com_Error (ERR_DROP, "SV_GetConfigstring: bad index %i\n", index); } - if ( !sv.configstrings[index] ) { + if ( !sv.configstrings[index].s ) { buffer[0] = 0; return; } - Q_strncpyz( buffer, sv.configstrings[index], bufferSize ); + Q_strncpyz( buffer, sv.configstrings[index].s, bufferSize ); +} + +/* +=============== +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); + } + } + } } @@ -366,8 +396,8 @@ static void SV_ClearServer(void) { int i; for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { - if ( sv.configstrings[i] ) { - Z_Free( sv.configstrings[i] ); + if ( sv.configstrings[i].s ) { + Z_Free( sv.configstrings[i].s ); } } Com_Memset (&sv, 0, sizeof(sv)); @@ -461,7 +491,9 @@ void SV_SpawnServer( char *server, qboolean killBots ) { // wipe the entire per-level structure SV_ClearServer(); for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { - sv.configstrings[i] = CopyString(""); + sv.configstrings[i].s = CopyString(""); + sv.configstrings[i].restricted = qfalse; + Com_Memset(&sv.configstrings[i].clientList, 0, sizeof(clientList_t)); } // make sure we are not paused |