From 86960ab1336030a23e0273d058c7ed85b652765c Mon Sep 17 00:00:00 2001
From: MirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Date: Wed, 1 Feb 2012 13:25:57 +0200
Subject: [PATCH] Make display digits use the proper weapon model, as well as
 the healthsize scaling factor. Previously, a self-animated weapon model (iqm
 instead of md3) would not scale properly, and digits would not fit even if it
 did.

---
 data/defaultVT.cfg                   |  2 +-
 data/qcsrc/server/cl_weaponsystem.qc | 14 +++++++++-----
 docs/TODO.txt                        |  2 --
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/data/defaultVT.cfg b/data/defaultVT.cfg
index ab32f8e3..de559885 100644
--- a/data/defaultVT.cfg
+++ b/data/defaultVT.cfg
@@ -1657,7 +1657,7 @@ set g_healthsize_viewfactor 2 "The view is offset by this amount based on player
 set g_healthsize_soundfactor 0.5 "The sounds players make are amplified or reduced by this amount based on their size"
 set g_healthsize_exteriorweapon_scalefactor 1 "Amount by which player size resizes the exterior weapon model"
 set g_healthsize_weapon_scalefactor 1 "Amount by which player size resizes the view weapon model"
-set g_healthsize_weapon_scalefactor_pos 10 "Amount by which the view model is moved vertically based on player size"
+set g_healthsize_weapon_scalefactor_pos 4 "Amount by which the view model is moved vertically based on player size"
 
 set g_power 5 "when armor is below this level, the HUD, crosshair and helper will not work"
 set g_power_reboot 2 "amount of time it takes to boot a player's subsystems once he has enough armor"
diff --git a/data/qcsrc/server/cl_weaponsystem.qc b/data/qcsrc/server/cl_weaponsystem.qc
index 85d65d47..e9e06ec0 100644
--- a/data/qcsrc/server/cl_weaponsystem.qc
+++ b/data/qcsrc/server/cl_weaponsystem.qc
@@ -759,10 +759,14 @@ void CL_Weaponentity_Think()
 	if(cvar("g_healthsize") && cvar("g_healthsize_weapon_scalefactor"))
 	if(self.model != "")
 	{
-		self.weaponentity.scale = (1 + cvar("g_healthsize_weapon_scalefactor")) - cvar("g_healthsize_weapon_scalefactor") * self.owner.scale;
-		if(self.weaponentity.scale < 0.1)
-			self.weaponentity.scale = 0.1; // stuff breaks if scale is smaller than this
-		self.weaponentity.origin_z = (1 - self.weaponentity.scale) * cvar("g_healthsize_weapon_scalefactor_pos");
+		self.scale = (1 + cvar("g_healthsize_weapon_scalefactor")) - cvar("g_healthsize_weapon_scalefactor") * self.owner.scale;
+		if(self.scale < 0.1)
+			self.scale = 0.1; // stuff breaks if scale is smaller than this
+		self.origin_z = (1 - self.scale) * cvar("g_healthsize_weapon_scalefactor_pos");
+
+		// copy properties to the static weapon entity as well
+		self.weaponentity.scale = self.scale;
+		self.weaponentity.origin = self.origin;
 	}
 };
 
@@ -1610,7 +1614,7 @@ void W_DisplayDigitThink()
 			setattachment(self, self.owner.weaponentity, "weapon");
 		else if(gettagindex(self.owner.weaponentity, "tag_weapon"))
 			setattachment(self, self.owner.weaponentity, "tag_weapon");
-		gun = self.owner.weaponentity.weaponentity;
+		gun = self.owner.weaponentity;
 	}
 
 	// copy all properties of the weapon to the digit
diff --git a/docs/TODO.txt b/docs/TODO.txt
index 76fc023a..7a7a7e94 100644
--- a/docs/TODO.txt
+++ b/docs/TODO.txt
@@ -120,8 +120,6 @@
 
 - 0.7 BUG: Default player model is broken?
 
-- 0.7 BUG: Display digits on th 1st persom model disappear when the next map starts.
-
 - 0.7 BUG: With the latest engine, the view is no longer locked after match end, and you can still look around. See what changed in Xonotic and how to fix this.
 
 - 0.7 BUG: Consumable health seems to give more than the health it should.
-- 
2.39.5