]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/spawnfunc.qh
Add minor optimizations and comments
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / spawnfunc.qh
index 5c1cfac379a440723d76e44b1f842fdf36706039..db0d83ead7d2ff2ab26db36a57b03d373633f81b 100644 (file)
@@ -251,6 +251,10 @@ void _checkWhitelisted(entity this, string id)
        }
 }
 
+// this function simply avoids expanding IL_NEW during compilation
+// for each spawning entity
+void g_spawn_queue_spawn() { g_spawn_queue = IL_NEW(); }
+
 noref bool __spawnfunc_first;
 
 #define spawnfunc(id) \
@@ -265,7 +269,7 @@ noref bool __spawnfunc_first;
                if (__spawnfunc_expecting > 1) { __spawnfunc_expecting = 0; } \
                else if (__spawnfunc_expecting) { \
                        /* engine call */ \
-                       if (!g_spawn_queue) { g_spawn_queue = IL_NEW(); } \
+                       if (!g_spawn_queue) g_spawn_queue_spawn(); \
                        __spawnfunc_expecting = 0; \
                        this = __spawnfunc_expect; \
                        __spawnfunc_expect = NULL; \
@@ -283,6 +287,9 @@ noref bool __spawnfunc_first;
                        this.spawnfunc_checked = true; \
                        if (this) { \
                                /* not worldspawn, delay spawn */ \
+                               /* clear some dangerous fields (TODO: properly support these in the map!) */ \
+                               this.think = func_null; \
+                               this.nextthink = 0; \
                                __spawnfunc_defer(this, __spawnfunc_##id); \
                        } else { \
                                /* world might not be "worldspawn" */ \