15 bool entityfieldassignablefromeditor(
int i)
17 switch (entityfieldtype(i))
27 #define _spawnfunc_checktypes(fld) \
29 if (!entityfieldassignablefromeditor(i)) LOG_FATALF("Entity field '%s' cannot be whitelisted", s);
31 #define _spawnfunc_checktypes(fld)
33 #define _spawnfunc_check(fld) \
34 if (s == #fld) continue;
40 .void(
entity) __spawnfunc_constructor;
43 #define SPAWNFUNC_INTERNAL_FIELDS(X) \
44 X(string, classname, "spawnfunc") \
45 X(string, target, string_null) \
46 X(string, target2, string_null) \
47 X(string, target3, string_null) \
48 X(string, target4, string_null) \
49 X(string, targetname, string_null) \
52 #define X(T, fld, def) .T fld, __spawnfunc_##fld;
59 #define X(T, fld, def) { prototype.__spawnfunc_##fld = prototype.fld; prototype.fld = def; }
62 prototype.__spawnfunc_constructor = constructor;
66 #define __spawnfunc_spawn_all() MACRO_BEGIN \
67 g_map_entities = IL_NEW(); \
68 IL_EACH(g_spawn_queue, true, __spawnfunc_spawn(it)); \
78 #define X(T, fld, def) { e.fld = e.__spawnfunc_##fld; e.__spawnfunc_##fld = def; }
87 e.__spawnfunc_constructor(e);
96#define spawnfunc(id) \
97 void __spawnfunc_##id(entity this); \
98 ACCUMULATE void spawnfunc_##id(entity this) \
100 if (!__spawnfunc_first) { \
101 __spawnfunc_first = true; \
102 static_init_early(); \
104 bool dospawn = true; \
105 if (__spawnfunc_expecting > 1) { __spawnfunc_expecting = 0; } \
106 else if (__spawnfunc_expecting) { \
108 if (!g_spawn_queue) g_spawn_queue_spawn(); \
109 __spawnfunc_expecting = 0; \
110 this = __spawnfunc_expect; \
111 __spawnfunc_expect = NULL; \
117 if (!this.sourceLoc) { \
118 this.sourceLoc = __FILE__":"STR(__LINE__); \
120 this.classname = #id; \
121 if (!this.spawnfunc_checked) { \
122 if (__fullspawndata) { \
125 this.fullspawndata = __fullspawndata; \
127 this.spawnfunc_checked = true; \
131 this.think = func_null; \
132 this.nextthink = 0; \
133 __spawnfunc_defer(this, __spawnfunc_##id); \
136 this.__spawnfunc_constructor = __spawnfunc_##id; \
139 if (dospawn) { __spawnfunc_##id(this); } \
140 if (__spawnfunc_unreachable_workaround) return; \
142 void __spawnfunc_##id(entity this)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
limitations: NULL cannot be present elements can only be present once a maximum of IL_MAX lists can e...
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
void copyentity_qc(entity src, entity dst)
noref IntrusiveList g_map_entities
void g_spawn_queue_spawn()
#define SPAWNFUNC_INTERNAL_FIELDS(X)
noref bool __spawnfunc_first
noref string __fullspawndata
Not for production use, provides access to a dump of the entity's fields when it is parsed from map d...
void __spawnfunc_spawn(entity prototype)
noref bool __spawnfunc_unreachable_workaround
void _SV_OnEntityPreSpawnFunction(entity this)
void __spawnfunc_defer(entity prototype, void(entity) constructor)
noref entity __spawnfunc_expect
noref bool require_spawnfunc_prefix
If this global exists, only functions with spawnfunc_ name prefix qualify as spawn functions.
noref IntrusiveList g_spawn_queue
noref int __spawnfunc_expecting