summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2006-04-16 00:21:43 +0000
committerTim Angus <tim@ngus.net>2006-04-16 00:21:43 +0000
commit85a7e9ef79326422e1fea85d7668f37c24c3dd93 (patch)
treeb79f9b98bbe11d4c2938aba5b54c62764eb5034d /src/server
parent2334d817d142e47ac1965f777e4d7c59aeb97939 (diff)
* Removed server command queueing -- that was a silly idea
Diffstat (limited to 'src/server')
-rw-r--r--src/server/server.h20
-rw-r--r--src/server/sv_client.c1
-rw-r--r--src/server/sv_main.c219
3 files changed, 2 insertions, 238 deletions
diff --git a/src/server/server.h b/src/server/server.h
index bd37c262..091d7e7a 100644
--- a/src/server/server.h
+++ b/src/server/server.h
@@ -171,26 +171,6 @@ typedef struct client_s {
int oldServerTime;
} client_t;
-typedef struct commandQueueElement_s
-{
- qboolean used;
- struct commandQueueElement_s *next;
- char command[ MAX_TOKEN_CHARS ];
-} commandQueueElement_t;
-
-typedef struct commandQueue_s
-{
- int nextCommandTime; //next time that the queue can be popped
-
- int numElements;
- commandQueueElement_t *front;
- commandQueueElement_t *back;
-
- commandQueueElement_t pool[ MAX_RELIABLE_COMMANDS ];
-} commandQueue_t;
-
-void SV_InitCommandQueue( int clientNum );
-
//=============================================================================
diff --git a/src/server/sv_client.c b/src/server/sv_client.c
index ffab3bfc..0272fab0 100644
--- a/src/server/sv_client.c
+++ b/src/server/sv_client.c
@@ -487,7 +487,6 @@ void SV_ClientEnterWorld( client_t *client, usercmd_t *cmd ) {
ent = SV_GentityNum( clientNum );
ent->s.number = clientNum;
client->gentity = ent;
- SV_InitCommandQueue( clientNum );
client->deltaMessage = -1;
client->nextSnapshotTime = svs.time; // generate a snapshot immediately
diff --git a/src/server/sv_main.c b/src/server/sv_main.c
index ba9bf2c6..f525f5c5 100644
--- a/src/server/sv_main.c
+++ b/src/server/sv_main.c
@@ -152,219 +152,6 @@ void SV_AddServerCommand( client_t *client, const char *cmd ) {
}
/*
-=============
-SV_ClientIsLagging
-=============
-*/
-qboolean SV_ClientIsLagging( client_t *client )
-{
- if( client )
- {
- if( client->ping >= 999 )
- return qtrue;
- else
- return qfalse;
- }
-
- return qfalse; //is a non-existant client lagging? woooo zen
-}
-
-
-static commandQueue_t queuedCommands[ MAX_CLIENTS ];
-
-/*
-===============
-SV_PopCommandQueue
-
-Return the front of a command queue
-Must use immediately or copy to a buffer
-===============
-*/
-static const char *SV_PopCommandQueue( commandQueue_t *cq )
-{
- if( cq->front )
- {
- commandQueueElement_t *cqe = cq->front;
-
- cq->front = cqe->next;
-
- // last element in the queue
- if( cq->front == NULL )
- cq->back = NULL;
-
- cq->nextCommandTime = svs.time + sv_dequeuePeriod->integer;
- cqe->used = qfalse;
-
- return cqe->command;
- }
- else
- return NULL;
-}
-
-/*
-===============
-SV_PushCommandQueue
-
-Put a command on a command queue
-===============
-*/
-static qboolean SV_PushCommandQueue( commandQueue_t *cq, const char *cmd )
-{
- int i;
-
- for( i = 0; i < MAX_RELIABLE_COMMANDS; i++ )
- {
- commandQueueElement_t *cqe = &cq->pool[ i ];
-
- if( !cqe->used )
- {
- cqe->used = qtrue;
- cqe->next = NULL;
- Q_strncpyz( cqe->command, cmd, MAX_TOKEN_CHARS );
-
- if( cq->back )
- {
- cq->back->next = cqe;
- cq->back = cqe;
- }
- else
- {
- cq->front = cqe;
- cq->back = cqe;
- }
-
- return qtrue;
- }
- }
-
- // The queue is full, so the command cannot be queued up.
- // Consequently, the command must be dropped -- meaning it
- // is no longer reliable.
- return qfalse;
-}
-
-/*
-===============
-SV_PrintCommandQueue
-===============
-*/
-#if 0 //quiet compiler
-static void SV_PrintCommandQueue( commandQueue_t *cq )
-{
- commandQueueElement_t *cqe;
-
- if( cq->front )
- {
- cqe = cq->front;
-
- do
- {
- Com_Printf( "->\"%s\"", cqe->command );
- } while( ( cqe = cqe->next ) );
-
- Com_Printf( "\n" );
- }
-}
-#endif
-
-/*
-===============
-SV_ReadyToDequeue
-===============
-*/
-static qboolean SV_ReadyToDequeue( commandQueue_t *cq )
-{
- if( !cq )
- return qfalse;
-
- return cq->front && cq->nextCommandTime <= svs.time;
-}
-
-/*
-===============
-SV_ProcessCommandQueues
-
-Check for any outstanding commands to be sent
-===============
-*/
-void SV_ProcessCommandQueues( void )
-{
- int i;
-
- for( i = 0; i < MAX_CLIENTS; i++ )
- {
- client_t *cl = &svs.clients[ i ];
- commandQueue_t *cq = &queuedCommands[ i ];
-
- if( !SV_ClientIsLagging( cl ) && SV_ReadyToDequeue( cq ) )
- {
- const char *command = SV_PopCommandQueue( cq );
-
- if( command )
- SV_AddServerCommand( cl, command );
- }
- }
-}
-
-/*
-===============
-SV_InitCommandQueue
-===============
-*/
-void SV_InitCommandQueue( int clientNum )
-{
- int i;
- commandQueue_t *cq = &queuedCommands[ clientNum ];
-
- if( clientNum >= 0 && clientNum < MAX_CLIENTS )
- {
- cq->front = cq->back = NULL;
- cq->nextCommandTime = 0;
-
- for( i = 0; i < MAX_RELIABLE_COMMANDS; i++ )
- {
- commandQueueElement_t *cqe = &cq->pool[ i ];
-
- cqe->used = qfalse;
- }
- }
-}
-
-/*
-===============
-SV_EnqueueServerCommand
-
-Sends a command to a client
-===============
-*/
-void SV_EnqueueServerCommand( int clientNum, const char *cmd )
-{
- commandQueue_t *cq = &queuedCommands[ clientNum ];
- client_t *cl = &svs.clients[ clientNum ];
-
- if( clientNum < 0 )
- cq = NULL;
-
- if( cq )
- {
- if( cq->nextCommandTime > svs.time || SV_ClientIsLagging( cl ) )
- {
- //can't send yet, so queue the command up
- if( !SV_PushCommandQueue( cq, cmd ) )
- SV_DropClient( cl,
- va( "Failed to enqueue reliable server command (%s)", cmd ) );
- }
- else
- {
- cq->nextCommandTime = svs.time + sv_dequeuePeriod->integer;
- SV_AddServerCommand( cl, cmd );
- }
- }
- else //no queue exists for this client
- SV_AddServerCommand( cl, cmd );
-}
-
-/*
=================
SV_SendServerCommand
@@ -392,7 +179,7 @@ void QDECL SV_SendServerCommand(client_t *cl, const char *fmt, ...) {
}
if ( cl != NULL ) {
- SV_EnqueueServerCommand( cl - svs.clients, (char *)message );
+ SV_AddServerCommand( cl, (char *)message );
return;
}
@@ -406,7 +193,7 @@ void QDECL SV_SendServerCommand(client_t *cl, const char *fmt, ...) {
if ( client->state < CS_PRIMED ) {
continue;
}
- SV_EnqueueServerCommand( client - svs.clients, (char *)message );
+ SV_AddServerCommand( client, (char *)message );
}
}
@@ -1084,8 +871,6 @@ void SV_Frame( int msec ) {
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
}
- SV_ProcessCommandQueues( );
-
if ( com_speeds->integer ) {
time_game = Sys_Milliseconds () - startTime;
}