]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
#pragma once
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 30 Dec 2015 10:49:05 +0000 (21:49 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 30 Dec 2015 10:49:05 +0000 (21:49 +1100)
There are scripts available to revert `once` to include guards should they be needed

49 files changed:
qcsrc/lib/_all.inc
qcsrc/lib/accumulate.qh
qcsrc/lib/arraylist.qh
qcsrc/lib/bits.qh
qcsrc/lib/bool.qh
qcsrc/lib/color.qh
qcsrc/lib/compiler.qh
qcsrc/lib/counting.qh
qcsrc/lib/cvar.qh
qcsrc/lib/defer.qh
qcsrc/lib/draw.qh
qcsrc/lib/enumclass.qh
qcsrc/lib/file.qh
qcsrc/lib/functional.qh
qcsrc/lib/i18n.qh
qcsrc/lib/int.qh
qcsrc/lib/iter.qh
qcsrc/lib/lazy.qh
qcsrc/lib/linkedlist.qh
qcsrc/lib/log.qh
qcsrc/lib/macro.qh
qcsrc/lib/map.qc [deleted file]
qcsrc/lib/map.qh [new file with mode: 0644]
qcsrc/lib/math.qh
qcsrc/lib/misc.qh
qcsrc/lib/net.qh
qcsrc/lib/nil.qh
qcsrc/lib/noise.qc [deleted file]
qcsrc/lib/noise.qh [new file with mode: 0644]
qcsrc/lib/oo.qh
qcsrc/lib/p2mathlib.qh
qcsrc/lib/progname.qh
qcsrc/lib/random.qh
qcsrc/lib/registry.qh
qcsrc/lib/registry_net.qh
qcsrc/lib/replicate.qh
qcsrc/lib/self.qh
qcsrc/lib/sort.qh
qcsrc/lib/sortlist.qh
qcsrc/lib/spawnfunc.qh
qcsrc/lib/static.qh
qcsrc/lib/stats.qh
qcsrc/lib/string.qh
qcsrc/lib/struct.qh
qcsrc/lib/test.qh
qcsrc/lib/unsafe.qh
qcsrc/lib/urllib.qh
qcsrc/lib/vector.qh
qcsrc/lib/yenc.qh

index 563a86c3c09ba21bc9feda3ab56db1d9fcc1d4ec..8b4c58bdd09f29463ce6487bb8125404166828a0 100644 (file)
 #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"
index e3d17b9f26848ae9f473b1c844878729274fd784..a32649f5c8d4118248f8a5cc59412c734c2b6c0e 100644 (file)
@@ -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
index f9df9e6bfc5c60a97ff5a55d911f3f015914de8b..209004b64839c018a4d4ab2287033d4f7a6b12db 100644 (file)
@@ -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
index 001984a632e0f8f9451354797879b31c5b7e67f4..266fe9c8cf3b304f05dbb78ab1f83be55fbe9eef 100644 (file)
@@ -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
index 5510c171cfcc357487f4cd92182e8b987f88d7ea..9889f778a442dc381375f96f6ca359c198aa7e09 100644 (file)
@@ -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
index 442d8ee89ea762ce8459981487b9a4631ef745a6..d1fdc2c3bcf39d82b3249c9c10f457b395e02a7a 100644 (file)
@@ -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
index d389248b0ed24f8460f1f54b691f021b5a8015c8..14824dc5a78362a5f0de8516601eb2f9f139fc7a 100644 (file)
@@ -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
index 892c692d87319999e717fd5650d9e572dd4c140e..d12ae42501494941e2dd9d679cbe8a13b8d12f64 100644 (file)
@@ -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
index 3a98c96061b587a78df703b407cc79d57652edfd..adcb7dfee0393a0685a3869405a68f3bddca56b5 100644 (file)
@@ -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
index 91782e56c129c4df904f92e72eb025560765cb6a..070c0927592a0ccfb6b4f1e83218d388b61f7078 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef DEFER_H
-#define DEFER_H
+#pragma once
+
 #ifndef MENUQC
 
        #include "oo.qh"
@@ -46,4 +46,3 @@
        }
 
 #endif
-#endif
index 40900b8772314837defb913413fb9f60dabb6c4c..96aa7901b8caf701927d25856b0dd2939907c3e2 100644 (file)
@@ -1,6 +1,6 @@
+#pragma once
+
 #ifdef CSQC
-#ifndef DRAW_H
-       #define DRAW_H
 
        #include "i18n.qh"
        #include "vector.qh"
        }
 
 #endif
-#endif
index 2959565c50bc5dfae107199936d6e8953a009fc6..412e9db6bd3a7720344c2e37babde9ee925d72f9 100644 (file)
@@ -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
index 87d1460250a1c007b5ebe0c23103208093fbc8cf..949a748a84e140efa80fa5cbfdd767dbad635190 100644 (file)
@@ -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
index 237492d90056fd54da37f3aeae91796bc9b1d0b2..82d577b169083eb18d9499d8540cd7e3f7e96e99 100644 (file)
@@ -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
index e439b22aa56799006c3eea004fa17fd987e699ae..c66d7b9a88bd8a163d20d5a13cef85132102892c 100644 (file)
@@ -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
index 9bd129b9e1f726fc27a4b05b393abd62a269427a..c1edf07c4b30b9949fe1ac99350baf5e7159bf94 100644 (file)
@@ -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
index 0eebddd4065c1901890b1abf93878c0f28cf6120..d02dd6284f74617826adea456fc405ddc165a59a 100644 (file)
@@ -1,5 +1,4 @@
-#ifndef ITER_H
-#define ITER_H
+#pragma once
 
 #define FOREACH_ARRAY(arr, start, end, cond, body) \
        MACRO_BEGIN \
 #define FOREACH_ENTITY(cond, body) FOREACH_ENTITY_UNORDERED(cond, body)
 
 #define FOREACH(list, cond, body) FOREACH_LIST(list, enemy, cond, body)
-
-#endif
index 5e0329bd206c21e4c94881bd8e947fea7afc51b2..ad30115a2e74c3fb00e25564cfe0e998816d42a9 100644 (file)
@@ -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
index b56493748a3b527ba0689e45cf898d27c367b430..a8e4aaa090a0ac9ec09a9fad0c1a047ec86337a4 100644 (file)
@@ -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
index b5e1ecec37d1c5b5db0078c839bb6cf4598f0a39..01dc645f5630e131ae77f857bba0087c9137a85d 100644 (file)
@@ -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
index cc4f37b3d1abfe37af43e619c5eb4e4c7911a04c..809708d7439e57fc3870b47714422a653a54667c 100644 (file)
@@ -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 (file)
index fc7012c..0000000
+++ /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 (file)
index 0000000..0ff16e1
--- /dev/null
@@ -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");
+}
index e49300c9615799921b7fe3930ca99c1d51769943..feb7a8247455bd84d7e426014bc301f787ac2c6e 100644 (file)
@@ -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
index 5dd3e77395c1c4bbb97a92336bac6f8154674a60..dfc3bdb2d47153a4dbc033a993c8779f7086d639 100644 (file)
@@ -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
index cfd083547a2bf09de3ef4a191e74729df53d2aa0..34cd292a8ef863eeea3294f3ca46dad9f6df349b 100644 (file)
@@ -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
index 8067cf1ad422b1776ec4c71c798faca64feecc7d..77a1e770b1863aba48485ab132fc11e1f0f18c1f 100644 (file)
@@ -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 (file)
index 2987f78..0000000
+++ /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 (file)
index 0000000..9b1b472
--- /dev/null
@@ -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;
+}
index ca98d4fe11ad7311a1b7f1e6d83bf74d585bcc9b..cd5b568feb639f1a98dd49ca35ebfbd7997ce201 100644 (file)
@@ -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
index b1886ae1268802c1011b31ccdfe6ebdcb671e3b4..78743d6ed483039056d23f47bc76ab01f05be175 100644 (file)
@@ -1,3 +1,5 @@
+#pragma once
+
 /*
  Copyright (C) 2015 Micah Talkiewicz.
 
index f0729460e5984ec6bcdb14b3bca21df21f40949a..b411db855b08bc29cd198b425c7a8d1ddd019e05 100644 (file)
@@ -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
index 5b7fb0d3cce723e58d9b7ca4ecb27edde91d9542..1834a97a331164086464ce6ecc87d0527971fb9a 100644 (file)
@@ -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
index 8f0d0740e20ffe35dce32696bb4db01c60365959..8c0eed0ed0a930630db1f26ffb665113f838aa2a 100644 (file)
@@ -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
index 14e4dbc3cc60e5a006985fb578ed7f7788609afd..6c947d7c5db192d390eab5d9b3616e190af37f56 100644 (file)
@@ -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
index a7b854cd17d446d8263199629358aa19c1b8baa1..eae9a6e6f1389a531d5b5c09a35f241cce8ff11a 100644 (file)
@@ -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
index 743214ab5f48f75dc635fac62dea992cbedf31b8..99bea5be7cd7ca5b0b8bc02963e4398d9ca0755c 100644 (file)
@@ -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
index 32ae28112f16b98805789a1ee85aa9a8b5705f0e..4313954cdc91c9a8497339d12af4dcaead45b665 100644 (file)
@@ -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
index eb8103f8fd51e8c8d7b185f3cd9a87fec4ce2b1b..af4b47ab8058ad35a8f8b6405538cc3f4ed32a31 100644 (file)
@@ -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
index ce3c512c1d4cbed378fd2e9397a2356836e7ac7a..7938bacde4d75014b729019305f1afa25e9a63fd 100644 (file)
@@ -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
index 534c2de02131cc3dc2737db2add776978bc192aa..e1cfeb8721ce54f6b29a9f440e410d2c29bf5626 100644 (file)
@@ -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
index 3f258df52d69e7b2288722d7161e78c9254ba679..ea7671a1cd6a6bb81a77c8112a7e0360b999c568 100644 (file)
@@ -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
index ef1c00c62c3c5c0d2714327f8d649b16120fc5ef..8a984d67e4c7a54af18c69a2ddeb5028ee5119c9 100644 (file)
@@ -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
index bce19f4fd674e807cc0ee4beb749ddf80ec4c3dd..3caf8aaf5717ff3d413e26af362b0aeab7497eba 100644 (file)
@@ -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
index 2f4f2dee5a429a4bd203ad6d5ba0cfc26c142d9f..77e1f52ee8ddca200f90d5d33deed2a155f99263 100644 (file)
@@ -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
index 6b4db2f1ac2a27bbac257bcda3a47f9a921ff5ec..e506ea51891d1137a8abb55a595a1a90c1065034 100644 (file)
@@ -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
index 918504ff8b64fdc44a168b7e1aae026fa5d83124..8746409405c6f8cc96fb3d6caf6bfd833efd4d0e 100644 (file)
@@ -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
index 8a63ae9b1252dfa8352f9ab5b11b09f31ebb76b1..cdfe739a09a6de9c6f4e19c74e74af7085bc7812 100644 (file)
@@ -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
index 34cf0635d5876359eea555a4f7d90da31dbdf018..c91db98f68143986a94fdb145cfa745cbcf945fa 100644 (file)
@@ -1,5 +1,4 @@
-#ifndef YENC_H
-#define YENC_H
+#pragma once
 
 #include "test.qh"
 
@@ -64,5 +63,3 @@ TEST(yEncDec)
        }
        TEST_OK();
 }
-
-#endif