From: Martin Taibr <taibr.martin@gmail.com>
Date: Mon, 30 Sep 2019 17:21:43 +0000 (+0200)
Subject: cleanup weaponorder
X-Git-Tag: xonotic-v0.8.5~1105^2~34^2~1
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8308420e81091199bd3304edd74833cbabdfff7d;p=xonotic%2Fxonotic-data.pk3dir.git

cleanup weaponorder
---

diff --git a/qcsrc/client/defs.qh b/qcsrc/client/defs.qh
index db1a5afac..0cf71294a 100644
--- a/qcsrc/client/defs.qh
+++ b/qcsrc/client/defs.qh
@@ -173,10 +173,6 @@ REPLICATE(cvar_cl_weaponpriorities[9], string, "cl_weaponpriority9");
 
 float bgmtime;
 
-string weaponorder_byimpulse; // NOTE: this is a misnomer, weapon order is not always sorted by impulse
-string weaponorder_bypriority;
-bool weapons_orderbyimpulse; // update priority list when toggling this
-
 float vortex_charge_movingavg;
 
 int serverflags;
diff --git a/qcsrc/client/hud/panel/weapons.qc b/qcsrc/client/hud/panel/weapons.qc
index 832ffad0b..8668886a9 100644
--- a/qcsrc/client/hud/panel/weapons.qc
+++ b/qcsrc/client/hud/panel/weapons.qc
@@ -39,6 +39,8 @@ int weaponorder_cmp(int i, int j, entity pass)
 	weapon_size.y = panel_size.y / rows; \
 MACRO_END
 
+string cl_weaponpriority_old;
+bool weapons_orderbyimpulse_old;
 void HUD_Weapons()
 {
 	// declarations
@@ -90,19 +92,19 @@ void HUD_Weapons()
 	// update generic hud functions
 	HUD_Panel_LoadCvars();
 
-	// figure out weapon order (how the weapons are sorted) // TODO make this configurable
-	if(weaponorder_bypriority != autocvar_cl_weaponpriority || autocvar_hud_panel_weapons_orderbyimpulse != weapons_orderbyimpulse || !weaponorder[0])
+	if(cl_weaponpriority_old != autocvar_cl_weaponpriority || weapons_orderbyimpulse_old != autocvar_hud_panel_weapons_orderbyimpulse || weaponorder[0] == NULL)
 	{
-		int weapon_cnt;
-		weapons_orderbyimpulse = autocvar_hud_panel_weapons_orderbyimpulse;
-		strcpy(weaponorder_bypriority, autocvar_cl_weaponpriority);
-		string weporder = W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority));
+		weapons_orderbyimpulse_old = autocvar_hud_panel_weapons_orderbyimpulse;
+		strcpy(cl_weaponpriority_old, autocvar_cl_weaponpriority);
+		string weporder = W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(cl_weaponpriority_old));
 		if(autocvar_hud_panel_weapons_orderbyimpulse)
+		{
 			weporder = W_FixWeaponOrder_BuildImpulseList(weporder);
-		strcpy(weaponorder_byimpulse, weporder);
-		weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
+		}
+
+		weaponorder_cmp_str = strcat(" ", weporder, " ");
 
-		weapon_cnt = 0;
+		int weapon_cnt = 0;
 		FOREACH(Weapons, it != WEP_Null && it.impulse >= 0, weaponorder[weapon_cnt++] = it);
 		for(i = weapon_cnt; i < Weapons_MAX; ++i)
 			weaponorder[i] = NULL;