3 #define GETTIME_REALTIME 1
5 float(int tmr) _gettime = #67;
7 float(int tmr) _gettime = #519;
11 void profile(string s)
13 static float g_starttime;
14 float rt = _gettime(GETTIME_REALTIME);
15 if (!g_starttime) { g_starttime = rt; }
16 LOG_TRACEF("[%f] %s", rt - g_starttime, s);
19 #define _STATIC_INIT(func, where) \
20 [[accumulate]] void _static_##func() \
24 ACCUMULATE_FUNCTION(where, _static_##func) \
27 /** before worldspawn */
28 #define STATIC_INIT_EARLY(func) _STATIC_INIT(func##_0, __static_init_0)
29 #define static_init_early() CALL_ACCUMULATED_FUNCTION(__static_init_0)
30 void __static_init_0() {}
32 /** during worldspawn */
33 #define STATIC_INIT(func) _STATIC_INIT(func##_1, __static_init_1)
34 #define static_init() CALL_ACCUMULATED_FUNCTION(__static_init_1)
35 void __static_init_1() {}
37 /** directly after STATIC_INIT */
38 #define STATIC_INIT_LATE(func) _STATIC_INIT(func##_2, __static_init_2)
39 #define static_init_late() CALL_ACCUMULATED_FUNCTION(__static_init_2)
40 void __static_init_2() {}
42 /** directly after STATIC_INIT_LATE */
43 #define PRECACHE(func) _STATIC_INIT(func##_3, __static_init_3)
44 #define static_init_precache() CALL_ACCUMULATED_FUNCTION(__static_init_3)
45 void __static_init_3() {}
47 /* other map entities spawn now */
49 /** before shutdown */
50 #define SHUTDOWN(func) _STATIC_INIT(func##_shutdown, __shutdown)
51 #define shutdownhooks() CALL_ACCUMULATED_FUNCTION(__shutdown)