From: TimePath <andrew.hardaker1995@gmail.com>
Date: Mon, 14 Mar 2016 04:43:26 +0000 (+1100)
Subject: W_WeaponFrame: use weapon reference, not id
X-Git-Tag: xonotic-v0.8.2~1091
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=dc5f1d6ca22ac02ac126b80d44826190f52d5b2b;p=xonotic%2Fxonotic-data.pk3dir.git

W_WeaponFrame: use weapon reference, not id
---

diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc
index 3fd9e896f..f65060e88 100644
--- a/qcsrc/server/weapons/weaponsystem.qc
+++ b/qcsrc/server/weapons/weaponsystem.qc
@@ -512,17 +512,17 @@ void W_WeaponFrame(entity actor)
 	// if (actor.button0)
 	//	print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(actor, slot)), " >= ", ftos(this.weapon_nextthink), "\n");
 
-	int w = PS(actor).m_weapon.m_id;
+	Weapon w = PS(actor).m_weapon;
 
 	// call the think code which may fire the weapon
 	// and do so multiple times to resolve framerate dependency issues if the
 	// server framerate is very low and the weapon fire rate very high
 	for (int c = 0; c < W_TICSPERFRAME; ++c)
 	{
-		if (w && !(actor.weapons & WepSet_FromWeapon(Weapons_from(w))))
+		if (w != WEP_Null && !(actor.weapons & WepSet_FromWeapon(w)))
 		{
 			if (PS(actor).m_weapon == PS(actor).m_switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
-			w = 0;
+			w = WEP_Null;
 		}
 
 		v_forward = fo;
@@ -554,15 +554,14 @@ void W_WeaponFrame(entity actor)
 
 		if (!block_weapon)
 		{
-			if (w)
+            Weapon e = PS(actor).m_weapon;
+			if (w != WEP_Null)
 			{
-				Weapon e = PS(actor).m_weapon;
 				e.wr_think(e, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
 			}
 			else
 			{
-				Weapon w = PS(actor).m_weapon;
-				w.wr_gonethink(w);
+				e.wr_gonethink(e);
 			}
 		}