]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up self uses in weapon dropping code, also switch EXACTTRIGGER_INIT over to...
authorMario <mario@smbclan.net>
Thu, 19 May 2016 20:25:20 +0000 (06:25 +1000)
committerMario <mario@smbclan.net>
Thu, 19 May 2016 20:25:20 +0000 (06:25 +1000)
12 files changed:
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/mutators/mutator/pinata/pinata.qc
qcsrc/common/triggers/triggers.qc
qcsrc/lib/warpzone/common.qh
qcsrc/lib/warpzone/server.qc
qcsrc/lib/warpzone/util_server.qc
qcsrc/lib/warpzone/util_server.qh
qcsrc/server/cl_impulse.qc
qcsrc/server/mutators/events.qh
qcsrc/server/weapons/throwing.qc
qcsrc/server/weapons/throwing.qh
qcsrc/server/weapons/weaponsystem.qc

index d4cc871d9112d4abaa70af68871c0669c8ac463b..b0872497dc9f767cbd9847795c9750383a69f426 100644 (file)
@@ -614,7 +614,7 @@ void SpawnGoal(entity this)
 {
        if(!g_nexball) { remove(this); return; }
 
-       WITHSELF(this, WarpZoneLib_ExactTrigger_Init());
+       EXACTTRIGGER_INIT;
 
        if(this.team != GOAL_OUT && Team_TeamToNumber(this.team) != -1)
        {
index 22ab9acae3d2193382a240a10c69556ae6d17d36..62dd19e4f07c09650591e074099f7efe815c1b26 100644 (file)
@@ -6,7 +6,7 @@ MUTATOR_HOOKFUNCTION(pinata, PlayerDies)
        FOREACH(Weapons, it != WEP_Null, LAMBDA(
                if(frag_target.weapons & WepSet_FromWeapon(it))
                if(PS(frag_target).m_switchweapon != it)
-               if(W_IsWeaponThrowable(it.m_id))
+               if(W_IsWeaponThrowable(frag_target, it.m_id))
                        W_ThrowNewWeapon(frag_target, it.m_id, false, CENTER_OR_VIEWOFS(frag_target), randomvec() * 175 + '0 0 325');
        ));
 
index 4493138d08dca032f149aaba09a4f8e5f2817f53..776044573edf934f3a354c55a3ee4d09e4662d3f 100644 (file)
@@ -24,7 +24,7 @@ void FixSize(entity e)
 void trigger_init(entity this)
 {
        string m = this.model;
-       WITHSELF(this, WarpZoneLib_ExactTrigger_Init());
+       EXACTTRIGGER_INIT;
        if(m != "")
        {
                precache_model(m);
index ebea01108dc72927c5180964e4599ed85e2262ff..c8279009580e9c085c533399e200a827b0ca48e2 100644 (file)
@@ -108,9 +108,9 @@ float WarpZoneLib_MoveOutOfSolid(entity e);
 #define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)
 
 float WarpZoneLib_ExactTrigger_Touch();
-void WarpZoneLib_ExactTrigger_Init();
+void WarpZoneLib_ExactTrigger_Init(entity this);
 
 // WARNING: this kills the trace globals
 #define EXACTTRIGGER_TOUCH if(WarpZoneLib_ExactTrigger_Touch()) return
-#define EXACTTRIGGER_INIT  WarpZoneLib_ExactTrigger_Init()
+#define EXACTTRIGGER_INIT  WarpZoneLib_ExactTrigger_Init(this)
 #endif
index f8260b5ad0a7c3c2b7c4fb52bef6699efe7ade73..6a748eed4181eca1f71c39ac57b56576054e5551 100644 (file)
@@ -761,7 +761,7 @@ spawnfunc(trigger_warpzone)
                this.scale = 1;
        string m;
        m = this.model;
-       WarpZoneLib_ExactTrigger_Init();
+       WarpZoneLib_ExactTrigger_Init(this);
        if(m != "")
        {
                precache_model(m);
index be232a28187af10a9f059ea2044eff531160be82..73f09c0e07e871c65c738e887547ec95e8e46d31 100644 (file)
@@ -9,8 +9,8 @@
 #endif
 #include "common.qh"
 
-void WarpZoneLib_ExactTrigger_Init()
-{SELFPARAM();
+void WarpZoneLib_ExactTrigger_Init(entity this)
+{
        vector mi, ma;
        if (this.movedir == '0 0 0')
        if (this.angles != '0 0 0')
index 75df5d862656b06141a03fdb850506320fbe987f..5c94d4319f210836bef113af9079d57bd354bc6c 100644 (file)
@@ -4,6 +4,6 @@
 float WarpZoneLib_MoveOutOfSolid(entity e);
 float WarpZoneLib_ExactTrigger_Touch();
 #ifdef SVQC
-void WarpZoneLib_ExactTrigger_Init();
+void WarpZoneLib_ExactTrigger_Init(entity this);
 #endif
 #endif
index 14779525fdaa53cfe83c95bde9cbc04be2d4daa5..3aa9cfeb7fa797ce0fa086b9030dffa2f31c9628 100644 (file)
@@ -248,7 +248,7 @@ IMPULSE(weapon_drop)
 {
        if (this.vehicle) return;
        if (IS_DEAD(this)) return;
-       W_ThrowWeapon(W_CalculateProjectileVelocity(this.velocity, v_forward * 750, false), '0 0 0', true);
+       W_ThrowWeapon(this, W_CalculateProjectileVelocity(this.velocity, v_forward * 750, false), '0 0 0', true);
 }
 
 IMPULSE(weapon_reload)
index 8039d8348f0108d497e21560491d95760560de86..fac7249c8b2d241ba57c3eee2fa7fee1a72891c1 100644 (file)
@@ -126,10 +126,16 @@ string format_message;
 MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage);
 
 /** returns true if throwing the current weapon shall not be allowed */
-MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_NO_ARGS);
+#define EV_ForbidThrowCurrentWeapon(i, o) \
+    /**/ i(entity, __self) \
+    /**/
+MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon);
 
 /** returns true if dropping the current weapon shall not be allowed at any time including death */
-MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_NO_ARGS);
+#define EV_ForbidDropCurrentWeapon(i, o) \
+    /**/ i(entity, __self) \
+    /**/
+MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon);
 
 /**  */
 MUTATOR_HOOKABLE(SetDefaultAlpha, EV_NO_ARGS);
index c06b08c08ac2a387618e90a6cc1f18357278b218..43285fb6a32c74e5dbe588026aa9c405069f16a0 100644 (file)
@@ -32,7 +32,7 @@ void thrown_wep_think()
 
 // returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo)
-{SELFPARAM();
+{
        float thisammo;
        string s;
        Weapon info = Weapons_from(wpn);
@@ -97,11 +97,11 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                if(doreduce && g_weapon_stay == 2)
                {
                        // if our weapon is loaded, give its load back to the player
-                       int i = PS(self).m_weapon.m_id;
-                       if(self.(weapon_load[i]) > 0)
+                       int i = PS(own).m_weapon.m_id;
+                       if(own.(weapon_load[i]) > 0)
                        {
-                               own.(ammotype) += self.(weapon_load[i]);
-                               self.(weapon_load[i]) = -1; // schedule the weapon for reloading
+                               own.(ammotype) += own.(weapon_load[i]);
+                               own.(weapon_load[i]) = -1; // schedule the weapon for reloading
                        }
 
                        wep.(ammotype) = 0;
@@ -109,11 +109,11 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                else if(doreduce)
                {
                        // if our weapon is loaded, give its load back to the player
-                       int i = PS(self).m_weapon.m_id;
-                       if(self.(weapon_load[i]) > 0)
+                       int i = PS(own).m_weapon.m_id;
+                       if(own.(weapon_load[i]) > 0)
                        {
-                               own.(ammotype) += self.(weapon_load[i]);
-                               self.(weapon_load[i]) = -1; // schedule the weapon for reloading
+                               own.(ammotype) += own.(weapon_load[i]);
+                               own.(weapon_load[i]) = -1; // schedule the weapon for reloading
                        }
 
                        thisammo = min(own.(ammotype), wep.(ammotype));
@@ -136,9 +136,9 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
        }
 }
 
-bool W_IsWeaponThrowable(bool w)
+bool W_IsWeaponThrowable(entity this, int w)
 {
-       if (MUTATOR_CALLHOOK(ForbidDropCurrentWeapon))
+       if (MUTATOR_CALLHOOK(ForbidDropCurrentWeapon, this))
                return false;
        if (!autocvar_g_pickup_items)
                return false;
@@ -165,35 +165,35 @@ bool W_IsWeaponThrowable(bool w)
 }
 
 // toss current weapon
-void W_ThrowWeapon(vector velo, vector delta, float doreduce)
-{SELFPARAM();
-       Weapon w = PS(self).m_weapon;
+void W_ThrowWeapon(entity this, vector velo, vector delta, float doreduce)
+{
+       Weapon w = PS(this).m_weapon;
        if (w == WEP_Null)
                return; // just in case
-       if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon))
+       if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon, this))
                return;
        if(!autocvar_g_weapon_throwable)
                return;
        .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-       if(self.(weaponentity).state != WS_READY)
+       if(this.(weaponentity).state != WS_READY)
                return;
-       if(!W_IsWeaponThrowable(w.m_id))
+       if(!W_IsWeaponThrowable(this, w.m_id))
                return;
 
        WepSet set = WepSet_FromWeapon(w);
-       if(!(self.weapons & set)) return;
-       self.weapons &= ~set;
+       if(!(this.weapons & set)) return;
+       this.weapons &= ~set;
 
-       W_SwitchWeapon_Force(self, w_getbestweapon(self));
-       string a = W_ThrowNewWeapon(self, w.m_id, doreduce, self.origin + delta, velo);
+       W_SwitchWeapon_Force(this, w_getbestweapon(this));
+       string a = W_ThrowNewWeapon(this, w.m_id, doreduce, this.origin + delta, velo);
 
        if(!a) return;
-       Send_Notification(NOTIF_ONE, self, MSG_MULTI, ITEM_WEAPON_DROP, a, w.m_id);
+       Send_Notification(NOTIF_ONE, this, MSG_MULTI, ITEM_WEAPON_DROP, a, w.m_id);
 }
 
 void SpawnThrownWeapon(entity this, vector org, float w)
 {
        if(this.weapons & WepSet_FromWeapon(PS(this).m_weapon))
-               if(W_IsWeaponThrowable(PS(this).m_weapon.m_id))
+               if(W_IsWeaponThrowable(this, PS(this).m_weapon.m_id))
                        W_ThrowNewWeapon(this, PS(this).m_weapon.m_id, false, org, randomvec() * 125 + '0 0 200');
 }
index 488791295b59bf8ed52df983ed949c6164abb2a6..b0482da9193bd34cb84b18e1d8a65dff74ef7db6 100644 (file)
@@ -6,9 +6,9 @@ void thrown_wep_think();
 // returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
 
-float W_IsWeaponThrowable(float w);
+bool W_IsWeaponThrowable(entity this, int w);
 
 // toss current weapon
-void W_ThrowWeapon(vector velo, vector delta, float doreduce);
+void W_ThrowWeapon(entity this, vector velo, vector delta, float doreduce);
 
 void SpawnThrownWeapon(entity this, vector org, float w);
index f44b3929013c2a5929abed8cb8add8679145017e..53d421ab6fdfcd3a47dfb7e79a65057a61d31983 100644 (file)
@@ -769,7 +769,6 @@ void W_Reload(entity actor, float sent_ammo_min, Sound sent_sound)
 
 void W_DropEvent(.void(Weapon) event, entity player, float weapon_type, entity weapon_item)
 {
-    SELFPARAM();
        Weapon w = Weapons_from(weapon_type);
        weapon_dropevent_item = weapon_item;
        WITHSELF(player, w.event(w));