]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Purge some more 0 slot cases
authorMario <mario@smbclan.net>
Wed, 5 Oct 2016 08:58:04 +0000 (18:58 +1000)
committerMario <mario@smbclan.net>
Wed, 5 Oct 2016 08:58:04 +0000 (18:58 +1000)
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/server/mutators/events.qh
qcsrc/server/weapons/throwing.qc

index 29bdd265fc5f2a6dc59629b41c1250c3d8e5d6de..00ffe6ab812c8a24f2d82617b5f78c017ccb7d27 100644 (file)
@@ -104,8 +104,8 @@ void nexball_setstatus(entity this)
                if(this.ballcarried.teamtime && (this.ballcarried.teamtime < time))
                {
                        bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n");
-                       DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0');
                        entity e = this.ballcarried;
+                       DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0');
                        ResetBall(e);
                }
                else
@@ -167,6 +167,7 @@ void GiveBall(entity plyr, entity ball)
                ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
 
        ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
+       ball.weaponentity_fld = weaponentity;
        ball.team = plyr.team;
        plyr.ballcarried = ball;
        ball.nb_dropper = plyr;
@@ -218,7 +219,7 @@ void DropBall(entity ball, vector org, vector vel)
        if(ball.owner.metertime)
        {
                ball.owner.metertime = 0;
-               .entity weaponentity = weaponentities[0]; // TODO: find ballstealer
+               .entity weaponentity = ball.weaponentity_fld;
                ball.owner.(weaponentity).state = WS_READY;
        }
 
@@ -994,16 +995,20 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink)
                }
                else
                {
-                       .entity weaponentity = weaponentities[0]; // TODO
-                       if(player.(weaponentity).weapons)
+                       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                        {
-                               player.weapons = player.(weaponentity).weapons;
-                               Weapon w = WEP_NEXBALL;
-                               w.wr_resetplayer(w, player);
-                               player.(weaponentity).m_switchweapon = player.m_switchweapon;
-                               W_SwitchWeapon(player, player.(weaponentity).m_switchweapon, weaponentity);
+                               .entity weaponentity = weaponentities[slot];
+
+                               if(player.(weaponentity).weapons)
+                               {
+                                       player.weapons = player.(weaponentity).weapons;
+                                       Weapon w = WEP_NEXBALL;
+                                       w.wr_resetplayer(w, player);
+                                       player.(weaponentity).m_switchweapon = player.m_switchweapon;
+                                       W_SwitchWeapon(player, player.(weaponentity).m_switchweapon, weaponentity);
 
-                               player.(weaponentity).weapons = '0 0 0';
+                                       player.(weaponentity).weapons = '0 0 0';
+                               }
                        }
                }
 
@@ -1055,18 +1060,18 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPhysics)
 
 MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon)
 {
-       entity player = M_ARGV(0, entity);
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+       //entity player = M_ARGV(0, entity);
+       entity wepent = M_ARGV(1, entity);
 
-       return player.(weaponentity).m_weapon == WEP_NEXBALL;
+       return wepent.m_weapon == WEP_NEXBALL;
 }
 
 MUTATOR_HOOKFUNCTION(nb, ForbidDropCurrentWeapon)
 {
-       entity player = M_ARGV(0, entity);
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+       //entity player = M_ARGV(0, entity);
+       int wep = M_ARGV(1, int);
 
-       return player.(weaponentity).m_weapon == WEP_MORTAR; // TODO: what is this for?
+       return wep == WEP_MORTAR.m_id; // TODO: what is this for?
 }
 
 MUTATOR_HOOKFUNCTION(nb, FilterItem)
index 232d2cfbe880b070e3f589b7ffe031c2dd1409fe..670e4c52ee2a70543675b9e6280d1ffa3dea24a7 100644 (file)
@@ -137,12 +137,14 @@ MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage);
 /** returns true if throwing the current weapon shall not be allowed */
 #define EV_ForbidThrowCurrentWeapon(i, o) \
     /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
+    /** weapon entity */ i(entity, MUTATOR_ARGV_1_entity) \
     /**/
 MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon);
 
 /** returns true if dropping the current weapon shall not be allowed at any time including death */
 #define EV_ForbidDropCurrentWeapon(i, o) \
-    /** player */ i(entity, MUTATOR_ARGV_0_entity) \
+    /** player */        i(entity, MUTATOR_ARGV_0_entity) \
+    /** weapon id */     i(int, MUTATOR_ARGV_1_int) \
     /**/
 MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon);
 
index 10fead1a610099dfcfdfb879a3d47675c656033c..a9fabf50a40239d9982e6a9bca266601f76c1cbe 100644 (file)
@@ -138,7 +138,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
 
 bool W_IsWeaponThrowable(entity this, int w)
 {
-       if (MUTATOR_CALLHOOK(ForbidDropCurrentWeapon, this))
+       if (MUTATOR_CALLHOOK(ForbidDropCurrentWeapon, this, w))
                return false;
        if (!autocvar_g_pickup_items)
                return false;
@@ -170,7 +170,7 @@ void W_ThrowWeapon(entity this, .entity weaponentity, vector velo, vector delta,
        Weapon w = this.(weaponentity).m_weapon;
        if (w == WEP_Null)
                return; // just in case
-       if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon, this))
+       if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon, this, this.(weaponentity)))
                return;
        if(!autocvar_g_weapon_throwable)
                return;
@@ -192,7 +192,9 @@ void W_ThrowWeapon(entity this, .entity weaponentity, vector velo, vector delta,
 
 void SpawnThrownWeapon(entity this, vector org, float w, .entity weaponentity)
 {
-       if(this.weapons & WepSet_FromWeapon(this.(weaponentity).m_weapon))
-               if(W_IsWeaponThrowable(this, this.(weaponentity).m_weapon.m_id))
-                       W_ThrowNewWeapon(this, this.(weaponentity).m_weapon.m_id, false, org, randomvec() * 125 + '0 0 200', weaponentity);
+       entity wep = this.(weaponentity).m_weapon;
+
+       if(this.weapons & WepSet_FromWeapon(wep))
+               if(W_IsWeaponThrowable(this, wep.m_id))
+                       W_ThrowNewWeapon(this, wep.m_id, false, org, randomvec() * 125 + '0 0 200', weaponentity);
 }