]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/spawnfunc.qh
Resolve conflicts 1: Merge commit 'c58baab5' into bones_was_here/q3compat
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / spawnfunc.qh
index 37bb11768c87022e1e698137a420c6307e1bce8c..7e8c025a2a3100b1f338fc2c153e038c856f2379 100644 (file)
@@ -6,6 +6,9 @@
 /** If this global exists, only functions with spawnfunc_ name prefix qualify as spawn functions */
 noref bool require_spawnfunc_prefix;
 .bool spawnfunc_checked;
+/** Not for production use, provides access to a dump of the entity's fields when it is parsed from map data */
+noref string __fullspawndata;
+.string fullspawndata;
 
 // Optional type checking; increases compile time too much to be enabled by default
 #if 0
@@ -146,14 +149,18 @@ noref bool require_spawnfunc_prefix;
                FIELD_SCALAR(fld, health) \
                FIELD_SCALAR(fld, height) \
                FIELD_SCALAR(fld, impulse) \
+               FIELD_SCALAR(fld, invincible_finished) \
+               FIELD_SCALAR(fld, item_pickupsound) \
                FIELD_SCALAR(fld, killtarget) \
                FIELD_SCALAR(fld, lerpfrac) \
                FIELD_SCALAR(fld, light_lev) \
                FIELD_SCALAR(fld, lip) \
                FIELD_SCALAR(fld, loddistance1) \
                FIELD_SCALAR(fld, lodmodel1) \
+               FIELD_SCALAR(fld, lodmodel2) \
                FIELD_SCALAR(fld, ltime) \
                FIELD_SCALAR(fld, map) \
+               FIELD_SCALAR(fld, max_health) \
                FIELD_SCALAR(fld, mdl) \
                FIELD_SCALAR(fld, message2) \
                FIELD_SCALAR(fld, message) \
@@ -172,9 +179,15 @@ noref bool require_spawnfunc_prefix;
                FIELD_SCALAR(fld, noise2) \
                FIELD_SCALAR(fld, noise3) \
                FIELD_SCALAR(fld, noise) \
+               FIELD_SCALAR(fld, notcpm) \
+               FIELD_SCALAR(fld, notfree) \
+               FIELD_SCALAR(fld, notta) \
+               FIELD_SCALAR(fld, notteam) \
+               FIELD_SCALAR(fld, notvq3) \
                FIELD_SCALAR(fld, phase) \
                FIELD_SCALAR(fld, platmovetype) \
                FIELD_SCALAR(fld, race_place) \
+               FIELD_SCALAR(fld, strength_finished) \
                FIELD_SCALAR(fld, radius) \
                FIELD_SCALAR(fld, respawntimestart) \
                FIELD_SCALAR(fld, respawntimejitter) \
@@ -199,8 +212,12 @@ noref bool require_spawnfunc_prefix;
                FIELD_SCALAR(fld, target_range) \
                FIELD_SCALAR(fld, team) \
                FIELD_SCALAR(fld, trigger_reverse) \
+               FIELD_SCALAR(fld, turret_scale_aim) \
+               FIELD_SCALAR(fld, turret_scale_ammo) \
+               FIELD_SCALAR(fld, turret_scale_damage) \
                FIELD_SCALAR(fld, turret_scale_health) \
                FIELD_SCALAR(fld, turret_scale_range) \
+               FIELD_SCALAR(fld, turret_scale_refire) \
                FIELD_SCALAR(fld, turret_scale_respawn) \
                FIELD_SCALAR(fld, volume) \
                FIELD_SCALAR(fld, wait) \
@@ -240,6 +257,10 @@ void _checkWhitelisted(entity this, string id)
        }
 }
 
+// this function simply avoids expanding IL_NEW during compilation
+// for each spawning entity
+void g_spawn_queue_spawn() { g_spawn_queue = IL_NEW(); }
+
 noref bool __spawnfunc_first;
 
 #define spawnfunc(id) \
@@ -254,7 +275,7 @@ noref bool __spawnfunc_first;
                if (__spawnfunc_expecting > 1) { __spawnfunc_expecting = 0; } \
                else if (__spawnfunc_expecting) { \
                        /* engine call */ \
-                       if (!g_spawn_queue) { g_spawn_queue = IL_NEW(); } \
+                       if (!g_spawn_queue) g_spawn_queue_spawn(); \
                        __spawnfunc_expecting = 0; \
                        this = __spawnfunc_expect; \
                        __spawnfunc_expect = NULL; \
@@ -264,13 +285,22 @@ noref bool __spawnfunc_first;
                        assert(this); \
                } \
                if (!this.sourceLoc) { \
-                       this.sourceLoc = __FILE__ ":" STR(__LINE__); \
+                       this.sourceLoc = __FILE__":"STR(__LINE__); \
                } \
+               this.classname = #id; \
                if (!this.spawnfunc_checked) { \
                        _checkWhitelisted(this, #id); \
+                       if (__fullspawndata) { \
+                               /* not supported in old DP */ \
+                               /* must be read inside the real spawnfunc */ \
+                               this.fullspawndata = __fullspawndata; \
+                       } \
                        this.spawnfunc_checked = true; \
                        if (this) { \
                                /* not worldspawn, delay spawn */ \
+                               /* clear some dangerous fields (TODO: properly support these in the map!) */ \
+                               this.think = func_null; \
+                               this.nextthink = 0; \
                                __spawnfunc_defer(this, __spawnfunc_##id); \
                        } else { \
                                /* world might not be "worldspawn" */ \