]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/spawnfunc.qh
Clean out self from wr_checkammo1 & wr_checkammo2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / spawnfunc.qh
index 75f56a23d01fbaafb70140067e53088670b5748a..22047bbc9daac0d285478015cbecbcf14ceb6303 100644 (file)
@@ -1,5 +1,4 @@
-#ifndef SPAWNFUNC_H
-#define SPAWNFUNC_H
+#pragma once
 
 /** If this global exists, only functions with spawnfunc_ name prefix qualify as spawn functions */
 noref bool require_spawnfunc_prefix;
@@ -28,6 +27,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,11 +35,19 @@ noref bool require_spawnfunc_prefix;
                void __spawnfunc_##id(entity this); \
                [[accumulate]] void spawnfunc_##id(entity this) \
                { \
-                       this = self; \
-                       if (!this.sourceLocFile) \
+                       if (__self == __spawnfunc_expect) \
                        { \
-                               this.sourceLocFile = __FILE__; \
-                               this.sourceLocLine = __LINE__; \
+                               /* engine call */ \
+                               __spawnfunc_expect = NULL; \
+                               this = __self; \
+                       } \
+                       else \
+                       { \
+                               assert(this); \
+                       } \
+                       if (!this.sourceLoc) \
+                       { \
+                               this.sourceLoc = __FILE__ ":" STR(__LINE__); \
                        } \
                        if (!this.spawnfunc_checked) \
                        { \
@@ -74,12 +82,12 @@ noref bool require_spawnfunc_prefix;
 
        #define FIELDS_COMMON(fld) \
                FIELD_SCALAR(fld, classname) \
+               FIELD_SCALAR(fld, sourceLoc) \
                FIELD_SCALAR(fld, spawnfunc_checked) \
+               FIELD_VEC(fld, origin) \
                /**/
 
        #define FIELDS_UNION(fld) \
-               FIELD_SCALAR(fld, sourceLocFile) \
-               FIELD_SCALAR(fld, sourceLocLine) \
                FIELD_SCALAR(fld, Version) \
                FIELD_SCALAR(fld, ammo_cells) \
                FIELD_SCALAR(fld, ammo_nails) \
@@ -130,7 +138,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) \
@@ -142,6 +152,7 @@ noref bool require_spawnfunc_prefix;
                FIELD_SCALAR(fld, platmovetype) \
                FIELD_SCALAR(fld, race_place) \
                FIELD_SCALAR(fld, radius) \
+               FIELD_SCALAR(fld, respawntimestart) \
                FIELD_SCALAR(fld, respawntimejitter) \
                FIELD_SCALAR(fld, respawntime) \
                FIELD_SCALAR(fld, restriction) \
@@ -177,10 +188,8 @@ noref bool require_spawnfunc_prefix;
                FIELD_VEC(fld, maxs) \
                FIELD_VEC(fld, mins) \
                FIELD_VEC(fld, modelscale_vec) \
-               FIELD_VEC(fld, origin) \
                FIELD_VEC(fld, velocity) \
                /**/
 
-       #define spawnfunc(...) EVAL(OVERLOAD(spawnfunc, __VA_ARGS__))
-
-#endif
+       #define spawnfunc(...) EVAL_spawnfunc(OVERLOAD(spawnfunc, __VA_ARGS__))
+       #define EVAL_spawnfunc(...) __VA_ARGS__