From 44cad443f15ba5e3c256a4964a117a9fa43985b9 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 16 Jul 2017 15:43:20 +1000 Subject: [PATCH] Put [[eraseable]] behind a conditional macro --- qcsrc/lib/_all.inc | 6 +++++ qcsrc/lib/angle.qc | 10 ++++---- qcsrc/lib/bits.qh | 10 ++++---- qcsrc/lib/bool.qh | 2 +- qcsrc/lib/color.qh | 16 ++++++------- qcsrc/lib/compiler.qh | 6 +++++ qcsrc/lib/counting.qh | 6 ++--- qcsrc/lib/cvar.qh | 14 +++++------ qcsrc/lib/draw.qh | 4 ++-- qcsrc/lib/file.qh | 2 +- qcsrc/lib/i18n.qh | 4 ++-- qcsrc/lib/intrusivelist.qh | 26 ++++++++++----------- qcsrc/lib/json.qc | 32 ++++++++++++------------- qcsrc/lib/map.qh | 16 ++++++------- qcsrc/lib/markdown.qh | 2 +- qcsrc/lib/math.qh | 38 +++++++++++++++--------------- qcsrc/lib/noise.qh | 8 +++---- qcsrc/lib/p2mathlib.qc | 16 ++++++------- qcsrc/lib/p2mathlib.qh | 16 ++++++------- qcsrc/lib/random.qc | 12 +++++----- qcsrc/lib/random.qh | 4 ++-- qcsrc/lib/registry.qh | 4 ++-- qcsrc/lib/sort.qh | 4 ++-- qcsrc/lib/sortlist.qc | 2 +- qcsrc/lib/static.qh | 2 +- qcsrc/lib/string.qh | 48 +++++++++++++++++++------------------- qcsrc/lib/urllib.qc | 14 +++++------ qcsrc/lib/urllib.qh | 12 +++++----- qcsrc/lib/vector.qh | 26 ++++++++++----------- 29 files changed, 187 insertions(+), 175 deletions(-) diff --git a/qcsrc/lib/_all.inc b/qcsrc/lib/_all.inc index b8d78cd04..4da78f144 100644 --- a/qcsrc/lib/_all.inc +++ b/qcsrc/lib/_all.inc @@ -24,6 +24,12 @@ #define bool float #endif +#ifndef QCC_SUPPORT_ERASEABLE + #define ERASEABLE +#else + #define ERASEABLE [[eraseable]] +#endif + #include #if defined(CSQC) diff --git a/qcsrc/lib/angle.qc b/qcsrc/lib/angle.qc index cebf84493..e2e7ae628 100644 --- a/qcsrc/lib/angle.qc +++ b/qcsrc/lib/angle.qc @@ -4,7 +4,7 @@ /* * Return a angle within +/- 360. */ -[[eraseable]] +ERASEABLE float anglemods(float v) { v = v - 360 * floor(v / 360); @@ -20,7 +20,7 @@ float anglemods(float v) /* * Return the short angle */ -[[eraseable]] +ERASEABLE float shortangle_f(float ang1, float ang2) { if(ang1 > ang2) @@ -37,7 +37,7 @@ float shortangle_f(float ang1, float ang2) return ang1; } -[[eraseable]] +ERASEABLE vector shortangle_v(vector ang1, vector ang2) { vector vtmp; @@ -49,7 +49,7 @@ vector shortangle_v(vector ang1, vector ang2) return vtmp; } -[[eraseable]] +ERASEABLE vector shortangle_vxy(vector ang1, vector ang2) { vector vtmp = '0 0 0'; @@ -64,7 +64,7 @@ vector shortangle_vxy(vector ang1, vector ang2) * Return the angle offset between angle ang and angle of the vector from->to */ -[[eraseable]] +ERASEABLE vector angleofs3(vector from, vector ang, vector to) { vector v_res; diff --git a/qcsrc/lib/bits.qh b/qcsrc/lib/bits.qh index ec9246c99..c158ea032 100644 --- a/qcsrc/lib/bits.qh +++ b/qcsrc/lib/bits.qh @@ -10,7 +10,7 @@ #define BITSET(var, mask, flag) ((var) ^ (-(flag) ^ (var)) & (mask)) #endif -[[eraseable]] +ERASEABLE int lowestbit(int f) { f &= ~(f << 1); @@ -21,7 +21,7 @@ int lowestbit(int f) return f; } -[[eraseable]] +ERASEABLE int randombit(int bits) { if (!(bits & (bits - 1))) // this ONLY holds for powers of two! @@ -44,7 +44,7 @@ int randombit(int bits) return b; } -[[eraseable]] +ERASEABLE int randombits(int bits, int k, bool error_return) { int r = 0; @@ -78,7 +78,7 @@ enum { OP_MINUS }; -[[eraseable]] +ERASEABLE bool GiveBit(entity e, .int fld, int bit, int op, int val) { int v0 = (e.(fld) & bit); @@ -103,7 +103,7 @@ bool GiveBit(entity e, .int fld, int bit, int op, int val) return v0 != v1; } -[[eraseable]] +ERASEABLE bool GiveValue(entity e, .int fld, int op, int val) { int v0 = e.(fld); diff --git a/qcsrc/lib/bool.qh b/qcsrc/lib/bool.qh index 8ea905807..c78f717d9 100644 --- a/qcsrc/lib/bool.qh +++ b/qcsrc/lib/bool.qh @@ -9,7 +9,7 @@ #define boolean(value) ((value) != 0) // get true/false value of a string with multiple different inputs -[[eraseable]] +ERASEABLE float InterpretBoolean(string input) { switch (strtolower(input)) diff --git a/qcsrc/lib/color.qh b/qcsrc/lib/color.qh index 7de70e831..5f9297f2d 100644 --- a/qcsrc/lib/color.qh +++ b/qcsrc/lib/color.qh @@ -3,7 +3,7 @@ #include "string.qh" #define colormapPaletteColor(c, isPants) colormapPaletteColor_(c, isPants, time) -[[eraseable]] +ERASEABLE vector colormapPaletteColor_(int c, bool isPants, float t) { switch (c) @@ -36,7 +36,7 @@ vector colormapPaletteColor_(int c, bool isPants, float t) } } -[[eraseable]] +ERASEABLE float rgb_mi_ma_to_hue(vector rgb, float mi, float ma) { if (mi == ma) @@ -58,7 +58,7 @@ float rgb_mi_ma_to_hue(vector rgb, float mi, float ma) } } -[[eraseable]] +ERASEABLE vector hue_mi_ma_to_rgb(float hue, float mi, float ma) { vector rgb; @@ -113,7 +113,7 @@ vector hue_mi_ma_to_rgb(float hue, float mi, float ma) return rgb; } -[[eraseable]] +ERASEABLE vector rgb_to_hsv(vector rgb) { float mi, ma; @@ -131,13 +131,13 @@ vector rgb_to_hsv(vector rgb) return hsv; } -[[eraseable]] +ERASEABLE vector hsv_to_rgb(vector hsv) { return hue_mi_ma_to_rgb(hsv.x, hsv.z * (1 - hsv.y), hsv.z); } -[[eraseable]] +ERASEABLE vector rgb_to_hsl(vector rgb) { float mi, ma; @@ -157,7 +157,7 @@ vector rgb_to_hsl(vector rgb) return hsl; } -[[eraseable]] +ERASEABLE vector hsl_to_rgb(vector hsl) { float mi, ma, maminusmi; @@ -173,7 +173,7 @@ vector hsl_to_rgb(vector hsl) return hue_mi_ma_to_rgb(hsl.x, mi, ma); } -[[eraseable]] +ERASEABLE string rgb_to_hexcolor(vector rgb) { return strcat( diff --git a/qcsrc/lib/compiler.qh b/qcsrc/lib/compiler.qh index 7cd34bc84..d1bdc4fe5 100644 --- a/qcsrc/lib/compiler.qh +++ b/qcsrc/lib/compiler.qh @@ -12,6 +12,12 @@ #endif #endif +#ifndef QCC_SUPPORT_ERASEABLE + #ifdef GMQCC + #define QCC_SUPPORT_ERASEABLE + #endif +#endif + #ifdef GMQCC #define LABEL(id) :id #else diff --git a/qcsrc/lib/counting.qh b/qcsrc/lib/counting.qh index 12ec4a9b6..b38ba9d05 100644 --- a/qcsrc/lib/counting.qh +++ b/qcsrc/lib/counting.qh @@ -61,7 +61,7 @@ _("CI_THI^%d seconds"), /* third */ \ _("CI_MUL^%d seconds")) /* multi */ -[[eraseable]] +ERASEABLE string count_ordinal(int interval) { // This function is designed primarily for the English language, it's impossible @@ -87,7 +87,7 @@ string count_ordinal(int interval) return ""; } -[[eraseable]] +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 @@ -118,7 +118,7 @@ string count_fill(float interval, string zeroth, string first, string second, st return ""; } -[[eraseable]] +ERASEABLE string process_time(float outputtype, float seconds) { float tmp_hours = 0, tmp_minutes = 0, tmp_seconds = 0; diff --git a/qcsrc/lib/cvar.qh b/qcsrc/lib/cvar.qh index f322753c0..a17f2bad7 100644 --- a/qcsrc/lib/cvar.qh +++ b/qcsrc/lib/cvar.qh @@ -4,10 +4,10 @@ #include "progname.qh" #include "static.qh" -[[eraseable]] +ERASEABLE void RegisterCvars(void(string name, string def, string desc, bool archive, string file) f) {} -[[eraseable]] +ERASEABLE bool cvar_value_issafe(string s) { if (strstrofs(s, "\"", 0) >= 0) return false; @@ -20,7 +20,7 @@ bool cvar_value_issafe(string s) } /** escape the string to make it safe for consoles */ -[[eraseable]] +ERASEABLE string MakeConsoleSafe(string input) { input = strreplace("\n", "", input); @@ -30,19 +30,19 @@ string MakeConsoleSafe(string input) return input; } -[[eraseable]] +ERASEABLE void cvar_describe(string name, string desc) { localcmd(sprintf("\nset %1$s \"$%1$s\" \"%2$s\"\n", name, MakeConsoleSafe(desc))); } -[[eraseable]] +ERASEABLE void cvar_archive(string name) { localcmd(sprintf("\nseta %1$s \"$%1$s\"\n", name)); } -[[eraseable]] +ERASEABLE void RegisterCvars_Set(string name, string def, string desc, bool archive, string file) { cvar_describe(name, desc); @@ -50,7 +50,7 @@ void RegisterCvars_Set(string name, string def, string desc, bool archive, strin } int RegisterCvars_Save_fd; -[[eraseable]] +ERASEABLE void RegisterCvars_Save(string name, string def, string desc, bool archive, string file) { if (!archive) return; diff --git a/qcsrc/lib/draw.qh b/qcsrc/lib/draw.qh index 5dbdb67b5..2bf480a87 100644 --- a/qcsrc/lib/draw.qh +++ b/qcsrc/lib/draw.qh @@ -117,14 +117,14 @@ } } - [[eraseable]] + 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]] + 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); diff --git a/qcsrc/lib/file.qh b/qcsrc/lib/file.qh index 9e1ba4c99..5bc24f627 100644 --- a/qcsrc/lib/file.qh +++ b/qcsrc/lib/file.qh @@ -1,6 +1,6 @@ #pragma once -[[eraseable]] +ERASEABLE bool fexists(string f) { int fh = fopen(f, FILE_READ); diff --git a/qcsrc/lib/i18n.qh b/qcsrc/lib/i18n.qh index 6a17fbaca..3dfac6224 100644 --- a/qcsrc/lib/i18n.qh +++ b/qcsrc/lib/i18n.qh @@ -10,7 +10,7 @@ string prvm_language; /** * @deprecated prefer _("translated") */ -[[eraseable]] +ERASEABLE string language_filename(string s) { string fn = prvm_language; @@ -41,7 +41,7 @@ string language_filename(string s) } #endif -[[eraseable]] +ERASEABLE string CTX(string s) { #if CTX_CACHE diff --git a/qcsrc/lib/intrusivelist.qh b/qcsrc/lib/intrusivelist.qh index 524c6bec7..fc0e080ea 100644 --- a/qcsrc/lib/intrusivelist.qh +++ b/qcsrc/lib/intrusivelist.qh @@ -4,11 +4,11 @@ const int IL_MAX = 128; -[[eraseable]] +ERASEABLE void IL_INIT(entity this); -[[eraseable]] +ERASEABLE void IL_DTOR(entity this); -[[eraseable]] +ERASEABLE void IL_ENDFRAME(); /** @@ -40,7 +40,7 @@ ENDCLASS(IntrusiveList) #define IL_LAST(this) (this.il_tail) #define IL_PEEK(this) (this.il_tail) -[[eraseable]] +ERASEABLE bool IL_CONTAINS(IntrusiveList this, entity it) { assert(this, return false); @@ -50,7 +50,7 @@ bool IL_CONTAINS(IntrusiveList this, entity it) /** * Push to tail */ -[[eraseable]] +ERASEABLE entity IL_PUSH(IntrusiveList this, entity it) { assert(this, return NULL); @@ -69,7 +69,7 @@ entity IL_PUSH(IntrusiveList this, entity it) /** * Push to head */ -[[eraseable]] +ERASEABLE entity IL_UNSHIFT(IntrusiveList this, entity it) { assert(this, return NULL); @@ -88,7 +88,7 @@ entity IL_UNSHIFT(IntrusiveList this, entity it) /** * Pop from tail */ -[[eraseable]] +ERASEABLE entity IL_POP(IntrusiveList this) { assert(this, return NULL); @@ -106,7 +106,7 @@ entity IL_POP(IntrusiveList this) /** * Pop from head */ -[[eraseable]] +ERASEABLE entity IL_SHIFT(IntrusiveList this) { assert(this, return NULL); @@ -124,7 +124,7 @@ entity IL_SHIFT(IntrusiveList this) /** * Remove any element, anywhere in the list */ -[[eraseable]] +ERASEABLE void IL_REMOVE(IntrusiveList this, entity it) { assert(this, return); @@ -189,7 +189,7 @@ int il_links_ptr; #define IL_LISTS_PER_BIT IL_CEIL(IL_MAX / (3 * 24)) -[[eraseable]] +ERASEABLE void IL_INIT(IntrusiveList this) { .entity nextfld, prevfld; @@ -218,14 +218,14 @@ void IL_INIT(IntrusiveList this) LOG_WARNF("IntrusiveList overflow"); } -[[eraseable]] +ERASEABLE void IL_DTOR(IntrusiveList this) { IL_CLEAR(this); il_links[this.il_id] = NULL; } -[[eraseable]] +ERASEABLE void IL_ENDFRAME() { #if 0 @@ -245,7 +245,7 @@ void IL_ENDFRAME() #endif } -[[eraseable]] +ERASEABLE void ONREMOVE(entity this) { if (this.il_lists) { diff --git a/qcsrc/lib/json.qc b/qcsrc/lib/json.qc index f15aa8cd6..b477fe15e 100644 --- a/qcsrc/lib/json.qc +++ b/qcsrc/lib/json.qc @@ -32,7 +32,7 @@ string _json_ns; // Current keys int _json_keys; -[[eraseable]] +ERASEABLE bool _json_parse_object() { JSON_BEGIN(); if (STRING_ITERATOR_GET(_json) != '{') JSON_FAIL("expected '{'"); @@ -41,7 +41,7 @@ bool _json_parse_object() { JSON_END(); } - [[eraseable]] + ERASEABLE bool _json_parse_members() { JSON_BEGIN(); for (;;) { @@ -55,7 +55,7 @@ bool _json_parse_object() { JSON_END(); } - [[eraseable]] + ERASEABLE bool _json_parse_pair() { JSON_BEGIN(); if (!_json_parse_string(false)) JSON_FAIL("expected string"); @@ -69,7 +69,7 @@ bool _json_parse_object() { JSON_END(); } -[[eraseable]] +ERASEABLE bool _json_parse_array() { JSON_BEGIN(); if (STRING_ITERATOR_GET(_json) != '[') JSON_FAIL("expected '['"); @@ -97,7 +97,7 @@ bool _json_parse_array() { JSON_END(); } -[[eraseable]] +ERASEABLE bool _json_parse_value() { JSON_BEGIN(); if (!(_json_parse_string(true) @@ -110,7 +110,7 @@ bool _json_parse_value() { JSON_END(); } - [[eraseable]] + ERASEABLE bool _json_parse_true() { JSON_BEGIN(); if (!(STRING_ITERATOR_GET(_json) == 't' @@ -122,7 +122,7 @@ bool _json_parse_value() { JSON_END(); } - [[eraseable]] + ERASEABLE bool _json_parse_false() { JSON_BEGIN(); if (!(STRING_ITERATOR_GET(_json) == 'f' @@ -135,7 +135,7 @@ bool _json_parse_value() { JSON_END(); } - [[eraseable]] + ERASEABLE bool _json_parse_null() { JSON_BEGIN(); if (!(STRING_ITERATOR_GET(_json) == 'n' @@ -147,7 +147,7 @@ bool _json_parse_value() { JSON_END(); } -[[eraseable]] +ERASEABLE bool _json_parse_string(bool add) { JSON_BEGIN(); if (STRING_ITERATOR_GET(_json) != '"') JSON_FAIL("expected opening '\"'"); @@ -179,14 +179,14 @@ bool _json_parse_string(bool add) { JSON_END(); } -[[eraseable]] +ERASEABLE bool _json_parse_number() { JSON_BEGIN(); if (!(_json_parse_float() || _json_parse_int())) JSON_FAIL("expected number"); JSON_END(); } - [[eraseable]] + ERASEABLE bool _json_parse_float() { JSON_BEGIN(); string s = ""; @@ -208,7 +208,7 @@ bool _json_parse_number() { JSON_END(); } - [[eraseable]] + ERASEABLE bool _json_parse_int() { JSON_BEGIN(); string s = ""; @@ -226,7 +226,7 @@ bool _json_parse_number() { JSON_END(); } -[[eraseable]] +ERASEABLE int json_parse(string in, bool() func) { string trimmed = ""; LABEL(trim) { @@ -272,7 +272,7 @@ int json_parse(string in, bool() func) { return _json_buffer; } -[[eraseable]] +ERASEABLE string json_get(int buf, string key) { for (int i = 1, n = buf_getsize(buf); i < n; i += 2) { @@ -281,13 +281,13 @@ string json_get(int buf, string key) return string_null; } -[[eraseable]] +ERASEABLE void json_del(int buf) { buf_del(buf); } -[[eraseable]] +ERASEABLE void json_dump(int buf) { for (int i = 0, n = buf_getsize(buf); i < n; ++i) { diff --git a/qcsrc/lib/map.qh b/qcsrc/lib/map.qh index bec7842ec..ea7f0e1fe 100644 --- a/qcsrc/lib/map.qh +++ b/qcsrc/lib/map.qh @@ -4,7 +4,7 @@ // Databases (hash tables) const int DB_BUCKETS = 8192; -[[eraseable]] +ERASEABLE void db_save(int db, string filename) { int fh = fopen(filename, FILE_WRITE); @@ -21,17 +21,17 @@ void db_save(int db, string filename) USING(HashMap, int); -[[eraseable]] +ERASEABLE int db_create() { return buf_create(); } #define HM_NEW(this) (this = db_create()) -[[eraseable]] +ERASEABLE void db_put(int db, string key, string value); -[[eraseable]] +ERASEABLE int db_load(string filename) { int db = buf_create(); @@ -65,7 +65,7 @@ int db_load(string filename) return db; } -[[eraseable]] +ERASEABLE void db_dump(int db, string filename) { int fh = fopen(filename, FILE_WRITE); @@ -80,14 +80,14 @@ void db_dump(int db, string filename) fclose(fh); } -[[eraseable]] +ERASEABLE void db_close(int db) { buf_del(db); } #define HM_DELETE(this) db_close(this) -[[eraseable]] +ERASEABLE string db_get(int db, string key) { int h = crc16(false, key) % DB_BUCKETS; @@ -97,7 +97,7 @@ string db_get(int db, string key) #define db_remove(db, key) db_put(db, key, "") -[[eraseable]] +ERASEABLE void db_put(int db, string key, string value) { int h = crc16(false, key) % DB_BUCKETS; diff --git a/qcsrc/lib/markdown.qh b/qcsrc/lib/markdown.qh index 324487719..a3bffeaae 100644 --- a/qcsrc/lib/markdown.qh +++ b/qcsrc/lib/markdown.qh @@ -5,7 +5,7 @@ * - two spaces escape a linebreak (otherwise text wraps) * - two linebreaks become a paragraph (remain unchanged) */ -[[eraseable]] +ERASEABLE string markdown(string s) { string buf = ""; diff --git a/qcsrc/lib/math.qh b/qcsrc/lib/math.qh index fbfe1d1d4..8ba31516d 100644 --- a/qcsrc/lib/math.qh +++ b/qcsrc/lib/math.qh @@ -2,7 +2,7 @@ #include "lib/float.qh" -[[eraseable]] +ERASEABLE void mean_accumulate(entity e, .float a, .float c, float mean, float value, float weight) { if (weight == 0) return; @@ -11,7 +11,7 @@ void mean_accumulate(entity e, .float a, .float c, float mean, float value, floa e.(c) += weight; } -[[eraseable]] +ERASEABLE float mean_evaluate(entity e, .float a, .float c, float mean) { if (e.(c) == 0) return 0; @@ -34,7 +34,7 @@ Angc used for animations */ -[[eraseable]] +ERASEABLE float angc(float a1, float a2) { while (a1 > 180) @@ -53,13 +53,13 @@ float angc(float a1, float a2) return a; } -[[eraseable]] +ERASEABLE float fsnap(float val, float fsize) { return rint(val / fsize) * fsize; } -[[eraseable]] +ERASEABLE vector vsnap(vector point, float fsize) { vector vret; @@ -71,13 +71,13 @@ vector vsnap(vector point, float fsize) return vret; } -[[eraseable]] +ERASEABLE vector lerpv(float t0, vector v0, float t1, vector v1, float t) { return v0 + (v1 - v0) * ((t - t0) / (t1 - t0)); } -[[eraseable]] +ERASEABLE vector bezier_quadratic_getpoint(vector a, vector b, vector c, float t) { return (c - 2 * b + a) * (t * t) @@ -85,14 +85,14 @@ vector bezier_quadratic_getpoint(vector a, vector b, vector c, float t) + a; } -[[eraseable]] +ERASEABLE vector bezier_quadratic_getderivative(vector a, vector b, vector c, float t) { return (c - 2 * b + a) * (2 * t) + (b - a) * 2; } -[[eraseable]] +ERASEABLE float cubic_speedfunc(float startspeedfactor, float endspeedfactor, float spd) { return (((startspeedfactor + endspeedfactor - 2 @@ -101,7 +101,7 @@ float cubic_speedfunc(float startspeedfactor, float endspeedfactor, float spd) ) * spd; } -[[eraseable]] +ERASEABLE bool cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor) { if (startspeedfactor < 0 || endspeedfactor < 0) return false; @@ -166,40 +166,40 @@ bool cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor) } /** continuous function mapping all reals into -1..1 */ -[[eraseable]] +ERASEABLE float float2range11(float f) { return f / (fabs(f) + 1); } /** continuous function mapping all reals into 0..1 */ -[[eraseable]] +ERASEABLE float float2range01(float f) { return 0.5 + 0.5 * float2range11(f); } -[[eraseable]] +ERASEABLE float median(float a, float b, float c) { return (a < c) ? bound(a, b, c) : bound(c, b, a); } -[[eraseable]] +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]] +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]] +ERASEABLE float almost_in_bounds(float a, float b, float c) { float eps = (max(a, -a) + max(c, -c)) * 0.001; @@ -207,7 +207,7 @@ float almost_in_bounds(float a, float b, float c) return b == median(a - eps, b, c + eps); } -[[eraseable]] +ERASEABLE float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d) { if (halflifedist > 0) return (0.5 ** ((bound(mindist, d, maxdist) - mindist) / halflifedist)); @@ -217,7 +217,7 @@ float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float #define power2of(e) (2 ** e) -[[eraseable]] +ERASEABLE float log2of(float e) { // NOTE: generated code @@ -270,7 +270,7 @@ float log2of(float e) } /** ax^2 + bx + c = 0 */ -[[eraseable]] +ERASEABLE vector solve_quadratic(float a, float b, float c) { vector v; diff --git a/qcsrc/lib/noise.qh b/qcsrc/lib/noise.qh index 9dc4d4f32..782798c9f 100644 --- a/qcsrc/lib/noise.qh +++ b/qcsrc/lib/noise.qh @@ -8,13 +8,13 @@ class(Noise).float noise_paccum2; class(Noise).float noise_paccum3; class(Noise).float noise_bstate; -[[eraseable]] +ERASEABLE float Noise_Brown(entity e, float dt) { e.noise_baccum += random() * sqrt(dt); // same stddev for all dt return e.noise_baccum; } -[[eraseable]] +ERASEABLE float Noise_Pink(entity e, float dt) { float f; @@ -25,13 +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]] +ERASEABLE float Noise_White(entity e, float dt) { return random() * 2 - 1; } /** +1 or -1 */ -[[eraseable]] +ERASEABLE float Noise_Burst(entity e, float dt, float p) { if (random() > (p ** dt)) e.noise_bstate = !e.noise_bstate; diff --git a/qcsrc/lib/p2mathlib.qc b/qcsrc/lib/p2mathlib.qc index 39b18bb62..ce6f7ea89 100644 --- a/qcsrc/lib/p2mathlib.qc +++ b/qcsrc/lib/p2mathlib.qc @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -[[eraseable]] +ERASEABLE vector vec_bias(vector v, float f) { vector c; @@ -26,7 +26,7 @@ vector vec_bias(vector v, float f) c.z = v.z + f; return c; } -[[eraseable]] +ERASEABLE vector vec_to_min(vector a, vector b) { vector c; @@ -36,7 +36,7 @@ vector vec_to_min(vector a, vector b) return c; } -[[eraseable]] +ERASEABLE vector vec_to_max(vector a, vector b) { vector c; @@ -47,7 +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]] +ERASEABLE vector vec_bounds_in(vector point, vector a, vector b) { vector d = vec_to_min(a, b); @@ -58,7 +58,7 @@ vector vec_bounds_in(vector point, vector a, vector b) return c; } -[[eraseable]] +ERASEABLE vector vec_bounds_out(vector point, vector a, vector b) { vector d = vec_to_max(a, b); @@ -69,7 +69,7 @@ vector vec_bounds_out(vector point, vector a, vector b) return c; } -[[eraseable]] +ERASEABLE float angle_snap_f(float f, float increment) { for (int j = 0; j <= 360; ) @@ -81,7 +81,7 @@ float angle_snap_f(float f, float increment) return 0; } -[[eraseable]] +ERASEABLE vector angle_snap_vec(vector v, float increment) { vector c; @@ -91,7 +91,7 @@ vector angle_snap_vec(vector v, float increment) return c; } -[[eraseable]] +ERASEABLE vector aim_vec(vector org, vector targ) { vector v; diff --git a/qcsrc/lib/p2mathlib.qh b/qcsrc/lib/p2mathlib.qh index 1f4deb1d8..898d6ca1c 100644 --- a/qcsrc/lib/p2mathlib.qh +++ b/qcsrc/lib/p2mathlib.qh @@ -19,25 +19,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -[[eraseable]] +ERASEABLE vector vec_bias(vector v, float f); -[[eraseable]] +ERASEABLE vector vec_to_min(vector a, vector b); -[[eraseable]] +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]] +ERASEABLE vector vec_bounds_in(vector point, vector a, vector b); -[[eraseable]] +ERASEABLE vector vec_bounds_out(vector point, vector a, vector b); -[[eraseable]] +ERASEABLE float angle_snap_f(float f, float increment); -[[eraseable]] +ERASEABLE vector angle_snap_vec(vector v, float increment); -[[eraseable]] +ERASEABLE vector aim_vec(vector org, vector targ); diff --git a/qcsrc/lib/random.qc b/qcsrc/lib/random.qc index d39cfdcad..a5ff69356 100644 --- a/qcsrc/lib/random.qc +++ b/qcsrc/lib/random.qc @@ -1,6 +1,6 @@ #include "random.qh" -[[eraseable]] +ERASEABLE void RandomSelection_Init() { RandomSelection_totalweight = 0; @@ -10,7 +10,7 @@ void RandomSelection_Init() RandomSelection_best_priority = -1; } -[[eraseable]] +ERASEABLE void RandomSelection_Add(entity e, float f, string s, vector v, float weight, float priority) { if (priority > RandomSelection_best_priority) @@ -38,7 +38,7 @@ void RandomSelection_Add(entity e, float f, string s, vector v, float weight, fl float DistributeEvenly_amount; float DistributeEvenly_totalweight; -[[eraseable]] +ERASEABLE void DistributeEvenly_Init(float amount, float totalweight) { if (DistributeEvenly_amount) @@ -50,7 +50,7 @@ void DistributeEvenly_Init(float amount, float totalweight) DistributeEvenly_totalweight = totalweight; } -[[eraseable]] +ERASEABLE float DistributeEvenly_Get(float weight) { float f; @@ -61,7 +61,7 @@ float DistributeEvenly_Get(float weight) return f; } -[[eraseable]] +ERASEABLE float DistributeEvenly_GetRandomized(float weight) { float f; @@ -75,7 +75,7 @@ float DistributeEvenly_GetRandomized(float weight) // from the GNU Scientific Library float gsl_ran_gaussian_lastvalue; float gsl_ran_gaussian_lastvalue_set; -[[eraseable]] +ERASEABLE float gsl_ran_gaussian(float sigma) { if (gsl_ran_gaussian_lastvalue_set) diff --git a/qcsrc/lib/random.qh b/qcsrc/lib/random.qh index 668e49784..e3900697b 100644 --- a/qcsrc/lib/random.qh +++ b/qcsrc/lib/random.qh @@ -7,9 +7,9 @@ float RandomSelection_chosen_float; string RandomSelection_chosen_string; vector RandomSelection_chosen_vec; -[[eraseable]] +ERASEABLE void RandomSelection_Init(); -[[eraseable]] +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) diff --git a/qcsrc/lib/registry.qh b/qcsrc/lib/registry.qh index e9712970e..a3282a0ab 100644 --- a/qcsrc/lib/registry.qh +++ b/qcsrc/lib/registry.qh @@ -140,9 +140,9 @@ REGISTRY(Registries, BITS(8)) #define REGISTRY_HASH(id) Registry_hash_##id -[[eraseable]] +ERASEABLE [[accumulate]] void Registry_check(string r, string server) { } -[[eraseable]] +ERASEABLE [[accumulate]] void Registry_send_all() { } #ifdef SVQC diff --git a/qcsrc/lib/sort.qh b/qcsrc/lib/sort.qh index 068707d0b..565ebb29c 100644 --- a/qcsrc/lib/sort.qh +++ b/qcsrc/lib/sort.qh @@ -5,7 +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]] +ERASEABLE void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass) { #define heapify(_count) \ @@ -40,7 +40,7 @@ void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass) } } -[[eraseable]] +ERASEABLE void shuffle(float n, swapfunc_t swap, entity pass) { for (int i = 1; i < n; ++i) diff --git a/qcsrc/lib/sortlist.qc b/qcsrc/lib/sortlist.qc index 2cc90268c..e800bc457 100644 --- a/qcsrc/lib/sortlist.qc +++ b/qcsrc/lib/sortlist.qc @@ -1,6 +1,6 @@ #include "sortlist.qh" -[[eraseable]] +ERASEABLE entity Sort_Spawn() { entity sort = new_pure(sortlist); diff --git a/qcsrc/lib/static.qh b/qcsrc/lib/static.qh index 46b3a7fa9..e2c5fd4f0 100644 --- a/qcsrc/lib/static.qh +++ b/qcsrc/lib/static.qh @@ -16,7 +16,7 @@ float(int tmr) _gettime = #67; float(int tmr) _gettime = #519; #endif -[[eraseable]] +ERASEABLE void profile(string s) { static float g_starttime; diff --git a/qcsrc/lib/string.qh b/qcsrc/lib/string.qh index 33aacebab..b05a316c9 100644 --- a/qcsrc/lib/string.qh +++ b/qcsrc/lib/string.qh @@ -27,7 +27,7 @@ } #endif -[[eraseable]] +ERASEABLE string seconds_tostring(float sec) { float minutes = floor(sec / 60); @@ -35,7 +35,7 @@ string seconds_tostring(float sec) return sprintf("%d:%02d", minutes, sec); } -[[eraseable]] +ERASEABLE string format_time(float seconds) { seconds = floor(seconds + 0.5); @@ -49,7 +49,7 @@ string format_time(float seconds) else return sprintf(_("%02d:%02d:%02d"), hours, minutes, seconds); } -[[eraseable]] +ERASEABLE string mmsss(float tenths) { tenths = floor(tenths + 0.5); @@ -59,7 +59,7 @@ string mmsss(float tenths) return strcat(ftos(minutes), ":", substring(s, 1, 2), ".", substring(s, 3, 1)); } -[[eraseable]] +ERASEABLE string mmssss(float hundredths) { hundredths = floor(hundredths + 0.5); @@ -71,7 +71,7 @@ string mmssss(float hundredths) int ColorTranslateMode; -[[eraseable]] +ERASEABLE string ColorTranslateRGB(string s) { return (ColorTranslateMode & 1) ? strdecolorize(s) : s; @@ -116,7 +116,7 @@ string CCR(string input) #define startsWith(haystack, needle) (strstrofs(haystack, needle, 0) == 0) -[[eraseable]] +ERASEABLE bool startsWithNocase(string haystack, string needle) { return strcasecmp(substring(haystack, 0, strlen(needle)), needle) == 0; @@ -126,7 +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]] +ERASEABLE string fstrunzone(string s) { if (!s) return s; @@ -136,7 +136,7 @@ string fstrunzone(string s) } /** returns first word */ -[[eraseable]] +ERASEABLE string car(string s) { int o = strstrofs(s, " ", 0); @@ -145,7 +145,7 @@ string car(string s) } /** returns all but first word */ -[[eraseable]] +ERASEABLE string cdr(string s) { int o = strstrofs(s, " ", 0); @@ -153,7 +153,7 @@ string cdr(string s) return substring(s, o + 1, strlen(s) - (o + 1)); } -[[eraseable]] +ERASEABLE string cons(string a, string b) { if (a == "") return b; @@ -161,13 +161,13 @@ string cons(string a, string b) return strcat(a, " ", b); } -[[eraseable]] +ERASEABLE string substring_range(string s, float b, float e) { return substring(s, b, e - b); } -[[eraseable]] +ERASEABLE string swapwords(string str, float i, float j) { float n; @@ -189,13 +189,13 @@ string swapwords(string str, float i, float j) } string _shufflewords_str; -[[eraseable]] +ERASEABLE void _shufflewords_swapfunc(float i, float j, entity pass) { _shufflewords_str = swapwords(_shufflewords_str, i, j); } -[[eraseable]] +ERASEABLE string shufflewords(string str) { _shufflewords_str = str; @@ -206,7 +206,7 @@ string shufflewords(string str) return str; } -[[eraseable]] +ERASEABLE string unescape(string in) { in = strzone(in); // but it doesn't seem to be necessary in my tests at least @@ -231,7 +231,7 @@ string unescape(string in) return str; } -[[eraseable]] +ERASEABLE string strwords(string s, int w) { int endpos = 0; @@ -243,7 +243,7 @@ string strwords(string s, int w) #define strhasword(s, w) (strstrofs(strcat(" ", s, " "), strcat(" ", w, " "), 0) >= 0) -[[eraseable]] +ERASEABLE int u8_strsize(string s) { int l = 0; @@ -256,7 +256,7 @@ int u8_strsize(string s) return l; } -[[eraseable]] +ERASEABLE bool isInvisibleString(string s) { s = strdecolorize(s); @@ -284,7 +284,7 @@ bool isInvisibleString(string s) // Multiline text file buffers -[[eraseable]] +ERASEABLE int buf_load(string pFilename) { int buf = buf_create(); @@ -302,7 +302,7 @@ int buf_load(string pFilename) return buf; } -[[eraseable]] +ERASEABLE void buf_save(float buf, string pFilename) { int fh = fopen(pFilename, FILE_WRITE); @@ -316,7 +316,7 @@ void buf_save(float buf, string pFilename) /** * converts a number to a string with the indicated number of decimals */ -[[eraseable]] +ERASEABLE string ftos_decimals(float number, int decimals) { // inhibit stupid negative zero @@ -327,7 +327,7 @@ string ftos_decimals(float number, int decimals) /** * converts a number to a string with the minimum number of decimals */ -[[eraseable]] +ERASEABLE string ftos_mindecimals(float number) { // inhibit stupid negative zero @@ -335,7 +335,7 @@ string ftos_mindecimals(float number) return sprintf("%.7g", number); } -[[eraseable]] +ERASEABLE int vercmp_recursive(string v1, string v2) { int dot1 = strstrofs(v1, ".", 0); @@ -354,7 +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]] +ERASEABLE int vercmp(string v1, string v2) { if (strcasecmp(v1, v2) == 0) return 0; // early out check diff --git a/qcsrc/lib/urllib.qc b/qcsrc/lib/urllib.qc index 9f5d3e26f..fd8b16d88 100644 --- a/qcsrc/lib/urllib.qc +++ b/qcsrc/lib/urllib.qc @@ -24,7 +24,7 @@ const float URL_FH_STDOUT = -2; entity url_fromid[NUM_URL_ID]; int autocvar__urllib_nextslot; -[[eraseable]] +ERASEABLE float url_URI_Get_Callback(int id, float status, string data) { if (id < MIN_URL_ID) return 0; @@ -83,7 +83,7 @@ float url_URI_Get_Callback(int id, float status, string data) } } -[[eraseable]] +ERASEABLE void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass) { entity e; @@ -203,7 +203,7 @@ void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass) } // close a file -[[eraseable]] +ERASEABLE void url_fclose(entity e) { int i; @@ -283,7 +283,7 @@ void url_fclose(entity e) } // with \n (blame FRIK_FILE) -[[eraseable]] +ERASEABLE string url_fgets(entity e) { if (e.url_fh == URL_FH_CURL) @@ -308,7 +308,7 @@ string url_fgets(entity e) } // without \n (blame FRIK_FILE) -[[eraseable]] +ERASEABLE void url_fputs(entity e, string s) { if (e.url_fh == URL_FH_CURL) @@ -331,7 +331,7 @@ void url_fputs(entity e, string s) } // multi URL object, tries URLs separated by space in sequence -[[eraseable]] +ERASEABLE void url_multi_ready(entity fh, entity me, float status) { float n; @@ -360,7 +360,7 @@ void url_multi_ready(entity fh, entity me, float status) me.url_ready(fh, me.url_ready_pass, status); } -[[eraseable]] +ERASEABLE void url_multi_fopen(string url, int mode, url_ready_func rdy, entity pass) { float n; diff --git a/qcsrc/lib/urllib.qh b/qcsrc/lib/urllib.qh index acb4077d6..8918ca0a2 100644 --- a/qcsrc/lib/urllib.qh +++ b/qcsrc/lib/urllib.qh @@ -17,20 +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]] +ERASEABLE void url_single_fopen(string url, float mode, url_ready_func rdy, entity pass); -[[eraseable]] +ERASEABLE void url_fclose(entity e); -[[eraseable]] +ERASEABLE string url_fgets(entity e); -[[eraseable]] +ERASEABLE void url_fputs(entity e, string s); // returns true if handled -[[eraseable]] +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]] +ERASEABLE void url_multi_fopen(string url, float mode, url_ready_func rdy, entity pass); diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh index 746a43d08..8340381ba 100644 --- a/qcsrc/lib/vector.qh +++ b/qcsrc/lib/vector.qh @@ -25,7 +25,7 @@ noref vector _dotproduct_a, _dotproduct_b; #if 1 #define cross(a, b) ((a) >< (b)) #else -[[eraseable]] +ERASEABLE vector cross(vector a, vector b) { return @@ -46,7 +46,7 @@ const vector eX = '1 0 0'; const vector eY = '0 1 0'; const vector eZ = '0 0 1'; -[[eraseable]] +ERASEABLE vector randompos(vector m1, vector m2) { vector v; @@ -57,19 +57,19 @@ vector randompos(vector m1, vector m2) return v; } -[[eraseable]] +ERASEABLE float vlen_maxnorm2d(vector v) { return max(v.x, v.y, -v.x, -v.y); } -[[eraseable]] +ERASEABLE float vlen_minnorm2d(vector v) { return min(max(v.x, -v.x), max(v.y, -v.y)); } -[[eraseable]] +ERASEABLE float dist_point_line(vector p, vector l0, vector ldir) { ldir = normalize(ldir); @@ -82,11 +82,11 @@ float dist_point_line(vector p, vector l0, vector ldir) } /** requires that m2>m1 in all coordinates, and that m4>m3 */ -[[eraseable]] +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]] +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) @@ -112,7 +112,7 @@ noref vector _vec2; noref vector _vec3; #define vec3(_x, _y, _z) (_vec3.x = (_x), _vec3.y = (_y), _vec3.z = (_z), _vec3) -[[eraseable]] +ERASEABLE vector Rotate(vector v, float a) { float a_sin = sin(a), a_cos = cos(a); @@ -127,7 +127,7 @@ noref vector _yinvert; * @param norm the normalized normal * @returns dir reflected by norm */ -[[eraseable]] +ERASEABLE vector reflect(vector dir, vector norm) { return dir - 2 * (dir * norm) * norm; @@ -136,13 +136,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]] +ERASEABLE vector vec_reflect(vector vel, vector norm, float bounce) { return vel - (1 + bounce) * (vel * norm) * norm; } -[[eraseable]] +ERASEABLE vector vec_epsilon(vector this, float eps) { if (this.x > -eps && this.x < eps) this.x = 0; @@ -155,7 +155,7 @@ vector vec_epsilon(vector this, float eps) (out = vec_epsilon(vec_reflect(in, normal, (overbounce) - 1), 0.1)) #ifdef GAMEQC - [[eraseable]] + ERASEABLE vector get_corner_position(entity box, int corner) { switch (corner) @@ -172,7 +172,7 @@ vector vec_epsilon(vector this, float eps) } } - [[eraseable]] + ERASEABLE vector NearestPointOnBox(entity box, vector org) { vector m1 = box.mins + box.origin; -- 2.39.2