From: Mario Date: Fri, 31 Jul 2015 14:47:38 +0000 (+1000) Subject: Only show available weapons in the accuracy scoreboard X-Git-Tag: xonotic-v0.8.1~30^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a9f8b27f22202073367611a130c1ab0047b33e6e;p=xonotic%2Fxonotic-data.pk3dir.git Only show available weapons in the accuracy scoreboard --- diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 418e1db08..f733abcb8 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -976,9 +976,25 @@ float HUD_WouldDrawScoreboard() { float average_accuracy; vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) { + WepSet weapons_stat = WepSet_GetFromStat(); + WepSet weapons_inmap = WepSet_GetFromStat_InMap(); int i; - int weapon_cnt = WEP_COUNT - 3; // either vaporizer/vortex are hidden, no port-o-launch, no tuba - float rows; + float weapon_stats; + int disownedcnt = 0; + for(i = WEP_FIRST; i <= WEP_LAST; ++i) + { + self = get_weaponinfo(i); + if(!self.weapon) + continue; + + weapon_stats = weapon_accuracy[i-WEP_FIRST]; + + if(weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i))) + ++disownedcnt; + } + + int weapon_cnt = WEP_COUNT - disownedcnt; + int rows; if(autocvar_scoreboard_accuracy_doublerows) rows = 2; else @@ -1023,7 +1039,6 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) if(switchweapon == WEP_VAPORIZER) g_instagib = 1; // TODO: real detection for instagib? - float weapon_stats; if(autocvar_scoreboard_accuracy_nocolors) rgb = '1 1 1'; else @@ -1034,10 +1049,11 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) self = get_weaponinfo(i); if (!self.weapon) continue; - if ((i == WEP_VORTEX && g_instagib) || i == WEP_PORTO || (i == WEP_VAPORIZER && !g_instagib) || i == WEP_TUBA) // skip port-o-launch, vortex || vaporizer and tuba - continue; weapon_stats = weapon_accuracy[i-WEP_FIRST]; + if(weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i))) + continue; + float weapon_alpha; if(weapon_stats >= 0) weapon_alpha = scoreboard_alpha_fg; diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index b488df1cf..fa5273763 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -109,9 +109,9 @@ const int STAT_OK_AMMO_CHARGE = 85; const int STAT_OK_AMMO_CHARGEPOOL = 86; const int STAT_FROZEN = 87; const int STAT_REVIVE_PROGRESS = 88; -// 89 empty? -// 90 empty? -// 91 empty? +const int STAT_WEAPONSINMAP = 89; +const int STAT_WEAPONSINMAP2 = 90; +const int STAT_WEAPONSINMAP3 = 91; // 92 empty? // 93 empty? // 94 empty? diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 36f08eff9..72c92471a 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -91,6 +91,16 @@ void WepSet_AddStat() #endif #endif } +void WepSet_AddStat_InMap() +{ + addstat(STAT_WEAPONSINMAP, AS_INT, weaponsinmap_x); +#if WEP_MAXCOUNT > 24 + addstat(STAT_WEAPONSINMAP2, AS_INT, weaponsinmap_y); +#if WEP_MAXCOUNT > 48 + addstat(STAT_WEAPONSINMAP3, AS_INT, weaponsinmap_z); +#endif +#endif +} void WriteWepSet(float dst, WepSet w) { #if WEP_MAXCOUNT > 48 @@ -115,6 +125,18 @@ WepSet WepSet_GetFromStat() #endif return w; } +WepSet WepSet_GetFromStat_InMap() +{ + WepSet w = '0 0 0'; + w_x = getstati(STAT_WEAPONSINMAP); +#if WEP_MAXCOUNT > 24 + w_y = getstati(STAT_WEAPONSINMAP2); +#if WEP_MAXCOUNT > 48 + w_z = getstati(STAT_WEAPONSINMAP3); +#endif +#endif + return w; +} WepSet ReadWepSet() { #if WEP_MAXCOUNT > 48 diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 154f8167e..eab3b0a5a 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -55,10 +55,12 @@ typedef vector WepSet; WepSet WepSet_FromWeapon(int a); #ifdef SVQC void WepSet_AddStat(); +void WepSet_AddStat_InMap(); void WriteWepSet(float dest, WepSet w); #endif #ifdef CSQC WepSet WepSet_GetFromStat(); +WepSet WepSet_GetFromStat_InMap(); WepSet ReadWepSet(); #endif diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 33491ff0e..8ca2f6c35 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2226,6 +2226,8 @@ void PlayerPreThink (void) self.stat_allow_oldvortexbeam = autocvar_g_allow_oldvortexbeam; self.stat_leadlimit = autocvar_leadlimit; + self.weaponsinmap = weaponsInMap; + if(frametime) { // physics frames: update anticheat stuff diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 9637cc67c..1fbc8d09a 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -255,6 +255,8 @@ void FixClientCvars(entity e); // WEAPONTODO: remove this WepSet weaponsInMap; +.WepSet weaponsinmap; + .float respawn_countdown; // next number to count float bot_waypoints_for_items; diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 9c2003cc1..c913e86e7 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -785,6 +785,7 @@ void spawnfunc_worldspawn (void) WeaponStats_Init(); WepSet_AddStat(); + WepSet_AddStat_InMap(); addstat(STAT_SWITCHWEAPON, AS_INT, switchweapon); addstat(STAT_SWITCHINGWEAPON, AS_INT, switchingweapon); addstat(STAT_GAMESTARTTIME, AS_FLOAT, stat_game_starttime);