Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
spawnfunc.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __spawnfunc_spawn_all()
#define _spawnfunc_check(fld)
#define _spawnfunc_checktypes(fld)
#define spawnfunc(id)
#define SPAWNFUNC_INTERNAL_FIELDS(X)
#define X(T, fld, def)
#define X(T, fld, def)
#define X(T, fld, def)

Functions

void __spawnfunc_defer (entity prototype, void(entity) constructor)
void __spawnfunc_spawn (entity prototype)
void _SV_OnEntityPreSpawnFunction (entity this)
void g_spawn_queue_spawn ()
 void (entity) __spawnfunc_constructor

Variables

noref string __fullspawndata
 Not for production use, provides access to a dump of the entity's fields when it is parsed from map data.
noref entity __spawnfunc_expect
noref int __spawnfunc_expecting
noref bool __spawnfunc_first
noref bool __spawnfunc_unreachable_workaround = true
string fullspawndata
noref IntrusiveList g_map_entities
noref IntrusiveList g_spawn_queue
noref bool require_spawnfunc_prefix
 If this global exists, only functions with spawnfunc_ name prefix qualify as spawn functions.
bool spawnfunc_checked

Macro Definition Documentation

◆ __spawnfunc_spawn_all

#define __spawnfunc_spawn_all ( )
Value:
MACRO_BEGIN \
g_map_entities = IL_NEW(); \
IL_EACH(g_spawn_queue, true, __spawnfunc_spawn(it)); \
#define IL_NEW()
#define MACRO_END
Definition macro.qh:7
void __spawnfunc_spawn(entity prototype)
Definition spawnfunc.qh:73
noref IntrusiveList g_spawn_queue
Definition spawnfunc.qh:41

Definition at line 66 of file spawnfunc.qh.

66 #define __spawnfunc_spawn_all() MACRO_BEGIN \
67 g_map_entities = IL_NEW(); \
68 IL_EACH(g_spawn_queue, true, __spawnfunc_spawn(it)); \
69 MACRO_END

Referenced by spawnfunc().

◆ _spawnfunc_check

#define _spawnfunc_check ( fld)
Value:
if (s == #fld) continue;

Definition at line 33 of file spawnfunc.qh.

33 #define _spawnfunc_check(fld) \
34 if (s == #fld) continue;

◆ _spawnfunc_checktypes

#define _spawnfunc_checktypes ( fld)

Definition at line 31 of file spawnfunc.qh.

◆ spawnfunc

#define spawnfunc ( id)

Definition at line 96 of file spawnfunc.qh.

96#define spawnfunc(id) \
97 void __spawnfunc_##id(entity this); \
98 ACCUMULATE void spawnfunc_##id(entity this) \
99 { \
100 if (!__spawnfunc_first) { \
101 __spawnfunc_first = true; \
102 static_init_early(); \
103 } \
104 bool dospawn = true; \
105 if (__spawnfunc_expecting > 1) { __spawnfunc_expecting = 0; } \
106 else if (__spawnfunc_expecting) { \
107 /* engine call */ \
108 if (!g_spawn_queue) g_spawn_queue_spawn(); \
109 __spawnfunc_expecting = 0; \
110 this = __spawnfunc_expect; \
111 __spawnfunc_expect = NULL; \
112 dospawn = false; \
113 } else { \
114 /* userland call */ \
115 assert(this); \
116 } \
117 if (!this.sourceLoc) { \
118 this.sourceLoc = __FILE__":"STR(__LINE__); \
119 } \
120 this.classname = #id; \
121 if (!this.spawnfunc_checked) { \
122 if (__fullspawndata) { \
123 /* not supported in old DP */ \
124 /* must be read inside the real spawnfunc */ \
125 this.fullspawndata = __fullspawndata; \
126 } \
127 this.spawnfunc_checked = true; \
128 if (this) { \
129 /* not worldspawn, delay spawn */ \
130 /* clear some dangerous fields (TODO: properly support these in the map!) */ \
131 this.think = func_null; \
132 this.nextthink = 0; \
133 __spawnfunc_defer(this, __spawnfunc_##id); \
134 } else { \
135 /* world might not be "worldspawn" */ \
136 this.__spawnfunc_constructor = __spawnfunc_##id; \
137 } \
138 } \
139 if (dospawn) { __spawnfunc_##id(this); } \
140 if (__spawnfunc_unreachable_workaround) return; \
141 } \
142 void __spawnfunc_##id(entity this)

Referenced by spawnfunc().

◆ SPAWNFUNC_INTERNAL_FIELDS

#define SPAWNFUNC_INTERNAL_FIELDS ( X)
Value:
X(string, classname, "spawnfunc") \
X(string, target, string_null) \
X(string, target2, string_null) \
X(string, target3, string_null) \
X(string, target4, string_null) \
X(string, targetname, string_null) \
string classname
#define X()
string string_null
Definition nil.qh:9
string target4
Definition subs.qh:55
string target3
Definition subs.qh:54
string target2
string targetname
Definition triggers.qh:56
string target
Definition triggers.qh:55

Definition at line 43 of file spawnfunc.qh.

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) \
50 /**/

Referenced by __spawnfunc_defer(), and __spawnfunc_spawn().

◆ X [1/3]

#define X ( T,
fld,
def )
Value:
.T fld, __spawnfunc_##fld;

Definition at line 52 of file spawnfunc.qh.

◆ X [2/3]

#define X ( T,
fld,
def )
Value:
{ prototype.__spawnfunc_##fld = prototype.fld; prototype.fld = def; }

Definition at line 52 of file spawnfunc.qh.

◆ X [3/3]

#define X ( T,
fld,
def )
Value:
{ e.fld = e.__spawnfunc_##fld; e.__spawnfunc_##fld = def; }

Definition at line 52 of file spawnfunc.qh.

Function Documentation

◆ __spawnfunc_defer()

void __spawnfunc_defer ( entity prototype,
void(entity) constructor )

Definition at line 56 of file spawnfunc.qh.

57 {
58 IL_PUSH(g_spawn_queue, prototype);
59 #define X(T, fld, def) { prototype.__spawnfunc_##fld = prototype.fld; prototype.fld = def; }
61 #undef X
62 prototype.__spawnfunc_constructor = constructor;
63 }
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define SPAWNFUNC_INTERNAL_FIELDS(X)
Definition spawnfunc.qh:43

References entity(), g_spawn_queue, IL_PUSH(), SPAWNFUNC_INTERNAL_FIELDS, and X.

◆ __spawnfunc_spawn()

void __spawnfunc_spawn ( entity prototype)

Definition at line 73 of file spawnfunc.qh.

74 {
75 entity e = new(clone);
76 copyentity_qc(prototype, e);
78 #define X(T, fld, def) { e.fld = e.__spawnfunc_##fld; e.__spawnfunc_##fld = def; }
80 #undef X
81#ifdef SVQC
83 if (wasfreed(e)) {
84 return;
85 }
86#endif
87 e.__spawnfunc_constructor(e);
88 }
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void copyentity_qc(entity src, entity dst)
Definition oo.qh:86
noref IntrusiveList g_map_entities
Definition spawnfunc.qh:65
void _SV_OnEntityPreSpawnFunction(entity this)

References _SV_OnEntityPreSpawnFunction(), copyentity_qc(), entity(), g_map_entities, IL_PUSH(), SPAWNFUNC_INTERNAL_FIELDS, and X.

◆ _SV_OnEntityPreSpawnFunction()

void _SV_OnEntityPreSpawnFunction ( entity this)

References entity().

Referenced by __spawnfunc_spawn().

◆ g_spawn_queue_spawn()

void g_spawn_queue_spawn ( )

Definition at line 92 of file spawnfunc.qh.

92{ g_spawn_queue = IL_NEW(); }

References g_spawn_queue, and IL_NEW.

◆ void()

void ( entity ) const

References entity().

Variable Documentation

◆ __fullspawndata

noref string __fullspawndata

Not for production use, provides access to a dump of the entity's fields when it is parsed from map data.

Definition at line 10 of file spawnfunc.qh.

◆ __spawnfunc_expect

noref entity __spawnfunc_expect

Definition at line 37 of file spawnfunc.qh.

◆ __spawnfunc_expecting

noref int __spawnfunc_expecting

Definition at line 36 of file spawnfunc.qh.

◆ __spawnfunc_first

noref bool __spawnfunc_first

Definition at line 94 of file spawnfunc.qh.

◆ __spawnfunc_unreachable_workaround

noref bool __spawnfunc_unreachable_workaround = true

Definition at line 38 of file spawnfunc.qh.

◆ fullspawndata

string fullspawndata

Definition at line 11 of file spawnfunc.qh.

◆ g_map_entities

noref IntrusiveList g_map_entities

Definition at line 65 of file spawnfunc.qh.

Referenced by __spawnfunc_spawn().

◆ g_spawn_queue

noref IntrusiveList g_spawn_queue

Definition at line 41 of file spawnfunc.qh.

Referenced by __spawnfunc_defer(), and g_spawn_queue_spawn().

◆ require_spawnfunc_prefix

noref bool require_spawnfunc_prefix

If this global exists, only functions with spawnfunc_ name prefix qualify as spawn functions.

Definition at line 7 of file spawnfunc.qh.

◆ spawnfunc_checked

bool spawnfunc_checked

Definition at line 8 of file spawnfunc.qh.

Referenced by ctf_SpawnTeam(), tdm_SpawnTeam(), and tmayhem_SpawnTeam().