From 93ea212d8c60d8c3e897f8b5b613ee112f88aa37 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 29 Sep 2020 21:58:35 +1000 Subject: [PATCH] Purge miscfunctions.qc from the client-side codebase, also remove an old unused CSQC constants header --- qcsrc/client/_mod.inc | 2 +- qcsrc/client/_mod.qh | 2 +- qcsrc/client/command/cl_cmd.qc | 2 +- qcsrc/client/csqc_constants.qh | 142 -------- qcsrc/client/csqcmodel_hooks.qc | 1 - qcsrc/client/{miscfunctions.qc => draw.qc} | 341 +----------------- qcsrc/client/{miscfunctions.qh => draw.qh} | 69 ---- qcsrc/client/hud/crosshair.qc | 2 +- qcsrc/client/hud/hud.qc | 42 ++- qcsrc/client/hud/hud.qh | 12 + qcsrc/client/hud/hud_config.qc | 2 +- qcsrc/client/hud/panel/ammo.qc | 2 +- qcsrc/client/hud/panel/centerprint.qc | 2 +- qcsrc/client/hud/panel/chat.qc | 2 +- qcsrc/client/hud/panel/engineinfo.qc | 2 +- qcsrc/client/hud/panel/healtharmor.qc | 2 +- qcsrc/client/hud/panel/infomessages.qc | 2 +- qcsrc/client/hud/panel/modicons.qc | 2 +- qcsrc/client/hud/panel/notify.qc | 2 +- qcsrc/client/hud/panel/physics.qc | 2 +- qcsrc/client/hud/panel/powerups.qc | 2 +- qcsrc/client/hud/panel/pressedkeys.qc | 2 +- qcsrc/client/hud/panel/quickmenu.qc | 2 +- qcsrc/client/hud/panel/racetimer.qc | 2 +- qcsrc/client/hud/panel/radar.qc | 2 +- qcsrc/client/hud/panel/score.qc | 2 +- qcsrc/client/hud/panel/scoreboard.qc | 3 +- qcsrc/client/hud/panel/timer.qc | 2 +- qcsrc/client/hud/panel/vote.qc | 2 +- qcsrc/client/hud/panel/weapons.qc | 50 ++- qcsrc/client/hud/panel/weapons.qh | 12 + qcsrc/client/main.qc | 147 +++++++- qcsrc/client/main.qh | 18 + qcsrc/client/mapvoting.qc | 15 +- qcsrc/client/mapvoting.qh | 2 + qcsrc/client/shownames.qc | 3 +- qcsrc/client/view.qc | 29 +- qcsrc/client/view.qh | 4 + qcsrc/common/constants.qh | 10 + qcsrc/common/debug.qh | 2 + .../gamemode/clanarena/cl_clanarena.qc | 2 + qcsrc/common/gamemodes/gamemode/ctf/cl_ctf.qc | 1 + .../gamemode/domination/cl_domination.qc | 1 + .../gamemode/keepaway/cl_keepaway.qc | 1 + .../common/gamemodes/gamemode/race/cl_race.qc | 1 + qcsrc/common/minigames/cl_minigames_hud.qc | 1 + qcsrc/common/minigames/minigame/nmm.qc | 4 - qcsrc/common/physics/player.qh | 1 + qcsrc/common/util.qc | 34 ++ qcsrc/common/util.qh | 6 + qcsrc/server/world.qh | 9 - 51 files changed, 425 insertions(+), 582 deletions(-) delete mode 100644 qcsrc/client/csqc_constants.qh rename qcsrc/client/{miscfunctions.qc => draw.qc} (60%) rename qcsrc/client/{miscfunctions.qh => draw.qh} (77%) diff --git a/qcsrc/client/_mod.inc b/qcsrc/client/_mod.inc index ec82018a3..8f56739df 100644 --- a/qcsrc/client/_mod.inc +++ b/qcsrc/client/_mod.inc @@ -2,9 +2,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/qcsrc/client/_mod.qh b/qcsrc/client/_mod.qh index 85d9c1204..5f82413c4 100644 --- a/qcsrc/client/_mod.qh +++ b/qcsrc/client/_mod.qh @@ -2,9 +2,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/qcsrc/client/command/cl_cmd.qc b/qcsrc/client/command/cl_cmd.qc index 127f404e7..9f3f232cc 100644 --- a/qcsrc/client/command/cl_cmd.qc +++ b/qcsrc/client/command/cl_cmd.qc @@ -8,6 +8,7 @@ #include "cl_cmd.qh" #include "../autocvars.qh" +#include #include #include #include @@ -15,7 +16,6 @@ #include #include "../main.qh" #include "../mapvoting.qh" -#include "../miscfunctions.qh" #include #include diff --git a/qcsrc/client/csqc_constants.qh b/qcsrc/client/csqc_constants.qh deleted file mode 100644 index d8906b12b..000000000 --- a/qcsrc/client/csqc_constants.qh +++ /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); diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc index 82b045801..f0ff55e8a 100644 --- a/qcsrc/client/csqcmodel_hooks.qc +++ b/qcsrc/client/csqcmodel_hooks.qc @@ -1,7 +1,6 @@ #include "csqcmodel_hooks.qh" #include "autocvars.qh" #include "main.qh" -#include "miscfunctions.qh" #include #include #include "player_skeleton.qh" diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/draw.qc similarity index 60% rename from qcsrc/client/miscfunctions.qc rename to qcsrc/client/draw.qc index 34d87b772..f08fbf5d9 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/draw.qc @@ -1,226 +1,6 @@ -#include "miscfunctions.qh" +#include "draw.qh" -#include "autocvars.qh" -#include "hud/_mod.qh" -#include "main.qh" - -#include - -#include - -#include - - -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); -} +#include void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag) { @@ -267,6 +47,17 @@ void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, } } +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; @@ -281,34 +72,6 @@ void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theSc 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; @@ -386,13 +149,6 @@ void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, f 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) { @@ -552,74 +308,3 @@ void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector 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/draw.qh similarity index 77% rename from qcsrc/client/miscfunctions.qh rename to qcsrc/client/draw.qh index f92633a41..409161fb1 100644 --- a/qcsrc/client/miscfunctions.qh +++ b/qcsrc/client/draw.qh @@ -1,45 +1,5 @@ #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 @@ -47,24 +7,10 @@ vector drawfontscale; 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. @@ -168,23 +114,8 @@ void drawstring_aspect_expanding(vector pos, string text, vector sz, vector colo 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); diff --git a/qcsrc/client/hud/crosshair.qc b/qcsrc/client/hud/crosshair.qc index 6bf0bb577..1c0f06c6a 100644 --- a/qcsrc/client/hud/crosshair.qc +++ b/qcsrc/client/hud/crosshair.qc @@ -1,8 +1,8 @@ #include "crosshair.qh" #include +#include #include -#include #include #include diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index 114b44823..26561f1d7 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -1,7 +1,7 @@ #include "hud.qh" +#include #include -#include #include #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 diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index 1021d7067..dae8a72d9 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -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(); diff --git a/qcsrc/client/hud/hud_config.qc b/qcsrc/client/hud/hud_config.qc index 32c7889ca..0b4c58c21 100644 --- a/qcsrc/client/hud/hud_config.qc +++ b/qcsrc/client/hud/hud_config.qc @@ -3,7 +3,7 @@ #include "hud.qh" #include "panel/scoreboard.qh" #include -#include +#include #include // Save the config diff --git a/qcsrc/client/hud/panel/ammo.qc b/qcsrc/client/hud/panel/ammo.qc index b75c3ebab..cab9d197d 100644 --- a/qcsrc/client/hud/panel/ammo.qc +++ b/qcsrc/client/hud/panel/ammo.qc @@ -1,9 +1,9 @@ #include "ammo.qh" #include +#include #include #include -#include #include #include #include diff --git a/qcsrc/client/hud/panel/centerprint.qc b/qcsrc/client/hud/panel/centerprint.qc index 15f46d29c..7723c1f44 100644 --- a/qcsrc/client/hud/panel/centerprint.qc +++ b/qcsrc/client/hud/panel/centerprint.qc @@ -2,7 +2,7 @@ #include "scoreboard.qh" #include -#include +#include // CenterPrint (#16) diff --git a/qcsrc/client/hud/panel/chat.qc b/qcsrc/client/hud/panel/chat.qc index d46aa81b8..13ef78136 100644 --- a/qcsrc/client/hud/panel/chat.qc +++ b/qcsrc/client/hud/panel/chat.qc @@ -1,7 +1,7 @@ #include "chat.qh" #include -#include +#include // Chat (#12) diff --git a/qcsrc/client/hud/panel/engineinfo.qc b/qcsrc/client/hud/panel/engineinfo.qc index 85d425977..7760c56f7 100644 --- a/qcsrc/client/hud/panel/engineinfo.qc +++ b/qcsrc/client/hud/panel/engineinfo.qc @@ -1,7 +1,7 @@ #include "engineinfo.qh" #include -#include +#include // Engine info (#13) diff --git a/qcsrc/client/hud/panel/healtharmor.qc b/qcsrc/client/hud/panel/healtharmor.qc index 48b852bf9..495aa63fc 100644 --- a/qcsrc/client/hud/panel/healtharmor.qc +++ b/qcsrc/client/hud/panel/healtharmor.qc @@ -1,7 +1,7 @@ #include "healtharmor.qh" +#include #include -#include #include diff --git a/qcsrc/client/hud/panel/infomessages.qc b/qcsrc/client/hud/panel/infomessages.qc index 03465cce5..632f3fad5 100644 --- a/qcsrc/client/hud/panel/infomessages.qc +++ b/qcsrc/client/hud/panel/infomessages.qc @@ -1,8 +1,8 @@ #include "infomessages.qh" #include +#include #include -#include #include diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index 17ea987bf..49f2dab8a 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -1,7 +1,7 @@ #include "modicons.qh" -#include #include +#include #include #include #include diff --git a/qcsrc/client/hud/panel/notify.qc b/qcsrc/client/hud/panel/notify.qc index 0dfb11db7..b3804eccf 100644 --- a/qcsrc/client/hud/panel/notify.qc +++ b/qcsrc/client/hud/panel/notify.qc @@ -1,7 +1,7 @@ #include "notify.qh" #include -#include +#include // Notifications (#4) diff --git a/qcsrc/client/hud/panel/physics.qc b/qcsrc/client/hud/panel/physics.qc index a60821909..11ed12e82 100644 --- a/qcsrc/client/hud/panel/physics.qc +++ b/qcsrc/client/hud/panel/physics.qc @@ -1,7 +1,7 @@ #include "physics.qh" #include -#include +#include #include #include diff --git a/qcsrc/client/hud/panel/powerups.qc b/qcsrc/client/hud/panel/powerups.qc index 75fb0c2aa..587d20071 100644 --- a/qcsrc/client/hud/panel/powerups.qc +++ b/qcsrc/client/hud/panel/powerups.qc @@ -1,8 +1,8 @@ #include "powerups.qh" #include +#include #include -#include #include #include diff --git a/qcsrc/client/hud/panel/pressedkeys.qc b/qcsrc/client/hud/panel/pressedkeys.qc index f29978c2d..021b66856 100644 --- a/qcsrc/client/hud/panel/pressedkeys.qc +++ b/qcsrc/client/hud/panel/pressedkeys.qc @@ -1,8 +1,8 @@ #include "pressedkeys.qh" #include +#include #include -#include // Pressed keys (#11) diff --git a/qcsrc/client/hud/panel/quickmenu.qc b/qcsrc/client/hud/panel/quickmenu.qc index 6e3c185c8..deed53da0 100644 --- a/qcsrc/client/hud/panel/quickmenu.qc +++ b/qcsrc/client/hud/panel/quickmenu.qc @@ -1,8 +1,8 @@ #include "quickmenu.qh" #include +#include #include -#include #include #include #include diff --git a/qcsrc/client/hud/panel/racetimer.qc b/qcsrc/client/hud/panel/racetimer.qc index 0703c4f2d..85fdc86c6 100644 --- a/qcsrc/client/hud/panel/racetimer.qc +++ b/qcsrc/client/hud/panel/racetimer.qc @@ -1,8 +1,8 @@ #include "racetimer.qh" #include +#include #include -#include // Race timer (#8) diff --git a/qcsrc/client/hud/panel/radar.qc b/qcsrc/client/hud/panel/radar.qc index 66665498e..1e688b1fd 100644 --- a/qcsrc/client/hud/panel/radar.qc +++ b/qcsrc/client/hud/panel/radar.qc @@ -1,8 +1,8 @@ #include "radar.qh" #include +#include #include -#include #include #include #include diff --git a/qcsrc/client/hud/panel/score.qc b/qcsrc/client/hud/panel/score.qc index 553283e5b..81f91663c 100644 --- a/qcsrc/client/hud/panel/score.qc +++ b/qcsrc/client/hud/panel/score.qc @@ -1,8 +1,8 @@ #include "score.qh" #include +#include #include -#include #include "scoreboard.qh" #include #include diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 05715bd6c..c21b99092 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -1,9 +1,10 @@ #include "scoreboard.qh" #include +#include #include -#include #include +#include #include "quickmenu.qh" #include #include diff --git a/qcsrc/client/hud/panel/timer.qc b/qcsrc/client/hud/panel/timer.qc index e49c777db..446c6229b 100644 --- a/qcsrc/client/hud/panel/timer.qc +++ b/qcsrc/client/hud/panel/timer.qc @@ -1,7 +1,7 @@ #include "timer.qh" #include -#include +#include #include // Timer (#5) diff --git a/qcsrc/client/hud/panel/vote.qc b/qcsrc/client/hud/panel/vote.qc index 2b2c7fa96..12f691c99 100644 --- a/qcsrc/client/hud/panel/vote.qc +++ b/qcsrc/client/hud/panel/vote.qc @@ -1,8 +1,8 @@ #include "vote.qh" #include +#include #include -#include // Vote (#9) diff --git a/qcsrc/client/hud/panel/weapons.qc b/qcsrc/client/hud/panel/weapons.qc index 03be211a2..b252df19e 100644 --- a/qcsrc/client/hud/panel/weapons.qc +++ b/qcsrc/client/hud/panel/weapons.qc @@ -1,8 +1,8 @@ #include "weapons.qh" #include +#include #include -#include #include #include @@ -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) { diff --git a/qcsrc/client/hud/panel/weapons.qh b/qcsrc/client/hud/panel/weapons.qh index 6db88c68b..1315b0f02 100644 --- a/qcsrc/client/hud/panel/weapons.qh +++ b/qcsrc/client/hud/panel/weapons.qh @@ -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); diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 2c63adc44..d111e8aad 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -1,8 +1,8 @@ #include "main.qh" +#include #include #include -#include "miscfunctions.qh" #include #include #include @@ -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); + } +} diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 784ecb9c9..1653ef643 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -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; diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index a38bb76cf..06a33f665 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -1,8 +1,8 @@ #include "mapvoting.qh" #include "autocvars.qh" +#include #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); diff --git a/qcsrc/client/mapvoting.qh b/qcsrc/client/mapvoting.qh index 8a6f542a0..8d184a95d 100644 --- a/qcsrc/client/mapvoting.qh +++ b/qcsrc/client/mapvoting.qh @@ -3,6 +3,8 @@ #include 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/shownames.qc b/qcsrc/client/shownames.qc index ad05c4a2a..05491cc8a 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -1,9 +1,10 @@ #include "shownames.qh" #include "autocvars.qh" +#include #include "main.qh" -#include "miscfunctions.qh" #include "resources.qh" +#include #include "hud/_mod.qh" #include diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index ee9164bae..c7b7a37c7 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1,7 +1,7 @@ #include "view.qh" #include "autocvars.qh" -#include "miscfunctions.qh" +#include #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; diff --git a/qcsrc/client/view.qh b/qcsrc/client/view.qh index 7b73e5ae4..ae6487796 100644 --- a/qcsrc/client/view.qh +++ b/qcsrc/client/view.qh @@ -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]; diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 344eec48c..2c43d12d9 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -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) diff --git a/qcsrc/common/debug.qh b/qcsrc/common/debug.qh index b349e22f2..5d92a5a63 100644 --- a/qcsrc/common/debug.qh +++ b/qcsrc/common/debug.qh @@ -1,7 +1,9 @@ #pragma once #ifdef CSQC +#include #include +#include #endif diff --git a/qcsrc/common/gamemodes/gamemode/clanarena/cl_clanarena.qc b/qcsrc/common/gamemodes/gamemode/clanarena/cl_clanarena.qc index 2bded9d6a..65f21fdd2 100644 --- a/qcsrc/common/gamemodes/gamemode/clanarena/cl_clanarena.qc +++ b/qcsrc/common/gamemodes/gamemode/clanarena/cl_clanarena.qc @@ -1,5 +1,7 @@ #include "cl_clanarena.qh" +#include + void HUD_Mod_CA_Export(int fh) { HUD_Write_Cvar("hud_panel_modicons_ca_layout"); diff --git a/qcsrc/common/gamemodes/gamemode/ctf/cl_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/cl_ctf.qc index e2258c0c5..80a9f1971 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/cl_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/cl_ctf.qc @@ -1,6 +1,7 @@ #include "cl_ctf.qh" #include +#include #include // CTF HUD modicon section diff --git a/qcsrc/common/gamemodes/gamemode/domination/cl_domination.qc b/qcsrc/common/gamemodes/gamemode/domination/cl_domination.qc index 5a91165e9..b962f7b77 100644 --- a/qcsrc/common/gamemodes/gamemode/domination/cl_domination.qc +++ b/qcsrc/common/gamemodes/gamemode/domination/cl_domination.qc @@ -1,5 +1,6 @@ #include "cl_domination.qh" +#include #include void HUD_Mod_Dom_Export(int fh) diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/cl_keepaway.qc b/qcsrc/common/gamemodes/gamemode/keepaway/cl_keepaway.qc index 660a5511e..7ac6225f1 100644 --- a/qcsrc/common/gamemodes/gamemode/keepaway/cl_keepaway.qc +++ b/qcsrc/common/gamemodes/gamemode/keepaway/cl_keepaway.qc @@ -1,5 +1,6 @@ #include "cl_keepaway.qh" +#include #include // Keepaway HUD mod icon diff --git a/qcsrc/common/gamemodes/gamemode/race/cl_race.qc b/qcsrc/common/gamemodes/gamemode/race/cl_race.qc index b12564b18..45d79bf0d 100644 --- a/qcsrc/common/gamemodes/gamemode/race/cl_race.qc +++ b/qcsrc/common/gamemodes/gamemode/race/cl_race.qc @@ -1,5 +1,6 @@ #include "cl_race.qh" +#include #include // Race/CTS HUD mod icons diff --git a/qcsrc/common/minigames/cl_minigames_hud.qc b/qcsrc/common/minigames/cl_minigames_hud.qc index 0acdb0da5..14dac4e88 100644 --- a/qcsrc/common/minigames/cl_minigames_hud.qc +++ b/qcsrc/common/minigames/cl_minigames_hud.qc @@ -1,6 +1,7 @@ #include "cl_minigames_hud.qh" #include +#include #include #include "minigames.qh" diff --git a/qcsrc/common/minigames/minigame/nmm.qc b/qcsrc/common/minigames/minigame/nmm.qc index 72b65e756..ab9444757 100644 --- a/qcsrc/common/minigames/minigame/nmm.qc +++ b/qcsrc/common/minigames/minigame/nmm.qc @@ -1,9 +1,5 @@ #include "nmm.qh" -#ifdef CSQC -#include -#endif - REGISTER_MINIGAME(nmm, _("Nine Men's Morris")); const int NMM_TURN_PLACE = 0x0100; // player has to place a piece on the board diff --git a/qcsrc/common/physics/player.qh b/qcsrc/common/physics/player.qh index 5d2fcf726..8b4013c8a 100644 --- a/qcsrc/common/physics/player.qh +++ b/qcsrc/common/physics/player.qh @@ -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; diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index b0acbee74..35eff3f9c 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -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); +} diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index b5a4ee6df..0663c49cf 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -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); diff --git a/qcsrc/server/world.qh b/qcsrc/server/world.qh index f89d645c4..7448c0847 100644 --- a/qcsrc/server/world.qh +++ b/qcsrc/server/world.qh @@ -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; -- 2.39.2