summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Millwood <thebenmachine@gmail.com>2009-10-03 12:04:29 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:39 +0000
commita8d7e1110216c7d530c3fe6939d3e734a44f16ef (patch)
tree0ffac1cc5f0856fe85b2e7c558237f341edf73d0
parentc29de5a7d5984c27fd85305aaab69e8d88db6d71 (diff)
* More testing code to fix ready state
-rw-r--r--src/cgame/cg_main.c8
-rw-r--r--src/game/g_main.c7
2 files changed, 11 insertions, 4 deletions
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index d48800fa..d8683d9e 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -1425,14 +1425,18 @@ static clientInfo_t * CG_InfoFromScoreIndex( int index, int team, int *scoreInde
static qboolean CG_ClientIsReady( int clientNum )
{
+ // each character of the hex string corresponds to 4 bits, which correspond
+ // to readiness for client (0, 1, 2, 3...) i.e. the highest order bit
+ // corresponds to the lowest clientnum
+ // because of this 1:4 ratio we only need one character for a given client
int val = clientNum / 4;
const char *s = CG_ConfigString( CS_CLIENTS_READY );
- while( *s && val-- )
+ while( *s && val-- > 0 )
s++;
if( !*s )
return qfalse;
sscanf( s, "%1x", &val );
- return ( ( val & ( clientNum % 4 ) ) != 0 );
+ return ( ( val & 1 << ( 3 - clientNum % 4 ) ) != 0 );
}
static const char *CG_FeederItemText( float feederID, int index, int column, qhandle_t *handle )
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 0a2cbedb..37477980 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -1796,7 +1796,6 @@ void CheckIntermissionExit( void )
gclient_t *cl;
byte readyMasks[ ( MAX_CLIENTS + 7 ) / 8 ];
char readyString[ 2 * sizeof( readyMasks ) + 1 ];
- int index;
//if no clients are connected, just exit
if( !level.numConnectedClients )
@@ -1822,6 +1821,7 @@ void CheckIntermissionExit( void )
if( cl->readyToExit )
{
ready++;
+ // the nth bit of readyMasks is for client (n - 1)
readyMasks[ i / 8 ] |= 1 << ( 7 - ( i % 8 ) );
}
else
@@ -1830,7 +1830,10 @@ void CheckIntermissionExit( void )
numPlayers++;
}
- for( i = 0; i < sizeof( readyMasks ); i++ )
+ // this is hex because we can convert bits to a hex string in pieces,
+ // whereas a decimal string would have to all be written at once
+ // (and we can't fit a number that large in an int)
+ for( i = 0; i < ( g_maxclients.integer + 7 ) / 8; i++ )
Com_sprintf( &readyString[ i * 2 ], sizeof( readyString ) - i * 2,
"%2.2x", readyMasks[ i ] );