]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Only show available weapons in the accuracy scoreboard
authorMario <zacjardine@y7mail.com>
Fri, 31 Jul 2015 14:47:38 +0000 (00:47 +1000)
committerMario <zacjardine@y7mail.com>
Fri, 31 Jul 2015 14:47:38 +0000 (00:47 +1000)
qcsrc/client/scoreboard.qc
qcsrc/common/stats.qh
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/all.qh
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/g_world.qc

index 418e1db08b2697239e7d81194fe91e82279d8ff6..f733abcb8dc971fff695e801085e447536270a9f 100644 (file)
@@ -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;
index b488df1cfd709edacf36401d42990adbd4f4ed93..fa52737631f93bf0599097b28ae9041b71142a27 100644 (file)
@@ -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?
index 36f08eff9017bd322cea18f6fc36f8590c714a81..72c92471a9c537435aaeb29ed20072303c7700a3 100644 (file)
@@ -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
index 154f8167e91aa5c7faa2e7be866335c89d4031cf..eab3b0a5ad2879f8f2e2048ff9703444c8062e87 100644 (file)
@@ -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
 
index 33491ff0e7bfa49cbbaae33e434094f83c11c084..8ca2f6c35f8771d2b58995bed78c0ca9442ec49a 100644 (file)
@@ -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
index 9637cc67c8496dd02032e99d3b5a864dfd9211e2..1fbc8d09a50587b2c30094d4fabe2bf8bde001b5 100644 (file)
@@ -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;
index 9c2003cc19d506afbe5de24d4b7e5adf0c7bdacb..c913e86e75a7d5b72346fe6c67b5dbca7f3ea65c 100644 (file)
@@ -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);