X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fstatic.qh;h=e1879890e8521dfe9c5173c209aee501c89da628;hb=640ba835e8cbe803fe66ec0e4c8457b91db6ad27;hp=6b5febe6fbfcab9909de383b4d7ccd86940474d6;hpb=4f133bdb70d13143f2ce4b9de097744371c1f92a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/static.qh b/qcsrc/lib/static.qh index 6b5febe6f..e1879890e 100644 --- a/qcsrc/lib/static.qh +++ b/qcsrc/lib/static.qh @@ -1,14 +1,5 @@ #pragma once -void __static_init() {} -#define static_init() CALL_ACCUMULATED_FUNCTION(__static_init) -void __static_init_late() {} -#define static_init_late() CALL_ACCUMULATED_FUNCTION(__static_init_late) -void __static_init_precache() {} -#define static_init_precache() CALL_ACCUMULATED_FUNCTION(__static_init_precache) -void __shutdown() {} -#define shutdownhooks() CALL_ACCUMULATED_FUNCTION(__shutdown) - #define GETTIME_REALTIME 1 #ifdef MENUQC float(int tmr) _gettime = #67; @@ -16,6 +7,7 @@ float(int tmr) _gettime = #67; float(int tmr) _gettime = #519; #endif +ERASEABLE void profile(string s) { static float g_starttime; @@ -24,12 +16,36 @@ void profile(string s) LOG_TRACEF("[%f] %s", rt - g_starttime, s); } -#define _STATIC_INIT(where, func) \ - [[accumulate]] void _static_##func() { profile(#func); } \ +#define _STATIC_INIT(func, where) \ + /* ACCUMULATE void _static_##func##profile() { profile(#func); } */ \ + /* ACCUMULATE_FUNCTION(where, _static_##func##profile) */ \ + ACCUMULATE void _static_##func(); \ ACCUMULATE_FUNCTION(where, _static_##func) \ void _static_##func() -#define STATIC_INIT(func) _STATIC_INIT(__static_init, func) -#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) +/** before worldspawn */ +#define STATIC_INIT_EARLY(func) _STATIC_INIT(func##_0, __static_init_0) +#define static_init_early() CALL_ACCUMULATED_FUNCTION(__static_init_0) +void __static_init_0() {} + +/** during worldspawn */ +#define STATIC_INIT(func) _STATIC_INIT(func##_1, __static_init_1) +#define static_init() CALL_ACCUMULATED_FUNCTION(__static_init_1) +void __static_init_1() {} + +/** directly after STATIC_INIT */ +#define STATIC_INIT_LATE(func) _STATIC_INIT(func##_2, __static_init_2) +#define static_init_late() CALL_ACCUMULATED_FUNCTION(__static_init_2) +void __static_init_2() {} + +/** directly after STATIC_INIT_LATE */ +#define PRECACHE(func) _STATIC_INIT(func##_3, __static_init_3) +#define static_init_precache() CALL_ACCUMULATED_FUNCTION(__static_init_3) +void __static_init_3() {} + +/* other map entities spawn now */ + +/** before shutdown */ +#define SHUTDOWN(func) _STATIC_INIT(func##_shutdown, __shutdown) +#define shutdownhooks() CALL_ACCUMULATED_FUNCTION( __shutdown) +void __shutdown() {}