]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/spawnfunc.qh
Monsters: resolve assertion failures
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / spawnfunc.qh
index 75f56a23d01fbaafb70140067e53088670b5748a..ef0d68f008d2cdc66b0ab2a1c815df416521f996 100644 (file)
@@ -28,6 +28,7 @@ noref bool require_spawnfunc_prefix;
        #define _spawnfunc_check(fld) \
                if (fieldname == #fld) continue;
 
+       noref entity __spawnfunc_expect;
        bool __spawnfunc_unreachable_workaround = true;
 
        #define spawnfunc_1(id) spawnfunc_2(id, FIELDS_UNION)
@@ -35,7 +36,16 @@ noref bool require_spawnfunc_prefix;
                void __spawnfunc_##id(entity this); \
                [[accumulate]] void spawnfunc_##id(entity this) \
                { \
-                       this = self; \
+                       if (self == __spawnfunc_expect) \
+                       { \
+                               /* engine call */ \
+                               __spawnfunc_expect = NULL; \
+                               this = self; \
+                       } \
+                       else \
+                       { \
+                               assert(this); \
+                       } \
                        if (!this.sourceLocFile) \
                        { \
                                this.sourceLocFile = __FILE__; \
@@ -130,7 +140,9 @@ noref bool require_spawnfunc_prefix;
                FIELD_SCALAR(fld, modelindex) \
                FIELD_SCALAR(fld, modelscale) \
                FIELD_SCALAR(fld, model) \
+               FIELD_SCALAR(fld, monsterid) \
                FIELD_SCALAR(fld, monster_moveflags) \
+               FIELD_SCALAR(fld, monster_name) \
                FIELD_SCALAR(fld, movetype) \
                FIELD_SCALAR(fld, netname) \
                FIELD_SCALAR(fld, nextthink) \