From b104fc884a9644c4469eb2d6076bee0c6720f132 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Thu, 21 Jul 2005 23:29:26 +0000 Subject: * Added icons to the scoreboard representing the current class/upgrades held --- src/cgame/cg_draw.c | 3 ++- src/cgame/cg_local.h | 13 ++++++++----- src/cgame/cg_main.c | 49 +++++++++++++++++++++++++++++++++++++++++++---- src/cgame/cg_servercmds.c | 10 ++++++---- src/game/g_cmds.c | 39 ++++++++++++++++++++++++++++++------- 5 files changed, 93 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 5df933af..a805f8ac 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -1663,7 +1663,8 @@ static void CG_DrawStageReport( rectDef_t *rect, float text_x, float text_y, char s[ MAX_TOKEN_CHARS ]; int tx, w, kills; - if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR ) + if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR || + cg.intermissionStarted ) return; if( cg.snap->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 8db55818..143403e1 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -593,11 +593,13 @@ typedef struct localEntity_s typedef struct { - int client; - int score; - int ping; - int time; - int team; + int client; + int score; + int ping; + int time; + int team; + weapon_t weapon; + upgrade_t upgrade; } score_t; // each client has an associated clientInfo_t @@ -1248,6 +1250,7 @@ typedef struct sfxHandle_t lCannonWarningSound; qhandle_t buildWeaponTimerPie[ 8 ]; + qhandle_t upgradeClassIconShader; } cgMedia_t; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 0239c95d..839e6b17 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -797,6 +797,8 @@ static void CG_RegisterGraphics( void ) for( i = 0; i < 8; i++ ) cgs.media.buildWeaponTimerPie[ i ] = trap_R_RegisterShader( buildWeaponTimerPieShaders[ i ] ); + + cgs.media.upgradeClassIconShader = trap_R_RegisterShader( "icons/icona_upgrade.tga" ); cgs.media.machinegunBrassModel = trap_R_RegisterModel( "models/weapons2/shells/m_shell.md3" ); cgs.media.shotgunBrassModel = trap_R_RegisterModel( "models/weapons2/shells/s_shell.md3" ); @@ -1481,6 +1483,7 @@ static const char *CG_FeederItemText( float feederID, int index, int column, qha clientInfo_t *info = NULL; int team = -1; score_t *sp = NULL; + qboolean showIcons = qfalse; *handle = -1; @@ -1489,6 +1492,13 @@ static const char *CG_FeederItemText( float feederID, int index, int column, qha else if( feederID == FEEDER_HUMANTEAM_LIST ) team = PTE_HUMANS; + if( ( atoi( CG_ConfigString( CS_CLIENTS_READY ) ) & ( 1 << sp->client ) ) && + cg.intermissionStarted ) + showIcons = qfalse; + else if( cg.snap->ps.pm_type == PM_SPECTATOR || cg.snap->ps.pm_flags & PMF_FOLLOW || + team == cg.snap->ps.stats[ STAT_PTEAM ] || cg.intermissionStarted ) + showIcons = qtrue; + info = CG_InfoFromScoreIndex( index, team, &scoreIndex ); sp = &cg.scores[ scoreIndex ]; @@ -1497,24 +1507,55 @@ static const char *CG_FeederItemText( float feederID, int index, int column, qha switch( column ) { case 0: + if( showIcons ) + { + if( sp->weapon != WP_NONE ) + *handle = cg_weapons[ sp->weapon ].weaponIcon; + } + break; + + case 1: + if( showIcons ) + { + if( sp->team == PTE_HUMANS && sp->upgrade != UP_NONE ) + *handle = cg_upgrades[ sp->upgrade ].upgradeIcon; + else if( sp->team == PTE_ALIENS ) + { + switch( sp->weapon ) + { + case WP_ABUILD2: + case WP_ALEVEL1_UPG: + case WP_ALEVEL2_UPG: + case WP_ALEVEL3_UPG: + *handle = cgs.media.upgradeClassIconShader; + break; + + default: + break; + } + } + } + break; + + case 2: if( ( atoi( CG_ConfigString( CS_CLIENTS_READY ) ) & ( 1 << sp->client ) ) && cg.intermissionStarted ) return "Ready"; break; - case 1: + case 3: return info->name; break; - case 2: + case 4: return va( "%d", info->score ); break; - case 3: + case 5: return va( "%4d", sp->time ); break; - case 4: + case 6: if( sp->ping == -1 ) return "connecting"; diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index a045a6ec..e529d1ab 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -45,10 +45,12 @@ static void CG_ParseScores( void ) for( i = 0; i < cg.numScores; i++ ) { // - cg.scores[ i ].client = atoi( CG_Argv( i * 4 + 4 ) ); - cg.scores[ i ].score = atoi( CG_Argv( i * 4 + 5 ) ); - cg.scores[ i ].ping = atoi( CG_Argv( i * 4 + 6 ) ); - cg.scores[ i ].time = atoi( CG_Argv( i * 4 + 7 ) ); + cg.scores[ i ].client = atoi( CG_Argv( i * 6 + 4 ) ); + cg.scores[ i ].score = atoi( CG_Argv( i * 6 + 5 ) ); + cg.scores[ i ].ping = atoi( CG_Argv( i * 6 + 6 ) ); + cg.scores[ i ].time = atoi( CG_Argv( i * 6 + 7 ) ); + cg.scores[ i ].weapon = atoi( CG_Argv( i * 6 + 8 ) ); + cg.scores[ i ].upgrade = atoi( CG_Argv( i * 6 + 9 ) ); if( cg.scores[ i ].client < 0 || cg.scores[ i ].client >= MAX_CLIENTS ) cg.scores[ i ].client = 0; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 384c9240..421fb9d5 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -108,12 +108,14 @@ ScoreboardMessage */ void ScoreboardMessage( gentity_t *ent ) { - char entry[ 1024 ]; - char string[ 1400 ]; - int stringlength; - int i, j; + char entry[ 1024 ]; + char string[ 1400 ]; + int stringlength; + int i, j; gclient_t *cl; - int numSorted; + int numSorted; + weapon_t weapon = WP_NONE; + upgrade_t upgrade = UP_NONE; // send the latest information on all clients string[ 0 ] = 0; @@ -132,9 +134,32 @@ void ScoreboardMessage( gentity_t *ent ) else ping = cl->ps.ping < 999 ? cl->ps.ping : 999; + if( cl->ps.stats[ STAT_HEALTH ] > 0 ) + { + weapon = cl->ps.weapon; + + if( BG_InventoryContainsUpgrade( UP_BATTLESUIT, cl->ps.stats ) ) + upgrade = UP_BATTLESUIT; + else if( BG_InventoryContainsUpgrade( UP_JETPACK, cl->ps.stats ) ) + upgrade = UP_JETPACK; + else if( BG_InventoryContainsUpgrade( UP_BATTPACK, cl->ps.stats ) ) + upgrade = UP_BATTPACK; + else if( BG_InventoryContainsUpgrade( UP_HELMET, cl->ps.stats ) ) + upgrade = UP_HELMET; + else if( BG_InventoryContainsUpgrade( UP_LIGHTARMOUR, cl->ps.stats ) ) + upgrade = UP_LIGHTARMOUR; + else + upgrade = UP_NONE; + } + else + { + weapon = WP_NONE; + upgrade = UP_NONE; + } + Com_sprintf( entry, sizeof( entry ), - " %i %i %i %i", level.sortedClients[ i ], - cl->ps.persistant[ PERS_SCORE ], ping, ( level.time - cl->pers.enterTime ) / 60000 ); + " %d %d %d %d %d %d", level.sortedClients[ i ], cl->ps.persistant[ PERS_SCORE ], + ping, ( level.time - cl->pers.enterTime ) / 60000, weapon, upgrade ); j = strlen( entry ); -- cgit