]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
cleanup weaponorder
authorMartin Taibr <taibr.martin@gmail.com>
Mon, 30 Sep 2019 17:21:43 +0000 (19:21 +0200)
committerMartin Taibr <taibr.martin@gmail.com>
Mon, 30 Sep 2019 17:21:43 +0000 (19:21 +0200)
qcsrc/client/defs.qh
qcsrc/client/hud/panel/weapons.qc

index db1a5afacaed87760c210bde6088c475c7dab29c..0cf71294a78936db18f480c5af6eb4047468405c 100644 (file)
@@ -173,10 +173,6 @@ REPLICATE(cvar_cl_weaponpriorities[9], string, "cl_weaponpriority9");
 
 float bgmtime;
 
-string weaponorder_byimpulse; // NOTE: this is a misnomer, weapon order is not always sorted by impulse
-string weaponorder_bypriority;
-bool weapons_orderbyimpulse; // update priority list when toggling this
-
 float vortex_charge_movingavg;
 
 int serverflags;
index 832ffad0b38ca9b27727451808c44570e5d5eb79..8668886a91282da36356f92d9577a8fdfffa9601 100644 (file)
@@ -39,6 +39,8 @@ int weaponorder_cmp(int i, int j, entity pass)
        weapon_size.y = panel_size.y / rows; \
 MACRO_END
 
+string cl_weaponpriority_old;
+bool weapons_orderbyimpulse_old;
 void HUD_Weapons()
 {
        // declarations
@@ -90,19 +92,19 @@ void HUD_Weapons()
        // update generic hud functions
        HUD_Panel_LoadCvars();
 
-       // figure out weapon order (how the weapons are sorted) // TODO make this configurable
-       if(weaponorder_bypriority != autocvar_cl_weaponpriority || autocvar_hud_panel_weapons_orderbyimpulse != weapons_orderbyimpulse || !weaponorder[0])
+       if(cl_weaponpriority_old != autocvar_cl_weaponpriority || weapons_orderbyimpulse_old != autocvar_hud_panel_weapons_orderbyimpulse || weaponorder[0] == NULL)
        {
-               int weapon_cnt;
-               weapons_orderbyimpulse = autocvar_hud_panel_weapons_orderbyimpulse;
-               strcpy(weaponorder_bypriority, autocvar_cl_weaponpriority);
-               string weporder = W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority));
+               weapons_orderbyimpulse_old = autocvar_hud_panel_weapons_orderbyimpulse;
+               strcpy(cl_weaponpriority_old, autocvar_cl_weaponpriority);
+               string weporder = W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(cl_weaponpriority_old));
                if(autocvar_hud_panel_weapons_orderbyimpulse)
+               {
                        weporder = W_FixWeaponOrder_BuildImpulseList(weporder);
-               strcpy(weaponorder_byimpulse, weporder);
-               weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
+               }
+
+               weaponorder_cmp_str = strcat(" ", weporder, " ");
 
-               weapon_cnt = 0;
+               int weapon_cnt = 0;
                FOREACH(Weapons, it != WEP_Null && it.impulse >= 0, weaponorder[weapon_cnt++] = it);
                for(i = weapon_cnt; i < Weapons_MAX; ++i)
                        weaponorder[i] = NULL;