From c21ce28cb332b39863c2d8ba9c6dc621bd6e4336 Mon Sep 17 00:00:00 2001
From: Mario <mario@smbclan.net>
Date: Tue, 9 Aug 2016 19:46:05 +1000
Subject: [PATCH] Fix wr_gonethink

---
 qcsrc/common/weapons/weapon.qh       |  2 +-
 qcsrc/common/weapons/weapon/hagar.qc | 12 +++---------
 qcsrc/server/weapons/weaponsystem.qc |  2 +-
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh
index b2ede3c503..3b83b450fe 100644
--- a/qcsrc/common/weapons/weapon.qh
+++ b/qcsrc/common/weapons/weapon.qh
@@ -109,7 +109,7 @@ CLASS(Weapon, Object)
     /** (SERVER) called whenever a player dies */
     METHOD(Weapon, wr_playerdeath, void(Weapon this, entity actor)) {}
     /** (SERVER) logic to run when weapon is lost */
-    METHOD(Weapon, wr_gonethink, void(Weapon this, entity actor)) {}
+    METHOD(Weapon, wr_gonethink, void(Weapon this, entity actor, .entity weaponentity)) {}
     /** (ALL)    dump weapon cvars to config in data directory (see: sv_cmd dumpweapons) */
     METHOD(Weapon, wr_config, void(Weapon this)) {}
     /** (CLIENT) weapon specific zoom reticle */
diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc
index f161823d28..70335cc0e5 100644
--- a/qcsrc/common/weapons/weapon/hagar.qc
+++ b/qcsrc/common/weapons/weapon/hagar.qc
@@ -471,19 +471,13 @@ METHOD(Hagar, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
         }
     }
 }
-METHOD(Hagar, wr_gonethink, void(entity thiswep, entity actor))
+METHOD(Hagar, wr_gonethink, void(entity thiswep, entity actor, .entity weaponentity))
 {
     // we lost the weapon and want to prepare switching away
     if(actor.hagar_load)
     {
-        for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-    	{
-    		.entity weaponentity = weaponentities[slot];
-    		if(actor.(weaponentity).weaponname != WEP_HAGAR.mdl)
-    			continue; // only if it's a hagar (currently only way to detect)
-    		actor.(weaponentity).state = WS_READY;
-    		W_Hagar_Attack2_Load_Release(actor, weaponentity);
-    	}
+    	actor.(weaponentity).state = WS_READY;
+    	W_Hagar_Attack2_Load_Release(actor, weaponentity);
     }
 }
 METHOD(Hagar, wr_setup, void(entity thiswep, entity actor))
diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc
index 6cc1324cf4..1a4e797f52 100644
--- a/qcsrc/server/weapons/weaponsystem.qc
+++ b/qcsrc/server/weapons/weaponsystem.qc
@@ -569,7 +569,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
 			}
 			else if (e)
 			{
-				e.wr_gonethink(e, actor);
+				e.wr_gonethink(e, actor, weaponentity);
 			}
 		}
 
-- 
2.39.5