]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/selection.qc
Merge remote-tracking branch 'origin/master' into samual/weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / selection.qc
index 837350229eaf417c841c99b5afce432b3dab9981..482b3180a0078222670860bf9fcb2eec018b509a 100644 (file)
@@ -1,11 +1,10 @@
 // switch between weapons
-void Send_WeaponComplain(entity e, float wpn, string wpnname, float type)
+void Send_WeaponComplain(entity e, float wpn, float type)
 {
        msg_entity = e;
        WriteByte(MSG_ONE, SVC_TEMPENTITY);
        WriteByte(MSG_ONE, TE_CSQC_WEAPONCOMPLAIN);
        WriteByte(MSG_ONE, wpn);
-       WriteString(MSG_ONE, wpnname);
        WriteByte(MSG_ONE, type);
 }
 
@@ -16,6 +15,10 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
 
        if(time < self.hasweapon_complain_spam)
                complain = 0;
+
+       if(wpn == WEP_HOOK && !g_grappling_hook && autocvar_g_nades && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn)))
+               complain = 0;
+               
        if(complain)
                self.hasweapon_complain_spam = time + 0.2;
 
@@ -25,7 +28,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        sprint(self, "Invalid weapon\n");
                return FALSE;
        }
-       if (WEPSET_CONTAINS_EW(cl, wpn))
+       if (cl.weapons & WepSet_FromWeapon(wpn))
        {
                if (andammo)
                {
@@ -54,7 +57,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                if(IS_REAL_CLIENT(cl))
                                {
                                        play2(cl, "weapons/unavailable.wav");
-                                       Send_WeaponComplain (cl, wpn, W_Name(wpn), 0);
+                                       Send_WeaponComplain (cl, wpn, 0);
                                }
                                return FALSE;
                        }
@@ -65,26 +68,22 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
        {
                // DRESK - 3/16/07
                // Report Proper Weapon Status / Modified Weapon Ownership Message
-               if (WEPSET_CONTAINS_AW(weaponsInMap, wpn))
+               if (weaponsInMap & WepSet_FromWeapon(wpn))
                {
-                       Send_WeaponComplain(cl, wpn, W_Name(wpn), 1);
+                       Send_WeaponComplain(cl, wpn, 1);
 
                        if(autocvar_g_showweaponspawns)
                        {
                                entity e;
-                               string s;
-
-                               e = get_weaponinfo(wpn);
-                               s = e.model2;
 
                                for(e = world; (e = findfloat(e, weapon, wpn)); )
                                {
                                        if(e.classname == "droppedweapon")
                                                continue;
-                                       if not(e.flags & FL_ITEM)
+                                       if(!(e.flags & FL_ITEM))
                                                continue;
                                        WaypointSprite_Spawn(
-                                               s,
+                                               (get_weaponinfo(wpn)).wpmodel,
                                                1, 0,
                                                world, e.origin,
                                                self, 0,
@@ -97,7 +96,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                }
                else
                {
-                       Send_WeaponComplain (cl, wpn, W_Name(wpn), 2);
+                       Send_WeaponComplain (cl, wpn, 2);
                }
 
                play2(cl, "weapons/unavailable.wav");
@@ -114,6 +113,7 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
        switchtonext = switchtolast = 0;
        first_valid = prev_valid = 0;
        float weaponcur;
+       entity wep;
 
        if(skipmissing || pl.selectweapon == 0)
                weaponcur = pl.switchweapon;
@@ -129,10 +129,17 @@ 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);
                if(imp >= 0)
-                       if((get_weaponinfo(weaponwant)).impulse != imp)
+                       if(wep.impulse != imp)
                                continue;
 
+               // skip weapons we don't own that aren't normal and aren't in the map
+               if(!(pl.weapons & WepSet_FromWeapon(weaponwant)))
+                       if(!((get_weaponinfo(weaponwant)).spawnflags & WEP_FLAG_NORMAL))
+                               if(!(weaponsInMap & WepSet_FromWeapon(weaponwant)))
+                                       continue;
+
                ++c;
 
                if(!skipmissing || client_hasweapon(pl, weaponwant, TRUE, FALSE))
@@ -169,10 +176,17 @@ 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);
                        if(imp >= 0)
-                               if((get_weaponinfo(weaponwant)).impulse != imp)
+                               if(wep.impulse != imp)
                                        continue;
 
+                       // skip weapons we don't own that aren't normal and aren't in the map
+                       if(!(pl.weapons & WepSet_FromWeapon(weaponwant)))
+                               if(!((get_weaponinfo(weaponwant)).spawnflags & WEP_FLAG_NORMAL))
+                                       if(!(weaponsInMap & WepSet_FromWeapon(weaponwant)))
+                                               continue;
+
                        --c;
                        if(c == 0)
                        {
@@ -197,11 +211,11 @@ 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(WEPSET_CONTAINS_EW(pl, w))
+       if(pl.weapons & WepSet_FromWeapon(w))
        {
-               WEPSET_ANDNOT_EW(pl, w);
+               pl.weapons &= ~WepSet_FromWeapon(w);
                ww = w_getbestweapon(pl);
-               WEPSET_OR_EW(pl, w);
+               pl.weapons |= WepSet_FromWeapon(w);
        }
        else
                ww = w_getbestweapon(pl);