summaryrefslogtreecommitdiff
path: root/src/game/g_utils.c
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2006-04-09 22:05:35 +0000
committerTim Angus <tim@ngus.net>2006-04-09 22:05:35 +0000
commit25fcd1f90c39ce5c7eb4dfab0fedb4388ad4289c (patch)
tree9680d9ae32cd6fb4cfcfc175a2c4446d237c969c /src/game/g_utils.c
parentcf9b7835e0f7021739bc620ac51c6081036faaee (diff)
* Removed CS_SCORE? config strings -- they were unused
* Moved server command queuing from game to server -- sv_dequeuePeriod probably needs to be lowered * Added g_friendlyBuildableFire to enable friendly buildable fire
Diffstat (limited to 'src/game/g_utils.c')
-rw-r--r--src/game/g_utils.c204
1 files changed, 3 insertions, 201 deletions
diff --git a/src/game/g_utils.c b/src/game/g_utils.c
index 78c50a1a..9caaba76 100644
--- a/src/game/g_utils.c
+++ b/src/game/g_utils.c
@@ -163,7 +163,7 @@ void G_TeamCommand( pTeam_t team, char *cmd )
if( level.clients[ i ].pers.connected == CON_CONNECTED )
{
if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == team )
- G_SendCommandFromServer( i, va( "%s", cmd ) );
+ trap_SendServerCommand( i, va( "%s", cmd ) );
}
}
}
@@ -709,204 +709,6 @@ qboolean G_ClientIsLagging( gclient_t *client )
return qfalse; //is a non-existant client lagging? woooo zen
}
-
-static commandQueue_t queuedCommands[ MAX_CLIENTS ];
-
-/*
-===============
-G_PopCommandQueue
-
-Return the front of a command queue
-Must use immediately or copy to a buffer
-===============
-*/
-static const char *G_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 = level.time + g_minCommandPeriod.integer;
- cqe->used = qfalse;
-
- return cqe->command;
- }
- else
- return NULL;
-}
-
-/*
-===============
-G_PushCommandQueue
-
-Put a command on a command queue
-===============
-*/
-static void G_PushCommandQueue( commandQueue_t *cq, const char *cmd )
-{
- int i;
-
- for( i = 0; i < MAX_QUEUE_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;
- }
- }
-
- //drop the command
-}
-
-/*
-===============
-G_PrintCommandQueue
-===============
-*/
-#if 0 //quiet compiler
-static void G_PrintCommandQueue( commandQueue_t *cq )
-{
- commandQueueElement_t *cqe;
-
- if( cq->front )
- {
- cqe = cq->front;
-
- do
- {
- G_Printf( "->\"%s\"", cqe->command );
- } while( ( cqe = cqe->next ) );
-
- G_Printf( "\n" );
- }
-}
-#endif
-
-/*
-===============
-G_ReadyToDequeue
-===============
-*/
-static qboolean G_ReadyToDequeue( commandQueue_t *cq )
-{
- if( !cq )
- return qfalse;
-
- return cq->front && cq->nextCommandTime <= level.time;
-}
-
-/*
-===============
-G_ProcessCommandQueues
-
-Check for any outstanding commands to be sent
-===============
-*/
-void G_ProcessCommandQueues( void )
-{
- int i;
-
- for( i = 0; i < MAX_CLIENTS; i++ )
- {
- gclient_t *cl = &level.clients[ i ];
- commandQueue_t *cq = &queuedCommands[ i ];
-
- if( !G_ClientIsLagging( cl ) && G_ReadyToDequeue( cq ) )
- {
- const char *command = G_PopCommandQueue( cq );
-
- if( command )
- trap_SendServerCommand( i, command );
- }
- }
-}
-
-/*
-===============
-G_InitCommandQueue
-===============
-*/
-void G_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_QUEUE_COMMANDS; i++ )
- {
- commandQueueElement_t *cqe = &cq->pool[ i ];
-
- cqe->used = qfalse;
- }
- }
-}
-
-/*
-===============
-G_SendCommandFromServer
-
-Sends a command to a client
-===============
-*/
-void G_SendCommandFromServer( int clientNum, const char *cmd )
-{
- commandQueue_t *cq = &queuedCommands[ clientNum ];
-
- if( clientNum < 0 )
- cq = NULL;
-
- if( strlen( cmd ) > 1022 )
- {
- G_LogPrintf( "G_SendCommandFromServer( %d, ... ) length exceeds 1022.\n", clientNum );
- G_LogPrintf( "cmd [%s]\n", cmd );
- return;
- }
-
- if( cq )
- {
- gclient_t *cl = &level.clients[ clientNum ];
-
- if( cq->nextCommandTime > level.time || G_ClientIsLagging( cl ) )
- {
- //can't send yet, so queue the command up
- G_PushCommandQueue( cq, cmd );
- }
- else
- {
- cq->nextCommandTime = level.time + g_minCommandPeriod.integer;
- trap_SendServerCommand( clientNum, cmd );
- }
- }
- else //no queue exists for this client
- trap_SendServerCommand( clientNum, cmd );
-}
-
//==============================================================================
@@ -1017,7 +819,7 @@ void G_TriggerMenu( int clientNum, dynMenu_t menu )
char buffer[ 32 ];
Com_sprintf( buffer, 32, "servermenu %d", menu );
- G_SendCommandFromServer( clientNum, buffer );
+ trap_SendServerCommand( clientNum, buffer );
}
@@ -1033,7 +835,7 @@ void G_CloseMenus( int clientNum )
char buffer[ 32 ];
Com_sprintf( buffer, 32, "serverclosemenus" );
- G_SendCommandFromServer( clientNum, buffer );
+ trap_SendServerCommand( clientNum, buffer );
}