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 227341a..80b68a6 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 ed4b356..46872d8 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 3da7986..ce6ca92 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 f623e27..32028ce 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 2309426..ed50dda 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 c9c5999..fbd98da 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 0c2be7f..9ac4634 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 6941d86..5066696 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 1e2ef0b..c635e97 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 874fec1..ab6129e 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 b2329cf..8aefc0f 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 0b300d3..2b9dcd0 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 9b4eddd..7720f58 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 700ceb4..c975f98 100644 (file)
@@ -1,7 +1,6 @@
 #include "command.qh"
 #include "rpn.qh"
 
-#include "../../warpzonelib/mathlib.qh"
 
 // ========================================
 //  RPN command code, written by divVerent
index a85f09e..6d332d6 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 56d64f5..b6e2f34 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 7d5ef31..046298a 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 30dab91..7cb3c28 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 1087906..a3bcbcb 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 8b1f8d9..975080a 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 600e326..92b10fa 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 3d8cf1d..b40488e 100644 (file)
@@ -1,5 +1,3 @@
-#include "../../warpzonelib/mathlib.qh"
-
 #ifndef SLIDER_DECIBELS_H
 #define SLIDER_DECIBELS_H
 #include "slider.qc"
index 1e67596..d065cb5 100644 (file)
@@ -8,7 +8,6 @@
 #include "../dpdefs/progsdefs.qh"
 #include "../dpdefs/dpextensions.qh"
 
-#include "../warpzonelib/mathlib.qh"
 
 #include "command/common.qh"
 
index 0bf2df3..29e75b6 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "../../common/monsters/sv_monsters.qh"
 
-#include "../../warpzonelib/mathlib.qh"
 
 void PutObserverInServer (void);
 
index d272af8..d2066b9 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 6ebf651..d6859be 100644 (file)
@@ -8,7 +8,6 @@
 #endif
 
 #include "../../warpzonelib/common.qh"
-#include "../../warpzonelib/mathlib.qh"
 
 void ctf_FakeTimeLimit(entity e, float t)
 {
index 73c3799..708683e 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 fa4c9ec..39adb17 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 c5b1ce2..aaedcba 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 9dd0fae..22afdf4 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 b93b1d5..41354bf 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;