]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Mark [[eraseable]] most of the common functions in the lib directory. Since many...
authorterencehill <piuntn@gmail.com>
Sat, 24 Jun 2017 14:58:29 +0000 (16:58 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 25 Jun 2017 07:53:45 +0000 (09:53 +0200)
28 files changed:
qcsrc/common/util.qh
qcsrc/lib/angle.qc
qcsrc/lib/bits.qh
qcsrc/lib/bool.qh
qcsrc/lib/color.qh
qcsrc/lib/counting.qh
qcsrc/lib/cvar.qh
qcsrc/lib/draw.qh
qcsrc/lib/file.qh
qcsrc/lib/i18n.qh
qcsrc/lib/intrusivelist.qh
qcsrc/lib/json.qc
qcsrc/lib/map.qh
qcsrc/lib/markdown.qh
qcsrc/lib/math.qh
qcsrc/lib/noise.qh
qcsrc/lib/p2mathlib.qc
qcsrc/lib/p2mathlib.qh
qcsrc/lib/random.qc
qcsrc/lib/random.qh
qcsrc/lib/registry.qh
qcsrc/lib/sort.qh
qcsrc/lib/sortlist.qc
qcsrc/lib/static.qh
qcsrc/lib/string.qh
qcsrc/lib/urllib.qc
qcsrc/lib/urllib.qh
qcsrc/lib/vector.qh

index 7ae9ab42a8adc8ab8e1c7c96b3971594ed4a06e4..d8c0d67faab7d4e066da95f61d4e522e74a7521e 100644 (file)
@@ -105,12 +105,6 @@ void get_mi_min_max_texcoords(float mode);
 float almost_equals(float a, float b);
 float almost_in_bounds(float a, float b, float c);
 
-vector rgb_to_hsl(vector rgb);
-vector hsl_to_rgb(vector hsl);
-vector rgb_to_hsv(vector rgb);
-vector hsv_to_rgb(vector hsv);
-string rgb_to_hexcolor(vector rgb);
-
 float boxesoverlap(vector m1, vector m2, vector m3, vector m4);
 float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs);
 
index 302d783239a9894b6e1056b5bb48ca39ba473122..cebf84493e09bb60ffbee5d73ac9f71b7e406608 100644 (file)
@@ -4,6 +4,7 @@
 /*
 * Return a angle within +/- 360.
 */
+[[eraseable]]
 float anglemods(float v)
 {
        v = v - 360 * floor(v / 360);
@@ -19,6 +20,7 @@ float anglemods(float v)
 /*
 * Return the short angle
 */
+[[eraseable]]
 float shortangle_f(float ang1, float ang2)
 {
        if(ang1 > ang2)
@@ -35,6 +37,7 @@ float shortangle_f(float ang1, float ang2)
        return ang1;
 }
 
+[[eraseable]]
 vector shortangle_v(vector ang1, vector ang2)
 {
        vector vtmp;
@@ -46,6 +49,7 @@ vector shortangle_v(vector ang1, vector ang2)
        return vtmp;
 }
 
+[[eraseable]]
 vector shortangle_vxy(vector ang1, vector ang2)
 {
        vector vtmp = '0 0 0';
@@ -60,6 +64,7 @@ vector shortangle_vxy(vector ang1, vector ang2)
 * Return the angle offset between angle ang and angle of the vector from->to
 */
 
+[[eraseable]]
 vector angleofs3(vector from, vector ang, vector to)
 {
        vector v_res;
index 0e07cb43e69d8a1e849f4301b26a359101565087..ec9246c99b4ddd09da26475d93471a5f28d862de 100644 (file)
@@ -10,6 +10,7 @@
        #define BITSET(var, mask, flag) ((var) ^ (-(flag) ^ (var)) & (mask))
 #endif
 
+[[eraseable]]
 int lowestbit(int f)
 {
        f &= ~(f << 1);
@@ -20,6 +21,7 @@ int lowestbit(int f)
        return f;
 }
 
+[[eraseable]]
 int randombit(int bits)
 {
        if (!(bits & (bits - 1)))  // this ONLY holds for powers of two!
@@ -42,6 +44,7 @@ int randombit(int bits)
        return b;
 }
 
+[[eraseable]]
 int randombits(int bits, int k, bool error_return)
 {
        int r = 0;
@@ -75,6 +78,7 @@ enum {
        OP_MINUS
 };
 
+[[eraseable]]
 bool GiveBit(entity e, .int fld, int bit, int op, int val)
 {
        int v0 = (e.(fld) & bit);
@@ -99,6 +103,7 @@ bool GiveBit(entity e, .int fld, int bit, int op, int val)
        return v0 != v1;
 }
 
+[[eraseable]]
 bool GiveValue(entity e, .int fld, int op, int val)
 {
        int v0 = e.(fld);
index dc50c771f164470a2a1e9d81d63c838c549abd2e..8ea9058074e3780e60ae45862f533717369a2560 100644 (file)
@@ -9,6 +9,7 @@
 #define boolean(value) ((value) != 0)
 
 // get true/false value of a string with multiple different inputs
+[[eraseable]]
 float InterpretBoolean(string input)
 {
        switch (strtolower(input))
index d1fdc2c3bcf39d82b3249c9c10f457b395e02a7a..7de70e8314e9dbe47cc6a9472257a415c1230f1d 100644 (file)
@@ -3,6 +3,7 @@
 #include "string.qh"
 
 #define colormapPaletteColor(c, isPants) colormapPaletteColor_(c, isPants, time)
+[[eraseable]]
 vector colormapPaletteColor_(int c, bool isPants, float t)
 {
        switch (c)
@@ -35,6 +36,7 @@ vector colormapPaletteColor_(int c, bool isPants, float t)
        }
 }
 
+[[eraseable]]
 float rgb_mi_ma_to_hue(vector rgb, float mi, float ma)
 {
        if (mi == ma)
@@ -56,6 +58,7 @@ float rgb_mi_ma_to_hue(vector rgb, float mi, float ma)
        }
 }
 
+[[eraseable]]
 vector hue_mi_ma_to_rgb(float hue, float mi, float ma)
 {
        vector rgb;
@@ -110,6 +113,7 @@ vector hue_mi_ma_to_rgb(float hue, float mi, float ma)
        return rgb;
 }
 
+[[eraseable]]
 vector rgb_to_hsv(vector rgb)
 {
        float mi, ma;
@@ -127,11 +131,13 @@ vector rgb_to_hsv(vector rgb)
        return hsv;
 }
 
+[[eraseable]]
 vector hsv_to_rgb(vector hsv)
 {
        return hue_mi_ma_to_rgb(hsv.x, hsv.z * (1 - hsv.y), hsv.z);
 }
 
+[[eraseable]]
 vector rgb_to_hsl(vector rgb)
 {
        float mi, ma;
@@ -151,6 +157,7 @@ vector rgb_to_hsl(vector rgb)
        return hsl;
 }
 
+[[eraseable]]
 vector hsl_to_rgb(vector hsl)
 {
        float mi, ma, maminusmi;
@@ -166,6 +173,7 @@ vector hsl_to_rgb(vector hsl)
        return hue_mi_ma_to_rgb(hsl.x, mi, ma);
 }
 
+[[eraseable]]
 string rgb_to_hexcolor(vector rgb)
 {
        return strcat(
index e430a648d168a41d38a976745880113c6f3258f1..11c06822edfd73767f86dc721219ce552429554f 100644 (file)
@@ -61,6 +61,7 @@
        _("CI_THI^%d seconds"), /* third */ \
        _("CI_MUL^%d seconds")) /* multi */
 
+[[eraseable]]
 string count_ordinal(int interval)
 {
        // This function is designed primarily for the English language, it's impossible
@@ -86,6 +87,7 @@ string count_ordinal(int interval)
        return "";
 }
 
+[[eraseable]]
 string count_fill(float interval, string zeroth, string first, string second, string third, string multi)
 {
        // This function is designed primarily for the English language, it's impossible
@@ -116,6 +118,7 @@ string count_fill(float interval, string zeroth, string first, string second, st
        return "";
 }
 
+[[eraseable]]
 string process_time(float outputtype, float seconds)
 {
        float tmp_hours = 0, tmp_minutes = 0, tmp_seconds = 0;
index adcb7dfee0393a0685a3869405a68f3bddca56b5..d52f25cdd28ac680b97be35b9311e855e553a0e7 100644 (file)
@@ -4,8 +4,10 @@
 #include "progname.qh"
 #include "static.qh"
 
+[[eraseable]]
 void RegisterCvars(void(string name, string def, string desc, bool archive, string file) f) {}
 
+[[eraseable]]
 bool cvar_value_issafe(string s)
 {
        if (strstrofs(s, "\"", 0) >= 0) return false;
@@ -18,6 +20,7 @@ bool cvar_value_issafe(string s)
 }
 
 /** escape the string to make it safe for consoles */
+[[eraseable]]
 string MakeConsoleSafe(string input)
 {
        input = strreplace("\n", "", input);
@@ -27,16 +30,19 @@ string MakeConsoleSafe(string input)
        return input;
 }
 
+[[eraseable]]
 void cvar_describe(string name, string desc)
 {
        localcmd(sprintf("\nset %1$s \"$%1$s\" \"%2$s\"\n", name, MakeConsoleSafe(desc)));
 }
 
+[[eraseable]]
 void cvar_archive(string name)
 {
        localcmd(sprintf("\nseta %1$s \"$%1$s\"\n", name));
 }
 
+[[eraseable]]
 void RegisterCvars_Set(string name, string def, string desc, bool archive, string file)
 {
        cvar_describe(name, desc);
@@ -44,6 +50,7 @@ void RegisterCvars_Set(string name, string def, string desc, bool archive, strin
 }
 
 int RegisterCvars_Save_fd;
+[[eraseable]]
 void RegisterCvars_Save(string name, string def, string desc, bool archive, string file)
 {
        if (!archive) return;
index fbb4a09b5510705f71d43a0eb461ded50ece0d0d..5dbdb67b546a2f7774ac7fd938e8f0a6963955b6 100644 (file)
                }
        }
 
+       [[eraseable]]
        void drawstringright(vector position, string text, vector theScale, vector rgb, float theAlpha, int flag)
        {
                position.x -= 2 / 3 * strlen(text) * theScale.x;
                drawstring_builtin(position, text, theScale, rgb, theAlpha, flag);
        }
 
+       [[eraseable]]
        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);
index 949a748a84e140efa80fa5cbfdd767dbad635190..9e1ba4c9928fcb2df244f304eab190c6acda8d76 100644 (file)
@@ -1,5 +1,6 @@
 #pragma once
 
+[[eraseable]]
 bool fexists(string f)
 {
        int fh = fopen(f, FILE_READ);
index 8ebedb76f65f66110d3fd26ffaa46277e1b24021..6a17fbaca4ab94c5a0938b55f9b0b7360d465a44 100644 (file)
@@ -10,6 +10,7 @@ string prvm_language;
 /**
  * @deprecated prefer _("translated")
  */
+[[eraseable]]
 string language_filename(string s)
 {
        string fn = prvm_language;
@@ -40,6 +41,7 @@ string language_filename(string s)
        }
 #endif
 
+[[eraseable]]
 string CTX(string s)
 {
 #if CTX_CACHE
index 4fa49d3f3bfef7bc41035a9bb56e35cf1db755a4..524c6bec7d4334793b088633f9e43718c9e36247 100644 (file)
@@ -4,8 +4,11 @@
 
 const int IL_MAX = 128;
 
+[[eraseable]]
 void IL_INIT(entity this);
+[[eraseable]]
 void IL_DTOR(entity this);
+[[eraseable]]
 void IL_ENDFRAME();
 
 /**
@@ -37,6 +40,7 @@ ENDCLASS(IntrusiveList)
 #define IL_LAST(this) (this.il_tail)
 #define IL_PEEK(this) (this.il_tail)
 
+[[eraseable]]
 bool IL_CONTAINS(IntrusiveList this, entity it)
 {
        assert(this, return false);
@@ -46,6 +50,7 @@ bool IL_CONTAINS(IntrusiveList this, entity it)
 /**
  * Push to tail
  */
+[[eraseable]]
 entity IL_PUSH(IntrusiveList this, entity it)
 {
        assert(this, return NULL);
@@ -64,6 +69,7 @@ entity IL_PUSH(IntrusiveList this, entity it)
 /**
  * Push to head
  */
+[[eraseable]]
 entity IL_UNSHIFT(IntrusiveList this, entity it)
 {
        assert(this, return NULL);
@@ -82,6 +88,7 @@ entity IL_UNSHIFT(IntrusiveList this, entity it)
 /**
  * Pop from tail
  */
+[[eraseable]]
 entity IL_POP(IntrusiveList this)
 {
        assert(this, return NULL);
@@ -99,6 +106,7 @@ entity IL_POP(IntrusiveList this)
 /**
  * Pop from head
  */
+[[eraseable]]
 entity IL_SHIFT(IntrusiveList this)
 {
        assert(this, return NULL);
@@ -116,6 +124,7 @@ entity IL_SHIFT(IntrusiveList this)
 /**
  * Remove any element, anywhere in the list
  */
+[[eraseable]]
 void IL_REMOVE(IntrusiveList this, entity it)
 {
        assert(this, return);
@@ -180,6 +189,7 @@ int il_links_ptr;
 
 #define IL_LISTS_PER_BIT IL_CEIL(IL_MAX / (3 * 24))
 
+[[eraseable]]
 void IL_INIT(IntrusiveList this)
 {
        .entity nextfld, prevfld;
@@ -208,12 +218,14 @@ void IL_INIT(IntrusiveList this)
        LOG_WARNF("IntrusiveList overflow");
 }
 
+[[eraseable]]
 void IL_DTOR(IntrusiveList this)
 {
        IL_CLEAR(this);
        il_links[this.il_id] = NULL;
 }
 
+[[eraseable]]
 void IL_ENDFRAME()
 {
 #if 0
@@ -233,6 +245,7 @@ void IL_ENDFRAME()
 #endif
 }
 
+[[eraseable]]
 void ONREMOVE(entity this)
 {
        if (this.il_lists) {
index acdf198e835bc83206df152766913225a27bb90c..f15aa8cd62ab96d584dc18198ccf87d04a4a5858 100644 (file)
@@ -32,6 +32,7 @@ string _json_ns;
 // Current keys
 int _json_keys;
 
+[[eraseable]]
 bool _json_parse_object() {
     JSON_BEGIN();
     if (STRING_ITERATOR_GET(_json) != '{') JSON_FAIL("expected '{'");
@@ -40,6 +41,7 @@ bool _json_parse_object() {
     JSON_END();
 }
 
+    [[eraseable]]
     bool _json_parse_members() {
         JSON_BEGIN();
         for (;;) {
@@ -53,6 +55,7 @@ bool _json_parse_object() {
         JSON_END();
     }
 
+        [[eraseable]]
         bool _json_parse_pair() {
             JSON_BEGIN();
             if (!_json_parse_string(false)) JSON_FAIL("expected string");
@@ -66,6 +69,7 @@ bool _json_parse_object() {
             JSON_END();
         }
 
+[[eraseable]]
 bool _json_parse_array() {
     JSON_BEGIN();
     if (STRING_ITERATOR_GET(_json) != '[') JSON_FAIL("expected '['");
@@ -93,6 +97,7 @@ bool _json_parse_array() {
     JSON_END();
 }
 
+[[eraseable]]
 bool _json_parse_value() {
     JSON_BEGIN();
     if (!(_json_parse_string(true)
@@ -105,6 +110,7 @@ bool _json_parse_value() {
     JSON_END();
 }
 
+    [[eraseable]]
     bool _json_parse_true() {
         JSON_BEGIN();
         if (!(STRING_ITERATOR_GET(_json) == 't'
@@ -116,6 +122,7 @@ bool _json_parse_value() {
         JSON_END();
     }
 
+    [[eraseable]]
     bool _json_parse_false() {
         JSON_BEGIN();
         if (!(STRING_ITERATOR_GET(_json) == 'f'
@@ -128,6 +135,7 @@ bool _json_parse_value() {
         JSON_END();
     }
 
+    [[eraseable]]
     bool _json_parse_null() {
         JSON_BEGIN();
         if (!(STRING_ITERATOR_GET(_json) == 'n'
@@ -139,6 +147,7 @@ bool _json_parse_value() {
         JSON_END();
     }
 
+[[eraseable]]
 bool _json_parse_string(bool add) {
     JSON_BEGIN();
     if (STRING_ITERATOR_GET(_json) != '"') JSON_FAIL("expected opening '\"'");
@@ -170,12 +179,14 @@ bool _json_parse_string(bool add) {
     JSON_END();
 }
 
+[[eraseable]]
 bool _json_parse_number() {
     JSON_BEGIN();
     if (!(_json_parse_float() || _json_parse_int())) JSON_FAIL("expected number");
     JSON_END();
 }
 
+    [[eraseable]]
     bool _json_parse_float() {
         JSON_BEGIN();
         string s = "";
@@ -197,6 +208,7 @@ bool _json_parse_number() {
         JSON_END();
     }
 
+    [[eraseable]]
     bool _json_parse_int() {
         JSON_BEGIN();
         string s = "";
@@ -214,6 +226,7 @@ bool _json_parse_number() {
         JSON_END();
     }
 
+[[eraseable]]
 int json_parse(string in, bool() func) {
     string trimmed = "";
     LABEL(trim) {
@@ -259,6 +272,7 @@ int json_parse(string in, bool() func) {
     return _json_buffer;
 }
 
+[[eraseable]]
 string json_get(int buf, string key)
 {
     for (int i = 1, n = buf_getsize(buf); i < n; i += 2) {
@@ -267,11 +281,13 @@ string json_get(int buf, string key)
     return string_null;
 }
 
+[[eraseable]]
 void json_del(int buf)
 {
     buf_del(buf);
 }
 
+[[eraseable]]
 void json_dump(int buf)
 {
     for (int i = 0, n = buf_getsize(buf); i < n; ++i) {
index 55da4d63f0caab22ec1c305a02ad0ca85822e116..bec7842ecd76b593037f7c25d1d7db98bc756873 100644 (file)
@@ -4,6 +4,7 @@
 
 // Databases (hash tables)
 const int DB_BUCKETS = 8192;
+[[eraseable]]
 void db_save(int db, string filename)
 {
        int fh = fopen(filename, FILE_WRITE);
@@ -20,14 +21,17 @@ void db_save(int db, string filename)
 
 USING(HashMap, int);
 
+[[eraseable]]
 int db_create()
 {
        return buf_create();
 }
 #define HM_NEW(this) (this = db_create())
 
+[[eraseable]]
 void db_put(int db, string key, string value);
 
+[[eraseable]]
 int db_load(string filename)
 {
        int db = buf_create();
@@ -61,6 +65,7 @@ int db_load(string filename)
        return db;
 }
 
+[[eraseable]]
 void db_dump(int db, string filename)
 {
        int fh = fopen(filename, FILE_WRITE);
@@ -75,12 +80,14 @@ void db_dump(int db, string filename)
        fclose(fh);
 }
 
+[[eraseable]]
 void db_close(int db)
 {
        buf_del(db);
 }
 #define HM_DELETE(this) db_close(this)
 
+[[eraseable]]
 string db_get(int db, string key)
 {
        int h = crc16(false, key) % DB_BUCKETS;
@@ -90,6 +97,7 @@ string db_get(int db, string key)
 
 #define db_remove(db, key) db_put(db, key, "")
 
+[[eraseable]]
 void db_put(int db, string key, string value)
 {
        int h = crc16(false, key) % DB_BUCKETS;
@@ -97,6 +105,7 @@ void db_put(int db, string key, string value)
 }
 #define HM_sets(this, key, val) db_put(this, key, val)
 
+/*
 void db_test()
 {
        LOG_INFO("LOAD...\n");
@@ -110,3 +119,4 @@ void db_test()
        db_close(db);
        LOG_INFO("CLOSED.\n");
 }
+*/
index 63a4182b457c1c38849467d5d0fbae0dc9b93446..3244877195355bc90b7363881ebb9532443d5b2c 100644 (file)
@@ -5,6 +5,7 @@
  *   - two spaces escape a linebreak (otherwise text wraps)
  *   - two linebreaks become a paragraph (remain unchanged)
  */
+[[eraseable]]
 string markdown(string s)
 {
        string buf = "";
index e5cf888472ef6d1fb3c2a531e606c5490243b466..fbfe1d1d4fae4fa06bf5a66b2620a987597baf54 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "lib/float.qh"
 
+[[eraseable]]
 void mean_accumulate(entity e, .float a, .float c, float mean, float value, float weight)
 {
        if (weight == 0) return;
@@ -10,6 +11,7 @@ void mean_accumulate(entity e, .float a, .float c, float mean, float value, floa
        e.(c) += weight;
 }
 
+[[eraseable]]
 float mean_evaluate(entity e, .float a, .float c, float mean)
 {
        if (e.(c) == 0) return 0;
@@ -32,6 +34,7 @@ Angc used for animations
 */
 
 
+[[eraseable]]
 float angc(float a1, float a2)
 {
        while (a1 > 180)
@@ -50,11 +53,13 @@ float angc(float a1, float a2)
        return a;
 }
 
+[[eraseable]]
 float fsnap(float val, float fsize)
 {
        return rint(val / fsize) * fsize;
 }
 
+[[eraseable]]
 vector vsnap(vector point, float fsize)
 {
        vector vret;
@@ -66,11 +71,13 @@ vector vsnap(vector point, float fsize)
        return vret;
 }
 
+[[eraseable]]
 vector lerpv(float t0, vector v0, float t1, vector v1, float t)
 {
        return v0 + (v1 - v0) * ((t - t0) / (t1 - t0));
 }
 
+[[eraseable]]
 vector bezier_quadratic_getpoint(vector a, vector b, vector c, float t)
 {
        return (c - 2 * b + a) * (t * t)
@@ -78,12 +85,14 @@ vector bezier_quadratic_getpoint(vector a, vector b, vector c, float t)
               + a;
 }
 
+[[eraseable]]
 vector bezier_quadratic_getderivative(vector a, vector b, vector c, float t)
 {
        return (c - 2 * b + a) * (2 * t)
               + (b - a) * 2;
 }
 
+[[eraseable]]
 float cubic_speedfunc(float startspeedfactor, float endspeedfactor, float spd)
 {
        return (((startspeedfactor + endspeedfactor - 2
@@ -92,6 +101,7 @@ float cubic_speedfunc(float startspeedfactor, float endspeedfactor, float spd)
               ) * spd;
 }
 
+[[eraseable]]
 bool cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor)
 {
        if (startspeedfactor < 0 || endspeedfactor < 0) return false;
@@ -156,34 +166,40 @@ bool cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor)
 }
 
 /** continuous function mapping all reals into -1..1 */
+[[eraseable]]
 float float2range11(float f)
 {
        return f / (fabs(f) + 1);
 }
 
 /** continuous function mapping all reals into 0..1 */
+[[eraseable]]
 float float2range01(float f)
 {
        return 0.5 + 0.5 * float2range11(f);
 }
 
+[[eraseable]]
 float median(float a, float b, float c)
 {
        return (a < c) ? bound(a, b, c) : bound(c, b, a);
 }
 
+[[eraseable]]
 float almost_equals(float a, float b)
 {
        float eps = (max(a, -a) + max(b, -b)) * 0.001;
        return a - b < eps && b - a < eps;
 }
 
+[[eraseable]]
 float almost_equals_eps(float a, float b, float times_eps)
 {
        float eps = max(fabs(a), fabs(b)) * FLOAT_EPSILON * times_eps;
        return a - b < eps && b - a < eps;
 }
 
+[[eraseable]]
 float almost_in_bounds(float a, float b, float c)
 {
        float eps = (max(a, -a) + max(c, -c)) * 0.001;
@@ -191,6 +207,7 @@ float almost_in_bounds(float a, float b, float c)
        return b == median(a - eps, b, c + eps);
 }
 
+[[eraseable]]
 float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d)
 {
        if (halflifedist > 0) return (0.5 ** ((bound(mindist, d, maxdist) - mindist) / halflifedist));
@@ -200,6 +217,7 @@ float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float
 
 #define power2of(e) (2 ** e)
 
+[[eraseable]]
 float log2of(float e)
 {
        // NOTE: generated code
@@ -252,6 +270,7 @@ float log2of(float e)
 }
 
 /** ax^2 + bx + c = 0 */
+[[eraseable]]
 vector solve_quadratic(float a, float b, float c)
 {
        vector v;
index 40647b30ebe8ee1ee090d313360cb136bbffb5ed..9dc4d4f32ee041a8a1358b8c77b988d05d172572 100644 (file)
@@ -8,11 +8,13 @@ class(Noise).float noise_paccum2;
 class(Noise).float noise_paccum3;
 class(Noise).float noise_bstate;
 
+[[eraseable]]
 float Noise_Brown(entity e, float dt)
 {
        e.noise_baccum += random() * sqrt(dt);  // same stddev for all dt
        return e.noise_baccum;
 }
+[[eraseable]]
 float Noise_Pink(entity e, float dt)
 {
        float f;
@@ -23,11 +25,13 @@ float Noise_Pink(entity e, float dt)
        if (random() > (0.9613 ** f)) e.noise_paccum3 = 0.43488 * (2 * random() - 1);
        return e.noise_paccum + e.noise_paccum2 + e.noise_paccum3;
 }
+[[eraseable]]
 float Noise_White(entity e, float dt)
 {
        return random() * 2 - 1;
 }
 /** +1 or -1 */
+[[eraseable]]
 float Noise_Burst(entity e, float dt, float p)
 {
        if (random() > (p ** dt)) e.noise_bstate = !e.noise_bstate;
index 0cee3112188a7d3196ac2ade8d71be2438e89163..39b18bb62a349c9d90384bed26abf7d5552572f2 100644 (file)
@@ -17,6 +17,7 @@
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
+[[eraseable]]
 vector vec_bias(vector v, float f)
 {
        vector c;
@@ -25,6 +26,7 @@ vector vec_bias(vector v, float f)
        c.z = v.z + f;
        return c;
 }
+[[eraseable]]
 vector vec_to_min(vector a, vector b)
 {
        vector c;
@@ -34,6 +36,7 @@ vector vec_to_min(vector a, vector b)
        return c;
 }
 
+[[eraseable]]
 vector vec_to_max(vector a, vector b)
 {
        vector c;
@@ -44,6 +47,7 @@ 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
+[[eraseable]]
 vector vec_bounds_in(vector point, vector a, vector b)
 {
        vector d = vec_to_min(a, b);
@@ -54,6 +58,7 @@ vector vec_bounds_in(vector point, vector a, vector b)
        return c;
 }
 
+[[eraseable]]
 vector vec_bounds_out(vector point, vector a, vector b)
 {
        vector d = vec_to_max(a, b);
@@ -64,6 +69,7 @@ vector vec_bounds_out(vector point, vector a, vector b)
        return c;
 }
 
+[[eraseable]]
 float angle_snap_f(float f, float increment)
 {
        for (int j = 0; j <= 360; )
@@ -75,6 +81,7 @@ float angle_snap_f(float f, float increment)
        return 0;
 }
 
+[[eraseable]]
 vector angle_snap_vec(vector v, float increment)
 {
        vector c;
@@ -84,6 +91,7 @@ vector angle_snap_vec(vector v, float increment)
        return c;
 }
 
+[[eraseable]]
 vector aim_vec(vector org, vector targ)
 {
        vector v;
index dc2944aa910e3e4eb399a37dbc212cd2e520f69e..1f4deb1d877461d2b5d58234c3c82ed7720a3641 100644 (file)
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
+[[eraseable]]
 vector vec_bias(vector v, float f);
 
 
+[[eraseable]]
 vector vec_to_min(vector a, vector b);
+[[eraseable]]
 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
+[[eraseable]]
 vector vec_bounds_in(vector point, vector a, vector b);
+[[eraseable]]
 vector vec_bounds_out(vector point, vector a, vector b);
 
+[[eraseable]]
 float angle_snap_f(float f, float increment);
+[[eraseable]]
 vector angle_snap_vec(vector v,  float increment);
 
+[[eraseable]]
 vector aim_vec(vector org, vector targ);
index 627fec11a92e1293bec76db098230b0a5fafc7f0..d39cfdcadcfef74b2b74e9513de62690f89ab659 100644 (file)
@@ -1,5 +1,6 @@
 #include "random.qh"
 
+[[eraseable]]
 void RandomSelection_Init()
 {
        RandomSelection_totalweight = 0;
@@ -9,6 +10,7 @@ void RandomSelection_Init()
        RandomSelection_best_priority = -1;
 }
 
+[[eraseable]]
 void RandomSelection_Add(entity e, float f, string s, vector v, float weight, float priority)
 {
        if (priority > RandomSelection_best_priority)
@@ -36,6 +38,7 @@ void RandomSelection_Add(entity e, float f, string s, vector v, float weight, fl
 float DistributeEvenly_amount;
 float DistributeEvenly_totalweight;
 
+[[eraseable]]
 void DistributeEvenly_Init(float amount, float totalweight)
 {
        if (DistributeEvenly_amount)
@@ -47,6 +50,7 @@ void DistributeEvenly_Init(float amount, float totalweight)
        DistributeEvenly_totalweight = totalweight;
 }
 
+[[eraseable]]
 float DistributeEvenly_Get(float weight)
 {
        float f;
@@ -57,6 +61,7 @@ float DistributeEvenly_Get(float weight)
        return f;
 }
 
+[[eraseable]]
 float DistributeEvenly_GetRandomized(float weight)
 {
        float f;
@@ -70,6 +75,7 @@ float DistributeEvenly_GetRandomized(float weight)
 // from the GNU Scientific Library
 float gsl_ran_gaussian_lastvalue;
 float gsl_ran_gaussian_lastvalue_set;
+[[eraseable]]
 float gsl_ran_gaussian(float sigma)
 {
        if (gsl_ran_gaussian_lastvalue_set)
index b2fc53f0cac4edaaa3ef964c25b7b6093ac2ae2c..668e49784b439c2ba79275300b5395a69f7f091d 100644 (file)
@@ -7,7 +7,9 @@ float RandomSelection_chosen_float;
 string RandomSelection_chosen_string;
 vector RandomSelection_chosen_vec;
 
+[[eraseable]]
 void RandomSelection_Init();
+[[eraseable]]
 void RandomSelection_Add(entity e, float f, string s, vector v, float weight, float priority);
 #define RandomSelection_AddEnt(e, weight, priority) RandomSelection_Add(e, 0, string_null, '0 0 0', weight, priority)
 #define RandomSelection_AddFloat(f, weight, priority) RandomSelection_Add(NULL, f, string_null, '0 0 0', weight, priority)
index 9d171e031ab4391090341737d675574a0154aca2..e9712970eb8747fa7a8925d0f4b7e8cdc6d5606a 100644 (file)
@@ -140,7 +140,9 @@ REGISTRY(Registries, BITS(8))
 
 #define REGISTRY_HASH(id) Registry_hash_##id
 
+[[eraseable]]
 [[accumulate]] void Registry_check(string r, string server) { }
+[[eraseable]]
 [[accumulate]] void Registry_send_all() { }
 
 #ifdef SVQC
index 2790cdf2dc3cc760dbe814bc8c8edb3be2322695..068707d0b649d9e709f6bd00711ba816da8eeea6 100644 (file)
@@ -5,6 +5,7 @@ USING(swapfunc_t, void (int i1, int i2, entity pass));
 /** <0 for <, ==0 for ==, >0 for > (like strcmp) */
 USING(comparefunc_t, int (int i1, int i2, entity pass));
 
+[[eraseable]]
 void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass)
 {
        #define heapify(_count) \
@@ -39,6 +40,7 @@ void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass)
        }
 }
 
+[[eraseable]]
 void shuffle(float n, swapfunc_t swap, entity pass)
 {
        for (int i = 1; i < n; ++i)
index 6748b60cd77954e84064e072a6d6cef715be0804..2cc90268cd16e704a15124a87359ba8ab4a448e7 100644 (file)
@@ -1,5 +1,6 @@
 #include "sortlist.qh"
 
+[[eraseable]]
 entity Sort_Spawn()
 {
        entity sort = new_pure(sortlist);
index 6b5febe6fbfcab9909de383b4d7ccd86940474d6..46b3a7fa9fb3daa5b77ddcab966ec4c38ce01982 100644 (file)
@@ -16,6 +16,7 @@ float(int tmr) _gettime = #67;
 float(int tmr) _gettime = #519;
 #endif
 
+[[eraseable]]
 void profile(string s)
 {
        static float g_starttime;
index 9f0c5ca13bcaea342e6e27537931dc7b076aeff4..33aacebabdbd8d8eee975006f6c9c1bf4dab1c5d 100644 (file)
@@ -27,6 +27,7 @@
        }
 #endif
 
+[[eraseable]]
 string seconds_tostring(float sec)
 {
        float minutes = floor(sec / 60);
@@ -34,6 +35,7 @@ string seconds_tostring(float sec)
        return sprintf("%d:%02d", minutes, sec);
 }
 
+[[eraseable]]
 string format_time(float seconds)
 {
        seconds = floor(seconds + 0.5);
@@ -47,6 +49,7 @@ string format_time(float seconds)
        else return sprintf(_("%02d:%02d:%02d"), hours, minutes, seconds);
 }
 
+[[eraseable]]
 string mmsss(float tenths)
 {
        tenths = floor(tenths + 0.5);
@@ -56,6 +59,7 @@ string mmsss(float tenths)
        return strcat(ftos(minutes), ":", substring(s, 1, 2), ".", substring(s, 3, 1));
 }
 
+[[eraseable]]
 string mmssss(float hundredths)
 {
        hundredths = floor(hundredths + 0.5);
@@ -67,6 +71,7 @@ string mmssss(float hundredths)
 
 int ColorTranslateMode;
 
+[[eraseable]]
 string ColorTranslateRGB(string s)
 {
        return (ColorTranslateMode & 1) ? strdecolorize(s) : s;
@@ -111,6 +116,7 @@ string CCR(string input)
 
 #define startsWith(haystack, needle) (strstrofs(haystack, needle, 0) == 0)
 
+[[eraseable]]
 bool startsWithNocase(string haystack, string needle)
 {
        return strcasecmp(substring(haystack, 0, strlen(needle)), needle) == 0;
@@ -120,6 +126,7 @@ noref string _endsWith_suffix;
 #define endsWith(this, suffix) (_endsWith_suffix = suffix, substring(this, -strlen(_endsWith_suffix), -1) == _endsWith_suffix)
 
 /** unzone the string, and return it as tempstring. Safe to be called on string_null */
+[[eraseable]]
 string fstrunzone(string s)
 {
        if (!s) return s;
@@ -129,6 +136,7 @@ string fstrunzone(string s)
 }
 
 /** returns first word */
+[[eraseable]]
 string car(string s)
 {
        int o = strstrofs(s, " ", 0);
@@ -137,6 +145,7 @@ string car(string s)
 }
 
 /** returns all but first word */
+[[eraseable]]
 string cdr(string s)
 {
        int o = strstrofs(s, " ", 0);
@@ -144,6 +153,7 @@ string cdr(string s)
        return substring(s, o + 1, strlen(s) - (o + 1));
 }
 
+[[eraseable]]
 string cons(string a, string b)
 {
        if (a == "") return b;
@@ -151,11 +161,13 @@ string cons(string a, string b)
        return strcat(a, " ", b);
 }
 
+[[eraseable]]
 string substring_range(string s, float b, float e)
 {
        return substring(s, b, e - b);
 }
 
+[[eraseable]]
 string swapwords(string str, float i, float j)
 {
        float n;
@@ -177,10 +189,13 @@ string swapwords(string str, float i, float j)
 }
 
 string _shufflewords_str;
+[[eraseable]]
 void _shufflewords_swapfunc(float i, float j, entity pass)
 {
        _shufflewords_str = swapwords(_shufflewords_str, i, j);
 }
+
+[[eraseable]]
 string shufflewords(string str)
 {
        _shufflewords_str = str;
@@ -191,6 +206,7 @@ string shufflewords(string str)
        return str;
 }
 
+[[eraseable]]
 string unescape(string in)
 {
        in = strzone(in);  // but it doesn't seem to be necessary in my tests at least
@@ -215,6 +231,7 @@ string unescape(string in)
        return str;
 }
 
+[[eraseable]]
 string strwords(string s, int w)
 {
        int endpos = 0;
@@ -226,6 +243,7 @@ string strwords(string s, int w)
 
 #define strhasword(s, w) (strstrofs(strcat(" ", s, " "), strcat(" ", w, " "), 0) >= 0)
 
+[[eraseable]]
 int u8_strsize(string s)
 {
        int l = 0;
@@ -238,6 +256,7 @@ int u8_strsize(string s)
        return l;
 }
 
+[[eraseable]]
 bool isInvisibleString(string s)
 {
        s = strdecolorize(s);
@@ -265,6 +284,7 @@ bool isInvisibleString(string s)
 
 // Multiline text file buffers
 
+[[eraseable]]
 int buf_load(string pFilename)
 {
        int buf = buf_create();
@@ -282,6 +302,7 @@ int buf_load(string pFilename)
        return buf;
 }
 
+[[eraseable]]
 void buf_save(float buf, string pFilename)
 {
        int fh = fopen(pFilename, FILE_WRITE);
@@ -295,6 +316,7 @@ void buf_save(float buf, string pFilename)
 /**
  * converts a number to a string with the indicated number of decimals
  */
+[[eraseable]]
 string ftos_decimals(float number, int decimals)
 {
        // inhibit stupid negative zero
@@ -305,6 +327,7 @@ string ftos_decimals(float number, int decimals)
 /**
  * converts a number to a string with the minimum number of decimals
  */
+[[eraseable]]
 string ftos_mindecimals(float number)
 {
        // inhibit stupid negative zero
@@ -312,6 +335,7 @@ string ftos_mindecimals(float number)
        return sprintf("%.7g", number);
 }
 
+[[eraseable]]
 int vercmp_recursive(string v1, string v2)
 {
        int dot1 = strstrofs(v1, ".", 0);
@@ -330,6 +354,7 @@ int vercmp_recursive(string v1, string v2)
        else return (dot2 == -1) ? 1 : vercmp_recursive(substring(v1, dot1 + 1, 999), substring(v2, dot2 + 1, 999));
 }
 
+[[eraseable]]
 int vercmp(string v1, string v2)
 {
        if (strcasecmp(v1, v2) == 0) return 0;  // early out check
index d1d5c65ed2a3d4bcf34e1a35789a709e44521c07..9f5d3e26fe5ae88a3638b12edf23784835b20d5b 100644 (file)
@@ -24,6 +24,7 @@ const float URL_FH_STDOUT = -2;
 entity url_fromid[NUM_URL_ID];
 int autocvar__urllib_nextslot;
 
+[[eraseable]]
 float url_URI_Get_Callback(int id, float status, string data)
 {
        if (id < MIN_URL_ID) return 0;
@@ -82,6 +83,7 @@ float url_URI_Get_Callback(int id, float status, string data)
        }
 }
 
+[[eraseable]]
 void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass)
 {
        entity e;
@@ -201,6 +203,7 @@ void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass)
 }
 
 // close a file
+[[eraseable]]
 void url_fclose(entity e)
 {
        int i;
@@ -280,6 +283,7 @@ void url_fclose(entity e)
 }
 
 // with \n (blame FRIK_FILE)
+[[eraseable]]
 string url_fgets(entity e)
 {
        if (e.url_fh == URL_FH_CURL)
@@ -304,6 +308,7 @@ string url_fgets(entity e)
 }
 
 // without \n (blame FRIK_FILE)
+[[eraseable]]
 void url_fputs(entity e, string s)
 {
        if (e.url_fh == URL_FH_CURL)
@@ -326,6 +331,7 @@ void url_fputs(entity e, string s)
 }
 
 // multi URL object, tries URLs separated by space in sequence
+[[eraseable]]
 void url_multi_ready(entity fh, entity me, float status)
 {
        float n;
@@ -353,6 +359,8 @@ void url_multi_ready(entity fh, entity me, float status)
        }
        me.url_ready(fh, me.url_ready_pass, status);
 }
+
+[[eraseable]]
 void url_multi_fopen(string url, int mode, url_ready_func rdy, entity pass)
 {
        float n;
index 00523a84f137adb1e9d1a393d7da07008070bfa7..acb4077d6a49422c9f275d0ea37910d4e05d3c9c 100644 (file)
@@ -17,14 +17,20 @@ const float URL_READY_CANREAD  =  2;
 // errors: -1, or negative HTTP status code
 USING(url_ready_func, void (entity handle, entity pass, float status));
 
+[[eraseable]]
 void url_single_fopen(string url, float mode, url_ready_func rdy, entity pass);
+[[eraseable]]
 void url_fclose(entity e);
+[[eraseable]]
 string url_fgets(entity e);
+[[eraseable]]
 void url_fputs(entity e, string s);
 
 // returns true if handled
+[[eraseable]]
 float url_URI_Get_Callback(int id, float status, string data);
 #define MIN_URL_ID URI_GET_URLLIB
 #define NUM_URL_ID (URI_GET_URLLIB_END - URI_GET_URLLIB + 1)
 
+[[eraseable]]
 void url_multi_fopen(string url, float mode, url_ready_func rdy, entity pass);
index 0a887cfebb03c4544df88a8d0316bd6f8aa4ab8d..5d2b795f4515f6915141cc7ff0c5758ebda26dd9 100644 (file)
@@ -25,6 +25,7 @@ noref vector _dotproduct_a, _dotproduct_b;
 #if 1
 #define cross(a, b) ((a) >< (b))
 #else
+[[eraseable]]
 vector cross(vector a, vector b)
 {
        return
@@ -45,6 +46,7 @@ const vector eX = '1 0 0';
 const vector eY = '0 1 0';
 const vector eZ = '0 0 1';
 
+[[eraseable]]
 vector randompos(vector m1, vector m2)
 {
        vector v;
@@ -55,16 +57,19 @@ vector randompos(vector m1, vector m2)
        return v;
 }
 
+[[eraseable]]
 float vlen_maxnorm2d(vector v)
 {
        return max(v.x, v.y, -v.x, -v.y);
 }
 
+[[eraseable]]
 float vlen_minnorm2d(vector v)
 {
        return min(max(v.x, -v.x), max(v.y, -v.y));
 }
 
+[[eraseable]]
 float dist_point_line(vector p, vector l0, vector ldir)
 {
        ldir = normalize(ldir);
@@ -77,9 +82,11 @@ float dist_point_line(vector p, vector l0, vector ldir)
 }
 
 /** requires that m2>m1 in all coordinates, and that m4>m3 */
+[[eraseable]]
 float boxesoverlap(vector m1, vector m2, vector m3, vector m4) { return m2_x >= m3_x && m1_x <= m4_x && m2_y >= m3_y && m1_y <= m4_y && m2_z >= m3_z && m1_z <= m4_z; }
 
 /** requires the same as boxesoverlap, but is a stronger condition */
+[[eraseable]]
 float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) { return smins.x >= bmins.x && smaxs.x <= bmaxs.x && smins.y >= bmins.y && smaxs.y <= bmaxs.y && smins.z >= bmins.z && smaxs.z <= bmaxs.z; }
 
 #define PITCH(v) ((v).x)
@@ -101,6 +108,7 @@ noref vector _vec2;
 noref vector _vec3;
 #define vec3(_x, _y, _z) (_vec3.x = (_x), _vec3.y = (_y), _vec3.z = (_z), _vec3)
 
+[[eraseable]]
 vector Rotate(vector v, float a)
 {
        float a_sin = sin(a), a_cos = cos(a);
@@ -118,6 +126,7 @@ noref vector _yinvert;
  * @param norm the normalized normal
  * @returns dir reflected by norm
  */
+[[eraseable]]
 vector reflect(vector dir, vector norm)
 {
        return dir - 2 * (dir * norm) * norm;
@@ -126,11 +135,13 @@ vector reflect(vector dir, vector norm)
 /**
  * clip vel along the plane defined by norm (assuming 0 distance away), bounciness determined by bounce 0..1
  */
+[[eraseable]]
 vector vec_reflect(vector vel, vector norm, float bounce)
 {
        return vel - (1 + bounce) * (vel * norm) * norm;
 }
 
+[[eraseable]]
 vector vec_epsilon(vector this, float eps)
 {
        if (this.x > -eps && this.x < eps) this.x = 0;
@@ -143,6 +154,7 @@ vector vec_epsilon(vector this, float eps)
        (out = vec_epsilon(vec_reflect(in, normal, (overbounce) - 1), 0.1))
 
 #ifdef GAMEQC
+       [[eraseable]]
        vector get_corner_position(entity box, int corner)
        {
                switch (corner)
@@ -159,6 +171,7 @@ vector vec_epsilon(vector this, float eps)
                }
        }
 
+       [[eraseable]]
        vector NearestPointOnBox(entity box, vector org)
        {
                vector m1 = box.mins + box.origin;