From 8d871808b81981b390e6450daab616f68c621849 Mon Sep 17 00:00:00 2001
From: FruitieX <rasse@rasse-lappy.localdomain>
Date: Thu, 10 Jun 2010 03:35:16 +0300
Subject: [PATCH] float ids -> constants, thanks for good cleanup tip parasti
 :3

---
 qcsrc/client/hud.qc       | 34 +++++++++++++++++-----------------
 qcsrc/client/hud.qh       |  2 --
 qcsrc/common/constants.qh | 16 ++++++++++++++++
 qcsrc/common/util.qc      | 26 +++++++++++++-------------
 4 files changed, 46 insertions(+), 32 deletions(-)

diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc
index 0db9ffe1b9..c4bd34bc6b 100644
--- a/qcsrc/client/hud.qc
+++ b/qcsrc/client/hud.qc
@@ -584,7 +584,7 @@ void HUD_Panel_ExportCfg(string cfgname)
 
 		// common cvars for all panels
 		float i;
-		for (i = 0; i < panel_cnt; ++i)
+		for (i = 0; i < HUD_PANEL_NUM; ++i)
 		{
 			fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
 			fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
@@ -876,7 +876,7 @@ vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
 	myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
 	targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
 
-	for (i = 0; i < panel_cnt; ++i) {
+	for (i = 0; i < HUD_PANEL_NUM; ++i) {
 		if(i == id || !HUD_Panel_CheckActive(i))
 			continue;
 
@@ -980,7 +980,7 @@ vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize)
 	myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
 	targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
 
-	for (i = 0; i < panel_cnt; ++i) {
+	for (i = 0; i < HUD_PANEL_NUM; ++i) {
 		if(i == id || !HUD_Panel_CheckActive(i))
 			continue;
 
@@ -1211,7 +1211,7 @@ void HUD_Panel_Mouse()
 		vector panelPos;
 		vector panelSize;
 
-		for(i = 0; i <= panel_cnt; ++i)
+		for(i = 0; i <= HUD_PANEL_NUM; ++i)
 		{
 			panelPos = HUD_Panel_GetPos(i);
 			panelSize = HUD_Panel_GetSize(i);
@@ -1324,7 +1324,7 @@ float weaponorder_cmp(float i, float j, entity pass)
 
 void HUD_WeaponIcons()
 {
-	float id = 0;
+	float id = HUD_PANEL_WEAPONICONS;
 	float alpha, stat_weapons; // "constants"
 	vector pos, mySize, accuracy_color;
 	float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
@@ -1466,7 +1466,7 @@ string GetAmmoPicture(float i)
 
 void HUD_Inventory()
 {
-	float id = 1;
+	float id = HUD_PANEL_INVENTORY;
 	float i;
 	float stat_items;
 
@@ -1557,7 +1557,7 @@ void HUD_Inventory()
 // Powerups (#2)
 //
 void HUD_Powerups() {
-	float id = 2;
+	float id = HUD_PANEL_POWERUPS;
 	float stat_items;
 	stat_items = getstati(STAT_ITEMS);
 
@@ -1781,7 +1781,7 @@ void HUD_Powerups() {
 //
 void HUD_HealthArmor(void)
 {
-	float id = 3;
+	float id = HUD_PANEL_HEALTHARMOR;
 	vector pos, mySize;
 	pos = HUD_Panel_GetPos(id);
 	mySize = HUD_Panel_GetSize(id);
@@ -2412,7 +2412,7 @@ void HUD_Centerprint(string s1, float type, float msg)
 
 void HUD_Notify (void)
 {
-	float id = 4;
+	float id = HUD_PANEL_NOTIFY;
 	vector pos, mySize;
 	pos = HUD_Panel_GetPos(id);
 	mySize = HUD_Panel_GetSize(id);
@@ -2678,7 +2678,7 @@ void HUD_Notify (void)
 //
 void HUD_Timer()
 {
-	float id = 5;
+	float id = HUD_PANEL_TIMER;
 	vector pos, mySize;
 	pos = HUD_Panel_GetPos(id);
 	mySize = HUD_Panel_GetSize(id);
@@ -2737,7 +2737,7 @@ void HUD_Timer()
 //
 void HUD_Radar(void)
 {
-	float id = 6;
+	float id = HUD_PANEL_RADAR;
 	vector pos, mySize;
 	pos = HUD_Panel_GetPos(id);
 	mySize = HUD_Panel_GetSize(id);
@@ -2863,7 +2863,7 @@ void HUD_Radar(void)
 //
 void HUD_Score()
 {
-	float id = 7;
+	float id = HUD_PANEL_SCORE;
 	vector pos, mySize;
 	pos = HUD_Panel_GetPos(id);
 	mySize = HUD_Panel_GetSize(id);
@@ -3011,7 +3011,7 @@ void HUD_Score()
 // Race timer (#8)
 //
 void HUD_RaceTimer (void) {
-	float id = 8;
+	float id = HUD_PANEL_RACETIMER;
 	vector pos, mySize;
 	pos = HUD_Panel_GetPos(id);
 	mySize = HUD_Panel_GetSize(id);
@@ -3154,7 +3154,7 @@ float vote_change; // "time" when vote_active changed
 
 void HUD_VoteWindow(void) 
 {
-	float id = 9;
+	float id = HUD_PANEL_VOTE;
 	vector pos, mySize;
 	pos = HUD_Panel_GetPos(id);
 	mySize = HUD_Panel_GetSize(id);
@@ -3660,7 +3660,7 @@ void HUD_ModIcons(void)
 	if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
 		return;
 
-	float id = 10;
+	float id = HUD_PANEL_MODICONS;
 	vector pos, mySize;
 	pos = HUD_Panel_GetPos(id);
 	mySize = HUD_Panel_GetSize(id);
@@ -3701,7 +3701,7 @@ void HUD_ModIcons(void)
 //
 void HUD_DrawPressedKeys(void)
 {
-	float id = 11;
+	float id = HUD_PANEL_PRESSEDKEYS;
 	vector pos, mySize;
 	pos = HUD_Panel_GetPos(id);
 	mySize = HUD_Panel_GetSize(id);
@@ -3732,7 +3732,7 @@ void HUD_DrawPressedKeys(void)
 float chat_prevtime;
 void HUD_Chat(void)
 {
-	float id = 12;
+	float id = HUD_PANEL_CHAT;
 	vector pos, mySize;
 	pos = HUD_Panel_GetPos(id);
 	mySize = HUD_Panel_GetSize(id);
diff --git a/qcsrc/client/hud.qh b/qcsrc/client/hud.qh
index ce8fc3a2ff..fb736c5e69 100644
--- a/qcsrc/client/hud.qh
+++ b/qcsrc/client/hud.qh
@@ -1,5 +1,3 @@
-float panel_cnt = 13; // NOTE: IDs start from 0!
-
 vector mousepos;
 vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
 vector panel_click_resizeorigin; // coordinates for opposite point when resizing
diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh
index 7fcbec7bf1..facf3bc950 100644
--- a/qcsrc/common/constants.qh
+++ b/qcsrc/common/constants.qh
@@ -565,3 +565,19 @@ float WR_KILLMESSAGE    = 8; // (CSQC) sets w_deathtypestring or leaves it alone
 float WR_RELOAD         = 9; // (SVQC) does not need to do anything
 float WR_RESETPLAYER    = 10; // (SVQC) does not need to do anything
 float WR_IMPACTEFFECT	= 11; // (CSQC) impact effect
+
+
+float HUD_PANEL_WEAPONICONS	= 0;
+float HUD_PANEL_INVENTORY	= 1;
+float HUD_PANEL_POWERUPS	= 2;
+float HUD_PANEL_HEALTHARMOR	= 3;
+float HUD_PANEL_NOTIFY		= 4;
+float HUD_PANEL_TIMER		= 5;
+float HUD_PANEL_RADAR		= 6;
+float HUD_PANEL_SCORE		= 7;
+float HUD_PANEL_RACETIMER	= 8;
+float HUD_PANEL_VOTE		= 9;
+float HUD_PANEL_MODICONS	= 10;
+float HUD_PANEL_PRESSEDKEYS	= 11;
+float HUD_PANEL_CHAT		= 12;
+float HUD_PANEL_NUM		= 13;
diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc
index bad6ee9400..5329d4e0ac 100644
--- a/qcsrc/common/util.qc
+++ b/qcsrc/common/util.qc
@@ -1953,19 +1953,19 @@ float get_model_parameters(string m, float sk)
 string HUD_Panel_GetName(float id)
 {
 	switch(id) {
-		case 0: return "weaponicons"; break;
-		case 1: return "inventory"; break;
-		case 2: return "powerups"; break;
-		case 3: return "healtharmor"; break;
-		case 4: return "notify"; break;
-		case 5: return "timer"; break;
-		case 6: return "radar"; break;
-		case 7: return "score"; break;
-		case 8: return "racetimer"; break;
-		case 9: return "vote"; break;
-		case 10: return "modicons"; break;
-		case 11: return "pressedkeys"; break;
-		case 12: return "chat"; break;
+		case HUD_PANEL_WEAPONICONS: return "weaponicons"; break;
+		case HUD_PANEL_INVENTORY: return "inventory"; break;
+		case HUD_PANEL_POWERUPS: return "powerups"; break;
+		case HUD_PANEL_HEALTHARMOR: return "healtharmor"; break;
+		case HUD_PANEL_NOTIFY: return "notify"; break;
+		case HUD_PANEL_TIMER: return "timer"; break;
+		case HUD_PANEL_RADAR: return "radar"; break;
+		case HUD_PANEL_SCORE: return "score"; break;
+		case HUD_PANEL_RACETIMER: return "racetimer"; break;
+		case HUD_PANEL_VOTE: return "vote"; break;
+		case HUD_PANEL_MODICONS: return "modicons"; break;
+		case HUD_PANEL_PRESSEDKEYS: return "pressedkeys"; break;
+		case HUD_PANEL_CHAT: return "chat"; break;
 		default: return "";
 	}
 }
-- 
2.39.5