]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Purge miscfunctions.qc from the client-side codebase, also remove an old unused CSQC...
authorMario <mario.mario@y7mail.com>
Tue, 29 Sep 2020 11:58:35 +0000 (21:58 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 29 Sep 2020 11:58:35 +0000 (21:58 +1000)
53 files changed:
qcsrc/client/_mod.inc
qcsrc/client/_mod.qh
qcsrc/client/command/cl_cmd.qc
qcsrc/client/csqc_constants.qh [deleted file]
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/draw.qc [new file with mode: 0644]
qcsrc/client/draw.qh [new file with mode: 0644]
qcsrc/client/hud/crosshair.qc
qcsrc/client/hud/hud.qc
qcsrc/client/hud/hud.qh
qcsrc/client/hud/hud_config.qc
qcsrc/client/hud/panel/ammo.qc
qcsrc/client/hud/panel/centerprint.qc
qcsrc/client/hud/panel/chat.qc
qcsrc/client/hud/panel/engineinfo.qc
qcsrc/client/hud/panel/healtharmor.qc
qcsrc/client/hud/panel/infomessages.qc
qcsrc/client/hud/panel/modicons.qc
qcsrc/client/hud/panel/notify.qc
qcsrc/client/hud/panel/physics.qc
qcsrc/client/hud/panel/powerups.qc
qcsrc/client/hud/panel/pressedkeys.qc
qcsrc/client/hud/panel/quickmenu.qc
qcsrc/client/hud/panel/racetimer.qc
qcsrc/client/hud/panel/radar.qc
qcsrc/client/hud/panel/score.qc
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/hud/panel/timer.qc
qcsrc/client/hud/panel/vote.qc
qcsrc/client/hud/panel/weapons.qc
qcsrc/client/hud/panel/weapons.qh
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/client/mapvoting.qc
qcsrc/client/mapvoting.qh
qcsrc/client/miscfunctions.qc [deleted file]
qcsrc/client/miscfunctions.qh [deleted file]
qcsrc/client/shownames.qc
qcsrc/client/view.qc
qcsrc/client/view.qh
qcsrc/common/constants.qh
qcsrc/common/debug.qh
qcsrc/common/gamemodes/gamemode/clanarena/cl_clanarena.qc
qcsrc/common/gamemodes/gamemode/ctf/cl_ctf.qc
qcsrc/common/gamemodes/gamemode/domination/cl_domination.qc
qcsrc/common/gamemodes/gamemode/keepaway/cl_keepaway.qc
qcsrc/common/gamemodes/gamemode/race/cl_race.qc
qcsrc/common/minigames/cl_minigames_hud.qc
qcsrc/common/minigames/minigame/nmm.qc
qcsrc/common/physics/player.qh
qcsrc/common/util.qc
qcsrc/common/util.qh
qcsrc/server/world.qh

index ec82018a3a520810bb443a95848ca8afb2e31b70..8f56739df0f66ea1458555cb83643b9df60e5bf1 100644 (file)
@@ -2,9 +2,9 @@
 #include <client/announcer.qc>
 #include <client/bgmscript.qc>
 #include <client/csqcmodel_hooks.qc>
+#include <client/draw.qc>
 #include <client/main.qc>
 #include <client/mapvoting.qc>
-#include <client/miscfunctions.qc>
 #include <client/player_skeleton.qc>
 #include <client/resources.qc>
 #include <client/shownames.qc>
index 85d9c1204a57220e9382a0a3c7abbebfe76cc41a..5f82413c4633f25f2b2b14d528c2d52b46283e68 100644 (file)
@@ -2,9 +2,9 @@
 #include <client/announcer.qh>
 #include <client/bgmscript.qh>
 #include <client/csqcmodel_hooks.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
 #include <client/mapvoting.qh>
-#include <client/miscfunctions.qh>
 #include <client/player_skeleton.qh>
 #include <client/resources.qh>
 #include <client/shownames.qh>
index 127f404e7f6b8e2dc591fb7879a0ed8b7fba0855..9f3f232ccdc26dd2ef0a0dd789c7e20ef0f42dfb 100644 (file)
@@ -8,6 +8,7 @@
 #include "cl_cmd.qh"
 
 #include "../autocvars.qh"
+#include <client/draw.qh>
 #include <client/hud/_mod.qh>
 #include <client/hud/panel/quickmenu.qh>
 #include <client/hud/panel/radar.qh>
@@ -15,7 +16,6 @@
 #include <client/hud/panel/vote.qh>
 #include "../main.qh"
 #include "../mapvoting.qh"
-#include "../miscfunctions.qh"
 #include <client/view.qh>
 
 #include <client/mutators/_mod.qh>
diff --git a/qcsrc/client/csqc_constants.qh b/qcsrc/client/csqc_constants.qh
deleted file mode 100644 (file)
index d8906b1..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-#pragma once
-
-// Mask Constants (set .drawmask on entities; use R_AddEntities to add all entities based on mask)
-const int              MASK_ENGINE                                             = BIT(0);
-const int              MASK_ENGINEVIEWMODELS                   = BIT(1);
-const int              MASK_NORMAL                                             = BIT(2);
-
-// Renderflag Constants (used for CSQC entities)
-const int              RF_VIEWMODEL                                    = BIT(0);
-const int              RF_EXTERNALMODEL                                = BIT(1);
-const int              RF_DEPTHHACK                                    = BIT(2);
-const int              RF_ADDITIVE                                             = BIT(3);
-const int              RF_USEAXIS                                              = BIT(4);
-
-// Viewflag Constants (use with R_SetView)
-const int              VF_MIN                                                  = 1;    //(vector)
-const int              VF_MIN_X                                                = 2;    //(float)
-const int              VF_MIN_Y                                                = 3;    //(float)
-const int              VF_SIZE                                                 = 4;    //(vector) (viewport size)
-const int              VF_SIZE_Y                                               = 5;    //(float)
-const int              VF_SIZE_X                                               = 6;    //(float)
-const int              VF_VIEWPORT                                             = 7;    //(vector, vector)
-const int              VF_FOV                                                  = 8;    //(vector)
-const int              VF_FOVX                                                 = 9;    //(float)
-const int              VF_FOVY                                                 = 10;   //(float)
-const int              VF_ORIGIN                                               = 11;   //(vector)
-const int              VF_ORIGIN_X                                             = 12;   //(float)
-const int              VF_ORIGIN_Y                                             = 13;   //(float)
-const int              VF_ORIGIN_Z                                             = 14;   //(float)
-const int              VF_ANGLES                                               = 15;   //(vector)
-const int              VF_ANGLES_X                                             = 16;   //(float)
-const int              VF_ANGLES_Y                                             = 17;   //(float)
-const int              VF_ANGLES_Z                                             = 18;   //(float)
-const int              VF_DRAWWORLD                                    = 19;   //(float)
-const int              VF_DRAWENGINEHUD                                = 20;   //(float)
-const int              VF_DRAWCROSSHAIR                                = 21;   //(float)
-const int              VF_PERSPECTIVE                                  = 200;  //(float)
-
-const int              VF_CL_VIEWANGLES                                = 33;   //(vector)
-const int              VF_CL_VIEWANGLES_X                              = 34;   //(float)
-const int              VF_CL_VIEWANGLES_Y                              = 35;   //(float)
-const int              VF_CL_VIEWANGLES_Z                              = 36;   //(float)
-
-// Quake-style Point Contents
-const int              CONTENT_EMPTY                                   = -1;
-const int              CONTENT_SOLID                                   = -2;
-const int              CONTENT_WATER                                   = -3;
-const int              CONTENT_SLIME                                   = -4;
-const int              CONTENT_LAVA                                    = -5;
-const int              CONTENT_SKY                                             = -6;
-
-// Vector / Hull Constants
-const vector   VEC_1                                                   = '1 1 1';
-const vector   VEC_0                                                   = '0 0 0';
-const vector   VEC_M1                                                  = '-1 -1 -1';
-
-const vector   VEC_HULL_MIN                                    = '-16 -16 -24';
-const vector   VEC_HULL_MAX                                    = '16 16 32';
-
-// Effect Constants
-const int      EF_NODRAW                                               = BIT(4);
-const int      EF_ADDITIVE                                             = BIT(5);
-const int      EF_BLUE                                                 = BIT(6);
-const int      EF_RED                                                  = BIT(7);
-const int      EF_FULLBRIGHT                                   = BIT(9);
-const int      EF_FLAME                                                = BIT(10);
-const int      EF_STARDUST                                             = BIT(11);
-const int      EF_NOSHADOW                                             = BIT(12);
-const int      EF_NODEPTHTEST                                  = BIT(13);
-
-// Quake Player Flag Constants
-const int      PFL_ONGROUND                                    = BIT(0);
-const int      PFL_CROUCH                                              = BIT(1);
-const int      PFL_DEAD                                                = BIT(2);
-const int      PFL_GIBBED                                              = BIT(3);
-
-// Quake Temporary Entity Constants
-const int              TE_SPIKE                                                = 0;
-const int              TE_SUPERSPIKE                                   = 1;
-const int              TE_GUNSHOT                                              = 2;
-const int              TE_EXPLOSION                                    = 3;
-const int              TE_TAREXPLOSION                                 = 4;
-const int              TE_LIGHTNING1                                   = 5;
-const int              TE_LIGHTNING2                                   = 6;
-const int              TE_WIZSPIKE                                             = 7;
-const int              TE_KNIGHTSPIKE                                  = 8;
-const int              TE_LIGHTNING3                                   = 9;
-const int              TE_LAVASPLASH                                   = 10;
-const int              TE_TELEPORT                                             = 11;
-const int      TE_EXPLOSION2                                   = 12;
-// Darkplaces Additions
-const int      TE_EXPLOSIONRGB                                 = 53;
-const int              TE_GUNSHOTQUAD                                  = 57;
-const int              TE_EXPLOSIONQUAD                                = 70;
-
-// Math Constants
-const int      EXTRA_LOW                                               = -99999999;
-const int      EXTRA_HIGH                                              = 99999999;
-
-// Frik File Constants
-const int              FILE_READ                                               = 0;
-const int              FILE_APPEND                                             = 1;
-const int              FILE_WRITE                                              = 2;
-
-// Button values used by input_buttons
-const int BUTTON_ATTACK = BIT(0);
-const int BUTTON_JUMP = BIT(1);
-const int BUTTON_3 = BIT(2);
-const int BUTTON_4 = BIT(3);
-const int BUTTON_5 = BIT(4);
-const int BUTTON_6 = BIT(5);
-const int BUTTON7 = BIT(6);
-const int BUTTON8 = BIT(7);
-const int BUTTON_USE = BIT(8);
-const int BUTTON_CHAT = BIT(9);
-const int BUTTON_PRYDONCURSOR = BIT(10);
-const int BUTTON_9 = BIT(11);
-const int BUTTON_10 = BIT(12);
-const int BUTTON_11 = BIT(13);
-const int BUTTON_12 = BIT(14);
-const int BUTTON_13 = BIT(15);
-const int BUTTON_14 = BIT(16);
-const int BUTTON_15 = BIT(17);
-const int BUTTON_16 = BIT(18);
-
-const int SOLID_NOT            = 0; // no interaction with other objects
-const int SOLID_TRIGGER        = 1; // touch on edge, but not blocking
-const int SOLID_BBOX           = 2; // touch on edge, block
-const int SOLID_SLIDEBOX       = 3; // touch on edge, but not an onground
-const int SOLID_BSP            = 4; // bsp clip, touch on edge, block
-const int SOLID_CORPSE         = 5; // same as SOLID_BBOX, except it behaves as SOLID_NOT against SOLID_SLIDEBOX objects (players/monsters)
-
-const int MOVE_NORMAL = 0; // same as false
-const int MOVE_NOMONSTERS = 1; // same as true
-const int MOVE_MISSILE = 2; // save as movement with .move_movetype == MOVETYPE_FLYMISSILE
-const int MOVE_HITMODEL = 4;
-const int MOVE_WORLDONLY = 3;
-
-const int CAMERA_FREE = 1;
-const int CAMERA_CHASE = 2;
-
-const int EF_NOMODELFLAGS = BIT(23);
index 82b045801429a2f750c2513db28fa0b148d552b8..f0ff55e8ab56a09021c507bfd963d6a72a19a3dd 100644 (file)
@@ -1,7 +1,6 @@
 #include "csqcmodel_hooks.qh"
 #include "autocvars.qh"
 #include "main.qh"
-#include "miscfunctions.qh"
 #include <client/mutators/_mod.qh>
 #include <client/main.qh>
 #include "player_skeleton.qh"
diff --git a/qcsrc/client/draw.qc b/qcsrc/client/draw.qc
new file mode 100644 (file)
index 0000000..f08fbf5
--- /dev/null
@@ -0,0 +1,310 @@
+#include "draw.qh"
+
+#include <client/hud/hud.qh>
+
+void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag)
+{
+       vector line_dim = '0 0 0';
+
+       // left and right lines
+       pos.x -= thickness;
+       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;
+       drawfill(pos, line_dim, color, theAlpha, drawflag);
+       drawfill(pos + (dim.y + thickness) * '0 1 0', line_dim, color, theAlpha, drawflag);
+}
+
+void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag)
+{
+       pos = HUD_Shift(pos);
+       sz = HUD_Scale(sz);
+       area = HUD_Scale(area);
+
+       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;
+       while (current_pos.y < end_pos.y)
+       {
+               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;
+                       drawsubpic(current_pos, new_size, pic, '0 0 0', ratio, color, theAlpha, drawflag);
+                       current_pos.x += sz.x;
+               }
+               current_pos.y += sz.y;
+       }
+}
+
+float expandingbox_sizefactor_from_fadelerp(float fadelerp)
+{
+       return 1.2 / (1.2 - fadelerp);
+}
+
+vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor)
+{
+       boxsize.x *= boxxsizefactor; // easier interface for text
+       return boxsize * (0.5 * (1 - sz));
+}
+
+void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
+{
+       float sz;
+       sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
+
+       drawpic_aspect_skin(position + expandingbox_resize_centered_box_offset(sz, theScale, 1), pic, theScale * sz, rgb, theAlpha * (1 - fadelerp), flag);
+}
+
+void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
+{
+       drawpic_aspect_skin_expanding(position, pic, theScale, rgb, theAlpha, flag, fadelerp);
+       drawpic_skin(position, pic, theScale, rgb, theAlpha * fadelerp, flag);
+}
+
+float stringwidth(string text, float handleColors, vector sz)
+{
+       vector dfs = drawfontscale;
+       drawfontscale = '1 1 0';
+       float r = stringwidth_builtin(text, handleColors, sz);
+       drawfontscale = dfs;
+       return r;
+}
+
+#define SET_POS_AND_SZ_Y_ASPECT(allow_colors) MACRO_BEGIN \
+       float textaspect, oldsz; \
+       vector dfs = drawfontscale; \
+       drawfontscale = '1 1 0'; \
+       textaspect = stringwidth(text, allow_colors, '1 1 1' * sz.y) / sz.y; \
+       drawfontscale = dfs; \
+       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; \
+       } \
+MACRO_END
+
+// 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);
+       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);
+       drawcolorcodedstring(pos, text, '1 1 0' * sz.y, theAlpha, drawflag);
+}
+
+void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
+{
+       float sz;
+       sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
+
+       drawfontscale = hud_scale * sz;
+       vector dfs = drawfontscale;
+       drawfontscale = sz * '1 1 0';
+       float textaspect = stringwidth_builtin(text, false, theScale * (sz / drawfontscale.x)) / (theScale.x * sz);
+       drawfontscale = dfs;
+       drawstring(position + expandingbox_resize_centered_box_offset(sz, theScale, textaspect), text, HUD_Scale(theScale * (sz / drawfontscale.x)), rgb, theAlpha * (1 - fadelerp), flag);
+       // width parameter:
+       //    (scale_x * sz / drawfontscale.x) * drawfontscale.x * SIZE1 / (scale_x * sz)
+       //    SIZE1
+       drawfontscale = hud_scale;
+}
+
+// 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);
+       drawstring_expanding(pos, text, '1 1 0' * sz.y, color, theAlpha, drawflag, fadelerp);
+}
+
+void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp)
+{
+       float sz;
+       sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
+
+       drawfontscale = hud_scale * sz;
+       // eventually replace with drawcolorcodedstring
+       drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth_builtin(text, true, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), theAlpha * (1 - fadelerp), flag);
+       drawfontscale = hud_scale;
+}
+
+void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp) {
+       SET_POS_AND_SZ_Y_ASPECT(true);
+       drawcolorcodedstring_expanding(pos, text, '1 1 0' * sz.y, theAlpha, drawflag, fadelerp);
+}
+
+// this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
+float PolyDrawModelSurface(entity e, float i_s)
+{
+       float i_t;
+       float n_t;
+       vector tri;
+       string tex;
+       tex = getsurfacetexture(e, i_s);
+       if (!tex)
+               return 0; // this is beyond the last one
+       n_t = getsurfacenumtriangles(e, i_s);
+       for(i_t = 0; i_t < n_t; ++i_t)
+       {
+               tri = getsurfacetriangle(e, i_s, i_t);
+               R_BeginPolygon(tex, 0, false);
+               R_PolygonVertex(getsurfacepoint(e, i_s, tri.x), getsurfacepointattribute(e, i_s, tri.x, SPA_TEXCOORDS0), '1 1 1', 1);
+               R_PolygonVertex(getsurfacepoint(e, i_s, tri.y), getsurfacepointattribute(e, i_s, tri.y, SPA_TEXCOORDS0), '1 1 1', 1);
+               R_PolygonVertex(getsurfacepoint(e, i_s, tri.z), getsurfacepointattribute(e, i_s, tri.z, SPA_TEXCOORDS0), '1 1 1', 1);
+               R_EndPolygon();
+       }
+       return 1;
+}
+void PolyDrawModel(entity e)
+{
+       float i_s;
+       for(i_s = 0; ; ++i_s)
+               if(!PolyDrawModelSurface(e, i_s))
+                       break;
+}
+
+void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag)
+{
+       vector ringsize, v, t;
+       ringsize = radi * '1 1 0';
+       centre = HUD_Shift(centre);
+       ringsize = HUD_Scale(ringsize);
+
+       if(f >= 1)
+       {
+               // draw full rectangle
+               R_BeginPolygon(pic, drawflag, true);
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.y += 0.5 * ringsize.y;        t += '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.y -= 0.5 * ringsize.y;        t -= '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+               R_EndPolygon();
+               return;  // Complete rectangle, nothing more needed.
+       }
+
+       float co = cos(f * 2 * M_PI);
+       float si = sin(f * 2 * M_PI);
+       float q = fabs(co) + fabs(si);
+       co /= q;
+       si /= q;
+
+       if(f > 0.75)
+       {
+               // draw upper half in full
+               R_BeginPolygon(pic, drawflag, true);
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.y += 0.5 * ringsize.y;        t += '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+               R_EndPolygon();
+               // draw clipped lower half as a quad
+               R_BeginPolygon(pic, drawflag, true);
+                       v = centre;                     t = '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.y -= 0.5 * ringsize.y;        t -= '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+       }
+       else if(f > 0.5)
+       {
+               // draw upper half in full
+               R_BeginPolygon(pic, drawflag, true);
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.y += 0.5 * ringsize.y;        t += '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+               R_EndPolygon();
+               // draw clipped lower half as a triangle
+               R_BeginPolygon(pic, drawflag, true);
+                       v = centre;                     t = '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+       }
+       else if(f > 0.25)
+       {
+               // draw clipped lower half as a quad
+               R_BeginPolygon(pic, drawflag, true);
+                       v = centre;                     t = '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.y += 0.5 * ringsize.y;        t += '0.5 -0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+       }
+       else if (f > 0)
+       {
+               // draw clipped lower half as a triangle
+               R_BeginPolygon(pic, drawflag, true);
+                       v = centre;                     t = '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
+       }
+       else
+       {
+               // Nothing to draw.
+               return;
+       }
+
+       // The last, moving vertex.
+               v = centre;                     t = '0.5 0.5 0';
+               v.x += co * 0.5 * ringsize.x;   t += co * '0.5 0.5 0';
+               v.y += si * 0.5 * ringsize.y;   t += si * '0.5 -0.5 0';
+               R_PolygonVertex(v, t, rgb, a);
+       R_EndPolygon();
+}
diff --git a/qcsrc/client/draw.qh b/qcsrc/client/draw.qh
new file mode 100644 (file)
index 0000000..409161f
--- /dev/null
@@ -0,0 +1,121 @@
+#pragma once
+
+vector drawfontscale;
+#define draw_beginBoldFont() drawfont = FONT_USER + 2
+#define draw_endBoldFont() drawfont = FONT_USER + 1
+
+float expandingbox_sizefactor_from_fadelerp(float fadelerp);
+
+vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
+void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);
+
+void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag);
+
+// The following functions / macros must be called from within
+// the panel HUD / scoreboard code so that pos and size are scaled
+// when the hud_dynamic code is running.
+// Make use of stringwidth_builtin and draw*_builtin everywhere else.
+
+float stringwidth(string text, float handleColors, vector sz);
+
+#define drawpic(position, pic, size, rgb, alpha, flag) \
+       drawpic_builtin(HUD_Shift(position), pic, HUD_Scale(size), rgb, alpha, flag)
+
+#define drawcharacter(position, character, scale, rgb, alpha, flag) \
+       drawcharacter_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
+
+#define drawstring(position, text, scale, rgb, alpha, flag) \
+       drawstring_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
+
+#define drawcolorcodedstring(position, text, scale, alpha, flag) \
+       drawcolorcodedstring_builtin(HUD_Shift(position), text, scale, alpha, flag)
+
+#define drawcolorcodedstring2(position, text, scale, rgb, alpha, flag) \
+       drawcolorcodedstring2_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
+
+#define drawfill(position, size, rgb, alpha, flag) \
+       drawfill_builtin(HUD_Shift(position), HUD_Scale(size), rgb, alpha, flag)
+
+#define drawsetcliparea(xposition, yposition, w, h) \
+       drawsetcliparea_builtin(HUD_ShiftX(xposition), HUD_ShiftY(yposition), HUD_ScaleX(w), HUD_ScaleY(h))
+
+// Since drawsubpic usually gets called multiple times from within an
+// utility function, instead of scaling pos and size in every call
+// we scale them once for all in the beginning of that utility function.
+// That's why drawsubpic isn't remapped.
+/*
+#define drawsubpic(position, size, pic, srcPosition, srcSize, rgb, alpha, flag) \
+       drawsubpic_builtin(HUD_Shift(position), HUD_Scale(size), pic, HUD_Shift(srcPosition), HUD_Scale(srcSize), rgb, alpha, flag)
+*/
+
+// drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
+float _drawpic_imgaspect;
+vector _drawpic_imgsize;
+vector _drawpic_sz;
+float _drawpic_oldsz;
+string _drawpic_picpath;
+#define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
+       MACRO_BEGIN \
+               _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 * 0.5 * (_drawpic_oldsz - _drawpic_sz.x), 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 * 0.5 * (_drawpic_oldsz - _drawpic_sz.y), pic, _drawpic_sz, color, theAlpha, drawflag);\
+                       }\
+               }\
+       MACRO_END
+
+// 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)\
+       MACRO_BEGIN \
+               _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;\
+       MACRO_END
+
+// 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)\
+       MACRO_BEGIN \
+               _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;\
+       MACRO_END
+
+void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
+
+void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
+
+// 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);
+
+// 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);
+
+void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
+
+// 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);
+
+void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
+
+void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
+// this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
+float PolyDrawModelSurface(entity e, float i_s);
+void PolyDrawModel(entity e);
+
+void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag);
index 6bf0bb5772d2b91f70c133ca3ca6e5f3c1e5650c..1c0f06c6ad5fb949982a751830c3199590ed4fce 100644 (file)
@@ -1,8 +1,8 @@
 #include "crosshair.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 #include <client/hud/panel/scoreboard.qh>
 #include <client/view.qh>
 
index 114b44823201041dacda11b18eb1d8367bbe69a5..26561f1d75bc4c8a86f1893e9cf090595c101c3d 100644 (file)
@@ -1,7 +1,7 @@
 #include "hud.qh"
 
+#include <client/draw.qh>
 #include <client/items/items.qh>
-#include <client/miscfunctions.qh>
 #include <client/view.qh>
 #include "panel/scoreboard.qh"
 #include "hud_config.qh"
@@ -79,6 +79,46 @@ void LoadMenuSkinValues()
        }
 }
 
+void HUD_Scale_Disable()
+{
+       hud_scale = '1 1 0';
+       hud_shift = '0 0 0';
+       drawfontscale = hud_scale;
+}
+
+void HUD_Scale_Enable()
+{
+       hud_scale = hud_scale_current;
+       hud_shift = hud_shift_current;
+       drawfontscale = hud_scale;
+}
+
+vector HUD_Scale(vector v)
+{
+       v.x = HUD_ScaleX(v.x);
+       v.y = HUD_ScaleY(v.y);
+       return v;
+}
+
+vector HUD_Shift(vector v)
+{
+       v.x = HUD_ShiftX(v.x);
+       v.y = HUD_ShiftY(v.y);
+       return v;
+}
+
+vector HUD_GetFontsize(string cvarname)
+{
+       vector v;
+       v = stov(cvar_string(cvarname));
+       if(v.x == 0)
+               v = '8 8 0';
+       if(v.y == 0)
+               v.y = v.x;
+       v.z = 0;
+       return v;
+}
+
 vector HUD_Get_Num_Color(float hp, float maxvalue, bool blink)
 {
        const vector COLOR100 = '0 1 0'; // green
index 1021d7067e06f3db382643a172be9a6463bd3999..dae8a72d9b5fced452fa5c4f469b8f7343734cea 100644 (file)
@@ -9,6 +9,18 @@ void draw_cursor(vector pos, vector ofs, string img, vector col, float a);
 void draw_cursor_normal(vector pos, vector col, float a);
 void LoadMenuSkinValues();
 
+void HUD_Scale_Disable();
+void HUD_Scale_Enable();
+
+#define HUD_ScaleX(f) (f * hud_scale.x)
+#define HUD_ScaleY(f) (f * hud_scale.y)
+#define HUD_ShiftX(f) (f + hud_shift.x + hud_shift.z * (f - hud_scale_center.x))
+#define HUD_ShiftY(f) (f + hud_shift.y + hud_shift.z * (f - hud_scale_center.y))
+vector HUD_Scale(vector v);
+vector HUD_Shift(vector v);
+
+vector HUD_GetFontsize(string cvarname);
+
 void Hud_Dynamic_Frame();
 
 bool HUD_Radar_Clickable();
index 32c7889cac866ef5266d8a3d11cf7300ff1483eb..0b4c58c2160babae9ea7decb39cc8e9426f676d0 100644 (file)
@@ -3,7 +3,7 @@
 #include "hud.qh"
 #include "panel/scoreboard.qh"
 #include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
 #include <client/view.qh>
 
 // Save the config
index b75c3ebabdb5fa0a154f6cf239911390f4d9d819..cab9d197d0aa6d3f29420d311f6e01f7eb3405a6 100644 (file)
@@ -1,9 +1,9 @@
 #include "ammo.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/items/items.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 #include <client/view.qh>
 #include <common/wepent.qh>
 #include <common/mutators/mutator/nades/nades.qh>
index 15f46d29c4d4e3a2413c235380ec73009dcad64e..7723c1f44496172dbaec3b794891280f853cd9cb 100644 (file)
@@ -2,7 +2,7 @@
 
 #include "scoreboard.qh"
 #include <common/notifications/all.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
 
 // CenterPrint (#16)
 
index d46aa81b8269a29960a4b6a5b475b3fc44d4b6b4..13ef78136d61ca8e0d7895faae112fbf4f11a815 100644 (file)
@@ -1,7 +1,7 @@
 #include "chat.qh"
 
 #include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
 
 // Chat (#12)
 
index 85d4259778d1598d1c0204fe0322596bd004c20f..7760c56f7c6a3865bc8fab19e66ef6f44b1f544f 100644 (file)
@@ -1,7 +1,7 @@
 #include "engineinfo.qh"
 
 #include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
 
 // Engine info (#13)
 
index 48b852bf95a1f79d538f42829f580c31be410d91..495aa63fc609df9ecf9e82c4335a78c0857aa048 100644 (file)
@@ -1,7 +1,7 @@
 #include "healtharmor.qh"
 
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 
 #include <common/deathtypes/all.qh>
 
index 03465cce56185d26267368b5c6043f57a435fc0d..632f3fad5425382625ada01d0774c8d2ca4dcf9f 100644 (file)
@@ -1,8 +1,8 @@
 #include "infomessages.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 
 #include <common/ent_cs.qh>
 
index 17ea987bf6c3cd9b03e13338d0e3940f296bd46d..49f2dab8ae3ffe172f60a9f22a4729b7c646f35c 100644 (file)
@@ -1,7 +1,7 @@
 #include "modicons.qh"
 
-#include <client/miscfunctions.qh>
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <common/mapinfo.qh>
 #include <common/ent_cs.qh>
 #include <common/scores.qh>
index 0dfb11db766bf0865ab7fd999e9b9d4cbd2e4ba5..b3804eccf3e19146bb1034813596a9968b4a0c0a 100644 (file)
@@ -1,7 +1,7 @@
 #include "notify.qh"
 
 #include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
 
 // Notifications (#4)
 
index a60821909b04512c92bedf4e7816639d691979ea..11ed12e82198461227226777c77aac57f8d37f2b 100644 (file)
@@ -1,7 +1,7 @@
 #include "physics.qh"
 
 #include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
 #include <lib/csqcmodel/cl_player.qh>
 
index 75fb0c2aaaf4009c80647750de6cbc8013413592..587d2007133b2eeae57402090e4a070fece253d4 100644 (file)
@@ -1,8 +1,8 @@
 #include "powerups.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 #include <common/items/_mod.qh>
 #include <common/util.qh>
 
index f29978c2d0da0527dc2a3112510bfe1cad5c8c74..021b66856d08733187bea69e9c7dff9bd70ecec2 100644 (file)
@@ -1,8 +1,8 @@
 #include "pressedkeys.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 
 // Pressed keys (#11)
 
index 6e3c185c8d29383043264a444007a7cb0d65e696..deed53da01e0323fc7bef89349f4431b38271c68 100644 (file)
@@ -1,8 +1,8 @@
 #include "quickmenu.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 #include <common/ent_cs.qh>
 #include <common/minigames/cl_minigames.qh>
 #include <client/hud/_mod.qh>
index 0703c4f2dcb9eaecd29a70f49213f091f08591d3..85fdc86c6635d7a85ee1da6d6ac1cda52cc0dbe7 100644 (file)
@@ -1,8 +1,8 @@
 #include "racetimer.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 
 // Race timer (#8)
 
index 66665498e07c6ced0a88d11371c4567c7aea4eee..1e688b1fde229e5fc547e722951338e6ce795998 100644 (file)
@@ -1,8 +1,8 @@
 #include "radar.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 #include <common/ent_cs.qh>
 #include <client/mapvoting.qh>
 #include <client/resources.qh>
index 553283e5bc4ab3bc2e15de5fde1eca5f9f94914f..81f91663c2d3436ff3022f5a0e7a63ed7f7e36bb 100644 (file)
@@ -1,8 +1,8 @@
 #include "score.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 #include "scoreboard.qh"
 #include <common/ent_cs.qh>
 #include <common/scores.qh>
index 05715bd6cf78dd3ae6dd9f6aa3d283a1064eca68..c21b990921f7d6a38ae489afc395a2af7246fde0 100644 (file)
@@ -1,9 +1,10 @@
 #include "scoreboard.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 #include <client/hud/panel/racetimer.qh>
+#include <client/hud/panel/weapons.qh>
 #include "quickmenu.qh"
 #include <common/ent_cs.qh>
 #include <common/constants.qh>
index e49c777db2491eeb25e0fa81bfa4d88ef001e1aa..446c6229bdc8f587da981d45d0f228a2c4b0a129 100644 (file)
@@ -1,7 +1,7 @@
 #include "timer.qh"
 
 #include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
 #include <client/view.qh>
 
 // Timer (#5)
index 2b2c7fa969c90f087b33bb086a97cbf78cb243ff..12f691c992001597cfa34627d5dd3243a2574e91 100644 (file)
@@ -1,8 +1,8 @@
 #include "vote.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 
 // Vote (#9)
 
index 03be211a23b82277d35575bab89baef212bc99d1..b252df19e8d9c7a64a89ac7385aef3ca73a80072 100644 (file)
@@ -1,8 +1,8 @@
 #include "weapons.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <client/main.qh>
-#include <client/miscfunctions.qh>
 #include <client/view.qh>
 #include <common/wepent.qh>
 
@@ -37,6 +37,54 @@ void HUD_Weapons_Export(int fh)
        HUD_Write_Cvar("hud_panel_weapons_selection_speed");
 }
 
+void Accuracy_LoadLevels()
+{
+       if(autocvar_accuracy_color_levels != acc_color_levels)
+       {
+               strcpy(acc_color_levels, autocvar_accuracy_color_levels);
+               acc_levels = tokenize_console(acc_color_levels);
+               if(acc_levels > MAX_ACCURACY_LEVELS)
+                       acc_levels = MAX_ACCURACY_LEVELS;
+               if(acc_levels < 2)
+                       LOG_INFO("Warning: accuracy_color_levels must contain at least 2 values");
+
+               int i;
+               for(i = 0; i < acc_levels; ++i)
+                       acc_lev[i] = stof(argv(i)) / 100.0;
+       }
+}
+
+void Accuracy_LoadColors()
+{
+       if(time > acc_col_loadtime)
+       if(acc_levels >= 2)
+       {
+               int i;
+               for(i = 0; i < acc_levels; ++i)
+                       acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
+               acc_col_loadtime = time + 2;
+       }
+}
+
+vector Accuracy_GetColor(float accuracy)
+{
+       float factor;
+       vector color;
+       if(acc_levels < 2)
+               return '0 0 0'; // return black, can't determine the right color
+
+       // find the max level lower than acc
+       int j = acc_levels-1;
+       while(j && accuracy < acc_lev[j])
+               --j;
+
+       // inject color j+1 in color j, how much depending on how much accuracy is higher than level j
+       factor = (accuracy - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
+       color = acc_col[j];
+       color = color + factor * (acc_col[j+1] - color);
+       return color;
+}
+
 entity weaponorder[REGISTRY_MAX(Weapons)];
 void weaponorder_swap(int i, int j, entity pass)
 {
index 6db88c68b39ee50fce1f8acce9c778465a3223ae..1315b0f0211f25d7cdd87b14babcc5307ea8ff51 100644 (file)
@@ -1,2 +1,14 @@
 #pragma once
 #include "../panel.qh"
+
+const int 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();
+
+void Accuracy_LoadColors();
+
+vector Accuracy_GetColor(float accuracy);
index 2c63adc4464c3a484477a8daad275cf83b453ebd..d111e8aadaaa023c09c4a1dfdd98f1c8b65d7187 100644 (file)
@@ -1,8 +1,8 @@
 #include "main.qh"
 
+#include <client/draw.qh>
 #include <client/items/items.qh>
 #include <common/ent_cs.qh>
-#include "miscfunctions.qh"
 #include <common/effects/effect.qh>
 #include <common/effects/qc/_mod.qh>
 #include <common/effects/all.qh>
@@ -187,6 +187,128 @@ void Shutdown()
        ReplicateVars(true); // destroy
 }
 
+void AuditLists()
+{
+       entity e;
+       entity prev;
+
+       prev = players;
+       for(e = prev.sort_next; e; prev = e, e = e.sort_next)
+       {
+               if(prev != e.sort_prev)
+                       error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
+       }
+
+       prev = teams;
+       for(e = prev.sort_next; e; prev = e, e = e.sort_next)
+       {
+               if(prev != e.sort_prev)
+                       error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
+       }
+}
+
+float RegisterPlayer(entity player)
+{
+       entity pl;
+       AuditLists();
+       for(pl = players.sort_next; pl; pl = pl.sort_next)
+               if(pl == player)
+                       error("Player already registered!");
+       player.sort_next = players.sort_next;
+       player.sort_prev = players;
+       if(players.sort_next)
+               players.sort_next.sort_prev = player;
+       players.sort_next = player;
+       AuditLists();
+       return true;
+}
+
+void RemovePlayer(entity player)
+{
+       entity pl, parent;
+       AuditLists();
+       parent = players;
+       for(pl = players.sort_next; pl && pl != player; pl = pl.sort_next)
+               parent = pl;
+
+       if(!pl)
+       {
+               error("Trying to remove a player which is not in the playerlist!");
+               return;
+       }
+       parent.sort_next = player.sort_next;
+       if(player.sort_next)
+               player.sort_next.sort_prev = parent;
+       AuditLists();
+}
+
+void MoveToLast(entity e)
+{
+       AuditLists();
+       entity ent = e.sort_next;
+       while(ent)
+       {
+               SORT_SWAP(ent, e);
+               ent = e.sort_next;
+       }
+       AuditLists();
+}
+
+float RegisterTeam(entity Team)
+{
+       assert_once(Team.team, eprint(Team));
+       entity tm;
+       AuditLists();
+       for(tm = teams.sort_next; tm; tm = tm.sort_next)
+               if(tm == Team)
+                       error("Team already registered!");
+       Team.sort_next = teams.sort_next;
+       Team.sort_prev = teams;
+       if(teams.sort_next)
+               teams.sort_next.sort_prev = Team;
+       teams.sort_next = Team;
+       if(Team.team && Team.team != NUM_SPECTATOR)
+               ++team_count;
+       AuditLists();
+       return true;
+}
+
+void RemoveTeam(entity Team)
+{
+       entity tm, parent;
+       AuditLists();
+       parent = teams;
+       for(tm = teams.sort_next; tm && tm != Team; tm = tm.sort_next)
+               parent = tm;
+
+       if(!tm)
+       {
+               LOG_INFO(_("Trying to remove a team which is not in the teamlist!"));
+               return;
+       }
+       parent.sort_next = Team.sort_next;
+       if(Team.sort_next)
+               Team.sort_next.sort_prev = parent;
+       if(Team.team && Team.team != NUM_SPECTATOR)
+               --team_count;
+       AuditLists();
+}
+
+entity GetTeam(int Team, bool add)
+{
+       TC(int, Team); TC(bool, add);
+       int num = (Team == NUM_SPECTATOR) ? 16 : Team;
+       if(teamslots[num])
+               return teamslots[num];
+       if (!add)
+               return NULL;
+       entity tm = new_pure(team);
+       tm.team = Team;
+       teamslots[num] = tm;
+       RegisterTeam(tm);
+       return tm;
+}
+
 .float has_team;
 bool SetTeam(entity o, int Team)
 {
@@ -1207,3 +1329,26 @@ string _getcommandkey(string cmd_name, string command, bool forcename)
        else
                return keys;
 }
+
+/** engine callback */
+void URI_Get_Callback(int id, int status, string data)
+{
+       TC(int, id); TC(int, status);
+       if(url_URI_Get_Callback(id, status, data))
+       {
+               // handled
+       }
+       else if (id == URI_GET_DISCARD)
+       {
+               // discard
+       }
+       else if (id >= URI_GET_CURL && id <= URI_GET_CURL_END)
+       {
+               // sv_cmd curl
+               Curl_URI_Get_Callback(id, status, data);
+       }
+       else
+       {
+               LOG_INFOF("Received HTTP request data for an invalid id %d.", id);
+       }
+}
index 784ecb9c99edf37d308a6e3aa14e8a9cc74d2e3b..1653ef64353753a872bdfc94891f973a0fde749a 100644 (file)
@@ -23,6 +23,24 @@ void Ent_Remove(entity this);
 
 void Gamemode_Init();
 
+entity players;
+entity teams;
+float team_count; // real teams
+
+void AuditLists();
+
+float RegisterPlayer(entity player);
+
+void RemovePlayer(entity player);
+
+void MoveToLast(entity e);
+
+float RegisterTeam(entity Team);
+
+void RemoveTeam(entity Team);
+
+entity GetTeam(int Team, bool add);
+
 bool SetTeam(entity pl, int Team);
 
 vector hud_fontsize;
index a38bb76cfc5b4bd4300bbcd5a3405f5f765e5c30..06a33f665e4932e1361292c3e2c79003d08c0273 100644 (file)
@@ -1,8 +1,8 @@
 #include "mapvoting.qh"
 
 #include "autocvars.qh"
+#include <client/draw.qh>
 #include "main.qh"
-#include "miscfunctions.qh"
 #include "hud/_mod.qh"
 #include "hud/panel/scoreboard.qh"
 
@@ -49,6 +49,19 @@ const int NUM_SSDIRS = 4;
 string ssdirs[NUM_SSDIRS];
 int n_ssdirs;
 
+bool PreviewExists(string name)
+{
+       if(autocvar_cl_readpicture_force)
+               return false;
+
+       if (fexists(strcat(name, ".tga"))) return true;
+       if (fexists(strcat(name, ".png"))) return true;
+       if (fexists(strcat(name, ".jpg"))) return true;
+       if (fexists(strcat(name, ".pcx"))) return true;
+
+       return false;
+}
+
 string MapVote_FormatMapItem(int id, string map, float _count, float maxwidth, vector fontsize)
 {
        TC(int, id);
index 8a6f542a0a597277cb598b45dff23f335f2ae824..8d184a95d7417609280f3f58263b59912c7e8b7b 100644 (file)
@@ -3,6 +3,8 @@
 #include <common/constants.qh>
 void MapVote_Draw();
 
+bool PreviewExists(string name);
+
 void Cmd_MapVote_MapDownload(int argc);
 
 float MapVote_InputEvent(float bInputType, float nPrimary, float nSecondary);
diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc
deleted file mode 100644 (file)
index 34d87b7..0000000
+++ /dev/null
@@ -1,625 +0,0 @@
-#include "miscfunctions.qh"
-
-#include "autocvars.qh"
-#include "hud/_mod.qh"
-#include "main.qh"
-
-#include <common/command/_mod.qh>
-
-#include <common/teams.qh>
-
-#include <lib/csqcmodel/cl_model.qh>
-
-
-void AuditLists()
-{
-       entity e;
-       entity prev;
-
-       prev = players;
-       for(e = prev.sort_next; e; prev = e, e = e.sort_next)
-       {
-               if(prev != e.sort_prev)
-                       error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
-       }
-
-       prev = teams;
-       for(e = prev.sort_next; e; prev = e, e = e.sort_next)
-       {
-               if(prev != e.sort_prev)
-                       error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
-       }
-}
-
-
-float RegisterPlayer(entity player)
-{
-       entity pl;
-       AuditLists();
-       for(pl = players.sort_next; pl; pl = pl.sort_next)
-               if(pl == player)
-                       error("Player already registered!");
-       player.sort_next = players.sort_next;
-       player.sort_prev = players;
-       if(players.sort_next)
-               players.sort_next.sort_prev = player;
-       players.sort_next = player;
-       AuditLists();
-       return true;
-}
-
-void RemovePlayer(entity player)
-{
-       entity pl, parent;
-       AuditLists();
-       parent = players;
-       for(pl = players.sort_next; pl && pl != player; pl = pl.sort_next)
-               parent = pl;
-
-       if(!pl)
-       {
-               error("Trying to remove a player which is not in the playerlist!");
-               return;
-       }
-       parent.sort_next = player.sort_next;
-       if(player.sort_next)
-               player.sort_next.sort_prev = parent;
-       AuditLists();
-}
-
-void MoveToLast(entity e)
-{
-       AuditLists();
-       entity ent = e.sort_next;
-       while(ent)
-       {
-               SORT_SWAP(ent, e);
-               ent = e.sort_next;
-       }
-       AuditLists();
-}
-
-float RegisterTeam(entity Team)
-{
-       assert_once(Team.team, eprint(Team));
-       entity tm;
-       AuditLists();
-       for(tm = teams.sort_next; tm; tm = tm.sort_next)
-               if(tm == Team)
-                       error("Team already registered!");
-       Team.sort_next = teams.sort_next;
-       Team.sort_prev = teams;
-       if(teams.sort_next)
-               teams.sort_next.sort_prev = Team;
-       teams.sort_next = Team;
-       if(Team.team && Team.team != NUM_SPECTATOR)
-               ++team_count;
-       AuditLists();
-       return true;
-}
-
-void RemoveTeam(entity Team)
-{
-       entity tm, parent;
-       AuditLists();
-       parent = teams;
-       for(tm = teams.sort_next; tm && tm != Team; tm = tm.sort_next)
-               parent = tm;
-
-       if(!tm)
-       {
-               LOG_INFO(_("Trying to remove a team which is not in the teamlist!"));
-               return;
-       }
-       parent.sort_next = Team.sort_next;
-       if(Team.sort_next)
-               Team.sort_next.sort_prev = parent;
-       if(Team.team && Team.team != NUM_SPECTATOR)
-               --team_count;
-       AuditLists();
-}
-
-entity GetTeam(int Team, bool add)
-{
-       TC(int, Team); TC(bool, add);
-       int num = (Team == NUM_SPECTATOR) ? 16 : Team;
-       if(teamslots[num])
-               return teamslots[num];
-       if (!add)
-               return NULL;
-       entity tm = new_pure(team);
-       tm.team = Team;
-       teamslots[num] = tm;
-       RegisterTeam(tm);
-       return tm;
-}
-
-vector HUD_GetFontsize(string cvarname)
-{
-       vector v;
-       v = stov(cvar_string(cvarname));
-       if(v.x == 0)
-               v = '8 8 0';
-       if(v.y == 0)
-               v.y = v.x;
-       v.z = 0;
-       return v;
-}
-
-float PreviewExists(string name)
-{
-       if(autocvar_cl_readpicture_force)
-               return false;
-
-       if (fexists(strcat(name, ".tga"))) return true;
-       if (fexists(strcat(name, ".png"))) return true;
-       if (fexists(strcat(name, ".jpg"))) return true;
-       if (fexists(strcat(name, ".pcx"))) return true;
-
-       return false;
-}
-
-float cvar_or(string cv, float v)
-{
-       string s;
-       s = cvar_string(cv);
-       if(s == "")
-               return v;
-       else
-               return stof(s);
-}
-
-vector project_3d_to_2d(vector vec)
-{
-       vec = cs_project(vec);
-       if(cs_project_is_b0rked > 0)
-       {
-               vec.x *= vid_conwidth / vid_width;
-               vec.y *= vid_conheight / vid_height;
-       }
-       return vec;
-}
-
-bool projected_on_screen(vector screen_pos)
-{
-       return screen_pos.z >= 0
-               && screen_pos.x >= 0
-               && screen_pos.y >= 0
-               && screen_pos.x < vid_conwidth
-               && screen_pos.y < vid_conheight;
-}
-
-float expandingbox_sizefactor_from_fadelerp(float fadelerp)
-{
-       return 1.2 / (1.2 - fadelerp);
-}
-
-vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor)
-{
-       boxsize.x *= boxxsizefactor; // easier interface for text
-       return boxsize * (0.5 * (1 - sz));
-}
-
-// NOTE base is the central value
-// freq: circle frequency, = 2*pi*frequency in hertz
-// start_pos:
-//  -1 start from the lower value
-//   0 start from the base value
-//   1 start from the higher value
-float blink_synced(float base, float range, float freq, float start_time, int start_pos)
-{
-       // note:
-       //   RMS = sqrt(base^2 + 0.5 * range^2)
-       // thus
-       //   base = sqrt(RMS^2 - 0.5 * range^2)
-       // ensure RMS == 1
-
-       return base + range * sin((time - start_time - (M_PI / 2) * start_pos) * freq);
-}
-
-float blink(float base, float range, float freq)
-{
-       return blink_synced(base, range, freq, 0, 0);
-}
-
-void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag)
-{
-       vector line_dim = '0 0 0';
-
-       // left and right lines
-       pos.x -= thickness;
-       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;
-       drawfill(pos, line_dim, color, theAlpha, drawflag);
-       drawfill(pos + (dim.y + thickness) * '0 1 0', line_dim, color, theAlpha, drawflag);
-}
-
-void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag)
-{
-       pos = HUD_Shift(pos);
-       sz = HUD_Scale(sz);
-       area = HUD_Scale(area);
-
-       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;
-       while (current_pos.y < end_pos.y)
-       {
-               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;
-                       drawsubpic(current_pos, new_size, pic, '0 0 0', ratio, color, theAlpha, drawflag);
-                       current_pos.x += sz.x;
-               }
-               current_pos.y += sz.y;
-       }
-}
-
-void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
-{
-       float sz;
-       sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
-
-       drawpic_aspect_skin(position + expandingbox_resize_centered_box_offset(sz, theScale, 1), pic, theScale * sz, rgb, theAlpha * (1 - fadelerp), flag);
-}
-
-void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
-{
-       drawpic_aspect_skin_expanding(position, pic, theScale, rgb, theAlpha, flag, fadelerp);
-       drawpic_skin(position, pic, theScale, rgb, theAlpha * fadelerp, flag);
-}
-
-void HUD_Scale_Disable()
-{
-       hud_scale = '1 1 0';
-       hud_shift = '0 0 0';
-       drawfontscale = hud_scale;
-}
-
-void HUD_Scale_Enable()
-{
-       hud_scale = hud_scale_current;
-       hud_shift = hud_shift_current;
-       drawfontscale = hud_scale;
-}
-
-vector HUD_Scale(vector v)
-{
-       v.x = HUD_ScaleX(v.x);
-       v.y = HUD_ScaleY(v.y);
-       return v;
-}
-
-vector HUD_Shift(vector v)
-{
-       v.x = HUD_ShiftX(v.x);
-       v.y = HUD_ShiftY(v.y);
-       return v;
-}
-
-float stringwidth(string text, float handleColors, vector sz)
-{
-       vector dfs = drawfontscale;
-       drawfontscale = '1 1 0';
-       float r = stringwidth_builtin(text, handleColors, sz);
-       drawfontscale = dfs;
-       return r;
-}
-
-#define SET_POS_AND_SZ_Y_ASPECT(allow_colors) MACRO_BEGIN \
-       float textaspect, oldsz; \
-       vector dfs = drawfontscale; \
-       drawfontscale = '1 1 0'; \
-       textaspect = stringwidth(text, allow_colors, '1 1 1' * sz.y) / sz.y; \
-       drawfontscale = dfs; \
-       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; \
-       } \
-MACRO_END
-
-// 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);
-       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);
-       drawcolorcodedstring(pos, text, '1 1 0' * sz.y, theAlpha, drawflag);
-}
-
-void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
-{
-       float sz;
-       sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
-
-       drawfontscale = hud_scale * sz;
-       vector dfs = drawfontscale;
-       drawfontscale = sz * '1 1 0';
-       float textaspect = stringwidth_builtin(text, false, theScale * (sz / drawfontscale.x)) / (theScale.x * sz);
-       drawfontscale = dfs;
-       drawstring(position + expandingbox_resize_centered_box_offset(sz, theScale, textaspect), text, HUD_Scale(theScale * (sz / drawfontscale.x)), rgb, theAlpha * (1 - fadelerp), flag);
-       // width parameter:
-       //    (scale_x * sz / drawfontscale.x) * drawfontscale.x * SIZE1 / (scale_x * sz)
-       //    SIZE1
-       drawfontscale = hud_scale;
-}
-
-// 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);
-       drawstring_expanding(pos, text, '1 1 0' * sz.y, color, theAlpha, drawflag, fadelerp);
-}
-
-void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp)
-{
-       float sz;
-       sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
-
-       drawfontscale = hud_scale * sz;
-       // eventually replace with drawcolorcodedstring
-       drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth_builtin(text, true, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), theAlpha * (1 - fadelerp), flag);
-       drawfontscale = hud_scale;
-}
-
-void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp) {
-       SET_POS_AND_SZ_Y_ASPECT(true);
-       drawcolorcodedstring_expanding(pos, text, '1 1 0' * sz.y, theAlpha, drawflag, fadelerp);
-}
-
-void update_mousepos()
-{
-       mousepos += getmousepos() * autocvar_menu_mouse_speed;
-       mousepos.x = bound(0, mousepos.x, vid_conwidth);
-       mousepos.y = bound(0, mousepos.y, vid_conheight);
-}
-
-// this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
-float PolyDrawModelSurface(entity e, float i_s)
-{
-       float i_t;
-       float n_t;
-       vector tri;
-       string tex;
-       tex = getsurfacetexture(e, i_s);
-       if (!tex)
-               return 0; // this is beyond the last one
-       n_t = getsurfacenumtriangles(e, i_s);
-       for(i_t = 0; i_t < n_t; ++i_t)
-       {
-               tri = getsurfacetriangle(e, i_s, i_t);
-               R_BeginPolygon(tex, 0, false);
-               R_PolygonVertex(getsurfacepoint(e, i_s, tri.x), getsurfacepointattribute(e, i_s, tri.x, SPA_TEXCOORDS0), '1 1 1', 1);
-               R_PolygonVertex(getsurfacepoint(e, i_s, tri.y), getsurfacepointattribute(e, i_s, tri.y, SPA_TEXCOORDS0), '1 1 1', 1);
-               R_PolygonVertex(getsurfacepoint(e, i_s, tri.z), getsurfacepointattribute(e, i_s, tri.z, SPA_TEXCOORDS0), '1 1 1', 1);
-               R_EndPolygon();
-       }
-       return 1;
-}
-void PolyDrawModel(entity e)
-{
-       float i_s;
-       for(i_s = 0; ; ++i_s)
-               if(!PolyDrawModelSurface(e, i_s))
-                       break;
-}
-
-void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag)
-{
-       vector ringsize, v, t;
-       ringsize = radi * '1 1 0';
-       centre = HUD_Shift(centre);
-       ringsize = HUD_Scale(ringsize);
-
-       if(f >= 1)
-       {
-               // draw full rectangle
-               R_BeginPolygon(pic, drawflag, true);
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.y += 0.5 * ringsize.y;        t += '0.5 -0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.y -= 0.5 * ringsize.y;        t -= '0.5 -0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-               R_EndPolygon();
-               return;  // Complete rectangle, nothing more needed.
-       }
-
-       float co = cos(f * 2 * M_PI);
-       float si = sin(f * 2 * M_PI);
-       float q = fabs(co) + fabs(si);
-       co /= q;
-       si /= q;
-
-       if(f > 0.75)
-       {
-               // draw upper half in full
-               R_BeginPolygon(pic, drawflag, true);
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.y += 0.5 * ringsize.y;        t += '0.5 -0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-               R_EndPolygon();
-               // draw clipped lower half as a quad
-               R_BeginPolygon(pic, drawflag, true);
-                       v = centre;                     t = '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.y -= 0.5 * ringsize.y;        t -= '0.5 -0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-       }
-       else if(f > 0.5)
-       {
-               // draw upper half in full
-               R_BeginPolygon(pic, drawflag, true);
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.y += 0.5 * ringsize.y;        t += '0.5 -0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-               R_EndPolygon();
-               // draw clipped lower half as a triangle
-               R_BeginPolygon(pic, drawflag, true);
-                       v = centre;                     t = '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-       }
-       else if(f > 0.25)
-       {
-               // draw clipped lower half as a quad
-               R_BeginPolygon(pic, drawflag, true);
-                       v = centre;                     t = '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.y += 0.5 * ringsize.y;        t += '0.5 -0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-       }
-       else if (f > 0)
-       {
-               // draw clipped lower half as a triangle
-               R_BeginPolygon(pic, drawflag, true);
-                       v = centre;                     t = '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-
-                       v = centre;                     t = '0.5 0.5 0';
-                       v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
-                       R_PolygonVertex(v, t, rgb, a);
-       }
-       else
-       {
-               // Nothing to draw.
-               return;
-       }
-
-       // The last, moving vertex.
-               v = centre;                     t = '0.5 0.5 0';
-               v.x += co * 0.5 * ringsize.x;   t += co * '0.5 0.5 0';
-               v.y += si * 0.5 * ringsize.y;   t += si * '0.5 -0.5 0';
-               R_PolygonVertex(v, t, rgb, a);
-       R_EndPolygon();
-}
-
-/** engine callback */
-void URI_Get_Callback(int id, int status, string data)
-{
-       TC(int, id); TC(int, status);
-       if(url_URI_Get_Callback(id, status, data))
-       {
-               // handled
-       }
-       else if (id == URI_GET_DISCARD)
-       {
-               // discard
-       }
-       else if (id >= URI_GET_CURL && id <= URI_GET_CURL_END)
-       {
-               // sv_cmd curl
-               Curl_URI_Get_Callback(id, status, data);
-       }
-       else
-       {
-               LOG_INFOF("Received HTTP request data for an invalid id %d.", id);
-       }
-}
-
-void Accuracy_LoadLevels()
-{
-       if(autocvar_accuracy_color_levels != acc_color_levels)
-       {
-               strcpy(acc_color_levels, autocvar_accuracy_color_levels);
-               acc_levels = tokenize_console(acc_color_levels);
-               if(acc_levels > MAX_ACCURACY_LEVELS)
-                       acc_levels = MAX_ACCURACY_LEVELS;
-               if(acc_levels < 2)
-                       LOG_INFO("Warning: accuracy_color_levels must contain at least 2 values");
-
-               int i;
-               for(i = 0; i < acc_levels; ++i)
-                       acc_lev[i] = stof(argv(i)) / 100.0;
-       }
-}
-
-void Accuracy_LoadColors()
-{
-       if(time > acc_col_loadtime)
-       if(acc_levels >= 2)
-       {
-               int i;
-               for(i = 0; i < acc_levels; ++i)
-                       acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
-               acc_col_loadtime = time + 2;
-       }
-}
-
-vector Accuracy_GetColor(float accuracy)
-{
-       float factor;
-       vector color;
-       if(acc_levels < 2)
-               return '0 0 0'; // return black, can't determine the right color
-
-       // find the max level lower than acc
-       int j = acc_levels-1;
-       while(j && accuracy < acc_lev[j])
-               --j;
-
-       // inject color j+1 in color j, how much depending on how much accuracy is higher than level j
-       factor = (accuracy - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
-       color = acc_col[j];
-       color = color + factor * (acc_col[j+1] - color);
-       return color;
-}
diff --git a/qcsrc/client/miscfunctions.qh b/qcsrc/client/miscfunctions.qh
deleted file mode 100644 (file)
index f92633a..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-#pragma once
-
-entity players;
-entity teams;
-float team_count; // real teams
-
-const int INITPRIO_FIRST                               = 0;
-const int INITPRIO_GAMETYPE                    = 0;
-const int INITPRIO_GAMETYPE_FALLBACK   = 1;
-const int INITPRIO_FINDTARGET                  = 10;
-const int INITPRIO_DROPTOFLOOR                         = 20;
-const int INITPRIO_SETLOCATION                         = 90;
-const int INITPRIO_LINKDOORS                   = 91;
-const int INITPRIO_LAST                                = 99;
-
-void AuditLists();
-
-float RegisterPlayer(entity player);
-
-void RemovePlayer(entity player);
-
-void MoveToLast(entity e);
-
-float RegisterTeam(entity Team);
-
-void RemoveTeam(entity Team);
-
-entity GetTeam(int Team, bool add);
-
-vector HUD_GetFontsize(string cvarname);
-
-float PreviewExists(string name);
-
-vector Rotate(vector v, float a);
-
-
-#define IS_DEAD(s) (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : (GetResource((s), RES_HEALTH) <= 0))
-
-float cvar_or(string cv, float v);
-
-vector project_3d_to_2d(vector vec);
-
-vector drawfontscale;
-#define draw_beginBoldFont() drawfont = FONT_USER + 2
-#define draw_endBoldFont() drawfont = FONT_USER + 1
-
-float expandingbox_sizefactor_from_fadelerp(float fadelerp);
-
-vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
-
-float blink_synced(float base, float range, float freq, float start_time, int start_blink);
-float blink(float base, float range, float freq);
-
-void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);
-
-void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag);
-
-void HUD_Scale_Disable();
-void HUD_Scale_Enable();
-
-#define HUD_ScaleX(f) (f * hud_scale.x)
-#define HUD_ScaleY(f) (f * hud_scale.y)
-#define HUD_ShiftX(f) (f + hud_shift.x + hud_shift.z * (f - hud_scale_center.x))
-#define HUD_ShiftY(f) (f + hud_shift.y + hud_shift.z * (f - hud_scale_center.y))
-vector HUD_Scale(vector v);
-vector HUD_Shift(vector v);
-
-// The following functions / macros must be called from within
-// the panel HUD / scoreboard code so that pos and size are scaled
-// when the hud_dynamic code is running.
-// Make use of stringwidth_builtin and draw*_builtin everywhere else.
-
-float stringwidth(string text, float handleColors, vector sz);
-
-#define drawpic(position, pic, size, rgb, alpha, flag) \
-       drawpic_builtin(HUD_Shift(position), pic, HUD_Scale(size), rgb, alpha, flag)
-
-#define drawcharacter(position, character, scale, rgb, alpha, flag) \
-       drawcharacter_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
-
-#define drawstring(position, text, scale, rgb, alpha, flag) \
-       drawstring_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
-
-#define drawcolorcodedstring(position, text, scale, alpha, flag) \
-       drawcolorcodedstring_builtin(HUD_Shift(position), text, scale, alpha, flag)
-
-#define drawcolorcodedstring2(position, text, scale, rgb, alpha, flag) \
-       drawcolorcodedstring2_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
-
-#define drawfill(position, size, rgb, alpha, flag) \
-       drawfill_builtin(HUD_Shift(position), HUD_Scale(size), rgb, alpha, flag)
-
-#define drawsetcliparea(xposition, yposition, w, h) \
-       drawsetcliparea_builtin(HUD_ShiftX(xposition), HUD_ShiftY(yposition), HUD_ScaleX(w), HUD_ScaleY(h))
-
-// Since drawsubpic usually gets called multiple times from within an
-// utility function, instead of scaling pos and size in every call
-// we scale them once for all in the beginning of that utility function.
-// That's why drawsubpic isn't remapped.
-/*
-#define drawsubpic(position, size, pic, srcPosition, srcSize, rgb, alpha, flag) \
-       drawsubpic_builtin(HUD_Shift(position), HUD_Scale(size), pic, HUD_Shift(srcPosition), HUD_Scale(srcSize), rgb, alpha, flag)
-*/
-
-// drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
-float _drawpic_imgaspect;
-vector _drawpic_imgsize;
-vector _drawpic_sz;
-float _drawpic_oldsz;
-string _drawpic_picpath;
-#define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
-       MACRO_BEGIN \
-               _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 * 0.5 * (_drawpic_oldsz - _drawpic_sz.x), 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 * 0.5 * (_drawpic_oldsz - _drawpic_sz.y), pic, _drawpic_sz, color, theAlpha, drawflag);\
-                       }\
-               }\
-       MACRO_END
-
-// 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)\
-       MACRO_BEGIN \
-               _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;\
-       MACRO_END
-
-// 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)\
-       MACRO_BEGIN \
-               _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;\
-       MACRO_END
-
-void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
-
-void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
-
-// 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);
-
-// 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);
-
-void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
-
-// 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);
-
-void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
-
-void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
-
-void update_mousepos();
-
-// this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
-float PolyDrawModelSurface(entity e, float i_s);
-void PolyDrawModel(entity e);
-
-void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag);
-
-const int 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();
-
-void Accuracy_LoadColors();
-
-vector Accuracy_GetColor(float accuracy);
index ad05c4a2a4c9705c15289cdd81e59406e29829bf..05491cc8a437b7dc44c393750a447952007a06a4 100644 (file)
@@ -1,9 +1,10 @@
 #include "shownames.qh"
 
 #include "autocvars.qh"
+#include <client/draw.qh>
 #include "main.qh"
-#include "miscfunctions.qh"
 #include "resources.qh"
+#include <client/view.qh>
 #include "hud/_mod.qh"
 
 #include <common/ent_cs.qh>
index ee9164bae1a279b4c0038441b7b595c637c4a26f..c7b7a37c7eeb42cf32d685de43011e3af8ec96d2 100644 (file)
@@ -1,7 +1,7 @@
 #include "view.qh"
 
 #include "autocvars.qh"
-#include "miscfunctions.qh"
+#include <client/draw.qh>
 #include "announcer.qh"
 #include "hud/_mod.qh"
 #include "main.qh"
@@ -363,6 +363,33 @@ STATIC_INIT(viewmodel) {
        viewmodels[slot] = new(viewmodel);
 }
 
+vector project_3d_to_2d(vector vec)
+{
+       vec = cs_project(vec);
+       if(cs_project_is_b0rked > 0)
+       {
+               vec.x *= vid_conwidth / vid_width;
+               vec.y *= vid_conheight / vid_height;
+       }
+       return vec;
+}
+
+bool projected_on_screen(vector screen_pos)
+{
+       return screen_pos.z >= 0
+               && screen_pos.x >= 0
+               && screen_pos.y >= 0
+               && screen_pos.x < vid_conwidth
+               && screen_pos.y < vid_conheight;
+}
+
+void update_mousepos()
+{
+       mousepos += getmousepos() * autocvar_menu_mouse_speed;
+       mousepos.x = bound(0, mousepos.x, vid_conwidth);
+       mousepos.y = bound(0, mousepos.y, vid_conheight);
+}
+
 float showfps_prevfps;
 float showfps_prevfps_time;
 int showfps_framecounter;
index 7b73e5ae4994e9f9c720b4a5eca7c49eb38fb473..ae6487796a6d6c6b30ee5499f1fc43ad0e78fb61 100644 (file)
@@ -4,6 +4,10 @@
 
 void calc_followmodel_ofs(entity view);
 
+vector project_3d_to_2d(vector vec);
+
+void update_mousepos();
+
 void CSQC_Demo_Camera();
 
 entity viewmodels[MAX_WEAPONSLOTS];
index 344eec48cee50401790682864c2e79e97abfcd13..2c43d12d98ec3a178ef470fa0d09b962938e078e 100644 (file)
@@ -83,6 +83,16 @@ const int FL_SPAWNING                                = BIT(16);
 const int FL_PICKUPITEMS                       = BIT(17);
 const int FL_DUCKED                            = BIT(18);
 const int FL_ONSLICK                           = BIT(19);
+
+// initialization stages
+const int INITPRIO_FIRST                               = 0;
+const int INITPRIO_GAMETYPE                    = 0;
+const int INITPRIO_GAMETYPE_FALLBACK   = 1;
+const int INITPRIO_FINDTARGET                  = 10;
+const int INITPRIO_DROPTOFLOOR                         = 20;
+const int INITPRIO_SETLOCATION                         = 90;
+const int INITPRIO_LINKDOORS                   = 91;
+const int INITPRIO_LAST                                = 99;
 #endif
 
 #if defined(SVQC)
index b349e22f2b7a1419bc62097f1ae6fd89fd587d61..5d92a5a6391980fdfcfa7ac9ecb57695f238e75c 100644 (file)
@@ -1,7 +1,9 @@
 #pragma once
 
 #ifdef CSQC
+#include <client/draw.qh>
 #include <client/resources.qh>
+#include <client/view.qh>
 #endif
 
 
index 2bded9d6a9e861670b34355ec9a28b430606ddf0..65f21fdd24c388eba082130f86c999aeb4ca23fd 100644 (file)
@@ -1,5 +1,7 @@
 #include "cl_clanarena.qh"
 
+#include <client/draw.qh>
+
 void HUD_Mod_CA_Export(int fh)
 {
        HUD_Write_Cvar("hud_panel_modicons_ca_layout");
index e2258c0c51ce50ce56e79953886012833aa14afc..80a9f19710c70802cdc86b490b505eef9af730da 100644 (file)
@@ -1,6 +1,7 @@
 #include "cl_ctf.qh"
 
 #include <common/mutators/base.qh>
+#include <client/draw.qh>
 #include <client/hud/panel/modicons.qh>
 
 // CTF HUD modicon section
index 5a91165e956061d12d1c15e27dba292433fb9982..b962f7b773ecbef956cceae3ae192d1ce344b4f1 100644 (file)
@@ -1,5 +1,6 @@
 #include "cl_domination.qh"
 
+#include <client/draw.qh>
 #include <client/hud/panel/modicons.qh>
 
 void HUD_Mod_Dom_Export(int fh)
index 660a5511ec551f9f2e57ef7bc2a2a8a9a3e76f59..7ac6225f1e866231f99abdf7f15a8d2f7a349a36 100644 (file)
@@ -1,5 +1,6 @@
 #include "cl_keepaway.qh"
 
+#include <client/draw.qh>
 #include <client/hud/panel/modicons.qh>
 
 // Keepaway HUD mod icon
index b12564b1863b499a2a6da14fdc05a59750f81756..45d79bf0dbae75b5bf40f44293bf286643e36f97 100644 (file)
@@ -1,5 +1,6 @@
 #include "cl_race.qh"
 
+#include <client/draw.qh>
 #include <common/mutators/base.qh>
 
 // Race/CTS HUD mod icons
index 0acdb0da59964e20c6900b5ff4532b953fb35652..14dac4e88e3baf9e556733160c0ccdb74c46fcd0 100644 (file)
@@ -1,6 +1,7 @@
 #include "cl_minigames_hud.qh"
 
 #include <client/autocvars.qh>
+#include <client/draw.qh>
 #include <common/ent_cs.qh>
 
 #include "minigames.qh"
index 72b65e75691ede0428b7cf4acffd85ee37c96506..ab9444757e05f973fb858118cdf80c0061544391 100644 (file)
@@ -1,9 +1,5 @@
 #include "nmm.qh"
 
-#ifdef CSQC
-#include <client/miscfunctions.qh>
-#endif
-
 REGISTER_MINIGAME(nmm, _("Nine Men's Morris"));
 
 const int NMM_TURN_PLACE = 0x0100; // player has to place a piece on the board
index 5d2fcf7263afd1d8dad0c75e8658eba1eed5d21f..8b4013c8a5f9c614ed7002936521856fb7dea395 100644 (file)
@@ -190,6 +190,7 @@ STATIC_INIT(PHYS_INPUT_BUTTON)
        #define IS_CLIENT(s)                        (((s).isplayermodel & ISPLAYER_CLIENT) || (s) == csqcplayer)
        #define IS_PLAYER(s)                        ((s).isplayermodel & ISPLAYER_PLAYER)
        #define IS_NOT_A_CLIENT(s)                  (!(s).isplayermodel && (s) != csqcplayer)
+       #define IS_DEAD(s)                          (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : (GetResource((s), RES_HEALTH) <= 0))
 
        //float player_multijump;
        //float player_jumpheight;
index b0acbee74a984d0093eeaf8448bb9faaf046e934..35eff3f9ce59ac74c6899b5b5420acfd66946047 100644 (file)
@@ -2073,3 +2073,37 @@ float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector t
     return trace_hits_box(start, end, thmi - ma, thma - mi);
 }
 #endif
+
+ERASEABLE
+float cvar_or(string cv, float v)
+{
+       string s = cvar_string(cv);
+       if(s == "")
+               return v;
+       else
+               return stof(s);
+}
+
+// NOTE base is the central value
+// freq: circle frequency, = 2*pi*frequency in hertz
+// start_pos:
+//  -1 start from the lower value
+//   0 start from the base value
+//   1 start from the higher value
+ERASEABLE
+float blink_synced(float base, float range, float freq, float start_time, int start_pos)
+{
+       // note:
+       //   RMS = sqrt(base^2 + 0.5 * range^2)
+       // thus
+       //   base = sqrt(RMS^2 - 0.5 * range^2)
+       // ensure RMS == 1
+
+       return base + range * sin((time - start_time - (M_PI / 2) * start_pos) * freq);
+}
+
+ERASEABLE
+float blink(float base, float range, float freq)
+{
+       return blink_synced(base, range, freq, 0, 0);
+}
index b5a4ee6dfa825089b21c5119f3375630a34e851f..0663c49cfac876892bd3a10c4a02275c0c955a3d 100644 (file)
@@ -253,3 +253,9 @@ float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector t
 
 float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma);
 #endif
+
+float cvar_or(string cv, float v);
+
+float blink_synced(float base, float range, float freq, float start_time, int start_blink);
+
+float blink(float base, float range, float freq);
index f89d645c4220c1695f2313ab5f5a31a9b5cffad4..7448c0847ed3dc710ff34691e5612c5abe34cc75 100644 (file)
@@ -84,15 +84,6 @@ float warmup_stage;
 
 bool sv_ready_restart_after_countdown;
 
-const int INITPRIO_FIRST               = 0;
-const int INITPRIO_GAMETYPE            = 0;
-const int INITPRIO_GAMETYPE_FALLBACK   = 1;
-const int INITPRIO_FINDTARGET          = 10;
-const int INITPRIO_DROPTOFLOOR                 = 20;
-const int INITPRIO_SETLOCATION                 = 90;
-const int INITPRIO_LINKDOORS           = 91;
-const int INITPRIO_LAST                = 99;
-
 .void(entity this) initialize_entity;
 .int initialize_entity_order;
 .entity initialize_entity_next;