From: TimePath Date: Sat, 16 Sep 2017 04:34:54 +0000 (+1000) Subject: spawnfuncs: fix SV_OnEntityPreSpawnFunction X-Git-Tag: xonotic-v0.8.5~2472 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=62b8cc388e7bcfd405efd1708f2149dcb252baae;p=xonotic%2Fxonotic-data.pk3dir.git spawnfuncs: fix SV_OnEntityPreSpawnFunction --- diff --git a/qcsrc/lib/_all.inc b/qcsrc/lib/_all.inc index 9d5820910..d44c5e89c 100644 --- a/qcsrc/lib/_all.inc +++ b/qcsrc/lib/_all.inc @@ -241,7 +241,8 @@ void make_safe_for_remove(entity this); void SV_OnEntityPreSpawnFunction() { ENGINE_EVENT(); - if (_SV_OnEntityPreSpawnFunction) _SV_OnEntityPreSpawnFunction(this); + __spawnfunc_expecting = true; + __spawnfunc_expect = this; } #define SV_OnEntityPreSpawnFunction _SV_OnEntityPreSpawnFunction diff --git a/qcsrc/lib/spawnfunc.qh b/qcsrc/lib/spawnfunc.qh index 4638bca2d..f1eb477a0 100644 --- a/qcsrc/lib/spawnfunc.qh +++ b/qcsrc/lib/spawnfunc.qh @@ -57,7 +57,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,6 +68,12 @@ 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); } diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index 68e7b375b..18706028f 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -320,8 +320,6 @@ bool expr_evaluate(string s) void SV_OnEntityPreSpawnFunction(entity this) { - __spawnfunc_expecting = true; - __spawnfunc_expect = this; if (this) if (this.gametypefilter != "") if (!isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, this.gametypefilter)) @@ -363,7 +361,6 @@ void SV_OnEntityPreSpawnFunction(entity this) return; LABEL(cleanup) builtin_remove(this); - __spawnfunc_expecting = false; } void WarpZone_PostInitialize_Callback()