-entity players;
-entity teams;
-var float team_count; // real teams
+#include "miscfunctions.qh"
+#include "_all.qh"
+
+#include "hud.qh"
+
+#include "../common/command/generic.qh"
+
+#include "../common/teams.qh"
+#include "../common/util.qh"
+
+#include "../csqcmodellib/cl_model.qh"
+
void AuditLists()
{
if(!tm)
{
- print(_("Trying to remove a team which is not in the teamlist!"));
+ LOG_INFO(_("Trying to remove a team which is not in the teamlist!"));
return;
}
parent.sort_next = Team.sort_next;
entity GetTeam(int Team, bool add)
{
- float num;
- entity tm;
- num = (Team == NUM_SPECTATOR) ? 16 : Team;
+ int num = (Team == NUM_SPECTATOR) ? 16 : Team;
if(teamslots[num])
return teamslots[num];
if (!add)
return world;
- tm = spawn();
+ entity tm = spawn();
tm.team = Team;
teamslots[num] = tm;
RegisterTeam(tm);
{
vector v;
v = stov(cvar_string(cvarname));
- if(v_x == 0)
+ if(v.x == 0)
v = '8 8 0';
- if(v_y == 0)
- v_y = v.x;
- v_z = 0;
+ if(v.y == 0)
+ v.y = v.x;
+ v.z = 0;
return v;
}
{
vector w = '0 0 0';
// FTEQCC SUCKS AGAIN
- w_x = v.x * cos(a) + v.y * sin(a);
- w_y = -1 * v.x * sin(a) + v.y * cos(a);
+ w.x = v.x * cos(a) + v.y * sin(a);
+ w.y = -1 * v.x * sin(a) + v.y * cos(a);
return w;
}
-int ColorTranslateMode;
-
-string ColorTranslateRGB(string s)
-{
- if(ColorTranslateMode & 1)
- return strdecolorize(s);
- else
- return s;
-}
-
// decolorizes and team colors the player name when needed
string playername(string thename, float teamid)
{
// left and right lines
pos.x -= thickness;
- line_dim_x = thickness;
- line_dim_y = dim.y;
+ line_dim.x = thickness;
+ line_dim.y = dim.y;
drawfill(pos, line_dim, color, theAlpha, drawflag);
drawfill(pos + (dim.x + thickness) * '1 0 0', line_dim, color, theAlpha, drawflag);
// upper and lower lines
pos.y -= thickness;
- line_dim_x = dim.x + thickness * 2; // make upper and lower lines longer
- line_dim_y = thickness;
+ line_dim.x = dim.x + thickness * 2; // make upper and lower lines longer
+ line_dim.y = thickness;
drawfill(pos, line_dim, color, theAlpha, drawflag);
drawfill(pos + (dim.y + thickness) * '0 1 0', line_dim, color, theAlpha, drawflag);
}
vector current_pos = '0 0 0', end_pos, new_size = '0 0 0', ratio = '0 0 0';
end_pos = pos + area;
- current_pos_y = pos.y;
+ current_pos.y = pos.y;
while (current_pos.y < end_pos.y)
{
- current_pos_x = pos.x;
+ current_pos.x = pos.x;
while (current_pos.x < end_pos.x)
{
- new_size_x = min(sz.x, end_pos.x - current_pos.x);
- new_size_y = min(sz.y, end_pos.y - current_pos.y);
- ratio_x = new_size.x / sz.x;
- ratio_y = new_size.y / sz.y;
+ new_size.x = min(sz.x, end_pos.x - current_pos.x);
+ new_size.y = min(sz.y, end_pos.y - current_pos.y);
+ ratio.x = new_size.x / sz.x;
+ ratio.y = new_size.y / sz.y;
drawsubpic(current_pos, new_size, pic, '0 0 0', ratio, color, theAlpha, drawflag);
current_pos.x += sz.x;
}
}
}
-// drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
-var float _drawpic_imgaspect;
-var vector _drawpic_imgsize;
-var vector _drawpic_sz;
-var float _drawpic_oldsz;
-var string _drawpic_picpath;
-#define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
- do {\
- _drawpic_imgsize = draw_getimagesize(pic);\
- if(_drawpic_imgsize != '0 0 0') {\
- _drawpic_imgaspect = _drawpic_imgsize.x/_drawpic_imgsize.y;\
- _drawpic_sz = mySize;\
- if(_drawpic_sz.x/_drawpic_sz.y > _drawpic_imgaspect) {\
- _drawpic_oldsz = _drawpic_sz.x;\
- _drawpic_sz_x = _drawpic_sz.y * _drawpic_imgaspect;\
- if(_drawpic_sz.x)\
- drawpic(pos + eX * (_drawpic_oldsz - _drawpic_sz.x) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
- } else {\
- _drawpic_oldsz = _drawpic_sz.y;\
- _drawpic_sz_y = _drawpic_sz.x / _drawpic_imgaspect;\
- if(_drawpic_sz.y)\
- drawpic(pos + eY * (_drawpic_oldsz - _drawpic_sz.y) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
- }\
- }\
- } while(0)
-
-// draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
-#define drawpic_aspect_skin(pos,pic,sz,color,theAlpha,drawflag)\
- do{\
- _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
- if(precache_pic(_drawpic_picpath) == "") {\
- _drawpic_picpath = strcat("gfx/hud/default/", pic);\
- }\
- drawpic_aspect(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
- _drawpic_picpath = string_null;\
- } while(0)
-
-// draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
-#define drawpic_skin(pos,pic,sz,color,theAlpha,drawflag)\
- do{\
- _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
- if(precache_pic(_drawpic_picpath) == "") {\
- _drawpic_picpath = strcat("gfx/hud/default/", pic);\
- }\
- drawpic(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
- _drawpic_picpath = string_null;\
- } while(0)
-
void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
{
float sz;
drawpic_aspect_skin_expanding(position, pic, theScale, rgb, theAlpha, flag, fadelerp);
drawpic_skin(position, pic, theScale, rgb, theAlpha * fadelerp, flag);
}
-#define SET_POS_AND_SZ_Y_ASPECT(allow_colors)\
- float textaspect, oldsz;\
- textaspect = stringwidth(text, allow_colors, '1 1 1' * sz.y) / sz.y;\
- if(sz.x/sz.y > textaspect) {\
- oldsz = sz.x;\
- sz_x = sz.y * textaspect;\
- pos.x += (oldsz - sz.x) * 0.5;\
- } else {\
- oldsz = sz.y;\
- sz_y = sz.x / textaspect; \
- pos.y += (oldsz - sz.y) * 0.5;\
- }
// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag) {
- SET_POS_AND_SZ_Y_ASPECT(FALSE)
+ SET_POS_AND_SZ_Y_ASPECT(false);
drawstring(pos, text, '1 1 0' * sz.y, color, theAlpha, drawflag);
}
// drawstring wrapper to draw a colorcodedstring as large as possible with preserved aspect ratio into a box
void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float theAlpha, float drawflag) {
- SET_POS_AND_SZ_Y_ASPECT(TRUE)
+ SET_POS_AND_SZ_Y_ASPECT(true);
drawcolorcodedstring(pos, text, '1 1 0' * sz.y, theAlpha, drawflag);
}
-vector drawfontscale;
void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
{
float sz;
drawfontscale = sz * '1 1 0';
dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
- drawstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth(text, FALSE, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), rgb, theAlpha * (1 - fadelerp), flag);
+ drawstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth(text, false, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), rgb, theAlpha * (1 - fadelerp), flag);
// width parameter:
// (scale_x * sz / drawfontscale_x) * drawfontscale_x * SIZE1 / (scale_x * sz)
// SIZE1
// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp) {
- SET_POS_AND_SZ_Y_ASPECT(FALSE)
+ SET_POS_AND_SZ_Y_ASPECT(false);
drawstring_expanding(pos, text, '1 1 0' * sz.y, color, theAlpha, drawflag, fadelerp);
}
drawfontscale = sz * '1 1 0';
dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
- drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth(text, TRUE, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), theAlpha * (1 - fadelerp), flag);
+ drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth(text, true, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), theAlpha * (1 - fadelerp), flag);
drawfontscale = '1 1 0';
}
void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp) {
- SET_POS_AND_SZ_Y_ASPECT(TRUE)
+ SET_POS_AND_SZ_Y_ASPECT(true);
drawcolorcodedstring_expanding(pos, text, '1 1 0' * sz.y, theAlpha, drawflag, fadelerp);
}
break;
}
-void DrawCircleClippedPic(vector centre, float radius, string pic, float f, vector rgb, float a, float drawflag)
+void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag)
{
float x, y, q, d;
vector ringsize, v, t;
- ringsize = radius * '1 1 0';
+ ringsize = radi * '1 1 0';
x = cos(f * 2 * M_PI);
y = sin(f * 2 * M_PI);
}
}
-const vector GETPLAYERORIGIN_ERROR = '1123581321 2357111317 3141592653'; // way out of bounds for anything on the map
vector getplayerorigin(int pl)
{
entity e;
if(e)
{
if(e.colormap > 0)
- return colormapPaletteColor(((e.colormap >= 1024) ? e.colormap : stof(getplayerkeyvalue(e.colormap - 1, "colors"))) & 0x0F, TRUE);
+ return colormapPaletteColor(((e.colormap >= 1024) ? e.colormap : stof(getplayerkeyvalue(e.colormap - 1, "colors"))) & 0x0F, true);
}
return '1 1 1';
if(e)
return e.csqcmodel_isdead;
- return FALSE;
+ return false;
}
-void URI_Get_Callback(float id, float status, string data)
+void URI_Get_Callback(int id, float status, string data)
{
if(url_URI_Get_Callback(id, status, data))
{
}
else
{
- printf("Received HTTP request data for an invalid id %d.\n", id);
+ LOG_INFOF("Received HTTP request data for an invalid id %d.\n", id);
}
}
drawfont = FONT_USER+1;
}
-
-const float MAX_ACCURACY_LEVELS = 10;
-float acc_lev[MAX_ACCURACY_LEVELS];
-vector acc_col[MAX_ACCURACY_LEVELS];
-float acc_col_loadtime;
-int acc_levels;
-string acc_color_levels;
void Accuracy_LoadLevels()
{
if(autocvar_accuracy_color_levels != acc_color_levels)
if(acc_levels > MAX_ACCURACY_LEVELS)
acc_levels = MAX_ACCURACY_LEVELS;
if(acc_levels < 2)
- print("Warning: accuracy_color_levels must contain at least 2 values\n");
+ LOG_INFO("Warning: accuracy_color_levels must contain at least 2 values\n");
int i;
for(i = 0; i < acc_levels; ++i)