diff options
Diffstat (limited to 'src/game/g_team.c')
-rw-r--r-- | src/game/g_team.c | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/src/game/g_team.c b/src/game/g_team.c index a527ff91..ec387acd 100644 --- a/src/game/g_team.c +++ b/src/game/g_team.c @@ -301,15 +301,15 @@ Format: */ void TeamplayInfoMessage( gentity_t *ent ) { - char entry[ 19 ], string[ 1143 ]; + char entry[ 17 ], + string[ ( MAX_CLIENTS - 1 ) * ( sizeof( entry ) - 1 ) + 1 ]; int i, j; int team, stringlength; - int sent = 0; gentity_t *player; gclient_t *cl; upgrade_t upgrade = UP_NONE; int curWeaponClass = WP_NONE ; // sends weapon for humans, class for aliens - char *tmp; + char *format; if( !g_allowTeamOverlay.integer ) return; @@ -328,10 +328,15 @@ void TeamplayInfoMessage( gentity_t *ent ) else team = ent->client->pers.teamSelection; + if( team == TEAM_ALIENS ) + format = " %i %i %i %i"; // aliens don't have upgrades + else + format = " %i %i %i %i %i"; + string[ 0 ] = '\0'; stringlength = 0; - for( i = 0; i < MAX_CLIENTS; i++) + for( i = 0; i < level.maxclients; i++) { player = g_entities + i ; cl = player->client; @@ -340,6 +345,10 @@ void TeamplayInfoMessage( gentity_t *ent ) !player->inuse ) continue; + // only update if changed since last time + if( cl->pers.infoChangeTime <= ent->client->pers.teamInfo ) + continue; + if( cl->sess.spectatorState != SPECTATOR_NOT ) { curWeaponClass = WP_NONE; @@ -367,36 +376,28 @@ void TeamplayInfoMessage( gentity_t *ent ) curWeaponClass = cl->ps.stats[ STAT_CLASS ]; upgrade = UP_NONE; } - - tmp = va( "%i %i %i %i", - player->client->pers.location, - player->client->ps.stats[ STAT_HEALTH ] < 1 ? 0 : - player->client->ps.stats[ STAT_HEALTH ], - curWeaponClass, - upgrade ); - if( !strcmp( ent->client->pers.cinfo[ i ], tmp ) ) - continue; - - Q_strncpyz( ent->client->pers.cinfo[ i ], tmp, - sizeof( ent->client->pers.cinfo[ i ] ) ); - - Com_sprintf( entry, sizeof( entry ), " %i %s", i, tmp ); + Com_sprintf( entry, sizeof( entry ), format, i, + cl->pers.location, + cl->ps.stats[ STAT_HEALTH ] < 1 ? 0 : cl->ps.stats[ STAT_HEALTH ], + curWeaponClass, + upgrade ); j = strlen( entry ); - if( stringlength + j > sizeof( string ) ) + // this should not happen if entry and string sizes are correct + if( stringlength + j >= sizeof( string ) ) break; strcpy( string + stringlength, entry ); stringlength += j; - sent++; } - if( !sent ) - return; - - trap_SendServerCommand( ent - g_entities, va( "tinfo%s", string ) ); + if( string[ 0 ] ) + { + trap_SendServerCommand( ent - g_entities, va( "tinfo%s", string ) ); + ent->client->pers.teamInfo = level.time; + } } void CheckTeamStatus( void ) @@ -421,9 +422,18 @@ void CheckTeamStatus( void ) loc = Team_GetLocation( ent ); if( loc ) - ent->client->pers.location = loc->s.generic1; - else + { + if( ent->client->pers.location != loc->s.generic1 ) + { + ent->client->pers.infoChangeTime = level.time; + ent->client->pers.location = loc->s.generic1; + } + } + else if( ent->client->pers.location != 0 ) + { + ent->client->pers.infoChangeTime = level.time; ent->client->pers.location = 0; + } } } |