summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2009-10-09 22:24:05 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:45 +0000
commita1f3d889f1eca9b3a670363dd386480ec2b48a76 (patch)
tree80452d051386e4ca98efed6d2cd6f762416b46e7 /src/server
parentd28ad7411a91881d168d45d0846adf80a579a02f (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')
-rw-r--r--src/server/server.h10
-rw-r--r--src/server/sv_client.c4
-rw-r--r--src/server/sv_game.c3
-rw-r--r--src/server/sv_init.c54
4 files changed, 57 insertions, 14 deletions
diff --git a/src/server/server.h b/src/server/server.h
index fe78026c..fca29aae 100644
--- a/src/server/server.h
+++ b/src/server/server.h
@@ -64,6 +64,13 @@ typedef enum {
SS_GAME // actively running
} serverState_t;
+typedef struct configString_s {
+ char *s;
+
+ qboolean restricted; // if true, don't send to clientList
+ clientList_t clientList;
+} configString_t;
+
typedef struct {
serverState_t state;
qboolean restarting; // if true, send configstring changes during SS_LOADING
@@ -77,7 +84,7 @@ typedef struct {
int timeResidual; // <= 1000 / sv_frame->value
int nextFrameTime; // when time > nextFrameTime, process world
struct cmodel_s *models[MAX_MODELS];
- char *configstrings[MAX_CONFIGSTRINGS];
+ configString_t configstrings[MAX_CONFIGSTRINGS];
svEntity_t svEntities[MAX_GENTITIES];
char *entityParsePoint; // used during game VM init
@@ -301,6 +308,7 @@ void SV_MasterGameStat( const char *data );
//
void SV_SetConfigstring( int index, const char *val );
void SV_GetConfigstring( int index, char *buffer, int bufferSize );
+void SV_SetConfigstringRestrictions(int index, const clientList_t* clientList);
void SV_UpdateConfigstrings( client_t *client );
void SV_SetUserinfo( int index, const char *val );
diff --git a/src/server/sv_client.c b/src/server/sv_client.c
index f164654c..319f865e 100644
--- a/src/server/sv_client.c
+++ b/src/server/sv_client.c
@@ -440,10 +440,10 @@ static void SV_SendClientGameState( client_t *client ) {
// write the configstrings
for ( start = 0 ; start < MAX_CONFIGSTRINGS ; start++ ) {
- if (sv.configstrings[start][0]) {
+ if (sv.configstrings[start].s[0]) {
MSG_WriteByte( &msg, svc_configstring );
MSG_WriteShort( &msg, start );
- MSG_WriteBigString( &msg, sv.configstrings[start] );
+ MSG_WriteBigString( &msg, sv.configstrings[start].s );
}
}
diff --git a/src/server/sv_game.c b/src/server/sv_game.c
index 1efa6d5f..2db7ee3f 100644
--- a/src/server/sv_game.c
+++ b/src/server/sv_game.c
@@ -386,6 +386,9 @@ intptr_t SV_GameSystemCalls( intptr_t *args ) {
case G_GET_CONFIGSTRING:
SV_GetConfigstring( args[1], VMA(2), args[3] );
return 0;
+ case G_SET_CONFIGSTRING_RESTRICTIONS:
+ SV_SetConfigstringRestrictions( args[1], VMA(2) );
+ return 0;
case G_SET_USERINFO:
SV_SetUserinfo( args[1], VMA(2) );
return 0;
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