]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/static.qh
Clean up monster direction checking code a bit more
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / static.qh
index 49ce802e90f0bb376366e522c0139be3f51600b6..6b5febe6fbfcab9909de383b4d7ccd86940474d6 100644 (file)
@@ -1,19 +1,35 @@
-#ifndef STATIC_H
-#define STATIC_H
+#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 REGISTER_REGISTRY(func) ACCUMULATE_FUNCTION(__static_init, func)
+#define GETTIME_REALTIME 1
+#ifdef MENUQC
+float(int tmr) _gettime = #67;
+#else
+float(int tmr) _gettime = #519;
+#endif
+
+void profile(string s)
+{
+       static float g_starttime;
+       float rt = _gettime(GETTIME_REALTIME);
+       if (!g_starttime) g_starttime = rt;
+       LOG_TRACEF("[%f] %s", rt - g_starttime, s);
+}
 
 #define _STATIC_INIT(where, func) \
-       void _static_##func(); \
+       [[accumulate]] void _static_##func() { profile(#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)
-
-#endif
+#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)