]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
spawnfuncs: fix SV_OnEntityPreSpawnFunction
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 16 Sep 2017 04:34:54 +0000 (14:34 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 16 Sep 2017 04:34:54 +0000 (14:34 +1000)
qcsrc/lib/_all.inc
qcsrc/lib/spawnfunc.qh
qcsrc/server/sv_main.qc

index 9d582091039faa12ac2028efeb9022357be3a631..d44c5e89cdda2acacbd1b615bfbc55dc8bb93b9f 100644 (file)
@@ -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
 
index 4638bca2d490544d8881d0e1507cfe048c7f7607..f1eb477a00195188c942ca3f7d5ce6b889343d1a 100644 (file)
@@ -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);
     }
 
index 68e7b375b507a09051f3607114f60d14cd9da0f2..18706028fcec4dbf8a7ade0c898355e90b2b90dd 100644 (file)
@@ -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()