]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/static.qh
Remove .move_* fields and MOVETYPE_PUSH logic (doesn't work)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / static.qh
1 #pragma once
2
3 void __static_init() {}
4 #define static_init() CALL_ACCUMULATED_FUNCTION(__static_init)
5 void __static_init_late() {}
6 #define static_init_late() CALL_ACCUMULATED_FUNCTION(__static_init_late)
7 void __static_init_precache() {}
8 #define static_init_precache() CALL_ACCUMULATED_FUNCTION(__static_init_precache)
9 void __shutdown() {}
10 #define shutdownhooks() CALL_ACCUMULATED_FUNCTION(__shutdown)
11
12 #define GETTIME_REALTIME 1
13 #ifdef MENUQC
14 float(int tmr) _gettime = #67;
15 #else
16 float(int tmr) _gettime = #519;
17 #endif
18
19 void profile(string s)
20 {
21         static float g_starttime;
22         float rt = _gettime(GETTIME_REALTIME);
23         if (!g_starttime) g_starttime = rt;
24         LOG_TRACEF("[%f] %s", rt - g_starttime, s);
25 }
26
27 #define _STATIC_INIT(where, func) \
28         [[accumulate]] void _static_##func() { profile(#func); } \
29         ACCUMULATE_FUNCTION(where, _static_##func) \
30         void _static_##func()
31
32 #define STATIC_INIT(func) _STATIC_INIT(__static_init,           func)
33 #define STATIC_INIT_LATE(func) _STATIC_INIT(__static_init_late, func##_late)
34 #define PRECACHE(func) _STATIC_INIT(__static_init_precache,     func##_precache)
35 #define SHUTDOWN(func) _STATIC_INIT(__shutdown,                         func##_shutdown)