]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/spawnfunc.qh
Remove uses of WITHSELF
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / spawnfunc.qh
index ef0d68f008d2cdc66b0ab2a1c815df416521f996..0463979c1a3fb855c3245360ffcb3be7f4387a6a 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 bool __spawnfunc_expecting;
        noref entity __spawnfunc_expect;
        bool __spawnfunc_unreachable_workaround = true;
 
@@ -36,20 +36,20 @@ noref bool require_spawnfunc_prefix;
                void __spawnfunc_##id(entity this); \
                [[accumulate]] void spawnfunc_##id(entity this) \
                { \
-                       if (self == __spawnfunc_expect) \
+                       if (__spawnfunc_expecting) \
                        { \
                                /* engine call */ \
+                               __spawnfunc_expecting = false; \
+                               this = __spawnfunc_expect; \
                                __spawnfunc_expect = NULL; \
-                               this = self; \
                        } \
                        else \
                        { \
                                assert(this); \
                        } \
-                       if (!this.sourceLocFile) \
+                       if (!this.sourceLoc) \
                        { \
-                               this.sourceLocFile = __FILE__; \
-                               this.sourceLocLine = __LINE__; \
+                               this.sourceLoc = __FILE__ ":" STR(__LINE__); \
                        } \
                        if (!this.spawnfunc_checked) \
                        { \
@@ -84,12 +84,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) \
@@ -154,6 +154,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) \
@@ -189,10 +190,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__