]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/weapons.qc
Merge branch 'terencehill/spectate_player' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / weapons.qc
index 8bf11cf1ac93d3994840bb64b96bac5ce993317d..8668886a91282da36356f92d9577a8fdfffa9601 100644 (file)
@@ -26,19 +26,21 @@ int weaponorder_cmp(int i, int j, entity pass)
        return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
 }
 
-#define HUD_WEAPONS_GET_FULL_LAYOUT() MACRO_BEGIN \
+#define HUD_WEAPONS_GET_FULL_LAYOUT() MACRO_BEGIN \
        int nHidden = 0; \
        FOREACH(Weapons, it != WEP_Null, { \
                if (weapons_stat & WepSet_FromWeapon(it)) continue; \
-               if ((it.spawnflags & WEP_FLAG_HIDDEN) || (it.spawnflags & WEP_FLAG_MUTATORBLOCKED)) nHidden += 1; \
+               if (it.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_SPECIALATTACK)) nHidden += 1; \
        }); \
        vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, panel_size, aspect); \
        columns = table_size.x; \
        rows = table_size.y; \
        weapon_size.x = panel_size.x / columns; \
        weapon_size.y = panel_size.y / rows; \
-MACRO_END
+MACRO_END
 
+string cl_weaponpriority_old;
+bool weapons_orderbyimpulse_old;
 void HUD_Weapons()
 {
        // declarations
@@ -63,7 +65,7 @@ void HUD_Weapons()
        float when = max(1, autocvar_hud_panel_weapons_complainbubble_time);
        float fadetime = max(0, autocvar_hud_panel_weapons_complainbubble_fadetime);
 
-       bool infinite_ammo = (STAT(ITEMS) & IT_UNLIMITED_WEAPON_AMMO);
+       bool infinite_ammo = (STAT(ITEMS) & IT_UNLIMITED_AMMO);
 
        vector weapon_pos, weapon_size = '0 0 0';
        vector color;
@@ -90,15 +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 || !weaponorder[0])
+       if(cl_weaponpriority_old != autocvar_cl_weaponpriority || weapons_orderbyimpulse_old != autocvar_hud_panel_weapons_orderbyimpulse || weaponorder[0] == NULL)
        {
-               int weapon_cnt;
-               strcpy(weaponorder_bypriority, autocvar_cl_weaponpriority);
-               strcpy(weaponorder_byimpulse, W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
-               weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
+               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);
+               }
+
+               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;
@@ -123,7 +129,7 @@ void HUD_Weapons()
                {
                        int j = 0;
                        FOREACH(Weapons, it != WEP_Null && it.impulse >= 0 && (it.impulse % 3 != 0) && j < 6, {
-                               if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
+                               if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & WEP_FLAG_SPECIALATTACK))
                                {
                                        if(!panel_switchweapon || j < 4)
                                                panel_switchweapon = it;
@@ -418,8 +424,11 @@ void HUD_Weapons()
                }
                else
                {
-                       if (((it.spawnflags & WEP_FLAG_HIDDEN) || (it.spawnflags & WEP_FLAG_MUTATORBLOCKED)) && !(weapons_stat & WepSet_FromWeapon(it)))
+                       if (it.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_SPECIALATTACK)
+                               && !(weapons_stat & WepSet_FromWeapon(it)))
+                       {
                                continue;
+                       }
                }
 
                // figure out the drawing position of weapon
@@ -490,7 +499,7 @@ void HUD_Weapons()
                        }
 
                        // draw ammo status bar
-                       if(!infinite_ammo && autocvar_hud_panel_weapons_ammo && (it.ammo_type != RESOURCE_NONE))
+                       if(!infinite_ammo && autocvar_hud_panel_weapons_ammo && (it.ammo_type != RES_NONE))
                        {
                                float ammo_full;
                                a = getstati(GetAmmoStat(it.ammo_type)); // how much ammo do we have?
@@ -499,12 +508,12 @@ void HUD_Weapons()
                                {
                                        switch (it.ammo_type)
                                        {
-                                               case RESOURCE_SHELLS:  ammo_full = autocvar_hud_panel_weapons_ammo_full_shells;  break;
-                                               case RESOURCE_BULLETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails;   break;
-                                               case RESOURCE_ROCKETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break;
-                                               case RESOURCE_CELLS:   ammo_full = autocvar_hud_panel_weapons_ammo_full_cells;   break;
-                                               case RESOURCE_PLASMA:  ammo_full = autocvar_hud_panel_weapons_ammo_full_plasma;  break;
-                                               case RESOURCE_FUEL:    ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel;    break;
+                                               case RES_SHELLS:  ammo_full = autocvar_hud_panel_weapons_ammo_full_shells;  break;
+                                               case RES_BULLETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails;   break;
+                                               case RES_ROCKETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break;
+                                               case RES_CELLS:   ammo_full = autocvar_hud_panel_weapons_ammo_full_cells;   break;
+                                               case RES_PLASMA:  ammo_full = autocvar_hud_panel_weapons_ammo_full_plasma;  break;
+                                               case RES_FUEL:    ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel;    break;
                                                default: ammo_full = 60;
                                        }