diff options
-rw-r--r-- | src/game/g_active.c | 2 | ||||
-rw-r--r-- | src/game/g_cmds.c | 37 | ||||
-rw-r--r-- | src/game/g_local.h | 7 | ||||
-rw-r--r-- | src/game/g_main.c | 2 | ||||
-rw-r--r-- | src/game/g_utils.c | 47 |
5 files changed, 45 insertions, 50 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c index 58667447..e90f28d0 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -1078,7 +1078,7 @@ void ClientThink_real( gentity_t *ent ) { BG_DeactivateUpgrade( UP_MEDKIT, client->ps.stats ); } - else + else if( client->ps.stats[ STAT_HEALTH ] > 0 ) { //remove anti toxin BG_DeactivateUpgrade( UP_MEDKIT, client->ps.stats ); diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 1df1f1ab..5a6e516e 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1530,12 +1530,6 @@ void Cmd_Buy_f( gentity_t *ent ) //can afford this? if( BG_FindPriceForWeapon( weapon ) > (short)ent->client->ps.persistant[ PERS_CREDIT ] ) { - G_LogPrintf( "Client %d buying weapon %d, value %d, credit %d\n", - ent->client->ps.clientNum, - weapon, - BG_FindPriceForWeapon( weapon ), - (short)ent->client->ps.persistant[ PERS_CREDIT ] ); - G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS ); return; } @@ -1600,12 +1594,6 @@ void Cmd_Buy_f( gentity_t *ent ) if( BG_FindPriceForUpgrade( upgrade ) > (short)ent->client->ps.persistant[ PERS_CREDIT ] ) { G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS ); - G_LogPrintf( "Client %d buying upgrade %d, value %d, credit %d\n", - ent->client->ps.clientNum, - weapon, - BG_FindPriceForWeapon( upgrade ), - (short)ent->client->ps.persistant[ PERS_CREDIT ] ); - return; } @@ -1899,30 +1887,7 @@ void Cmd_Build_f( gentity_t *ent ) } } else - { G_SendCommandFromServer( ent-g_entities, va( "print \"Cannot build this item\n\"" ) ); - - G_LogPrintf( "Client %d tried to build %d using weapon %d\n", - ent->client->ps.clientNum, - buildable, - ( 1 << ent->client->ps.weapon ) & BG_FindBuildWeaponForBuildable( buildable ) ); - } -} - - -//TA: so we can print to the console from anywhere -/* -================= -Cmd_Echo_f -================= -*/ -void Cmd_Echo_f( gentity_t *ent ) -{ - char s[ MAX_TOKEN_CHARS ]; - - trap_Argv( 1, s, sizeof( s ) ); - - G_SendCommandFromServer( ent-g_entities, va( "print \"%s\n\"", s ) ); } @@ -2301,8 +2266,6 @@ void ClientCommand( int clientNum ) Cmd_Destroy_f( ent, qtrue ); else if( Q_stricmp( cmd, "reload" ) == 0 ) Cmd_Reload_f( ent ); - else if( Q_stricmp( cmd, "echo" ) == 0 ) - Cmd_Echo_f( ent ); else if( Q_stricmp( cmd, "boost" ) == 0 ) Cmd_Boost_f( ent ); else if( Q_stricmp( cmd, "where" ) == 0 ) diff --git a/src/game/g_local.h b/src/game/g_local.h index 4642686a..a56993fc 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -701,7 +701,8 @@ void G_SetOrigin( gentity_t *ent, vec3_t origin ); void AddRemap(const char *oldShader, const char *newShader, float timeOffset); const char *BuildShaderStateConfig(); -#define MAX_QUEUE_COMMANDS 10 + +#define MAX_QUEUE_COMMANDS 64 //should be MAX_RELIABLE_COMMANDS/server.h typedef struct commandQueueElement_s { @@ -714,10 +715,14 @@ 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_QUEUE_COMMANDS ]; } commandQueue_t; +qboolean G_ClientIsLagging( gclient_t *client ); void G_ProcessCommandQueues( void ); void G_SendCommandFromServer( int clientNum, const char *cmd ); void G_InitCommandQueue( int clientNum ); diff --git a/src/game/g_main.c b/src/game/g_main.c index 4cde34b7..77aa54b1 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -1504,7 +1504,7 @@ void LogExit( const char *string ) cl = &level.clients[ level.sortedClients[ i ] ]; - if( cl->sess.sessionTeam == TEAM_SPECTATOR ) + if( cl->ps.stats[ STAT_PTEAM ] == PTE_NONE ) continue; if( cl->pers.connected == CON_CONNECTING ) diff --git a/src/game/g_utils.c b/src/game/g_utils.c index b09ec8cb..a7d66fd5 100644 --- a/src/game/g_utils.c +++ b/src/game/g_utils.c @@ -683,10 +683,26 @@ void G_Sound( gentity_t *ent, int channel, int soundIndex ) } -#define MAX_QUEUE_ELEMENTS MAX_CLIENTS * MAX_QUEUE_COMMANDS +/* +============= +G_ClientIsLagging +============= +*/ +qboolean G_ClientIsLagging( gclient_t *client ) +{ + if( client ) + { + if( client->ps.ping >= 999 ) + return qtrue; + else + return qfalse; + } + + return qfalse; //is a non-existant client lagging? woooo zen +} + -static commandQueueElement_t queuedCommandElements[ MAX_QUEUE_ELEMENTS ]; -static commandQueue_t queuedCommands[ MAX_CLIENTS ]; +static commandQueue_t queuedCommands[ MAX_CLIENTS ]; /* =============== @@ -728,9 +744,9 @@ static void G_PushCommandQueue( commandQueue_t *cq, const char *cmd ) { int i; - for( i = 0; i < MAX_QUEUE_ELEMENTS; i++ ) + for( i = 0; i < MAX_QUEUE_COMMANDS; i++ ) { - commandQueueElement_t *cqe = &queuedCommandElements[ i ]; + commandQueueElement_t *cqe = &cq->pool[ i ]; if( !cqe->used ) { @@ -806,9 +822,10 @@ void G_ProcessCommandQueues( void ) for( i = 0; i < MAX_CLIENTS; i++ ) { - commandQueue_t *cq = &queuedCommands[ i ]; + gclient_t *cl = &level.clients[ i ]; + commandQueue_t *cq = &queuedCommands[ i ]; - if( G_ReadyToDequeue( cq ) ) + if( !G_ClientIsLagging( cl ) && G_ReadyToDequeue( cq ) ) { const char *command = G_PopCommandQueue( cq ); @@ -825,12 +842,20 @@ G_InitCommandQueue */ void G_InitCommandQueue( int clientNum ) { - commandQueue_t *cq = &queuedCommands[ 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; + } } } @@ -857,7 +882,9 @@ void G_SendCommandFromServer( int clientNum, const char *cmd ) if( cq ) { - if( cq->nextCommandTime > level.time ) + 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 ); @@ -868,7 +895,7 @@ void G_SendCommandFromServer( int clientNum, const char *cmd ) trap_SendServerCommand( clientNum, cmd ); } } - else + else //no queue exists for this client trap_SendServerCommand( clientNum, cmd ); } |