X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Flib%2Fspawnfunc.qh;h=884714e3596928e9ef334c5d0efd711d21e76cf4;hp=e30e565fd3259a6916d36d5c230d7165bae4dd1c;hb=d865de7a9a17c5a1d9286aec40f68c3530697660;hpb=c89e099b706d9c07b2ce49fd267c0f35f06f2146 diff --git a/qcsrc/lib/spawnfunc.qh b/qcsrc/lib/spawnfunc.qh index e30e565fd..884714e35 100644 --- a/qcsrc/lib/spawnfunc.qh +++ b/qcsrc/lib/spawnfunc.qh @@ -36,6 +36,10 @@ noref bool require_spawnfunc_prefix; #define SPAWNFUNC_INTERNAL_FIELDS(X) \ X(string, classname, "spawnfunc") \ + X(string, target, string_null) \ + X(string, target2, string_null) \ + X(string, target3, string_null) \ + X(string, target4, string_null) \ X(string, targetname, string_null) \ /**/ @@ -57,7 +61,9 @@ noref bool require_spawnfunc_prefix; g_map_entities = IL_NEW(); \ IL_EACH(g_spawn_queue, true, __spawnfunc_spawn(it)); \ MACRO_END - +#ifdef SVQC + void _SV_OnEntityPreSpawnFunction(entity this); +#endif void __spawnfunc_spawn(entity prototype) { entity e = new(clone); @@ -66,14 +72,26 @@ noref bool require_spawnfunc_prefix; #define X(T, fld, def) { e.fld = e.__spawnfunc_##fld; e.__spawnfunc_##fld = def; } SPAWNFUNC_INTERNAL_FIELDS(X); #undef X +#ifdef SVQC + _SV_OnEntityPreSpawnFunction(e); + if (wasfreed(e)) { + return; + } +#endif e.__spawnfunc_constructor(e); } + noref bool __spawnfunc_first; + #define spawnfunc_1(id) spawnfunc_2(id, FIELDS_UNION) #define spawnfunc_2(id, whitelist) \ void __spawnfunc_##id(entity this); \ [[accumulate]] void spawnfunc_##id(entity this) \ { \ + if (!__spawnfunc_first) { \ + __spawnfunc_first = true; \ + static_init_early(); \ + } \ bool dospawn = true; \ if (__spawnfunc_expecting > 1) { __spawnfunc_expecting = false; } \ else if (__spawnfunc_expecting) { \