void name##_hud_board(vector, vector); \
void name##_hud_status(vector, vector); \
int name##_client_event(entity, string, ...); \
- REGISTER_INIT_POST(MINIGAME_##name) { \
+ REGISTER_INIT(MINIGAME_##name) { \
this.netname = strzone(strtolower(#name)); \
this.message = nicename; \
this.minigame_hud_board = name##_hud_board; \
#define REGISTER_MINIGAME(name,nicename) \
REGISTER(Minigames, MINIGAME_##name, m_id, new_pure(minigame_descriptor)); \
int name##_server_event(entity, string, ...); \
- REGISTER_INIT_POST(MINIGAME_##name) { \
+ REGISTER_INIT(MINIGAME_##name) { \
this.netname = strzone(strtolower(#name)); \
this.message = nicename; \
this.minigame_event = name##_server_event; \
REGISTRY_CHECK(Buffs)
#define REGISTER_BUFF(id) \
- REGISTER(Buffs, BUFF_##id, m_id, NEW(Buff)); \
- REGISTER_INIT_POST(BUFF_##id) { \
- this.netname = this.m_name; \
- this.m_itemid = BIT(this.m_id - 1); \
- this.m_sprite = strzone(strcat("buff-", this.m_name)); \
- } \
- REGISTER_INIT(BUFF_##id)
+ REGISTER(Buffs, BUFF_##id, m_id, NEW(Buff))
#include <common/items/item/pickup.qh>
CLASS(Buff, Pickup)
#endif
ENDCLASS(Buff)
+STATIC_INIT(REGISTER_BUFFS) {
+ FOREACH(Buffs, true, {
+ it.netname = it.m_name; \
+ it.m_itemid = BIT(it.m_id - 1); \
+ it.m_sprite = strzone(strcat("buff-", it.m_name)); \
+ });
+}
+
#ifdef SVQC
// .int buffs = _STAT(BUFFS);
void buff_Init(entity ent);
* Must be followed by a semicolon or a function body with a `this` parameter.
* Wrapper macros may perform actions after user initialization like so:
* #define REGISTER_FOO(id) \
- * REGISTER(Foos, FOO, id, m_id, NEW(Foo)); \
- * REGISTER_INIT_POST(FOO, id) { \
+ * REGISTER(Foos, FOO, id, m_id, NEW(Foo)) { \
* print("Registering foo #", this.m_id + 1, "\n"); \
* } \
* REGISTER_INIT(FOO, id)
#define REGISTER_4(registry, id, fld, inst) \
entity id; \
REGISTER_INIT(id) {} \
- REGISTER_INIT_POST(id) {} \
void Register_##id() \
{ \
if (registry##_COUNT >= registry##_MAX) LOG_FATALF("Registry capacity exceeded (%d)", registry##_MAX); \
this.registered_id = #id; \
REGISTRY_PUSH(registry, fld, this); \
Register_##id##_init(this); \
- Register_##id##_init_post(this); \
} \
ACCUMULATE_FUNCTION(_Register##registry, Register_##id) \
REGISTER_INIT(id)
} MACRO_END
#define REGISTER_INIT(id) [[accumulate]] void Register_##id##_init(entity this)
-#define REGISTER_INIT_POST(id) [[accumulate]] void Register_##id##_init_post(entity this)
/** internal next pointer */
#define REGISTRY_NEXT enemy