X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fspawnfunc.qh;h=db0d83ead7d2ff2ab26db36a57b03d373633f81b;hb=b5c2004edc3d7e620e24283b1e3fe4d2396cd357;hp=5c1cfac379a440723d76e44b1f842fdf36706039;hpb=ad464bb5417768682f9989dd025871d14a438e68;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/spawnfunc.qh b/qcsrc/lib/spawnfunc.qh index 5c1cfac37..db0d83ead 100644 --- a/qcsrc/lib/spawnfunc.qh +++ b/qcsrc/lib/spawnfunc.qh @@ -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" */ \