]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Extract more lib functions
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 27 Aug 2015 02:38:07 +0000 (12:38 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 27 Aug 2015 02:38:07 +0000 (12:38 +1000)
46 files changed:
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/generator.qc
qcsrc/client/hook.qc
qcsrc/client/hud.qc
qcsrc/client/main.qc
qcsrc/client/miscfunctions.qc
qcsrc/client/miscfunctions.qh
qcsrc/client/noise.qc [deleted file]
qcsrc/client/noise.qh [deleted file]
qcsrc/client/progs.src
qcsrc/client/scoreboard.qc
qcsrc/client/sortlist.qc [deleted file]
qcsrc/client/sortlist.qh [deleted file]
qcsrc/client/teamradar.qc
qcsrc/client/teamradar.qh
qcsrc/client/tuba.qc
qcsrc/client/view.qc
qcsrc/common/command/rpn.qc
qcsrc/common/constants.qh
qcsrc/common/p2mathlib.qc [deleted file]
qcsrc/common/p2mathlib.qh [deleted file]
qcsrc/common/util.qc
qcsrc/common/weapons/all.qc
qcsrc/csqcmodellib/cl_player.qc
qcsrc/lib/Draw.qh [new file with mode: 0644]
qcsrc/lib/Player.qh [new file with mode: 0644]
qcsrc/lib/String.qh [new file with mode: 0644]
qcsrc/lib/Vector.qh [new file with mode: 0644]
qcsrc/lib/_all.inc
qcsrc/lib/noise.qc [new file with mode: 0644]
qcsrc/lib/p2mathlib.qc [new file with mode: 0644]
qcsrc/lib/p2mathlib.qh [new file with mode: 0644]
qcsrc/lib/prandom.qc
qcsrc/lib/sortlist.qc [new file with mode: 0644]
qcsrc/lib/sortlist.qh [new file with mode: 0644]
qcsrc/menu/progs.src
qcsrc/menu/xonotic/slider_decibels.qc
qcsrc/server/anticheat.qc
qcsrc/server/command/sv_cmd.qc
qcsrc/server/mutators/gamemode.qh
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_onslaught.qc
qcsrc/server/mutators/mutator.qh
qcsrc/server/mutators/mutators_include.qc
qcsrc/server/progs.src
qcsrc/server/t_plats.qc

index 227341ae3d4936458a81d1369e89e1fa8e92d492..80b68a6e287384480a002026329a1f8f4cba283d 100644 (file)
@@ -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;
index ed4b356817fdebf3c33002e62b299dccbc71a99e..46872d8173296c7e810e289a94256ade3b3c7cda 100644 (file)
@@ -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)
index 3da79866d874a4926033db89cd349562d6566a99..ce6ca92b5f4ec0c1b774c32540aefcf7bc10d4fe 100644 (file)
@@ -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;
index f623e2706849f4594fa3faaa18b287cb8f6259db..32028ce423caa39dd81f8d73a46d6ce753b6949d 100644 (file)
@@ -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;
index 2309426cee16fe46b7c4d9a8f00f61aa95368a4c..ed50dda37878b5b7dc20e67a08f09708875215e6 100644 (file)
@@ -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"
index c9c59994548b2f071bb1f7162e9cdedbd3dd5d7d..fbd98da95e53021332869743c5be700f3293b1d8 100644 (file)
@@ -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)
 {
index 0c2be7fc54afa6dbab8782acb592f2af11125ace..9ac46340dd45a40ec01982bd9961d25ac5baec6b 100644 (file)
@@ -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 (file)
index 2047410..0000000
+++ /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 (file)
index 2b18ade..0000000
+++ /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
index 6941d86daf609bbcf3a598f990c3d68ffca607da..5066696022308653a84774cbd84fc16494ef3d71 100644 (file)
@@ -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
index 1e2ef0baaafa0fc35ffd2c4130406a2adb176981..c635e975496df63c584d1a56b8aa0253e6bd0a20 100644 (file)
@@ -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 (file)
index 4d05d2c..0000000
+++ /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 (file)
index 2983148..0000000
+++ /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
index 874fec1f596d1aa7c04ee068e4ebd9b6bc5d0239..ab6129e782cd214de6e72b33d7731b6ef7960962 100644 (file)
@@ -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;
index b2329cfb06c715137474f0ce11eb5dbe23c187e1..8aefc0fad1bea52f62a739dca70ce404ed383a20 100644 (file)
@@ -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);
index 0b300d3b2e17364b889d5939143cbdf9431a2e7e..2b9dcd0a83840e80d9126196abb6185aa7cfb878 100644 (file)
@@ -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)))
 
index 9b4eddd4891d7e4f80f4ccd4af9157b7c927b4cb..7720f58fbe6fa73d06c2f91296852c3e43aecd5a 100644 (file)
@@ -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];
index 700ceb46ea02dc5fa5c210b5fc3e3a5074f98a28..c975f98ea988418b5d13501f7cb0b3f109bad3d9 100644 (file)
@@ -1,7 +1,6 @@
 #include "command.qh"
 #include "rpn.qh"
 
-#include "../../warpzonelib/mathlib.qh"
 
 // ========================================
 //  RPN command code, written by divVerent
index a85f09e1bfce0599aa1369265e9c547b75447e0b..6d332d61198ecc36d1170fecaacc9be43cd17c09 100644 (file)
@@ -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 (file)
index 85c5396..0000000
+++ /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 (file)
index c92f26a..0000000
+++ /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);
index 56d64f5614ccf9e503afbd2c012c501f0cf55548..b6e2f348b7753a8bd3aeb1c9d4924161c171f7b6 100644 (file)
@@ -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"
index 7d5ef31eecef27277ed8c73d1b92456c0e6a2bb0..046298a4c4f97c7bd2111a74503b2ac7483d46c6 100644 (file)
@@ -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"
index 30dab91f2e3e3c0e2cf280b3c222902116d36f83..7cb3c2852244f53aa105f4d771864a4432990867 100644 (file)
@@ -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 (file)
index 0000000..4ca5369
--- /dev/null
@@ -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 (file)
index 0000000..07034a0
--- /dev/null
@@ -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 (file)
index 0000000..faf81b2
--- /dev/null
@@ -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 (file)
index 0000000..d81a795
--- /dev/null
@@ -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
index 108790668f24eb9c5a4b708549a5b5d44e001f83..a3bcbcb5c0e8c8e2a20b9b8f71b2f29ca4c64a1c 100644 (file)
@@ -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 (file)
index 0000000..5bd6ad6
--- /dev/null
@@ -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 (file)
index 0000000..85c5396
--- /dev/null
@@ -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 (file)
index 0000000..c92f26a
--- /dev/null
@@ -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);
index 8b1f8d938a3d46a60ec448ad1066f9ee004a56dd..975080a71a2de0f85c4857f1d6787f43c14e1121 100644 (file)
@@ -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 (file)
index 0000000..fcaf6be
--- /dev/null
@@ -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 (file)
index 0000000..d4a1f18
--- /dev/null
@@ -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
index 600e326a310c6442dd43de7e70c78e52b9e1f2fe..92b10fa4cf374a8b5658b5aa51cc7cf38db073c9 100644 (file)
@@ -28,6 +28,5 @@ xonotic/util.qc
 ../common/vehicles/all.qc
 ../common/weapons/all.qc
 
-../warpzonelib/mathlib.qc
 
 ../../mod/menu/progs.inc
index 3d8cf1da4419f73b9e2d2315a9a3a9fbf597eb19..b40488ef4b9b100247a672dce46ba1cd21549fb9 100644 (file)
@@ -1,5 +1,3 @@
-#include "../../warpzonelib/mathlib.qh"
-
 #ifndef SLIDER_DECIBELS_H
 #define SLIDER_DECIBELS_H
 #include "slider.qc"
index 1e6759684a593df5fea8690173ee76946d2b4fbe..d065cb59f838db7949b8bf2294458b0df9a8e7fe 100644 (file)
@@ -8,7 +8,6 @@
 #include "../dpdefs/progsdefs.qh"
 #include "../dpdefs/dpextensions.qh"
 
-#include "../warpzonelib/mathlib.qh"
 
 #include "command/common.qh"
 
index 0bf2df320b9475adfddeb9e7ba8c2782b87a5053..29e75b63b2a0121c1a62e336acc3ebda2ae2e6c3 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "../../common/monsters/sv_monsters.qh"
 
-#include "../../warpzonelib/mathlib.qh"
 
 void PutObserverInServer (void);
 
index d272af85796edc6e2c206fb454a4f36cd3ec05ac..d2066b9abde1a14fdee774df9168b86d17347373 100644 (file)
@@ -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"
 
index 6ebf651f246e3c980af4e1b31189b8bc1db99f36..d6859bee3d88f281b6479d879864fe44e2196089 100644 (file)
@@ -8,7 +8,6 @@
 #endif
 
 #include "../../warpzonelib/common.qh"
-#include "../../warpzonelib/mathlib.qh"
 
 void ctf_FakeTimeLimit(entity e, float t)
 {
index 73c37997a5ae713f848943e231379568a88401ed..708683e6755139802e1bd0d7f84587e9e17ee1f7 100644 (file)
@@ -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
 // =======================
index fa4c9ec8fbccd535a81233ea900a9d5e1aeab565..39adb175c86a6a587ab0f8de146facc82d9bcce6 100644 (file)
@@ -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"
 
index c5b1ce2ca9eba23e5d3cca696482667ffcb409be..aaedcba8b37256305b67c702cc028c1b7a0c2a2e 100644 (file)
@@ -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"
index 9dd0fae9b9d3bffd5cce4e5642f5e023486fd087..22afdf4115d0f2b980107de653309720e4a68da5 100644 (file)
@@ -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
 
index b93b1d57770c1748b392f496250180963fcd8030..41354bf8a1f7a14b823ce476cde8c17cfce71746 100644 (file)
@@ -17,7 +17,6 @@
 #include "../csqcmodellib/sv_model.qh"
 
 #include "../warpzonelib/common.qh"
-#include "../warpzonelib/mathlib.qh"
 #include "../warpzonelib/util_server.qh"
 
 .float height;