]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Turn complain_weapon into an entity to reduce accesses to .m_id field
authorterencehill <piuntn@gmail.com>
Mon, 18 Jun 2018 17:59:02 +0000 (19:59 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 18 Jun 2018 17:59:02 +0000 (19:59 +0200)
qcsrc/client/hud/hud.qh
qcsrc/client/hud/panel/weapons.qc
qcsrc/client/main.qc

index 950dee17ad5ec77799cab431c5bc3229f13d58af..68d1e6bffabb1c327a75d5068b91a7cfd072683e 100644 (file)
@@ -86,8 +86,8 @@ const float BORDER_MULTIPLIER = 4;
 float scoreboard_bottom;
 int weapon_accuracy[Weapons_MAX];
 
-int complain_weapon;
-float complain_weapon_type;
+entity complain_weapon;
+int complain_weapon_type;
 float complain_weapon_time;
 
 PlayerScoreField ps_primary, ps_secondary;
index f94979133c588c634d576f8e8b1b1fb545fa9337..5d75c7dd2a4182fe19d9a4ec67d2940a3d877174 100644 (file)
@@ -108,7 +108,7 @@ void HUD_Weapons()
        }
 
        if(!autocvar_hud_panel_weapons_complainbubble || autocvar__hud_configure || time - complain_weapon_time >= when + fadetime)
-               complain_weapon = 0;
+               complain_weapon = NULL;
 
        entity wepent = viewmodels[0]; // TODO: unhardcode
 
@@ -169,13 +169,13 @@ void HUD_Weapons()
                if (autocvar_hud_panel_weapons_onlyowned >= 2) // only current
                {
                        for (i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
-                               if (weaponorder[i] == panel_switchweapon || weaponorder[i].m_id == complain_weapon)
+                               if (weaponorder[i] == panel_switchweapon || weaponorder[i] == complain_weapon)
                                        ++weapon_count;
                }
                else
                {
                        for (i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
-                               if ((weapons_stat & WepSet_FromWeapon(weaponorder[i])) || weaponorder[i].m_id == complain_weapon)
+                               if ((weapons_stat & WepSet_FromWeapon(weaponorder[i])) || weaponorder[i] == complain_weapon)
                                        ++weapon_count;
                }
 
@@ -407,12 +407,12 @@ void HUD_Weapons()
                {
                        if (autocvar_hud_panel_weapons_onlyowned >= 2) // only current
                        {
-                               if (!(it == panel_switchweapon || it.m_id == complain_weapon))
+                               if (!(it == panel_switchweapon || it == complain_weapon))
                                        continue;
                        }
                        else
                        {
-                               if (!((weapons_stat & WepSet_FromWeapon(it)) || (it.m_id == complain_weapon)))
+                               if (!((weapons_stat & WepSet_FromWeapon(it)) || (it == complain_weapon)))
                                        continue;
                        }
                }
@@ -534,7 +534,7 @@ void HUD_Weapons()
                }
 
                // draw the complain message
-               if(it.m_id == complain_weapon)
+               if(it == complain_weapon)
                {
                        if(fadetime)
                                a = ((complain_weapon_time + when > time) ? 1 : bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1));
index 3de8cefeb661084515be0ebe365d88f73888ede5..218df18a474fc47746e8a928f77e164ecece995f 100644 (file)
@@ -1216,7 +1216,8 @@ NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew)
 
 NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
 {
-       complain_weapon = ReadByte();
+       int weapon_id = ReadByte();
+       complain_weapon = Weapons_from(weapon_id);
        complain_weapon_type = ReadByte();
        return = true;
 
@@ -1225,9 +1226,9 @@ NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
 
        switch(complain_weapon_type)
        {
-               case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break;
-               case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break;
-               default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break;
+               case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, weapon_id); break;
+               case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, weapon_id); break;
+               default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, weapon_id); break;
        }
 }