From 8b8fd61e6c99b1b10f9cb0b6bd8c1d70963bfaa9 Mon Sep 17 00:00:00 2001
From: tankefugl <tankefugl@67975925-1194-0748-b3d5-c16f83f1a3a1>
Date: Wed, 13 Apr 2005 00:45:59 +0000
Subject: [PATCH] Mantis 0000991: o Structure health is now always visible to
 maintance players (using welder or having healspray as active weapon) o Small
 optimization

Mantis 0000992:
o Ensured all teammate order data got wiped on HUD reset (ClearData())

- Enabled new hitbox code check


git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@75 67975925-1194-0748-b3d5-c16f83f1a3a1
---
 dev/tankefugl/source/mod/AvHHud.cpp        |  3 ++
 dev/tankefugl/source/mod/AvHHudRender.cpp  | 38 ++++++++++++++--------
 dev/tankefugl/source/mod/AvHPlayer.cpp     |  2 +-
 dev/tankefugl/source/mod/AvHServerUtil.cpp |  4 +--
 4 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/dev/tankefugl/source/mod/AvHHud.cpp b/dev/tankefugl/source/mod/AvHHud.cpp
index 864aeb3..829b4cd 100644
--- a/dev/tankefugl/source/mod/AvHHud.cpp
+++ b/dev/tankefugl/source/mod/AvHHud.cpp
@@ -649,6 +649,9 @@ void AvHHud::ClearData()
 
 	// tankefugl: 0000971 
 	this->mTeammateOrder.clear();
+	this->mDisplayOrderIndex = 0;
+	this->mDisplayOrderTime = 0;
+	this->mDisplayOrderType = 0;
 	// :tankefugl
 }
 
diff --git a/dev/tankefugl/source/mod/AvHHudRender.cpp b/dev/tankefugl/source/mod/AvHHudRender.cpp
index d4c2fca..722fba3 100644
--- a/dev/tankefugl/source/mod/AvHHudRender.cpp
+++ b/dev/tankefugl/source/mod/AvHHudRender.cpp
@@ -159,7 +159,6 @@ extern AvHCommanderModeHandler	gCommanderHandler;
 extern AvHParticleEditorHandler	gParticleEditorHandler;
 float kD3DErrorValue = 0.01f;
 
-
 vec3_t GetViewOrigin()
 {
 	vec3_t theOrigin = v_origin;
@@ -2397,8 +2396,11 @@ void AvHHud::DrawBuildHealthEffectsForEntity(int inEntityIndex, float inAlpha)
 				// It's an unfriendly building that's very close OR
 				(!theEntityIsPlayer && (theDistanceToEntity < kDrawEnemyBuildingDistance)) ||
 
-				// It's a friendly entity and we're a builder
-				(theIsOnOurTeam && (this->GetHUDUser3() == AVH_USER3_ALIEN_PLAYER2))
+				// It's a friendly entity and we're a builder OR
+				(theIsOnOurTeam && (this->GetHUDUser3() == AVH_USER3_ALIEN_PLAYER2)) ||
+
+				// welder/healing spray is selected
+				(this->mCurrentWeaponID == 18 || this->mCurrentWeaponID == 27)
 
 				)
 			{
@@ -2521,16 +2523,17 @@ void AvHHud::DrawSelectionAndBuildEffects()
 		// :tankefugl
 	}
 
-// tankefugl: 0000988 
-	gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
-	gEngfuncs.pEventAPI->EV_PushPMStates();
-	gEngfuncs.pEventAPI->EV_SetSolidPlayers(-1);
+	// tankefugl: 0000988 & 0000991
+	bool maintanceWeaponSelected = (this->mCurrentWeaponID == 18 || this->mCurrentWeaponID == 27);
+	bool isCommander = this->GetInTopDownMode();
+	if (isCommander || maintanceWeaponSelected) {		
+		gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
+		gEngfuncs.pEventAPI->EV_PushPMStates();
+		gEngfuncs.pEventAPI->EV_SetSolidPlayers(-1);
 
-	if (this->GetInTopDownMode()) {
 		int localPlayerIndex = gEngfuncs.GetLocalPlayer()->index;
-		physent_t *thePlayer = gEngfuncs.pEventAPI->EV_GetPhysent(localPlayerIndex);
-//		gEngfuncs.Con_Printf("gEngfuncs.GetLocalPlayer()->index = %d, thePlayer->team = %d\n", gEngfuncs.GetLocalPlayer()->index, thePlayer->team);
 
+		physent_t *thePlayer = gEngfuncs.pEventAPI->EV_GetPhysent(localPlayerIndex);
 		physent_t* theEntity = NULL;
 		int theNumEnts = pmove->numphysent;
 		for (int i = 0; i < theNumEnts; i++)
@@ -2547,17 +2550,24 @@ void AvHHud::DrawSelectionAndBuildEffects()
 						bool theIsPlayer = ((theEntityIndex >= 1) && (theEntityIndex <= gEngfuncs.GetMaxClients()));
 						bool theSameTeam = (theEntity->team == thePlayer->team );
 						
-						if(theIsPlayer || theSameTeam)
+						if (isCommander && (theIsPlayer || theSameTeam))
 						{
-							this->DrawBuildHealthEffectsForEntity(theEntityIndex, 0.3);
+							this->DrawBuildHealthEffectsForEntity(theEntityIndex, 0.2);
+						}
+						else if (maintanceWeaponSelected && theSameTeam && !theIsPlayer)
+						{
+							if (AvHTraceLineAgainstWorld(gEngfuncs.GetLocalPlayer()->origin, theEntity->origin) == 1.0f)
+							{
+								this->DrawBuildHealthEffectsForEntity(theEntityIndex, 0.3);
+							}
 						}
 					}
 				}
 			}
 		}
+		gEngfuncs.pEventAPI->EV_PopPMStates();
 	}
-	gEngfuncs.pEventAPI->EV_PopPMStates();
-// :tankefugl
+	// :tankefugl
 }
 
 
diff --git a/dev/tankefugl/source/mod/AvHPlayer.cpp b/dev/tankefugl/source/mod/AvHPlayer.cpp
index d229682..56fb5a1 100644
--- a/dev/tankefugl/source/mod/AvHPlayer.cpp
+++ b/dev/tankefugl/source/mod/AvHPlayer.cpp
@@ -1364,7 +1364,7 @@ bool AvHPlayer::ExecuteMessage(AvHMessageID inMessageID, bool inInstantaneous, b
 				int theTraced = 0;
 				vec3_t vecFrom, vecTo;
 
-				if (theEntity->GetTeam() == this->GetTeam())
+				if ((theEntity->entindex() != this->entindex()) && (theEntity->GetTeam() == this->GetTeam()))
 				{
 					VectorSubtract(theEntity->pev->origin, this->pev->origin, vecDistance);
 					// theDistance = Length(vecDistance);
diff --git a/dev/tankefugl/source/mod/AvHServerUtil.cpp b/dev/tankefugl/source/mod/AvHServerUtil.cpp
index 8a46907..72f5b58 100644
--- a/dev/tankefugl/source/mod/AvHServerUtil.cpp
+++ b/dev/tankefugl/source/mod/AvHServerUtil.cpp
@@ -1224,14 +1224,14 @@ void AvHSUServerTraceBullets(const Vector& inStart, const Vector& inEnd, IGNORE_
 	outProtected = false;
 
     // This is the old way that doesn't take into account skulk rotation.
-    UTIL_TraceLine(inStart, inEnd, inIgnoreMonsters, /*dont_ignore_glass,*/ inIgnoreEdict, &outTraceResult);
+    // UTIL_TraceLine(inStart, inEnd, inIgnoreMonsters, /*dont_ignore_glass,*/ inIgnoreEdict, &outTraceResult);
     
     // TEMP removed the skulk hitboxes since it's too risky for the LAN.
 	// joev:  0000573
 	// this was commented out meaning that it was just stock tracelines, not using Max M's superb hitbox collision code.
 	// Now *all* hitboxes perform as expected and the crouched fade can be shot pretty much anywhere on the model
 	// (allowing for about a 5% visual disparity) 
-    //AvHTraceLine(inStart, inEnd, inIgnoreMonsters, /*dont_ignore_glass,*/ inIgnoreEdict, &outTraceResult);
+    AvHTraceLine(inStart, inEnd, inIgnoreMonsters, /*dont_ignore_glass,*/ inIgnoreEdict, &outTraceResult);
 	// :joev
 	CBaseEntity* theEntityHit = CBaseEntity::Instance(outTraceResult.pHit);