]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into Mario/ctf_updates
authorMario <zacjardine@y7mail.com>
Mon, 2 Feb 2015 20:13:37 +0000 (07:13 +1100)
committerMario <zacjardine@y7mail.com>
Mon, 2 Feb 2015 20:13:37 +0000 (07:13 +1100)
Conflicts:
qcsrc/client/hud.qc
qcsrc/client/progs.src
qcsrc/common/notifications.qh
qcsrc/common/stats.qh
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_ctf.qh

1  2 
qcsrc/client/hud.qc
qcsrc/client/waypointsprites.qc
qcsrc/common/notifications.qh
qcsrc/common/stats.qh
qcsrc/server/autocvars.qh
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_ctf.qh

diff --combined qcsrc/client/hud.qc
index 136b77361eedc97aedd6aba32e4d752cf996a58f,e33b9b0203705e87c0895d687e609dec265492ba..d22459af7677df2327d8266a05b5c8f51f7aed57
@@@ -1,3 -1,11 +1,12 @@@
+ #include "scoreboard.qh"
+ #include "teamradar.qh"
+ #include "../common/buffs.qh"
+ #include "../common/counting.qh"
+ #include "../common/mapinfo.qh"
+ #include "../common/nades.qh"
+ #include "../server/t_items.qh"
++#include "../server/mutators/gamemode_ctf.qh"
  /*
  ==================
  Misc HUD functions
  //   1/4 height: bottom part
  void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
  {
-     if (theBorderSize_x < 0 && theBorderSize_y < 0) // draw whole image as it is
+     if (theBorderSize.x < 0 && theBorderSize.y < 0) // draw whole image as it is
      {
                drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0);
                return;
      }
-       if (theBorderSize_x == 0 && theBorderSize_y == 0) // no border
+       if (theBorderSize.x == 0 && theBorderSize.y == 0) // no border
        {
                // draw only the central part
                drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
        vector width, height;
        vector bW, bH;
        //pic = draw_UseSkinFor(pic);
-       width = eX * theSize_x;
-       height = eY * theSize_y;
-       if(theSize_x <= theBorderSize_x * 2)
+       width = eX * theSize.x;
+       height = eY * theSize.y;
+       if(theSize.x <= theBorderSize.x * 2)
        {
                // not wide enough... draw just left and right then
-               bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
-               if(theSize_y <= theBorderSize_y * 2)
+               bW = eX * (0.25 * theSize.x / (theBorderSize.x * 2));
+               if(theSize.y <= theBorderSize.y * 2)
                {
                        // not high enough... draw just corners
-                       bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
+                       bH = eY * (0.25 * theSize.y / (theBorderSize.y * 2));
                        drawsubpic(theOrigin,                 width * 0.5 + height * 0.5, pic, '0 0 0',           bW + bH, theColor, theAlpha, 0);
                        drawsubpic(theOrigin + width   * 0.5, width * 0.5 + height * 0.5, pic, eX - bW,           bW + bH, theColor, theAlpha, 0);
                        drawsubpic(theOrigin + height  * 0.5, width * 0.5 + height * 0.5, pic, eY - bH,           bW + bH, theColor, theAlpha, 0);
@@@ -47,7 -55,7 +56,7 @@@
                }
                else
                {
-                       dY = theBorderSize_x * eY;
+                       dY = theBorderSize.x * eY;
                        drawsubpic(theOrigin,                             width * 0.5          +     dY, pic, '0 0    0',           '0 0.25 0' + bW, theColor, theAlpha, 0);
                        drawsubpic(theOrigin + width * 0.5,               width * 0.5          +     dY, pic, '0 0    0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
                        drawsubpic(theOrigin                        + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0',           '0 0.5  0' + bW, theColor, theAlpha, 0);
        }
        else
        {
-               if(theSize_y <= theBorderSize_y * 2)
+               if(theSize.y <= theBorderSize.y * 2)
                {
                        // not high enough... draw just top and bottom then
-                       bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
-                       dX = theBorderSize_x * eX;
+                       bH = eY * (0.25 * theSize.y / (theBorderSize.y * 2));
+                       dX = theBorderSize.x * eX;
                        drawsubpic(theOrigin,                                         dX + height * 0.5, pic, '0    0 0',           '0.25 0 0' + bH, theColor, theAlpha, 0);
                        drawsubpic(theOrigin + dX,                        width - 2 * dX + height * 0.5, pic, '0.25 0 0',           '0.5  0 0' + bH, theColor, theAlpha, 0);
                        drawsubpic(theOrigin + width - dX,                            dX + height * 0.5, pic, '0.75 0 0',           '0.25 0 0' + bH, theColor, theAlpha, 0);
@@@ -72,8 -80,8 +81,8 @@@
                }
                else
                {
-                       dX = theBorderSize_x * eX;
-                       dY = theBorderSize_x * eY;
+                       dX = theBorderSize.x * eX;
+                       dY = theBorderSize.x * eY;
                        drawsubpic(theOrigin,                                        dX          +     dY, pic, '0    0    0', '0.25 0.25 0', theColor, theAlpha, 0);
                        drawsubpic(theOrigin                  + dX,      width - 2 * dX          +     dY, pic, '0.25 0    0', '0.5  0.25 0', theColor, theAlpha, 0);
                        drawsubpic(theOrigin          + width - dX,                  dX          +     dY, pic, '0.75 0    0', '0.25 0.25 0', theColor, theAlpha, 0);
@@@ -92,65 -100,65 +101,65 @@@ vector HUD_Get_Num_Color (float x, floa
        float blinkingamt;
        vector color;
        if(x >= maxvalue) {
-               color_x = sin(2*M_PI*time);
-               color_y = 1;
-               color_z = sin(2*M_PI*time);
+               color.x = sin(2*M_PI*time);
+               color.y = 1;
+               color.z = sin(2*M_PI*time);
        }
        else if(x > maxvalue * 0.75) {
-               color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
-               color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
-               color_z = 0;
+               color.x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
+               color.y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
+               color.z = 0;
        }
        else if(x > maxvalue * 0.5) {
-               color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
-               color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
-               color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
+               color.x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
+               color.y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
+               color.z = 1 - (x-100)*0.02; // blue value between 1 -> 0
        }
        else if(x > maxvalue * 0.25) {
-               color_x = 1;
-               color_y = 1;
-               color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
+               color.x = 1;
+               color.y = 1;
+               color.z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
        }
        else if(x > maxvalue * 0.1) {
-               color_x = 1;
-               color_y = (x-20)*90/27/100; // green value between 0 -> 1
-               color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
+               color.x = 1;
+               color.y = (x-20)*90/27/100; // green value between 0 -> 1
+               color.z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
        }
        else {
-               color_x = 1;
-               color_y = 0;
-               color_z = 0;
+               color.x = 1;
+               color.y = 0;
+               color.z = 0;
        }
  
        blinkingamt = (1 - x/maxvalue/0.25);
        if(blinkingamt > 0)
        {
-               color_x = color_x - color_x * blinkingamt * sin(2*M_PI*time);
-               color_y = color_y - color_y * blinkingamt * sin(2*M_PI*time);
-               color_z = color_z - color_z * blinkingamt * sin(2*M_PI*time);
+               color.x = color.x - color.x * blinkingamt * sin(2*M_PI*time);
+               color.y = color.y - color.y * blinkingamt * sin(2*M_PI*time);
+               color.z = color.z - color.z * blinkingamt * sin(2*M_PI*time);
        }
        return color;
  }
  
  float stringwidth_colors(string s, vector theSize)
  {
-       return stringwidth(s, TRUE, theSize);
+       return stringwidth(s, true, theSize);
  }
  
  float stringwidth_nocolors(string s, vector theSize)
  {
-       return stringwidth(s, FALSE, theSize);
+       return stringwidth(s, false, theSize);
  }
  
  void drawstringright(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag)
  {
-       position_x -= 2 / 3 * strlen(text) * theScale_x;
+       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)
  {
-       position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * theScale_x);
+       position.x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * theScale.x);
        drawstring(position, text, theScale, rgb, theAlpha, flag);
  }
  
@@@ -232,7 -240,7 +241,7 @@@ float race_CheckName(string net_name) 
        return 0;
  }
  
- float GetPlayerColorForce(float i)
+ float GetPlayerColorForce(int i)
  {
        if(!teamplay)
                return 0;
                return stof(getplayerkeyvalue(i, "colors")) & 15;
  }
  
- float GetPlayerColor(float i)
+ float GetPlayerColor(int i)
  {
        if(!playerslots[i].gotscores) // unconnected
                return NUM_SPECTATOR;
                return GetPlayerColorForce(i);
  }
  
- string GetPlayerName(float i)
+ string GetPlayerName(int i)
  {
        return ColorTranslateRGB(getplayerkeyvalue(i, "name"));
  }
@@@ -263,9 -271,10 +272,10 @@@ HUD panel
  */
  
  // draw the background/borders
- #define HUD_Panel_DrawBg(theAlpha)\
- if(panel.current_panel_bg != "0" && panel.current_panel_bg != "")\
-       draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER))
+ #define HUD_Panel_DrawBg(theAlpha) do {                                                                                                                                                               \
+       if(panel.current_panel_bg != "0" && panel.current_panel_bg != "")                                                                                               \
+               draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
+ } 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)
                }
  
          if (baralign == 1) // bottom align
-                       theOrigin_y += (1 - length_ratio) * theSize_y;
+                       theOrigin.y += (1 - length_ratio) * theSize.y;
          else if (baralign == 2) // center align
-             theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y;
+             theOrigin.y += 0.5 * (1 - length_ratio) * theSize.y;
          else if (baralign == 3) // center align, positive values down, negative up
                {
-                       theSize_y *= 0.5;
+                       theSize.y *= 0.5;
                        if (length_ratio > 0)
-                               theOrigin_y += theSize_y;
+                               theOrigin.y += theSize.y;
                        else
                        {
-                               theOrigin_y += (1 + length_ratio) * theSize_y;
+                               theOrigin.y += (1 + length_ratio) * theSize.y;
                                length_ratio = -length_ratio;
                        }
                }
-               theSize_y *= length_ratio;
+               theSize.y *= length_ratio;
  
                vector bH;
-               width = eX * theSize_x;
-               height = eY * theSize_y;
-               if(theSize_y <= theSize_x * 2)
+               width = eX * theSize.x;
+               height = eY * theSize.y;
+               if(theSize.y <= theSize.x * 2)
                {
                        // button not high enough
                        // draw just upper and lower part then
-                       square = eY * theSize_y * 0.5;
-                       bH = eY * (0.25 * theSize_y / (theSize_x * 2));
+                       square = eY * theSize.y * 0.5;
+                       bH = eY * (0.25 * theSize.y / (theSize.x * 2));
                        drawsubpic(theOrigin,          square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
                }
                else
                {
-                       square = eY * theSize_x;
+                       square = eY * theSize.x;
                        drawsubpic(theOrigin,                   width   +     square, pic, '0 0    0', '1 0.25 0', theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin +          square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5  0', theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin + height - square, width   +     square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
                }
  
                if (baralign == 1) // right align
-                       theOrigin_x += (1 - length_ratio) * theSize_x;
+                       theOrigin.x += (1 - length_ratio) * theSize.x;
          else if (baralign == 2) // center align
-             theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x;
+             theOrigin.x += 0.5 * (1 - length_ratio) * theSize.x;
          else if (baralign == 3) // center align, positive values on the right, negative on the left
                {
-                       theSize_x *= 0.5;
+                       theSize.x *= 0.5;
                        if (length_ratio > 0)
-                               theOrigin_x += theSize_x;
+                               theOrigin.x += theSize.x;
                        else
                        {
-                               theOrigin_x += (1 + length_ratio) * theSize_x;
+                               theOrigin.x += (1 + length_ratio) * theSize.x;
                                length_ratio = -length_ratio;
                        }
                }
-               theSize_x *= length_ratio;
+               theSize.x *= length_ratio;
  
                vector bW;
-               width = eX * theSize_x;
-               height = eY * theSize_y;
-               if(theSize_x <= theSize_y * 2)
+               width = eX * theSize.x;
+               height = eY * theSize.y;
+               if(theSize.x <= theSize.y * 2)
                {
                        // button not wide enough
                        // draw just left and right part then
-                       square = eX * theSize_x * 0.5;
-                       bW = eX * (0.25 * theSize_x / (theSize_y * 2));
+                       square = eX * theSize.x * 0.5;
+                       bW = eX * (0.25 * theSize.x / (theSize.y * 2));
                        drawsubpic(theOrigin,          square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
                }
                else
                {
-                       square = eX * theSize_y;
+                       square = eX * theSize.y;
                        drawsubpic(theOrigin,                  height  +     square, pic, '0    0 0', '0.25 1 0', theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin +         square, theSize - 2 * square, pic, '0.25 0 0', '0.5  1 0', theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin + width - square, height  +     square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
@@@ -382,19 -391,18 +392,18 @@@ void HUD_Panel_DrawHighlight(vector pos
                pic = "gfx/hud/default/num_leading";
        }
  
-       drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, theAlpha, drawflag);
-       if(mySize_x/mySize_y > 2)
-               drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, theAlpha, drawflag);
-       drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, theAlpha, drawflag);
+       drawsubpic(pos, eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0 0 0', '0.25 1 0', color, theAlpha, drawflag);
+       if(mySize.x/mySize.y > 2)
+               drawsubpic(pos + eX * mySize.y, eX * (mySize.x - 2 * mySize.y) + eY * mySize.y, pic, '0.25 0 0', '0.5 1 0', color, theAlpha, drawflag);
+       drawsubpic(pos + eX * mySize.x - eX * min(mySize.x * 0.5, mySize.y), eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0.75 0 0', '0.25 1 0', color, theAlpha, drawflag);
  }
  
  // Weapon icons (#0)
  //
  entity weaponorder[WEP_MAXCOUNT];
- void weaponorder_swap(float i, float j, entity pass)
+ void weaponorder_swap(int i, int j, entity pass)
  {
-       entity h;
-       h = weaponorder[i];
+       entity h = weaponorder[i];
        weaponorder[i] = weaponorder[j];
        weaponorder[j] = h;
  }
@@@ -413,9 -421,10 +422,10 @@@ void HUD_Weapons(void
        // declarations
        WepSet weapons_stat = WepSet_GetFromStat();
        float i, f, a;
-       float screen_ar, center_x = 0, center_y;
+       float screen_ar;
+       vector center = '0 0 0';
        float weapon_count, weapon_id;
-       float row, column, rows = 0, columns;
+       float row, column, rows = 0, columns = 0;
        float aspect = autocvar_hud_panel_weapons_aspect;
  
        float panel_weapon_accuracy;
        float timeout_effect_length = autocvar_hud_panel_weapons_timeout_speed_out; //? 0.75 : 0);
  
        float ammo_full;
-       float barsize_x = 0, barsize_y = 0, baroffset_x = 0, baroffset_y = 0;
+       vector barsize = '0 0 0', baroffset = '0 0 0';
        vector ammo_color = '1 0 1';
        float ammo_alpha = 1;
  
        float fadetime = max(0, autocvar_hud_panel_weapons_complainbubble_fadetime);
  
        vector weapon_pos, weapon_size = '0 0 0';
-       local noref vector old_panel_size; // fteqcc sucks
        vector color;
  
        // check to see if we want to continue
        // figure out weapon order (how the weapons are sorted) // TODO make this configurable
        if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
        {
-               float weapon_cnt;
+               int weapon_cnt;
                if(weaponorder_bypriority)
                        strunzone(weaponorder_bypriority);
                if(weaponorder_byimpulse)
                        return;
                }
  
-               old_panel_size = panel_size;
-               if(panel_bg_padding)
-                       old_panel_size -= '2 2 0' * panel_bg_padding;
-               // first find values for the standard table (with all the weapons)
-               rows = old_panel_size_y/old_panel_size_x;
-               rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
-               columns = ceil(WEP_COUNT/rows);
-               weapon_size_x = old_panel_size_x / columns;
-               weapon_size_y = old_panel_size_y / rows;
+               vector max_panel_size = panel_size - '2 2 0' * panel_bg_padding;
  
-               // change table values to include only the owned weapons
-               float columns_save = columns;
-               if(weapon_count <= rows)
+               // calculate distribution and size of table cells
+               if(max_panel_size.x > max_panel_size.y)
                {
-                       rows = weapon_count;
-                       columns = 1;
+                       while(weapon_count > columns * rows)
+                       {
+                               ++rows;
+                               columns = ceil(max_panel_size.x / (max_panel_size.y / rows * aspect));
+                       }
+                       weapon_size.x = max_panel_size.x / columns;
+                       weapon_size.y = max_panel_size.y / rows;
+                       columns = ceil(weapon_count / rows);
                }
                else
-                       columns = ceil(weapon_count / rows);
+               {
+                       while(weapon_count > columns * rows)
+                       {
+                               ++columns;
+                               rows = ceil(max_panel_size.y / (max_panel_size.x / columns / aspect));
+                       }
  
-               // enlarge weapon_size to match desired aspect ratio in order to capitalize on panel space
-               if(columns < columns_save)
-                       weapon_size_x = min(old_panel_size_x / columns, aspect * weapon_size_y);
+                       weapon_size.x = max_panel_size.x / columns;
+                       weapon_size.y = max_panel_size.y / rows;
+                       rows = ceil(weapon_count / columns);
+               }
  
                // reduce size of the panel
-               panel_size_x = columns * weapon_size_x;
-               panel_size_y = rows * weapon_size_y;
-               panel_pos_x += (old_panel_size_x - panel_size_x) / 2;
-               panel_pos_y += (old_panel_size_y - panel_size_y) / 2;
-               if(panel_bg_padding)
-                       panel_size += '2 2 0' * panel_bg_padding;
+               panel_size.x = columns * weapon_size.x;
+               panel_size.y = rows * weapon_size.y;
+               panel_pos.x += (max_panel_size.x - panel_size.x) / 2;
+               panel_pos.y += (max_panel_size.y - panel_size.y) / 2;
+               panel_size += '2 2 0' * panel_bg_padding;
        }
        else
                weapon_count = WEP_COUNT;
                        if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
                        {
                                f *= f; // for a cooler movement
-                               center_x = panel_pos_x + panel_size_x/2;
-                               center_y = panel_pos_y + panel_size_y/2;
+                               center.x = panel_pos.x + panel_size.x/2;
+                               center.y = panel_pos.y + panel_size.y/2;
                                screen_ar = vid_conwidth/vid_conheight;
-                               if (center_x/center_y < screen_ar) //bottom left
+                               if (center.x/center.y < screen_ar) //bottom left
                                {
-                                       if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
-                                               panel_pos_y += f * (vid_conheight - panel_pos_y);
+                                       if ((vid_conwidth - center.x)/center.y < screen_ar) //bottom
+                                               panel_pos.y += f * (vid_conheight - panel_pos.y);
                                        else //left
-                                               panel_pos_x -= f * (panel_pos_x + panel_size_x);
+                                               panel_pos.x -= f * (panel_pos.x + panel_size.x);
                                }
                                else //top right
                                {
-                                       if ((vid_conwidth - center_x)/center_y < screen_ar) //right
-                                               panel_pos_x += f * (vid_conwidth - panel_pos_x);
+                                       if ((vid_conwidth - center.x)/center.y < screen_ar) //right
+                                               panel_pos.x += f * (vid_conwidth - panel_pos.x);
                                        else //top
-                                               panel_pos_y -= f * (panel_pos_y + panel_size_y);
+                                               panel_pos.y -= f * (panel_pos.y + panel_size.y);
                                }
                                if(f == 1)
-                                       center_x = -1; // mark the panel as off screen
+                                       center.x = -1; // mark the panel as off screen
                        }
                        weaponprevtime = time - (1 - f) * timein_effect_length;
                }
                        {
                                f *= f; // for a cooler movement
                                f = 1 - f;
-                               center_x = panel_pos_x + panel_size_x/2;
-                               center_y = panel_pos_y + panel_size_y/2;
+                               center.x = panel_pos.x + panel_size.x/2;
+                               center.y = panel_pos.y + panel_size.y/2;
                                screen_ar = vid_conwidth/vid_conheight;
-                               if (center_x/center_y < screen_ar) //bottom left
+                               if (center.x/center.y < screen_ar) //bottom left
                                {
-                                       if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
-                                               panel_pos_y += f * (vid_conheight - panel_pos_y);
+                                       if ((vid_conwidth - center.x)/center.y < screen_ar) //bottom
+                                               panel_pos.y += f * (vid_conheight - panel_pos.y);
                                        else //left
-                                               panel_pos_x -= f * (panel_pos_x + panel_size_x);
+                                               panel_pos.x -= f * (panel_pos.x + panel_size.x);
                                }
                                else //top right
                                {
-                                       if ((vid_conwidth - center_x)/center_y < screen_ar) //right
-                                               panel_pos_x += f * (vid_conwidth - panel_pos_x);
+                                       if ((vid_conwidth - center.x)/center.y < screen_ar) //right
+                                               panel_pos.x += f * (vid_conwidth - panel_pos.x);
                                        else //top
-                                               panel_pos_y -= f * (panel_pos_y + panel_size_y);
+                                               panel_pos.y -= f * (panel_pos.y + panel_size.y);
                                }
                        }
                }
        // draw the background, then change the virtual size of it to better fit other items inside
        HUD_Panel_DrawBg(1);
  
-       if(center_x == -1)
+       if(center.x == -1)
        {
                draw_endBoldFont();
                return;
  
        if(!rows) // if rows is > 0 onlyowned code has already updated these vars
        {
-               rows = panel_size_y/panel_size_x;
+               rows = panel_size.y/panel_size.x;
                rows = bound(1, floor((sqrt(4 * aspect * rows * weapon_count + rows * rows) + rows + 0.5) / 2), weapon_count);
                columns = ceil(weapon_count/rows);
-               weapon_size = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
+               weapon_size = eX * panel_size.x*(1/columns) + eY * panel_size.y*(1/rows);
        }
  
        // calculate position/size for visual bar displaying ammount of ammo status
                ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
                ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
  
-               if(weapon_size_x/weapon_size_y > aspect)
+               if(weapon_size.x/weapon_size.y > aspect)
                {
-                       barsize_x = aspect * weapon_size_y;
-                       barsize_y = weapon_size_y;
-                       baroffset_x = (weapon_size_x - barsize_x) / 2;
+                       barsize.x = aspect * weapon_size.y;
+                       barsize.y = weapon_size.y;
+                       baroffset.x = (weapon_size.x - barsize.x) / 2;
                }
                else
                {
-                       barsize_y = 1/aspect * weapon_size_x;
-                       barsize_x = weapon_size_x;
-                       baroffset_y = (weapon_size_y - barsize_y) / 2;
+                       barsize.y = 1/aspect * weapon_size.x;
+                       barsize.x = weapon_size.x;
+                       baroffset.y = (weapon_size.y - barsize.y) / 2;
                }
        }
        if(autocvar_hud_panel_weapons_accuracy)
                Accuracy_LoadColors();
  
+       // 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);
        for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
        {
                // retrieve information about the current weapon to be drawn
  
                // figure out the drawing position of weapon
                weapon_pos = (panel_pos
-                       + eX * column * weapon_size_x
-                       + eY * row * weapon_size_y);
+                       + eX * column * weapon_size.x
+                       + eY * row * weapon_size.y);
  
                // draw background behind currently selected weapon
                if(self.weapon == switchweapon)
                        switch(autocvar_hud_panel_weapons_label)
                        {
                                case 1: // weapon number
-                                       drawstring(weapon_pos, ftos(weapon_id), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       drawstring(weapon_pos, ftos(weapon_id), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                                        break;
  
                                case 2: // bind
-                                       drawstring(weapon_pos, getcommandkey(ftos(weapon_id), strcat("weapon_group_", ftos(weapon_id))), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       drawstring(weapon_pos, getcommandkey(ftos(weapon_id), strcat("weapon_group_", ftos(weapon_id))), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                                        break;
  
                                case 3: // weapon name
-                                       drawstring(weapon_pos, strtolower(self.message), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       drawstring(weapon_pos, strtolower(self.message), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                                        break;
  
                                default: // nothing
                                        }
  
                                        drawsetcliparea(
-                                               weapon_pos_x + baroffset_x,
-                                               weapon_pos_y + baroffset_y,
-                                               barsize_x * bound(0, a/ammo_full, 1),
-                                               barsize_y
+                                               weapon_pos.x + baroffset.x,
+                                               weapon_pos.y + baroffset.y,
+                                               barsize.x * bound(0, a/ammo_full, 1),
+                                               barsize.y
                                        );
  
                                        drawpic_aspect_skin(
  // Ammo (#1)
  void DrawNadeScoreBar(vector myPos, vector mySize, 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, 
+               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,
                autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
  
  }
@@@ -847,20 -860,20 +861,20 @@@ void DrawAmmoNades(vector myPos, vecto
  {
        float theAlpha = 1, a, b;
        vector nade_color, picpos, numpos;
-       
        nade_color = Nade_Color(getstati(STAT_NADE_BONUS_TYPE));
-       
        a = getstatf(STAT_NADE_BONUS);
        b = getstatf(STAT_NADE_BONUS_SCORE);
-       
        if(autocvar_hud_panel_ammo_iconalign)
        {
                numpos = myPos;
-               picpos = myPos + eX * 2 * mySize_y;
+               picpos = myPos + eX * 2 * mySize.y;
        }
        else
        {
-               numpos = myPos + eX * mySize_y;
+               numpos = myPos + eX * mySize.y;
                picpos = myPos;
        }
  
        if(b > 0 || a > 0)
        {
                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(numpos, ftos(a), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, 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(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_expanding(picpos, "nade_nbg", '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, 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);
        }
  }
  
@@@ -905,13 -918,13 +919,13 @@@ void DrawAmmoItem(vector myPos, vector 
        vector iconPos, textPos;
        if(autocvar_hud_panel_ammo_iconalign)
        {
-               iconPos = myPos + eX * 2 * mySize_y;
+               iconPos = myPos + eX * 2 * mySize.y;
                textPos = myPos;
        }
        else
        {
                iconPos = myPos;
-               textPos = myPos + eX * mySize_y;
+               textPos = myPos + eX * mySize.y;
        }
  
        float isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
                drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
  
        if(ammo > 0 && autocvar_hud_panel_ammo_progressbar)
-               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, ammo/autocvar_hud_panel_ammo_maxammo, 0, 0, textColor, autocvar_hud_progressbar_alpha * alpha, DRAWFLAG_NORMAL);
+               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, ammo/autocvar_hud_panel_ammo_maxammo, 0, 0, textColor, autocvar_hud_progressbar_alpha * alpha, DRAWFLAG_NORMAL);
  
        if(autocvar_hud_panel_ammo_text)
-               drawstring_aspect(textPos, text, eX * (2/3) * mySize_x + eY * mySize_y, textColor, alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(textPos, text, eX * (2/3) * mySize.x + eY * mySize.y, textColor, alpha, DRAWFLAG_NORMAL);
  
-       drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize_y, iconColor, alpha, DRAWFLAG_NORMAL);
+       drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize.y, iconColor, alpha, DRAWFLAG_NORMAL);
  }
  
  float nade_prevstatus;
@@@ -1002,30 -1015,30 +1016,30 @@@ void HUD_Ammo(void
        else
                nade_prevstatus = nade_prevframe = nade_statuschange_time = 0;
  
-       rows = mySize_y/mySize_x;
+       rows = mySize.y/mySize.x;
        rows = bound(1, floor((sqrt(4 * (3/1) * rows * (total_ammo_count) + rows * rows) + rows + 0.5) / 2), (total_ammo_count));
        //                               ^^^ ammo item aspect goes here
  
        columns = ceil((total_ammo_count)/rows);
  
-       ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
-       
+       ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
  
-       local vector offset = '0 0 0'; // fteqcc sucks
+       vector offset = '0 0 0'; // fteqcc sucks
        float newSize;
-       if(ammo_size_x/ammo_size_y > 3)
+       if(ammo_size.x/ammo_size.y > 3)
        {
-               newSize = 3 * ammo_size_y;
-               offset_x = ammo_size_x - newSize;
-               pos_x += offset_x/2;
-               ammo_size_x = newSize;
+               newSize = 3 * ammo_size.y;
+               offset.x = ammo_size.x - newSize;
+               pos.x += offset.x/2;
+               ammo_size.x = newSize;
        }
        else
        {
-               newSize = 1/3 * ammo_size_x;
-               offset_y = ammo_size_y - newSize;
-               pos_y += offset_y/2;
-               ammo_size_y = newSize;
+               newSize = 1/3 * ammo_size.x;
+               offset.y = ammo_size.y - newSize;
+               pos.y += offset.y/2;
+               ammo_size.y = newSize;
        }
  
        float i;
        {
                if(autocvar__hud_configure)
                {
-                       DrawAmmoItem(pos, ammo_size, ammo_rockets, TRUE, FALSE);
+                       DrawAmmoItem(pos, ammo_size, ammo_rockets, true, false);
                }
                else
                {
                                pos,
                                ammo_size,
                                (get_weaponinfo(switchweapon)).ammo_field,
-                               TRUE,
+                               true,
                                infinite_ammo
                        );
                }
                {
                        ammotype = GetAmmoFieldFromNum(i);
                        DrawAmmoItem(
-                               pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y),
+                               pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y),
                                ammo_size,
                                ammotype,
                                ((get_weaponinfo(switchweapon)).ammo_field == ammotype),
  
                float f = bound(0, nade_statuschange_elapsedtime*2, 1);
  
-               DrawAmmoNades(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, nade_prevstatus < nade_cnt && nade_cnt != 0 && f < 1, f);
+               DrawAmmoNades(pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y), ammo_size, nade_prevstatus < nade_cnt && nade_cnt != 0 && f < 1, f);
        }
  
        draw_endBoldFont();
@@@ -1098,76 -1111,76 +1112,76 @@@ void DrawNumIcon_expanding(vector myPos
  
        if (vertical)
        {
-               if(mySize_y/mySize_x > 2)
+               if(mySize.y/mySize.x > 2)
                {
-                       newSize_y = 2 * mySize_x;
-                       newSize_x = mySize_x;
+                       newSize.y = 2 * mySize.x;
+                       newSize.x = mySize.x;
  
-                       newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
-                       newPos_x = myPos_x;
+                       newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
+                       newPos.x = myPos.x;
                }
                else
                {
-                       newSize_x = 1/2 * mySize_y;
-                       newSize_y = mySize_y;
+                       newSize.x = 1/2 * mySize.y;
+                       newSize.y = mySize.y;
  
-                       newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
-                       newPos_y = myPos_y;
+                       newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
+                       newPos.y = myPos.y;
                }
  
                if(icon_right_align)
                {
                        numpos = newPos;
-                       picpos = newPos + eY * newSize_x;
+                       picpos = newPos + eY * newSize.x;
                }
                else
                {
                        picpos = newPos;
-                       numpos = newPos + eY * newSize_x;
+                       numpos = newPos + eY * newSize.x;
                }
  
-               newSize_y /= 2;
+               newSize.y /= 2;
                drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
                // make number smaller than icon, it looks better
                // reduce only y to draw numbers with different number of digits with the same y size
-               numpos_y += newSize_y * ((1 - 0.7) / 2);
-               newSize_y *= 0.7;
+               numpos.y += newSize.y * ((1 - 0.7) / 2);
+               newSize.y *= 0.7;
                drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
                return;
        }
  
-       if(mySize_x/mySize_y > 3)
+       if(mySize.x/mySize.y > 3)
        {
-               newSize_x = 3 * mySize_y;
-               newSize_y = mySize_y;
+               newSize.x = 3 * mySize.y;
+               newSize.y = mySize.y;
  
-               newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
-               newPos_y = myPos_y;
+               newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
+               newPos.y = myPos.y;
        }
        else
        {
-               newSize_y = 1/3 * mySize_x;
-               newSize_x = mySize_x;
+               newSize.y = 1/3 * mySize.x;
+               newSize.x = mySize.x;
  
-               newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
-               newPos_x = myPos_x;
+               newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
+               newPos.x = myPos.x;
        }
  
        if(icon_right_align) // right align
        {
                numpos = newPos;
-               picpos = newPos + eX * 2 * newSize_y;
+               picpos = newPos + eX * 2 * newSize.y;
        }
        else // left align
        {
-               numpos = newPos + eX * newSize_y;
+               numpos = newPos + eX * newSize.y;
                picpos = newPos;
        }
  
        // NOTE: newSize_x is always equal to 3 * mySize_y so we can use
        // '2 1 0' * newSize_y instead of eX * (2/3) * newSize_x + eY * newSize_y
-       drawstring_aspect_expanding(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
-       drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
+       drawstring_aspect_expanding(numpos, ftos(x), '2 1 0' * newSize.y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
+       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)
@@@ -1220,7 -1233,7 +1234,7 @@@ void HUD_Powerups(void
                mySize -= '2 2 0' * panel_bg_padding;
        }
  
-       float panel_ar = mySize_x/mySize_y;
+       float panel_ar = mySize.x/mySize.y;
        float is_vertical = (panel_ar < 1);
        vector shield_offset = '0 0 0', strength_offset = '0 0 0', superweapons_offset = '0 0 0';
  
        {
                if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
                {
-                       mySize_x *= (1.0 / 3.0);
-                       superweapons_offset_x = mySize_x;
+                       mySize.x *= (1.0 / 3.0);
+                       superweapons_offset.x = mySize.x;
                        if (autocvar_hud_panel_powerups_flip)
-                               shield_offset_x = 2*mySize_x;
+                               shield_offset.x = 2*mySize.x;
                        else
-                               strength_offset_x = 2*mySize_x;
+                               strength_offset.x = 2*mySize.x;
                }
                else
                {
-                       mySize_y *= (1.0 / 3.0);
-                       superweapons_offset_y = mySize_y;
+                       mySize.y *= (1.0 / 3.0);
+                       superweapons_offset.y = mySize.y;
                        if (autocvar_hud_panel_powerups_flip)
-                               shield_offset_y = 2*mySize_y;
+                               shield_offset.y = 2*mySize.y;
                        else
-                               strength_offset_y = 2*mySize_y;
+                               strength_offset.y = 2*mySize.y;
                }
        }
        else
        {
                if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
                {
-                       mySize_x *= 0.5;
+                       mySize.x *= 0.5;
                        if (autocvar_hud_panel_powerups_flip)
-                               shield_offset_x = mySize_x;
+                               shield_offset.x = mySize.x;
                        else
-                               strength_offset_x = mySize_x;
+                               strength_offset.x = mySize.x;
                }
                else
                {
-                       mySize_y *= 0.5;
+                       mySize.y *= 0.5;
                        if (autocvar_hud_panel_powerups_flip)
-                               shield_offset_y = mySize_y;
+                               shield_offset.y = mySize.y;
                        else
-                               strength_offset_y = mySize_y;
+                               strength_offset.y = mySize.y;
                }
        }
  
@@@ -1459,18 -1472,18 +1473,18 @@@ void HUD_HealthArmor(void
                v = healtharmor_maxdamage(health, armor, armorblockpercent, DEATH_WEAPON);
  
                float x;
-               x = floor(v_x + 1);
+               x = floor(v.x + 1);
  
          float maxtotal = maxhealth + maxarmor;
                string biggercount;
-               if(v_z) // NOT fully armored
+               if(v.z) // NOT fully armored
                {
                        biggercount = "health";
                        if(autocvar_hud_panel_healtharmor_progressbar)
                                HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        if(armor)
              if(autocvar_hud_panel_healtharmor_text)
-                               drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha * armor / health, DRAWFLAG_NORMAL);
+                               drawpic_aspect_skin(pos + eX * mySize.x - eX * 0.5 * mySize.y, "armor", '0.5 0.5 0' * mySize.y, '1 1 1', panel_fg_alpha * armor / health, DRAWFLAG_NORMAL);
                }
                else
                {
                                HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        if(health)
              if(autocvar_hud_panel_healtharmor_text)
-                               drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawpic_aspect_skin(pos + eX * mySize.x - eX * 0.5 * mySize.y, "health", '0.5 0.5 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                }
          if(autocvar_hud_panel_healtharmor_text)
                        DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
  
                if(fuel)
-                       HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawProgressBar(pos, eX * mySize.x + eY * 0.2 * mySize.y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
        }
        else
        {
-               float panel_ar = mySize_x/mySize_y;
+               float panel_ar = mySize.x/mySize.y;
                float 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))
                {
-                       mySize_x *= 0.5;
+                       mySize.x *= 0.5;
                        if (autocvar_hud_panel_healtharmor_flip)
-                               health_offset_x = mySize_x;
+                               health_offset.x = mySize.x;
                        else
-                               armor_offset_x = mySize_x;
+                               armor_offset.x = mySize.x;
                }
                else
                {
-                       mySize_y *= 0.5;
+                       mySize.y *= 0.5;
                        if (autocvar_hud_panel_healtharmor_flip)
-                               health_offset_y = mySize_y;
+                               health_offset.y = mySize.y;
                        else
-                               armor_offset_y = mySize_y;
+                               armor_offset.y = mySize.y;
                }
  
                float health_baralign, armor_baralign, fuel_baralign;
                if(fuel)
                {
                        if (is_vertical)
-                               mySize_x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
+                               mySize.x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
                        else
-                               mySize_y *= 0.2;
+                               mySize.y *= 0.2;
                        if (panel_ar >= 4)
-                               mySize_x *= 2; //restore full panel size
+                               mySize.x *= 2; //restore full panel size
                        else if (panel_ar < 1/4)
-                               mySize_y *= 2; //restore full panel size
+                               mySize.y *= 2; //restore full panel size
                        HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
                }
        }
@@@ -1714,18 -1727,18 +1728,18 @@@ 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);
-       float entry_height = size_y / entry_count;
+       float 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;
+       float panel_width_half = size.x * 0.5;
        float icon_width_half = entry_height * icon_aspect / 2;
-       float name_maxwidth = panel_width_half - icon_width_half - size_x * NOTIFY_ICON_MARGIN;
+       float name_maxwidth = panel_width_half - icon_width_half - size.x * NOTIFY_ICON_MARGIN;
  
        vector font_size = '0.5 0.5 0' * entry_height * autocvar_hud_panel_notify_fontsize;
        vector icon_size = (eX * icon_aspect + eY) * entry_height;
        vector icon_left = eX * (panel_width_half - icon_width_half);
        vector attacker_right = eX * name_maxwidth;
-       vector victim_left = eX * (size_x - name_maxwidth);
+       vector victim_left = eX * (size.x - name_maxwidth);
  
        vector attacker_pos, victim_pos, icon_pos;
        string attacker, victim, icon;
  
                if (icon != "" && victim != "")
                {
-                       vector name_top = eY * (i * entry_height + 0.5 * (entry_height - font_size_y));
+                       vector name_top = eY * (i * entry_height + 0.5 * (entry_height - font_size.y));
  
                        icon_pos = pos + icon_left + eY * i * entry_height;
                        drawpic_aspect_skin(icon_pos, icon, icon_size, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
                        if (attacker != "")
                        {
                                attacker = textShortenToWidth(attacker, name_maxwidth, font_size, stringwidth_colors);
-                               attacker_pos = pos + attacker_right - eX * stringwidth(attacker, TRUE, font_size) + name_top;
+                               attacker_pos = pos + attacker_right - eX * stringwidth(attacker, true, font_size) + name_top;
                                drawcolorcodedstring(attacker_pos, attacker, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
                        }
                }
@@@ -1897,10 -1910,10 +1911,10 @@@ void HUD_Radar(void
        if (hud_panel_radar_maximized && !autocvar__hud_configure)
        {
                panel_size = autocvar_hud_panel_radar_maximized_size;
-               panel_size_x = bound(0.2, panel_size_x, 1) * vid_conwidth;
-               panel_size_y = bound(0.2, panel_size_y, 1) * vid_conheight;
-               panel_pos_x = (vid_conwidth - panel_size_x) / 2;
-               panel_pos_y = (vid_conheight - panel_size_y) / 2;
+               panel_size.x = bound(0.2, panel_size.x, 1) * vid_conwidth;
+               panel_size.y = bound(0.2, panel_size.y, 1) * vid_conheight;
+               panel_pos.x = (vid_conwidth - panel_size.x) / 2;
+               panel_pos.y = (vid_conheight - panel_size.y) / 2;
  
                string panel_bg;
                panel_bg = strcat(hud_skin_path, "/border_default"); // always use the default border when maximized
                switch(hud_panel_radar_maximized_rotation)
                {
                        case 0:
-                               teamradar_angle = view_angles_y - 90;
+                               teamradar_angle = view_angles.y - 90;
                                break;
                        default:
                                teamradar_angle = 90 * hud_panel_radar_maximized_rotation;
                switch(hud_panel_radar_rotation)
                {
                        case 0:
-                               teamradar_angle = view_angles_y - 90;
+                               teamradar_angle = view_angles.y - 90;
                                break;
                        default:
                                teamradar_angle = 90 * hud_panel_radar_rotation;
                vector c0, c1, c2, c3, span;
                c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
                c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
-               c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
-               c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
+               c2 = rotate('1 0 0' * mi_min.x + '0 1 0' * mi_max.y, teamradar_angle * DEG2RAD);
+               c3 = rotate('1 0 0' * mi_max.x + '0 1 0' * mi_min.y, teamradar_angle * DEG2RAD);
                span = '0 0 0';
-               span_x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
-               span_y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
+               span.x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
+               span.y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
  
                // max-min distance must fit the radar in x=x, y=y
                bigsize = min(
-                       teamradar_size2d_x * scale2d / (1.05 * span_x),
-                       teamradar_size2d_y * scale2d / (1.05 * span_y)
+                       teamradar_size2d.x * scale2d / (1.05 * span.x),
+                       teamradar_size2d.y * scale2d / (1.05 * span.y)
                );
        }
  
                + (1 - f) * view_origin);
  
        drawsetcliparea(
-               pos_x,
-               pos_y,
-               mySize_x,
-               mySize_y
+               pos.x,
+               pos.y,
+               mySize.x,
+               mySize.y
        );
  
        draw_teamradar_background(hud_panel_radar_foreground_alpha);
@@@ -2063,17 -2076,17 +2077,17 @@@ void HUD_Score_Rankings(vector pos, vec
  {
        float score;
        entity tm = world, pl;
- #define SCOREPANEL_MAX_ENTRIES 6
- #define SCOREPANEL_ASPECTRATIO 2
-       float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
-       vector fontsize = '1 1 0' * (mySize_y/entries);
+       float 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);
+       vector fontsize = '1 1 0' * (mySize.y/entries);
  
        vector rgb, score_color;
        rgb = '1 1 1';
        score_color = '1 1 1';
  
-       float name_size = mySize_x*0.75;
-       float spacing_size = mySize_x*0.04;
+       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;
        string s;
                if (team_count)
                {
                        // show team scores in the first line
-                       float score_size = mySize_x / team_count;
+                       float score_size = mySize.x / team_count;
                        players_per_team = max(2, ceil((entries - 1) / team_count));
                        for(i=0; i<team_count; ++i) {
                                if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
-                                       HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawstring_aspect(pos + eX * score_size * i, ftos(175 - 23*i), eX * score_size + eY * fontsize_y, Team_ColorRGB(ColorByTeam(i)) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawstring_aspect(pos + eX * score_size * i, ftos(175 - 23*i), eX * score_size + eY * fontsize.y, Team_ColorRGB(ColorByTeam(i)) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        first_pl = 1;
-                       pos_y += fontsize_y;
+                       pos.y += fontsize.y;
                }
                score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
                for (i=first_pl; i<entries; ++i)
                        if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
                        {
                                rgb = '1 1 0';
-                               drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                s = GetPlayerName(player_localnum);
                                score = 7;
                        }
                        if (team_count)
                                score_color = Team_ColorRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
                        s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
-                       drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
                        drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
-                       pos_y += fontsize_y;
+                       pos.y += fontsize.y;
                }
                return;
        }
        if (team_count)
        {
                // show team scores in the first line
-               float score_size = mySize_x / team_count;
+               float score_size = mySize.x / team_count;
                for(tm = teams.sort_next; tm; tm = tm.sort_next) {
                        if(tm.team == NUM_SPECTATOR)
                                continue;
                        if (tm.team == myteam)
-                               drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-                       drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize_y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize.y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize.y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                        ++i;
                }
                first_pl = 1;
-               pos_y += fontsize_y;
+               pos.y += fontsize.y;
                tm = teams.sort_next;
        }
        i = first_pl;
                        if (i == first_pl)
                                rgb = '0 1 0'; //first: green
                        me_printed = 1;
-                       drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                }
                if (team_count)
                        score_color = Team_ColorRGB(pl.team) * 0.8;
                s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
-               drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
                drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
-               pos_y += fontsize_y;
+               pos.y += fontsize.y;
                ++i;
        }
        while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != NUM_SPECTATOR || (tm = tm.sort_next)));
@@@ -2235,12 -2248,12 +2249,12 @@@ void HUD_Score(void
                                distribution_color = '1 0 0';
                                sign = "+";
                        }
-                       drawstring_aspect(pos + eX * 0.75 * mySize_x, strcat(sign, distrtimer), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(pos + eX * 0.75 * mySize.x, strcat(sign, distrtimer), eX * 0.25 * mySize.x + eY * (1/3) * mySize.y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
                }
                // race record display
                if (distribution <= 0)
-                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(pos, timer, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                draw_endBoldFont();
        } else if (!teamplay) { // non-teamgames
                if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
                {
                        if (distribution > 0)
                                distribution_str = strcat("+", distribution_str);
-                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                }
-               drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(pos + eX * 0.75 * mySize_x, distribution_str, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize.x + eY * mySize.y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(pos + eX * 0.75 * mySize.x, distribution_str, eX * 0.25 * mySize.x + eY * (1/3) * mySize.y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
                draw_endBoldFont();
        } else { // teamgames
                float row, column, rows = 0, columns = 0;
-               local noref vector offset = '0 0 0';
+               vector offset = '0 0 0';
                vector score_pos, score_size; //for scores other than myteam
                if(autocvar_hud_panel_score_rankings)
                {
                }
                if(spectatee_status == -1)
                {
-                       rows = mySize_y/mySize_x;
+                       rows = mySize.y/mySize.x;
                        rows = bound(1, floor((sqrt(4 * (3/1) * rows * team_count + rows * rows) + rows + 0.5) / 2), team_count);
                        //                               ^^^ ammo item aspect goes here
  
                        columns = ceil(team_count/rows);
  
-                       score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
+                       score_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
  
                        float newSize;
-                       if(score_size_x/score_size_y > 3)
+                       if(score_size.x/score_size.y > 3)
                        {
-                               newSize = 3 * score_size_y;
-                               offset_x = score_size_x - newSize;
-                               pos_x += offset_x/2;
-                               score_size_x = newSize;
+                               newSize = 3 * score_size.y;
+                               offset.x = score_size.x - newSize;
+                               pos.x += offset.x/2;
+                               score_size.x = newSize;
                        }
                        else
                        {
-                               newSize = 1/3 * score_size_x;
-                               offset_y = score_size_y - newSize;
-                               pos_y += offset_y/2;
-                               score_size_y = newSize;
+                               newSize = 1/3 * score_size.x;
+                               offset.y = score_size.y - newSize;
+                               pos.y += offset.y/2;
+                               score_size.y = newSize;
                        }
                }
                else
-                       score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
+                       score_size = eX * mySize.x*(1/4) + eY * mySize.y*(1/3);
  
                float max_fragcount;
                max_fragcount = -99;
  
                        if (spectatee_status == -1)
                        {
-                               score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
+                               score_pos = pos + eX * column * (score_size.x + offset.x) + eY * row * (score_size.y + offset.y);
                                if (max_fragcount == score)
                                        HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                                drawstring_aspect(score_pos, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        else if(tm.team == myteam) {
                                if (max_fragcount == score)
-                                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize.x + eY * mySize.y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                        } else {
                                if (max_fragcount == score)
-                                       HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize.x + eY * (1/3) * rows * mySize.y, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawstring_aspect(pos + eX * 0.75 * mySize.x + eY * (1/3) * rows * mySize.y, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                                ++rows;
                        }
                }
@@@ -2393,19 -2406,19 +2407,19 @@@ void HUD_RaceTimer (void
  
        // always force 4:1 aspect
        vector newSize = '0 0 0';
-       if(mySize_x/mySize_y > 4)
+       if(mySize.x/mySize.y > 4)
        {
-               newSize_x = 4 * mySize_y;
-               newSize_y = mySize_y;
+               newSize.x = 4 * mySize.y;
+               newSize.y = mySize.y;
  
-               pos_x = pos_x + (mySize_x - newSize_x) / 2;
+               pos.x = pos.x + (mySize.x - newSize.x) / 2;
        }
        else
        {
-               newSize_y = 1/4 * mySize_x;
-               newSize_x = mySize_x;
+               newSize.y = 1/4 * mySize.x;
+               newSize.x = mySize.x;
  
-               pos_y = pos_y + (mySize_y - newSize_y) / 2;
+               pos.y = pos.y + (mySize.y - newSize.y) / 2;
        }
        mySize = newSize;
  
        if(autocvar__hud_configure)
        {
                s = "0:13:37";
-               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);
+               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);
                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);
+               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");
-               drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize_y) + eY * 0.80 * mySize_y, s, '1 1 0' * 0.20 * mySize_y, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.20 * mySize.y) + eY * 0.80 * mySize.y, s, '1 1 0' * 0.20 * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL);
        }
        else if(race_checkpointtime)
        {
  
                if(s != "" && a > 0)
                {
-                       drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                       drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                }
  
                if(race_penaltytime)
                        if(a > 0)
                        {
                                s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
-                               drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.8 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                               drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.8 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                        }
                }
  
                if(forcetime != "")
                {
                        a = bound(0, (time - race_checkpointtime) / 0.5, 1);
-                       drawstring_expanding(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(forcetime, FALSE, '1 1 0' * 0.6 * mySize_y), forcetime, '1 1 0' * 0.6 * mySize_y, '1 1 1', panel_fg_alpha, 0, a);
+                       drawstring_expanding(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(forcetime, false, '1 1 0' * 0.6 * mySize.y), forcetime, '1 1 0' * 0.6 * mySize.y, '1 1 1', panel_fg_alpha, 0, a);
                }
                else
                        a = 1;
                if(race_laptime && race_checkpoint != 255)
                {
                        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);
+                       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);
                }
        }
        else
                {
                        a = bound(0, 2 - (time - race_mycheckpointtime), 1);
                        s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -(race_mycheckpointenemy == ""), race_mycheckpointlapsdelta, race_mycheckpointenemy);
-                       drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                       drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                }
                if(race_othercheckpointtime && race_othercheckpointenemy != "")
                {
                        a = bound(0, 2 - (time - race_othercheckpointtime), 1);
                        s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -(race_othercheckpointenemy == ""), race_othercheckpointlapsdelta, race_othercheckpointenemy);
-                       drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                       drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                }
  
                if(race_penaltytime && !race_penaltyaccumulator)
                                        s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
                                else
                                        s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
-                               drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                               drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                        }
                }
        }
@@@ -2601,61 -2614,61 +2615,61 @@@ void HUD_Vote(void
  
        // always force 3:1 aspect
        vector newSize = '0 0 0';
-       if(mySize_x/mySize_y > 3)
+       if(mySize.x/mySize.y > 3)
        {
-               newSize_x = 3 * mySize_y;
-               newSize_y = mySize_y;
+               newSize.x = 3 * mySize.y;
+               newSize.y = mySize.y;
  
-               pos_x = pos_x + (mySize_x - newSize_x) / 2;
+               pos.x = pos.x + (mySize.x - newSize.x) / 2;
        }
        else
        {
-               newSize_y = 1/3 * mySize_x;
-               newSize_x = mySize_x;
+               newSize.y = 1/3 * mySize.x;
+               newSize.x = mySize.x;
  
-               pos_y = pos_y + (mySize_y - newSize_y) / 2;
+               pos.y = pos.y + (mySize.y - newSize.y) / 2;
        }
        mySize = newSize;
  
        s = _("A vote has been called for:");
        if(uid2name_dialog)
                s = _("Allow servers to store and display your name?");
-       drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
-       s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
+       drawstring_aspect(pos, s, eX * mySize.x + eY * (2/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
+       s = textShortenToWidth(vote_called_vote, mySize.x, '1 1 0' * mySize.y * (1/8), stringwidth_colors);
        if(autocvar__hud_configure)
                s = _("^1Configure the HUD");
-       drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
+       drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize.y, s, eX * mySize.x + eY * (1.75/8) * mySize.y, a, DRAWFLAG_NORMAL);
  
        // print the yes/no counts
      s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
-       drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a, DRAWFLAG_NORMAL);
+       drawstring_aspect(pos + eY * (4/8) * mySize.y, s, eX * 0.5 * mySize.x + eY * (1.5/8) * mySize.y, '0 1 0', a, DRAWFLAG_NORMAL);
      s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
-       drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a, DRAWFLAG_NORMAL);
+       drawstring_aspect(pos + eX * 0.5 * mySize.x + eY * (4/8) * mySize.y, s, eX * 0.5 * mySize.x + eY * (1.5/8) * mySize.y, '1 0 0', a, DRAWFLAG_NORMAL);
  
        // draw the progress bar backgrounds
-       drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+       drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_back", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
  
        // draw the highlights
        if(vote_highlighted == 1) {
-               drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
-               drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+               drawsetcliparea(pos.x, pos.y, mySize.x * 0.5, mySize.y);
+               drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
        else if(vote_highlighted == -1) {
-               drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
-               drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+               drawsetcliparea(pos.x + 0.5 * mySize.x, pos.y, mySize.x * 0.5, mySize.y);
+               drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
  
        // draw the progress bars
        if(vote_yescount && vote_needed)
        {
-               drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
-               drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+               drawsetcliparea(pos.x, pos.y, mySize.x * 0.5 * (vote_yescount/vote_needed), mySize.y);
+               drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
  
        if(vote_nocount && vote_needed)
        {
-               drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
-               drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+               drawsetcliparea(pos.x + mySize.x - mySize.x * 0.5 * (vote_nocount/vote_needed), pos.y, mySize.x * 0.5, mySize.y);
+               drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
  
        drawresetcliparea();
  
  float mod_active; // is there any active mod icon?
  
- void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
+ void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, float i)
  {
-       float stat;
-       string pic;
-       vector color;
- #ifdef GMQCC
-       stat = -1;
-       pic = "";
-       color = '0 0 0';
- #endif
+       float stat = -1;
+       string pic = "";
+       vector color = '0 0 0';
        switch(i)
        {
                case 0:
                        break;
        }
  
-       if(mySize_x/mySize_y > aspect_ratio)
+       if(mySize.x/mySize.y > aspect_ratio)
        {
-               i = aspect_ratio * mySize_y;
-               myPos_x = myPos_x + (mySize_x - i) / 2;
-               mySize_x = i;
+               i = aspect_ratio * mySize.y;
+               myPos.x = myPos.x + (mySize.x - i) / 2;
+               mySize.x = i;
        }
        else
        {
-               i = 1/aspect_ratio * mySize_x;
-               myPos_y = myPos_y + (mySize_y - i) / 2;
-               mySize_y = i;
+               i = 1/aspect_ratio * mySize.x;
+               myPos.y = myPos.y + (mySize.y - i) / 2;
+               mySize.y = i;
        }
  
        if(layout)
        {
-               drawpic_aspect_skin(myPos, pic, eX * 0.7 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(myPos + eX * 0.7 * mySize_x, ftos(stat), eX * 0.3 * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(myPos, pic, eX * 0.7 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(myPos + eX * 0.7 * mySize.x, ftos(stat), eX * 0.3 * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
        }
        else
                drawstring_aspect(myPos, ftos(stat), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
@@@ -2728,13 -2736,13 +2737,13 @@@ void HUD_Mod_CA(vector myPos, vector my
  {
        mod_active = 1; // required in each mod function that always shows something
  
-       float layout;
+       int layout;
        if(gametype == MAPINFO_TYPE_CA)
                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;
-       rows = mySize_y/mySize_x;
+       rows = mySize.y/mySize.x;
        aspect_ratio = (layout) ? 2 : 1;
        rows = bound(1, floor((sqrt((4 * aspect_ratio * team_count + rows) * rows) + rows + 0.5) / 2), team_count);
        columns = ceil(team_count/rows);
        int i;
        float row = 0, column = 0;
        vector pos, itemSize;
-       itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
+       itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
        for(i=0; i<team_count; ++i)
        {
-               pos = myPos + eX * column * itemSize_x + eY * row * itemSize_y;
+               pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
  
                DrawCAItem(pos, itemSize, aspect_ratio, layout, i);
  
  }
  
  // CTF HUD modicon section
- float redflag_prevframe, blueflag_prevframe, yellowflag_prevframe, pinkflag_prevframe, neutralflag_prevframe; // status during previous frame
- float redflag_prevstatus, blueflag_prevstatus, yellowflag_prevstatus, pinkflag_prevstatus, neutralflag_prevstatus; // last remembered status
- float redflag_statuschange_time, blueflag_statuschange_time, yellowflag_statuschange_time, pinkflag_statuschange_time, neutralflag_statuschange_time; // time when the status changed
 -float redflag_prevframe, blueflag_prevframe; // status during previous frame
 -float redflag_prevstatus, blueflag_prevstatus; // last remembered status
 -float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
++int redflag_prevframe, blueflag_prevframe, yellowflag_prevframe, pinkflag_prevframe, neutralflag_prevframe; // status during previous frame
++int redflag_prevstatus, blueflag_prevstatus, yellowflag_prevstatus, pinkflag_prevstatus, neutralflag_prevstatus; // last remembered status
++int redflag_statuschange_time, blueflag_statuschange_time, yellowflag_statuschange_time, pinkflag_statuschange_time, neutralflag_statuschange_time; // time when the status changed
  
  void HUD_Mod_CTF_Reset(void)
  {
 -      redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
 +      redflag_prevstatus = blueflag_prevstatus = yellowflag_prevstatus = pinkflag_prevstatus = neutralflag_prevstatus = 0;
 +      redflag_prevframe = blueflag_prevframe = yellowflag_prevframe = pinkflag_prevframe = neutralflag_prevframe = 0;
 +      redflag_statuschange_time = blueflag_statuschange_time = yellowflag_statuschange_time = pinkflag_statuschange_time = neutralflag_statuschange_time = 0;
  }
  
  void HUD_Mod_CTF(vector pos, vector mySize)
  {
 -      vector redflag_pos, blueflag_pos;
 +      vector redflag_pos, blueflag_pos, yellowflag_pos, pinkflag_pos, neutralflag_pos;
        vector flag_size;
        float f; // every function should have that
  
-       float redflag, blueflag, yellowflag, pinkflag, neutralflag; // current status
 -      float redflag, blueflag; // current status
 -      float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
 -      float stat_items;
 -
 -      stat_items = getstati(STAT_ITEMS, 0, 24);
 -      redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
 -      blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
 -
 -      if(redflag || blueflag)
++      int redflag, blueflag, yellowflag, pinkflag, neutralflag; // current status
 +      float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime, yellowflag_statuschange_elapsedtime, pinkflag_statuschange_elapsedtime, neutralflag_statuschange_elapsedtime; // time since the status changed
-       float ctf_oneflag; // one-flag CTF mode enabled/disabled
-       float stat_items = getstati(STAT_CTF_FLAGSTATUS, 0, 24);
++      bool ctf_oneflag; // one-flag CTF mode enabled/disabled
++      int stat_items = getstati(STAT_CTF_FLAGSTATUS, 0, 24);
 +      float fs, fs2, fs3, size1, size2;
 +      vector e1, e2;
 +
 +      redflag = (stat_items/CTF_RED_FLAG_TAKEN) & 3;
 +      blueflag = (stat_items/CTF_BLUE_FLAG_TAKEN) & 3;
 +      yellowflag = (stat_items/CTF_YELLOW_FLAG_TAKEN) & 3;
 +      pinkflag = (stat_items/CTF_PINK_FLAG_TAKEN) & 3;
 +      neutralflag = (stat_items/CTF_NEUTRAL_FLAG_TAKEN) & 3;
 +      
 +      ctf_oneflag = (stat_items & CTF_FLAG_NEUTRAL);
 +
 +      if(redflag || blueflag || yellowflag || pinkflag || neutralflag)
                mod_active = 1;
        else
                mod_active = 0;
        {
                redflag = 1;
                blueflag = 2;
 +              if(team_count >= 3)
 +                      yellowflag = 2;
 +              if(team_count >= 4)
 +                      pinkflag = 3;
 +              ctf_oneflag = neutralflag = 0; // disable neutral flag in hud editor?
        }
  
        // when status CHANGES, set old status into prevstatus and current status into status
                blueflag_prevframe = blueflag;
        }
  
 +      if (yellowflag != yellowflag_prevframe)
 +      {
 +              yellowflag_statuschange_time = time;
 +              yellowflag_prevstatus = yellowflag_prevframe;
 +              yellowflag_prevframe = yellowflag;
 +      }
 +
 +      if (pinkflag != pinkflag_prevframe)
 +      {
 +              pinkflag_statuschange_time = time;
 +              pinkflag_prevstatus = pinkflag_prevframe;
 +              pinkflag_prevframe = pinkflag;
 +      }
 +
 +      if (neutralflag != neutralflag_prevframe)
 +      {
 +              neutralflag_statuschange_time = time;
 +              neutralflag_prevstatus = neutralflag_prevframe;
 +              neutralflag_prevframe = neutralflag;
 +      }
 +
        redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
        blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
 +      yellowflag_statuschange_elapsedtime = time - yellowflag_statuschange_time;
 +      pinkflag_statuschange_elapsedtime = time - pinkflag_statuschange_time;
 +      neutralflag_statuschange_elapsedtime = time - neutralflag_statuschange_time;
  
--      float BLINK_FACTOR = 0.15;
--      float BLINK_BASE = 0.85;
++      const float BLINK_FACTOR = 0.15;
++      const float BLINK_BASE = 0.85;
        // note:
        //   RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
        // thus
        //   BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
        // ensure RMS == 1
--      float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
++      const float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
  
        string red_icon, red_icon_prevstatus;
--      float red_alpha, red_alpha_prevstatus;
++      int red_alpha, red_alpha_prevstatus;
        red_alpha = red_alpha_prevstatus = 1;
--      switch(redflag) {
++      switch(redflag)
++      {
                case 1: red_icon = "flag_red_taken"; break;
                case 2: red_icon = "flag_red_lost"; break;
                case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
                default:
 -                      if((stat_items & IT_CTF_SHIELDED) && (myteam == NUM_TEAM_2))
 +                      if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_1))
                                red_icon = "flag_red_shielded";
                        else
                                red_icon = string_null;
                        break;
        }
--      switch(redflag_prevstatus) {
++      switch(redflag_prevstatus)
++      {
                case 1: red_icon_prevstatus = "flag_red_taken"; break;
                case 2: red_icon_prevstatus = "flag_red_lost"; break;
                case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
                default:
                        if(redflag == 3)
                                red_icon_prevstatus = "flag_red_carrying"; // make it more visible
 -                      else if((stat_items & IT_CTF_SHIELDED) && (myteam == NUM_TEAM_2))
 +                      else if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_1))
                                red_icon_prevstatus = "flag_red_shielded";
                        else
                                red_icon_prevstatus = string_null;
        }
  
        string blue_icon, blue_icon_prevstatus;
--      float blue_alpha, blue_alpha_prevstatus;
++      int blue_alpha, blue_alpha_prevstatus;
        blue_alpha = blue_alpha_prevstatus = 1;
--      switch(blueflag) {
++      switch(blueflag)
++      {
                case 1: blue_icon = "flag_blue_taken"; break;
                case 2: blue_icon = "flag_blue_lost"; break;
                case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
                default:
 -                      if((stat_items & IT_CTF_SHIELDED) && (myteam == NUM_TEAM_1))
 +                      if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_2))
                                blue_icon = "flag_blue_shielded";
                        else
                                blue_icon = string_null;
                        break;
        }
--      switch(blueflag_prevstatus) {
++      switch(blueflag_prevstatus)
++      {
                case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
                case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
                case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
                default:
                        if(blueflag == 3)
                                blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
 -                      else if((stat_items & IT_CTF_SHIELDED) && (myteam == NUM_TEAM_1))
 +                      else if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_2))
                                blue_icon_prevstatus = "flag_blue_shielded";
                        else
                                blue_icon_prevstatus = string_null;
                        break;
        }
  
 -      if(mySize.x > mySize.y) {
 -              if (myteam == NUM_TEAM_1) { // always draw own flag on left
 +      string yellow_icon, yellow_icon_prevstatus;
-       float yellow_alpha, yellow_alpha_prevstatus;
++      int yellow_alpha, yellow_alpha_prevstatus;
 +      yellow_alpha = yellow_alpha_prevstatus = 1;
-       switch(yellowflag) {
++      switch(yellowflag)
++      {
 +              case 1: yellow_icon = "flag_yellow_taken"; break;
 +              case 2: yellow_icon = "flag_yellow_lost"; break;
 +              case 3: yellow_icon = "flag_yellow_carrying"; yellow_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
 +              default:
 +                      if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_3))
 +                              yellow_icon = "flag_yellow_shielded";
 +                      else
 +                              yellow_icon = string_null;
 +                      break;
 +      }
-       switch(yellowflag_prevstatus) {
++      switch(yellowflag_prevstatus)
++      {
 +              case 1: yellow_icon_prevstatus = "flag_yellow_taken"; break;
 +              case 2: yellow_icon_prevstatus = "flag_yellow_lost"; break;
 +              case 3: yellow_icon_prevstatus = "flag_yellow_carrying"; yellow_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
 +              default:
 +                      if(yellowflag == 3)
 +                              yellow_icon_prevstatus = "flag_yellow_carrying"; // make it more visible
 +                      else if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_3))
 +                              yellow_icon_prevstatus = "flag_yellow_shielded";
 +                      else
 +                              yellow_icon_prevstatus = string_null;
 +                      break;
 +      }
 +
 +      string pink_icon, pink_icon_prevstatus;
-       float pink_alpha, pink_alpha_prevstatus;
++      int pink_alpha, pink_alpha_prevstatus;
 +      pink_alpha = pink_alpha_prevstatus = 1;
-       switch(pinkflag) {
++      switch(pinkflag)
++      {
 +              case 1: pink_icon = "flag_pink_taken"; break;
 +              case 2: pink_icon = "flag_pink_lost"; break;
 +              case 3: pink_icon = "flag_pink_carrying"; pink_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
 +              default:
 +                      if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_4))
 +                              pink_icon = "flag_pink_shielded";
 +                      else
 +                              pink_icon = string_null;
 +                      break;
 +      }
-       switch(pinkflag_prevstatus) {
++      switch(pinkflag_prevstatus)
++      {
 +              case 1: pink_icon_prevstatus = "flag_pink_taken"; break;
 +              case 2: pink_icon_prevstatus = "flag_pink_lost"; break;
 +              case 3: pink_icon_prevstatus = "flag_pink_carrying"; pink_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
 +              default:
 +                      if(pinkflag == 3)
 +                              pink_icon_prevstatus = "flag_pink_carrying"; // make it more visible
 +                      else if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_4))
 +                              pink_icon_prevstatus = "flag_pink_shielded";
 +                      else
 +                              pink_icon_prevstatus = string_null;
 +                      break;
 +      }
 +
 +      string neutral_icon, neutral_icon_prevstatus;
-       float neutral_alpha, neutral_alpha_prevstatus;
++      int neutral_alpha, neutral_alpha_prevstatus;
 +      neutral_alpha = neutral_alpha_prevstatus = 1;
-       switch(neutralflag) {
++      switch(neutralflag)
++      {
 +              case 1: neutral_icon = "flag_neutral_taken"; break;
 +              case 2: neutral_icon = "flag_neutral_lost"; break;
 +              case 3: neutral_icon = "flag_neutral_carrying"; neutral_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
 +              default:
 +                      if((stat_items & CTF_SHIELDED))
 +                              neutral_icon = "flag_neutral_shielded";
 +                      else
 +                              neutral_icon = string_null;
 +                      break;
 +      }
-       switch(neutralflag_prevstatus) {
++      switch(neutralflag_prevstatus)
++      {
 +              case 1: neutral_icon_prevstatus = "flag_neutral_taken"; break;
 +              case 2: neutral_icon_prevstatus = "flag_neutral_lost"; break;
 +              case 3: neutral_icon_prevstatus = "flag_neutral_carrying"; neutral_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
 +              default:
 +                      if(neutralflag == 3)
 +                              neutral_icon_prevstatus = "flag_neutral_carrying"; // make it more visible
 +                      else if((stat_items & CTF_SHIELDED))
 +                              neutral_icon_prevstatus = "flag_neutral_shielded";
 +                      else
 +                              neutral_icon_prevstatus = string_null;
 +                      break;
 +      }
 +
 +      if(ctf_oneflag)
 +      {
 +              // hacky, but these aren't needed
 +              red_icon = red_icon_prevstatus = blue_icon = blue_icon_prevstatus = yellow_icon = yellow_icon_prevstatus = pink_icon = pink_icon_prevstatus = string_null;
 +              fs = fs2 = fs3 = 1;
 +      }
 +      else switch(team_count)
 +      {
 +              default:
 +              case 2: fs = 0.5; fs2 = 0.5; fs3 = 0.5; break;
 +              case 3: fs = 1; fs2 = 0.35; fs3 = 0.35; break;
 +              case 4: fs = 0.75; fs2 = 0.25; fs3 = 0.5; break;
 +      }
 +
 +      if(mySize_x > mySize_y)
 +      {
 +              size1 = mySize_x;
 +              size2 = mySize_y;
 +              e1 = eX;
 +              e2 = eY;
 +      }
 +      else
 +      {
 +              size1 = mySize_y;
 +              size2 = mySize_x;
 +              e1 = eY;
 +              e2 = eX;
 +      }
 +
 +      switch(myteam)
 +      {
 +              default:
 +              case NUM_TEAM_1:
 +              {
                        redflag_pos = pos;
 -                      blueflag_pos = pos + eX * 0.5 * mySize.x;
 -              } else {
 -                      blueflag_pos = pos;
 -                      redflag_pos = pos + eX * 0.5 * mySize.x;
 +                      blueflag_pos = pos + eX * fs2 * size1;
 +                      yellowflag_pos = pos - eX * fs2 * size1;
 +                      pinkflag_pos = pos + eX * fs3 * size1;
 +                      break;
                }
 -              flag_size = eX * 0.5 * mySize.x + eY * mySize.y;
 -      } else {
 -              if (myteam == NUM_TEAM_1) { // always draw own flag on left
 -                      redflag_pos = pos;
 -                      blueflag_pos = pos + eY * 0.5 * mySize.y;
 -              } else {
 +              case NUM_TEAM_2:
 +              {
 +                      redflag_pos = pos + eX * fs2 * size1;
                        blueflag_pos = pos;
 -                      redflag_pos = pos + eY * 0.5 * mySize.y;
 +                      yellowflag_pos = pos - eX * fs2 * size1;
 +                      pinkflag_pos = pos + eX * fs3 * size1;
 +                      break;
 +              }
 +              case NUM_TEAM_3:
 +              {
 +                      redflag_pos = pos + eX * fs3 * size1;
 +                      blueflag_pos = pos - eX * fs2 * size1;
 +                      yellowflag_pos = pos;
 +                      pinkflag_pos = pos + eX * fs2 * size1;
 +                      break;
 +              }
 +              case NUM_TEAM_4:
 +              {
 +                      redflag_pos = pos - eX * fs2 * size1;
 +                      blueflag_pos = pos + eX * fs3 * size1;
 +                      yellowflag_pos = pos + eX * fs2 * size1;
 +                      pinkflag_pos = pos;
 +                      break;
                }
 -              flag_size = eY * 0.5 * mySize.y + eX * mySize.x;
        }
 +      neutralflag_pos = pos;
 +      flag_size = e1 * fs * size1 + e2 * size2;
  
        f = bound(0, redflag_statuschange_elapsedtime*2, 1);
        if(red_icon_prevstatus && f < 1)
                drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
        if(blue_icon)
                drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
 +
 +      f = bound(0, yellowflag_statuschange_elapsedtime*2, 1);
 +      if(yellow_icon_prevstatus && f < 1)
 +              drawpic_aspect_skin_expanding(yellowflag_pos, yellow_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * yellow_alpha_prevstatus, DRAWFLAG_NORMAL, f);
 +      if(yellow_icon)
 +              drawpic_aspect_skin(yellowflag_pos, yellow_icon, flag_size, '1 1 1', panel_fg_alpha * yellow_alpha * f, DRAWFLAG_NORMAL);
 +
 +      f = bound(0, pinkflag_statuschange_elapsedtime*2, 1);
 +      if(pink_icon_prevstatus && f < 1)
 +              drawpic_aspect_skin_expanding(pinkflag_pos, pink_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * pink_alpha_prevstatus, DRAWFLAG_NORMAL, f);
 +      if(pink_icon)
 +              drawpic_aspect_skin(pinkflag_pos, pink_icon, flag_size, '1 1 1', panel_fg_alpha * pink_alpha * f, DRAWFLAG_NORMAL);
 +
 +      f = bound(0, neutralflag_statuschange_elapsedtime*2, 1);
 +      if(neutral_icon_prevstatus && f < 1)
 +              drawpic_aspect_skin_expanding(neutralflag_pos, neutral_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * neutral_alpha_prevstatus, DRAWFLAG_NORMAL, f);
 +      if(neutral_icon)
 +              drawpic_aspect_skin(neutralflag_pos, neutral_icon, flag_size, '1 1 1', panel_fg_alpha * neutral_alpha * f, DRAWFLAG_NORMAL);
  }
  
  // Keyhunt HUD modicon section
- float kh_runheretime;
- void HUD_Mod_KH_Reset(void)
- {
-       kh_runheretime = 0;
- }
+ vector KH_SLOTS[4];
  
  void HUD_Mod_KH(vector pos, vector mySize)
  {
        mod_active = 1; // keyhunt should never hide the mod icons panel
-       float kh_keys;
-       float keyteam;
-       float a, aa;
-       vector p = '0 0 0', pa, kh_size = '0 0 0', kh_asize = '0 0 0';
  
-       kh_keys = getstati(STAT_KH_KEYS);
+       // Read current state
  
-       p_x = pos_x;
-       if(mySize_x > mySize_y)
-       {
-               p_y = pos_y + 0.25 * mySize_y;
-               pa = p - eY * 0.25 * mySize_y;
+       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;
+       all_keys = team1_keys = team2_keys = team3_keys = team4_keys = dropped_keys = carrying_keys = 0;
  
-               kh_size_x = mySize_x * 0.25;
-               kh_size_y = 0.75 * mySize_y;
-               kh_asize_x = mySize_x * 0.25;
-               kh_asize_y = mySize_y * 0.25;
-       }
-       else
+       for(i = 0; i < 4; ++i)
        {
-               p_y = pos_y + 0.125 * mySize_y;
-               pa = p - eY * 0.125 * mySize_y;
+               key_state = (bitshift(state, i * -5) & 31) - 1;
  
-               kh_size_x = mySize_x * 0.5;
-               kh_size_y = 0.375 * mySize_y;
-               kh_asize_x = mySize_x * 0.5;
-               kh_asize_y = mySize_y * 0.125;
-       }
+               if(key_state == -1)
+                       continue;
  
-       float i, key;
+               if(key_state == 30)
+               {
+                       ++carrying_keys;
+                       key_state = myteam;
+               }
  
-       float keycount;
-       keycount = 0;
-       for(i = 0; i < 4; ++i)
-       {
-               key = floor(kh_keys / pow(32, i)) & 31;
-               keyteam = key - 1;
-               if(keyteam == 30 && keycount <= 4)
-                       keycount += 4;
-               if(keyteam == myteam || keyteam == -1 || keyteam == 30)
-                       keycount += 1;
+               switch(key_state)
+               {
+                       case NUM_TEAM_1: ++team1_keys; break;
+                       case NUM_TEAM_2: ++team2_keys; break;
+                       case NUM_TEAM_3: ++team3_keys; break;
+                       case NUM_TEAM_4: ++team4_keys; break;
+                       case 29: ++dropped_keys; break;
+               }
+               ++all_keys;
        }
  
-       // this yields 8 exactly if "RUN HERE" shows
+       // Calculate slot measurements
  
-       if(keycount == 8)
+       vector slot_size;
+       if(all_keys == 4 && mySize.x * 0.5 < mySize.y && mySize.y * 0.5 < mySize.x)
        {
-               if(!kh_runheretime)
-                       kh_runheretime = time;
-               pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
+               // Quadratic arrangement
+               slot_size = eX * mySize.x * 0.5 + eY * mySize.y * 0.5;
+               KH_SLOTS[0] = pos;
+               KH_SLOTS[1] = pos + eX * slot_size.x;
+               KH_SLOTS[2] = pos + eY * slot_size.y;
+               KH_SLOTS[3] = pos + eX * slot_size.x + eY * slot_size.y;
        }
        else
-               kh_runheretime = 0;
-       for(i = 0; i < 4; ++i)
        {
-               key = floor(kh_keys / pow(32, i)) & 31;
-               keyteam = key - 1;
-               switch(keyteam)
+               if(mySize.x > mySize.y)
                {
-                       case 30: // my key
-                               keyteam = myteam;
-                               a = 1;
-                               aa = 1;
-                               break;
-                       case -1: // no key
-                               a = 0;
-                               aa = 0;
-                               break;
-                       default: // owned or dropped
-                               a = 0.2;
-                               aa = 0.5;
-                               break;
+                       // Horizontal arrangement
+                       slot_size = eX * mySize.x / all_keys + eY * mySize.y;
+                       for(i = 0; i < all_keys; ++i)
+                               KH_SLOTS[i] = pos + eX * slot_size.x * i;
                }
-               a = a * panel_fg_alpha;
-               aa = aa * panel_fg_alpha;
-               if(a > 0)
+               else
                {
-                       switch(keyteam)
-                       {
-                               case NUM_TEAM_1:
-                                       drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case NUM_TEAM_2:
-                                       drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case NUM_TEAM_3:
-                                       drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case NUM_TEAM_4:
-                                       drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               default:
-                                       break;
-                       }
-                       switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
-                       {
-                               case 0:
-                                       drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case 1:
-                                       drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case 2:
-                                       drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case 3:
-                                       drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                       }
+                       // Vertical arrangement
+                       slot_size = eX * mySize.x + eY * mySize.y / all_keys;
+                       for(i = 0; i < all_keys; ++i)
+                               KH_SLOTS[i] = pos + eY * slot_size.y * i;
                }
-               if(mySize_x > mySize_y)
+       }
+       // Make icons blink in case of RUN HERE
+       float blink = 0.6 + sin(2*M_PI*time) / 2.5; // Oscillate between 0.2 and 1
+       float alpha;
+       alpha = 1;
+       if(carrying_keys)
+               switch(myteam)
                {
-                       p_x += 0.25 * mySize_x;
-                       pa_x += 0.25 * mySize_x;
+                       case NUM_TEAM_1: if(team1_keys == all_keys) alpha = blink; break;
+                       case NUM_TEAM_2: if(team2_keys == all_keys) alpha = blink; break;
+                       case NUM_TEAM_3: if(team3_keys == all_keys) alpha = blink; break;
+                       case NUM_TEAM_4: if(team4_keys == all_keys) alpha = blink; break;
+               }
+       // Draw icons
+       i = 0;
+       while(team1_keys--)
+               if(myteam == NUM_TEAM_1 && carrying_keys)
+               {
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+                       --carrying_keys;
                }
                else
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+       while(team2_keys--)
+               if(myteam == NUM_TEAM_2 && carrying_keys)
                {
-                       if(i == 1)
-                       {
-                               p_y = pos_y + 0.625 * mySize_y;
-                               pa_y = pos_y + 0.5 * mySize_y;
-                               p_x = pos_x;
-                               pa_x = pos_x;
-                       }
-                       else
-                       {
-                               p_x += 0.5 * mySize_x;
-                               pa_x += 0.5 * mySize_x;
-                       }
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+                       --carrying_keys;
                }
-       }
+               else
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+       while(team3_keys--)
+               if(myteam == NUM_TEAM_3 && carrying_keys)
+               {
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+                       --carrying_keys;
+               }
+               else
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+       while(team4_keys--)
+               if(myteam == NUM_TEAM_4 && carrying_keys)
+               {
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+                       --carrying_keys;
+               }
+               else
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+       while(dropped_keys--)
+               drawpic_aspect_skin(KH_SLOTS[i++], "kh_dropped", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
  }
  
  // Keepaway HUD mod icon
@@@ -3269,12 -3073,12 +3272,12 @@@ void HUD_Mod_Keepaway(vector pos, vecto
  
        vector kaball_pos, kaball_size;
  
-       if(mySize_x > mySize_y) {
-               kaball_pos = pos + eX * 0.25 * mySize_x;
-               kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
+       if(mySize.x > mySize.y) {
+               kaball_pos = pos + eX * 0.25 * mySize.x;
+               kaball_size = eX * 0.5 * mySize.x + eY * mySize.y;
        } else {
-               kaball_pos = pos + eY * 0.25 * mySize_y;
-               kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
+               kaball_pos = pos + eY * 0.25 * mySize.y;
+               kaball_size = eY * 0.5 * mySize.y + eX * mySize.x;
        }
  
        float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
                drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
  
        if(kaball)
-               drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
  }
  
  
@@@ -3310,11 -3114,11 +3313,11 @@@ void HUD_Mod_NexBall(vector pos, vecto
                if (p > 1)
                        p = 2 - p;
  
-               HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, (mySize_x <= mySize_y), 0, autocvar_hud_progressbar_nexball_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+               HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, (mySize.x <= mySize.y), 0, autocvar_hud_progressbar_nexball_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
  
        if (stat_items & IT_KEY1)
-               drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
  }
  
  // Race/CTS HUD mod icons
@@@ -3363,16 -3167,16 +3366,16 @@@ void HUD_Mod_Race(vector pos, vector my
  
        vector textPos, medalPos;
        float squareSize;
-       if(mySize_x > mySize_y) {
+       if(mySize.x > mySize.y) {
                // text on left side
-               squareSize = min(mySize_y, mySize_x/2);
-               textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
-               medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
+               squareSize = min(mySize.y, mySize.x/2);
+               textPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eY * 0.5 * (mySize.y - squareSize);
+               medalPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eX * 0.5 * mySize.x + eY * 0.5 * (mySize.y - squareSize);
        } else {
                // text on top
-               squareSize = min(mySize_x, mySize_y/2);
-               textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
-               medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
+               squareSize = min(mySize.x, mySize.y/2);
+               textPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eX * 0.5 * (mySize.x - squareSize);
+               medalPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eY * 0.5 * mySize.y + eX * 0.5 * (mySize.x - squareSize);
        }
  
        f = time - crecordtime_change_time;
        }
  }
  
- void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
+ void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, float i)
  {
-       float stat, pps_ratio;
-       string pic;
-       vector color;
- #ifdef GMQCC
-       stat = -1;
-       pic = "";
-       color = '0 0 0';
- #endif
+       float stat = -1;
+       string pic = "";
+       vector color = '0 0 0';
        switch(i)
        {
                case 0:
                        color = '1 0 1';
                        break;
        }
-       pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
+       float pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
  
-       if(mySize_x/mySize_y > aspect_ratio)
+       if(mySize.x/mySize.y > aspect_ratio)
        {
-               i = aspect_ratio * mySize_y;
-               myPos_x = myPos_x + (mySize_x - i) / 2;
-               mySize_x = i;
+               i = aspect_ratio * mySize.y;
+               myPos.x = myPos.x + (mySize.x - i) / 2;
+               mySize.x = i;
        }
        else
        {
-               i = 1/aspect_ratio * mySize_x;
-               myPos_y = myPos_y + (mySize_y - i) / 2;
-               mySize_y = i;
+               i = 1/aspect_ratio * mySize.x;
+               myPos.y = myPos.y + (mySize.y - i) / 2;
+               mySize.y = i;
        }
  
        if (layout) // show text too
                //draw the text
                color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
                if (layout == 2) // average pps
-                       drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(myPos + eX * mySize.y, ftos_decimals(stat, 2), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
                else // percentage of average pps
-                       drawstring_aspect(myPos + eX * mySize_y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(myPos + eX * mySize.y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
        }
  
        //draw the icon
-       drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
        if (stat > 0)
        {
-               drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
-               drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawsetcliparea(myPos.x, myPos.y + mySize.y * (1 - pps_ratio), mySize.y, mySize.y * pps_ratio);
+               drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                drawresetcliparea();
        }
  }
@@@ -3537,9 -3336,9 +3535,9 @@@ void HUD_Mod_Dom(vector myPos, vector m
  {
        mod_active = 1; // required in each mod function that always shows something
  
-       float layout = autocvar_hud_panel_modicons_dom_layout;
+       int layout = autocvar_hud_panel_modicons_dom_layout;
        float rows, columns, aspect_ratio;
-       rows = mySize_y/mySize_x;
+       rows = mySize.y/mySize.x;
        aspect_ratio = (layout) ? 3 : 1;
        rows = bound(1, floor((sqrt((4 * aspect_ratio * team_count + rows) * rows) + rows + 0.5) / 2), team_count);
        columns = ceil(team_count/rows);
        int i;
        float row = 0, column = 0;
        vector pos, itemSize;
-       itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
+       itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
        for(i=0; i<team_count; ++i)
        {
-               pos = myPos + eX * column * itemSize_x + eY * row * itemSize_y;
+               pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
  
                DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
  
@@@ -3649,42 -3448,42 +3647,42 @@@ void HUD_PressedKeys(void
        if(aspect)
        {
                vector newSize = '0 0 0';
-               if(mySize_x/mySize_y > aspect)
+               if(mySize.x/mySize.y > aspect)
                {
-                       newSize_x = aspect * mySize_y;
-                       newSize_y = mySize_y;
+                       newSize.x = aspect * mySize.y;
+                       newSize.y = mySize.y;
  
-                       pos_x = pos_x + (mySize_x - newSize_x) / 2;
+                       pos.x = pos.x + (mySize.x - newSize.x) / 2;
                }
                else
                {
-                       newSize_y = 1/aspect * mySize_x;
-                       newSize_x = mySize_x;
+                       newSize.y = 1/aspect * mySize.x;
+                       newSize.x = mySize.x;
  
-                       pos_y = pos_y + (mySize_y - newSize_y) / 2;
+                       pos.y = pos.y + (mySize.y - newSize.y) / 2;
                }
                mySize = newSize;
        }
  
        vector keysize;
-       keysize = eX * mySize_x * (1/3.0) + eY * mySize_y * (1/(3.0 - !autocvar_hud_panel_pressedkeys_attack));
+       keysize = eX * mySize.x * (1/3.0) + eY * mySize.y * (1/(3.0 - !autocvar_hud_panel_pressedkeys_attack));
        float pressedkeys;
        pressedkeys = getstatf(STAT_PRESSED_KEYS);
  
        if(autocvar_hud_panel_pressedkeys_attack)
        {
-               drawpic_aspect_skin(pos + eX * keysize_x * 0.5, ((pressedkeys & KEY_ATCK) ? "key_atck_inv.tga" : "key_atck.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawpic_aspect_skin(pos + eX * keysize_x * 1.5, ((pressedkeys & KEY_ATCK2) ? "key_atck_inv.tga" : "key_atck.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               pos_y += keysize_y;
+               drawpic_aspect_skin(pos + eX * keysize.x * 0.5, ((pressedkeys & KEY_ATCK) ? "key_atck_inv.tga" : "key_atck.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(pos + eX * keysize.x * 1.5, ((pressedkeys & KEY_ATCK2) ? "key_atck_inv.tga" : "key_atck.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               pos.y += keysize.y;
        }
  
        drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       drawpic_aspect_skin(pos + eX * keysize_x, ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       drawpic_aspect_skin(pos + eX * keysize_x * 2, ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       pos_y += keysize_y;
+       drawpic_aspect_skin(pos + eX * keysize.x, ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawpic_aspect_skin(pos + eX * keysize.x * 2, ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       pos.y += keysize.y;
        drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       drawpic_aspect_skin(pos + eX * keysize_x, ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       drawpic_aspect_skin(pos + eX * keysize_x * 2, ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawpic_aspect_skin(pos + eX * keysize.x, ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawpic_aspect_skin(pos + eX * keysize.x * 2, ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
  }
  
  // Handle chat as a panel (#12)
@@@ -3714,8 -3513,8 +3712,8 @@@ void HUD_Chat(void
  
        if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
        {
-               panel_pos_y = panel_bg_border;
-               panel_size_y = vid_conheight - panel_bg_border * 2;
+               panel_pos.y = panel_bg_border;
+               panel_size.y = vid_conheight - panel_bg_border * 2;
                if(panel.current_panel_bg == "0") // force a border when maximized
                {
                        string panel_bg;
        if (!autocvar_con_chatrect)
                cvar_set("con_chatrect", "1");
  
-       cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
-       cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
+       cvar_set("con_chatrect_x", ftos(pos.x/vid_conwidth));
+       cvar_set("con_chatrect_y", ftos(pos.y/vid_conheight));
  
-       cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
-       cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
+       cvar_set("con_chatwidth", ftos(mySize.x/vid_conwidth));
+       cvar_set("con_chat", ftos(floor(mySize.y/autocvar_con_chatsize - 0.5)));
  
        if(autocvar__hud_configure)
        {
                                a = panel_fg_alpha;
                        else
                                a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
-                       drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
-                       pos_y += chatsize_y;
+                       drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize.x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
+                       pos.y += chatsize.y;
                }
        }
  }
@@@ -3833,11 -3632,12 +3831,12 @@@ void HUD_EngineInfo(void
  
  // Info messages panel (#14)
  //
- #define drawInfoMessage(s)\
-       if(autocvar_hud_panel_infomessages_flip)\
-               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
-       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
-       o_y += fontsize_y;
+ #define drawInfoMessage(s) do {                                                                                                                                                                               \
+       if(autocvar_hud_panel_infomessages_flip)                                                                                                                                                \
+               o.x = pos.x + mySize.x - stringwidth(s, true, fontsize);                                                                                                        \
+       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);                                                                                                               \
+       o.y += fontsize.y;                                                                                                                                                                                              \
+ } while(0)
  void HUD_InfoMessages(void)
  {
        if(!autocvar__hud_configure)
  
        // always force 5:1 aspect
        vector newSize = '0 0 0';
-       if(mySize_x/mySize_y > 5)
+       if(mySize.x/mySize.y > 5)
        {
-               newSize_x = 5 * mySize_y;
-               newSize_y = mySize_y;
+               newSize.x = 5 * mySize.y;
+               newSize.y = mySize.y;
  
-               pos_x = pos_x + (mySize_x - newSize_x) / 2;
+               pos.x = pos.x + (mySize.x - newSize.x) / 2;
        }
        else
        {
-               newSize_y = 1/5 * mySize_x;
-               newSize_x = mySize_x;
+               newSize.y = 1/5 * mySize.x;
+               newSize.x = mySize.x;
  
-               pos_y = pos_y + (mySize_y - newSize_y) / 2;
+               pos.y = pos.y + (mySize.y - newSize.y) / 2;
        }
  
        mySize = newSize;
        o = pos;
  
        vector fontsize;
-       fontsize = '0.20 0.20 0' * mySize_y;
+       fontsize = '0.20 0.20 0' * mySize.y;
  
        float a;
        a = panel_fg_alpha;
                                s = _("^1Observing");
                        else
                                s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(player_localentnum - 1));
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
  
                        if(spectatee_status == -1)
                                s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
                        else
                                s = sprintf(_("^1Press ^3%s^1 or ^3%s^1 for next or previous player"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
  
                        if(spectatee_status == -1)
                                s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
                        else
                                s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
  
                        s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
  
                        if(gametype == MAPINFO_TYPE_LMS)
                        {
                        }
                        else
                                s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
  
                        //show restart countdown:
                        if (time < getstatf(STAT_GAMESTARTTIME)) {
                                countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
                                s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
                                drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                               o_y += fontsize_y;
+                               o.y += fontsize.y;
                        }
                }
                if(warmup_stage && !intermission)
                {
                        s = _("^2Currently in ^1warmup^2 stage!");
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
                }
  
                string blinkcolor;
                                else
                                        s = _("^2Waiting for others to ready up...");
                        }
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
                }
                else if(warmup_stage && !intermission && !spectatee_status)
                {
                        s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
                }
  
                if(teamplay && !intermission && !spectatee_status && gametype != MAPINFO_TYPE_CA && teamnagger)
                        tm = teams.sort_next;
                        if (tm)
                        {
-                               for(; tm.sort_next; tm = tm.sort_next)
+                               for (; tm.sort_next; tm = tm.sort_next)
                                {
                                        if(!tm.team_size || tm.team == NUM_SPECTATOR)
                                                continue;
                                        if (tm.team != NUM_SPECTATOR)
                                        if (tm.team_size == ts_max)
                                                s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
-                                       drawInfoMessage(s)
+                                       drawInfoMessage(s);
                                }
                        }
                }
        else
        {
                s = _("^7Press ^3ESC ^7to show HUD options.");
-               drawInfoMessage(s)
+               drawInfoMessage(s);
                s = _("^3Doubleclick ^7a panel for panel-specific options.");
-               drawInfoMessage(s)
+               drawInfoMessage(s);
                s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
-               drawInfoMessage(s)
+               drawInfoMessage(s);
                s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
-               drawInfoMessage(s)
+               drawInfoMessage(s);
        }
  }
  
@@@ -4085,7 -3885,7 +4084,7 @@@ void HUD_Physics(void
        else if(autocvar_hud_panel_physics_speed_vertical)
                speed = floor( vlen(vel) * conversion_factor + 0.5 );
        else
-               speed = floor( vlen(vel - vel_z * '0 0 1') * conversion_factor + 0.5 );
+               speed = floor( vlen(vel - vel.z * '0 0 1') * conversion_factor + 0.5 );
  
        //compute acceleration
        float acceleration, f;
                if(autocvar_hud_panel_physics_acceleration_vertical)
                        acceleration = (vlen(vel) - vlen(acc_prevspeed));
                else
-                       acceleration = (vlen(vel - '0 0 1' * vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z));
+                       acceleration = (vlen(vel - '0 0 1' * vel.z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed.z));
  
                acceleration = acceleration * (1 / max(0.0001, f)) * (0.0254 / 9.80665);
  
        }
  
        //compute layout
-       float panel_ar = panel_size_x/panel_size_y;
+       float panel_ar = panel_size.x/panel_size.y;
        vector speed_offset = '0 0 0', acceleration_offset = '0 0 0';
        if (panel_ar >= 5 && !acceleration_progressbar_scale)
        {
-               panel_size_x *= 0.5;
+               panel_size.x *= 0.5;
                if (autocvar_hud_panel_physics_flip)
-                       speed_offset_x = panel_size_x;
+                       speed_offset.x = panel_size.x;
                else
-                       acceleration_offset_x = panel_size_x;
+                       acceleration_offset.x = panel_size.x;
        }
        else
        {
-               panel_size_y *= 0.5;
+               panel_size.y *= 0.5;
                if (autocvar_hud_panel_physics_flip)
-                       speed_offset_y = panel_size_y;
+                       speed_offset.y = panel_size.y;
                else
-                       acceleration_offset_y = panel_size_y;
+                       acceleration_offset.y = panel_size.y;
        }
        float speed_baralign, acceleration_baralign;
        if (autocvar_hud_panel_physics_baralign == 1)
        vector tmp_offset = '0 0 0', tmp_size = '0 0 0';
        if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
        {
-               tmp_size_x = panel_size_x * 0.75;
-               tmp_size_y = panel_size_y * text_scale;
+               tmp_size.x = panel_size.x * 0.75;
+               tmp_size.y = panel_size.y * text_scale;
                if (speed_baralign)
-                       tmp_offset_x = panel_size_x - tmp_size_x;
+                       tmp_offset.x = panel_size.x - tmp_size.x;
                //else
                        //tmp_offset_x = 0;
-               tmp_offset_y = (panel_size_y - tmp_size_y) / 2;
+               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);
  
                //draw speed unit
                if (speed_baralign)
-                       tmp_offset_x = 0;
+                       tmp_offset.x = 0;
                else
-                       tmp_offset_x = tmp_size_x;
+                       tmp_offset.x = tmp_size.x;
                if (autocvar_hud_panel_physics_speed_unit_show)
                {
                        //tmp_offset_y = 0;
-                       tmp_size_x = panel_size_x * (1 - 0.75);
-                       tmp_size_y = panel_size_y * 0.4 * text_scale;
-                       tmp_offset_y = (panel_size_y * 0.4 - tmp_size_y) / 2;
+                       tmp_size.x = panel_size.x * (1 - 0.75);
+                       tmp_size.y = panel_size.y * 0.4 * text_scale;
+                       tmp_offset.y = (panel_size.y * 0.4 - tmp_size.y) / 2;
                        drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                }
        }
                        if(speed < top_speed)
                        if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
                        {
-                               float peak_offset_x;
+                               float peak_offsetX;
                                vector peak_size = '0 0 0';
                                if (speed_baralign == 0)
-                                       peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
+                                       peak_offsetX = min(top_speed, max_speed)/max_speed * panel_size.x;
                  else if (speed_baralign == 1)
-                                       peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
+                                       peak_offsetX = (1 - min(top_speed, max_speed)/max_speed) * panel_size.x;
                  else // if (speed_baralign == 2)
-                     peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
-                               peak_size_x = floor(panel_size_x * 0.01 + 1.5);
-                 peak_size_y = panel_size_y;
+                     peak_offsetX = min(top_speed, max_speed)/max_speed * panel_size.x * 0.5;
+                               peak_size.x = floor(panel_size.x * 0.01 + 1.5);
+                 peak_size.y = panel_size.y;
                  if (speed_baralign == 2) // draw two peaks, on both sides
                  {
-                     drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x + peak_offset_x - peak_size_x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-                     drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x - peak_offset_x + peak_size_x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                     drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size.x + peak_offsetX - peak_size.x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                     drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size.x - peak_offsetX + peak_size.x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                  }
                  else
-                     drawfill(panel_pos + speed_offset + eX * (peak_offset_x - peak_size_x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                     drawfill(panel_pos + speed_offset + eX * (peak_offsetX - peak_size.x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
  
                        //top speed
-                       tmp_offset_y = panel_size_y * 0.4;
-                       tmp_size_x = panel_size_x * (1 - 0.75);
-                       tmp_size_y = (panel_size_y - tmp_offset_y) * text_scale;
-                       tmp_offset_y += (panel_size_y - tmp_offset_y - tmp_size_y) / 2;
+                       tmp_offset.y = panel_size.y * 0.4;
+                       tmp_size.x = panel_size.x * (1 - 0.75);
+                       tmp_size.y = (panel_size.y - tmp_offset.y) * text_scale;
+                       tmp_offset.y += (panel_size.y - tmp_offset.y - tmp_size.y) / 2;
                        drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
                }
                else
  
                if (acceleration_progressbar_scale) // allow progressbar to go out of panel bounds
                {
-                       tmp_size = acceleration_progressbar_scale * panel_size_x * eX + panel_size_y * eY;
+                       tmp_size = acceleration_progressbar_scale * panel_size.x * eX + panel_size.y * eY;
  
                        if (acceleration_baralign == 1)
-                               tmp_offset_x = panel_size_x - tmp_size_x;
+                               tmp_offset.x = panel_size.x - tmp_size.x;
                        else if (acceleration_baralign == 2 || acceleration_baralign == 3)
-                               tmp_offset_x = (panel_size_x - tmp_size_x) / 2;
+                               tmp_offset.x = (panel_size.x - tmp_size.x) / 2;
                        else
-                               tmp_offset_x = 0;
-                       tmp_offset_y = 0;
+                               tmp_offset.x = 0;
+                       tmp_offset.y = 0;
                }
                else
                {
  
                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;
+       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);
  
  
  // CenterPrint (#16)
  //
- #define CENTERPRINT_MAX_MSGS 10
- #define CENTERPRINT_MAX_ENTRIES 50
- #define CENTERPRINT_SPACING 0.7
+ const float CENTERPRINT_MAX_MSGS = 10;
+ const float CENTERPRINT_MAX_ENTRIES = 50;
+ const float CENTERPRINT_SPACING = 0.7;
  float cpm_index;
  string centerprint_messages[CENTERPRINT_MAX_MSGS];
  float centerprint_msgID[CENTERPRINT_MAX_MSGS];
@@@ -4324,7 -4124,7 +4323,7 @@@ void centerprint_generic(float new_id, 
                return;
  
        if (!centerprint_showing)
-               centerprint_showing = TRUE;
+               centerprint_showing = true;
  
        for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
        {
@@@ -4435,12 -4235,12 +4434,12 @@@ void HUD_CenterPrint (void
                        return;
                vector target_pos;
  
-               target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size_x);
+               target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size.x);
  
-               if(target_pos_y > panel_pos_y)
+               if(target_pos.y > panel_pos.y)
                {
                        panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha);
-                       panel_size_y = min(panel_size_y, vid_conheight - scoreboard_bottom);
+                       panel_size.y = min(panel_size.y, vid_conheight - scoreboard_bottom);
                }
        }
  
        // fontsize = '1 1 0' * height;
        height = vid_conheight/50 * autocvar_hud_panel_centerprint_fontscale;
        fontsize = '1 1 0' * height;
-       entries = bound(1, floor(panel_size_y/height), CENTERPRINT_MAX_ENTRIES);
+       entries = bound(1, floor(panel_size.y/height), CENTERPRINT_MAX_ENTRIES);
  
        float i, j, k, n, g;
-       float a, sz, align, current_msg_pos_y = 0, msg_size;
+       float a, sz, align, current_msg_posY = 0, msg_size;
        vector pos;
        string ts;
-       float all_messages_expired = TRUE;
+       float all_messages_expired = true;
  
        pos = panel_pos;
        if (autocvar_hud_panel_centerprint_flip)
-               pos_y += panel_size_y;
+               pos.y += panel_size.y;
        align = bound(0, autocvar_hud_panel_centerprint_align, 1);
        for (g=0, i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
        {
                                continue;
                }
  
-               all_messages_expired = FALSE;
+               all_messages_expired = false;
  
                // fade the centerprint_hud in/out
                if(centerprint_time[j] < 0)  // Expired but forced. Expire time is the fade-in time.
                                getWrappedLine_remaining = argv(k);
                                while(getWrappedLine_remaining)
                                {
-                                       ts = getWrappedLine(panel_size_x * sz, fontsize, stringwidth_colors);
+                                       ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
                                        if (ts != "")
-                                               pos_y -= fontsize_y;
+                                               pos.y -= fontsize.y;
                                        else
-                                               pos_y -= fontsize_y * CENTERPRINT_SPACING/2;
+                                               pos.y -= fontsize.y * CENTERPRINT_SPACING/2;
                                }
                        }
-                       current_msg_pos_y = pos_y; // save starting pos (first line) of the current message
+                       current_msg_posY = pos.y; // save starting pos (first line) of the current message
                }
  
-               msg_size = pos_y;
+               msg_size = pos.y;
                for(k = 0; k < n; ++k)
                {
                        getWrappedLine_remaining = argv(k);
                        while(getWrappedLine_remaining)
                        {
-                               ts = getWrappedLine(panel_size_x * sz, fontsize, stringwidth_colors);
+                               ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
                                if (ts != "")
                                {
                                        if (align)
-                                               pos_x = panel_pos_x + (panel_size_x - stringwidth(ts, TRUE, fontsize)) * align;
+                                               pos.x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize)) * align;
                                        if (a > 0.5/255.0)  // Otherwise guaranteed invisible - don't show. This is checked a second time after some multiplications with other factors were done so temporary changes of these cannot cause flicker.
-                                               drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize_y, ts, fontsize, a, DRAWFLAG_NORMAL);
-                                       pos_y += fontsize_y;
+                                               drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize.y, ts, fontsize, a, DRAWFLAG_NORMAL);
+                                       pos.y += fontsize.y;
                                }
                                else
-                                       pos_y += fontsize_y * CENTERPRINT_SPACING/2;
+                                       pos.y += fontsize.y * CENTERPRINT_SPACING/2;
                        }
                }
  
                ++g; // move next position number up
  
-               msg_size = pos_y - msg_size;
+               msg_size = pos.y - msg_size;
                if (autocvar_hud_panel_centerprint_flip)
                {
-                       pos_y = current_msg_pos_y - CENTERPRINT_SPACING * fontsize_y;
+                       pos.y = current_msg_posY - CENTERPRINT_SPACING * fontsize.y;
                        if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
-                               pos_y += (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz));
+                               pos.y += (msg_size + CENTERPRINT_SPACING * fontsize.y) * (1 - sqrt(sz));
  
-                       if (pos_y < panel_pos_y) // check if the next message can be shown
+                       if (pos.y < panel_pos.y) // check if the next message can be shown
                        {
                                drawfontscale = '1 1 0';
                                return;
                }
                else
                {
-                       pos_y += CENTERPRINT_SPACING * fontsize_y;
+                       pos.y += CENTERPRINT_SPACING * fontsize.y;
                        if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
-                               pos_y -= (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz));
+                               pos.y -= (msg_size + CENTERPRINT_SPACING * fontsize.y) * (1 - sqrt(sz));
  
-                       if(pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next message can be shown
+                       if(pos.y > panel_pos.y + panel_size.y - fontsize.y) // check if the next message can be shown
                        {
                                drawfontscale = '1 1 0';
                                return;
        drawfontscale = '1 1 0';
        if (all_messages_expired)
        {
-               centerprint_showing = FALSE;
+               centerprint_showing = false;
                reset_centerprint_messages();
        }
  }
@@@ -4617,7 -4417,7 +4616,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
        entity e;
        string s = "";
        //float is_vertical = (panel_ar < 1);
        //float buff_iconalign = autocvar_hud_panel_buffs_iconalign;
        vector buff_offset = '0 0 0';
-       
        for(e = Buff_Type_first; e; e = e.enemy) if(buffs & e.items)
        {
                //DrawNumIcon(pos + buff_offset, mySize, shield, "shield", is_vertical, buff_iconalign, '1 1 1', 1);
@@@ -4670,15 -4470,13 +4669,13 @@@ Main HUD syste
  void HUD_Reset (void)
  {
        // reset gametype specific icons
-       if(gametype == MAPINFO_TYPE_KEYHUNT)
-               HUD_Mod_KH_Reset();
-       else if(gametype == MAPINFO_TYPE_CTF)
+       if(gametype == MAPINFO_TYPE_CTF)
                HUD_Mod_CTF_Reset();
  }
  
  void HUD_Main (void)
  {
-       float i;
+       int i;
        // global hud theAlpha fade
        if(menu_enabled == 1)
                hud_fade_alpha = 1;
index 027f8cf893001123427199bd320d725b8a00406a,788dd871eed84f74e2050375211ef9eca122ee20..1cef3616482f7f93db5010f75d2871cb52115a35
@@@ -1,51 -1,4 +1,4 @@@
- float waypointsprite_initialized;
- float waypointsprite_fadedistance;
- float waypointsprite_normdistance;
- float waypointsprite_minscale;
- float waypointsprite_minalpha;
- float waypointsprite_distancealphaexponent;
- float waypointsprite_timealphaexponent;
- float waypointsprite_scale;
- float waypointsprite_fontsize;
- float waypointsprite_edgefadealpha;
- float waypointsprite_edgefadescale;
- float waypointsprite_edgefadedistance;
- float waypointsprite_edgeoffset_bottom;
- float waypointsprite_edgeoffset_left;
- float waypointsprite_edgeoffset_right;
- float waypointsprite_edgeoffset_top;
- float waypointsprite_crosshairfadealpha;
- float waypointsprite_crosshairfadescale;
- float waypointsprite_crosshairfadedistance;
- float waypointsprite_distancefadealpha;
- float waypointsprite_distancefadescale;
- float waypointsprite_distancefadedistance;
- float waypointsprite_alpha;
- .float helpme;
- .float rule;
- .string netname; // primary picture
- .string netname2; // secondary picture
- .string netname3; // tertiary picture
- .float team; // team that gets netname2
- .float lifetime;
- .float fadetime;
- .float maxdistance;
- .float hideflags;
- .float spawntime;
- .float health;
- .float build_started;
- .float build_starthealth;
- .float build_finished;
- const float SPRITE_HEALTHBAR_WIDTH = 144;
- const float SPRITE_HEALTHBAR_HEIGHT = 9;
- const float SPRITE_HEALTHBAR_MARGIN = 6;
- const float SPRITE_HEALTHBAR_BORDER = 2;
- const float SPRITE_HEALTHBAR_BORDERALPHA = 1;
- const float SPRITE_HEALTHBAR_HEALTHALPHA = 0.5;
- const float SPRITE_ARROW_SCALE = 1.0;
- const float SPRITE_HELPME_BLINK = 2;
+ #include "waypointsprites.qh"
  
  void drawrotpic(vector org, float rot, string pic, vector sz, vector hotspot, vector rgb, float a, float f)
  {
@@@ -55,9 -8,9 +8,9 @@@
  
        // hotspot-relative coordinates of the corners
        v1 = hotspot;
-       v2 = hotspot + '1 0 0' * sz_x;
-       v3 = hotspot + '1 0 0' * sz_x + '0 1 0' * sz_y;
-       v4 = hotspot                  + '0 1 0' * sz_y;
+       v2 = hotspot + '1 0 0' * sz.x;
+       v3 = hotspot + '1 0 0' * sz.x + '0 1 0' * sz.y;
+       v4 = hotspot                  + '0 1 0' * sz.y;
  
        // rotate them, and make them absolute
        rot = -rot; // rotate by the opposite angle, as our coordinate system is reversed
@@@ -103,7 -56,7 +56,7 @@@ void drawhealthbar(vector org, float ro
        up = rotate(up, rot);
  
        owidth = width + 2 * border;
-       o = o - up * (margin + border + height) + ri * (sz_x - owidth) * 0.5;
+       o = o - up * (margin + border + height) + ri * (sz.x - owidth) * 0.5;
  
        drawquad(o - up * border,                               ri * owidth,    up * border, "", rgb,  a,  f);
        drawquad(o + up * height,                               ri * owidth,    up * border, "", rgb,  a,  f);
@@@ -149,12 -102,12 +102,12 @@@ vector drawspritetext(vector o, float a
        float sw, w, h;
        float aspect, sa, ca;
  
-       sw = stringwidth(s, FALSE, fontsize);
+       sw = stringwidth(s, false, fontsize);
        if(sw > minwidth)
                w = sw;
        else
                w = minwidth;
-       h = fontsize_y;
+       h = fontsize.y;
  
        // how do corners work?
        aspect = vid_conwidth / vid_conheight;
        }
  
        // align
-       o_x -= w * algnx;
-       o_y -= h * algny;
+       o.x -= w * algnx;
+       o.y -= h * algny;
  
        // we want to be onscreen
-       if(o_x < 0)
-               o_x = 0;
-       if(o_y < 0)
-               o_y = 0;
-       if(o_x > vid_conwidth - w)
-               o_x = vid_conwidth - w;
-       if(o_y > vid_conheight - h)
-               o_x = vid_conheight - h;
+       if(o.x < 0)
+               o.x = 0;
+       if(o.y < 0)
+               o.y = 0;
+       if(o.x > vid_conwidth - w)
+               o.x = vid_conwidth - w;
+       if(o.y > vid_conheight - h)
+               o.x = vid_conheight - h;
  
-       o_x += 0.5 * (w - sw);
+       o.x += 0.5 * (w - sw);
  
        drawstring(o, s, fontsize, rgb, a, DRAWFLAG_NORMAL);
  
-       o_x += 0.5 * sw;
-       o_y += 0.5 * h;
+       o.x += 0.5 * sw;
+       o.y += 0.5 * h;
  
        return o;
  }
@@@ -251,9 -204,6 +204,9 @@@ string spritelookuptext(string s
                case "keycarrier-red": return _("Key carrier");
                case "keycarrier-yellow": return _("Key carrier");
                case "redbase": return _("Red base");
 +              case "yellowbase": return _("Yellow base");
 +              case "neutralbase": return _("White base");
 +              case "pinkbase": return _("Pink base");
                case "waypoint": return _("Waypoint");
                case "ons-gen-red": return _("Generator");
                case "ons-gen-blue": return _("Generator");
@@@ -300,58 -250,57 +253,57 @@@ vector fixrgbexcess_move(vector rgb, ve
  }
  vector fixrgbexcess(vector rgb)
  {
-       if(rgb_x > 1)
+       if(rgb.x > 1)
        {
                rgb = fixrgbexcess_move(rgb, '1 0 0', '0 1 1');
-               if(rgb_y > 1)
+               if(rgb.y > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '0 1 0', '0 0 1');
-                       if(rgb_z > 1)
-                               rgb_z = 1;
+                       if(rgb.z > 1)
+                               rgb.z = 1;
                }
-               else if(rgb_z > 1)
+               else if(rgb.z > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '0 0 1', '0 1 0');
-                       if(rgb_y > 1)
-                               rgb_y = 1;
+                       if(rgb.y > 1)
+                               rgb.y = 1;
                }
        }
-       else if(rgb_y > 1)
+       else if(rgb.y > 1)
        {
                rgb = fixrgbexcess_move(rgb, '0 1 0', '1 0 1');
-               if(rgb_x > 1)
+               if(rgb.x > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '1 0 0', '0 0 1');
-                       if(rgb_z > 1)
-                               rgb_z = 1;
+                       if(rgb.z > 1)
+                               rgb.z = 1;
                }
-               else if(rgb_z > 1)
+               else if(rgb.z > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '0 0 1', '1 0 0');
-                       if(rgb_x > 1)
-                               rgb_x = 1;
+                       if(rgb.x > 1)
+                               rgb.x = 1;
                }
        }
-       else if(rgb_z > 1)
+       else if(rgb.z > 1)
        {
                rgb = fixrgbexcess_move(rgb, '0 0 1', '1 1 0');
-               if(rgb_x > 1)
+               if(rgb.x > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '1 0 0', '0 1 0');
-                       if(rgb_y > 1)
-                               rgb_y = 1;
+                       if(rgb.y > 1)
+                               rgb.y = 1;
                }
-               else if(rgb_y > 1)
+               else if(rgb.y > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '0 1 0', '1 0 0');
-                       if(rgb_x > 1)
-                               rgb_x = 1;
+                       if(rgb.x > 1)
+                               rgb.x = 1;
                }
        }
        return rgb;
  }
  
- float waypointsprite_count, waypointsprite_newcount;
  void Draw_WaypointSprite()
  {
        string spriteimage;
        float ang;
  
        o = project_3d_to_2d(self.origin);
-       if(o_z < 0
-       || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
-       || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
-       || o_x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
-       || o_y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
+       if(o.z < 0
+       || o.x < (vid_conwidth * waypointsprite_edgeoffset_left)
+       || o.y < (vid_conheight * waypointsprite_edgeoffset_top)
+       || o.x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
+       || o.y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
        {
                // scale it to be just in view
                vector d;
                float f1, f2;
  
                d = o - '0.5 0 0' * vid_conwidth - '0 0.5 0' * vid_conheight;
-               ang = atan2(-d_x, -d_y);
-               if(o_z < 0)
+               ang = atan2(-d.x, -d.y);
+               if(o.z < 0)
                        ang += M_PI;
  
-               f1 = d_x / vid_conwidth;
-               f2 = d_y / vid_conheight;
+               f1 = d.x / vid_conwidth;
+               f2 = d.y / vid_conheight;
  
                if(max(f1, -f1) > max(f2, -f2))
                {
-                       if(d_z * f1 > 0)
+                       if(d.z * f1 > 0)
                        {
                                // RIGHT edge
                                d = d * ((0.5 - waypointsprite_edgeoffset_right) / f1);
                }
                else
                {
-                       if(d_z * f2 > 0)
+                       if(d.z * f2 > 0)
                        {
                                // BOTTOM edge
                                d = d * ((0.5 - waypointsprite_edgeoffset_bottom) / f2);
  #else
                vector d;
                d = o - '0.5 0 0' * vid_conwidth - '0 0.5 0' * vid_conheight;
-               ang = atan2(-d_x, -d_y);
+               ang = atan2(-d.x, -d.y);
  #endif
        }
-       o_z = 0;
+       o.z = 0;
  
        float edgedistance_min, crosshairdistance;
-               edgedistance_min = min((o_y - (vid_conheight * waypointsprite_edgeoffset_top)),
-       (o_x - (vid_conwidth * waypointsprite_edgeoffset_left)),
-       (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o_x,
-       (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o_y);
+               edgedistance_min = min((o.y - (vid_conheight * waypointsprite_edgeoffset_top)),
+       (o.x - (vid_conwidth * waypointsprite_edgeoffset_left)),
+       (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o.x,
+       (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o.y);
  
        float vidscale;
        vidscale = max(vid_conwidth / vid_width, vid_conheight / vid_height);
  
-       crosshairdistance = sqrt( pow(o_x - vid_conwidth/2, 2) + pow(o_y - vid_conheight/2, 2) );
+       crosshairdistance = sqrt( pow(o.x - vid_conwidth/2, 2) + pow(o.y - vid_conheight/2, 2) );
  
        t = waypointsprite_scale * vidscale;
        a *= waypointsprite_alpha;
@@@ -617,7 -566,7 +569,7 @@@ void Ent_RemoveWaypointSprite(
  
  void Ent_WaypointSprite()
  {
-       float sendflags, f, t;
+       int sendflags, f, t;
        sendflags = ReadByte();
  
        if(!self.spawntime)
@@@ -723,7 -672,7 +675,7 @@@ void WaypointSprite_Load_Frames(string 
  {
        float dh, n, i, o, f;
        string s, sname, sframes;
-       dh = search_begin(strcat("models/sprites/*_frame*", ext), FALSE, FALSE);
+       dh = search_begin(strcat("models/sprites/*_frame*", ext), false, false);
        if (dh < 0)
                 return;
        float ext_len = strlen(ext);
index 445a951314a3ddc35b290ff8bb7111fd8f554f13,1cb1adf51f368e9e97ad2d3b5afebc2cbb8595ee..9580f56929cdad22ecd42347f7ad9d4dafe09ff6
@@@ -1,19 -1,25 +1,25 @@@
+ #ifndef NOTIFICATIONS_H
+ #define NOTIFICATIONS_H
+ #include "constants.qh"
+ #include "teams.qh"
  // ================================================
  //  Unified notification system, written by Samual
  //  Last updated: March, 2013
  // ================================================
  
  // main types/groups of notifications
#define MSG_ANNCE 1 // "Global" AND "personal" announcer messages
#define MSG_INFO 2 // "Global" information messages
#define MSG_CENTER 3 // "Personal" centerprint messages
#define MSG_CENTER_CPID 4 // Kill centerprint message
#define MSG_MULTI 5 // Subcall MSG_INFO and/or MSG_CENTER notifications
#define MSG_CHOICE 6 // Choose which subcall wrapper to activate
const int MSG_ANNCE = 1; // "Global" AND "personal" announcer messages
const int MSG_INFO = 2; // "Global" information messages
const int MSG_CENTER = 3; // "Personal" centerprint messages
const int MSG_CENTER_CPID = 4; // Kill centerprint message
const int MSG_MULTI = 5; // Subcall MSG_INFO and/or MSG_CENTER notifications
const int MSG_CHOICE = 6; // Choose which subcall wrapper to activate
  
  // negative confirmations
#define NO_MSG       -12345  // allows various things to know when no information is added
#define NOTIF_ABORT  -1234   // allows Send_Notification to safely abort sending
const int NO_MSG = -12345;  // allows various things to know when no information is added
const int NOTIF_ABORT = -1234;   // allows Send_Notification to safely abort sending
  
  #define EIGHT_VARS_TO_VARARGS_VARLIST \
      VARITEM(1, 0, s1) \
@@@ -45,11 -51,11 +51,11 @@@ void Destroy_All_Notifications(void)
  void Create_Notification_Entity(
      float var_default,
      float var_cvar,
-     float typeid,
+     float typeId,
      float nameid,
      string namestring,
-     float strnum,
-     float flnum,
+     int strnum,
+     int flnum,
      /* MSG_ANNCE */
      float channel,
      string snd,
@@@ -80,7 -86,7 +86,7 @@@ void Dump_Notifications(float fh, floa
  void Debug_Notification(string input);
  #endif
  
- void Local_Notification(float net_type, float net_name, ...count);
+ void Local_Notification(int net_type, int net_name, ...count);
  void Local_Notification_WOVA(
      float net_type, float net_name,
      float stringcount, float floatcount,
@@@ -94,12 -100,12 +100,12 @@@ float prev_soundtime
  #endif
  
  #ifdef SVQC // SERVER ONLY
- #define NOTIF_ONE 1
- #define NOTIF_ONE_ONLY 2
- #define NOTIF_TEAM 3
- #define NOTIF_TEAM_EXCEPT 4
- #define NOTIF_ALL 5
- #define NOTIF_ALL_EXCEPT 6
+ const float NOTIF_ONE = 1;
+ const float NOTIF_ONE_ONLY = 2;
+ const float NOTIF_TEAM = 3;
+ const float NOTIF_TEAM_EXCEPT = 4;
+ const float NOTIF_ALL = 5;
+ const float NOTIF_ALL_EXCEPT = 6;
  
  void Kill_Notification(
      float broadcast, entity client,
@@@ -340,34 -346,25 +346,34 @@@ void Send_Notification_WOCOVA
  
  #define MSG_INFO_NOTIFICATIONS \
      MSG_INFO_NOTIF(2, INFO_CHAT_NOSPECTATORS,              0, 0, "", "",                            "",                     _("^F4NOTE: ^BGSpectator chat is not sent to players during the match"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_CAPTURE_, 4,                1, 0, "s1", "s1",                        "notify_%s_captured",   _("^BG%s^BG captured the ^TC^TT^BG flag"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_CAPTURE_BROKEN_, 4,         2, 2, "s1 f1p2dec s2 f2p2dec", "s1",     "notify_%s_captured",   _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%s^BG seconds, breaking ^BG%s^BG's previous record of ^F2%s^BG seconds"), "") \
 +    MSG_INFO_NOTIF(1, INFO_CTF_CAPTURE_NEUTRAL,            1, 0, "s1", "s1",                        "notify_%s_captured",   _("^BG%s^BG captured the flag"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_CAPTURE_TIME_, 4,           1, 1, "s1 f1p2dec", "s1",                "notify_%s_captured",   _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%s^BG seconds"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_CAPTURE_UNBROKEN_, 4,       2, 2, "s1 f1p2dec s2 f2p2dec", "s1",     "notify_%s_captured",   _("^BG%s^BG captured the ^TC^TT^BG flag in ^F2%s^BG seconds, failing to break ^BG%s^BG's previous record of ^F1%s^BG seconds"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_ABORTRUN_, 4,    0, 0, "", "",                            "",                     _("^BGThe ^TC^TT^BG flag was returned to base by its owner"), "") \
 +    MSG_INFO_NOTIF(1, INFO_CTF_FLAGRETURN_ABORTRUN_NEUTRAL,0, 0, "", "",                            "",                     _("^BGThe flag was returned by its owner"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_DAMAGED_, 4,     0, 0, "", "",                            "",                     _("^BGThe ^TC^TT^BG flag was destroyed and returned to base"), "") \
 +    MSG_INFO_NOTIF(1, INFO_CTF_FLAGRETURN_DAMAGED_NEUTRAL, 0, 0, "", "",                            "",                     _("^BGThe flag was destroyed and returned to base"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_DROPPED_, 4,     0, 0, "", "",                            "",                     _("^BGThe ^TC^TT^BG flag was dropped in the base and returned itself"), "") \
 +    MSG_INFO_NOTIF(1, INFO_CTF_FLAGRETURN_DROPPED_NEUTRAL, 0, 0, "", "",                            "",                     _("^BGThe flag was dropped in the base and returned itself"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_NEEDKILL_, 4,    0, 0, "", "",                            "",                     _("^BGThe ^TC^TT^BG flag fell somewhere it couldn't be reached and returned to base"), "") \
 +    MSG_INFO_NOTIF(1, INFO_CTF_FLAGRETURN_NEEDKILL_NEUTRAL,0, 0, "", "",                            "",                     _("^BGThe flag fell somewhere it couldn't be reached and returned to base"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_SPEEDRUN_, 4,    0, 1, "f1p2dec", "",                     "",                     _("^BGThe ^TC^TT^BG flag became impatient after ^F1%.2f^BG seconds and returned itself"), "") \
 +    MSG_INFO_NOTIF(1, INFO_CTF_FLAGRETURN_SPEEDRUN_NEUTRAL,0, 1, "f1p2dec", "",                     "",                     _("^BGThe flag became impatient after ^F1%.2f^BG seconds and returned itself"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_TIMEOUT_, 4,     0, 0, "", "",                            "",                     _("^BGThe ^TC^TT^BG flag has returned to the base"), "") \
 +    MSG_INFO_NOTIF(1, INFO_CTF_FLAGRETURN_TIMEOUT_NEUTRAL, 0, 0, "", "",                            "",                     _("^BGThe flag has returned to the base"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_LOST_, 4,                   1, 0, "s1", "s1",                        "notify_%s_lost",       _("^BG%s^BG lost the ^TC^TT^BG flag"), "") \
 +    MSG_INFO_NOTIF(1, INFO_CTF_LOST_NEUTRAL,               1, 0, "s1", "s1",                        "notify_%s_lost",       _("^BG%s^BG lost the flag"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_PICKUP_, 4,                 1, 0, "s1", "s1",                        "notify_%s_taken",      _("^BG%s^BG got the ^TC^TT^BG flag"), "") \
 +    MSG_INFO_NOTIF(1, INFO_CTF_PICKUP_NEUTRAL,             1, 0, "s1", "s1",                        "notify_%s_taken",      _("^BG%s^BG got the flag"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_RETURN_, 4,                 1, 0, "s1", "s1",                        "notify_%s_returned",   _("^BG%s^BG returned the ^TC^TT^BG flag"), "") \
 +    MULTITEAM_INFO(1, INFO_CTF_RETURN_MONSTER_, 4,         1, 0, "s1", "s1",                        "notify_%s_returned",   _("^BG%s^BG returned the ^TC^TT^BG flag"), "") \
      MSG_INFO_NOTIF(2, INFO_COINTOSS,                       1, 0, "s1", "",                          "",                     _("^F2Throwing coin... Result: %s^F2!"), "") \
      MSG_INFO_NOTIF(1, INFO_JETPACK_NOFUEL,                 0, 0, "", "",                            "",                     _("^BGYou don't have any fuel for the ^F1Jetpack"), "") \
      MSG_INFO_NOTIF(2, INFO_SUPERSPEC_MISSING_UID,          0, 0, "", "",                            "",                     _("^F2You lack a UID, superspec options will not be saved/restored"), "") \
      MSG_INFO_NOTIF(1, INFO_CA_JOIN_LATE,                   0, 0, "", "",                            "",                     _("^F1Round already started, you will join the game in the next round"), "") \
      MSG_INFO_NOTIF(1, INFO_CA_LEAVE,                       0, 0, "", "",                            "",                     _("^F2You will spectate in the next round"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_CAPTURE_, 2,                1, 0, "s1", "s1",                        "notify_%s_captured",   _("^BG%s^BG captured the ^TC^TT^BG flag"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_CAPTURE_BROKEN_, 2,         2, 2, "s1 f1p2dec s2 f2p2dec", "s1",     "notify_%s_captured",   _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%s^BG seconds, breaking ^BG%s^BG's previous record of ^F2%s^BG seconds"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_CAPTURE_TIME_, 2,           1, 1, "s1 f1p2dec", "s1",                "notify_%s_captured",   _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%s^BG seconds"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_CAPTURE_UNBROKEN_, 2,       2, 2, "s1 f1p2dec s2 f2p2dec", "s1",     "notify_%s_captured",   _("^BG%s^BG captured the ^TC^TT^BG flag in ^F2%s^BG seconds, failing to break ^BG%s^BG's previous record of ^F1%s^BG seconds"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_ABORTRUN_, 2,    0, 0, "", "",                            "",                     _("^BGThe ^TC^TT^BG flag was returned to base by its owner"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_DAMAGED_, 2,     0, 0, "", "",                            "",                     _("^BGThe ^TC^TT^BG flag was destroyed and returned to base"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_DROPPED_, 2,     0, 0, "", "",                            "",                     _("^BGThe ^TC^TT^BG flag was dropped in the base and returned itself"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_NEEDKILL_, 2,    0, 0, "", "",                            "",                     _("^BGThe ^TC^TT^BG flag fell somewhere it couldn't be reached and returned to base"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_SPEEDRUN_, 2,    0, 1, "f1p2dec", "",                     "",                     _("^BGThe ^TC^TT^BG flag became impatient after ^F1%.2f^BG seconds and returned itself"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_FLAGRETURN_TIMEOUT_, 2,     0, 0, "", "",                            "",                     _("^BGThe ^TC^TT^BG flag has returned to the base"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_LOST_, 2,                   1, 0, "s1", "s1",                        "notify_%s_lost",       _("^BG%s^BG lost the ^TC^TT^BG flag"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_PICKUP_, 2,                 1, 0, "s1", "s1",                        "notify_%s_taken",      _("^BG%s^BG got the ^TC^TT^BG flag"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_RETURN_, 2,                 1, 0, "s1", "s1",                        "notify_%s_returned",   _("^BG%s^BG returned the ^TC^TT^BG flag"), "") \
 -    MULTITEAM_INFO(1, INFO_CTF_RETURN_MONSTER_, 2,         1, 0, "s1", "s1",                        "notify_%s_returned",   _("^BG%s^BG returned the ^TC^TT^BG flag"), "") \
      MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_CHEAT,             3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",  "notify_death",         _("^BG%s%s^K1 was unfairly eliminated by ^BG%s^K1%s%s"), "") \
      MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_DROWN,             3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",  "notify_water",         _("^BG%s%s^K1 was drowned by ^BG%s^K1%s%s"), "") \
      MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_FALL,              3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",  "notify_fall",          _("^BG%s%s^K1 was grounded by ^BG%s^K1%s%s"), "") \
      MSG_CENTER_NOTIF(1, CENTER_CAMPCHECK,                   0, 0, "",             CPID_CAMPCHECK,      "0 0", _("^F2Don't camp!"), "") \
      MSG_CENTER_NOTIF(1, CENTER_COINTOSS,                    1, 0, "s1",           NO_CPID,             "0 0", _("^F2Throwing coin... Result: %s^F2!"), "") \
      MSG_CENTER_NOTIF(1, CENTER_CTF_CAPTURESHIELD_FREE,      0, 0, "",             CPID_CTF_CAPSHIELD,  "0 0", _("^BGYou are now free.\n^BGFeel free to ^F2try to capture^BG the flag again\n^BGif you think you will succeed."), "") \
 -    MSG_CENTER_NOTIF(1, CENTER_CTF_CAPTURESHIELD_SHIELDED,  0, 0, "",             CPID_CTF_CAPSHIELD,  "0 0", _("^BGYou are now ^F1shielded^BG from the flag\n^BGfor ^F2too many unsuccessful attempts^BG to capture.\n^BGMake some defensive scores before trying again."), "") \
 -    MULTITEAM_CENTER(1, CENTER_CTF_CAPTURE_, 2,             0, 0, "",             CPID_CTF_LOWPRIO,    "0 0", _("^BGYou captured the ^TC^TT^BG flag!"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_CAPTURESHIELD_INACTIVE,  0, 0, "",             CPID_CTF_CAPSHIELD,  "0 0", _("^BGThis flag is currently inactive"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_CAPTURESHIELD_SHIELDED,  0, 0, "",             CPID_CTF_CAPSHIELD,  "0 0", _("^BGYou are now ^F1shielded^BG from the flag(s)\n^BGfor ^F2too many unsuccessful attempts^BG to capture.\n^BGMake some defensive scores before trying again."), "") \
 +    MULTITEAM_CENTER(1, CENTER_CTF_CAPTURE_, 4,             0, 0, "",             CPID_CTF_LOWPRIO,    "0 0", _("^BGYou captured the ^TC^TT^BG flag!"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_CAPTURE_NEUTRAL,         0, 0, "",             CPID_CTF_LOWPRIO,    "0 0", _("^BGYou captured the flag!"), "") \
      MSG_CENTER_NOTIF(1, CENTER_CTF_FLAG_THROW_PUNISH,       0, 1, "f1secs",       CPID_CTF_LOWPRIO,    "0 0", _("^BGToo many flag throws! Throwing disabled for %s."), "") \
 -    MULTITEAM_CENTER(1, CENTER_CTF_PASS_OTHER_, 2,          2, 0, "s1 s2",        CPID_CTF_PASS,       "0 0", _("^BG%s^BG passed the ^TC^TT^BG flag to %s"), "") \
 -    MULTITEAM_CENTER(1, CENTER_CTF_PASS_RECEIVED_, 2,       1, 0, "s1",           CPID_CTF_PASS,       "0 0", _("^BGYou received the ^TC^TT^BG flag from %s"), "") \
 +    MULTITEAM_CENTER(1, CENTER_CTF_PASS_OTHER_, 4,          2, 0, "s1 s2",        CPID_CTF_PASS,       "0 0", _("^BG%s^BG passed the ^TC^TT^BG flag to %s"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PASS_OTHER_NEUTRAL,      2, 0, "s1 s2",        CPID_CTF_PASS,       "0 0", _("^BG%s^BG passed the flag to %s"), "") \
 +    MULTITEAM_CENTER(1, CENTER_CTF_PASS_RECEIVED_, 4,       1, 0, "s1",           CPID_CTF_PASS,       "0 0", _("^BGYou received the ^TC^TT^BG flag from %s"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PASS_RECEIVED_NEUTRAL,   1, 0, "s1",           CPID_CTF_PASS,       "0 0", _("^BGYou received the flag from %s"), "") \
      MSG_CENTER_NOTIF(1, CENTER_CTF_PASS_REQUESTED,          1, 0, "s1 pass_key",  CPID_CTF_PASS,       "0 0", _("^BG%s^BG requests you to pass the flag%s"), "") \
      MSG_CENTER_NOTIF(1, CENTER_CTF_PASS_REQUESTING,         1, 0, "s1",           CPID_CTF_PASS,       "0 0", _("^BGRequesting %s^BG to pass you the flag"), "") \
 -    MULTITEAM_CENTER(1, CENTER_CTF_PASS_SENT_, 2,           1, 0, "s1",           CPID_CTF_PASS,       "0 0", _("^BGYou passed the ^TC^TT^BG flag to %s"), "") \
 -    MULTITEAM_CENTER(1, CENTER_CTF_PICKUP_, 2,              0, 0, "",             CPID_CTF_LOWPRIO,    "0 0", _("^BGYou got the ^TC^TT^BG flag!"), "") \
 +    MULTITEAM_CENTER(1, CENTER_CTF_PASS_SENT_, 4,           1, 0, "s1",           CPID_CTF_PASS,       "0 0", _("^BGYou passed the ^TC^TT^BG flag to %s"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PASS_SENT_NEUTRAL,       1, 0, "s1",           CPID_CTF_PASS,       "0 0", _("^BGYou passed the flag to %s"), "") \
 +    MULTITEAM_CENTER(1, CENTER_CTF_PICKUP_, 4,              0, 0, "",             CPID_CTF_LOWPRIO,    "0 0", _("^BGYou got the ^TC^TT^BG flag!"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_NEUTRAL,          0, 0, "",             CPID_CTF_LOWPRIO,    "0 0", _("^BGYou got the flag!"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_TEAM,             1, 0, "s1",           CPID_CTF_LOWPRIO,    "0 0", _("^BGYou got your %steam^BG's flag, return it!"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_TEAM_ENEMY,       1, 0, "s1",           CPID_CTF_LOWPRIO,    "0 0", _("^BGYou got the %senemy^BG's flag, return it!"), "") \
      MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_ENEMY,            1, 0, "s1",           CPID_CTF_LOWPRIO,    "0 0", _("^BGThe %senemy^BG got your flag! Retrieve it!"), "") \
      MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_ENEMY_VERBOSE,    2, 0, "s1 s2 s1",     CPID_CTF_LOWPRIO,    "0 0", _("^BGThe %senemy (^BG%s%s)^BG got your flag! Retrieve it!"), "") \
 -    MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_TEAM,             1, 0, "s1",           CPID_CTF_LOWPRIO,    "0 0", _("^BGYour %steam mate^BG got the flag! Protect them!"), "") \
 -    MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_TEAM_VERBOSE,     2, 0, "s1 s2 s1",     CPID_CTF_LOWPRIO,    "0 0", _("^BGYour %steam mate (^BG%s%s)^BG got the flag! Protect them!"), "") \
 -    MULTITEAM_CENTER(1, CENTER_CTF_RETURN_, 2,              0, 0, "",             CPID_CTF_LOWPRIO,    "0 0", _("^BGYou returned the ^TC^TT^BG flag!"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_ENEMY_NEUTRAL,    1, 0, "s1",           CPID_CTF_LOWPRIO,    "0 0", _("^BGThe %senemy^BG got the flag! Retrieve it!"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_ENEMY_NEUTRAL_VERBOSE, 2, 0, "s1 s2 s1",CPID_CTF_LOWPRIO,    "0 0", _("^BGThe %senemy (^BG%s%s)^BG got the flag! Retrieve it!"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_ENEMY_TEAM,        1, 0, "s1",          CPID_CTF_LOWPRIO,    "0 0", _("^BGThe %senemy^BG got their flag! Retrieve it!"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_ENEMY_TEAM_VERBOSE,2, 0, "s1 s2 s1",    CPID_CTF_LOWPRIO,    "0 0", _("^BGThe %senemy (^BG%s%s)^BG got their flag! Retrieve it!"), "") \
 +    MULTITEAM_CENTER(1, CENTER_CTF_PICKUP_TEAM_, 4,         1, 0, "s1",           CPID_CTF_LOWPRIO,    "0 0", _("^BGYour %steam mate^BG got the ^TC^TT^BG flag! Protect them!"), "") \
 +    MULTITEAM_CENTER(1, CENTER_CTF_PICKUP_TEAM_VERBOSE_,    4, 2, 0, "s1 s2 s1",  CPID_CTF_LOWPRIO,    "0 0", _("^BGYour %steam mate (^BG%s%s)^BG got the ^TC^TT^BG flag! Protect them!"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_TEAM_NEUTRAL,         1, 0, "s1",       CPID_CTF_LOWPRIO,    "0 0", _("^BGYour %steam mate^BG got the flag! Protect them!"), "") \
 +    MSG_CENTER_NOTIF(1, CENTER_CTF_PICKUP_TEAM_VERBOSE_NEUTRAL, 2, 0, "s1 s2 s1", CPID_CTF_LOWPRIO,    "0 0", _("^BGYour %steam mate (^BG%s%s)^BG got the flag! Protect them!"), "") \
 +    MULTITEAM_CENTER(1, CENTER_CTF_RETURN_, 4,              0, 0, "",             CPID_CTF_LOWPRIO,    "0 0", _("^BGYou returned the ^TC^TT^BG flag!"), "") \
      MSG_CENTER_NOTIF(1, CENTER_CTF_STALEMATE_CARRIER,       0, 0, "",             CPID_STALEMATE,      "0 0", _("^BGStalemate! Enemies can now see you on radar!"), "") \
      MSG_CENTER_NOTIF(1, CENTER_CTF_STALEMATE_OTHER,         0, 0, "",             CPID_STALEMATE,      "0 0", _("^BGStalemate! Flag carriers can now be seen by enemies on radar!"), "") \
      MSG_CENTER_NOTIF(1, CENTER_DEATH_MURDER_FRAG,                 1, 1, "spree_cen s1",             NO_CPID, "0 0", _("^K3%sYou fragged ^BG%s"), _("^K3%sYou scored against ^BG%s")) \
      MSG_CENTER_NOTIF(1, CENTER_TEAMCHANGE_SUICIDE,          0, 1, "",              CPID_TEAMCHANGE,       "1 f1", _("^K1Suicide in ^COUNT"), "") \
      MSG_CENTER_NOTIF(1, CENTER_TIMEOUT_BEGINNING,           0, 1, "",              CPID_TIMEOUT,          "1 f1", _("^F4Timeout begins in ^COUNT"), "") \
      MSG_CENTER_NOTIF(1, CENTER_TIMEOUT_ENDING,              0, 1, "",              CPID_TIMEOUT,          "1 f1", _("^F4Timeout ends in ^COUNT"), "") \
-     MSG_CENTER_NOTIF(1, CENTER_WEAPON_MINELAYER_LIMIT,      0, 1, "f1",            NO_CPID,               "0 0",  _("^BGYou cannot place more than ^F2%s^BG mines at a time"), "") 
+     MSG_CENTER_NOTIF(1, CENTER_WEAPON_MINELAYER_LIMIT,      0, 1, "f1",            NO_CPID,               "0 0",  _("^BGYou cannot place more than ^F2%s^BG mines at a time"), "")
  
  #define MULTITEAM_MULTI2(default,prefix,anncepre,infopre,centerpre) \
      MSG_MULTI_NOTIF(default, prefix##RED, anncepre##RED, infopre##RED, centerpre##RED) \
      MULTITEAM_CHOICE##teams(default,challow,prefix,chtype,optiona,optionb)
  
  #define MSG_CHOICE_NOTIFICATIONS \
 -    MULTITEAM_CHOICE(1, 2, CHOICE_CTF_CAPTURE_BROKEN_, 2,    MSG_INFO,    INFO_CTF_CAPTURE_,                INFO_CTF_CAPTURE_BROKEN_) \
 -    MULTITEAM_CHOICE(1, 2, CHOICE_CTF_CAPTURE_TIME_, 2,      MSG_INFO,    INFO_CTF_CAPTURE_,                INFO_CTF_CAPTURE_TIME_) \
 -    MULTITEAM_CHOICE(1, 2, CHOICE_CTF_CAPTURE_UNBROKEN_, 2,  MSG_INFO,    INFO_CTF_CAPTURE_,                INFO_CTF_CAPTURE_UNBROKEN_) \
 -    MSG_CHOICE_NOTIF(1, 2, CHOICE_CTF_PICKUP_TEAM,           MSG_CENTER,  CENTER_CTF_PICKUP_TEAM,           CENTER_CTF_PICKUP_TEAM_VERBOSE) \
 +    MULTITEAM_CHOICE(1, 2, CHOICE_CTF_CAPTURE_BROKEN_, 4,    MSG_INFO,    INFO_CTF_CAPTURE_,                INFO_CTF_CAPTURE_BROKEN_) \
 +    MULTITEAM_CHOICE(1, 2, CHOICE_CTF_CAPTURE_TIME_, 4,      MSG_INFO,    INFO_CTF_CAPTURE_,                INFO_CTF_CAPTURE_TIME_) \
 +    MULTITEAM_CHOICE(1, 2, CHOICE_CTF_CAPTURE_UNBROKEN_, 4,  MSG_INFO,    INFO_CTF_CAPTURE_,                INFO_CTF_CAPTURE_UNBROKEN_) \
 +    MULTITEAM_CHOICE(1, 2, CHOICE_CTF_PICKUP_TEAM_, 4,       MSG_CENTER,  CENTER_CTF_PICKUP_TEAM_,          CENTER_CTF_PICKUP_TEAM_VERBOSE_) \
 +    MSG_CHOICE_NOTIF(1, 2, CHOICE_CTF_PICKUP_TEAM_NEUTRAL,   MSG_CENTER,  CENTER_CTF_PICKUP_TEAM_NEUTRAL,   CENTER_CTF_PICKUP_TEAM_VERBOSE_NEUTRAL) \
      MSG_CHOICE_NOTIF(1, 2, CHOICE_CTF_PICKUP_ENEMY,          MSG_CENTER,  CENTER_CTF_PICKUP_ENEMY,          CENTER_CTF_PICKUP_ENEMY_VERBOSE) \
 +    MSG_CHOICE_NOTIF(1, 2, CHOICE_CTF_PICKUP_ENEMY_NEUTRAL,  MSG_CENTER,  CENTER_CTF_PICKUP_ENEMY_NEUTRAL,  CENTER_CTF_PICKUP_ENEMY_NEUTRAL_VERBOSE) \
 +    MSG_CHOICE_NOTIF(1, 2, CHOICE_CTF_PICKUP_ENEMY_TEAM,     MSG_CENTER,  CENTER_CTF_PICKUP_ENEMY_TEAM,     CENTER_CTF_PICKUP_ENEMY_TEAM_VERBOSE) \
      MSG_CHOICE_NOTIF(1, 1, CHOICE_FRAG,                      MSG_CENTER,  CENTER_DEATH_MURDER_FRAG,         CENTER_DEATH_MURDER_FRAG_VERBOSE) \
      MSG_CHOICE_NOTIF(1, 1, CHOICE_FRAGGED,                   MSG_CENTER,  CENTER_DEATH_MURDER_FRAGGED,      CENTER_DEATH_MURDER_FRAGGED_VERBOSE) \
      MSG_CHOICE_NOTIF(1, 1, CHOICE_TYPEFRAG,                  MSG_CENTER,  CENTER_DEATH_MURDER_TYPEFRAG,     CENTER_DEATH_MURDER_TYPEFRAG_VERBOSE) \
  // MAKE SURE THIS IS ALWAYS SYNCHRONIZED WITH THE DUMP
  // NOTIFICATIONS FUNCTION IN THE .QC FILE!
  
- #define NOTIF_ADD_AUTOCVAR(name,default) var float autocvar_notification_##name = default;
+ #define NOTIF_ADD_AUTOCVAR(name,default) float autocvar_notification_##name = default;
  
var float autocvar_notification_show_location = FALSE;
var string autocvar_notification_show_location_string = ""; //_(" at the %s");
var float autocvar_notification_show_sprees = TRUE;
var float autocvar_notification_show_sprees_info = 3; // 0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker
var float autocvar_notification_show_sprees_info_newline = TRUE;
var float autocvar_notification_show_sprees_info_specialonly = TRUE;
var float autocvar_notification_errors_are_fatal = TRUE;
var float autocvar_notification_lifetime_runtime = 0.5;
var float autocvar_notification_lifetime_mapload = 10;
var float autocvar_notification_debug = FALSE;
float autocvar_notification_show_location = false;
+ string autocvar_notification_show_location_string = ""; //_(" at the %s");
float autocvar_notification_show_sprees = true;
+ float autocvar_notification_show_sprees_info = 3; // 0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker
float autocvar_notification_show_sprees_info_newline = true;
float autocvar_notification_show_sprees_info_specialonly = true;
float autocvar_notification_errors_are_fatal = true;
+ float autocvar_notification_lifetime_runtime = 0.5;
+ float autocvar_notification_lifetime_mapload = 10;
float autocvar_notification_debug = false;
  
  #ifdef SVQC
  .float FRAG_VERBOSE;
  void Notification_GetCvars(void);
var float autocvar_notification_server_allows_location = 1; // 0 = no, 1 = yes
+ float autocvar_notification_server_allows_location = 1; // 0 = no, 1 = yes
  #else
var float autocvar_notification_item_centerprinttime = 1.5;
+ float autocvar_notification_item_centerprinttime = 1.5;
  
  // 0 = no, 1 = yes, 2 = forced on for all MSG_INFO notifs
  // DISABLED IN CODE, BUT ENABLED IN CONFIG FOR COMPATIBILITY WITH OLD CLIENTS
var float autocvar_notification_allow_chatboxprint = 0;
+ float autocvar_notification_allow_chatboxprint = 0;
  
var float autocvar_notification_show_sprees_center = TRUE;
var float autocvar_notification_show_sprees_center_specialonly = TRUE;
float autocvar_notification_show_sprees_center = true;
float autocvar_notification_show_sprees_center_specialonly = true;
  #endif
  
  
      death_team: show the full name of the team a player is switching from
  */
  
- #define NOTIF_MAX_ARGS 7
- #define NOTIF_MAX_HUDARGS 2
- #define NOTIF_MAX_DURCNT 2
+ const float NOTIF_MAX_ARGS = 7;
+ const float NOTIF_MAX_HUDARGS = 2;
+ const float NOTIF_MAX_DURCNT = 2;
  
  string arg_slot[NOTIF_MAX_ARGS];
  
#define ARG_CS_SV_HA 1 // enabled on CSQC, SVQC, and Hudargs
#define ARG_CS_SV_DC 2 // enabled on CSQC, SVQC, and durcnt centerprint
#define ARG_CS_SV 3 // enabled on CSQC and SVQC
#define ARG_CS 4 // unique result to CSQC
#define ARG_SV 5 // unique result to SVQC
#define ARG_DC 6 // unique result to durcnt/centerprint
const float ARG_CS_SV_HA = 1; // enabled on CSQC, SVQC, and Hudargs
const float ARG_CS_SV_DC = 2; // enabled on CSQC, SVQC, and durcnt centerprint
const float ARG_CS_SV = 3; // enabled on CSQC and SVQC
const float ARG_CS = 4; // unique result to CSQC
const float ARG_SV = 5; // unique result to SVQC
const float ARG_DC = 6; // unique result to durcnt/centerprint
  
  // todo possible idea.... declare how many floats/strings each arg needs, and then dynamically increment the input
  // this way, we don't need to have duplicates like i.e. s2loc and s3loc?
      ARG_CASE(ARG_CS_SV,     "race_diff",     ((f2 > f3) ? sprintf(CCR("^1[+%s]"), mmssss(f2 - f3)) : sprintf(CCR("^2[-%s]"), mmssss(f3 - f2)))) \
      ARG_CASE(ARG_CS,        "missing_teams", notif_arg_missing_teams(f1)) \
      ARG_CASE(ARG_CS,        "pass_key",      ((((tmp_s = getcommandkey("pass", "+use")) != "pass") && !(strstrofs(tmp_s, "not bound", 0) >= 0)) ? sprintf(CCR(_(" ^F1(Press %s)")), tmp_s) : "")) \
-     ARG_CASE(ARG_CS,        "frag_ping",     notif_arg_frag_ping(TRUE, f2)) \
+     ARG_CASE(ARG_CS,        "frag_ping",     notif_arg_frag_ping(true, f2)) \
      ARG_CASE(ARG_CS,        "frag_stats",    notif_arg_frag_stats(f2, f3, f4)) \
      /*ARG_CASE(ARG_CS,      "frag_pos",      ((Should_Print_Score_Pos(f1)) ? sprintf("\n^BG%s", Read_Score_Pos(f1)) : ""))*/ \
      ARG_CASE(ARG_CS,        "spree_cen",     (autocvar_notification_show_sprees ? notif_arg_spree_cen(f1) : "")) \
      ARG_CASE(ARG_SV,        "death_team",    Team_ColoredFullName(f1)) \
      ARG_CASE(ARG_CS,        "death_team",    Team_ColoredFullName(f1 - 1))
  
- #define NOTIF_HIT_MAX(count,funcname) if(sel_num == count) { backtrace(sprintf("%s: Hit maximum arguments!\n", funcname)); break; }
+ #define NOTIF_HIT_MAX(count,funcname) do { \
+     if(sel_num == count) { backtrace(sprintf("%s: Hit maximum arguments!\n", funcname)); break; } \
+ } while(0)
  #define NOTIF_HIT_UNKNOWN(token,funcname) { backtrace(sprintf("%s: Hit unknown token in selected string! '%s'\n", funcname, selected)); break; }
  
  #define KILL_SPREE_LIST \
@@@ -1118,9 -1100,9 +1126,9 @@@ string notif_arg_frag_ping(float newlin
  string notif_arg_frag_stats(float fhealth, float farmor, float fping)
  {
      if (!(fhealth < 1))
-         return sprintf(CCR(_("\n(Health ^1%d^BG / Armor ^2%d^BG)%s")), fhealth, farmor, notif_arg_frag_ping(FALSE, fping));
+         return sprintf(CCR(_("\n(Health ^1%d^BG / Armor ^2%d^BG)%s")), fhealth, farmor, notif_arg_frag_ping(false, fping));
      else
-         return sprintf(CCR(_("\n(^F4Dead^BG)%s")), notif_arg_frag_ping(FALSE, fping));
+         return sprintf(CCR(_("\n(^F4Dead^BG)%s")), notif_arg_frag_ping(false, fping));
  }
  
  string notif_arg_missing_teams(float f1)
@@@ -1295,21 -1277,52 +1303,52 @@@ string notif_arg_spree_inf(float type, 
  //  Initialization/Create Declarations
  // ====================================
  
+ enum {
+     NO_CPID
+ ,   CPID_ASSAULT_ROLE
+ ,   CPID_ROUND
+ ,   CPID_CAMPCHECK
+ ,   CPID_CTF_CAPSHIELD
+ ,   CPID_CTF_LOWPRIO
+ ,   CPID_CTF_PASS
+ ,   CPID_STALEMATE
+ ,   CPID_NADES
+ ,   CPID_IDLING
+ ,   CPID_ITEM
+ ,   CPID_PREVENT_JOIN
+ ,   CPID_KEEPAWAY
+ ,   CPID_KEEPAWAY_WARN
+ ,   CPID_KEYHUNT
+ ,   CPID_KEYHUNT_OTHER
+ ,   CPID_LMS
+ ,   CPID_MISSING_TEAMS
+ ,   CPID_MISSING_PLAYERS
+ ,   CPID_INSTAGIB_FINDAMMO
+ ,   CPID_MOTD
+ ,   CPID_NIX
+ ,   CPID_ONSLAUGHT
+ ,   CPID_OVERTIME
+ ,   CPID_POWERUP
+ ,   CPID_RACE_FINISHLAP
+ ,   CPID_TEAMCHANGE
+ ,   CPID_TIMEOUT
+ // always last
+ ,   NOTIF_CPID_COUNT
+ };
  // notification counts
- #define NOTIF_FIRST 1
+ const float NOTIF_FIRST = 1;
  float NOTIF_ANNCE_COUNT;
  float NOTIF_INFO_COUNT;
  float NOTIF_CENTER_COUNT;
  float NOTIF_MULTI_COUNT;
  float NOTIF_CHOICE_COUNT;
- float NOTIF_CPID_COUNT;
  
  // notification limits -- INCREASE AS NECESSARY
- #define NOTIF_ANNCE_MAX   100
- #define NOTIF_INFO_MAX    300
- #define NOTIF_CENTER_MAX  200
- #define NOTIF_MULTI_MAX   200
- #define NOTIF_CHOICE_MAX  30
+ const float NOTIF_ANNCE_MAX   = 100;
+ const float NOTIF_INFO_MAX    = 300;
+ const float NOTIF_CENTER_MAX  = 200;
+ const float NOTIF_MULTI_MAX   = 200;
 -const float NOTIF_CHOICE_MAX  = 20;
++const float NOTIF_CHOICE_MAX  = 30;
  
  // notification entities
  entity msg_annce_notifs[NOTIF_ANNCE_MAX];
@@@ -1324,8 -1337,8 +1363,8 @@@ entity msg_choice_notifs[NOTIF_CHOICE_M
  .float nent_type;
  .float nent_id;
  .string nent_name;
- .float nent_stringcount;
- .float nent_floatcount;
+ .int nent_stringcount;
+ .int nent_floatcount;
  
  // MSG_ANNCE entity values
  .float nent_channel;
@@@ -1378,7 -1391,7 +1417,7 @@@ float notif_global_error
              /* COMMON ======================== */ \
              default,            /* var_default */ \
              ACVNN(name),        /* var_cvar    */ \
-             MSG_ANNCE,          /* typeid      */ \
+             MSG_ANNCE,          /* typeId      */ \
              name,               /* nameid      */ \
              strtoupper(#name),  /* namestring  */ \
              NO_MSG,             /* strnum      */ \
  
  #define MSG_INFO_NOTIF(default,name,strnum,flnum,args,hudargs,icon,normal,gentle) \
      NOTIF_ADD_AUTOCVAR(name, default) \
-     float name; \
+     int name; \
      void RegisterNotification_##name() \
      { \
          SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_INFO_COUNT) \
              /* COMMON ======================== */ \
              default,            /* var_default */ \
              ACVNN(name),        /* var_cvar    */ \
-             MSG_INFO,           /* typeid      */ \
+             MSG_INFO,           /* typeId      */ \
              name,               /* nameid      */ \
              strtoupper(#name),  /* namestring  */ \
              strnum,             /* strnum      */ \
  #define MSG_CENTER_NOTIF(default,name,strnum,flnum,args,cpid,durcnt,normal,gentle) \
      NOTIF_ADD_AUTOCVAR(name, default) \
      float name; \
-     float cpid; \
      void RegisterNotification_##name() \
      { \
          SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_CENTER_COUNT) \
-         SET_FIELD_COUNT(cpid, NOTIF_FIRST, NOTIF_CPID_COUNT) \
          CHECK_MAX_COUNT(name, NOTIF_CENTER_MAX, NOTIF_CENTER_COUNT, "MSG_CENTER") \
          Create_Notification_Entity( \
              /* COMMON ======================== */ \
              default,            /* var_default */ \
              ACVNN(name),        /* var_cvar    */ \
-             MSG_CENTER,         /* typeid      */ \
+             MSG_CENTER,         /* typeId      */ \
              name,               /* nameid      */ \
              strtoupper(#name),  /* namestring  */ \
              strnum,             /* strnum      */ \
  
  #define MSG_MULTI_NOTIF(default,name,anncename,infoname,centername) \
      NOTIF_ADD_AUTOCVAR(name, default) \
-     float name; \
+     int name; \
      void RegisterNotification_##name() \
      { \
          SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_MULTI_COUNT) \
              /* COMMON ======================== */ \
              default,            /* var_default */ \
              ACVNN(name),        /* var_cvar    */ \
-             MSG_MULTI,          /* typeid      */ \
+             MSG_MULTI,          /* typeId      */ \
              name,               /* nameid      */ \
              strtoupper(#name),  /* namestring  */ \
              NO_MSG,             /* strnum      */ \
              /* COMMON ======================== */ \
              default,            /* var_default */ \
              ACVNN(name),        /* var_cvar    */ \
-             MSG_CHOICE,         /* typeid      */ \
+             MSG_CHOICE,         /* typeId      */ \
              name,               /* nameid      */ \
              strtoupper(#name),  /* namestring  */ \
              NO_MSG,             /* strnum      */ \
  
  void RegisterNotifications_First()
  {
-     notif_global_error = FALSE;
+     notif_global_error = false;
  
      #ifdef SVQC
      #define dedi (server_is_dedicated ? "a dedicated " : "")
          #else
          if(autocvar_notification_version_mismatch_server_error)
          #endif
-             notif_global_error = TRUE;
+             notif_global_error = true;
  
          printf("^1NOTIFICATION VERSION MISMATCH: ^7program = %s, config = %d, code = %d.\n",
              PROGNAME, autocvar_notification_version, NOTIF_VERSION);
@@@ -1638,3 -1649,4 +1675,4 @@@ ACCUMULATE_FUNCTION(RegisterNotificatio
  #undef MSG_CHOICE_NOTIF
  
  #undef NOTIF_ADD_AUTOCVAR
+ #endif
diff --combined qcsrc/common/stats.qh
index f08c6b56dd1e51bfe13b5549ca66a2b89e850afd,481713cc9cb8f17df86aad4be260f8fd6f5ba76a..28ec85e30a7cedf7d8c485ba1365403d6f35336e
@@@ -1,29 -1,32 +1,32 @@@
- // Full list of all stat constants, icnluded in a single location for easy reference
+ #ifndef STATS_H
+ #define STATS_H
+ // Full list of all stat constants, included in a single location for easy reference
  // 255 is the current limit (MAX_CL_STATS - 1), engine will need to be modified if you wish to add more stats
  
- const float MAX_CL_STATS                = 256;
- const float STAT_HEALTH                 = 0;
+ const int MAX_CL_STATS                = 256;
+ const int STAT_HEALTH                 = 0;
  // 1 empty?
- const float STAT_WEAPON                 = 2;
- const float STAT_AMMO                   = 3;
- const float STAT_ARMOR                  = 4;
- const float STAT_WEAPONFRAME            = 5;
- const float STAT_SHELLS                 = 6;
- const float STAT_NAILS                  = 7;
- const float STAT_ROCKETS                = 8;
- const float STAT_CELLS                  = 9;
- const float STAT_ACTIVEWEAPON           = 10;
- const float STAT_TOTALSECRETS           = 11;
- const float STAT_TOTALMONSTERS          = 12;
- const float STAT_SECRETS                = 13;
- const float STAT_MONSTERS               = 14;
- const float STAT_ITEMS                  = 15;
- const float STAT_VIEWHEIGHT             = 16;
+ const int STAT_WEAPON                 = 2;
+ const int STAT_AMMO                   = 3;
+ const int STAT_ARMOR                  = 4;
+ const int STAT_WEAPONFRAME            = 5;
+ const int STAT_SHELLS                 = 6;
+ const int STAT_NAILS                  = 7;
+ const int STAT_ROCKETS                = 8;
+ const int STAT_CELLS                  = 9;
+ const int STAT_ACTIVEWEAPON           = 10;
+ const int STAT_TOTALSECRETS           = 11;
+ const int STAT_TOTALMONSTERS          = 12;
+ const int STAT_SECRETS                = 13;
+ const int STAT_MONSTERS               = 14;
+ const int STAT_ITEMS                  = 15;
+ const int STAT_VIEWHEIGHT             = 16;
  // 17 empty?
  // 18 empty?
  // 19 empty?
  // 20 empty?
- const float STAT_VIEWZOOM               = 21;
+ const int STAT_VIEWZOOM               = 21;
  // 22 empty?
  // 23 empty?
  // 24 empty?
  // 29 empty?
  // 30 empty?
  // 31 empty?
- const float STAT_KH_KEYS                = 32;
- const float STAT_CTF_STATE              = 33;
+ const int STAT_KH_KEYS                = 32;
+ const int STAT_CTF_STATE              = 33;
  // 34 empty?
- const float STAT_WEAPONS                = 35;
- const float STAT_SWITCHWEAPON           = 36;
- const float STAT_GAMESTARTTIME          = 37;
- const float STAT_STRENGTH_FINISHED      = 38;
- const float STAT_INVINCIBLE_FINISHED    = 39;
+ const int STAT_WEAPONS                = 35;
+ const int STAT_SWITCHWEAPON           = 36;
+ const int STAT_GAMESTARTTIME          = 37;
+ const int STAT_STRENGTH_FINISHED      = 38;
+ const int STAT_INVINCIBLE_FINISHED    = 39;
  // 40 empty?
- const float STAT_ARC_HEAT               = 41;
- const float STAT_PRESSED_KEYS           = 42;
- const float STAT_ALLOW_OLDVORTEXBEAM    = 43; // this stat could later contain some other bits of info, like, more server-side particle config
- const float STAT_FUEL                   = 44;
- const float STAT_NB_METERSTART          = 45;
- const float STAT_SHOTORG                = 46; // compressShotOrigin
- const float STAT_LEADLIMIT              = 47;
- const float STAT_WEAPON_CLIPLOAD        = 48;
- const float STAT_WEAPON_CLIPSIZE        = 49;
- const float STAT_VORTEX_CHARGE          = 50;
- const float STAT_LAST_PICKUP            = 51;
- const float STAT_HUD                    = 52;
- const float STAT_VORTEX_CHARGEPOOL      = 53;
- const float STAT_HIT_TIME               = 54;
- const float STAT_DAMAGE_DEALT_TOTAL     = 55;
- const float STAT_TYPEHIT_TIME           = 56;
- const float STAT_LAYED_MINES            = 57;
- const float STAT_HAGAR_LOAD             = 58;
- const float STAT_SWITCHINGWEAPON        = 59;
- const float STAT_SUPERWEAPONS_FINISHED  = 60;
- const float STAT_VEHICLESTAT_HEALTH     = 61;
- const float STAT_VEHICLESTAT_SHIELD     = 62;
- const float STAT_VEHICLESTAT_ENERGY     = 63;
- const float STAT_VEHICLESTAT_AMMO1      = 64;
- const float STAT_VEHICLESTAT_RELOAD1    = 65;
- const float STAT_VEHICLESTAT_AMMO2      = 66;
- const float STAT_VEHICLESTAT_RELOAD2    = 67;
- const float STAT_VEHICLESTAT_W2MODE     = 68;
- const float STAT_NADE_TIMER             = 69;
- const float STAT_SECRETS_TOTAL          = 70;
- const float STAT_SECRETS_FOUND          = 71;
- const float STAT_RESPAWN_TIME           = 72;
- const float STAT_ROUNDSTARTTIME         = 73;
- const float STAT_WEAPONS2               = 74;
- const float STAT_WEAPONS3               = 75;
- const float STAT_MONSTERS_TOTAL         = 76;
- const float STAT_MONSTERS_KILLED        = 77;
- const float STAT_BUFFS                  = 78;
- const float STAT_NADE_BONUS             = 79;
- const float STAT_NADE_BONUS_TYPE        = 80;
- const float STAT_NADE_BONUS_SCORE       = 81;
- const float STAT_HEALING_ORB            = 82;
- const float STAT_HEALING_ORB_ALPHA      = 83;
- const float STAT_PLASMA                 = 84;
- const float STAT_OK_AMMO_CHARGE         = 85;
- const float STAT_OK_AMMO_CHARGEPOOL     = 86;
- const float STAT_CTF_FLAGSTATUS         = 87;
+ const int STAT_ARC_HEAT               = 41;
+ const int STAT_PRESSED_KEYS           = 42;
+ const int STAT_ALLOW_OLDVORTEXBEAM    = 43; // this stat could later contain some other bits of info, like, more server-side particle config
+ const int STAT_FUEL                   = 44;
+ const int STAT_NB_METERSTART          = 45;
+ const int STAT_SHOTORG                = 46; // compressShotOrigin
+ const int STAT_LEADLIMIT              = 47;
+ const int STAT_WEAPON_CLIPLOAD        = 48;
+ const int STAT_WEAPON_CLIPSIZE        = 49;
+ const int STAT_VORTEX_CHARGE          = 50;
+ const int STAT_LAST_PICKUP            = 51;
+ const int STAT_HUD                    = 52;
+ const int STAT_VORTEX_CHARGEPOOL      = 53;
+ const int STAT_HIT_TIME               = 54;
+ const int STAT_DAMAGE_DEALT_TOTAL     = 55;
+ const int STAT_TYPEHIT_TIME           = 56;
+ const int STAT_LAYED_MINES            = 57;
+ const int STAT_HAGAR_LOAD             = 58;
+ const int STAT_SWITCHINGWEAPON        = 59;
+ const int STAT_SUPERWEAPONS_FINISHED  = 60;
+ const int STAT_VEHICLESTAT_HEALTH     = 61;
+ const int STAT_VEHICLESTAT_SHIELD     = 62;
+ const int STAT_VEHICLESTAT_ENERGY     = 63;
+ const int STAT_VEHICLESTAT_AMMO1      = 64;
+ const int STAT_VEHICLESTAT_RELOAD1    = 65;
+ const int STAT_VEHICLESTAT_AMMO2      = 66;
+ const int STAT_VEHICLESTAT_RELOAD2    = 67;
+ const int STAT_VEHICLESTAT_W2MODE     = 68;
+ const int STAT_NADE_TIMER             = 69;
+ const int STAT_SECRETS_TOTAL          = 70;
+ const int STAT_SECRETS_FOUND          = 71;
+ const int STAT_RESPAWN_TIME           = 72;
+ const int STAT_ROUNDSTARTTIME         = 73;
+ const int STAT_WEAPONS2               = 74;
+ const int STAT_WEAPONS3               = 75;
+ const int STAT_MONSTERS_TOTAL         = 76;
+ const int STAT_MONSTERS_KILLED        = 77;
+ const int STAT_BUFFS                  = 78;
+ const int STAT_NADE_BONUS             = 79;
+ const int STAT_NADE_BONUS_TYPE        = 80;
+ const int STAT_NADE_BONUS_SCORE       = 81;
+ const int STAT_HEALING_ORB            = 82;
+ const int STAT_HEALING_ORB_ALPHA      = 83;
+ const int STAT_PLASMA                 = 84;
+ const int STAT_OK_AMMO_CHARGE         = 85;
+ const int STAT_OK_AMMO_CHARGEPOOL     = 86;
 -// 87 empty?
++const int STAT_CTF_FLAGSTATUS         = 87;
  // 88 empty?
  // 89 empty?
  // 90 empty?
  // IDs 100 to 104 reserved for gamemodes
  
  // freeze tag, clan arena, jailbreak
- const float STAT_REDALIVE               = 100;
- const float STAT_BLUEALIVE              = 101;
- const float STAT_YELLOWALIVE            = 102;
- const float STAT_PINKALIVE              = 103;
+ const int STAT_REDALIVE               = 100;
+ const int STAT_BLUEALIVE              = 101;
+ const int STAT_YELLOWALIVE            = 102;
+ const int STAT_PINKALIVE              = 103;
  
  // domination
- const float STAT_DOM_TOTAL_PPS          = 100;
- const float STAT_DOM_PPS_RED            = 101;
- const float STAT_DOM_PPS_BLUE           = 102;
- const float STAT_DOM_PPS_YELLOW         = 103;
- const float STAT_DOM_PPS_PINK           = 104;
+ const int STAT_DOM_TOTAL_PPS          = 100;
+ const int STAT_DOM_PPS_RED            = 101;
+ const int STAT_DOM_PPS_BLUE           = 102;
+ const int STAT_DOM_PPS_YELLOW         = 103;
+ const int STAT_DOM_PPS_PINK           = 104;
  
  // vip
- const float STAT_VIP                    = 100;
- const float STAT_VIP_RED                = 101;
- const float STAT_VIP_BLUE               = 102;
- const float STAT_VIP_YELLOW             = 103;
- const float STAT_VIP_PINK               = 104;
+ const int STAT_VIP                    = 100;
+ const int STAT_VIP_RED                = 101;
+ const int STAT_VIP_BLUE               = 102;
+ const int STAT_VIP_YELLOW             = 103;
+ const int STAT_VIP_PINK               = 104;
  
  // key hunt
- const float STAT_KH_REDKEY_TEAM         = 100;
- const float STAT_KH_BLUEKEY_TEAM        = 101;
- const float STAT_KH_YELLOWKEY_TEAM      = 102;
- const float STAT_KH_PINKKEY_TEAM        = 103;
+ const int STAT_KH_REDKEY_TEAM         = 100;
+ const int STAT_KH_BLUEKEY_TEAM        = 101;
+ const int STAT_KH_YELLOWKEY_TEAM      = 102;
+ const int STAT_KH_PINKKEY_TEAM        = 103;
  
  /* Gamemode-specific stats end here */
  
  
- const float STAT_FROZEN                 = 105;
- const float STAT_REVIVE_PROGRESS        = 106;
+ const int STAT_FROZEN                 = 105;
+ const int STAT_REVIVE_PROGRESS        = 106;
  // 107 empty?
  // 108 empty?
  // 109 empty?
  // 217 empty?
  // 218 empty?
  // 219 empty?
- const float STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR     = 220;
- const float STAT_MOVEVARS_AIRCONTROL_PENALTY            = 221;
- const float STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW           = 222;
- const float STAT_MOVEVARS_AIRSTRAFEACCEL_QW             = 223;
- const float STAT_MOVEVARS_AIRCONTROL_POWER              = 224;
- const float STAT_MOVEFLAGS                              = 225;
- const float STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL   = 226;
- const float STAT_MOVEVARS_WARSOWBUNNY_ACCEL             = 227;
- const float STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED          = 228;
- const float STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL         = 229;
- const float STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO   = 230;
- const float STAT_MOVEVARS_AIRSTOPACCELERATE             = 231;
- const float STAT_MOVEVARS_AIRSTRAFEACCELERATE           = 232;
- const float STAT_MOVEVARS_MAXAIRSTRAFESPEED             = 233;
- const float STAT_MOVEVARS_AIRCONTROL                    = 234;
- const float STAT_FRAGLIMIT                              = 235;
- const float STAT_TIMELIMIT                              = 236;
- const float STAT_MOVEVARS_WALLFRICTION                  = 237;
- const float STAT_MOVEVARS_FRICTION                      = 238;
- const float STAT_MOVEVARS_WATERFRICTION                 = 239;
- const float STAT_MOVEVARS_TICRATE                       = 240;
- const float STAT_MOVEVARS_TIMESCALE                     = 241;
- const float STAT_MOVEVARS_GRAVITY                       = 242;
- const float STAT_MOVEVARS_STOPSPEED                     = 243;
- const float STAT_MOVEVARS_MAXSPEED                      = 244;
- const float STAT_MOVEVARS_SPECTATORMAXSPEED             = 245;
- const float STAT_MOVEVARS_ACCELERATE                    = 246;
- const float STAT_MOVEVARS_AIRACCELERATE                 = 247;
- const float STAT_MOVEVARS_WATERACCELERATE               = 248;
- const float STAT_MOVEVARS_ENTGRAVITY                    = 249;
- const float STAT_MOVEVARS_JUMPVELOCITY                  = 250;
- const float STAT_MOVEVARS_EDGEFRICTION                  = 251;
- const float STAT_MOVEVARS_MAXAIRSPEED                   = 252;
- const float STAT_MOVEVARS_STEPHEIGHT                    = 253;
- const float STAT_MOVEVARS_AIRACCEL_QW                   = 254;
- const float STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION    = 255;
+ const int STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR     = 220;
+ const int STAT_MOVEVARS_AIRCONTROL_PENALTY            = 221;
+ const int STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW           = 222;
+ const int STAT_MOVEVARS_AIRSTRAFEACCEL_QW             = 223;
+ const int STAT_MOVEVARS_AIRCONTROL_POWER              = 224;
+ const int STAT_MOVEFLAGS                              = 225;
+ const int STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL   = 226;
+ const int STAT_MOVEVARS_WARSOWBUNNY_ACCEL             = 227;
+ const int STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED          = 228;
+ const int STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL         = 229;
+ const int STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO   = 230;
+ const int STAT_MOVEVARS_AIRSTOPACCELERATE             = 231;
+ const int STAT_MOVEVARS_AIRSTRAFEACCELERATE           = 232;
+ const int STAT_MOVEVARS_MAXAIRSTRAFESPEED             = 233;
+ const int STAT_MOVEVARS_AIRCONTROL                    = 234;
+ const int STAT_FRAGLIMIT                              = 235;
+ const int STAT_TIMELIMIT                              = 236;
+ const int STAT_MOVEVARS_WALLFRICTION                  = 237;
+ const int STAT_MOVEVARS_FRICTION                      = 238;
+ const int STAT_MOVEVARS_WATERFRICTION                 = 239;
+ const int STAT_MOVEVARS_TICRATE                       = 240;
+ const int STAT_MOVEVARS_TIMESCALE                     = 241;
+ const int STAT_MOVEVARS_GRAVITY                       = 242;
+ const int STAT_MOVEVARS_STOPSPEED                     = 243;
+ const int STAT_MOVEVARS_MAXSPEED                      = 244;
+ const int STAT_MOVEVARS_SPECTATORMAXSPEED             = 245;
+ const int STAT_MOVEVARS_ACCELERATE                    = 246;
+ const int STAT_MOVEVARS_AIRACCELERATE                 = 247;
+ const int STAT_MOVEVARS_WATERACCELERATE               = 248;
+ const int STAT_MOVEVARS_ENTGRAVITY                    = 249;
+ const int STAT_MOVEVARS_JUMPVELOCITY                  = 250;
+ const int STAT_MOVEVARS_EDGEFRICTION                  = 251;
+ const int STAT_MOVEVARS_MAXAIRSPEED                   = 252;
+ const int STAT_MOVEVARS_STEPHEIGHT                    = 253;
+ const int STAT_MOVEVARS_AIRACCEL_QW                   = 254;
+ const int STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION    = 255;
+ #endif
index 611564da2834ba1afb03ae9eb7a88d21913d8e5d,bcb9d28d70240e779e942a25b3c5764e7252298a..89f7caf780c94f2f99e7898ed94abbbd5783ea34
@@@ -1,9 -1,12 +1,12 @@@
- float autocvar__notarget;
- float autocvar__independent_players;
- float autocvar__campaign_testrun;
- float autocvar__campaign_index;
+ #ifndef SERVER_AUTOCVARS_H
+ #define SERVER_AUTOCVARS_H
+ bool autocvar__notarget;
+ bool autocvar__independent_players;
+ bool autocvar__campaign_testrun;
+ int autocvar__campaign_index;
  string autocvar__campaign_name;
float autocvar__sv_init;
bool autocvar__sv_init;
  float autocvar_bot_ai_aimskill_blendrate;
  float autocvar_bot_ai_aimskill_firetolerance_distdegrees;
  float autocvar_bot_ai_aimskill_firetolerance_maxdegrees;
@@@ -43,63 -46,63 +46,63 @@@ float autocvar_bot_ai_navigation_jetpac
  float autocvar_bot_ai_navigation_jetpack_mindistance;
  float autocvar_bot_ai_strategyinterval;
  float autocvar_bot_ai_thinkinterval;
float autocvar_bot_ai_weapon_combo;
bool autocvar_bot_ai_weapon_combo;
  float autocvar_bot_ai_weapon_combo_threshold;
  string autocvar_bot_config_file;
float autocvar_bot_god;
float autocvar_bot_ignore_bots;
float autocvar_bot_join_empty;
float autocvar_bot_navigation_ignoreplayers;
float autocvar_bot_nofire;
bool autocvar_bot_god;
bool autocvar_bot_ignore_bots;
bool autocvar_bot_join_empty;
bool autocvar_bot_navigation_ignoreplayers;
bool autocvar_bot_nofire;
  #define autocvar_bot_number cvar("bot_number")
  #define autocvar_bot_prefix cvar_string("bot_prefix")
float autocvar_bot_sound_monopoly;
bool autocvar_bot_sound_monopoly;
  #define autocvar_bot_suffix cvar_string("bot_suffix")
float autocvar_bot_usemodelnames;
float autocvar_bot_vs_human;
float autocvar_bot_debug;
float autocvar_bot_debug_tracewalk;
float autocvar_bot_debug_goalstack;
float autocvar_bot_wander_enable;
float autocvar_captureleadlimit_override;
bool autocvar_bot_usemodelnames;
int autocvar_bot_vs_human;
int autocvar_bot_debug;
bool autocvar_bot_debug_tracewalk;
bool autocvar_bot_debug_goalstack;
bool autocvar_bot_wander_enable;
int autocvar_captureleadlimit_override;
  #define autocvar_capturelimit_override cvar("capturelimit_override")
  #define autocvar_developer cvar("developer")
  float autocvar_ekg;
  #define autocvar_fraglimit cvar("fraglimit")
  #define autocvar_fraglimit_override cvar("fraglimit_override")
float autocvar_g_allow_oldvortexbeam;
float autocvar_g_antilag;
bool autocvar_g_allow_oldvortexbeam;
int autocvar_g_antilag;
  float autocvar_g_antilag_nudge;
  float autocvar_g_balance_armor_blockpercent;
float autocvar_g_balance_armor_limit;
int autocvar_g_balance_armor_limit;
  float autocvar_g_balance_armor_regen;
- float autocvar_g_balance_armor_regenlinear;
float autocvar_g_balance_armor_regenstable;
+ float autocvar_g_balance_armor_regenlinear; // TODO: int/bool?
int autocvar_g_balance_armor_regenstable;
  float autocvar_g_balance_armor_rot;
  float autocvar_g_balance_armor_rotlinear;
float autocvar_g_balance_armor_rotstable;
float autocvar_g_balance_armor_start;
int autocvar_g_balance_armor_rotstable;
int autocvar_g_balance_armor_start;
  float autocvar_g_balance_cloaked_alpha;
  float autocvar_g_balance_contents_damagerate;
  float autocvar_g_balance_contents_drowndelay;
float autocvar_g_balance_contents_playerdamage_drowning;
float autocvar_g_balance_contents_playerdamage_lava;
float autocvar_g_balance_contents_playerdamage_slime;
float autocvar_g_balance_contents_projectiledamage;
int autocvar_g_balance_contents_playerdamage_drowning;
int autocvar_g_balance_contents_playerdamage_lava;
int autocvar_g_balance_contents_playerdamage_slime;
int autocvar_g_balance_contents_projectiledamage;
  float autocvar_g_balance_damagepush_speedfactor;
  float autocvar_g_balance_falldamage_deadminspeed;
  float autocvar_g_balance_falldamage_factor;
float autocvar_g_balance_falldamage_maxdamage;
int autocvar_g_balance_falldamage_maxdamage;
  float autocvar_g_balance_falldamage_minspeed;
float autocvar_g_balance_firetransfer_damage;
float autocvar_g_balance_firetransfer_time;
int autocvar_g_balance_firetransfer_damage;
int autocvar_g_balance_firetransfer_time;
  float autocvar_g_balance_fuel_limit;
  float autocvar_g_balance_fuel_regen;
  float autocvar_g_balance_fuel_regenlinear;
float autocvar_g_balance_fuel_regenstable;
int autocvar_g_balance_fuel_regenstable;
  float autocvar_g_balance_fuel_rot;
  float autocvar_g_balance_fuel_rotlinear;
float autocvar_g_balance_fuel_rotstable;
int autocvar_g_balance_fuel_rotstable;
  float autocvar_g_balance_grapplehook_airfriction;
  float autocvar_g_balance_grapplehook_force_rubber;
  float autocvar_g_balance_grapplehook_force_rubber_overstretch;
@@@ -221,13 -224,13 +224,13 @@@ float autocvar_g_chat_flood_spl_tell
  float autocvar_g_chat_nospectators;
  float autocvar_g_chat_teamcolors;
  float autocvar_g_chat_tellprivacy;
--float autocvar_g_ctf_allow_vehicle_carry;
--float autocvar_g_ctf_allow_vehicle_touch;
--float autocvar_g_ctf_allow_monster_touch;
--float autocvar_g_ctf_throw;
++bool autocvar_g_ctf_allow_vehicle_carry;
++bool autocvar_g_ctf_allow_vehicle_touch;
++bool autocvar_g_ctf_allow_monster_touch;
++bool autocvar_g_ctf_throw;
  float autocvar_g_ctf_throw_angle_max;
  float autocvar_g_ctf_throw_angle_min;
--float autocvar_g_ctf_throw_punish_count;
++int autocvar_g_ctf_throw_punish_count;
  float autocvar_g_ctf_throw_punish_delay;
  float autocvar_g_ctf_throw_punish_time;
  float autocvar_g_ctf_throw_strengthmultiplier;
@@@ -235,9 -238,8 +238,9 @@@ float autocvar_g_ctf_throw_velocity_for
  float autocvar_g_ctf_throw_velocity_up;
  float autocvar_g_ctf_drop_velocity_up;
  float autocvar_g_ctf_drop_velocity_side;
- float autocvar_g_ctf_oneflag_reverse;
++bool autocvar_g_ctf_oneflag_reverse;
  float autocvar_g_ctf_portalteleport;
--float autocvar_g_ctf_pass;
++bool autocvar_g_ctf_pass;
  float autocvar_g_ctf_pass_arc;
  float autocvar_g_ctf_pass_arc_max;
  float autocvar_g_ctf_pass_directional_max;
@@@ -248,30 -250,21 +251,30 @@@ float autocvar_g_ctf_pass_request
  float autocvar_g_ctf_pass_turnrate;
  float autocvar_g_ctf_pass_timelimit;
  float autocvar_g_ctf_pass_velocity;
--float autocvar_g_ctf_dynamiclights;
++bool autocvar_g_ctf_dynamiclights;
  string autocvar_g_ctf_flag_blue_model;
--float autocvar_g_ctf_flag_blue_skin;
++int autocvar_g_ctf_flag_blue_skin;
  float autocvar_g_ctf_flag_collect_delay;
  float autocvar_g_ctf_flag_damageforcescale;
--float autocvar_g_ctf_flag_dropped_waypoint;
--float autocvar_g_ctf_flag_dropped_floatinwater;
--float autocvar_g_ctf_flag_glowtrails;
--float autocvar_g_ctf_flag_health;
++bool autocvar_g_ctf_flag_dropped_waypoint;
++bool autocvar_g_ctf_flag_dropped_floatinwater;
++bool autocvar_g_ctf_flag_glowtrails;
++int autocvar_g_ctf_flag_health;
 +string autocvar_g_ctf_flag_neutral_model;
- float autocvar_g_ctf_flag_neutral_skin;
++int autocvar_g_ctf_flag_neutral_skin;
 +string autocvar_g_ctf_flag_pink_model;
- float autocvar_g_ctf_flag_pink_skin;
++int autocvar_g_ctf_flag_pink_skin;
  string autocvar_g_ctf_flag_red_model;
--float autocvar_g_ctf_flag_red_skin;
- float autocvar_g_ctf_flag_return;
++int autocvar_g_ctf_flag_red_skin;
++bool autocvar_g_ctf_flag_return;
 +float autocvar_g_ctf_flag_return_carried_radius;
  float autocvar_g_ctf_flag_return_time;
  float autocvar_g_ctf_flag_return_when_unreachable;
  float autocvar_g_ctf_flag_return_damage;
 +float autocvar_g_ctf_flag_return_damage_delay;
  float autocvar_g_ctf_flag_return_dropped;
- float autocvar_g_ctf_flag_yellow_skin;
 +string autocvar_g_ctf_flag_yellow_model;
++int autocvar_g_ctf_flag_yellow_skin;
  float autocvar_g_ctf_flagcarrier_auto_helpme_damage;
  float autocvar_g_ctf_flagcarrier_auto_helpme_time;
  float autocvar_g_ctf_flagcarrier_selfdamagefactor;
@@@ -279,25 -272,25 +282,25 @@@ float autocvar_g_ctf_flagcarrier_selffo
  float autocvar_g_ctf_flagcarrier_damagefactor;
  float autocvar_g_ctf_flagcarrier_forcefactor;
  //float autocvar_g_ctf_flagcarrier_waypointforenemy_spotting;
--float autocvar_g_ctf_fullbrightflags;
--float autocvar_g_ctf_ignore_frags;
--float autocvar_g_ctf_score_capture;
--float autocvar_g_ctf_score_capture_assist;
--float autocvar_g_ctf_score_kill;
--float autocvar_g_ctf_score_penalty_drop;
++bool autocvar_g_ctf_fullbrightflags;
++bool autocvar_g_ctf_ignore_frags;
++int autocvar_g_ctf_score_capture;
++int autocvar_g_ctf_score_capture_assist;
++int autocvar_g_ctf_score_kill;
++int autocvar_g_ctf_score_penalty_drop;
  //float autocvar_g_ctf_score_penalty_suicidedrop;
--float autocvar_g_ctf_score_penalty_returned;
--float autocvar_g_ctf_score_pickup_base;
--float autocvar_g_ctf_score_pickup_dropped_early;
--float autocvar_g_ctf_score_pickup_dropped_late;
--float autocvar_g_ctf_score_return;
++int autocvar_g_ctf_score_penalty_returned;
++int autocvar_g_ctf_score_pickup_base;
++int autocvar_g_ctf_score_pickup_dropped_early;
++int autocvar_g_ctf_score_pickup_dropped_late;
++int autocvar_g_ctf_score_return;
  float autocvar_g_ctf_shield_force;
  float autocvar_g_ctf_shield_max_ratio;
  float autocvar_g_ctf_shield_min_negscore;
--float autocvar_g_ctf_stalemate;
--float autocvar_g_ctf_stalemate_endcondition;
++bool autocvar_g_ctf_stalemate;
++int autocvar_g_ctf_stalemate_endcondition;
  float autocvar_g_ctf_stalemate_time;
--float autocvar_g_ctf_reverse;
++bool autocvar_g_ctf_reverse;
  float autocvar_g_ctf_dropped_capture_delay;
  float autocvar_g_ctf_dropped_capture_radius;
  float autocvar_g_cts_finish_kill_delay;
@@@ -410,7 -403,7 +413,7 @@@ float autocvar_g_instagib_invis_alpha
  #define autocvar_g_mirrordamage cvar("g_mirrordamage")
  #define autocvar_g_mirrordamage_virtual cvar("g_mirrordamage_virtual")
  
var float autocvar_g_movement_highspeed = 1;
+ float autocvar_g_movement_highspeed = 1;
  float autocvar_g_multijump;
  float autocvar_g_multijump_add;
  float autocvar_g_multijump_speed;
@@@ -593,7 -586,7 +596,7 @@@ float autocvar_snd_soundradius
  float autocvar_spawn_debug;
  float autocvar_speedmeter;
  float autocvar_sv_accelerate;
var float autocvar_sv_accuracy_data_share = 1;
+ float autocvar_sv_accuracy_data_share = 1;
  string autocvar_sv_adminnick;
  float autocvar_sv_airaccel_qw;
  float autocvar_sv_airaccel_qw_stretchfactor;
@@@ -805,7 -798,7 +808,7 @@@ float autocvar_g_nades_nade_edgedamage
  float autocvar_g_nades_nade_radius;
  float autocvar_g_nades_nade_force;
  float autocvar_g_nades_nade_newton_style;
float autocvar_g_nades_napalm_ball_count;
int autocvar_g_nades_napalm_ball_count;
  float autocvar_g_nades_napalm_ball_spread;
  float autocvar_g_nades_napalm_ball_damage;
  float autocvar_g_nades_napalm_ball_damageforcescale;
@@@ -889,4 -882,4 +892,4 @@@ float autocvar_g_buffs_vampire_damage_s
  float autocvar_g_buffs_invisible_alpha;
  float autocvar_g_buffs_flight_gravity;
  float autocvar_g_buffs_jump_height;
+ #endif
index ae657b4c68152158a5312141fa73502389a2f728,2e6eb4ff732533e927fc4359459ea5fec9f940f6..bb09d734ab3d5bd8736ac81a67d50d4839af3a7b
@@@ -14,11 -14,10 +14,11 @@@ void ctf_FakeTimeLimit(entity e, float 
                WriteCoord(MSG_ONE, (t + 1) / 60);
  }
  
--void ctf_EventLog(string mode, float flagteam, entity actor) // use an alias for easy changing and quick editing later
++void ctf_EventLog(string mode, int flagteam, entity actor) // use an alias for easy changing and quick editing later
  {
        if(autocvar_sv_eventlog)
 -              GameLogEcho(strcat(":ctf:", mode, ":", ftos(flagteam), ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
 +              GameLogEcho(sprintf(":ctf:%s:%d:%d:%s", mode, flagteam, actor.team, ((actor != world) ? ftos(actor.playerid) : "")));
 +              //GameLogEcho(strcat(":ctf:", mode, ":", ftos(flagteam), ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
  }
  
  void ctf_CaptureRecord(entity flag, entity player)
        string refername = db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"));
  
        // notify about shit
 -      if(!ctf_captimerecord) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_2(flag, CHOICE_CTF_CAPTURE_TIME_), player.netname, (cap_time * 100)); }
 -      else if(cap_time < cap_record) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_2(flag, CHOICE_CTF_CAPTURE_BROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); }
 -      else { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_2(flag, CHOICE_CTF_CAPTURE_UNBROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); }
 +      if(ctf_oneflag) { Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_CTF_CAPTURE_NEUTRAL, player.netname); }
 +      else if(!ctf_captimerecord) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_CAPTURE_TIME_), player.netname, (cap_time * 100)); }
 +      else if(cap_time < cap_record) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_CAPTURE_BROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); }
 +      else { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_CAPTURE_UNBROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); }
  
        // write that shit in the database
 +      if(!ctf_oneflag) // but not in 1-flag mode
        if((!ctf_captimerecord) || (cap_time < cap_record))
        {
                ctf_captimerecord = cap_time;
@@@ -46,7 -43,7 +46,7 @@@
  
  void ctf_FlagcarrierWaypoints(entity player)
  {
-       WaypointSprite_Spawn("flagcarrier", 0, 0, player, FLAG_WAYPOINT_OFFSET, world, player.team, player, wps_flagcarrier, TRUE, RADARICON_FLAG, WPCOLOR_FLAGCARRIER(player.team));
+       WaypointSprite_Spawn("flagcarrier", 0, 0, player, FLAG_WAYPOINT_OFFSET, world, player.team, player, wps_flagcarrier, true, RADARICON_FLAG, WPCOLOR_FLAGCARRIER(player.team));
        WaypointSprite_UpdateMaxHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON) * 2);
        WaypointSprite_UpdateHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(player.health, player.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON));
        WaypointSprite_UpdateTeamRadar(player.wps_flagcarrier, RADARICON_FLAGCARRIER, WPCOLOR_FLAGCARRIER(player.team));
@@@ -54,7 -51,7 +54,7 @@@
  
  void ctf_CalculatePassVelocity(entity flag, vector to, vector from, float turnrate)
  {
-       float current_distance = vlen((('1 0 0' * to_x) + ('0 1 0' * to_y)) - (('1 0 0' * from_x) + ('0 1 0' * from_y))); // for the sake of this check, exclude Z axis
+       float current_distance = vlen((('1 0 0' * to.x) + ('0 1 0' * to.y)) - (('1 0 0' * from.x) + ('0 1 0' * from.y))); // for the sake of this check, exclude Z axis
        float initial_height = min(autocvar_g_ctf_pass_arc_max, (flag.pass_distance * tanh(autocvar_g_ctf_pass_arc)));
        float current_height = (initial_height * min(1, (current_distance / flag.pass_distance)));
        //print("current_height = ", ftos(current_height), ", initial_height = ", ftos(initial_height), ".\n");
@@@ -83,7 -80,7 +83,7 @@@
        else { flag.velocity = (desired_direction * autocvar_g_ctf_pass_velocity); }
  }
  
--float ctf_CheckPassDirection(vector head_center, vector passer_center, vector passer_angle, vector nearest_to_passer)
++bool ctf_CheckPassDirection(vector head_center, vector passer_center, vector passer_angle, vector nearest_to_passer)
  {
        if(autocvar_g_ctf_pass_directional_max || autocvar_g_ctf_pass_directional_min)
        {
                spreadlimit = (autocvar_g_ctf_pass_directional_min * (1 - spreadlimit) + autocvar_g_ctf_pass_directional_max * spreadlimit);
  
                if(spreadlimit && (distance_from_line <= spreadlimit) && ((vlen(normalize(head_center - passer_center) - v_forward) * RAD2DEG) <= 90))
-                       { return TRUE; }
+                       { return true; }
                else
-                       { return FALSE; }
+                       { return false; }
        }
-       else { return TRUE; }
+       else { return true; }
  }
  
  
  // CaptureShield Functions
  // =======================
  
--float ctf_CaptureShield_CheckStatus(entity p)
++bool ctf_CaptureShield_CheckStatus(entity p)
  {
 -      float s, se;
 +      float s, s2, s3, s4, se, se2, se3, se4, sr, ser;
        entity e;
        float players_worseeq, players_total;
  
        if(ctf_captureshield_max_ratio <= 0)
-               return FALSE;
+               return false;
  
 -      s = PlayerScore_Add(p, SP_SCORE, 0);
 -      if(s >= -ctf_captureshield_min_negscore)
 +      s = PlayerScore_Add(p, SP_CTF_CAPS, 0);
 +      s2 = PlayerScore_Add(p, SP_CTF_PICKUPS, 0);
 +      s3 = PlayerScore_Add(p, SP_CTF_RETURNS, 0);
 +      s4 = PlayerScore_Add(p, SP_CTF_FCKILLS, 0);
 +
 +      sr = ((s - s2) + (s3 + s4));
 +
 +      if(sr >= -ctf_captureshield_min_negscore)
-               return FALSE;
+               return false;
  
        players_total = players_worseeq = 0;
        FOR_EACH_PLAYER(e)
        {
                if(DIFF_TEAM(e, p))
                        continue;
 -              se = PlayerScore_Add(e, SP_SCORE, 0);
 -              if(se <= s)
 +              se = PlayerScore_Add(e, SP_CTF_CAPS, 0);
 +              se2 = PlayerScore_Add(e, SP_CTF_PICKUPS, 0);
 +              se3 = PlayerScore_Add(e, SP_CTF_RETURNS, 0);
 +              se4 = PlayerScore_Add(e, SP_CTF_FCKILLS, 0);
 +
 +              ser = ((se - se2) + (se3 + se4));
 +
 +              if(ser <= sr)
                        ++players_worseeq;
                ++players_total;
        }
        // use this rule here
  
        if(players_worseeq >= players_total * ctf_captureshield_max_ratio)
-               return FALSE;
+               return false;
  
-       return TRUE;
+       return true;
  }
  
--void ctf_CaptureShield_Update(entity player, float wanted_status)
++void ctf_CaptureShield_Update(entity player, bool wanted_status)
  {
--      float updated_status = ctf_CaptureShield_CheckStatus(player);
++      bool updated_status = ctf_CaptureShield_CheckStatus(player);
        if((wanted_status == player.ctf_captureshielded) && (updated_status != wanted_status)) // 0: shield only, 1: unshield only
        {
                Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((updated_status) ? CENTER_CTF_CAPTURESHIELD_SHIELDED : CENTER_CTF_CAPTURESHIELD_FREE));
        }
  }
  
--float ctf_CaptureShield_Customize()
++bool ctf_CaptureShield_Customize()
  {
-       if(self.enemy.active != ACTIVE_ACTIVE) { return TRUE; }
-       if(!other.ctf_captureshielded) { return FALSE; }
-       if(CTF_SAMETEAM(self, other)) { return FALSE; }
++      if(self.enemy.active != ACTIVE_ACTIVE) { return true; }
+       if(!other.ctf_captureshielded) { return false; }
 -      if(SAME_TEAM(self, other)) { return false; }
++      if(CTF_SAMETEAM(self, other)) { return false; }
  
-       return TRUE;
+       return true;
  }
  
  void ctf_CaptureShield_Touch()
  {
 +      if(self.enemy.active != ACTIVE_ACTIVE)
 +      {
 +              vector mymid = (self.absmin + self.absmax) * 0.5;
 +              vector othermid = (other.absmin + other.absmax) * 0.5;
 +
 +              Damage(other, self, self, 0, DEATH_HURTTRIGGER, mymid, normalize(othermid - mymid) * ctf_captureshield_force);
 +              if(IS_REAL_CLIENT(other)) { Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_CTF_CAPTURESHIELD_INACTIVE); }
 +
 +              return;
 +      }
 +
        if(!other.ctf_captureshielded) { return; }
 -      if(SAME_TEAM(self, other)) { return; }
 +      if(CTF_SAMETEAM(self, other)) { return; }
  
        vector mymid = (self.absmin + self.absmax) * 0.5;
        vector othermid = (other.absmin + other.absmax) * 0.5;
@@@ -231,7 -204,7 +231,7 @@@ void ctf_CaptureShield_Spawn(entity fla
  // Drop/Pass/Throw Code
  // ====================
  
--void ctf_Handle_Drop(entity flag, entity player, float droptype)
++void ctf_Handle_Drop(entity flag, entity player, int droptype)
  {
        // declarations
        player = (player ? player : flag.pass_sender);
        flag.ctf_status = FLAG_DROPPED;
  
        // messages and sounds
 -      Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_LOST_), player.netname);
 +      Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_LOST_) : INFO_CTF_LOST_NEUTRAL), player.netname);
        sound(flag, CH_TRIGGER, flag.snd_flag_dropped, VOL_BASE, ATTEN_NONE);
        ctf_EventLog("dropped", player.team, player);
  
  
        // waypoints
        if(autocvar_g_ctf_flag_dropped_waypoint)
-               WaypointSprite_Spawn("flagdropped", 0, 0, flag, FLAG_WAYPOINT_OFFSET, world, ((autocvar_g_ctf_flag_dropped_waypoint == 2) ? 0 : player.team), flag, wps_flagdropped, TRUE, RADARICON_FLAG, WPCOLOR_DROPPEDFLAG(flag.team));
+               WaypointSprite_Spawn("flagdropped", 0, 0, flag, FLAG_WAYPOINT_OFFSET, world, ((autocvar_g_ctf_flag_dropped_waypoint == 2) ? 0 : player.team), flag, wps_flagdropped, true, RADARICON_FLAG, WPCOLOR_DROPPEDFLAG(flag.team));
  
        if(autocvar_g_ctf_flag_return_time || (autocvar_g_ctf_flag_return_damage && autocvar_g_ctf_flag_health))
        {
@@@ -308,11 -281,11 +308,11 @@@ void ctf_Handle_Retrieve(entity flag, e
        FOR_EACH_REALPLAYER(tmp_player)
        {
                if(tmp_player == sender)
 -                      Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_2(flag, CENTER_CTF_PASS_SENT_), player.netname);
 +                      Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, ((flag.team) ? APP_TEAM_ENT_4(flag, CENTER_CTF_PASS_SENT_) : CENTER_CTF_PASS_SENT_NEUTRAL), player.netname);
                else if(tmp_player == player)
 -                      Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_2(flag, CENTER_CTF_PASS_RECEIVED_), sender.netname);
 +                      Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, ((flag.team) ? APP_TEAM_ENT_4(flag, CENTER_CTF_PASS_RECEIVED_) : CENTER_CTF_PASS_RECEIVED_NEUTRAL), sender.netname);
                else if(SAME_TEAM(tmp_player, sender))
 -                      Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_2(flag, CENTER_CTF_PASS_OTHER_), sender.netname, player.netname);
 +                      Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, ((flag.team) ? APP_TEAM_ENT_4(flag, CENTER_CTF_PASS_OTHER_) : CENTER_CTF_PASS_OTHER_NEUTRAL), sender.netname, player.netname);
        }
  
        // create new waypoint
        flag.pass_target = world;
  }
  
--void ctf_Handle_Throw(entity player, entity receiver, float droptype)
++void ctf_Handle_Throw(entity player, entity receiver, int droptype)
  {
        entity flag = player.flagcarried;
        vector targ_origin, flag_velocity;
                        WarpZone_RefSys_AddInverse(flag, receiver); // wz1^-1 ... wzn^-1 receiver
                        targ_origin = WarpZone_RefSys_TransformOrigin(receiver, flag, (0.5 * (receiver.absmin + receiver.absmax))); // this is target origin as seen by the flag
  
-                       flag.pass_distance = vlen((('1 0 0' * targ_origin_x) + ('0 1 0' * targ_origin_y)) - (('1 0 0' *  player.origin_x) + ('0 1 0' *  player.origin_y))); // for the sake of this check, exclude Z axis
-                       ctf_CalculatePassVelocity(flag, targ_origin, player.origin, FALSE);
+                       flag.pass_distance = vlen((('1 0 0' * targ_origin.x) + ('0 1 0' * targ_origin.y)) - (('1 0 0' *  player.origin.x) + ('0 1 0' *  player.origin.y))); // for the sake of this check, exclude Z axis
+                       ctf_CalculatePassVelocity(flag, targ_origin, player.origin, false);
  
                        // main
                        flag.movetype = MOVETYPE_FLY;
  
                case DROP_THROW:
                {
-                       makevectors((player.v_angle_y * '0 1 0') + (bound(autocvar_g_ctf_throw_angle_min, player.v_angle_x, autocvar_g_ctf_throw_angle_max) * '1 0 0'));
+                       makevectors((player.v_angle.y * '0 1 0') + (bound(autocvar_g_ctf_throw_angle_min, player.v_angle.x, autocvar_g_ctf_throw_angle_max) * '1 0 0'));
  
                        flag_velocity = (('0 0 1' * autocvar_g_ctf_throw_velocity_up) + ((v_forward * autocvar_g_ctf_throw_velocity_forward) * ((player.items & IT_STRENGTH) ? autocvar_g_ctf_throw_strengthmultiplier : 1)));
-                       flag.velocity = W_CalculateProjectileVelocity(player.velocity, flag_velocity, FALSE);
+                       flag.velocity = W_CalculateProjectileVelocity(player.velocity, flag_velocity, false);
                        ctf_Handle_Drop(flag, player, droptype);
                        break;
                }
                default:
                case DROP_NORMAL:
                {
-                       flag.velocity = W_CalculateProjectileVelocity(player.velocity, (('0 0 1' * autocvar_g_ctf_drop_velocity_up) + ((('0 1 0' * crandom()) + ('1 0 0' * crandom())) * autocvar_g_ctf_drop_velocity_side)), FALSE);
+                       flag.velocity = W_CalculateProjectileVelocity(player.velocity, (('0 0 1' * autocvar_g_ctf_drop_velocity_up) + ((('0 1 0' * crandom()) + ('1 0 0' * crandom())) * autocvar_g_ctf_drop_velocity_side)), false);
                        ctf_Handle_Drop(flag, player, droptype);
                        break;
                }
  // Event Handlers
  // ==============
  
--void ctf_Handle_Capture(entity flag, entity toucher, float capturetype)
++void ctf_Handle_Capture(entity flag, entity toucher, int capturetype)
  {
        entity enemy_flag = ((capturetype == CAPTURE_NORMAL) ? toucher.flagcarried : toucher);
        entity player = ((capturetype == CAPTURE_NORMAL) ? toucher : enemy_flag.ctf_dropper);
 +      entity player_team_flag = world, tmp_entity;
        float old_time, new_time;
  
 -      if (!player) { return; } // without someone to give the reward to, we can't possibly cap
 +      if(!player) { return; } // without someone to give the reward to, we can't possibly cap
 +      if(CTF_DIFFTEAM(player, flag)) { return; }
 +      
 +      if(ctf_oneflag)
 +      for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext)
 +      if(SAME_TEAM(tmp_entity, player))
 +      {
 +              player_team_flag = tmp_entity;
 +              break;
 +      }
  
        nades_GiveBonus(player, autocvar_g_nades_bonus_score_high );
  
 +      player.throw_prevtime = time;
 +      player.throw_count = 0;
 +
        // messages and sounds
 -      Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_2(enemy_flag, CENTER_CTF_CAPTURE_));
 +      Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((enemy_flag.team) ? APP_TEAM_ENT_4(enemy_flag, CENTER_CTF_CAPTURE_) : CENTER_CTF_CAPTURE_NEUTRAL));
        ctf_CaptureRecord(enemy_flag, player);
 -      sound(player, CH_TRIGGER, flag.snd_flag_capture, VOL_BASE, ATTEN_NONE);
 +      sound(player, CH_TRIGGER, ((ctf_oneflag) ? player_team_flag.snd_flag_capture : ((DIFF_TEAM(player, flag)) ? enemy_flag.snd_flag_capture : flag.snd_flag_capture)), VOL_BASE, ATTEN_NONE);
  
        switch(capturetype)
        {
@@@ -484,12 -444,12 +484,12 @@@ void ctf_Handle_Return(entity flag, ent
        // messages and sounds
        if(player.flags & FL_MONSTER)
        {
 -              Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_RETURN_MONSTER_), player.monster_name);
 +              Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_RETURN_MONSTER_), player.monster_name);
        }
 -      else
 +      else if(flag.team)
        {
 -              Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_2(flag, CENTER_CTF_RETURN_));
 -              Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_RETURN_), player.netname);
 +              Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_RETURN_));
 +              Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_RETURN_), player.netname);
        }
        sound(player, CH_TRIGGER, flag.snd_flag_returned, VOL_BASE, ATTEN_NONE);
        ctf_EventLog("return", flag.team, player);
                flag.ctf_dropper.next_take_time = time + autocvar_g_ctf_flag_collect_delay; // set next take time
        }
  
 +      // other
 +      if(player.flagcarried == flag)
 +              WaypointSprite_Kill(player.wps_flagcarrier);
 +
        // reset the flag
        ctf_RespawnFlag(flag);
  }
  
--void ctf_Handle_Pickup(entity flag, entity player, float pickuptype)
++void ctf_Handle_Pickup(entity flag, entity player, int pickuptype)
  {
        // declarations
        float pickup_dropped_score; // used to calculate dropped pickup score
 +      entity tmp_entity; // temporary entity
  
        // attach the flag to the player
        flag.owner = player;
        }
  
        // messages and sounds
 -      Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_PICKUP_), player.netname);
 -      Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_2(flag, CENTER_CTF_PICKUP_));
 +      Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_PICKUP_) : INFO_CTF_PICKUP_NEUTRAL), player.netname);
        if(ctf_stalemate) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_STALEMATE_CARRIER); }
 -
 -      Send_Notification(NOTIF_TEAM_EXCEPT, player, MSG_CHOICE, CHOICE_CTF_PICKUP_TEAM, Team_ColorCode(player.team), player.netname);
 -      Send_Notification(NOTIF_TEAM, flag, MSG_CHOICE, CHOICE_CTF_PICKUP_ENEMY, Team_ColorCode(player.team), player.netname);
 +      if(!flag.team) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_PICKUP_NEUTRAL); }
 +      else if(CTF_DIFFTEAM(player, flag)) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_PICKUP_)); }
 +      else { Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((SAME_TEAM(player, flag)) ? CENTER_CTF_PICKUP_TEAM : CENTER_CTF_PICKUP_TEAM_ENEMY), Team_ColorCode(flag.team)); }
 +
 +      Send_Notification(NOTIF_TEAM_EXCEPT, player, MSG_CHOICE, ((flag.team) ? APP_TEAM_ENT_4(flag, CHOICE_CTF_PICKUP_TEAM_) : CHOICE_CTF_PICKUP_TEAM_NEUTRAL), Team_ColorCode(player.team), player.netname);
 +      
 +      if(!flag.team)
 +      FOR_EACH_PLAYER(tmp_entity)
 +      if(tmp_entity != player)
 +      if(DIFF_TEAM(player, tmp_entity))
 +              Send_Notification(NOTIF_ONE, tmp_entity, MSG_CHOICE, CHOICE_CTF_PICKUP_ENEMY_NEUTRAL, Team_ColorCode(player.team), player.netname);
 +      
 +      if(flag.team)
 +      FOR_EACH_PLAYER(tmp_entity)
 +      if(tmp_entity != player)
 +      if(CTF_SAMETEAM(flag, tmp_entity))
 +      if(SAME_TEAM(player, tmp_entity))
 +              Send_Notification(NOTIF_ONE, tmp_entity, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_PICKUP_TEAM_), Team_ColorCode(player.team), player.netname);
 +      else
 +              Send_Notification(NOTIF_ONE, tmp_entity, MSG_CHOICE, ((SAME_TEAM(flag, player)) ? CHOICE_CTF_PICKUP_ENEMY_TEAM : CHOICE_CTF_PICKUP_ENEMY), Team_ColorCode(player.team), player.netname);
  
        sound(player, CH_TRIGGER, flag.snd_flag_taken, VOL_BASE, ATTEN_NONE);
  
  // Main Flag Functions
  // ===================
  
--void ctf_CheckFlagReturn(entity flag, float returntype)
++void ctf_CheckFlagReturn(entity flag, int returntype)
  {
        if((flag.ctf_status == FLAG_DROPPED) || (flag.ctf_status == FLAG_PASSING))
        {
                {
                        switch(returntype)
                        {
 -                              case RETURN_DROPPED: Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_FLAGRETURN_DROPPED_)); break;
 -                              case RETURN_DAMAGE: Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_FLAGRETURN_DAMAGED_)); break;
 -                              case RETURN_SPEEDRUN: Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_FLAGRETURN_SPEEDRUN_), ctf_captimerecord); break;
 -                              case RETURN_NEEDKILL: Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_FLAGRETURN_NEEDKILL_)); break;
 +                              case RETURN_DROPPED: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_DROPPED_) : INFO_CTF_FLAGRETURN_DROPPED_NEUTRAL)); break;
 +                              case RETURN_DAMAGE: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_DAMAGED_) : INFO_CTF_FLAGRETURN_DAMAGED_NEUTRAL)); break;
 +                              case RETURN_SPEEDRUN: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_SPEEDRUN_) : INFO_CTF_FLAGRETURN_SPEEDRUN_NEUTRAL), ctf_captimerecord); break;
 +                              case RETURN_NEEDKILL: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_NEEDKILL_) : INFO_CTF_FLAGRETURN_NEEDKILL_NEUTRAL)); break;
  
                                default:
                                case RETURN_TIMEOUT:
 -                                      { Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_FLAGRETURN_TIMEOUT_)); break; }
 +                                      { Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_TIMEOUT_) : INFO_CTF_FLAGRETURN_TIMEOUT_NEUTRAL)); break; }
                        }
                        sound(flag, CH_TRIGGER, flag.snd_flag_respawn, VOL_BASE, ATTEN_NONE);
                        ctf_EventLog("returned", flag.team, world);
        }
  }
  
- float ctf_Stalemate_Customize()
++bool ctf_Stalemate_Customize()
 +{
 +      // make spectators see what the player would see
 +      entity e, wp_owner;
 +      e = WaypointSprite_getviewentity(other);
 +      wp_owner = self.owner;
 +
 +      // team waypoints
-       if(CTF_SAMETEAM(wp_owner.flagcarried, wp_owner)) { return FALSE; }
-       if(SAME_TEAM(wp_owner, e)) { return FALSE; }
-       if(!IS_PLAYER(e)) { return FALSE; }
++      if(CTF_SAMETEAM(wp_owner.flagcarried, wp_owner)) { return false; }
++      if(SAME_TEAM(wp_owner, e)) { return false; }
++      if(!IS_PLAYER(e)) { return false; }
 +
-       return TRUE;
++      return true;
 +}
 +
  void ctf_CheckStalemate(void)
  {
        // declarations
-       float stale_flags = 0, stale_red_flags = 0, stale_blue_flags = 0, stale_yellow_flags = 0, stale_pink_flags = 0, stale_neutral_flags = 0;
 -      float stale_red_flags = 0, stale_blue_flags = 0;
++      int stale_flags = 0, stale_red_flags = 0, stale_blue_flags = 0, stale_yellow_flags = 0, stale_pink_flags = 0, stale_neutral_flags = 0;
        entity tmp_entity;
  
        entity ctf_staleflaglist = world; // reset the list, we need to build the list each time this function runs
        {
                if(autocvar_g_ctf_stalemate)
                if(tmp_entity.ctf_status != FLAG_BASE)
 -              if(time >= tmp_entity.ctf_pickuptime + autocvar_g_ctf_stalemate_time)
 +              if(time >= tmp_entity.ctf_pickuptime + autocvar_g_ctf_stalemate_time || !tmp_entity.team) // instant stalemate in oneflag
                {
                        tmp_entity.ctf_staleflagnext = ctf_staleflaglist; // link flag into staleflaglist
                        ctf_staleflaglist = tmp_entity;
                        {
                                case NUM_TEAM_1: ++stale_red_flags; break;
                                case NUM_TEAM_2: ++stale_blue_flags; break;
 +                              case NUM_TEAM_3: ++stale_yellow_flags; break;
 +                              case NUM_TEAM_4: ++stale_pink_flags; break;
 +                              default: ++stale_neutral_flags; break;
                        }
                }
        }
  
 -      if(stale_red_flags && stale_blue_flags)
 +      if(ctf_oneflag)
 +              stale_flags = (stale_neutral_flags >= 1);
 +      else
 +              stale_flags = (stale_red_flags >= 1) + (stale_blue_flags >= 1) + (stale_yellow_flags >= 1) + (stale_pink_flags >= 1);
 +
 +      if(ctf_oneflag && stale_flags == 1)
-               ctf_stalemate = TRUE;
++              ctf_stalemate = true;
 +      else if(stale_flags == ctf_teams)
-               ctf_stalemate = TRUE;
+               ctf_stalemate = true;
 -      else if((!stale_red_flags && !stale_blue_flags) && autocvar_g_ctf_stalemate_endcondition == 2)
 +      else if(stale_flags == 0 && autocvar_g_ctf_stalemate_endcondition == 2)
-               { ctf_stalemate = FALSE; wpforenemy_announced = FALSE; }
+               { ctf_stalemate = false; wpforenemy_announced = false; }
 -      else if((!stale_red_flags || !stale_blue_flags) && autocvar_g_ctf_stalemate_endcondition == 1)
 +      else if(stale_flags < ctf_teams && autocvar_g_ctf_stalemate_endcondition == 1)
-               { ctf_stalemate = FALSE; wpforenemy_announced = FALSE; }
+               { ctf_stalemate = false; wpforenemy_announced = false; }
  
        // if sufficient stalemate, then set up the waypointsprite and announce the stalemate if necessary
        if(ctf_stalemate)
                for(tmp_entity = ctf_staleflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_staleflagnext)
                {
                        if((tmp_entity.owner) && (!tmp_entity.owner.wps_enemyflagcarrier))
 -                              WaypointSprite_Spawn("enemyflagcarrier", 0, 0, tmp_entity.owner, FLAG_WAYPOINT_OFFSET, world, tmp_entity.team, tmp_entity.owner, wps_enemyflagcarrier, true, RADARICON_FLAG, WPCOLOR_ENEMYFC(tmp_entity.owner.team));
 +                      {
-                               WaypointSprite_Spawn(((ctf_oneflag) ? "flagcarrier" : "enemyflagcarrier"), 0, 0, tmp_entity.owner, FLAG_WAYPOINT_OFFSET, world, 0, tmp_entity.owner, wps_enemyflagcarrier, TRUE, RADARICON_FLAG, WPCOLOR_ENEMYFC(tmp_entity.owner.team));
++                              WaypointSprite_Spawn(((ctf_oneflag) ? "flagcarrier" : "enemyflagcarrier"), 0, 0, tmp_entity.owner, FLAG_WAYPOINT_OFFSET, world, 0, tmp_entity.owner, wps_enemyflagcarrier, true, RADARICON_FLAG, WPCOLOR_ENEMYFC(tmp_entity.owner.team));
 +                              tmp_entity.owner.wps_enemyflagcarrier.customizeentityforclient = ctf_Stalemate_Customize;
 +                      }
                }
  
                if (!wpforenemy_announced)
                        FOR_EACH_REALPLAYER(tmp_entity)
                                Send_Notification(NOTIF_ONE, tmp_entity, MSG_CENTER, ((tmp_entity.flagcarried) ? CENTER_CTF_STALEMATE_CARRIER : CENTER_CTF_STALEMATE_OTHER));
  
-                       wpforenemy_announced = TRUE;
+                       wpforenemy_announced = true;
                }
        }
  }
@@@ -738,15 -649,9 +738,15 @@@ void ctf_FlagDamage(entity inflictor, e
  {
        if(ITEM_DAMAGE_NEEDKILL(deathtype))
        {
 -              // automatically kill the flag and return it
 -              self.health = 0;
 -              ctf_CheckFlagReturn(self, RETURN_NEEDKILL);
 +              if(autocvar_g_ctf_flag_return_damage_delay)
 +              {
-                       self.ctf_flagdamaged = TRUE;
++                      self.ctf_flagdamaged = true;
 +              }
 +              else
 +              {
 +                      self.health = 0;
 +                      ctf_CheckFlagReturn(self, RETURN_NEEDKILL);
 +              }
                return;
        }
        if(autocvar_g_ctf_flag_return_damage)
@@@ -829,13 -734,7 +829,13 @@@ void ctf_FlagThink(
                                        return;
                                }
                        }
 -                      if(autocvar_g_ctf_flag_return_time)
 +                      if(self.ctf_flagdamaged)
 +                      {
 +                              self.health -= ((self.max_flag_health / autocvar_g_ctf_flag_return_damage_delay) * FLAG_THINKRATE);
 +                              ctf_CheckFlagReturn(self, RETURN_NEEDKILL);
 +                              return;
 +                      }
 +                      else if(autocvar_g_ctf_flag_return_time)
                        {
                                self.health -= ((self.max_flag_health / autocvar_g_ctf_flag_return_time) * FLAG_THINKRATE);
                                ctf_CheckFlagReturn(self, RETURN_TIMEOUT);
                                        wpforenemy_nextthink = time + WPFE_THINKRATE; // waypoint for enemy think rate (to reduce unnecessary spam of this check)
                                }
                        }
 +                      if(CTF_SAMETEAM(self, self.owner) && self.team)
 +                      {
 +                              if(autocvar_g_ctf_flag_return) // drop the flag if reverse status has changed
 +                                      ctf_Handle_Throw(self.owner, world, DROP_THROW);
 +                              else if(vlen(self.owner.origin - self.ctf_spawnorigin) <= autocvar_g_ctf_flag_return_carried_radius)
 +                                      ctf_Handle_Return(self, self.owner);
 +                      }
                        return;
                }
  
                        else
                        {
                                // still a viable target, go for it
-                               ctf_CalculatePassVelocity(self, targ_origin, self.origin, TRUE);
+                               ctf_CalculatePassVelocity(self, targ_origin, self.origin, true);
                        }
                        return;
                }
  void ctf_FlagTouch()
  {
        if(gameover) { return; }
 +      if(self.active != ACTIVE_ACTIVE) { return; }
        if(trace_dphitcontents & (DPCONTENTS_PLAYERCLIP | DPCONTENTS_MONSTERCLIP)) { return; }
  
 -      entity toucher = other;
 -      float is_not_monster = (!(toucher.flags & FL_MONSTER));
 +      entity toucher = other, tmp_entity;
-       float is_not_monster = (!(toucher.flags & FL_MONSTER)), num_perteam = 0;
++      bool is_not_monster = (!(toucher.flags & FL_MONSTER)), num_perteam = 0;
  
        // automatically kill the flag and return it if it touched lava/slime/nodrop surfaces
        if(ITEM_TOUCH_NEEDKILL())
        {
 -              self.health = 0;
 -              ctf_CheckFlagReturn(self, RETURN_NEEDKILL);
 -              return;
 +              if(!autocvar_g_ctf_flag_return_damage_delay)
 +              {
 +                      self.health = 0;
 +                      ctf_CheckFlagReturn(self, RETURN_NEEDKILL);
 +              }
 +              if(!self.ctf_flagdamaged) { return; }
        }
  
 +      FOR_EACH_PLAYER(tmp_entity) if(SAME_TEAM(toucher, tmp_entity)) { ++num_perteam; }
 +
        // special touch behaviors
        if(toucher.frozen) { return; }
        else if(toucher.vehicle_flags & VHF_ISVEHICLE)
        {
                case FLAG_BASE:
                {
 -                      if(SAME_TEAM(toucher, self) && (toucher.flagcarried) && DIFF_TEAM(toucher.flagcarried, self) && is_not_monster)
 +                      if(ctf_oneflag)
 +                      {
 +                              if(CTF_SAMETEAM(toucher, self) && (toucher.flagcarried) && !toucher.flagcarried.team && is_not_monster)
 +                                      ctf_Handle_Capture(self, toucher, CAPTURE_NORMAL); // toucher just captured the neutral flag to enemy base
 +                              else if(!self.team && (!toucher.flagcarried) && (!toucher.ctf_captureshielded) && (time > toucher.next_take_time) && is_not_monster)
 +                                      ctf_Handle_Pickup(self, toucher, PICKUP_BASE); // toucher just stole the neutral flag
 +                      }
 +                      else if(CTF_SAMETEAM(toucher, self) && (toucher.flagcarried) && DIFF_TEAM(toucher.flagcarried, self) && is_not_monster)
                                ctf_Handle_Capture(self, toucher, CAPTURE_NORMAL); // toucher just captured the enemies flag to his base
 -                      else if(DIFF_TEAM(toucher, self) && (!toucher.flagcarried) && (!toucher.ctf_captureshielded) && (time > toucher.next_take_time) && is_not_monster)
 +                      else if(CTF_DIFFTEAM(toucher, self) && (!toucher.flagcarried) && (!toucher.ctf_captureshielded) && (time > toucher.next_take_time) && is_not_monster)
                                ctf_Handle_Pickup(self, toucher, PICKUP_BASE); // toucher just stole the enemies flag
                        break;
                }
  
                case FLAG_DROPPED:
                {
 -                      if(SAME_TEAM(toucher, self))
 +                      if(CTF_SAMETEAM(toucher, self) && (autocvar_g_ctf_flag_return || num_perteam <= 1) && self.team) // automatically return if there's only 1 player on the team
                                ctf_Handle_Return(self, toucher); // toucher just returned his own flag
                        else if(is_not_monster && (!toucher.flagcarried) && ((toucher != self.ctf_dropper) || (time > self.ctf_droptime + autocvar_g_ctf_flag_collect_delay)))
                                ctf_Handle_Pickup(self, toucher, PICKUP_DROPPED); // toucher just picked up a dropped enemy flag
@@@ -1014,7 -893,9 +1014,7 @@@ void ctf_RespawnFlag(entity flag
        // reset the player (if there is one)
        if((flag.owner) && (flag.owner.flagcarried == flag))
        {
 -              if(flag.owner.wps_enemyflagcarrier)
 -                      WaypointSprite_Kill(flag.owner.wps_enemyflagcarrier);
 -
 +              WaypointSprite_Kill(flag.owner.wps_enemyflagcarrier);
                WaypointSprite_Kill(flag.wps_flagcarrier);
  
                flag.owner.flagcarried = world;
        if((flag.owner) && (flag.owner.vehicle))
                flag.scale = FLAG_SCALE;
  
 -      if((flag.ctf_status == FLAG_DROPPED) && (flag.wps_flagdropped))
 +      if(flag.ctf_status == FLAG_DROPPED)
                { WaypointSprite_Kill(flag.wps_flagdropped); }
  
        // reset the flag
        flag.ctf_dropper = world;
        flag.ctf_pickuptime = 0;
        flag.ctf_droptime = 0;
 +      flag.ctf_flagdamaged = 0;
  
        ctf_CheckStalemate();
  }
@@@ -1063,22 -943,6 +1063,22 @@@ void ctf_Reset(
        ctf_RespawnFlag(self);
  }
  
- float ctf_FlagWaypoint_Customize()
 +void ctf_Use()
 +{
 +      if(self.ctf_status != FLAG_BASE) { return; }
 +
 +      self.active = ((self.active) ? ACTIVE_NOT : ACTIVE_ACTIVE);
 +
 +      if(self.active == ACTIVE_ACTIVE)
 +              WaypointSprite_Ping(self.wps_flagbase);
 +}
 +
-       if(self.owner.active != ACTIVE_ACTIVE) { return FALSE; }
-       return TRUE;
++bool ctf_FlagWaypoint_Customize()
 +{
++      if(self.owner.active != ACTIVE_ACTIVE) { return false; }
++      return true;
 +}
 +
  void ctf_DelayedFlagSetup(void) // called after a flag is placed on a map by ctf_FlagSetup()
  {
        // bot waypoints
        self.bot_basewaypoint = self.nearestwaypoint;
  
        // waypointsprites
 -      WaypointSprite_SpawnFixed(((self.team == NUM_TEAM_1) ? "redbase" : "bluebase"), self.origin + FLAG_WAYPOINT_OFFSET, self, wps_flagbase, RADARICON_FLAG, colormapPaletteColor(self.team - 1, false));
 -      WaypointSprite_UpdateTeamRadar(self.wps_flagbase, RADARICON_FLAG, colormapPaletteColor(self.team - 1, false));
 +      string basename = "base";
 +
 +      switch(self.team)
 +      {
 +              case NUM_TEAM_1: basename = "redbase"; break;
 +              case NUM_TEAM_2: basename = "bluebase"; break;
 +              case NUM_TEAM_3: basename = "yellowbase"; break;
 +              case NUM_TEAM_4: basename = "pinkbase"; break;
 +              default: basename = "neutralbase"; break;
 +      }
 +
 +      WaypointSprite_SpawnFixed(basename, self.origin + FLAG_WAYPOINT_OFFSET, self, wps_flagbase, RADARICON_FLAG, ((self.team) ? Team_ColorRGB(self.team) : '1 1 1'));
-       WaypointSprite_UpdateTeamRadar(self.wps_flagbase, RADARICON_FLAG, ((self.team) ? colormapPaletteColor(self.team - 1, FALSE) : '1 1 1'));
++      WaypointSprite_UpdateTeamRadar(self.wps_flagbase, RADARICON_FLAG, ((self.team) ? colormapPaletteColor(self.team - 1, false) : '1 1 1'));
 +      self.wps_flagbase.customizeentityforclient = ctf_FlagWaypoint_Customize;
  
        // captureshield setup
        ctf_CaptureShield_Spawn(self);
  }
  
--void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
++void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
  {
        // declarations
 -      teamnumber = fabs(teamnumber - bound(0, autocvar_g_ctf_reverse, 1)); // if we were originally 1, this will become 0. If we were originally 0, this will become 1.
        self = flag; // for later usage with droptofloor()
  
        // main setup
  
        setattachment(flag, world, "");
  
 -      flag.netname = ((teamnumber) ? "^1RED^7 flag" : "^4BLUE^7 flag"); // Primarily only used for debugging or when showing nearby item name
 -      flag.team = ((teamnumber) ? NUM_TEAM_1 : NUM_TEAM_2); // NUM_TEAM_1: color 4 team (red) - NUM_TEAM_2: color 13 team (blue)
 -      flag.items = ((teamnumber) ? IT_KEY2 : IT_KEY1); // IT_KEY2: gold key (redish enough) - IT_KEY1: silver key (bluish enough)
 +      flag.netname = strzone(sprintf("%s%s^7 flag", Team_ColorCode(teamnumber), Team_ColorName_Upper(teamnumber)));
 +      flag.team = teamnumber;
        flag.classname = "item_flag_team";
        flag.target = "###item###"; // wut?
        flag.flags = FL_ITEM | FL_NOTARGET;
        flag.max_flag_health = ((autocvar_g_ctf_flag_return_damage && autocvar_g_ctf_flag_health) ? autocvar_g_ctf_flag_health : 100);
        flag.health = flag.max_flag_health;
        flag.event_damage = ctf_FlagDamage;
-       flag.pushable = TRUE;
+       flag.pushable = true;
        flag.teleportable = TELEPORT_NORMAL;
 +      flag.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
        flag.damagedbytriggers = autocvar_g_ctf_flag_return_when_unreachable;
        flag.damagedbycontents = autocvar_g_ctf_flag_return_when_unreachable;
        flag.velocity = '0 0 0';
        flag.mangle = flag.angles;
        flag.reset = ctf_Reset;
 +      flag.use = ctf_Use;
        flag.touch = ctf_FlagTouch;
        flag.think = ctf_FlagThink;
        flag.nextthink = time + FLAG_THINKRATE;
        flag.ctf_status = FLAG_BASE;
  
        // appearence
 -      if(flag.model == "")       { flag.model = ((teamnumber) ? autocvar_g_ctf_flag_red_model : autocvar_g_ctf_flag_blue_model); }
 +      if(flag.model == "")       { flag.model = ((teamnumber == NUM_TEAM_1) ? autocvar_g_ctf_flag_red_model : ((teamnumber == NUM_TEAM_2) ? autocvar_g_ctf_flag_blue_model : ((teamnumber == NUM_TEAM_3) ? autocvar_g_ctf_flag_yellow_model : ((teamnumber == NUM_TEAM_4) ? autocvar_g_ctf_flag_pink_model : autocvar_g_ctf_flag_neutral_model)))); }
        if(!flag.scale)            { flag.scale = FLAG_SCALE; }
 -      if(!flag.skin)             { flag.skin = ((teamnumber) ? autocvar_g_ctf_flag_red_skin : autocvar_g_ctf_flag_blue_skin); }
 -      if(flag.toucheffect == "") { flag.toucheffect = ((teamnumber) ? "redflag_touch" : "blueflag_touch"); }
 -      if(flag.passeffect == "")  { flag.passeffect = ((teamnumber) ? "red_pass" : "blue_pass"); }
 -      if(flag.capeffect == "")   { flag.capeffect = ((teamnumber) ? "red_cap" : "blue_cap"); }
 +      if(!flag.skin)             { flag.skin = ((teamnumber == NUM_TEAM_1) ? autocvar_g_ctf_flag_red_skin : ((teamnumber == NUM_TEAM_2) ? autocvar_g_ctf_flag_blue_skin : ((teamnumber == NUM_TEAM_3) ? autocvar_g_ctf_flag_yellow_skin : ((teamnumber == NUM_TEAM_4) ? autocvar_g_ctf_flag_pink_skin : autocvar_g_ctf_flag_neutral_skin)))); }
 +      if(flag.toucheffect == "") { flag.toucheffect = ((teamnumber == NUM_TEAM_1) ? "redflag_touch" : ((teamnumber == NUM_TEAM_2) ? "blueflag_touch" : ((teamnumber == NUM_TEAM_3) ? "yellowflag_touch" : ((teamnumber == NUM_TEAM_4) ? "pinkflag_touch" : "neutralflag_touch")))); }
 +      if(flag.passeffect == "")  { flag.passeffect = ((teamnumber == NUM_TEAM_1) ? "red_pass" : ((teamnumber == NUM_TEAM_2) ? "blue_pass" : ((teamnumber == NUM_TEAM_3) ? "yellow_pass" : ((teamnumber == NUM_TEAM_4) ? "pink_pass" : "neutral_pass")))); }
 +      if(flag.capeffect == "")   { flag.capeffect = ((teamnumber == NUM_TEAM_1) ? "red_cap" : ((teamnumber == NUM_TEAM_2) ? "blue_cap" : ((teamnumber == NUM_TEAM_3) ? "yellow_cap" : ((teamnumber == NUM_TEAM_4) ? "pink_cap" : "")))); } // neutral flag cant be capped itself
 +      if(!flag.active)           { flag.active = ACTIVE_ACTIVE; }
  
        // sound
 -      if(flag.snd_flag_taken == "")    { flag.snd_flag_taken  = ((teamnumber) ? "ctf/red_taken.wav" : "ctf/blue_taken.wav"); }
 -      if(flag.snd_flag_returned == "") { flag.snd_flag_returned = ((teamnumber) ? "ctf/red_returned.wav" : "ctf/blue_returned.wav"); }
 -      if(flag.snd_flag_capture == "")  { flag.snd_flag_capture = ((teamnumber) ? "ctf/red_capture.wav" : "ctf/blue_capture.wav"); } // blue team scores by capturing the red flag
 +      if(flag.snd_flag_taken == "")    { flag.snd_flag_taken = ((teamnumber == NUM_TEAM_1) ? "ctf/red_taken.wav" : ((teamnumber == NUM_TEAM_2) ? "ctf/blue_taken.wav" : ((teamnumber == NUM_TEAM_3) ? "ctf/yellow_taken.wav" : ((teamnumber == NUM_TEAM_4) ? "ctf/pink_taken.wav" : "ctf/neutral_taken.wav")))); }
 +      if(flag.snd_flag_returned == "") { flag.snd_flag_returned = ((teamnumber == NUM_TEAM_1) ? "ctf/red_returned.wav" : ((teamnumber == NUM_TEAM_2) ? "ctf/blue_returned.wav" : ((teamnumber == NUM_TEAM_3) ? "ctf/yellow_returned.wav" : ((teamnumber == NUM_TEAM_4) ? "ctf/pink_returned.wav" : "")))); } // neutral flag can't be returned by players
 +      if(flag.snd_flag_capture == "")  { flag.snd_flag_capture = ((teamnumber == NUM_TEAM_1) ? "ctf/red_capture.wav" : ((teamnumber == NUM_TEAM_2) ? "ctf/blue_capture.wav" : ((teamnumber == NUM_TEAM_3) ? "ctf/yellow_capture.wav" : ((teamnumber == NUM_TEAM_4) ? "ctf/pink_capture.wav" : "")))); } // again can't be captured
        if(flag.snd_flag_respawn == "")  { flag.snd_flag_respawn = "ctf/flag_respawn.wav"; } // if there is ever a team-based sound for this, update the code to match.
 -      if(flag.snd_flag_dropped == "")  { flag.snd_flag_dropped = ((teamnumber) ? "ctf/red_dropped.wav" : "ctf/blue_dropped.wav"); }
 +      if(flag.snd_flag_dropped == "")  { flag.snd_flag_dropped = ((teamnumber == NUM_TEAM_1) ? "ctf/red_dropped.wav" : ((teamnumber == NUM_TEAM_2) ? "ctf/blue_dropped.wav" : ((teamnumber == NUM_TEAM_3) ? "ctf/yellow_dropped.wav" : ((teamnumber == NUM_TEAM_4) ? "ctf/pink_dropped.wav" : "ctf/neutral_dropped.wav")))); }
        if(flag.snd_flag_touch == "")    { flag.snd_flag_touch = "ctf/touch.wav"; } // again has no team-based sound
        if(flag.snd_flag_pass == "")     { flag.snd_flag_pass = "ctf/pass.wav"; } // same story here
  
  
        if(autocvar_g_ctf_flag_glowtrails)
        {
 -              flag.glow_color = ((teamnumber) ? 251 : 210); // 251: red - 210: blue
 +              flag.glow_color = ((teamnumber == NUM_TEAM_1) ? 251 : ((teamnumber == NUM_TEAM_2) ? 210 : ((teamnumber == NUM_TEAM_3) ? 110 : ((teamnumber == NUM_TEAM_4) ? 145 : 254))));
                flag.glow_size = 25;
                flag.glow_trail = 1;
        }
  
        flag.effects |= EF_LOWPRECISION;
        if(autocvar_g_ctf_fullbrightflags) { flag.effects |= EF_FULLBRIGHT; }
 -      if(autocvar_g_ctf_dynamiclights)   { flag.effects |= ((teamnumber) ? EF_RED : EF_BLUE); }
 -
 +      if(autocvar_g_ctf_dynamiclights)
 +      {
 +              switch(teamnumber)
 +              {
 +                      case NUM_TEAM_1: flag.effects |= EF_RED; break;
 +                      case NUM_TEAM_2: flag.effects |= EF_BLUE; break;
 +                      case NUM_TEAM_3: flag.effects |= EF_DIMLIGHT; break;
 +                      case NUM_TEAM_4: flag.effects |= EF_RED; break;
 +                      default: flag.effects |= EF_DIMLIGHT; break;
 +              }
 +      }
 +      
        // flag placement
        if((flag.spawnflags & 1) || flag.noalign) // don't drop to floor, just stay at fixed location
        {
                flag.dropped_origin = flag.origin;
-               flag.noalign = TRUE;
+               flag.noalign = true;
                flag.movetype = MOVETYPE_NONE;
        }
        else // drop to floor, automatically find a platform and set that as spawn origin
        {
-               flag.noalign = FALSE;
+               flag.noalign = false;
                self = flag;
                droptofloor();
                flag.movetype = MOVETYPE_TOSS;
@@@ -1250,7 -1091,7 +1250,7 @@@ entity havocbot_ctf_find_flag(entity bo
        f = ctf_worldflaglist;
        while (f)
        {
 -              if (bot.team == f.team)
 +              if (CTF_SAMETEAM(bot, f))
                        return f;
                f = f.ctf_worldflagnext;
        }
@@@ -1263,37 -1104,24 +1263,37 @@@ entity havocbot_ctf_find_enemy_flag(ent
        f = ctf_worldflaglist;
        while (f)
        {
 -              if (bot.team != f.team)
 +              if(ctf_oneflag)
 +              {
 +                      if(CTF_DIFFTEAM(bot, f))
 +                      {
 +                              if(f.team)
 +                              {
 +                                      if(bot.flagcarried)
 +                                              return f;
 +                              }
 +                              else if(!bot.flagcarried)
 +                                      return f;
 +                      }
 +              }
 +              else if (CTF_DIFFTEAM(bot, f))
                        return f;
                f = f.ctf_worldflagnext;
        }
        return world;
  }
  
--float havocbot_ctf_teamcount(entity bot, vector org, float tc_radius)
++int havocbot_ctf_teamcount(entity bot, vector org, float tc_radius)
  {
        if (!teamplay)
                return 0;
  
--      float c = 0;
++      int c = 0;
        entity head;
  
        FOR_EACH_PLAYER(head)
        {
 -              if(head.team!=bot.team || head.deadflag != DEAD_NO || head == bot)
 +              if(DIFF_TEAM(head, bot) || head.deadflag != DEAD_NO || head == bot)
                        continue;
  
                if(vlen(head.origin - org) < tc_radius)
@@@ -1309,7 -1137,7 +1309,7 @@@ void havocbot_goalrating_ctf_ourflag(fl
        head = ctf_worldflaglist;
        while (head)
        {
 -              if (self.team == head.team)
 +              if (CTF_SAMETEAM(self, head))
                        break;
                head = head.ctf_worldflagnext;
        }
@@@ -1323,7 -1151,7 +1323,7 @@@ void havocbot_goalrating_ctf_ourbase(fl
        head = ctf_worldflaglist;
        while (head)
        {
 -              if (self.team == head.team)
 +              if (CTF_SAMETEAM(self, head))
                        break;
                head = head.ctf_worldflagnext;
        }
@@@ -1339,20 -1167,7 +1339,20 @@@ void havocbot_goalrating_ctf_enemyflag(
        head = ctf_worldflaglist;
        while (head)
        {
 -              if (self.team != head.team)
 +              if(ctf_oneflag)
 +              {
 +                      if(CTF_DIFFTEAM(self, head))
 +                      {
 +                              if(head.team)
 +                              {
 +                                      if(self.flagcarried)
 +                                              break;
 +                              }
 +                              else if(!self.flagcarried)
 +                                      break;
 +                      }
 +              }
 +              else if(CTF_DIFFTEAM(self, head))
                        break;
                head = head.ctf_worldflagnext;
        }
@@@ -1418,7 -1233,7 +1418,7 @@@ void havocbot_goalrating_ctf_carrierite
  {
        entity head;
        float t;
-       head = findchainfloat(bot_pickup, TRUE);
+       head = findchainfloat(bot_pickup, true);
        while (head)
        {
                // gather health and armor only
@@@ -1520,10 -1335,7 +1520,10 @@@ void havocbot_role_ctf_carrier(
                self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
  
                navigation_goalrating_start();
 -              havocbot_goalrating_ctf_ourbase(50000);
 +              if(ctf_oneflag)
 +                      havocbot_goalrating_ctf_enemybase(50000);
 +              else
 +                      havocbot_goalrating_ctf_ourbase(50000);
  
                if(self.health<100)
                        havocbot_goalrating_ctf_carrieritems(1000, self.origin, 1000);
@@@ -1769,7 -1581,7 +1769,7 @@@ void havocbot_role_ctf_middle(
                vector org;
  
                org = havocbot_ctf_middlepoint;
-               org_z = self.origin_z;
+               org.z = self.origin.z;
  
                self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start();
@@@ -1910,40 -1722,28 +1910,39 @@@ void havocbot_role_ctf_setrole(entity b
  MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink)
  {
        entity flag;
-       float t = 0, t2 = 0, t3 = 0;
++      int t = 0, t2 = 0, t3 = 0;
  
        // initially clear items so they can be set as necessary later.
 -      self.items &= ~(IT_RED_FLAG_CARRYING | IT_RED_FLAG_TAKEN | IT_RED_FLAG_LOST
 -              | IT_BLUE_FLAG_CARRYING | IT_BLUE_FLAG_TAKEN | IT_BLUE_FLAG_LOST | IT_CTF_SHIELDED);
 +      self.ctf_flagstatus &= ~(CTF_RED_FLAG_CARRYING          | CTF_RED_FLAG_TAKEN            | CTF_RED_FLAG_LOST 
 +                                                 | CTF_BLUE_FLAG_CARRYING             | CTF_BLUE_FLAG_TAKEN           | CTF_BLUE_FLAG_LOST
 +                                                 | CTF_YELLOW_FLAG_CARRYING   | CTF_YELLOW_FLAG_TAKEN         | CTF_YELLOW_FLAG_LOST
 +                                                 | CTF_PINK_FLAG_CARRYING     | CTF_PINK_FLAG_TAKEN           | CTF_PINK_FLAG_LOST
 +                                                 | CTF_NEUTRAL_FLAG_CARRYING  | CTF_NEUTRAL_FLAG_TAKEN        | CTF_NEUTRAL_FLAG_LOST
 +                                                 | CTF_FLAG_NEUTRAL | CTF_SHIELDED);
  
        // scan through all the flags and notify the client about them
        for(flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext)
        {
 +              if(flag.team == NUM_TEAM_1) { t = CTF_RED_FLAG_CARRYING;                t2 = CTF_RED_FLAG_TAKEN;                t3 = CTF_RED_FLAG_LOST; }
 +              if(flag.team == NUM_TEAM_2) { t = CTF_BLUE_FLAG_CARRYING;               t2 = CTF_BLUE_FLAG_TAKEN;               t3 = CTF_BLUE_FLAG_LOST; }
 +              if(flag.team == NUM_TEAM_3) { t = CTF_YELLOW_FLAG_CARRYING;     t2 = CTF_YELLOW_FLAG_TAKEN;             t3 = CTF_YELLOW_FLAG_LOST; }
 +              if(flag.team == NUM_TEAM_4) { t = CTF_PINK_FLAG_CARRYING;               t2 = CTF_PINK_FLAG_TAKEN;               t3 = CTF_PINK_FLAG_LOST; }
 +              if(flag.team == 0)                      { t = CTF_NEUTRAL_FLAG_CARRYING;        t2 = CTF_NEUTRAL_FLAG_TAKEN;    t3 = CTF_NEUTRAL_FLAG_LOST; self.ctf_flagstatus |= CTF_FLAG_NEUTRAL; }
 +
                switch(flag.ctf_status)
                {
                        case FLAG_PASSING:
                        case FLAG_CARRY:
                        {
                                if((flag.owner == self) || (flag.pass_sender == self))
 -                                      self.items |= ((flag.items & IT_KEY2) ? IT_RED_FLAG_CARRYING : IT_BLUE_FLAG_CARRYING); // carrying: self is currently carrying the flag
 -                              else
 -                                      self.items |= ((flag.items & IT_KEY2) ? IT_RED_FLAG_TAKEN : IT_BLUE_FLAG_TAKEN); // taken: someone on self's team is carrying the flag
 +                                      self.ctf_flagstatus |= t; // carrying: self is currently carrying the flag
 +                              else 
 +                                      self.ctf_flagstatus |= t2; // taken: someone else is carrying the flag
                                break;
                        }
                        case FLAG_DROPPED:
                        {
 -                              self.items |= ((flag.items & IT_KEY2) ? IT_RED_FLAG_LOST : IT_BLUE_FLAG_LOST); // lost: the flag is dropped somewhere on the map
 +                              self.ctf_flagstatus |= t3; // lost: the flag is dropped somewhere on the map
                                break;
                        }
                }
  
        // item for stopping players from capturing the flag too often
        if(self.ctf_captureshielded)
 -              self.items |= IT_CTF_SHIELDED;
 +              self.ctf_flagstatus |= CTF_SHIELDED;
  
        // update the health of the flag carrier waypointsprite
        if(self.wps_flagcarrier)
                WaypointSprite_UpdateHealth(self.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON));
  
-       return FALSE;
+       return false;
  }
  
  MUTATOR_HOOKFUNCTION(ctf_PlayerDamage) // for changing damage and force values that are applied to players in g_damage.qc
                        frag_force *= autocvar_g_ctf_flagcarrier_forcefactor;
                }
        }
 -      else if(frag_target.flagcarried && (frag_target.deadflag == DEAD_NO) && DIFF_TEAM(frag_target, frag_attacker)) // if the target is a flagcarrier
 +      else if(frag_target.flagcarried && (frag_target.deadflag == DEAD_NO) && CTF_DIFFTEAM(frag_target, frag_attacker)) // if the target is a flagcarrier
        {
                if(autocvar_g_ctf_flagcarrier_auto_helpme_damage > ('1 0 0' * healtharmor_maxdamage(frag_target.health, frag_target.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON)))
                if(time > frag_target.wps_helpme_time + autocvar_g_ctf_flagcarrier_auto_helpme_time)
                }
                // todo: add notification for when flag carrier needs help?
        }
-       return FALSE;
+       return false;
  }
  
  MUTATOR_HOOKFUNCTION(ctf_PlayerDies)
        }
  
        if(frag_target.flagcarried)
 -              { ctf_Handle_Throw(frag_target, world, DROP_NORMAL); }
 +      {
 +              entity tmp_entity = frag_target.flagcarried;
 +              ctf_Handle_Throw(frag_target, world, DROP_NORMAL);
 +              tmp_entity.ctf_dropper = world;
 +      }
  
-       return FALSE;
+       return false;
  }
  
  MUTATOR_HOOKFUNCTION(ctf_GiveFragsForKill)
@@@ -2026,7 -1822,7 +2025,7 @@@ MUTATOR_HOOKFUNCTION(ctf_RemovePlayer
                if(flag.ctf_dropper == self) { flag.ctf_dropper = world; }
        }
  
-       return FALSE;
+       return false;
  }
  
  MUTATOR_HOOKFUNCTION(ctf_PortalTeleport)
        if(!autocvar_g_ctf_portalteleport)
                { ctf_Handle_Throw(self, world, DROP_NORMAL); }
  
-       return FALSE;
+       return false;
  }
  
  MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey)
  {
-       if(MUTATOR_RETURNVALUE || gameover) { return FALSE; }
+       if(MUTATOR_RETURNVALUE || gameover) { return false; }
  
        entity player = self;
  
                if(autocvar_g_ctf_pass)
                {
                        entity head, closest_target = world;
-                       head = WarpZone_FindRadius(player.origin, autocvar_g_ctf_pass_radius, TRUE);
+                       head = WarpZone_FindRadius(player.origin, autocvar_g_ctf_pass_radius, true);
  
                        while(head) // find the closest acceptable target to pass to
                        {
                                                                Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_PASS_REQUESTING, head.netname);
                                                        }
                                                        player.throw_antispam = time + autocvar_g_ctf_pass_wait;
-                                                       return TRUE;
+                                                       return true;
                                                }
                                                else if(player.flagcarried)
                                                {
                                head = head.chain;
                        }
  
-                       if(closest_target) { ctf_Handle_Throw(player, closest_target, DROP_PASS); return TRUE; }
+                       if(closest_target) { ctf_Handle_Throw(player, closest_target, DROP_PASS); return true; }
                }
  
                // throw the flag in front of you
                                        player.throw_prevtime = time;
                                        player.throw_count = 1;
                                        ctf_Handle_Throw(player, world, DROP_THROW);
-                                       return TRUE;
+                                       return true;
                                }
                                else
                                {
                                        Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_FLAG_THROW_PUNISH, rint((player.throw_prevtime + autocvar_g_ctf_throw_punish_delay) - time));
-                                       return FALSE;
+                                       return false;
                                }
                        }
                        else
  
                                player.throw_prevtime = time;
                                ctf_Handle_Throw(player, world, DROP_THROW);
-                               return TRUE;
+                               return true;
                        }
                }
        }
  
-       return FALSE;
+       return false;
  }
  
  MUTATOR_HOOKFUNCTION(ctf_HelpMePing)
        }
        else // create a normal help me waypointsprite
        {
-               WaypointSprite_Spawn("helpme", waypointsprite_deployed_lifetime, waypointsprite_limitedrange, self, FLAG_WAYPOINT_OFFSET, world, self.team, self, wps_helpme, FALSE, RADARICON_HELPME, '1 0.5 0');
+               WaypointSprite_Spawn("helpme", waypointsprite_deployed_lifetime, waypointsprite_limitedrange, self, FLAG_WAYPOINT_OFFSET, world, self.team, self, wps_helpme, false, RADARICON_HELPME, '1 0.5 0');
                WaypointSprite_Ping(self.wps_helpme);
        }
  
-       return TRUE;
+       return true;
  }
  
  MUTATOR_HOOKFUNCTION(ctf_VehicleEnter)
                        vh_player.flagcarried.scale = VEHICLE_FLAG_SCALE;
                        //vh_player.flagcarried.angles = '0 0 0';
                }
-               return TRUE;
+               return true;
        }
  
-       return FALSE;
+       return false;
  }
  
  MUTATOR_HOOKFUNCTION(ctf_VehicleExit)
                setorigin(vh_player.flagcarried, FLAG_CARRY_OFFSET);
                vh_player.flagcarried.scale = FLAG_SCALE;
                vh_player.flagcarried.angles = '0 0 0';
-               return TRUE;
+               return true;
        }
  
-       return FALSE;
+       return false;
  }
  
  MUTATOR_HOOKFUNCTION(ctf_AbortSpeedrun)
  {
        if(self.flagcarried)
        {
 -              Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(self.flagcarried, INFO_CTF_FLAGRETURN_ABORTRUN_));
 +              Send_Notification(NOTIF_ALL, world, MSG_INFO, ((self.flagcarried.team) ? APP_TEAM_ENT_4(self.flagcarried, INFO_CTF_FLAGRETURN_ABORTRUN_) : INFO_CTF_FLAGRETURN_ABORTRUN_NEUTRAL));
                ctf_RespawnFlag(self.flagcarried);
-               return TRUE;
+               return true;
        }
  
-       return FALSE;
+       return false;
  }
  
  MUTATOR_HOOKFUNCTION(ctf_MatchEnd)
                                flag.movetype = MOVETYPE_NONE;
                                flag.takedamage = DAMAGE_NO;
                                flag.solid = SOLID_NOT;
-                               flag.nextthink = FALSE; // stop thinking
+                               flag.nextthink = false; // stop thinking
  
                                //dprint("stopping the ", flag.netname, " from moving.\n");
                                break;
                }
        }
  
-       return FALSE;
+       return false;
  }
  
  MUTATOR_HOOKFUNCTION(ctf_BotRoles)
  {
        havocbot_ctf_reset_role(self);
-       return TRUE;
+       return true;
  }
  
-       return TRUE;
 +MUTATOR_HOOKFUNCTION(ctf_GetTeamCount)
 +{
 +      //ret_float = ctf_teams;
 +      ret_string = "ctf_team";
-       return FALSE;
++      return true;
 +}
 +
 +MUTATOR_HOOKFUNCTION(ctf_SpectateCopy)
 +{
 +      self.ctf_flagstatus = other.ctf_flagstatus;
++      return false;
 +}
 +
  
  // ==========
  // Spawnfuncs
@@@ -2313,7 -2096,7 +2312,7 @@@ void spawnfunc_item_flag_team1(
  {
        if(!g_ctf) { remove(self); return; }
  
 -      ctf_FlagSetup(1, self); // 1 = red
 +      ctf_FlagSetup(NUM_TEAM_1, self);
  }
  
  /*QUAKED spawnfunc_item_flag_team2 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
@@@ -2331,62 -2114,7 +2330,62 @@@ void spawnfunc_item_flag_team2(
  {
        if(!g_ctf) { remove(self); return; }
  
 -      ctf_FlagSetup(0, self); // the 0 is misleading, but -- 0 = blue.
 +      ctf_FlagSetup(NUM_TEAM_2, self);
 +}
 +
 +/*QUAKED spawnfunc_item_flag_team3 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
 +CTF flag for team three (Yellow).
 +Keys: 
 +"angle" Angle the flag will point (minus 90 degrees)... 
 +"model" model to use, note this needs red, blue yellow and pink as skins 0, 1, 2 and 3...
 +"noise" sound played when flag is picked up...
 +"noise1" sound played when flag is returned by a teammate...
 +"noise2" sound played when flag is captured...
 +"noise3" sound played when flag is lost in the field and respawns itself... 
 +"noise4" sound played when flag is dropped by a player...
 +"noise5" sound played when flag touches the ground... */
 +void spawnfunc_item_flag_team3()
 +{
 +      if(!g_ctf) { remove(self); return; }
 +
 +      ctf_FlagSetup(NUM_TEAM_3, self);
 +}
 +
 +/*QUAKED spawnfunc_item_flag_team4 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
 +CTF flag for team four (Pink).
 +Keys: 
 +"angle" Angle the flag will point (minus 90 degrees)... 
 +"model" model to use, note this needs red, blue yellow and pink as skins 0, 1, 2 and 3...
 +"noise" sound played when flag is picked up...
 +"noise1" sound played when flag is returned by a teammate...
 +"noise2" sound played when flag is captured...
 +"noise3" sound played when flag is lost in the field and respawns itself... 
 +"noise4" sound played when flag is dropped by a player...
 +"noise5" sound played when flag touches the ground... */
 +void spawnfunc_item_flag_team4()
 +{
 +      if(!g_ctf) { remove(self); return; }
 +
 +      ctf_FlagSetup(NUM_TEAM_4, self);
 +}
 +
 +/*QUAKED spawnfunc_item_flag_neutral (0 0.5 0.8) (-48 -48 -37) (48 48 37)
 +CTF flag (Neutral).
 +Keys: 
 +"angle" Angle the flag will point (minus 90 degrees)... 
 +"model" model to use, note this needs red, blue yellow and pink as skins 0, 1, 2 and 3...
 +"noise" sound played when flag is picked up...
 +"noise1" sound played when flag is returned by a teammate...
 +"noise2" sound played when flag is captured...
 +"noise3" sound played when flag is lost in the field and respawns itself... 
 +"noise4" sound played when flag is dropped by a player...
 +"noise5" sound played when flag touches the ground... */
 +void spawnfunc_item_flag_neutral()
 +{
 +      if(!g_ctf) { remove(self); return; }
 +      if(!cvar("g_ctf_oneflag")) { remove(self); return; }
 +
 +      ctf_FlagSetup(0, self);
  }
  
  /*QUAKED spawnfunc_ctf_team (0 .5 .8) (-16 -16 -24) (16 16 32)
@@@ -2417,10 -2145,9 +2416,10 @@@ void spawnfunc_team_CTF_bluespawn()  { 
  // ==============
  
  // scoreboard setup
 -void ctf_ScoreRules()
 +void ctf_ScoreRules(float teams)
  {
 -      ScoreRules_basics(2, SFL_SORT_PRIO_PRIMARY, 0, true);
 +      CheckAllowedTeams(world);
-       ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, TRUE);
++      ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, true);
        ScoreInfo_SetLabel_TeamScore  (ST_CTF_CAPS,     "caps",      SFL_SORT_PRIO_PRIMARY);
        ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPS,     "caps",      SFL_SORT_PRIO_SECONDARY);
        ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPTIME,  "captime",   SFL_LOWER_IS_BETTER | SFL_TIME);
@@@ -2448,31 -2175,15 +2447,31 @@@ void ctf_SpawnTeam (string teamname, fl
  
  void ctf_DelayedInit() // Do this check with a delay so we can wait for teams to be set up.
  {
-               if(tmp_entity.team == 0) { ctf_oneflag = TRUE; }
 +      ctf_teams = 2;
 +
 +      entity tmp_entity;
 +      for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext)
 +      {
 +              if(tmp_entity.team == NUM_TEAM_3) { ctf_teams = max(3, ctf_teams); }
 +              if(tmp_entity.team == NUM_TEAM_4) { ctf_teams = max(4, ctf_teams); }
++              if(tmp_entity.team == 0) { ctf_oneflag = true; }
 +      }
 +
 +      ctf_teams = bound(2, ctf_teams, 4);
 +
        // if no teams are found, spawn defaults
        if(find(world, classname, "ctf_team") == world)
        {
                print("No ""ctf_team"" entities found on this map, creating them anyway.\n");
                ctf_SpawnTeam("Red", NUM_TEAM_1 - 1);
                ctf_SpawnTeam("Blue", NUM_TEAM_2 - 1);
 +              if(ctf_teams >= 3)
 +                      ctf_SpawnTeam("Yellow", NUM_TEAM_3 - 1);
 +              if(ctf_teams >= 4)
 +                      ctf_SpawnTeam("Pink", NUM_TEAM_4 - 1);
        }
  
 -      ctf_ScoreRules();
 +      ctf_ScoreRules(ctf_teams);
  }
  
  void ctf_Initialize()
        ctf_captureshield_max_ratio = autocvar_g_ctf_shield_max_ratio;
        ctf_captureshield_force = autocvar_g_ctf_shield_force;
  
 +      addstat(STAT_CTF_FLAGSTATUS, AS_INT, ctf_flagstatus);
 +
        InitializeEntity(world, ctf_DelayedInit, INITPRIO_GAMETYPE);
  }
  
@@@ -2505,8 -2214,6 +2504,8 @@@ MUTATOR_DEFINITION(gamemode_ctf
        MUTATOR_HOOK(VehicleExit, ctf_VehicleExit, CBC_ORDER_ANY);
        MUTATOR_HOOK(AbortSpeedrun, ctf_AbortSpeedrun, CBC_ORDER_ANY);
        MUTATOR_HOOK(HavocBot_ChooseRole, ctf_BotRoles, CBC_ORDER_ANY);
 +      MUTATOR_HOOK(GetTeamCount, ctf_GetTeamCount, CBC_ORDER_ANY);
 +      MUTATOR_HOOK(SpectateCopy, ctf_SpectateCopy, CBC_ORDER_ANY);
  
        MUTATOR_ONADD
        {
index bb76aa9e1c051b8c4df285b9163d8e1c107290f3,0e5930db2cbe83c95b439e8f75461cdce64eda7f..d2572bc458896ef24159bc9ada697496ed6424aa
@@@ -1,3 -1,5 +1,5 @@@
+ #ifndef GAMEMODE_CTF_H
+ #define GAMEMODE_CTF_H
  // these are needed since mutators are compiled last
  
  #ifdef SVQC
@@@ -5,38 -7,38 +7,41 @@@
  void ctf_RespawnFlag(entity flag);
  
  // score rule declarations
- #define ST_CTF_CAPS 1
- #define SP_CTF_CAPS 4
- #define SP_CTF_CAPTIME 5
- #define SP_CTF_PICKUPS 6
- #define SP_CTF_DROPS 7
- #define SP_CTF_FCKILLS 8
- #define SP_CTF_RETURNS 9
 -const float ST_CTF_CAPS = 1;
 -const float SP_CTF_CAPS = 4;
 -const float SP_CTF_CAPTIME = 5;
 -const float SP_CTF_PICKUPS = 6;
 -const float SP_CTF_DROPS = 7;
 -const float SP_CTF_FCKILLS = 8;
 -const float SP_CTF_RETURNS = 9;
++const int ST_CTF_CAPS = 1;
++const int SP_CTF_CAPS = 4;
++const int SP_CTF_CAPTIME = 5;
++const int SP_CTF_PICKUPS = 6;
++const int SP_CTF_DROPS = 7;
++const int SP_CTF_FCKILLS = 8;
++const int SP_CTF_RETURNS = 9;
  
  // flag constants // for most of these, there is just one question to be asked: WHYYYYY?
  #define FLAG_MIN (PL_MIN + '0 0 -13')
  #define FLAG_MAX (PL_MAX + '0 0 -13')
  
- #define FLAG_SCALE 0.6
+ const float FLAG_SCALE = 0.6;
  
- #define FLAG_THINKRATE 0.2
- #define FLAG_TOUCHRATE 0.5
- #define WPFE_THINKRATE 0.5
+ const float FLAG_THINKRATE = 0.2;
+ const float FLAG_TOUCHRATE = 0.5;
+ const float WPFE_THINKRATE = 0.5;
  
--#define FLAG_DROP_OFFSET ('0 0 32')
--#define FLAG_CARRY_OFFSET ('-16 0 8')
++const vector FLAG_DROP_OFFSET = ('0 0 32');
++const vector FLAG_CARRY_OFFSET = ('-16 0 8');
  #define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX_z - 13))
--#define FLAG_WAYPOINT_OFFSET ('0 0 64')
--#define FLAG_FLOAT_OFFSET ('0 0 32')
--#define FLAG_PASS_ARC_OFFSET ('0 0 -10')
++const vector FLAG_WAYPOINT_OFFSET = ('0 0 64');
++const vector FLAG_FLOAT_OFFSET = ('0 0 32');
++const vector FLAG_PASS_ARC_OFFSET = ('0 0 -10');
 +
- #define VEHICLE_FLAG_OFFSET ('0 0 96')
- #define VEHICLE_FLAG_SCALE 1.0
++const vector VEHICLE_FLAG_OFFSET = ('0 0 90');
++
++
 -#define VEHICLE_FLAG_OFFSET ('0 0 96')
+ const float VEHICLE_FLAG_SCALE = 1.0;
  
  // waypoint colors
- #define WPCOLOR_ENEMYFC(t) ((t) ? colormapPaletteColor(t - 1, FALSE) * 0.75 : '1 1 1')
 -#define WPCOLOR_ENEMYFC(t) (colormapPaletteColor(t - 1, false) * 0.75)
++#define WPCOLOR_ENEMYFC(t) ((t) ? colormapPaletteColor(t - 1, false) * 0.75 : '1 1 1')
  #define WPCOLOR_FLAGCARRIER(t) ('0.8 0.8 0')
- #define WPCOLOR_DROPPEDFLAG(t) ((t) ? ('0.25 0.25 0.25' + colormapPaletteColor(t - 1, FALSE)) * 0.5 : '1 1 1')
 -#define WPCOLOR_DROPPEDFLAG(t) (('0.25 0.25 0.25' + colormapPaletteColor(t - 1, false)) * 0.5)
++#define WPCOLOR_DROPPEDFLAG(t) ((t) ? ('0.25 0.25 0.25' + colormapPaletteColor(t - 1, false)) * 0.5 : '1 1 1')
  
  // sounds
  #define snd_flag_taken noise
@@@ -65,44 -67,42 +70,44 @@@ entity ctf_worldflaglist
  .entity wps_flagdropped;
  .entity wps_enemyflagcarrier;
  .float wps_helpme_time;
--float wpforenemy_announced;
++bool wpforenemy_announced;
  float wpforenemy_nextthink;
  
  // statuses
- #define FLAG_BASE 1
- #define FLAG_DROPPED 2
- #define FLAG_CARRY 3
- #define FLAG_PASSING 4
 -const float FLAG_BASE = 1;
 -const float FLAG_DROPPED = 2;
 -const float FLAG_CARRY = 3;
 -const float FLAG_PASSING = 4;
++const int FLAG_BASE = 1;
++const int FLAG_DROPPED = 2;
++const int FLAG_CARRY = 3;
++const int FLAG_PASSING = 4;
  
- #define DROP_NORMAL 1
- #define DROP_THROW 2
- #define DROP_PASS 3
- #define DROP_RESET 4
 -const float DROP_NORMAL = 1;
 -const float DROP_THROW = 2;
 -const float DROP_PASS = 3;
 -const float DROP_RESET = 4;
++const int DROP_NORMAL = 1;
++const int DROP_THROW = 2;
++const int DROP_PASS = 3;
++const int DROP_RESET = 4;
  
- #define PICKUP_BASE 1
- #define PICKUP_DROPPED 2
 -const float PICKUP_BASE = 1;
 -const float PICKUP_DROPPED = 2;
++const int PICKUP_BASE = 1;
++const int PICKUP_DROPPED = 2;
  
- #define CAPTURE_NORMAL 1
- #define CAPTURE_DROPPED 2
 -const float CAPTURE_NORMAL = 1;
 -const float CAPTURE_DROPPED = 2;
++const int CAPTURE_NORMAL = 1;
++const int CAPTURE_DROPPED = 2;
  
- #define RETURN_TIMEOUT 1
- #define RETURN_DROPPED 2
- #define RETURN_DAMAGE 3
- #define RETURN_SPEEDRUN 4
- #define RETURN_NEEDKILL 5
 -const float RETURN_TIMEOUT = 1;
 -const float RETURN_DROPPED = 2;
 -const float RETURN_DAMAGE = 3;
 -const float RETURN_SPEEDRUN = 4;
 -const float RETURN_NEEDKILL = 5;
++const int RETURN_TIMEOUT = 1;
++const int RETURN_DROPPED = 2;
++const int RETURN_DAMAGE = 3;
++const int RETURN_SPEEDRUN = 4;
++const int RETURN_NEEDKILL = 5;
  
  // flag properties
  #define ctf_spawnorigin dropped_origin
--float ctf_stalemate; // indicates that a stalemate is active
++bool ctf_stalemate; // indicates that a stalemate is active
  float ctf_captimerecord; // record time for capturing the flag
  .float ctf_pickuptime;
  .float ctf_droptime;
--.float ctf_status; // status of the flag (FLAG_BASE, FLAG_DROPPED, FLAG_CARRY declared globally)
++.int ctf_status; // status of the flag (FLAG_BASE, FLAG_DROPPED, FLAG_CARRY declared globally)
  .entity ctf_dropper; // don't allow spam of dropping the flag
--.float max_flag_health;
++.int max_flag_health;
  .float next_take_time;
- .float ctf_flagdamaged;
- float ctf_teams;
++.bool ctf_flagdamaged;
++int ctf_teams;
  
  // passing/throwing properties
  .float pass_distance;
  .entity pass_target;
  .float throw_antispam;
  .float throw_prevtime;
--.float throw_count;
++.int throw_count;
  
  // CaptureShield: If the player is too bad to be allowed to capture, shield them from taking the flag.
--.float ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
++.bool ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
  float ctf_captureshield_min_negscore; // punish at -20 points
  float ctf_captureshield_max_ratio; // punish at most 30% of each team
  float ctf_captureshield_force; // push force of the shield
  
- float ctf_oneflag; // indicates whether or not a neutral flag has been found
 +// 1 flag ctf
++bool ctf_oneflag; // indicates whether or not a neutral flag has been found
 +
  // bot player logic
- #define HAVOCBOT_CTF_ROLE_NONE 0
- #define HAVOCBOT_CTF_ROLE_DEFENSE 2
- #define HAVOCBOT_CTF_ROLE_MIDDLE 4
- #define HAVOCBOT_CTF_ROLE_OFFENSE 8
- #define HAVOCBOT_CTF_ROLE_CARRIER 16
- #define HAVOCBOT_CTF_ROLE_RETRIEVER 32
- #define HAVOCBOT_CTF_ROLE_ESCORT 64
 -const float HAVOCBOT_CTF_ROLE_NONE = 0;
 -const float HAVOCBOT_CTF_ROLE_DEFENSE = 2;
 -const float HAVOCBOT_CTF_ROLE_MIDDLE = 4;
 -const float HAVOCBOT_CTF_ROLE_OFFENSE = 8;
 -const float HAVOCBOT_CTF_ROLE_CARRIER = 16;
 -const float HAVOCBOT_CTF_ROLE_RETRIEVER = 32;
 -const float HAVOCBOT_CTF_ROLE_ESCORT = 64;
++const int HAVOCBOT_CTF_ROLE_NONE = 0;
++const int HAVOCBOT_CTF_ROLE_DEFENSE = 2;
++const int HAVOCBOT_CTF_ROLE_MIDDLE = 4;
++const int HAVOCBOT_CTF_ROLE_OFFENSE = 8;
++const int HAVOCBOT_CTF_ROLE_CARRIER = 16;
++const int HAVOCBOT_CTF_ROLE_RETRIEVER = 32;
++const int HAVOCBOT_CTF_ROLE_ESCORT = 64;
  
--.float havocbot_cantfindflag;
++.bool havocbot_cantfindflag;
  
  vector havocbot_ctf_middlepoint;
  float havocbot_ctf_middlepoint_radius;
  
--void havocbot_role_ctf_setrole(entity bot, float role);
++void havocbot_role_ctf_setrole(entity bot, int role);
 +
 +// team checking
 +#define CTF_SAMETEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? DIFF_TEAM(a,b) : SAME_TEAM(a,b))
 +#define CTF_DIFFTEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? SAME_TEAM(a,b) : DIFF_TEAM(a,b))
 +
++// networked flag statuses
++.int ctf_flagstatus;
  #endif
- // networked flag statuses
- .float ctf_flagstatus;
- const float   CTF_RED_FLAG_TAKEN                      = 1;
- const float   CTF_RED_FLAG_LOST                       = 2;
- const float   CTF_RED_FLAG_CARRYING           = 3;
- const float   CTF_BLUE_FLAG_TAKEN                     = 4;
- const float   CTF_BLUE_FLAG_LOST                      = 8;
- const float   CTF_BLUE_FLAG_CARRYING          = 12;
- const float   CTF_YELLOW_FLAG_TAKEN           = 16;
- const float   CTF_YELLOW_FLAG_LOST            = 32;
- const float   CTF_YELLOW_FLAG_CARRYING        = 48;
- const float   CTF_PINK_FLAG_TAKEN                     = 64;
- const float   CTF_PINK_FLAG_LOST                      = 128;
- const float   CTF_PINK_FLAG_CARRYING          = 192;
- const float   CTF_NEUTRAL_FLAG_TAKEN          = 256;
- const float   CTF_NEUTRAL_FLAG_LOST           = 512;
- const float   CTF_NEUTRAL_FLAG_CARRYING       = 768;
- const float CTF_FLAG_NEUTRAL                  = 2048;
- const float CTF_SHIELDED                              = 4096;
 +
++const int CTF_RED_FLAG_TAKEN                  = 1;
++const int CTF_RED_FLAG_LOST                           = 2;
++const int CTF_RED_FLAG_CARRYING                       = 3;
++const int CTF_BLUE_FLAG_TAKEN                 = 4;
++const int CTF_BLUE_FLAG_LOST                  = 8;
++const int CTF_BLUE_FLAG_CARRYING              = 12;
++const int CTF_YELLOW_FLAG_TAKEN                       = 16;
++const int CTF_YELLOW_FLAG_LOST                        = 32;
++const int CTF_YELLOW_FLAG_CARRYING            = 48;
++const int CTF_PINK_FLAG_TAKEN                 = 64;
++const int CTF_PINK_FLAG_LOST                  = 128;
++const int CTF_PINK_FLAG_CARRYING              = 192;
++const int CTF_NEUTRAL_FLAG_TAKEN              = 256;
++const int CTF_NEUTRAL_FLAG_LOST                       = 512;
++const int CTF_NEUTRAL_FLAG_CARRYING           = 768;
++const int CTF_FLAG_NEUTRAL                            = 2048;
++const int CTF_SHIELDED                                        = 4096;
++
+ #endif