From: TimePath Date: Thu, 27 Aug 2015 02:38:07 +0000 (+1000) Subject: Extract more lib functions X-Git-Tag: xonotic-v0.8.2~2017 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c1b058929459a95a525deff9e0ebb76a513a7c22;p=xonotic%2Fxonotic-data.pk3dir.git Extract more lib functions --- diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc index 227341ae3..80b68a6e2 100644 --- a/qcsrc/client/csqcmodel_hooks.qc +++ b/qcsrc/client/csqcmodel_hooks.qc @@ -3,7 +3,6 @@ #include "gibs.qh" #include "player_skeleton.qh" -#include "sortlist.qh" #include "weapons/projectile.qh" @@ -18,7 +17,6 @@ #include "../csqcmodellib/cl_player.qh" #include "../csqcmodellib/interpolate.qh" -#include "../warpzonelib/mathlib.qh" .float death_time; .int modelflags; diff --git a/qcsrc/client/generator.qc b/qcsrc/client/generator.qc index ed4b35681..46872d817 100644 --- a/qcsrc/client/generator.qc +++ b/qcsrc/client/generator.qc @@ -4,16 +4,6 @@ bool generator_precached; .int count; .float max_health; -vector randompos(vector m1, vector m2) -{ - vector v; - m2 = m2 - m1; - v_x = m2_x * random() + m1_x; - v_y = m2_y * random() + m1_y; - v_z = m2_z * random() + m1_z; - return v; -} - void generator_precache() { if(generator_precached) diff --git a/qcsrc/client/hook.qc b/qcsrc/client/hook.qc index 3da79866d..ce6ca92b5 100644 --- a/qcsrc/client/hook.qc +++ b/qcsrc/client/hook.qc @@ -2,14 +2,12 @@ #include "_all.qh" #include "hud.qh" -#include "noise.qh" #include "../common/teams.qh" #include "../csqcmodellib/interpolate.qh" #include "../warpzonelib/common.qh" -#include "../warpzonelib/mathlib.qh" entityclass(Hook); class(Hook) .float HookType; // ENT_CLIENT_* @@ -18,33 +16,6 @@ class(Hook) .vector velocity; class(Hook) .float HookSilent; class(Hook) .float HookRange; -void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg) -{ - // I want to draw a quad... - // from and to are MIDPOINTS. - - vector axis, thickdir, A, B, C, D; - float length_tex; - - axis = normalize(to - from); - length_tex = aspect * vlen(to - from) / thickness; - - // direction is perpendicular to the view normal, and perpendicular to the axis - thickdir = normalize(cross(axis, vieworg - from)); - - A = from - thickdir * (thickness / 2); - B = from + thickdir * (thickness / 2); - C = to + thickdir * (thickness / 2); - D = to - thickdir * (thickness / 2); - - R_BeginPolygon(texture, drawflag); - R_PolygonVertex(A, '0 0 0' + shift * '1 0 0', rgb, theAlpha); - R_PolygonVertex(B, '0 1 0' + shift * '1 0 0', rgb, theAlpha); - R_PolygonVertex(C, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha); - R_PolygonVertex(D, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha); - R_EndPolygon(); -} - string Draw_GrapplingHook_trace_callback_tex; float Draw_GrapplingHook_trace_callback_rnd; vector Draw_GrapplingHook_trace_callback_rgb; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index f623e2706..32028ce42 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4,7 +4,6 @@ #include "hud_config.qh" #include "mapvoting.qh" #include "scoreboard.qh" -#include "sortlist.qh" #include "teamradar.qh" #include "t_items.qh" @@ -23,7 +22,6 @@ #include "../csqcmodellib/cl_player.qh" -#include "../warpzonelib/mathlib.qh" /* ================== @@ -31,89 +29,6 @@ Misc HUD functions ================== */ -// a border picture is a texture containing nine parts: -// 1/4 width: left part -// 1/2 width: middle part (stretched) -// 1/4 width: right part -// divided into -// 1/4 height: top part -// 1/2 height: middle part (stretched) -// 1/4 height: bottom part -void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize) -{ - if (theBorderSize.x < 0 && theBorderSize.y < 0) // draw whole image as it is - { - drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0); - return; - } - if (theBorderSize.x == 0 && theBorderSize.y == 0) // no border - { - // draw only the central part - drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0); - return; - } - - vector dX, dY; - vector width, height; - vector bW, bH; - //pic = draw_UseSkinFor(pic); - width = eX * theSize.x; - height = eY * theSize.y; - if(theSize.x <= theBorderSize.x * 2) - { - // not wide enough... draw just left and right then - bW = eX * (0.25 * theSize.x / (theBorderSize.x * 2)); - if(theSize.y <= theBorderSize.y * 2) - { - // not high enough... draw just corners - bH = eY * (0.25 * theSize.y / (theBorderSize.y * 2)); - drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0); - drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0); - drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0); - drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0); - } - else - { - dY = theBorderSize.x * eY; - drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0); - drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0); - drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0); - drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0); - drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0); - drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0); - } - } - else - { - if(theSize.y <= theBorderSize.y * 2) - { - // not high enough... draw just top and bottom then - bH = eY * (0.25 * theSize.y / (theBorderSize.y * 2)); - dX = theBorderSize.x * eX; - drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0); - drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0); - drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0); - drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0); - drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0); - drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0); - } - else - { - dX = theBorderSize.x * eX; - dY = theBorderSize.x * eY; - drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0); - drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0); - drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0); - drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0); - drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0); - drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0); - drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0); - drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0); - drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0); - } - } -} - vector HUD_Get_Num_Color (float x, float maxvalue) { float blinkingamt; @@ -205,28 +120,6 @@ vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspe return eX * best_columns + eY * best_rows; } -float stringwidth_colors(string s, vector theSize) -{ - return stringwidth(s, true, theSize); -} - -float stringwidth_nocolors(string s, vector theSize) -{ - return stringwidth(s, false, theSize); -} - -void drawstringright(vector position, string text, vector theScale, vector rgb, float theAlpha, int flag) -{ - position.x -= 2 / 3 * strlen(text) * theScale.x; - drawstring(position, text, theScale, rgb, theAlpha, flag); -} - -void drawstringcenter(vector position, string text, vector theScale, vector rgb, float theAlpha, int flag) -{ - position.x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * theScale.x); - drawstring(position, text, theScale, rgb, theAlpha, flag); -} - // return the string of the onscreen race timer string MakeRaceString(int cp, float mytime, float theirtime, float lapdelta, string theirname) { @@ -306,30 +199,6 @@ int race_CheckName(string net_name) return 0; } -int GetPlayerColorForce(int i) -{ - if(!teamplay) - return 0; - else - return stof(getplayerkeyvalue(i, "colors")) & 15; -} - -int GetPlayerColor(int i) -{ - if(!playerslots[i].gotscores) // unconnected - return NUM_SPECTATOR; - else if(stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR) - return NUM_SPECTATOR; - else - return GetPlayerColorForce(i); -} - -string GetPlayerName(int i) -{ - return ColorTranslateRGB(getplayerkeyvalue(i, "name")); -} - - /* ================== HUD panels @@ -1947,18 +1816,6 @@ void HUD_Notify(void) notify_count = count; } -// Timer (#5) -// -// TODO: macro -string seconds_tostring(float sec) -{ - float minutes; - minutes = floor(sec / 60); - - sec -= minutes * 60; - return sprintf("%d:%02d", minutes, sec); -} - void HUD_Timer(void) { if(intermission == 2) return; diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 2309426ce..ed50dda37 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -16,7 +16,6 @@ #include "particles.qh" #include "scoreboard.qh" #include "shownames.qh" -#include "sortlist.qh" #include "tuba.qh" #include "t_items.qh" #include "wall.qh" diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index c9c599945..fbd98da95 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -2,7 +2,6 @@ #include "_all.qh" #include "hud.qh" -#include "sortlist.qh" #include "../common/command/generic.qh" @@ -11,7 +10,6 @@ #include "../csqcmodellib/cl_model.qh" -#include "../warpzonelib/mathlib.qh" void AuditLists() { @@ -168,14 +166,6 @@ vector rotate(vector v, float a) return w; } -string ColorTranslateRGB(string s) -{ - if(ColorTranslateMode & 1) - return strdecolorize(s); - else - return s; -} - // decolorizes and team colors the player name when needed string playername(string thename, float teamid) { diff --git a/qcsrc/client/miscfunctions.qh b/qcsrc/client/miscfunctions.qh index 0c2be7fc5..9ac46340d 100644 --- a/qcsrc/client/miscfunctions.qh +++ b/qcsrc/client/miscfunctions.qh @@ -34,7 +34,6 @@ float PreviewExists(string name); vector rotate(vector v, float a); -int ColorTranslateMode; string ColorTranslateRGB(string s); diff --git a/qcsrc/client/noise.qc b/qcsrc/client/noise.qc deleted file mode 100644 index 2047410a9..000000000 --- a/qcsrc/client/noise.qc +++ /dev/null @@ -1,38 +0,0 @@ -#include "noise.qh" -#include "_all.qh" - -entityclass(Noise); -class(Noise) .float noise_baccum; -class(Noise) .float noise_paccum; -class(Noise) .float noise_paccum2; -class(Noise) .float noise_paccum3; -class(Noise) .float noise_bstate; - -float Noise_Brown(entity e, float dt) -{ - e.noise_baccum += random() * sqrt(dt); // same stddev for all dt - return e.noise_baccum; -} -float Noise_Pink(entity e, float dt) -{ - float f; - f = dt * 60; - // http://home.earthlink.net/~ltrammell/tech/pinkalg.htm - if(random() > pow(0.3190, f)) - e.noise_paccum = 0.34848 * (2 * random() - 1); - if(random() > pow(0.7756, f)) - e.noise_paccum2 = 0.28768 * (2 * random() - 1); - if(random() > pow(0.9613, f)) - e.noise_paccum3 = 0.43488 * (2 * random() - 1); - return e.noise_paccum + e.noise_paccum2 + e.noise_paccum3; -} -float Noise_White(entity e, float dt) -{ - return random() * 2 - 1; -} -float Noise_Burst(entity e, float dt, float p) -{ - if(random() > pow(p, dt)) - e.noise_bstate = !e.noise_bstate; - return 2 * e.noise_bstate - 1; -} diff --git a/qcsrc/client/noise.qh b/qcsrc/client/noise.qh deleted file mode 100644 index 2b18adee5..000000000 --- a/qcsrc/client/noise.qh +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef NOISE_H -#define NOISE_H - -// noises "usually" start in the range -1..1 -float Noise_Brown(entity e, float dt); -float Noise_Pink(entity e, float dt); -float Noise_White(entity e, float dt); -float Noise_Burst(entity e, float dt, float p); // +1 or -1 -#endif diff --git a/qcsrc/client/progs.src b/qcsrc/client/progs.src index 6941d86da..506669602 100644 --- a/qcsrc/client/progs.src +++ b/qcsrc/client/progs.src @@ -22,13 +22,11 @@ mapvoting.qc miscfunctions.qc modeleffects.qc movelib.qc -noise.qc particles.qc player_skeleton.qc rubble.qc scoreboard.qc shownames.qc -sortlist.qc teamradar.qc tuba.qc t_items.qc @@ -49,7 +47,6 @@ weapons/projectile.qc // TODO ../common/notifications.qc ../common/physics.qc ../common/playerstats.qc -../common/p2mathlib.qc ../common/util.qc ../common/viewloc.qc @@ -77,7 +74,6 @@ weapons/projectile.qc // TODO ../warpzonelib/anglestransform.qc ../warpzonelib/client.qc ../warpzonelib/common.qc -../warpzonelib/mathlib.qc ../warpzonelib/util_server.qc ../../mod/client/progs.inc diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 1e2ef0baa..c635e9754 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -2,7 +2,6 @@ #include "_all.qh" #include "hud.qh" -#include "sortlist.qh" #include "../common/constants.qh" #include "../common/mapinfo.qh" diff --git a/qcsrc/client/sortlist.qc b/qcsrc/client/sortlist.qc deleted file mode 100644 index 4d05d2c5f..000000000 --- a/qcsrc/client/sortlist.qc +++ /dev/null @@ -1,121 +0,0 @@ -#include "sortlist.qh" - -entity Sort_Spawn() -{ - entity sort; - sort = spawn(); - sort.sort_next = world; - sort.chain = sort; - return sort; -} -/* -entity Sort_New(float(entity,entity) cmp) -{ - entity sort; - sort = spawn(); - sort.sort_cmp = cmp; - sort.sort_next = world; - sort.chain = sort; - return sort; -} - -void Sort_Remove(entity sort) -{ - entity next; - while(sort.sort_next) - { - next = sort.sort_next; - remove(sort); - sort = next; - } - remove(sort); -} - -void Sort_Add(entity sort, entity ent) -{ - entity next, parent; - parent = sort; - next = sort.sort_next; - while(next) - { - if(!sort.sort_cmp(next, ent)) - break; - parent = next; - next = next.sort_next; - } - ent.sort_next = next; - ent.sort_prev = parent; - parent.sort_next = ent; - if(next) - next.sort_prev = ent; -} - -void Sort_Reset(entity sort) -{ - sort.chain = sort; -} - -float Sort_HasNext(entity sort) -{ - return (sort.chain.sort_next != world); -} - -entity Sort_Next(entity sort) -{ - entity next; - next = sort.chain.sort_next; - if(!next) { - next = spawn(); - sort.chain.sort_next = next; - next.sort_prev = sort.chain; - next.sort_next = world; - } - sort.chain = next; - return next; -} - -void Sort_Finish(entity sort) -{ - entity next; - next = sort.chain; - if(!next) - return; - - while(next.sort_next) - { - sort = next.sort_next; - next.sort_next = sort.sort_next; - remove(sort); - } -} - -entity Sort_Get(entity sort, float i) -{ - for (; sort.sort_next && i > 0; --i) - sort = sort.sort_next; - return sort; -} -*/ - -/* -void Sort_Erase(entity ent) -{ - ent.sort_prev.sort_next = ent.sort_next; - if(ent.sort_next) - ent.sort_next.sort_prev = ent.sort_prev; - remove(ent); -} - -void Sort_RemoveOld(entity sort) -{ - entity tmp; - for(tmp = sort.sort_next; tmp; tmp = tmp.sort_next) - { - if(tmp.frame < time) - { - tmp = tmp.sort_prev; - Sort_Erase(tmp.sort_next); - } - } -} -*/ diff --git a/qcsrc/client/sortlist.qh b/qcsrc/client/sortlist.qh deleted file mode 100644 index 298314810..000000000 --- a/qcsrc/client/sortlist.qh +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef SORTLIST_H -#define SORTLIST_H - -entityclass(Sort); -//.float(entity,entity) sort_cmp; -class(Sort) .entity sort_next, sort_prev; - -entity Sort_Spawn(); - -/** - * Swap two neighbours in a sortlist. - * @param a FIRST entity - * @param b entity after a - */ -#define SORT_SWAP(a,b) \ - b.sort_prev = a.sort_prev; \ - a.sort_next = b.sort_next; \ - if(b.sort_next) b.sort_next.sort_prev = a; \ - if(a.sort_prev) a.sort_prev.sort_next = b; \ - a.sort_prev = b; \ - b.sort_next = a - -#endif diff --git a/qcsrc/client/teamradar.qc b/qcsrc/client/teamradar.qc index 874fec1f5..ab6129e78 100644 --- a/qcsrc/client/teamradar.qc +++ b/qcsrc/client/teamradar.qc @@ -7,21 +7,6 @@ #include "../csqcmodellib/interpolate.qh" -float vlen2d(vector v) -{ - return sqrt(v.x * v.x + v.y * v.y); -} - -float vlen_maxnorm2d(vector v) -{ - return max(v.x, v.y, -v.x, -v.y); -} - -float vlen_minnorm2d(vector v) -{ - return min(max(v.x, -v.x), max(v.y, -v.y)); -} - vector teamradar_3dcoord_to_texcoord(vector in) { vector out; diff --git a/qcsrc/client/teamradar.qh b/qcsrc/client/teamradar.qh index b2329cfb0..8aefc0fad 100644 --- a/qcsrc/client/teamradar.qh +++ b/qcsrc/client/teamradar.qh @@ -27,12 +27,6 @@ float hud_panel_radar_maximized_zoommode; float hud_panel_radar_maximized_rotation; -float vlen2d(vector v); - -float vlen_maxnorm2d(vector v); - -float vlen_minnorm2d(vector v); - vector teamradar_2dcoord_to_texcoord(vector in); vector teamradar_3dcoord_to_texcoord(vector in); diff --git a/qcsrc/client/tuba.qc b/qcsrc/client/tuba.qc index 0b300d3b2..2b9dcd0a8 100644 --- a/qcsrc/client/tuba.qc +++ b/qcsrc/client/tuba.qc @@ -4,7 +4,6 @@ #include "../common/constants.qh" #include "../common/util.qh" -#include "../warpzonelib/mathlib.qh" #define TUBA_STARTNOTE(i, n) W_Sound(strcat("tuba", (i ? ftos(i) : ""), "_loopnote", ftos(n))) diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 9b4eddd48..7720f58fb 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -5,7 +5,6 @@ #include "hud.qh" #include "hud_config.qh" #include "mapvoting.qh" -#include "noise.qh" #include "scoreboard.qh" #include "shownames.qh" @@ -25,7 +24,6 @@ #include "../warpzonelib/client.qh" #include "../warpzonelib/common.qh" -#include "../warpzonelib/mathlib.qh" entity porto; vector polyline[16]; diff --git a/qcsrc/common/command/rpn.qc b/qcsrc/common/command/rpn.qc index 700ceb46e..c975f98ea 100644 --- a/qcsrc/common/command/rpn.qc +++ b/qcsrc/common/command/rpn.qc @@ -1,7 +1,6 @@ #include "command.qh" #include "rpn.qh" -#include "../../warpzonelib/mathlib.qh" // ======================================== // RPN command code, written by divVerent diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index a85f09e1b..6d332d611 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -177,10 +177,6 @@ const int CTF_STATE_COMMANDER = 3; const int HUD_NORMAL = 0; const int HUD_BUMBLEBEE_GUN = 25; -const vector eX = '1 0 0'; -const vector eY = '0 1 0'; -const vector eZ = '0 0 1'; - // moved that here so the client knows the max. // # of maps, I'll use arrays for them :P const int MAPVOTE_COUNT = 30; diff --git a/qcsrc/common/p2mathlib.qc b/qcsrc/common/p2mathlib.qc deleted file mode 100644 index 85c5396d7..000000000 --- a/qcsrc/common/p2mathlib.qc +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 2015 Micah Talkiewicz. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -vector vec_bias(vector v, float f){ - vector c; - c_x = v_x + f; - c_y = v_y + f; - c_z = v_z + f; - return c; -} -vector vec_to_min (vector a, vector b) { - vector c; - c_x = min (a_x, b_x); - c_y = min (a_y, b_y); - c_z = min (a_z, b_z); - return c; -} - -vector vec_to_max (vector a, vector b) { - vector c; - c_x = max (a_x, b_x); - c_y = max (a_y, b_y); - c_z = max (a_z, b_z); - return c; -} - -// there may already be a function for bounding a vector in this manner, however my very quick search did not reveal one -- Player_2 -vector vec_bounds_in (vector point, vector a, vector b) { - vector c, d, e; - - d = vec_to_min(a,b); - e = vec_to_max(a,b); - - c = vec_to_max(point, d); - c = vec_to_min(c, e); - - return c; - -} - -vector vec_bounds_out (vector point, vector a, vector b) { - vector c, d, e; - - d = vec_to_max(a,b); - e = vec_to_min(a,b); - - c = vec_to_max(point, d); - c = vec_to_min(c, e); - - return c; - -} - -float angle_snap_f (float f, float increment){ - - float i; - for (i = 0; i <= 360; ){ - if (f <= i - increment) - return i - increment; - i = i + increment; - } - - return 0; -} - -vector angle_snap_vec (vector v, float increment) { - vector c; - c_x = angle_snap_f (v_x, increment); - c_y = angle_snap_f (v_y, increment); - c_z = angle_snap_f (v_z, increment); - return c; -} - -vector aim_vec (vector origin, vector target) { - vector v; - //we float around x and y, but rotate around z - v_x = target_x - origin_x; - v_y = target_y - origin_y; - v_z = origin_z - target_z; - //get the angles actual - return vectoangles(normalize(v)); -} diff --git a/qcsrc/common/p2mathlib.qh b/qcsrc/common/p2mathlib.qh deleted file mode 100644 index c92f26a91..000000000 --- a/qcsrc/common/p2mathlib.qh +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2015 Micah Talkiewicz. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -vector vec_bias(vector v, float f); - - -vector vec_to_min (vector a, vector b); -vector vec_to_max (vector a, vector b); - -// there may already be a function for bounding a vector in this manner, however my very quick search did not reveal one -- Player_2 -vector vec_bounds_in (vector point, vector a, vector b); -vector vec_bounds_out (vector point, vector a, vector b); - -float angle_snap_f (float f, float increment); -vector angle_snap_vec (vector v, float increment); - -vector aim_vec (vector origin, vector target); diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 56d64f561..b6e2f348b 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -4,7 +4,6 @@ #include "../dpdefs/csprogsdefs.qh" #include "../client/defs.qh" #include "constants.qh" - #include "../warpzonelib/mathlib.qh" #include "../client/mutators/events.qh" #include "mapinfo.qh" #include "notifications.qh" @@ -13,7 +12,6 @@ #elif defined(SVQC) #include "../dpdefs/progsdefs.qh" #include "../dpdefs/dpextensions.qh" - #include "../warpzonelib/mathlib.qh" #include "constants.qh" #include "../server/autocvars.qh" #include "../server/defs.qh" diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 7d5ef31ee..046298a4c 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -9,7 +9,6 @@ #include "../constants.qh" #include "../stats.qh" #include "../../warpzonelib/anglestransform.qh" - #include "../../warpzonelib/mathlib.qh" #include "../../warpzonelib/common.qh" #include "../../warpzonelib/client.qh" #include "../util.qh" @@ -25,7 +24,6 @@ #include "../../dpdefs/progsdefs.qh" #include "../../dpdefs/dpextensions.qh" #include "../../warpzonelib/anglestransform.qh" - #include "../../warpzonelib/mathlib.qh" #include "../../warpzonelib/common.qh" #include "../../warpzonelib/util_server.qh" #include "../../warpzonelib/server.qh" diff --git a/qcsrc/csqcmodellib/cl_player.qc b/qcsrc/csqcmodellib/cl_player.qc index 30dab91f2..7cb3c2852 100644 --- a/qcsrc/csqcmodellib/cl_player.qc +++ b/qcsrc/csqcmodellib/cl_player.qc @@ -24,7 +24,6 @@ #include "../dpdefs/csprogsdefs.qh" #include "../client/defs.qh" #include "../common/constants.qh" - #include "../common/p2mathlib.qh" #include "../common/stats.qh" #include "../common/util.qh" #include "interpolate.qh" diff --git a/qcsrc/lib/Draw.qh b/qcsrc/lib/Draw.qh new file mode 100644 index 000000000..4ca536956 --- /dev/null +++ b/qcsrc/lib/Draw.qh @@ -0,0 +1,133 @@ +#ifdef CSQC +#ifndef DRAW_H +#define DRAW_H + +#include "I18N.qh" +#include "Vector.qh" + +#include "../client/defs.qh" + +void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg) +{ + // I want to draw a quad... + // from and to are MIDPOINTS. + + vector axis, thickdir, A, B, C, D; + float length_tex; + + axis = normalize(to - from); + length_tex = aspect * vlen(to - from) / thickness; + + // direction is perpendicular to the view normal, and perpendicular to the axis + thickdir = normalize(cross(axis, vieworg - from)); + + A = from - thickdir * (thickness / 2); + B = from + thickdir * (thickness / 2); + C = to + thickdir * (thickness / 2); + D = to - thickdir * (thickness / 2); + + R_BeginPolygon(texture, drawflag); + R_PolygonVertex(A, '0 0 0' + shift * '1 0 0', rgb, theAlpha); + R_PolygonVertex(B, '0 1 0' + shift * '1 0 0', rgb, theAlpha); + R_PolygonVertex(C, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha); + R_PolygonVertex(D, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha); + R_EndPolygon(); +} + +// a border picture is a texture containing nine parts: +// 1/4 width: left part +// 1/2 width: middle part (stretched) +// 1/4 width: right part +// divided into +// 1/4 height: top part +// 1/2 height: middle part (stretched) +// 1/4 height: bottom part +void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize) +{ + if (theBorderSize.x < 0 && theBorderSize.y < 0) // draw whole image as it is + { + drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0); + return; + } + if (theBorderSize.x == 0 && theBorderSize.y == 0) // no border + { + // draw only the central part + drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0); + return; + } + + vector dX, dY; + vector width, height; + vector bW, bH; + //pic = draw_UseSkinFor(pic); + width = eX * theSize.x; + height = eY * theSize.y; + if(theSize.x <= theBorderSize.x * 2) + { + // not wide enough... draw just left and right then + bW = eX * (0.25 * theSize.x / (theBorderSize.x * 2)); + if(theSize.y <= theBorderSize.y * 2) + { + // not high enough... draw just corners + bH = eY * (0.25 * theSize.y / (theBorderSize.y * 2)); + drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0); + drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0); + drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0); + drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0); + } + else + { + dY = theBorderSize.x * eY; + drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0); + drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0); + drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0); + drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0); + drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0); + drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0); + } + } + else + { + if(theSize.y <= theBorderSize.y * 2) + { + // not high enough... draw just top and bottom then + bH = eY * (0.25 * theSize.y / (theBorderSize.y * 2)); + dX = theBorderSize.x * eX; + drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0); + drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0); + drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0); + drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0); + drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0); + drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0); + } + else + { + dX = theBorderSize.x * eX; + dY = theBorderSize.x * eY; + drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0); + drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0); + drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0); + drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0); + drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0); + drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0); + drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0); + drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0); + drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0); + } + } +} + +void drawstringright(vector position, string text, vector theScale, vector rgb, float theAlpha, int flag) +{ + position.x -= 2 / 3 * strlen(text) * theScale.x; + drawstring(position, text, theScale, rgb, theAlpha, flag); +} + +void drawstringcenter(vector position, string text, vector theScale, vector rgb, float theAlpha, int flag) +{ + position.x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * theScale.x); + drawstring(position, text, theScale, rgb, theAlpha, flag); +} + +#endif +#endif diff --git a/qcsrc/lib/Player.qh b/qcsrc/lib/Player.qh new file mode 100644 index 000000000..07034a066 --- /dev/null +++ b/qcsrc/lib/Player.qh @@ -0,0 +1,34 @@ +#ifdef CSQC +#ifndef PLAYER_H +#define PLAYER_H + +#include "String.qh" + +#include "../client/main.qh" +#include "../common/teams.qh" + +int GetPlayerColorForce(int i) +{ + if(!teamplay) + return 0; + else + return stof(getplayerkeyvalue(i, "colors")) & 15; +} + +int GetPlayerColor(int i) +{ + if(!playerslots[i].gotscores) // unconnected + return NUM_SPECTATOR; + else if(stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR) + return NUM_SPECTATOR; + else + return GetPlayerColorForce(i); +} + +string GetPlayerName(int i) +{ + return ColorTranslateRGB(getplayerkeyvalue(i, "name")); +} + +#endif +#endif diff --git a/qcsrc/lib/String.qh b/qcsrc/lib/String.qh new file mode 100644 index 000000000..faf81b29d --- /dev/null +++ b/qcsrc/lib/String.qh @@ -0,0 +1,38 @@ +#ifndef STRING_H +#define STRING_H + +#ifndef SVQC +float stringwidth_colors(string s, vector theSize) +{ + return stringwidth(s, true, theSize); +} + +float stringwidth_nocolors(string s, vector theSize) +{ + return stringwidth(s, false, theSize); +} +#endif + +// Timer (#5) +// +// TODO: macro +string seconds_tostring(float sec) +{ + float minutes; + minutes = floor(sec / 60); + + sec -= minutes * 60; + return sprintf("%d:%02d", minutes, sec); +} + +int ColorTranslateMode; + +string ColorTranslateRGB(string s) +{ + if(ColorTranslateMode & 1) + return strdecolorize(s); + else + return s; +} + +#endif diff --git a/qcsrc/lib/Vector.qh b/qcsrc/lib/Vector.qh new file mode 100644 index 000000000..d81a79571 --- /dev/null +++ b/qcsrc/lib/Vector.qh @@ -0,0 +1,34 @@ +#ifndef VECTOR_H +#define VECTOR_H + +const vector eX = '1 0 0'; +const vector eY = '0 1 0'; +const vector eZ = '0 0 1'; + +vector randompos(vector m1, vector m2) +{ + vector v; + m2 = m2 - m1; + v_x = m2_x * random() + m1_x; + v_y = m2_y * random() + m1_y; + v_z = m2_z * random() + m1_z; + return v; +} + +float vlen2d(vector v) +{ + return sqrt(v.x * v.x + v.y * v.y); +} + +float vlen_maxnorm2d(vector v) +{ + return max(v.x, v.y, -v.x, -v.y); +} + +float vlen_minnorm2d(vector v) +{ + return min(max(v.x, -v.x), max(v.y, -v.y)); +} + + +#endif diff --git a/qcsrc/lib/_all.inc b/qcsrc/lib/_all.inc index 108790668..a3bcbcb5c 100644 --- a/qcsrc/lib/_all.inc +++ b/qcsrc/lib/_all.inc @@ -1,12 +1,21 @@ +#include "../warpzonelib/mathlib.qc" + #include "Accumulate.qh" #include "Counting.qh" #include "Cvar.qh" +#include "Draw.qh" #include "I18N.qh" #include "Lazy.qh" #include "Nil.qh" +#include "noise.qc" #include "OO.qh" +#include "p2mathlib.qc" +#include "Player.qh" #include "prandom.qc" #include "Progname.qh" #include "Registry.qh" +#include "sortlist.qc" +#include "String.qh" #include "test.qc" #include "urllib.qc" +#include "Vector.qh" diff --git a/qcsrc/lib/noise.qc b/qcsrc/lib/noise.qc new file mode 100644 index 000000000..5bd6ad650 --- /dev/null +++ b/qcsrc/lib/noise.qc @@ -0,0 +1,37 @@ +// noises "usually" start in the range -1..1 +entityclass(Noise); +class(Noise) .float noise_baccum; +class(Noise) .float noise_paccum; +class(Noise) .float noise_paccum2; +class(Noise) .float noise_paccum3; +class(Noise) .float noise_bstate; + +float Noise_Brown(entity e, float dt) +{ + e.noise_baccum += random() * sqrt(dt); // same stddev for all dt + return e.noise_baccum; +} +float Noise_Pink(entity e, float dt) +{ + float f; + f = dt * 60; + // http://home.earthlink.net/~ltrammell/tech/pinkalg.htm + if(random() > pow(0.3190, f)) + e.noise_paccum = 0.34848 * (2 * random() - 1); + if(random() > pow(0.7756, f)) + e.noise_paccum2 = 0.28768 * (2 * random() - 1); + if(random() > pow(0.9613, f)) + e.noise_paccum3 = 0.43488 * (2 * random() - 1); + return e.noise_paccum + e.noise_paccum2 + e.noise_paccum3; +} +float Noise_White(entity e, float dt) +{ + return random() * 2 - 1; +} +/** +1 or -1 */ +float Noise_Burst(entity e, float dt, float p) +{ + if(random() > pow(p, dt)) + e.noise_bstate = !e.noise_bstate; + return 2 * e.noise_bstate - 1; +} diff --git a/qcsrc/lib/p2mathlib.qc b/qcsrc/lib/p2mathlib.qc new file mode 100644 index 000000000..85c5396d7 --- /dev/null +++ b/qcsrc/lib/p2mathlib.qc @@ -0,0 +1,98 @@ +/* + Copyright (C) 2015 Micah Talkiewicz. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +vector vec_bias(vector v, float f){ + vector c; + c_x = v_x + f; + c_y = v_y + f; + c_z = v_z + f; + return c; +} +vector vec_to_min (vector a, vector b) { + vector c; + c_x = min (a_x, b_x); + c_y = min (a_y, b_y); + c_z = min (a_z, b_z); + return c; +} + +vector vec_to_max (vector a, vector b) { + vector c; + c_x = max (a_x, b_x); + c_y = max (a_y, b_y); + c_z = max (a_z, b_z); + return c; +} + +// there may already be a function for bounding a vector in this manner, however my very quick search did not reveal one -- Player_2 +vector vec_bounds_in (vector point, vector a, vector b) { + vector c, d, e; + + d = vec_to_min(a,b); + e = vec_to_max(a,b); + + c = vec_to_max(point, d); + c = vec_to_min(c, e); + + return c; + +} + +vector vec_bounds_out (vector point, vector a, vector b) { + vector c, d, e; + + d = vec_to_max(a,b); + e = vec_to_min(a,b); + + c = vec_to_max(point, d); + c = vec_to_min(c, e); + + return c; + +} + +float angle_snap_f (float f, float increment){ + + float i; + for (i = 0; i <= 360; ){ + if (f <= i - increment) + return i - increment; + i = i + increment; + } + + return 0; +} + +vector angle_snap_vec (vector v, float increment) { + vector c; + c_x = angle_snap_f (v_x, increment); + c_y = angle_snap_f (v_y, increment); + c_z = angle_snap_f (v_z, increment); + return c; +} + +vector aim_vec (vector origin, vector target) { + vector v; + //we float around x and y, but rotate around z + v_x = target_x - origin_x; + v_y = target_y - origin_y; + v_z = origin_z - target_z; + //get the angles actual + return vectoangles(normalize(v)); +} diff --git a/qcsrc/lib/p2mathlib.qh b/qcsrc/lib/p2mathlib.qh new file mode 100644 index 000000000..c92f26a91 --- /dev/null +++ b/qcsrc/lib/p2mathlib.qh @@ -0,0 +1,33 @@ +/* + Copyright (C) 2015 Micah Talkiewicz. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +vector vec_bias(vector v, float f); + + +vector vec_to_min (vector a, vector b); +vector vec_to_max (vector a, vector b); + +// there may already be a function for bounding a vector in this manner, however my very quick search did not reveal one -- Player_2 +vector vec_bounds_in (vector point, vector a, vector b); +vector vec_bounds_out (vector point, vector a, vector b); + +float angle_snap_f (float f, float increment); +vector angle_snap_vec (vector v, float increment); + +vector aim_vec (vector origin, vector target); diff --git a/qcsrc/lib/prandom.qc b/qcsrc/lib/prandom.qc index 8b1f8d938..975080a71 100644 --- a/qcsrc/lib/prandom.qc +++ b/qcsrc/lib/prandom.qc @@ -1,7 +1,5 @@ #include "prandom.qh" -#include "../warpzonelib/mathlib.qh" - // prandom - PREDICTABLE random number generator (not seeded yet) #ifdef USE_PRANDOM diff --git a/qcsrc/lib/sortlist.qc b/qcsrc/lib/sortlist.qc new file mode 100644 index 000000000..fcaf6be50 --- /dev/null +++ b/qcsrc/lib/sortlist.qc @@ -0,0 +1,121 @@ +#include "sortlist.qh" + +entity Sort_Spawn() +{ + entity sort; + sort = spawn(); + sort.sort_next = NULL; + sort.chain = sort; + return sort; +} +/* +entity Sort_New(float(entity,entity) cmp) +{ + entity sort; + sort = spawn(); + sort.sort_cmp = cmp; + sort.sort_next = world; + sort.chain = sort; + return sort; +} + +void Sort_Remove(entity sort) +{ + entity next; + while(sort.sort_next) + { + next = sort.sort_next; + remove(sort); + sort = next; + } + remove(sort); +} + +void Sort_Add(entity sort, entity ent) +{ + entity next, parent; + parent = sort; + next = sort.sort_next; + while(next) + { + if(!sort.sort_cmp(next, ent)) + break; + parent = next; + next = next.sort_next; + } + ent.sort_next = next; + ent.sort_prev = parent; + parent.sort_next = ent; + if(next) + next.sort_prev = ent; +} + +void Sort_Reset(entity sort) +{ + sort.chain = sort; +} + +float Sort_HasNext(entity sort) +{ + return (sort.chain.sort_next != world); +} + +entity Sort_Next(entity sort) +{ + entity next; + next = sort.chain.sort_next; + if(!next) { + next = spawn(); + sort.chain.sort_next = next; + next.sort_prev = sort.chain; + next.sort_next = world; + } + sort.chain = next; + return next; +} + +void Sort_Finish(entity sort) +{ + entity next; + next = sort.chain; + if(!next) + return; + + while(next.sort_next) + { + sort = next.sort_next; + next.sort_next = sort.sort_next; + remove(sort); + } +} + +entity Sort_Get(entity sort, float i) +{ + for (; sort.sort_next && i > 0; --i) + sort = sort.sort_next; + return sort; +} +*/ + +/* +void Sort_Erase(entity ent) +{ + ent.sort_prev.sort_next = ent.sort_next; + if(ent.sort_next) + ent.sort_next.sort_prev = ent.sort_prev; + remove(ent); +} + +void Sort_RemoveOld(entity sort) +{ + entity tmp; + for(tmp = sort.sort_next; tmp; tmp = tmp.sort_next) + { + if(tmp.frame < time) + { + tmp = tmp.sort_prev; + Sort_Erase(tmp.sort_next); + } + } +} +*/ diff --git a/qcsrc/lib/sortlist.qh b/qcsrc/lib/sortlist.qh new file mode 100644 index 000000000..d4a1f183e --- /dev/null +++ b/qcsrc/lib/sortlist.qh @@ -0,0 +1,23 @@ +#ifndef SORTLIST_H +#define SORTLIST_H + +entityclass(Sort); +//.float(entity,entity) sort_cmp; +class(Sort) .entity chain, sort_next, sort_prev; + +entity Sort_Spawn(); + +/** + * Swap two neighbours in a sortlist. + * @param a FIRST entity + * @param b entity after a + */ +#define SORT_SWAP(a,b) \ + b.sort_prev = a.sort_prev; \ + a.sort_next = b.sort_next; \ + if(b.sort_next) b.sort_next.sort_prev = a; \ + if(a.sort_prev) a.sort_prev.sort_next = b; \ + a.sort_prev = b; \ + b.sort_next = a + +#endif diff --git a/qcsrc/menu/progs.src b/qcsrc/menu/progs.src index 600e326a3..92b10fa4c 100644 --- a/qcsrc/menu/progs.src +++ b/qcsrc/menu/progs.src @@ -28,6 +28,5 @@ xonotic/util.qc ../common/vehicles/all.qc ../common/weapons/all.qc -../warpzonelib/mathlib.qc ../../mod/menu/progs.inc diff --git a/qcsrc/menu/xonotic/slider_decibels.qc b/qcsrc/menu/xonotic/slider_decibels.qc index 3d8cf1da4..b40488ef4 100644 --- a/qcsrc/menu/xonotic/slider_decibels.qc +++ b/qcsrc/menu/xonotic/slider_decibels.qc @@ -1,5 +1,3 @@ -#include "../../warpzonelib/mathlib.qh" - #ifndef SLIDER_DECIBELS_H #define SLIDER_DECIBELS_H #include "slider.qc" diff --git a/qcsrc/server/anticheat.qc b/qcsrc/server/anticheat.qc index 1e6759684..d065cb59f 100644 --- a/qcsrc/server/anticheat.qc +++ b/qcsrc/server/anticheat.qc @@ -8,7 +8,6 @@ #include "../dpdefs/progsdefs.qh" #include "../dpdefs/dpextensions.qh" -#include "../warpzonelib/mathlib.qh" #include "command/common.qh" diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 0bf2df320..29e75b63b 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -31,7 +31,6 @@ #include "../../common/monsters/sv_monsters.qh" -#include "../../warpzonelib/mathlib.qh" void PutObserverInServer (void); diff --git a/qcsrc/server/mutators/gamemode.qh b/qcsrc/server/mutators/gamemode.qh index d272af857..d2066b9ab 100644 --- a/qcsrc/server/mutators/gamemode.qh +++ b/qcsrc/server/mutators/gamemode.qh @@ -36,7 +36,6 @@ #include "../../common/stats.qh" #include "../../common/teams.qh" -#include "../../warpzonelib/mathlib.qh" #include "../../warpzonelib/server.qh" #include "../../warpzonelib/util_server.qh" diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index 6ebf651f2..d6859bee3 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -8,7 +8,6 @@ #endif #include "../../warpzonelib/common.qh" -#include "../../warpzonelib/mathlib.qh" void ctf_FakeTimeLimit(entity e, float t) { diff --git a/qcsrc/server/mutators/gamemode_onslaught.qc b/qcsrc/server/mutators/gamemode_onslaught.qc index 73c37997a..708683e67 100644 --- a/qcsrc/server/mutators/gamemode_onslaught.qc +++ b/qcsrc/server/mutators/gamemode_onslaught.qc @@ -4,16 +4,6 @@ #include "../controlpoint.qh" #include "../generator.qh" -vector randompos(vector m1, vector m2) -{ - vector v; - m2 = m2 - m1; - v_x = m2_x * random() + m1_x; - v_y = m2_y * random() + m1_y; - v_z = m2_z * random() + m1_z; - return v; -} - // ======================= // CaptureShield Functions // ======================= diff --git a/qcsrc/server/mutators/mutator.qh b/qcsrc/server/mutators/mutator.qh index fa4c9ec8f..39adb175c 100644 --- a/qcsrc/server/mutators/mutator.qh +++ b/qcsrc/server/mutators/mutator.qh @@ -39,7 +39,6 @@ #include "../../common/monsters/all.qh" #include "../../warpzonelib/anglestransform.qh" -#include "../../warpzonelib/mathlib.qh" #include "../../warpzonelib/server.qh" #include "../../warpzonelib/util_server.qh" diff --git a/qcsrc/server/mutators/mutators_include.qc b/qcsrc/server/mutators/mutators_include.qc index c5b1ce2ca..aaedcba8b 100644 --- a/qcsrc/server/mutators/mutators_include.qc +++ b/qcsrc/server/mutators/mutators_include.qc @@ -4,7 +4,6 @@ #include "../../dpdefs/progsdefs.qh" #include "../../dpdefs/dpextensions.qh" #include "../../warpzonelib/anglestransform.qh" - #include "../../warpzonelib/mathlib.qh" #include "../../warpzonelib/common.qh" #include "../../warpzonelib/util_server.qh" #include "../../warpzonelib/server.qh" diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index 9dd0fae9b..22afdf411 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -97,7 +97,6 @@ weapons/weaponsystem.qc ../common/notifications.qc ../common/physics.qc ../common/playerstats.qc -../common/p2mathlib.qc ../common/viewloc.qc ../common/triggers/include.qc ../common/util.qc @@ -120,7 +119,6 @@ weapons/weaponsystem.qc ../warpzonelib/anglestransform.qc ../warpzonelib/common.qc -../warpzonelib/mathlib.qc ../warpzonelib/server.qc ../warpzonelib/util_server.qc diff --git a/qcsrc/server/t_plats.qc b/qcsrc/server/t_plats.qc index b93b1d577..41354bf8a 100644 --- a/qcsrc/server/t_plats.qc +++ b/qcsrc/server/t_plats.qc @@ -17,7 +17,6 @@ #include "../csqcmodellib/sv_model.qh" #include "../warpzonelib/common.qh" -#include "../warpzonelib/mathlib.qh" #include "../warpzonelib/util_server.qh" .float height;