]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/selection.qc
Merge branch 'master' into terencehill/menu_optimization
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / selection.qc
index ce2a671c4584f9290ea9a67d93b985c102f11179..b301da6f2e46ff7eb44cf0929fbce458b0537deb 100644 (file)
@@ -1,18 +1,18 @@
 #include "selection.qh"
-#include "../_all.qh"
 
 #include "weaponsystem.qh"
 #include "../t_items.qh"
 #include "../../common/constants.qh"
 #include "../../common/util.qh"
+#include "../../common/items/item.qh"
 #include "../../common/weapons/all.qh"
+#include "../../common/mutators/mutator/waypoints/waypointsprites.qh"
 
 // switch between weapons
 void Send_WeaponComplain(entity e, float wpn, float type)
 {
        msg_entity = e;
-       WriteByte(MSG_ONE, SVC_TEMPENTITY);
-       WriteByte(MSG_ONE, TE_CSQC_WEAPONCOMPLAIN);
+       WriteHeader(MSG_ONE, TE_CSQC_WEAPONCOMPLAIN);
        WriteByte(MSG_ONE, wpn);
        WriteByte(MSG_ONE, type);
 }
@@ -26,7 +26,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
 
        // ignore hook button when using other offhand equipment
        if (cl.offhand != OFFHAND_HOOK)
-       if (wpn == WEP_HOOK.m_id && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn)))
+       if (wpn == WEP_HOOK.m_id && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(Weapons_from(wpn))))
            complain = 0;
 
        if(complain)
@@ -38,7 +38,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        sprint(self, "Invalid weapon\n");
                return false;
        }
-       if (cl.weapons & WepSet_FromWeapon(wpn))
+       if (cl.weapons & WepSet_FromWeapon(Weapons_from(wpn)))
        {
                if (andammo)
                {
@@ -49,7 +49,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        else
                        {
                                setself(cl);
-                               Weapon w = get_weaponinfo(wpn);
+                               Weapon w = Weapons_from(wpn);
                                f = w.wr_checkammo1(w) + w.wr_checkammo2(w);
 
                                // always allow selecting the Mine Layer if we placed mines, so that we can detonate them
@@ -77,7 +77,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
        {
                // DRESK - 3/16/07
                // Report Proper Weapon Status / Modified Weapon Ownership Message
-               if (weaponsInMap & WepSet_FromWeapon(wpn))
+               if (weaponsInMap & WepSet_FromWeapon(Weapons_from(wpn)))
                {
                        Send_WeaponComplain(cl, wpn, 1);
 
@@ -139,8 +139,8 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
        while(rest != "")
        {
                weaponwant = stof(car(rest)); rest = cdr(rest);
-               wep = get_weaponinfo(weaponwant);
-               wepset = WepSet_FromWeapon(weaponwant);
+               wep = Weapons_from(weaponwant);
+               wepset = wep.m_wepset;
                if(imp >= 0)
                if(wep.impulse != imp)
                        continue;
@@ -148,9 +148,10 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                float i, have_other = false;
                for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                {
+                       Weapon e = Weapons_from(i);
                        if(i != weaponwant)
-                       if((get_weaponinfo(i)).impulse == imp || imp < 0)
-                       if((pl.weapons & WepSet_FromWeapon(i)) || (weaponsInMap & WepSet_FromWeapon(i)))
+                       if(e.impulse == imp || imp < 0)
+                       if((pl.weapons & (e.m_wepset)) || (weaponsInMap & (e.m_wepset)))
                                have_other = true;
                }
 
@@ -196,8 +197,8 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                while(rest != "")
                {
                        weaponwant = stof(car(rest)); rest = cdr(rest);
-                       wep = get_weaponinfo(weaponwant);
-                       wepset = WepSet_FromWeapon(weaponwant);
+                       wep = Weapons_from(weaponwant);
+                       wepset = wep.m_wepset;
                        if(imp >= 0)
                                if(wep.impulse != imp)
                                        continue;
@@ -205,9 +206,10 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                        float i, have_other = false;
                        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                        {
+                               Weapon w = Weapons_from(i);
                                if(i != weaponwant)
-                               if((get_weaponinfo(i)).impulse == imp || imp < 0)
-                               if((pl.weapons & WepSet_FromWeapon(i)) || (weaponsInMap & WepSet_FromWeapon(i)))
+                               if(w.impulse == imp || imp < 0)
+                               if((pl.weapons & (w.m_wepset)) || (weaponsInMap & (w.m_wepset)))
                                        have_other = true;
                        }
 
@@ -239,13 +241,13 @@ void W_SwitchWeapon_Force(entity e, float w)
 void W_SwitchToOtherWeapon(entity pl)
 {
        // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway)
-       float w, ww;
-       w = pl.weapon;
-       if(pl.weapons & WepSet_FromWeapon(w))
+       int ww;
+       WepSet set = WepSet_FromWeapon(Weapons_from(pl.weapon));
+       if(pl.weapons & set)
        {
-               pl.weapons &= ~WepSet_FromWeapon(w);
+               pl.weapons &= ~set;
                ww = w_getbestweapon(pl);
-               pl.weapons |= WepSet_FromWeapon(w);
+               pl.weapons |= set;
        }
        else
                ww = w_getbestweapon(pl);
@@ -263,7 +265,7 @@ void W_SwitchWeapon(float imp)
                        self.selectweapon = imp; // update selectweapon ANYWAY
        }
        else if(!forbidWeaponUse(self)) {
-               Weapon w = get_weaponinfo(self.weapon);
+               Weapon w = Weapons_from(self.weapon);
                w.wr_reload(w);
        }
 }
@@ -307,7 +309,7 @@ void W_PreviousWeapon(float list)
 }
 
 // previously used if exists and has ammo, (second) best otherwise
-void W_LastWeapon(void)
+void W_LastWeapon()
 {SELFPARAM();
        if(client_hasweapon(self, self.cnt, true, false))
                W_SwitchWeapon(self.cnt);