summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDarren Salt <devspam@moreofthesa.me.uk>2013-03-12 18:02:22 +0000
committermsk <mkpdev@gmail.com>2013-03-12 14:51:16 -0400
commit23d60561d515769296808cb60df1f681e901a9cb (patch)
tree23d064632353b7874779e8098650c22d29cf93b0 /src
parent9423baa1f9eed0f9c2752f25f91c6a4e0252e22a (diff)
Drop team info if it's for the wrong team's players.
This avoids apparently spurious 'bad client number' messages, caused by the difference in item counts between humans and aliens. Suspected cause is a race between client and server; the effect can (at least in Unvanquished) be observed as spectator when switching between players on opposing teams.
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_servercmds.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c
index 035b8c56..e955e8ab 100644
--- a/src/cgame/cg_servercmds.c
+++ b/src/cgame/cg_servercmds.c
@@ -81,32 +81,31 @@ static void CG_ParseTeamInfo( void )
int i;
int count;
int client;
- int fields;
- if( cg.snap->ps.stats[ STAT_TEAM ] == TEAM_ALIENS )
- fields = 4; // aliens don't have upgrades
- else
- fields = 5;
+ count = trap_Argc( );
- count = ( trap_Argc( ) - 1 ) / fields;
+ for( i = 1; i < count; i++ ) // i is also incremented when writing into cgs.clientinfo
+ {
+ client = atoi( CG_Argv( i ) );
- cgs.teaminfoReceievedTime = cg.time;
+ // wrong team? drop the remaining info
+ if( cgs.clientinfo[ client ].team != cg.snap->ps.stats[ STAT_TEAM ] )
+ return;
- for( i = 0; i < count; i++ )
- {
- client = atoi( CG_Argv( i * fields + 1 ) );
if( client < 0 || client >= MAX_CLIENTS )
{
CG_Printf( "[skipnotify]CG_ParseTeamInfo: bad client number: %d\n", client );
return;
}
- cgs.clientinfo[ client ].location = atoi( CG_Argv( i * fields + 2 ) );
- cgs.clientinfo[ client ].health = atoi( CG_Argv( i * fields + 3 ) );
- cgs.clientinfo[ client ].curWeaponClass = atoi( CG_Argv( i * fields + 4 ) );
+ cgs.clientinfo[ client ].location = atoi( CG_Argv( ++i ) );
+ cgs.clientinfo[ client ].health = atoi( CG_Argv( ++i ) );
+ cgs.clientinfo[ client ].curWeaponClass = atoi( CG_Argv( ++i ) );
if( cg.snap->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
- cgs.clientinfo[ client ].upgrade = atoi( CG_Argv( i * fields + 5 ) );
+ cgs.clientinfo[ client ].upgrade = atoi( CG_Argv( ++i ) );
}
+
+ cgs.teaminfoReceievedTime = cg.time;
}