]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge branch 'master' into sev/luma_revisions
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 74a5df16627d45735fbbbbb876475ea428da3bf8..14a1e15aecca88f595baacf1482df8eb838666ec 100644 (file)
@@ -1,10 +1,23 @@
+#include "hud.qh"
+#include "_all.qh"
+
+#include "hud_config.qh"
 #include "scoreboard.qh"
+#include "sortlist.qh"
 #include "teamradar.qh"
+#include "t_items.qh"
+
 #include "../common/buffs.qh"
+#include "../common/constants.qh"
 #include "../common/counting.qh"
+#include "../common/deathtypes.qh"
 #include "../common/mapinfo.qh"
 #include "../common/nades.qh"
-#include "../server/t_items.qh"
+#include "../common/stats.qh"
+
+#include "../csqcmodellib/cl_player.qh"
+
+#include "../warpzonelib/mathlib.qh"
 
 /*
 ==================
@@ -140,13 +153,13 @@ vector HUD_Get_Num_Color (float x, float maxvalue)
        return color;
 }
 
-float HUD_GetRowCount(float item_count, vector size, float item_aspect)
+float HUD_GetRowCount(int item_count, vector size, float item_aspect)
 {
        float aspect = size_y / size_x;
        return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count);
 }
 
-vector HUD_GetTableSize(float item_count, vector psize, float item_aspect)
+vector HUD_GetTableSize(int item_count, vector psize, float item_aspect)
 {
        float columns, rows;
        float ratio, best_ratio = 0;
@@ -196,20 +209,20 @@ float stringwidth_nocolors(string s, vector theSize)
        return stringwidth(s, false, theSize);
 }
 
-void drawstringright(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag)
+void drawstringright(vector position, string text, vector theScale, vector rgb, float theAlpha, int flag)
 {
        position.x -= 2 / 3 * strlen(text) * theScale.x;
        drawstring(position, text, theScale, rgb, theAlpha, flag);
 }
 
-void drawstringcenter(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag)
+void drawstringcenter(vector position, string text, vector theScale, vector rgb, float theAlpha, int flag)
 {
        position.x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * theScale.x);
        drawstring(position, text, theScale, rgb, theAlpha, flag);
 }
 
 // return the string of the onscreen race timer
-string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
+string MakeRaceString(int cp, float mytime, float theirtime, float lapdelta, string theirname)
 {
        string col;
        string timestr;
@@ -217,7 +230,7 @@ string MakeRaceString(float cp, float mytime, float histime, float lapdelta, str
        string lapstr;
        lapstr = "";
 
-       if(histime == 0) // goal hit
+       if(theirtime == 0) // goal hit
        {
                if(mytime > 0)
                {
@@ -246,12 +259,12 @@ string MakeRaceString(float cp, float mytime, float histime, float lapdelta, str
                        col = "^1";
                }
        }
-       else if(histime > 0) // anticipation
+       else if(theirtime > 0) // anticipation
        {
-               if(mytime >= histime)
-                       timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
+               if(mytime >= theirtime)
+                       timestr = strcat("+", ftos_decimals(mytime - theirtime, TIME_DECIMALS));
                else
-                       timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
+                       timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(theirtime));
                col = "^3";
        }
        else
@@ -269,24 +282,25 @@ string MakeRaceString(float cp, float mytime, float histime, float lapdelta, str
        else
                cpname = _("Finish line");
 
-       if(histime < 0)
+       if(theirtime < 0)
                return strcat(col, cpname);
-       else if(hisname == "")
+       else if(theirname == "")
                return strcat(col, sprintf("%s (%s)", cpname, timestr));
        else
-               return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(hisname, col, lapstr)));
+               return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(theirname, col, lapstr)));
 }
 
 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
-float race_CheckName(string net_name) {
-       float i;
+int race_CheckName(string net_name)
+{
+       int i;
        for (i=RANKINGS_CNT-1;i>=0;--i)
                if(grecordholder[i] == net_name)
                        return i+1;
        return 0;
 }
 
-float GetPlayerColorForce(int i)
+int GetPlayerColorForce(int i)
 {
        if(!teamplay)
                return 0;
@@ -294,7 +308,7 @@ float GetPlayerColorForce(int i)
                return stof(getplayerkeyvalue(i, "colors")) & 15;
 }
 
-float GetPlayerColor(int i)
+int GetPlayerColor(int i)
 {
        if(!playerslots[i].gotscores) // unconnected
                return NUM_SPECTATOR;
@@ -323,7 +337,7 @@ HUD panels
 } while(0)
 
 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
-void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
+void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
 {
        if(!length_ratio || !theAlpha)
                return;
@@ -426,7 +440,7 @@ void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, flo
        }
 }
 
-void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, float drawflag)
+void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
 {
        if(!theAlpha)
                return;
@@ -454,9 +468,9 @@ void weaponorder_swap(int i, int j, entity pass)
 }
 
 string weaponorder_cmp_str;
-float weaponorder_cmp(float i, float j, entity pass)
+int weaponorder_cmp(int i, int j, entity pass)
 {
-       float ai, aj;
+       int ai, aj;
        ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
        aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
        return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
@@ -466,11 +480,12 @@ void HUD_Weapons(void)
 {
        // declarations
        WepSet weapons_stat = WepSet_GetFromStat();
-       float i, f, a;
+       int i;
+       float f, a;
        float screen_ar;
        vector center = '0 0 0';
-       float weapon_count, weapon_id;
-       float row, column, rows = 0, columns = 0;
+       int weapon_count, weapon_id;
+       int row, column, rows = 0, columns = 0;
        bool vertical_order = true;
        float aspect = autocvar_hud_panel_weapons_aspect;
 
@@ -506,8 +521,6 @@ void HUD_Weapons(void)
        // update generic hud functions
        HUD_Panel_UpdateCvars();
 
-       draw_beginBoldFont();
-
        // figure out weapon order (how the weapons are sorted) // TODO make this configurable
        if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
        {
@@ -577,10 +590,7 @@ void HUD_Weapons(void)
 
                // might as well commit suicide now, no reason to live ;)
                if (weapon_count == 0)
-               {
-                       draw_endBoldFont();
                        return;
-               }
 
                vector old_panel_size = panel_size;
                vector padded_panel_size = panel_size - '2 2 0' * panel_bg_padding;
@@ -597,7 +607,7 @@ void HUD_Weapons(void)
                if(padded_panel_size.x / padded_panel_size.y < aspect)
                {
                        // maximum number of rows that allows to display items with the desired aspect ratio
-                       float max_rows = floor(padded_panel_size.y / (weapon_size.x / aspect));
+                       int max_rows = floor(padded_panel_size.y / (weapon_size.x / aspect));
                        columns = min(columns, ceil(weapon_count / max_rows));
                        rows = ceil(weapon_count / columns);
                        weapon_size.y = min(padded_panel_size.y / rows, weapon_size.x / aspect);
@@ -606,7 +616,7 @@ void HUD_Weapons(void)
                }
                else
                {
-                       float max_columns = floor(padded_panel_size.x / (weapon_size.y * aspect));
+                       int max_columns = floor(padded_panel_size.x / (weapon_size.y * aspect));
                        rows = min(rows, ceil(weapon_count / max_columns));
                        columns = ceil(weapon_count / rows);
                        weapon_size.x = min(padded_panel_size.x / columns, aspect * weapon_size.y);
@@ -734,10 +744,7 @@ void HUD_Weapons(void)
        HUD_Panel_DrawBg(1);
 
        if(center.x == -1)
-       {
-               draw_endBoldFont();
                return;
-       }
 
        if(panel_bg_padding)
        {
@@ -782,11 +789,17 @@ void HUD_Weapons(void)
        // draw items
        row = column = 0;
        vector label_size = '1 1 0' * min(weapon_size.x, weapon_size.y) * bound(0, autocvar_hud_panel_weapons_label_scale, 1);
+       vector noncurrent_pos = '0 0 0';
+       vector noncurrent_size = weapon_size * bound(0, autocvar_hud_panel_weapons_noncurrent_scale, 1);
+       float noncurrent_alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_weapons_noncurrent_alpha, 1);
+       bool isCurrent;
+
        for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
        {
                // retrieve information about the current weapon to be drawn
                self = weaponorder[i];
                weapon_id = self.impulse;
+               isCurrent = (self.weapon == switchweapon);
 
                // skip if this weapon doesn't exist
                if(!self || weapon_id < 0) { continue; }
@@ -797,12 +810,12 @@ void HUD_Weapons(void)
                        continue;
 
                // figure out the drawing position of weapon
-               weapon_pos = (panel_pos
-                       + eX * column * weapon_size.x
-                       + eY * row * weapon_size.y);
+               weapon_pos = (panel_pos + eX * column * weapon_size.x + eY * row * weapon_size.y);
+               noncurrent_pos.x = weapon_pos.x + (weapon_size.x - noncurrent_size.x) / 2;
+               noncurrent_pos.y = weapon_pos.y + (weapon_size.y - noncurrent_size.y) / 2;
 
                // draw background behind currently selected weapon
-               if(self.weapon == switchweapon)
+               if(isCurrent)
                        drawpic_aspect_skin(weapon_pos, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 
                // draw the weapon accuracy
@@ -820,7 +833,10 @@ void HUD_Weapons(void)
                if(weapons_stat & WepSet_FromWeapon(self.weapon))
                {
                        // draw the weapon image
-                       drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       if(isCurrent)
+                               drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       else
+                               drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '1 1 1', noncurrent_alpha, DRAWFLAG_NORMAL);
 
                        // draw weapon label string
                        switch(autocvar_hud_panel_weapons_label)
@@ -882,7 +898,7 @@ void HUD_Weapons(void)
                }
                else // draw a "ghost weapon icon" if you don't have the weapon
                {
-                       drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
+                       drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '0.2 0.2 0.2', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
                }
 
                // draw the complain message
@@ -940,67 +956,62 @@ void HUD_Weapons(void)
                        }
                }
        }
-
-       draw_endBoldFont();
 }
 
 // Ammo (#1)
-void DrawNadeScoreBar(vector myPos, vector mySize, vector color)
+void DrawNadeProgressBar(vector myPos, vector mySize, float progress, vector color)
 {
-
        HUD_Panel_DrawProgressBar(
                myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
                mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
                autocvar_hud_panel_ammo_progressbar_name,
-               getstatf(STAT_NADE_BONUS_SCORE), 0, 0, color,
+               progress, 0, 0, color,
                autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-
 }
 
-void DrawAmmoNades(vector myPos, vector mySize, float draw_expanding, float expand_time)
+void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
 {
-       float theAlpha = 1, a, b;
-       vector nade_color, picpos, numpos;
-
-       nade_color = Nade_Color(getstati(STAT_NADE_BONUS_TYPE));
+       float bonusNades    = getstatf(STAT_NADE_BONUS);
+       float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE);
+       float bonusType     = getstati(STAT_NADE_BONUS_TYPE);
+       vector nadeColor    = Nade_Color(bonusType);
+       string nadeIcon     = Nade_Icon(bonusType);
 
-       a = getstatf(STAT_NADE_BONUS);
-       b = getstatf(STAT_NADE_BONUS_SCORE);
+       vector iconPos, textPos;
 
        if(autocvar_hud_panel_ammo_iconalign)
        {
-               numpos = myPos;
-               picpos = myPos + eX * 2 * mySize.y;
+               iconPos = myPos + eX * 2 * mySize.y;
+               textPos = myPos;
        }
        else
        {
-               numpos = myPos + eX * mySize.y;
-               picpos = myPos;
+               iconPos = myPos;
+               textPos = myPos + eX * mySize.y;
        }
 
-       DrawNadeScoreBar(myPos, mySize, nade_color);
-
-       if(b > 0 || a > 0)
+       if(bonusNades > 0 || bonusProgress > 0)
        {
+               DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
+
                if(autocvar_hud_panel_ammo_text)
-                       drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 
                if(draw_expanding)
-                       drawpic_aspect_skin_expanding(picpos, "nade_nbg", '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, expand_time);
+                       drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
 
-               drawpic_aspect_skin(picpos, "nade_bg" , '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
-               drawpic_aspect_skin(picpos, "nade_nbg" , '1 1 0' * mySize.y, nade_color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
        }
 }
 
-void DrawAmmoItem(vector myPos, vector mySize, .float ammoType, float isCurrent, float isInfinite)
+void DrawAmmoItem(vector myPos, vector mySize, .int ammoType, bool isCurrent, bool isInfinite)
 {
        if(ammoType == ammo_none)
                return;
 
        // Initialize variables
 
-       float ammo;
+       int ammo;
        if(autocvar__hud_configure)
        {
                isCurrent = (ammoType == ammo_rockets); // Rockets always current
@@ -1028,7 +1039,7 @@ void DrawAmmoItem(vector myPos, vector mySize, .float ammoType, float isCurrent,
                textPos = myPos + eX * mySize.y;
        }
 
-       float isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
+       bool isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
 
        vector iconColor = isShadowed ? '0 0 0' : '1 1 1';
        vector textColor;
@@ -1065,8 +1076,8 @@ void DrawAmmoItem(vector myPos, vector mySize, .float ammoType, float isCurrent,
        drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize.y, iconColor, alpha, DRAWFLAG_NORMAL);
 }
 
-float nade_prevstatus;
-float nade_prevframe;
+int nade_prevstatus;
+int nade_prevframe;
 float nade_statuschange_time;
 void HUD_Ammo(void)
 {
@@ -1092,10 +1103,11 @@ void HUD_Ammo(void)
                mySize -= '2 2 0' * panel_bg_padding;
        }
 
-       float rows = 0, columns, row, column;
+       int rows = 0, columns, row, column;
        float nade_cnt = getstatf(STAT_NADE_BONUS), nade_score = getstatf(STAT_NADE_BONUS_SCORE);
-       float draw_nades = (nade_cnt > 0 || nade_score > 0), nade_statuschange_elapsedtime;
-       float total_ammo_count;
+       bool draw_nades = (nade_cnt > 0 || nade_score > 0);
+       float nade_statuschange_elapsedtime;
+       int total_ammo_count;
 
        vector ammo_size;
        if (autocvar_hud_panel_ammo_onlycurrent)
@@ -1137,8 +1149,8 @@ void HUD_Ammo(void)
                ammo_size.y = newSize;
        }
 
-       float i;
-       float infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO);
+       int i;
+       bool infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO);
        row = column = 0;
        if(autocvar_hud_panel_ammo_onlycurrent)
        {
@@ -1166,7 +1178,7 @@ void HUD_Ammo(void)
        }
        else
        {
-               .float ammotype;
+               .int ammotype;
                row = column = 0;
                for(i = 0; i < AMMO_COUNT; ++i)
                {
@@ -1200,7 +1212,7 @@ void HUD_Ammo(void)
        draw_endBoldFont();
 }
 
-void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float theAlpha, float fadelerp)
+void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, bool vertical, bool icon_right_align, vector color, float theAlpha, float fadelerp)
 {
        vector newPos = '0 0 0', newSize = '0 0 0';
        vector picpos, numpos;
@@ -1279,7 +1291,7 @@ void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, fl
        drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
 }
 
-void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float theAlpha)
+void DrawNumIcon(vector myPos, vector mySize, float x, string icon, bool vertical, bool icon_right_align, vector color, float theAlpha)
 {
        DrawNumIcon_expanding(myPos, mySize, x, icon, vertical, icon_right_align, color, theAlpha, 0);
 }
@@ -1330,10 +1342,10 @@ void HUD_Powerups(void)
        }
 
        float panel_ar = mySize.x/mySize.y;
-       float is_vertical = (panel_ar < 1);
+       bool is_vertical = (panel_ar < 1);
        vector shield_offset = '0 0 0', strength_offset = '0 0 0', superweapons_offset = '0 0 0';
 
-       float superweapons_is = -1;
+       int superweapons_is = -1;
 
        if(superweapons_time)
        {
@@ -1395,8 +1407,8 @@ void HUD_Powerups(void)
                }
        }
 
-       float shield_baralign, strength_baralign, superweapons_baralign;
-       float shield_iconalign, strength_iconalign, superweapons_iconalign;
+       bool shield_baralign, strength_baralign, superweapons_baralign;
+       bool shield_iconalign, strength_iconalign, superweapons_iconalign;
 
        if (autocvar_hud_panel_powerups_flip)
        {
@@ -1482,21 +1494,10 @@ void HUD_Powerups(void)
 // Health/armor (#3)
 //
 
-// prev_* vars contain the health/armor at the previous FRAME
-// set to -1 when player is dead or was not playing
-float prev_health, prev_armor;
-float health_damagetime, armor_damagetime;
-float health_beforedamage, armor_beforedamage;
-// old_p_* vars keep track of previous values when smoothing value changes of the progressbar
-float old_p_health, old_p_armor;
-float old_p_healthtime, old_p_armortime;
-// prev_p_* vars contain the health/armor progressbar value at the previous FRAME
-// set to -1 to forcedly stop effects when we switch spectated player (e.g. from playerX: 70h to playerY: 50h)
-float prev_p_health, prev_p_armor;
 
 void HUD_HealthArmor(void)
 {
-       float armor, health, fuel;
+       int armor, health, fuel;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_healtharmor) return;
@@ -1546,6 +1547,9 @@ void HUD_HealthArmor(void)
        }
 
        HUD_Panel_UpdateCvars();
+
+       draw_beginBoldFont();
+
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
@@ -1557,11 +1561,11 @@ void HUD_HealthArmor(void)
                mySize -= '2 2 0' * panel_bg_padding;
        }
 
-       float baralign = autocvar_hud_panel_healtharmor_baralign;
-       float iconalign = autocvar_hud_panel_healtharmor_iconalign;
+       int baralign = autocvar_hud_panel_healtharmor_baralign;
+       int iconalign = autocvar_hud_panel_healtharmor_iconalign;
 
-    float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
-    float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
+    int maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
+    int maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
        if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
        {
                vector v;
@@ -1599,7 +1603,7 @@ void HUD_HealthArmor(void)
        else
        {
                float panel_ar = mySize.x/mySize.y;
-               float is_vertical = (panel_ar < 1);
+               bool is_vertical = (panel_ar < 1);
                vector health_offset = '0 0 0', armor_offset = '0 0 0';
                if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
                {
@@ -1618,8 +1622,8 @@ void HUD_HealthArmor(void)
                                armor_offset.y = mySize.y;
                }
 
-               float health_baralign, armor_baralign, fuel_baralign;
-               float health_iconalign, armor_iconalign;
+               bool health_baralign, armor_baralign, fuel_baralign;
+               bool health_iconalign, armor_iconalign;
                if (autocvar_hud_panel_healtharmor_flip)
                {
                        armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
@@ -1751,6 +1755,8 @@ void HUD_HealthArmor(void)
                        HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
                }
        }
+
+       draw_endBoldFont();
 }
 
 // Notification area (#4)
@@ -1823,7 +1829,7 @@ void HUD_Notify(void)
        float fade_time = max(0, autocvar_hud_panel_notify_fadetime);
        float icon_aspect = max(1, autocvar_hud_panel_notify_icon_aspect);
 
-       float entry_count = bound(1, floor(NOTIFY_MAX_ENTRIES * size.y / size.x), NOTIFY_MAX_ENTRIES);
+       int entry_count = bound(1, floor(NOTIFY_MAX_ENTRIES * size.y / size.x), NOTIFY_MAX_ENTRIES);
        float entry_height = size.y / entry_count;
 
        float panel_width_half = size.x * 0.5;
@@ -1838,7 +1844,8 @@ void HUD_Notify(void)
 
        vector attacker_pos, victim_pos, icon_pos;
        string attacker, victim, icon;
-       float i, j, count, step, limit, alpha;
+       int i, j, count, step, limit;
+       float alpha;
 
        if (autocvar_hud_panel_notify_flip)
        {
@@ -2089,7 +2096,7 @@ void HUD_Radar(void)
                mySize -= '2 2 0' * panel_bg_padding;
        }
 
-       float color2;
+       int color2;
        entity tm;
        float scale2d, normalsize, bigsize;
 
@@ -2172,9 +2179,9 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me)
 {
        float score;
        entity tm = world, pl;
-       float SCOREPANEL_MAX_ENTRIES = 6;
+       int SCOREPANEL_MAX_ENTRIES = 6;
        float SCOREPANEL_ASPECTRATIO = 2;
-       float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize.y/mySize.x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
+       int entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize.y/mySize.x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
        vector fontsize = '1 1 0' * (mySize.y/entries);
 
        vector rgb, score_color;
@@ -2184,7 +2191,8 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me)
        float name_size = mySize.x*0.75;
        float spacing_size = mySize.x*0.04;
        const float highlight_alpha = 0.2;
-       float i = 0, me_printed = 0, first_pl = 0;
+       int i = 0, first_pl = 0;
+       bool me_printed = false;
        string s;
        if (autocvar__hud_configure)
        {
@@ -2275,7 +2283,7 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me)
                {
                        if (i == first_pl)
                                rgb = '0 1 0'; //first: green
-                       me_printed = 1;
+                       me_printed = true;
                        drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                }
                if (team_count)
@@ -2314,7 +2322,7 @@ void HUD_Score(void)
        vector distribution_color;
        entity tm, pl, me;
 
-       me = playerslots[player_localentnum - 1];
+       me = playerslots[current_player];
 
        if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
                string timer, distrtimer;
@@ -2483,8 +2491,6 @@ void HUD_RaceTimer (void)
 
        HUD_Panel_UpdateCvars();
 
-       draw_beginBoldFont();
-
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
@@ -2520,7 +2526,9 @@ void HUD_RaceTimer (void)
        if(autocvar__hud_configure)
        {
                s = "0:13:37";
+               draw_beginBoldFont();
                drawstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, false, '0.60 0.60 0' * mySize.y), s, '0.60 0.60 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               draw_endBoldFont();
                s = _("^1Intermediate 1 (+15.42)");
                drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.20 * mySize.y) + eY * 0.60 * mySize.y, s, '1 1 0' * 0.20 * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL);
                s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
@@ -2570,6 +2578,8 @@ void HUD_RaceTimer (void)
                        }
                }
 
+               draw_beginBoldFont();
+
                if(forcetime != "")
                {
                        a = bound(0, (time - race_checkpointtime) / 0.5, 1);
@@ -2583,6 +2593,8 @@ void HUD_RaceTimer (void)
                        s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
                        drawstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, false, '0.6 0.6 0' * mySize.y), s, '0.6 0.6 0' * mySize.y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
                }
+
+               draw_endBoldFont();
        }
        else
        {
@@ -2613,21 +2625,10 @@ void HUD_RaceTimer (void)
                        }
                }
        }
-
-       draw_endBoldFont();
 }
 
 // Vote window (#9)
 //
-float vote_yescount;
-float vote_nocount;
-float vote_needed;
-float vote_highlighted; // currently selected vote
-
-float vote_active; // is there an active vote?
-float vote_prev; // previous state of vote_active to check for a change
-float vote_alpha;
-float vote_change; // "time" when vote_active changed
 
 void HUD_Vote(void)
 {
@@ -2769,11 +2770,11 @@ void HUD_Vote(void)
 // Mod icons panel (#10)
 //
 
-float mod_active; // is there any active mod icon?
+bool mod_active; // is there any active mod icon?
 
-void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, float i)
+void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
 {
-       float stat = -1;
+       int stat = -1;
        string pic = "";
        vector color = '0 0 0';
        switch(i)
@@ -2833,7 +2834,8 @@ void HUD_Mod_CA(vector myPos, vector mySize)
                layout = autocvar_hud_panel_modicons_ca_layout;
        else //if(gametype == MAPINFO_TYPE_FREEZETAG)
                layout = autocvar_hud_panel_modicons_freezetag_layout;
-       float rows, columns, aspect_ratio;
+       int rows, columns;
+       float aspect_ratio;
        aspect_ratio = (layout) ? 2 : 1;
        rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
        columns = ceil(team_count/rows);
@@ -2859,7 +2861,7 @@ void HUD_Mod_CA(vector myPos, vector mySize)
 
 // CTF HUD modicon section
 float redflag_prevframe, blueflag_prevframe; // status during previous frame
-float redflag_prevstatus, blueflag_prevstatus; // last remembered status
+int redflag_prevstatus, blueflag_prevstatus; // last remembered status
 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
 
 void HUD_Mod_CTF_Reset(void)
@@ -2873,9 +2875,9 @@ void HUD_Mod_CTF(vector pos, vector mySize)
        vector flag_size;
        float f; // every function should have that
 
-       float redflag, blueflag; // current status
+       int redflag, blueflag; // current status
        float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
-       float stat_items;
+       int stat_items;
 
        stat_items = getstati(STAT_ITEMS, 0, 24);
        redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
@@ -3017,9 +3019,9 @@ void HUD_Mod_KH(vector pos, vector mySize)
 
        // Read current state
 
-       float state = getstati(STAT_KH_KEYS);
-       float i, key_state;
-       float all_keys, team1_keys, team2_keys, team3_keys, team4_keys, dropped_keys, carrying_keys;
+       int state = getstati(STAT_KH_KEYS);
+       int i, key_state;
+       int all_keys, team1_keys, team2_keys, team3_keys, team4_keys, dropped_keys, carrying_keys;
        all_keys = team1_keys = team2_keys = team3_keys = team4_keys = dropped_keys = carrying_keys = 0;
 
        for(i = 0; i < 4; ++i)
@@ -3138,7 +3140,7 @@ void HUD_Mod_KH(vector pos, vector mySize)
 }
 
 // Keepaway HUD mod icon
-float kaball_prevstatus; // last remembered status
+int kaball_prevstatus; // last remembered status
 float kaball_statuschange_time; // time when the status changed
 
 // we don't need to reset for keepaway since it immediately
@@ -3153,8 +3155,8 @@ void HUD_Mod_Keepaway(vector pos, vector mySize)
        float BLINK_FREQ = 5;
        float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
 
-       float stat_items = getstati(STAT_ITEMS, 0, 24);
-       float kaball = (stat_items/IT_KEY1) & 1;
+       int stat_items = getstati(STAT_ITEMS, 0, 24);
+       int kaball = (stat_items/IT_KEY1) & 1;
 
        if(kaball != kaball_prevstatus)
        {
@@ -3186,7 +3188,8 @@ void HUD_Mod_Keepaway(vector pos, vector mySize)
 // Nexball HUD mod icon
 void HUD_Mod_NexBall(vector pos, vector mySize)
 {
-       float stat_items, nb_pb_starttime, dt, p;
+       float nb_pb_starttime, dt, p;
+       int stat_items;
 
        stat_items = getstati(STAT_ITEMS, 0, 24);
        nb_pb_starttime = getstatf(STAT_NB_METERSTART);
@@ -3219,7 +3222,7 @@ float srecordtime_prev; // last remembered srecordtime
 float srecordtime_change_time; // time when srecordtime last changed
 
 float race_status_time;
-float race_status_prev;
+int race_status_prev;
 string race_status_name_prev;
 void HUD_Mod_Race(vector pos, vector mySize)
 {
@@ -3359,7 +3362,7 @@ void HUD_Mod_Race(vector pos, vector mySize)
        }
 }
 
-void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, float i)
+void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
 {
        float stat = -1;
        string pic = "";
@@ -3428,7 +3431,8 @@ void HUD_Mod_Dom(vector myPos, vector mySize)
        mod_active = 1; // required in each mod function that always shows something
 
        int layout = autocvar_hud_panel_modicons_dom_layout;
-       float rows, columns, aspect_ratio;
+       int rows, columns;
+       float aspect_ratio;
        aspect_ratio = (layout) ? 3 : 1;
        rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
        columns = ceil(team_count/rows);
@@ -3468,7 +3472,7 @@ void HUD_ModIcons_SetFunc()
        }
 }
 
-float mod_prev; // previous state of mod_active to check for a change
+int mod_prev; // previous state of mod_active to check for a change
 float mod_alpha;
 float mod_change; // "time" when mod_active changed
 
@@ -3662,7 +3666,7 @@ void HUD_Chat(void)
 //
 float prevfps;
 float prevfps_time;
-float framecounter;
+int framecounter;
 
 float frametimeavg;
 float frametimeavg1; // 1 frame ago
@@ -3784,7 +3788,7 @@ void HUD_InfoMessages(void)
                        if(spectatee_status == -1)
                                s = _("^1Observing");
                        else
-                               s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(player_localentnum - 1));
+                               s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(current_player));
                        drawInfoMessage(s);
 
                        if(spectatee_status == -1)
@@ -3908,6 +3912,7 @@ void HUD_InfoMessages(void)
 //
 vector acc_prevspeed;
 float acc_prevtime, acc_avg, top_speed, top_speed_time;
+float physics_update_time, discrete_speed, discrete_acceleration;
 void HUD_Physics(void)
 {
        if(!autocvar__hud_configure)
@@ -3995,8 +4000,23 @@ void HUD_Physics(void)
                acc_prevspeed = vel;
                acc_prevtime = time;
 
-               f = bound(0, f * 10, 1);
-               acc_avg = acc_avg * (1 - f) + acceleration * f;
+               if(autocvar_hud_panel_physics_acceleration_movingaverage)
+               {
+                       f = bound(0, f * 10, 1);
+                       acc_avg = acc_avg * (1 - f) + acceleration * f;
+                       acceleration = acc_avg;
+               }
+       }
+
+       int acc_decimals = 2;
+       if(time > physics_update_time)
+       {
+               // workaround for ftos_decimals returning a negative 0
+               if(discrete_acceleration > -1 / pow(10, acc_decimals) && discrete_acceleration < 0)
+                       discrete_acceleration = 0;
+               discrete_acceleration = acceleration;
+               discrete_speed = speed;
+               physics_update_time += autocvar_hud_panel_physics_update_interval;
        }
 
        //compute layout
@@ -4018,7 +4038,7 @@ void HUD_Physics(void)
                else
                        acceleration_offset.y = panel_size.y;
        }
-       float speed_baralign, acceleration_baralign;
+       int speed_baralign, acceleration_baralign;
        if (autocvar_hud_panel_physics_baralign == 1)
                acceleration_baralign = speed_baralign = 1;
     else if(autocvar_hud_panel_physics_baralign == 4)
@@ -4050,7 +4070,7 @@ void HUD_Physics(void)
                //else
                        //tmp_offset_x = 0;
                tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
-               drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(discrete_speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 
                //draw speed unit
                if (speed_baralign)
@@ -4140,7 +4160,7 @@ void HUD_Physics(void)
 
                f = acceleration/autocvar_hud_panel_physics_acceleration_max;
                if (autocvar_hud_panel_physics_acceleration_progressbar_nonlinear)
-                       f = sqrt(f);
+                       f = (f >= 0 ? sqrt(f) : -sqrt(-f));
 
                if (acceleration_progressbar_scale) // allow progressbar to go out of panel bounds
                {
@@ -4162,33 +4182,37 @@ void HUD_Physics(void)
 
                HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset + tmp_offset, tmp_size, "accelbar", f, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
-       tmp_size.x = panel_size.x;
-       tmp_size.y = panel_size.y * text_scale;
-       tmp_offset.x = 0;
-       tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
-       if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
-               drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(acceleration, 2), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+
+       if(autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
+       {
+               tmp_size.x = panel_size.x;
+               tmp_size.y = panel_size.y * text_scale;
+               tmp_offset.x = 0;
+               tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
+
+               drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(discrete_acceleration, acc_decimals), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       }
 
        draw_endBoldFont();
 }
 
 // CenterPrint (#16)
 //
-const float CENTERPRINT_MAX_MSGS = 10;
-const float CENTERPRINT_MAX_ENTRIES = 50;
+const int CENTERPRINT_MAX_MSGS = 10;
+const int CENTERPRINT_MAX_ENTRIES = 50;
 const float CENTERPRINT_SPACING = 0.7;
-float cpm_index;
+int cpm_index;
 string centerprint_messages[CENTERPRINT_MAX_MSGS];
-float centerprint_msgID[CENTERPRINT_MAX_MSGS];
+int centerprint_msgID[CENTERPRINT_MAX_MSGS];
 float centerprint_time[CENTERPRINT_MAX_MSGS];
 float centerprint_expire_time[CENTERPRINT_MAX_MSGS];
-float centerprint_countdown_num[CENTERPRINT_MAX_MSGS];
-float centerprint_showing;
+int centerprint_countdown_num[CENTERPRINT_MAX_MSGS];
+bool centerprint_showing;
 
-void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num)
+void centerprint_generic(int new_id, string strMessage, float duration, int countdown_num)
 {
        //printf("centerprint_generic(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num);
-       float i, j;
+       int i, j;
 
        if(strMessage == "" && new_id == 0)
                return;
@@ -4268,7 +4292,7 @@ void centerprint_hud(string strMessage)
 
 void reset_centerprint_messages(void)
 {
-       float i;
+       int i;
        for (i=0; i<CENTERPRINT_MAX_MSGS; ++i)
        {
                centerprint_expire_time[i] = 0;
@@ -4295,15 +4319,23 @@ void HUD_CenterPrint (void)
                        reset_centerprint_messages();
                if (time > hud_configure_cp_generation_time)
                {
-                       float r;
-                       r = random();
-                       if (r > 0.75)
-                               centerprint_generic(floor(r*1000), strcat(sprintf("^3Countdown message at time %s", seconds_tostring(time)), ", seconds left: ^COUNT"), 1, 10);
-                       else if (r > 0.5)
-                               centerprint_generic(0, sprintf("^1Multiline message at time %s that\n^1lasts longer than normal", seconds_tostring(time)), 20, 0);
+                       if(HUD_PANEL(CENTERPRINT) == highlightedPanel)
+                       {
+                               float r;
+                               r = random();
+                               if (r > 0.8)
+                                       centerprint_generic(floor(r*1000), strcat(sprintf("^3Countdown message at time %s", seconds_tostring(time)), ", seconds left: ^COUNT"), 1, 10);
+                               else if (r > 0.55)
+                                       centerprint_generic(0, sprintf("^1Multiline message at time %s that\n^1lasts longer than normal", seconds_tostring(time)), 20, 0);
+                               else
+                                       centerprint_hud(sprintf("Message at time %s", seconds_tostring(time)));
+                               hud_configure_cp_generation_time = time + 1 + random()*4;
+                       }
                        else
-                               centerprint_hud(sprintf("Message at time %s", seconds_tostring(time)));
-                       hud_configure_cp_generation_time = time + 1 + random()*4;
+                       {
+                               centerprint_generic(0, sprintf("Centerprint message", seconds_tostring(time)), 10, 0);
+                               hud_configure_cp_generation_time = time + 10 - random()*3;
+                       }
                }
        }
 
@@ -4345,7 +4377,8 @@ void HUD_CenterPrint (void)
                panel_size -= '2 2 0' * panel_bg_padding;
        }
 
-       float entries, height;
+       int entries;
+       float height;
        vector fontsize;
        // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
        // height = panel_size_y/entries;
@@ -4354,11 +4387,11 @@ void HUD_CenterPrint (void)
        fontsize = '1 1 0' * height;
        entries = bound(1, floor(panel_size.y/height), CENTERPRINT_MAX_ENTRIES);
 
-       float i, j, k, n, g;
+       int i, j, k, n, g;
        float a, sz, align, current_msg_posY = 0, msg_size;
        vector pos;
        string ts;
-       float all_messages_expired = true;
+       bool all_messages_expired = true;
 
        pos = panel_pos;
        if (autocvar_hud_panel_centerprint_flip)
@@ -4495,7 +4528,7 @@ void HUD_CenterPrint (void)
 //
 void HUD_Buffs(void)
 {
-       float buffs = getstati(STAT_BUFFS, 0, 24);
+       int buffs = getstati(STAT_BUFFS, 0, 24);
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_buffs) return;
@@ -4508,7 +4541,7 @@ void HUD_Buffs(void)
                buffs = Buff_Type_first.items; // force first buff
        }
 
-       float b = 0; // counter to tell other functions that we have buffs
+       int b = 0; // counter to tell other functions that we have buffs
        entity e;
        string s = "";
        for(e = Buff_Type_first; e; e = e.enemy) if(buffs & e.items)
@@ -4537,7 +4570,7 @@ void HUD_Buffs(void)
        }
 
        //float panel_ar = mySize_x/mySize_y;
-       //float is_vertical = (panel_ar < 1);
+       //bool is_vertical = (panel_ar < 1);
        //float buff_iconalign = autocvar_hud_panel_buffs_iconalign;
        vector buff_offset = '0 0 0';
 
@@ -4603,12 +4636,10 @@ void HUD_Main (void)
                hud_skin_prev = strzone(autocvar_hud_skin);
        }
 
-    current_player = player_localentnum;
-
        // draw the dock
        if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
        {
-               float f;
+               int f;
                vector color;
                float hud_dock_color_team = autocvar_hud_dock_color_team;
                if((teamplay) && hud_dock_color_team) {
@@ -4624,11 +4655,11 @@ void HUD_Main (void)
                {
                        string hud_dock_color = autocvar_hud_dock_color;
                        if(hud_dock_color == "shirt") {
-                               f = stof(getplayerkeyvalue(current_player - 1, "colors"));
+                               f = stof(getplayerkeyvalue(current_player, "colors"));
                                color = colormapPaletteColor(floor(f / 16), 0);
                        }
                        else if(hud_dock_color == "pants") {
-                               f = stof(getplayerkeyvalue(current_player - 1, "colors"));
+                               f = stof(getplayerkeyvalue(current_player, "colors"));
                                color = colormapPaletteColor(f % 16, 1);
                        }
                        else
@@ -4651,13 +4682,14 @@ void HUD_Main (void)
                for(i = 0; i < HUD_PANEL_NUM; ++i)
                        panel_order[i] = -1;
                string s = "";
-               float p_num, warning = false;
-               float argc = tokenize_console(autocvar__hud_panelorder);
+               int p_num;
+               bool warning = false;
+               int argc = tokenize_console(autocvar__hud_panelorder);
                if (argc > HUD_PANEL_NUM)
                        warning = true;
                //first detect wrong/missing panel numbers
                for(i = 0; i < HUD_PANEL_NUM; ++i) {
-                       p_num = stof(argv(i));
+                       p_num = stoi(argv(i));
                        if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
                                if (panel_order[p_num] == -1) //found for the first time?
                                        s = strcat(s, ftos(p_num), " ");