From: TimePath Date: Wed, 30 Dec 2015 10:49:05 +0000 (+1100) Subject: #pragma once X-Git-Tag: xonotic-v0.8.2~1357 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cd82710e25e3b84401bf9b01b0bcd482d612c800;p=xonotic%2Fxonotic-data.pk3dir.git #pragma once There are scripts available to revert `once` to include guards should they be needed --- diff --git a/qcsrc/lib/_all.inc b/qcsrc/lib/_all.inc index 563a86c3c..8b4c58bdd 100644 --- a/qcsrc/lib/_all.inc +++ b/qcsrc/lib/_all.inc @@ -47,12 +47,12 @@ #include "lazy.qh" #include "linkedlist.qh" #include "log.qh" -#include "map.qc" +#include "map.qh" #include "math.qh" #include "misc.qh" #include "net.qh" #include "nil.qh" -#include "noise.qc" +#include "noise.qh" #include "oo.qh" #include "p2mathlib.qc" #include "progname.qh" diff --git a/qcsrc/lib/accumulate.qh b/qcsrc/lib/accumulate.qh index e3d17b9f2..a32649f5c 100644 --- a/qcsrc/lib/accumulate.qh +++ b/qcsrc/lib/accumulate.qh @@ -1,5 +1,4 @@ -#ifndef ACCUMULATE_H -#define ACCUMULATE_H +#pragma once #ifdef QCC_SUPPORT_ACCUMULATE #define ACCUMULATE_FUNCTION(func, otherfunc) \ @@ -56,5 +55,3 @@ if (!field) { field = (first + count); ++count; } #define CHECK_MAX_COUNT(name, max, count, type) \ if (count > max) { error(strcat("Maximum ", type, " hit: ", #name, ": ", ftos(count), ".\n")); } - -#endif diff --git a/qcsrc/lib/arraylist.qh b/qcsrc/lib/arraylist.qh index f9df9e6bf..209004b64 100644 --- a/qcsrc/lib/arraylist.qh +++ b/qcsrc/lib/arraylist.qh @@ -1,5 +1,4 @@ -#ifndef ARRAYLIST_H -#define ARRAYLIST_H +#pragma once typedef entity ArrayList; .int al_buf; @@ -69,5 +68,3 @@ entity al_ftoe(int i) = #80; if (cond) { body } \ } \ } MACRO_END - -#endif diff --git a/qcsrc/lib/bits.qh b/qcsrc/lib/bits.qh index 001984a63..266fe9c8c 100644 --- a/qcsrc/lib/bits.qh +++ b/qcsrc/lib/bits.qh @@ -1,5 +1,5 @@ -#ifndef BITS_H -#define BITS_H +#pragma once + #include "log.qh" #define BIT(n) (1 << (n)) @@ -121,5 +121,3 @@ bool GiveValue(entity e, .int fld, int op, int val) int v1 = e.(fld); return v0 != v1; } - -#endif diff --git a/qcsrc/lib/bool.qh b/qcsrc/lib/bool.qh index 5510c171c..9889f778a 100644 --- a/qcsrc/lib/bool.qh +++ b/qcsrc/lib/bool.qh @@ -1,5 +1,4 @@ -#ifndef BOOL_H -#define BOOL_H +#pragma once #ifndef QCC_SUPPORT_BOOL // Boolean Constants @@ -31,5 +30,3 @@ float InterpretBoolean(string input) default: return boolean(stof(input)); } } - -#endif diff --git a/qcsrc/lib/color.qh b/qcsrc/lib/color.qh index 442d8ee89..d1fdc2c3b 100644 --- a/qcsrc/lib/color.qh +++ b/qcsrc/lib/color.qh @@ -1,5 +1,4 @@ -#ifndef COLOR_H -#define COLOR_H +#pragma once #include "string.qh" @@ -176,5 +175,3 @@ string rgb_to_hexcolor(vector rgb) DEC_TO_HEXDIGIT(floor(rgb.z * 15 + 0.5)) ); } - -#endif diff --git a/qcsrc/lib/compiler.qh b/qcsrc/lib/compiler.qh index d389248b0..14824dc5a 100644 --- a/qcsrc/lib/compiler.qh +++ b/qcsrc/lib/compiler.qh @@ -1,5 +1,4 @@ -#ifndef COMPILER_H -#define COMPILER_H +#pragma once #ifndef QCC_SUPPORT_ACCUMULATE #ifdef GMQCC @@ -12,5 +11,3 @@ #define QCC_SUPPORT_NIL #endif #endif - -#endif diff --git a/qcsrc/lib/counting.qh b/qcsrc/lib/counting.qh index 892c692d8..d12ae4250 100644 --- a/qcsrc/lib/counting.qh +++ b/qcsrc/lib/counting.qh @@ -1,5 +1,4 @@ -#ifndef COUNTING_H -#define COUNTING_H +#pragma once #include "i18n.qh" @@ -225,4 +224,3 @@ string process_time(float outputtype, float seconds) } return ""; } -#endif diff --git a/qcsrc/lib/cvar.qh b/qcsrc/lib/cvar.qh index 3a98c9606..adcb7dfee 100644 --- a/qcsrc/lib/cvar.qh +++ b/qcsrc/lib/cvar.qh @@ -1,5 +1,4 @@ -#ifndef CVAR_H -#define CVAR_H +#pragma once #include "nil.qh" #include "progname.qh" @@ -88,5 +87,3 @@ const noref vector default_vector = '0 0 0'; #define EVAL__AUTOCVAR(...) __VA_ARGS__ #define AUTOCVAR_SAVE(...) _AUTOCVAR(true, __VA_ARGS__) #define AUTOCVAR(...) _AUTOCVAR(false, __VA_ARGS__) - -#endif diff --git a/qcsrc/lib/defer.qh b/qcsrc/lib/defer.qh index 91782e56c..070c09275 100644 --- a/qcsrc/lib/defer.qh +++ b/qcsrc/lib/defer.qh @@ -1,5 +1,5 @@ -#ifndef DEFER_H -#define DEFER_H +#pragma once + #ifndef MENUQC #include "oo.qh" @@ -46,4 +46,3 @@ } #endif -#endif diff --git a/qcsrc/lib/draw.qh b/qcsrc/lib/draw.qh index 40900b877..96aa7901b 100644 --- a/qcsrc/lib/draw.qh +++ b/qcsrc/lib/draw.qh @@ -1,6 +1,6 @@ +#pragma once + #ifdef CSQC -#ifndef DRAW_H - #define DRAW_H #include "i18n.qh" #include "vector.qh" @@ -130,4 +130,3 @@ } #endif -#endif diff --git a/qcsrc/lib/enumclass.qh b/qcsrc/lib/enumclass.qh index 2959565c5..412e9db6b 100644 --- a/qcsrc/lib/enumclass.qh +++ b/qcsrc/lib/enumclass.qh @@ -1,5 +1,4 @@ -#ifndef ENUMCLASS_H -#define ENUMCLASS_H +#pragma once #include "oo.qh" @@ -22,5 +21,3 @@ #define ENUMCLASS_END(id) ENDCLASS(id) #endif - -#endif diff --git a/qcsrc/lib/file.qh b/qcsrc/lib/file.qh index 87d146025..949a748a8 100644 --- a/qcsrc/lib/file.qh +++ b/qcsrc/lib/file.qh @@ -1,5 +1,4 @@ -#ifndef FILE_H -#define FILE_H +#pragma once bool fexists(string f) { @@ -8,5 +7,3 @@ bool fexists(string f) fclose(fh); return true; } - -#endif diff --git a/qcsrc/lib/functional.qh b/qcsrc/lib/functional.qh index 237492d90..82d577b16 100644 --- a/qcsrc/lib/functional.qh +++ b/qcsrc/lib/functional.qh @@ -1,5 +1,4 @@ -#ifndef FUNCTIONAL_H -#define FUNCTIONAL_H +#pragma once #define MAP(f, ...) EVAL(OVERLOAD(MAP, f, __VA_ARGS__)) #define MAP_2(f, it) f(it) @@ -41,5 +40,3 @@ #endif #define IF(cond, f, ...) cond(f, __VA_ARGS__) - -#endif diff --git a/qcsrc/lib/i18n.qh b/qcsrc/lib/i18n.qh index e439b22aa..c66d7b9a8 100644 --- a/qcsrc/lib/i18n.qh +++ b/qcsrc/lib/i18n.qh @@ -1,8 +1,7 @@ -#ifndef I18N_H -#define I18N_H +#pragma once #include "log.qh" -#include "map.qc" +#include "map.qh" #include "unsafe.qh" // translation helpers @@ -57,5 +56,3 @@ string CTX(string s) } #define ZCTX(s) strzone(CTX(s)) - -#endif diff --git a/qcsrc/lib/int.qh b/qcsrc/lib/int.qh index 9bd129b9e..c1edf07c4 100644 --- a/qcsrc/lib/int.qh +++ b/qcsrc/lib/int.qh @@ -1,5 +1,4 @@ -#ifndef INT_H -#define INT_H +#pragma once #ifndef QCC_SUPPORT_INT #define stoi(s) stof(s) @@ -10,5 +9,3 @@ #define stob(s) ((bool) stof(s)) #define itos(i) ftos(i) #endif - -#endif diff --git a/qcsrc/lib/iter.qh b/qcsrc/lib/iter.qh index 0eebddd40..d02dd6284 100644 --- a/qcsrc/lib/iter.qh +++ b/qcsrc/lib/iter.qh @@ -1,5 +1,4 @@ -#ifndef ITER_H -#define ITER_H +#pragma once #define FOREACH_ARRAY(arr, start, end, cond, body) \ MACRO_BEGIN \ @@ -151,5 +150,3 @@ #define FOREACH_ENTITY(cond, body) FOREACH_ENTITY_UNORDERED(cond, body) #define FOREACH(list, cond, body) FOREACH_LIST(list, enemy, cond, body) - -#endif diff --git a/qcsrc/lib/lazy.qh b/qcsrc/lib/lazy.qh index 5e0329bd2..ad30115a2 100644 --- a/qcsrc/lib/lazy.qh +++ b/qcsrc/lib/lazy.qh @@ -1,5 +1,4 @@ -#ifndef LAZY_H -#define LAZY_H +#pragma once #include "oo.qh" @@ -19,4 +18,3 @@ ENDCLASS(Lazy) if (!done) { it = compute; done = true; } \ return it; \ } -#endif diff --git a/qcsrc/lib/linkedlist.qh b/qcsrc/lib/linkedlist.qh index b56493748..a8e4aaa09 100644 --- a/qcsrc/lib/linkedlist.qh +++ b/qcsrc/lib/linkedlist.qh @@ -1,5 +1,4 @@ -#ifndef LINKEDLIST_H -#define LINKEDLIST_H +#pragma once CLASS(LinkedListNode, Object) ATTRIB(LinkedListNode, ll_data, entity, NULL) @@ -83,5 +82,3 @@ entity LL_POP(LinkedList this) if (cond) { body } \ } \ } MACRO_END - -#endif diff --git a/qcsrc/lib/log.qh b/qcsrc/lib/log.qh index b5e1ecec3..01dc645f5 100644 --- a/qcsrc/lib/log.qh +++ b/qcsrc/lib/log.qh @@ -1,5 +1,4 @@ -#ifndef LOG_H -#define LOG_H +#pragma once #define assert(expr, ...) _assert(LOG_SEVERE, expr, __VA_ARGS__) #define devassert(...) MACRO_BEGIN if (autocvar_developer) assert(__VA_ARGS__); MACRO_END @@ -109,5 +108,3 @@ noref bool autocvar_prvm_backtraceforwarnings; bt_cvar_set("developer", ftos(dev)); \ bt_cvar_set("prvm_backtraceforwarnings", ftos(war)); \ } MACRO_END - -#endif diff --git a/qcsrc/lib/macro.qh b/qcsrc/lib/macro.qh index cc4f37b3d..809708d74 100644 --- a/qcsrc/lib/macro.qh +++ b/qcsrc/lib/macro.qh @@ -1,5 +1,4 @@ -#ifndef MACRO_H -#define MACRO_H +#pragma once #if 1 void voidfunc() { error("voidfunc"); } @@ -15,5 +14,3 @@ #define _STR(it) #it #define STR(it) _STR(it) - -#endif diff --git a/qcsrc/lib/map.qc b/qcsrc/lib/map.qc deleted file mode 100644 index fc7012cc0..000000000 --- a/qcsrc/lib/map.qc +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef MAP_H -#define MAP_H - -#include "int.qh" - -// Databases (hash tables) -const int DB_BUCKETS = 8192; -void db_save(int db, string filename) -{ - int fh = fopen(filename, FILE_WRITE); - if (fh < 0) - { - LOG_WARNINGF("^1Can't write DB to %s\n", filename); - return; - } - fputs(fh, strcat(ftos(DB_BUCKETS), "\n")); - for (int i = 0, n = buf_getsize(db); i < n; ++i) - fputs(fh, strcat(bufstr_get(db, i), "\n")); - fclose(fh); -} - -typedef int HashMap; - -int db_create() -{ - return buf_create(); -} -#define HM_NEW(this) (this = db_create()) - -void db_put(int db, string key, string value); - -int db_load(string filename) -{ - int db = buf_create(); - if (db < 0) return -1; - int fh = fopen(filename, FILE_READ); - if (fh < 0) return db; - string l = fgets(fh); - if (stoi(l) == DB_BUCKETS) - { - for (int i = 0; (l = fgets(fh)); ++i) - { - if (l != "") bufstr_set(db, i, l); - } - } - else - { - // different count of buckets, or a dump? - // need to reorganize the database then (SLOW) - // - // note: we also parse the first line (l) in case the DB file is - // missing the bucket count - do - { - int n = tokenizebyseparator(l, "\\"); - for (int j = 2; j < n; j += 2) - db_put(db, argv(j - 1), uri_unescape(argv(j))); - } - while ((l = fgets(fh))); - } - fclose(fh); - return db; -} - -void db_dump(int db, string filename) -{ - int fh = fopen(filename, FILE_WRITE); - if (fh < 0) LOG_FATALF("Can't dump DB to %s\n"); - fputs(fh, "0\n"); - for (int i = 0, n = buf_getsize(db); i < n; ++i) - { - int m = tokenizebyseparator(bufstr_get(db, i), "\\"); - for (int j = 2; j < m; j += 2) - fputs(fh, strcat("\\", argv(j - 1), "\\", argv(j), "\n")); - } - fclose(fh); -} - -void db_close(int db) -{ - buf_del(db); -} -#define HM_DELETE(this) db_close(this) - -string db_get(int db, string key) -{ - int h = crc16(false, key) % DB_BUCKETS; - return uri_unescape(infoget(bufstr_get(db, h), key)); -} -#define HM_gets(this, k) db_get(this, k) - -#define db_remove(db, key) db_put(db, key, "") - -void db_put(int db, string key, string value) -{ - int h = crc16(false, key) % DB_BUCKETS; - bufstr_set(db, h, infoadd(bufstr_get(db, h), key, uri_escape(value))); -} -#define HM_sets(this, key, val) db_put(this, key, val) - -void db_test() -{ - LOG_INFO("LOAD...\n"); - int db = db_load("foo.db"); - LOG_INFO("LOADED. FILL...\n"); - for (int i = 0; i < DB_BUCKETS; ++i) - db_put(db, ftos(random()), "X"); - LOG_INFO("FILLED. SAVE...\n"); - db_save(db, "foo.db"); - LOG_INFO("SAVED. CLOSE...\n"); - db_close(db); - LOG_INFO("CLOSED.\n"); -} - -#endif diff --git a/qcsrc/lib/map.qh b/qcsrc/lib/map.qh new file mode 100644 index 000000000..0ff16e13d --- /dev/null +++ b/qcsrc/lib/map.qh @@ -0,0 +1,112 @@ +#pragma once + +#include "int.qh" + +// Databases (hash tables) +const int DB_BUCKETS = 8192; +void db_save(int db, string filename) +{ + int fh = fopen(filename, FILE_WRITE); + if (fh < 0) + { + LOG_WARNINGF("^1Can't write DB to %s\n", filename); + return; + } + fputs(fh, strcat(ftos(DB_BUCKETS), "\n")); + for (int i = 0, n = buf_getsize(db); i < n; ++i) + fputs(fh, strcat(bufstr_get(db, i), "\n")); + fclose(fh); +} + +typedef int HashMap; + +int db_create() +{ + return buf_create(); +} +#define HM_NEW(this) (this = db_create()) + +void db_put(int db, string key, string value); + +int db_load(string filename) +{ + int db = buf_create(); + if (db < 0) return -1; + int fh = fopen(filename, FILE_READ); + if (fh < 0) return db; + string l = fgets(fh); + if (stoi(l) == DB_BUCKETS) + { + for (int i = 0; (l = fgets(fh)); ++i) + { + if (l != "") bufstr_set(db, i, l); + } + } + else + { + // different count of buckets, or a dump? + // need to reorganize the database then (SLOW) + // + // note: we also parse the first line (l) in case the DB file is + // missing the bucket count + do + { + int n = tokenizebyseparator(l, "\\"); + for (int j = 2; j < n; j += 2) + db_put(db, argv(j - 1), uri_unescape(argv(j))); + } + while ((l = fgets(fh))); + } + fclose(fh); + return db; +} + +void db_dump(int db, string filename) +{ + int fh = fopen(filename, FILE_WRITE); + if (fh < 0) LOG_FATALF("Can't dump DB to %s\n"); + fputs(fh, "0\n"); + for (int i = 0, n = buf_getsize(db); i < n; ++i) + { + int m = tokenizebyseparator(bufstr_get(db, i), "\\"); + for (int j = 2; j < m; j += 2) + fputs(fh, strcat("\\", argv(j - 1), "\\", argv(j), "\n")); + } + fclose(fh); +} + +void db_close(int db) +{ + buf_del(db); +} +#define HM_DELETE(this) db_close(this) + +string db_get(int db, string key) +{ + int h = crc16(false, key) % DB_BUCKETS; + return uri_unescape(infoget(bufstr_get(db, h), key)); +} +#define HM_gets(this, k) db_get(this, k) + +#define db_remove(db, key) db_put(db, key, "") + +void db_put(int db, string key, string value) +{ + int h = crc16(false, key) % DB_BUCKETS; + bufstr_set(db, h, infoadd(bufstr_get(db, h), key, uri_escape(value))); +} +#define HM_sets(this, key, val) db_put(this, key, val) + +void db_test() +{ + LOG_INFO("LOAD...\n"); + int db = db_load("foo.db"); + LOG_INFO("LOADED. FILL...\n"); + for (int i = 0; i < DB_BUCKETS; ++i) + db_put(db, ftos(random()), "X"); + LOG_INFO("FILLED. SAVE...\n"); + db_save(db, "foo.db"); + LOG_INFO("SAVED. CLOSE...\n"); + db_close(db); + LOG_INFO("CLOSED.\n"); +} diff --git a/qcsrc/lib/math.qh b/qcsrc/lib/math.qh index e49300c96..feb7a8247 100644 --- a/qcsrc/lib/math.qh +++ b/qcsrc/lib/math.qh @@ -1,5 +1,4 @@ -#ifndef MATH_H -#define MATH_H +#pragma once void mean_accumulate(entity e, .float a, .float c, float mean, float value, float weight) { @@ -299,5 +298,3 @@ vector solve_quadratic(float a, float b, float c) } return v; } - -#endif diff --git a/qcsrc/lib/misc.qh b/qcsrc/lib/misc.qh index 5dd3e7739..dfc3bdb2d 100644 --- a/qcsrc/lib/misc.qh +++ b/qcsrc/lib/misc.qh @@ -1,5 +1,4 @@ -#ifndef MISC_H -#define MISC_H +#pragma once #ifdef __STDC__ #define EMPTY() @@ -47,5 +46,3 @@ LAMBDA(block) \ name = __with_save; \ } MACRO_END - -#endif diff --git a/qcsrc/lib/net.qh b/qcsrc/lib/net.qh index cfd083547..34cd292a8 100644 --- a/qcsrc/lib/net.qh +++ b/qcsrc/lib/net.qh @@ -1,5 +1,4 @@ -#ifndef NET_H -#define NET_H +#pragma once #include "registry.qh" #include "sort.qh" @@ -360,5 +359,3 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); } } MACRO_END #endif #endif - -#endif diff --git a/qcsrc/lib/nil.qh b/qcsrc/lib/nil.qh index 8067cf1ad..77a1e770b 100644 --- a/qcsrc/lib/nil.qh +++ b/qcsrc/lib/nil.qh @@ -1,5 +1,4 @@ -#ifndef NIL_H -#define NIL_H +#pragma once #ifdef QCC_SUPPORT_NIL #define func_null nil @@ -9,5 +8,3 @@ var void func_null(); string string_null; #endif - -#endif diff --git a/qcsrc/lib/noise.qc b/qcsrc/lib/noise.qc deleted file mode 100644 index 2987f78e6..000000000 --- a/qcsrc/lib/noise.qc +++ /dev/null @@ -1,33 +0,0 @@ -// 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/noise.qh b/qcsrc/lib/noise.qh new file mode 100644 index 000000000..9b1b47224 --- /dev/null +++ b/qcsrc/lib/noise.qh @@ -0,0 +1,35 @@ +#pragma once + +// 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/oo.qh b/qcsrc/lib/oo.qh index ca98d4fe1..cd5b568fe 100644 --- a/qcsrc/lib/oo.qh +++ b/qcsrc/lib/oo.qh @@ -1,5 +1,4 @@ -#ifndef OO_H -#define OO_H +#pragma once #include "misc.qh" #include "nil.qh" @@ -245,5 +244,3 @@ ENDCLASS(Object) #undef spawn_static #undef spawn_1 #undef _vtbl - -#endif diff --git a/qcsrc/lib/p2mathlib.qh b/qcsrc/lib/p2mathlib.qh index b1886ae12..78743d6ed 100644 --- a/qcsrc/lib/p2mathlib.qh +++ b/qcsrc/lib/p2mathlib.qh @@ -1,3 +1,5 @@ +#pragma once + /* Copyright (C) 2015 Micah Talkiewicz. diff --git a/qcsrc/lib/progname.qh b/qcsrc/lib/progname.qh index f0729460e..b411db855 100644 --- a/qcsrc/lib/progname.qh +++ b/qcsrc/lib/progname.qh @@ -1,5 +1,4 @@ -#ifndef PROGNAME_H -#define PROGNAME_H +#pragma once #if defined(MENUQC) #define PROGNAME "MENUQC" @@ -10,5 +9,3 @@ #else #error "Unable to detect PROGNAME" #endif - -#endif diff --git a/qcsrc/lib/random.qh b/qcsrc/lib/random.qh index 5b7fb0d3c..1834a97a3 100644 --- a/qcsrc/lib/random.qh +++ b/qcsrc/lib/random.qh @@ -1,5 +1,4 @@ -#ifndef RANDOM_H -#define RANDOM_H +#pragma once float RandomSelection_totalweight; float RandomSelection_best_priority; @@ -30,4 +29,3 @@ void RandomSelection_Add(entity e, float f, string s, float weight, float priori #define psrandom(x) #define prandom_debug() #endif -#endif diff --git a/qcsrc/lib/registry.qh b/qcsrc/lib/registry.qh index 8f0d0740e..8c0eed0ed 100644 --- a/qcsrc/lib/registry.qh +++ b/qcsrc/lib/registry.qh @@ -1,5 +1,4 @@ -#ifndef REGISTRY_H -#define REGISTRY_H +#pragma once #include "oo.qh" @@ -175,6 +174,3 @@ void Registry_send(string id, string hash); ATTRIB(id##Registry, REGISTRY_NEXT, entity, id##_first) \ ENDCLASS(id##Registry) \ REGISTER(Registries, REGISTRY, id, m_id, NEW(id##Registry)); - - -#endif diff --git a/qcsrc/lib/registry_net.qh b/qcsrc/lib/registry_net.qh index 14e4dbc3c..6c947d7c5 100644 --- a/qcsrc/lib/registry_net.qh +++ b/qcsrc/lib/registry_net.qh @@ -1,5 +1,4 @@ -#ifndef REGISTRY_NET_H -#define REGISTRY_NET_H +#pragma once #include "net.qh" @@ -24,5 +23,3 @@ void Registry_send(string id, string hash) WriteString(channel, hash); } #endif - -#endif diff --git a/qcsrc/lib/replicate.qh b/qcsrc/lib/replicate.qh index a7b854cd1..eae9a6e6f 100644 --- a/qcsrc/lib/replicate.qh +++ b/qcsrc/lib/replicate.qh @@ -1,5 +1,5 @@ -#ifndef REPLICATE_H -#define REPLICATE_H +#pragma once + #ifndef MENUQC #define REPLICATE(...) EVAL_REPLICATE(OVERLOAD(REPLICATE, __VA_ARGS__)) @@ -54,4 +54,3 @@ #endif #endif -#endif diff --git a/qcsrc/lib/self.qh b/qcsrc/lib/self.qh index 743214ab5..99bea5be7 100644 --- a/qcsrc/lib/self.qh +++ b/qcsrc/lib/self.qh @@ -1,5 +1,4 @@ -#ifndef SELF_H -#define SELF_H +#pragma once // Transition from global 'self' to local 'this' @@ -33,5 +32,3 @@ #define SELFPARAM() noref const entity this = __self #define self this #endif - -#endif diff --git a/qcsrc/lib/sort.qh b/qcsrc/lib/sort.qh index 32ae28112..4313954cd 100644 --- a/qcsrc/lib/sort.qh +++ b/qcsrc/lib/sort.qh @@ -1,5 +1,4 @@ -#ifndef SORT_H -#define SORT_H +#pragma once /** is only ever called for i1 < i2 */ typedef void (int i1, int i2, entity pass) swapfunc_t; @@ -57,5 +56,3 @@ void shuffle(float n, swapfunc_t swap, entity pass) if (j != i) swap(j, i, pass); } } - -#endif diff --git a/qcsrc/lib/sortlist.qh b/qcsrc/lib/sortlist.qh index eb8103f8f..af4b47ab8 100644 --- a/qcsrc/lib/sortlist.qh +++ b/qcsrc/lib/sortlist.qh @@ -1,5 +1,4 @@ -#ifndef SORTLIST_H -#define SORTLIST_H +#pragma once entityclass(Sort); // .float(entity,entity) sort_cmp; @@ -19,5 +18,3 @@ entity Sort_Spawn(); if (a.sort_prev) a.sort_prev.sort_next = b; \ a.sort_prev = b; \ b.sort_next = a - -#endif diff --git a/qcsrc/lib/spawnfunc.qh b/qcsrc/lib/spawnfunc.qh index ce3c512c1..7938bacde 100644 --- a/qcsrc/lib/spawnfunc.qh +++ b/qcsrc/lib/spawnfunc.qh @@ -1,5 +1,4 @@ -#ifndef SPAWNFUNC_H -#define SPAWNFUNC_H +#pragma once /** If this global exists, only functions with spawnfunc_ name prefix qualify as spawn functions */ noref bool require_spawnfunc_prefix; @@ -195,5 +194,3 @@ noref bool require_spawnfunc_prefix; #define spawnfunc(...) EVAL_spawnfunc(OVERLOAD(spawnfunc, __VA_ARGS__)) #define EVAL_spawnfunc(...) __VA_ARGS__ - -#endif diff --git a/qcsrc/lib/static.qh b/qcsrc/lib/static.qh index 534c2de02..e1cfeb872 100644 --- a/qcsrc/lib/static.qh +++ b/qcsrc/lib/static.qh @@ -1,5 +1,4 @@ -#ifndef STATIC_H -#define STATIC_H +#pragma once void __static_init() {} #define static_init() CALL_ACCUMULATED_FUNCTION(__static_init) @@ -19,5 +18,3 @@ void __shutdown() {} #define STATIC_INIT_LATE(func) _STATIC_INIT(__static_init_late, func##_late) #define PRECACHE(func) _STATIC_INIT(__static_init_precache, func##_precache) #define SHUTDOWN(func) _STATIC_INIT(__shutdown, func##_shutdown) - -#endif diff --git a/qcsrc/lib/stats.qh b/qcsrc/lib/stats.qh index 3f258df52..ea7671a1c 100644 --- a/qcsrc/lib/stats.qh +++ b/qcsrc/lib/stats.qh @@ -1,5 +1,4 @@ -#ifndef LIB_STATS_H -#define LIB_STATS_H +#pragma once // TODO: rename to 'netvars' @@ -113,5 +112,3 @@ STATIC_INIT(RegisterStats_renumber) #ifdef SVQC STATIC_INIT(stats_add) { stats_add(); } #endif - -#endif diff --git a/qcsrc/lib/string.qh b/qcsrc/lib/string.qh index ef1c00c62..8a984d67e 100644 --- a/qcsrc/lib/string.qh +++ b/qcsrc/lib/string.qh @@ -1,5 +1,4 @@ -#ifndef STRING_H -#define STRING_H +#pragma once #include "nil.qh" #include "sort.qh" @@ -323,5 +322,3 @@ const string HEXDIGITS = "0123456789ABCDEF0123456789abcdef"; #define HEXDIGIT_TO_DEC_RAW(d) (strstrofs(HEXDIGITS, (d), 0)) #define HEXDIGIT_TO_DEC(d) ((HEXDIGIT_TO_DEC_RAW(d) | 0x10) - 0x10) #define DEC_TO_HEXDIGIT(d) (substring(HEXDIGITS, (d), 1)) - -#endif diff --git a/qcsrc/lib/struct.qh b/qcsrc/lib/struct.qh index bce19f4fd..3caf8aaf5 100644 --- a/qcsrc/lib/struct.qh +++ b/qcsrc/lib/struct.qh @@ -1,5 +1,4 @@ -#ifndef STRUCT_H -#define STRUCT_H +#pragma once #ifndef QCC_SUPPORT_STRUCT #define _STRUCT_DECLARE(x, id, type, END) noref type x##_##id; @@ -31,5 +30,3 @@ #define _STRUCT_MEMBER(my, id, type, END) type id; #define STRUCT(id, s) struct STRUCT_##id { s(_STRUCT_MEMBER, ) }; #endif - -#endif diff --git a/qcsrc/lib/test.qh b/qcsrc/lib/test.qh index 2f4f2dee5..77e1f52ee 100644 --- a/qcsrc/lib/test.qh +++ b/qcsrc/lib/test.qh @@ -1,5 +1,4 @@ -#ifndef TEST_H -#define TEST_H +#pragma once #define TEST(id) \ void _TEST_##id(); \ @@ -16,5 +15,3 @@ void TEST_Fail(string cond); bool TEST_RunAll(); bool TEST_Run(string test); - -#endif diff --git a/qcsrc/lib/unsafe.qh b/qcsrc/lib/unsafe.qh index 6b4db2f1a..e506ea518 100644 --- a/qcsrc/lib/unsafe.qh +++ b/qcsrc/lib/unsafe.qh @@ -1,5 +1,4 @@ -#ifndef UNSAFE_H -#define UNSAFE_H +#pragma once #define reinterpret_cast(T, it) _unsafe_cast_##T(0, it) #define X(T) T _unsafe_cast_##T(int dummy, ...) { return ...(0, T); } @@ -25,5 +24,3 @@ STATIC_INIT(INTEGER_ONE) { INTEGER_ONE = reinterpret_cast(int, _unsafe_fld2) - reinterpret_cast(int, _unsafe_fld1); } - -#endif diff --git a/qcsrc/lib/urllib.qh b/qcsrc/lib/urllib.qh index 918504ff8..874640940 100644 --- a/qcsrc/lib/urllib.qh +++ b/qcsrc/lib/urllib.qh @@ -1,5 +1,4 @@ -#ifndef URLLIB_H -#define URLLIB_H +#pragma once // URI handles const int URI_GET_DISCARD = 0; @@ -29,4 +28,3 @@ float url_URI_Get_Callback(int id, float status, string data); #define NUM_URL_ID (URI_GET_URLLIB_END - URI_GET_URLLIB + 1) void url_multi_fopen(string url, float mode, url_ready_func rdy, entity pass); -#endif diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh index 8a63ae9b1..cdfe739a0 100644 --- a/qcsrc/lib/vector.qh +++ b/qcsrc/lib/vector.qh @@ -1,5 +1,4 @@ -#ifndef VECTOR_H -#define VECTOR_H +#pragma once noref vector _vlen2; #define vlen2(v) (_vlen2 = (v), dotproduct(_vlen2, _vlen2)) @@ -134,5 +133,3 @@ noref vector _yinvert; return ret; } #endif - -#endif diff --git a/qcsrc/lib/yenc.qh b/qcsrc/lib/yenc.qh index 34cf0635d..c91db98f6 100644 --- a/qcsrc/lib/yenc.qh +++ b/qcsrc/lib/yenc.qh @@ -1,5 +1,4 @@ -#ifndef YENC_H -#define YENC_H +#pragma once #include "test.qh" @@ -64,5 +63,3 @@ TEST(yEncDec) } TEST_OK(); } - -#endif