summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2006-11-28 23:46:04 +0000
committerTim Angus <tim@ngus.net>2006-11-28 23:46:04 +0000
commit92905745a71578eed267f25311d7a18d49976f6d (patch)
tree5836f0a4424b938c6782190ec9c28c6be808f389 /src/server
parent6af24abf02f1d0dedc5dbe655a37d5afc9f0646a (diff)
* Merge ioq3-989
Diffstat (limited to 'src/server')
-rw-r--r--src/server/server.h2
-rw-r--r--src/server/sv_client.c13
-rw-r--r--src/server/sv_init.c112
-rw-r--r--src/server/sv_main.c26
-rw-r--r--src/server/sv_snapshot.c17
5 files changed, 123 insertions, 47 deletions
diff --git a/src/server/server.h b/src/server/server.h
index fd49da7b..4d73038e 100644
--- a/src/server/server.h
+++ b/src/server/server.h
@@ -169,6 +169,7 @@ typedef struct client_s {
netchan_buffer_t **netchan_end_queue;
int oldServerTime;
+ qboolean csUpdated[MAX_CONFIGSTRINGS+1];
} client_t;
//=============================================================================
@@ -272,6 +273,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_UpdateConfigstrings( client_t *client );
void SV_SetUserinfo( int index, const char *val );
void SV_GetUserinfo( int index, char *buffer, int bufferSize );
diff --git a/src/server/sv_client.c b/src/server/sv_client.c
index 794f32a8..e128b579 100644
--- a/src/server/sv_client.c
+++ b/src/server/sv_client.c
@@ -462,6 +462,10 @@ void SV_ClientEnterWorld( client_t *client, usercmd_t *cmd ) {
Com_DPrintf( "Going from CS_PRIMED to CS_ACTIVE for %s\n", client->name );
client->state = CS_ACTIVE;
+ // resend all configstrings using the cs commands since these are
+ // no longer sent when the client is CS_PRIMED
+ SV_UpdateConfigstrings( client );
+
// set up the entity for the client
clientNum = client - svs.clients;
ent = SV_GentityNum( clientNum );
@@ -643,7 +647,9 @@ void SV_WriteDownloadToClient( client_t *cl , msg_t *msg )
}
// We open the file here
- if ( !sv_allowDownload->integer || idPack || unreferenced ||
+ if ( !(sv_allowDownload->integer & DLF_ENABLE) ||
+ (sv_allowDownload->integer & DLF_NO_UDP) ||
+ idPack || unreferenced ||
( cl->downloadSize = FS_SV_FOpenFileRead( cl->downloadName, &cl->download ) ) <= 0 ) {
// cannot auto-download file
if(unreferenced)
@@ -660,7 +666,10 @@ void SV_WriteDownloadToClient( client_t *cl , msg_t *msg )
else {
Com_sprintf(errorMessage, sizeof(errorMessage), "Cannot autodownload id pk3 file \"%s\"", cl->downloadName);
}
- } else if ( !sv_allowDownload->integer ) {
+ }
+ else if ( !(sv_allowDownload->integer & DLF_ENABLE) ||
+ (sv_allowDownload->integer & DLF_NO_UDP) ) {
+
Com_Printf("clientDownload: %d : \"%s\" download disabled", cl - svs.clients, cl->downloadName);
if (sv_pure->integer) {
Com_sprintf(errorMessage, sizeof(errorMessage), "Could not download \"%s\" because autodownloading is disabled on the server.\n\n"
diff --git a/src/server/sv_init.c b/src/server/sv_init.c
index 0099e63f..293b31c9 100644
--- a/src/server/sv_init.c
+++ b/src/server/sv_init.c
@@ -23,6 +23,81 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "server.h"
+
+/*
+===============
+SV_SendConfigstring
+
+Creates and sends the server command necessary to update the CS index for the
+given client
+===============
+*/
+static void SV_SendConfigstring(client_t *client, int index)
+{
+ int maxChunkSize = MAX_STRING_CHARS - 24;
+ int len;
+
+ len = strlen(sv.configstrings[index]);
+
+ if( len >= maxChunkSize ) {
+ int sent = 0;
+ int remaining = len;
+ char *cmd;
+ char buf[MAX_STRING_CHARS];
+
+ while (remaining > 0 ) {
+ if ( sent == 0 ) {
+ cmd = "bcs0";
+ }
+ else if( remaining < maxChunkSize ) {
+ cmd = "bcs2";
+ }
+ else {
+ cmd = "bcs1";
+ }
+ Q_strncpyz( buf, &sv.configstrings[index][sent],
+ maxChunkSize );
+
+ SV_SendServerCommand( client, "%s %i \"%s\"\n", cmd,
+ index, buf );
+
+ sent += (maxChunkSize - 1);
+ remaining -= (maxChunkSize - 1);
+ }
+ } else {
+ // standard cs, just send it
+ SV_SendServerCommand( client, "cs %i \"%s\"\n", index,
+ sv.configstrings[index] );
+ }
+}
+
+/*
+===============
+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;
+
+ // 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
@@ -31,7 +106,6 @@ SV_SetConfigstring
*/
void SV_SetConfigstring (int index, const char *val) {
int len, i;
- int maxChunkSize = MAX_STRING_CHARS - 24;
client_t *client;
if ( index < 0 || index >= MAX_CONFIGSTRINGS ) {
@@ -57,48 +131,23 @@ void SV_SetConfigstring (int index, const char *val) {
// send the data to all relevent clients
for (i = 0, client = svs.clients; i < sv_maxclients->integer ; i++, client++) {
- if ( client->state < CS_PRIMED ) {
+ 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;
}
+
len = strlen( val );
- if( len >= maxChunkSize ) {
- int sent = 0;
- int remaining = len;
- char *cmd;
- char buf[MAX_STRING_CHARS];
-
- while (remaining > 0 ) {
- if ( sent == 0 ) {
- cmd = "bcs0";
- }
- else if( remaining < maxChunkSize ) {
- cmd = "bcs2";
- }
- else {
- cmd = "bcs1";
- }
- Q_strncpyz( buf, &val[sent], maxChunkSize );
-
- SV_SendServerCommand( client, "%s %i \"%s\"\n", cmd, index, buf );
-
- sent += (maxChunkSize - 1);
- remaining -= (maxChunkSize - 1);
- }
- } else {
- // standard cs, just send it
- SV_SendServerCommand( client, "cs %i \"%s\"\n", index, val );
- }
+ SV_SendConfigstring(client, index);
}
}
}
-
-
/*
===============
SV_GetConfigstring
@@ -561,6 +610,7 @@ void SV_Init (void) {
sv_zombietime = Cvar_Get ("sv_zombietime", "2", CVAR_TEMP );
sv_allowDownload = Cvar_Get ("sv_allowDownload", "0", CVAR_SERVERINFO);
+ Cvar_Get ("sv_dlURL", "", CVAR_SERVERINFO | CVAR_ARCHIVE);
sv_master[0] = Cvar_Get ("sv_master1", MASTER_SERVER_NAME, 0 );
sv_master[1] = Cvar_Get ("sv_master2", "", CVAR_ARCHIVE );
sv_master[2] = Cvar_Get ("sv_master3", "", CVAR_ARCHIVE );
diff --git a/src/server/sv_main.c b/src/server/sv_main.c
index c84e5ac3..2dc5a778 100644
--- a/src/server/sv_main.c
+++ b/src/server/sv_main.c
@@ -129,6 +129,10 @@ void SV_AddServerCommand( client_t *client, const char *cmd ) {
// return;
// }
+ // do not send commands until the gamestate has been sent
+ if( client->state < CS_PRIMED )
+ return;
+
client->reliableSequence++;
// if we would be losing an old command that hasn't been acknowledged,
// we must drop the connection
@@ -186,9 +190,6 @@ void QDECL SV_SendServerCommand(client_t *cl, const char *fmt, ...) {
// send the data to all relevent clients
for (j = 0, client = svs.clients; j < sv_maxclients->integer ; j++, client++) {
- if ( client->state < CS_PRIMED ) {
- continue;
- }
SV_AddServerCommand( client, (char *)message );
}
}
@@ -784,7 +785,15 @@ void SV_Frame( int msec ) {
return;
}
- if ( !com_sv_running->integer ) {
+ if (!com_sv_running->integer)
+ {
+ if(com_dedicated->integer)
+ {
+ // Block indefinitely until something interesting happens
+ // on STDIN.
+ NET_Sleep(-1);
+ }
+
return;
}
@@ -797,7 +806,14 @@ void SV_Frame( int msec ) {
if ( sv_fps->integer < 1 ) {
Cvar_Set( "sv_fps", "10" );
}
- frameMsec = 1000 / sv_fps->integer ;
+
+ frameMsec = 1000 / sv_fps->integer * com_timescale->value;
+ // don't let it scale below 1ms
+ if(frameMsec < 1)
+ {
+ Cvar_Set("timescale", va("%f", sv_fps->integer / 1000.0f));
+ frameMsec = 1;
+ }
sv.timeResidual += msec;
diff --git a/src/server/sv_snapshot.c b/src/server/sv_snapshot.c
index 75da32b0..47471ba5 100644
--- a/src/server/sv_snapshot.c
+++ b/src/server/sv_snapshot.c
@@ -559,7 +559,7 @@ static int SV_RateMsec( client_t *client, int messageSize ) {
rate = sv_minRate->integer;
}
- rateMsec = ( messageSize + HEADER_RATE_BYTES ) * 1000 / rate;
+ rateMsec = ( messageSize + HEADER_RATE_BYTES ) * 1000 / rate * com_timescale->value;
return rateMsec;
}
@@ -588,31 +588,30 @@ void SV_SendMessageToClient( msg_t *msg, client_t *client ) {
// TTimo - https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=491
// added sv_lanForceRate check
if ( client->netchan.remoteAddress.type == NA_LOOPBACK || (sv_lanForceRate->integer && Sys_IsLANAddress (client->netchan.remoteAddress)) ) {
- client->nextSnapshotTime = svs.time + (1000/sv_fps->integer);
+ client->nextSnapshotTime = svs.time + (1000.0 / sv_fps->integer * com_timescale->value);
return;
}
// normal rate / snapshotMsec calculation
- rateMsec = SV_RateMsec( client, msg->cursize );
+ rateMsec = SV_RateMsec(client, msg->cursize);
- if ( rateMsec < client->snapshotMsec ) {
+ if ( rateMsec < client->snapshotMsec * com_timescale->value) {
// never send more packets than this, no matter what the rate is at
- rateMsec = client->snapshotMsec;
+ rateMsec = client->snapshotMsec * com_timescale->value;
client->rateDelayed = qfalse;
} else {
client->rateDelayed = qtrue;
}
- client->nextSnapshotTime = svs.time + rateMsec;
+ client->nextSnapshotTime = svs.time + rateMsec * com_timescale->value;
// don't pile up empty snapshots while connecting
if ( client->state != CS_ACTIVE ) {
// a gigantic connection message may have already put the nextSnapshotTime
// more than a second away, so don't shorten it
// do shorten if client is downloading
- if ( !*client->downloadName && client->nextSnapshotTime < svs.time + 1000 ) {
- client->nextSnapshotTime = svs.time + 1000;
- }
+ if (!*client->downloadName && client->nextSnapshotTime < svs.time + 1000 * com_timescale->value)
+ client->nextSnapshotTime = svs.time + 1000 * com_timescale->value;
}
}