diff options
author | enneract <trem.redman@gmail.com> | 2014-12-21 01:43:59 +0100 |
---|---|---|
committer | enneract <trem.redman@gmail.com> | 2014-12-21 01:43:59 +0100 |
commit | ff555a521abe57c7c150d3bd4f1fc65323fbd5dd (patch) | |
tree | 7eae7ae15a40c0f2bc47457fb3c3744caa53b2e1 /src/game/g_combat.c | |
parent | 89c52da526ea245d79184e373bcc259e9a6b0e9d (diff) |
Simplify in-game combat statistics.
Diffstat (limited to 'src/game/g_combat.c')
-rw-r--r-- | src/game/g_combat.c | 93 |
1 files changed, 41 insertions, 52 deletions
diff --git a/src/game/g_combat.c b/src/game/g_combat.c index c79f97d..4ed8e8b 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -1901,7 +1901,11 @@ void G_CalculateCombatRanks( void ) { gentity_t *ent; combatStatsWeapon_t weapon; - combatStatsDmgType_t dmgtype; + combatStats_t *stats; + combatRanks_t *ranks; + int i, sample_count = 0, rank; + csrSample_t samples[ MAX_CLIENTS ]; + float last; // reset all ranks for( ent = g_entities; ent < g_entities + MAX_CLIENTS; ent++ ) @@ -1909,69 +1913,54 @@ void G_CalculateCombatRanks( void ) memset( &ent->client->pers.combatRanks, 0, sizeof( combatRanks_t ) ); for( weapon = CSW_UNKNOWN + 1; weapon < CSW_MAX; weapon++ ) - for( dmgtype = CSD_FIRST; dmgtype < CSD_MAX; dmgtype++ ) + { + for( ent = g_entities; ent < g_entities + MAX_CLIENTS; ent++ ) { - int i, sample_count = 0, rank; - csrSample_t samples[ MAX_CLIENTS ]; - float last; - - for( ent = g_entities; ent < g_entities + MAX_CLIENTS; ent++ ) - { - combatStats_t *stats; - combatRanks_t *ranks; - int potential; - - if( !ent->inuse || - !ent->client || - ent->client->pers.connected == CON_CONNECTING ) - continue; - - stats = ent->client->pers.combatStats + weapon; - ranks = ent->client->pers.combatRanks + weapon; - - if( !stats->fired ) - continue; - - potential = stats->fired; + if( !ent->inuse || + !ent->client || + ent->client->pers.connected == CON_CONNECTING ) + continue; - for( i = 0; i < CSD_MAX; i++ ) - if( i != dmgtype ) - potential -= stats->dealt[ i ]; + stats = ent->client->pers.combatStats + weapon; + ranks = ent->client->pers.combatRanks + weapon; - if( !potential ) - continue; + if( !stats->fired ) + continue; - ranks->inuse[ dmgtype ] = qtrue; - ranks->effs[ dmgtype ] = (float)stats->dealt[ dmgtype ] / potential; + ranks->inuse = qtrue; + ranks->skill = + ( stats->dealt[ CSD_ENEMY ] + stats->dealt[ CSD_ENEMY_BUILDABLE ] - + stats->dealt[ CSD_FRIENDLY ] - stats->dealt[ CSD_FRIENDLY_BUILDABLE ] - + stats->dealt[ CSD_SELF ] ) / (float)stats->fired; - samples[ sample_count ].ent = ent; - samples[ sample_count++ ].value = ranks->effs[ dmgtype ]; - } + samples[ sample_count ].ent = ent; + samples[ sample_count++ ].value = ranks->skill; + } - if( sample_count < 2 ) - continue; + if( sample_count < 2 ) + continue; - qsort( samples, sample_count, sizeof( csrSample_t ), (int(*)(const void*,const void*))csrSampleCmp ); + qsort( samples, sample_count, sizeof( csrSample_t ), (int(*)(const void*,const void*))csrSampleCmp ); - for( i = 0, rank = 0; i < sample_count; i++ ) - { - combatRanks_t *ranks = samples[ i ].ent->client->pers.combatRanks + weapon; + for( i = 0, rank = 0; i < sample_count; i++ ) + { + combatRanks_t *ranks = samples[ i ].ent->client->pers.combatRanks + weapon; - if( i > 0 && fabs( last - samples[ i ].value ) > 1.0e-5 ) - rank++; + if( i > 0 && fabs( last - samples[ i ].value ) > 1.0e-5 ) + rank++; - ranks->ranked[ dmgtype ] = qtrue; - ranks->effs_pc[ dmgtype ] = rank; + ranks->ranked = qtrue; + ranks->skill_pc = rank; - last = samples[ i ].value; - } + last = samples[ i ].value; + } - for( i = 0; i < sample_count; i++ ) - { - float *eff = samples[ i ].ent->client->pers.combatRanks[ weapon ].effs_pc + dmgtype; - (*eff) = 1.0f - (*eff) / ( (float)rank + 1 ); - } + for( i = 0; i < sample_count; i++ ) + { + float *skill = &samples[ i ].ent->client->pers.combatRanks[ weapon ].skill; + (*skill) = 1.0f - (*skill) / ( (float)rank + 1 ); } + } level.combatRanksTime = level.time; } @@ -1994,7 +1983,7 @@ void G_LogCombatSettings( void ) #undef CSW }; - for( i = 0; i < CSW_MAX; i++ ) + for( i = CSW_UNKNOWN + 1; i < CSW_MAX; i++ ) { Com_sprintf( p, 4096 - ( p - buffer ), " %s %i", modNames[ cswToMod[ i ] ], cswDamages[ i ] ); while( *p ) p++; |