From 2d3d069401a83bf8ee3e23724994b777738cc3b8 Mon Sep 17 00:00:00 2001
From: Mario <mario@smbclan.net>
Date: Thu, 8 Feb 2018 23:24:16 +1000
Subject: [PATCH] Alternative way of making auxiliary crosshairs spectatable

---
 qcsrc/common/vehicles/sv_vehicles.qc |  4 ++--
 qcsrc/server/client.qc               | 20 ++++----------------
 2 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc
index 1fbd802104..0cd864c382 100644
--- a/qcsrc/common/vehicles/sv_vehicles.qc
+++ b/qcsrc/common/vehicles/sv_vehicles.qc
@@ -26,8 +26,8 @@ bool SendAuxiliaryXhair(entity this, entity to, int sf)
 
 bool AuxiliaryXhair_customize(entity this, entity client)
 {
-	//entity e = WaypointSprite_getviewentity(client);
-	entity axh = client.(AuxiliaryXhair[this.cnt]);
+	entity e = WaypointSprite_getviewentity(client);
+	entity axh = e.(AuxiliaryXhair[this.cnt]);
 	return axh.owner == this.owner; // cheaply check if the client's axh owner is the same as our real owner
 }
 
diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc
index 749e59f142..c460f9dded 100644
--- a/qcsrc/server/client.qc
+++ b/qcsrc/server/client.qc
@@ -357,14 +357,6 @@ void PutObserverInServer(entity this)
 
 	//this.spawnpoint_targ = NULL; // keep it so they can return to where they were?
 
-	for(int slot = 0; slot < MAX_AXH; ++slot)
-	{
-		entity axh = this.(AuxiliaryXhair[slot]);
-		this.(AuxiliaryXhair[slot]) = NULL;
-		if(axh && axh.owner == this)
-			delete(axh);
-	}
-
 	this.weaponmodel = "";
 	for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
 	{
@@ -649,16 +641,17 @@ void PutPlayerInServer(entity this)
 
 	this.viewloc = NULL;
 
-	this.spawnpoint_targ = NULL;
-
 	for(int slot = 0; slot < MAX_AXH; ++slot)
 	{
 		entity axh = this.(AuxiliaryXhair[slot]);
 		this.(AuxiliaryXhair[slot]) = NULL;
-		if(axh && axh.owner == this)
+
+		if(axh.owner == this && axh != NULL && !wasfreed(axh))
 			delete(axh);
 	}
 
+	this.spawnpoint_targ = NULL;
+
 	this.crouch = false;
 	this.view_ofs = STAT(PL_VIEW_OFS, this);
 	setsize(this, STAT(PL_MIN, this), STAT(PL_MAX, this));
@@ -1811,11 +1804,6 @@ void SpectateCopy(entity this, entity spectatee)
 		this.(weaponentity) = spectatee.(weaponentity);
 	}
 
-	for(int slot = 0; slot < MAX_AXH; ++slot)
-	{
-		this.(AuxiliaryXhair[slot]) = spectatee.(AuxiliaryXhair[slot]);
-	}
-
     anticheat_spectatecopy(this, spectatee);
 	this.hud = spectatee.hud;
 	if(spectatee.vehicle)
-- 
2.39.5