From: TimePath Date: Tue, 22 Mar 2016 03:13:41 +0000 (+1100) Subject: Registry: remove per-item post-initialization X-Git-Tag: xonotic-v0.8.2~1060 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a2fd53d21fd4a51a0b0df9b52745e5d4bebf3bcf;p=xonotic%2Fxonotic-data.pk3dir.git Registry: remove per-item post-initialization --- diff --git a/qcsrc/common/minigames/cl_minigames.qh b/qcsrc/common/minigames/cl_minigames.qh index 596d9204c..e3c7df18f 100644 --- a/qcsrc/common/minigames/cl_minigames.qh +++ b/qcsrc/common/minigames/cl_minigames.qh @@ -120,7 +120,7 @@ REGISTRY_CHECK(Minigames) 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; \ diff --git a/qcsrc/common/minigames/sv_minigames.qh b/qcsrc/common/minigames/sv_minigames.qh index ecef02856..1e00fd1b3 100644 --- a/qcsrc/common/minigames/sv_minigames.qh +++ b/qcsrc/common/minigames/sv_minigames.qh @@ -53,7 +53,7 @@ REGISTRY_CHECK(Minigames) #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; \ diff --git a/qcsrc/common/mutators/mutator/buffs/all.qh b/qcsrc/common/mutators/mutator/buffs/all.qh index b45cb0621..8e1319b39 100644 --- a/qcsrc/common/mutators/mutator/buffs/all.qh +++ b/qcsrc/common/mutators/mutator/buffs/all.qh @@ -13,13 +13,7 @@ REGISTER_REGISTRY(Buffs) 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 CLASS(Buff, Pickup) @@ -39,6 +33,14 @@ 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); diff --git a/qcsrc/lib/registry.qh b/qcsrc/lib/registry.qh index 434473a86..2b96cf7c4 100644 --- a/qcsrc/lib/registry.qh +++ b/qcsrc/lib/registry.qh @@ -51,8 +51,7 @@ REGISTRY(Registries, BITS(8)) * 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) @@ -70,7 +69,6 @@ REGISTRY(Registries, BITS(8)) #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); \ @@ -78,7 +76,6 @@ REGISTRY(Registries, BITS(8)) 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) @@ -99,7 +96,6 @@ REGISTRY(Registries, BITS(8)) } 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