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 ()
 This function simply avoids expanding IL_NEW during compilation for each spawning entity.
 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:79
noref IntrusiveList g_spawn_queue
Definition spawnfunc.qh:43

Definition at line 72 of file spawnfunc.qh.

72 #define __spawnfunc_spawn_all() MACRO_BEGIN \
73 g_map_entities = IL_NEW(); \
74 IL_EACH(g_spawn_queue, true, __spawnfunc_spawn(it)); \
75 MACRO_END

Referenced by spawnfunc().

◆ _spawnfunc_check

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

Definition at line 34 of file spawnfunc.qh.

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

◆ _spawnfunc_checktypes

#define _spawnfunc_checktypes ( fld)

Definition at line 32 of file spawnfunc.qh.

◆ spawnfunc

#define spawnfunc ( id)

Definition at line 107 of file spawnfunc.qh.

107#define spawnfunc(id) \
108 void __spawnfunc_##id(entity this); \
109 ACCUMULATE void spawnfunc_##id(entity this) \
110 { \
111 if (!__spawnfunc_first) \
112 { \
113 __spawnfunc_first = true; \
114 static_init_early(); \
115 } \
116 bool dospawn = true; \
117 if (__spawnfunc_expecting > 1) \
118 __spawnfunc_expecting = 0; \
119 else if (__spawnfunc_expecting) \
120 { \
121 /* engine call */ \
122 if (!g_spawn_queue) \
123 g_spawn_queue_spawn(); \
124 __spawnfunc_expecting = 0; \
125 this = __spawnfunc_expect; \
126 __spawnfunc_expect = NULL; \
127 dospawn = false; \
128 } \
129 else \
130 /* userland call */ \
131 assert(this); \
132 if (!this.sourceLoc) \
133 this.sourceLoc = __FILE__":"STR(__LINE__); \
134 this.classname = #id; \
135 if (!this.spawnfunc_checked) \
136 { \
137 if (__fullspawndata) \
138 /* not supported in old DP */ \
139 /* must be read inside the real spawnfunc */ \
140 this.fullspawndata = __fullspawndata; \
141 this.spawnfunc_checked = true; \
142 if (this) \
143 { \
144 /* not worldspawn, delay spawn */ \
145 /* clear some dangerous fields (TODO: properly support these in the map!) */ \
146 this.think = func_null; \
147 this.nextthink = 0; \
148 __spawnfunc_defer(this, __spawnfunc_##id); \
149 } \
150 else \
151 /* world might not be "worldspawn" */ \
152 this.__spawnfunc_constructor = __spawnfunc_##id; \
153 } \
154 if (dospawn) \
155 __spawnfunc_##id(this); \
156 if (__spawnfunc_unreachable_workaround) \
157 return; \
158 } \
159 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 45 of file spawnfunc.qh.

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

Referenced by __spawnfunc_defer(), and __spawnfunc_spawn().

◆ X [1/3]

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

Definition at line 54 of file spawnfunc.qh.

◆ X [2/3]

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

Definition at line 54 of file spawnfunc.qh.

◆ X [3/3]

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

Definition at line 54 of file spawnfunc.qh.

Function Documentation

◆ __spawnfunc_defer()

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

Definition at line 58 of file spawnfunc.qh.

59 {
60 IL_PUSH(g_spawn_queue, prototype);
61 #define X(T, fld, def) \
62 { \
63 prototype.__spawnfunc_##fld = prototype.fld; \
64 prototype.fld = def; \
65 }
67 #undef X
68 prototype.__spawnfunc_constructor = constructor;
69 }
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define SPAWNFUNC_INTERNAL_FIELDS(X)
Definition spawnfunc.qh:45

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

◆ __spawnfunc_spawn()

void __spawnfunc_spawn ( entity prototype)

Definition at line 79 of file spawnfunc.qh.

80 {
81 entity e = new(clone);
82 copyentity_qc(prototype, e);
84 #define X(T, fld, def) \
85 { \
86 e.fld = e.__spawnfunc_##fld; \
87 e.__spawnfunc_##fld = def; \
88 }
90 #undef X
91#ifdef SVQC
93 if (wasfreed(e))
94 return;
95#endif
96 e.__spawnfunc_constructor(e);
97 }
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void copyentity_qc(entity src, entity dst)
Definition oo.qh:88
noref IntrusiveList g_map_entities
Definition spawnfunc.qh:71
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 ( )

This function simply avoids expanding IL_NEW during compilation for each spawning entity.

Definition at line 100 of file spawnfunc.qh.

101{
103}

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 39 of file spawnfunc.qh.

◆ __spawnfunc_expecting

noref int __spawnfunc_expecting

Definition at line 38 of file spawnfunc.qh.

◆ __spawnfunc_first

noref bool __spawnfunc_first

Definition at line 105 of file spawnfunc.qh.

◆ __spawnfunc_unreachable_workaround

noref bool __spawnfunc_unreachable_workaround = true

Definition at line 40 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 71 of file spawnfunc.qh.

Referenced by __spawnfunc_spawn().

◆ g_spawn_queue

noref IntrusiveList g_spawn_queue

Definition at line 43 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 _SpawnTeam().