From e3fc1826b101daa67e27bb849abbb9b7a43e58d5 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sat, 8 Sep 2012 23:19:06 +0000 Subject: [PATCH] Send team info for team overlay to spectators for the team of the client they're following (bug #5740). --- code/game/g_team.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/code/game/g_team.c b/code/game/g_team.c index 17f50aad..b3fb2f20 100644 --- a/code/game/g_team.c +++ b/code/game/g_team.c @@ -1066,17 +1066,32 @@ void TeamplayInfoMessage( gentity_t *ent ) { int cnt; int h, a; int clients[TEAM_MAXOVERLAY]; + int team; if ( ! ent->client->pers.teamInfo ) return; + // send team info to spectator for team of followed client + if (ent->client->sess.sessionTeam == TEAM_SPECTATOR) { + if ( ent->client->sess.spectatorState != SPECTATOR_FOLLOW + || ent->client->sess.spectatorClient < 0 ) { + return; + } + team = g_entities[ ent->client->sess.spectatorClient ].client->sess.sessionTeam; + } else { + team = ent->client->sess.sessionTeam; + } + + if (team != TEAM_RED && team != TEAM_BLUE) { + return; + } + // figure out what client should be on the display // we are limited to 8, but we want to use the top eight players // but in client order (so they don't keep changing position on the overlay) for (i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++) { player = g_entities + level.sortedClients[i]; - if (player->inuse && player->client->sess.sessionTeam == - ent->client->sess.sessionTeam ) { + if (player->inuse && player->client->sess.sessionTeam == team ) { clients[cnt++] = level.sortedClients[i]; } } @@ -1090,8 +1105,7 @@ void TeamplayInfoMessage( gentity_t *ent ) { for (i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++) { player = g_entities + i; - if (player->inuse && player->client->sess.sessionTeam == - ent->client->sess.sessionTeam ) { + if (player->inuse && player->client->sess.sessionTeam == team ) { h = player->client->ps.stats[STAT_HEALTH]; a = player->client->ps.stats[STAT_ARMOR]; @@ -1146,7 +1160,7 @@ void CheckTeamStatus(void) { continue; } - if (ent->inuse && (ent->client->sess.sessionTeam == TEAM_RED || ent->client->sess.sessionTeam == TEAM_BLUE)) { + if (ent->inuse) { TeamplayInfoMessage( ent ); } }