15 bool entityfieldassignablefromeditor(
int i)
17 switch (entityfieldtype(i))
27 #define _spawnfunc_checktypes(fld) \
29 if (!entityfieldassignablefromeditor(i)) \
30 LOG_FATALF("Entity field '%s' cannot be whitelisted", s);
32 #define _spawnfunc_checktypes(fld)
34 #define _spawnfunc_check(fld) \
42 .void(
entity) __spawnfunc_constructor;
45 #define SPAWNFUNC_INTERNAL_FIELDS(X) \
46 X(string, classname, "spawnfunc") \
47 X(string, target, string_null) \
48 X(string, target2, string_null) \
49 X(string, target3, string_null) \
50 X(string, target4, string_null) \
51 X(string, targetname, string_null) \
54 #define X(T, fld, def) .T fld, __spawnfunc_##fld;
61 #define X(T, fld, def) \
63 prototype.__spawnfunc_##fld = prototype.fld; \
64 prototype.fld = def; \
68 prototype.__spawnfunc_constructor = constructor;
72 #define __spawnfunc_spawn_all() MACRO_BEGIN \
73 g_map_entities = IL_NEW(); \
74 IL_EACH(g_spawn_queue, true, __spawnfunc_spawn(it)); \
84 #define X(T, fld, def) \
86 e.fld = e.__spawnfunc_##fld; \
87 e.__spawnfunc_##fld = def; \
96 e.__spawnfunc_constructor(e);
107#define spawnfunc(id) \
108 void __spawnfunc_##id(entity this); \
109 ACCUMULATE void spawnfunc_##id(entity this) \
111 if (!__spawnfunc_first) \
113 __spawnfunc_first = true; \
114 static_init_early(); \
116 bool dospawn = true; \
117 if (__spawnfunc_expecting > 1) \
118 __spawnfunc_expecting = 0; \
119 else if (__spawnfunc_expecting) \
122 if (!g_spawn_queue) \
123 g_spawn_queue_spawn(); \
124 __spawnfunc_expecting = 0; \
125 this = __spawnfunc_expect; \
126 __spawnfunc_expect = NULL; \
132 if (!this.sourceLoc) \
133 this.sourceLoc = __FILE__":"STR(__LINE__); \
134 this.classname = #id; \
135 if (!this.spawnfunc_checked) \
137 if (__fullspawndata) \
140 this.fullspawndata = __fullspawndata; \
141 this.spawnfunc_checked = true; \
146 this.think = func_null; \
147 this.nextthink = 0; \
148 __spawnfunc_defer(this, __spawnfunc_##id); \
152 this.__spawnfunc_constructor = __spawnfunc_##id; \
155 __spawnfunc_##id(this); \
156 if (__spawnfunc_unreachable_workaround) \
159 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()
This function simply avoids expanding IL_NEW during compilation for each spawning entity.
#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