]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Registry: cleanup
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 10 Nov 2015 06:29:25 +0000 (17:29 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 10 Nov 2015 06:29:25 +0000 (17:29 +1100)
24 files changed:
qcsrc/client/hud/hud.qh
qcsrc/common/command/all.qh
qcsrc/common/deathtypes/all.qh
qcsrc/common/effects/all.qh
qcsrc/common/effects/effectinfo.qc
qcsrc/common/items/all.qh
qcsrc/common/mapinfo.qh
qcsrc/common/minigames/cl_minigames.qh
qcsrc/common/minigames/sv_minigames.qh
qcsrc/common/models/all.qh
qcsrc/common/monsters/all.qh
qcsrc/common/mutators/base.qh
qcsrc/common/mutators/mutator/buffs/all.qh
qcsrc/common/mutators/mutator/nades/nades.qh
qcsrc/common/mutators/mutator/waypoints/all.qh
qcsrc/common/sounds/all.qh
qcsrc/common/turrets/all.qh
qcsrc/common/vehicles/all.qh
qcsrc/common/weapons/all.qh
qcsrc/lib/net.qh
qcsrc/lib/registry.qh
qcsrc/lib/stats.qh
qcsrc/menu/gamesettings.qh
qcsrc/server/cl_player.qh

index 5c5a0fe96091968c3d5c66f62af18019364b93b9..7762d16c03706cfb6791238a11867674fbe92214 100644 (file)
@@ -8,11 +8,11 @@ void HUD_Radar_Mouse();
 
 REGISTRY(hud_panels, BITS(6))
 #define hud_panels_from(i) _hud_panels_from(i, NULL)
-REGISTER_REGISTRY(Registerhud_panels)
+REGISTER_REGISTRY(hud_panels)
 
 #define REGISTER_HUD_PANEL(id, draw_func, name, configflags, showflags) \
        void draw_func(); \
-       REGISTER(Registerhud_panels, HUD_PANEL, hud_panels, id, m_id, new(hud_panel)) { \
+       REGISTER(hud_panels, HUD_PANEL, id, m_id, new(hud_panel)) { \
                make_pure(this); \
                this.panel_id = this.m_id; \
                this.panel_draw = draw_func; \
index 05ccb464193d6670943eaefd822e337e513867d4..d1eb3cf76e284bf3b1ddc547366bef69218ac1ef 100644 (file)
@@ -4,7 +4,7 @@
 #include "command.qh"
 REGISTRY(GENERIC_COMMANDS, BITS(7))
 #define GENERIC_COMMANDS_from(i) _GENERIC_COMMANDS_from(i, NULL)
-REGISTER_REGISTRY(RegisterGENERIC_COMMANDS)
+REGISTER_REGISTRY(GENERIC_COMMANDS)
 REGISTRY_SORT(GENERIC_COMMANDS, 0)
 
 #define GENERIC_COMMAND(id, description) \
@@ -12,7 +12,7 @@ REGISTRY_SORT(GENERIC_COMMANDS, 0)
                ATTRIB(genericcommand_##id, m_name, string, #id); \
        ATTRIB(genericcommand_##id, m_description, string, description); \
        ENDCLASS(genericcommand_##id) \
-    REGISTER(RegisterGENERIC_COMMANDS, CMD_G, GENERIC_COMMANDS, id, m_id, NEW(genericcommand_##id)); \
+    REGISTER(GENERIC_COMMANDS, CMD_G, id, m_id, NEW(genericcommand_##id)); \
        METHOD(genericcommand_##id, m_invokecmd, void(int request, int arguments, string command))
 
 STATIC_INIT(GENERIC_COMMANDS_aliases) {
index b3a671d260fde17cd95175394112a9e25f99afc7..dcf64b11f3d635b6dac5224de9d93977ac87585c 100644 (file)
@@ -5,7 +5,7 @@
 
 REGISTRY(Deathtypes, BITS(8))
 #define Deathtypes_from(i) _Deathtypes_from(i, NULL)
-REGISTER_REGISTRY(RegisterDeathtypes)
+REGISTER_REGISTRY(Deathtypes)
 REGISTRY_CHECK(Deathtypes)
 
 .entity death_msgself;
@@ -13,7 +13,7 @@ REGISTRY_CHECK(Deathtypes)
 .string death_msgextra;
 
 #define REGISTER_DEATHTYPE(id, msg_death, msg_death_by, extra) \
-    REGISTER(RegisterDeathtypes, DEATH, Deathtypes, id, m_id, new(deathtype)) { \
+    REGISTER(Deathtypes, DEATH, id, m_id, new(deathtype)) { \
         make_pure(this); \
         this.m_id += DT_FIRST; \
         this.nent_name = #id; \
index 58284fb0e39711516830b2b2e6b0dba2b81d07eb..e0e9a3ca869d16b85734356e49802dba3fc706b9 100644 (file)
@@ -10,10 +10,10 @@ void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt);
 
 REGISTRY(Effects, BITS(8))
 #define Effects_from(i) _Effects_from(i, EFFECT_Null)
-REGISTER_REGISTRY(RegisterEffects)
+REGISTER_REGISTRY(Effects)
 REGISTRY_CHECK(Effects)
 #define EFFECT(istrail, name, realname) \
-    REGISTER(RegisterEffects, EFFECT, Effects, name, m_id, Create_Effect_Entity(realname, istrail));
+    REGISTER(Effects, EFFECT, name, m_id, Create_Effect_Entity(realname, istrail));
 
 EFFECT(0, Null, string_null)
 #include "all.inc"
index d6e929b2017b358b393dfdfd9b9fb2c845222f96..f4df3237d4e5ef046bb5909e84652004d2da9f59 100644 (file)
@@ -321,10 +321,10 @@ GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt")
 
 REGISTRY(EffectInfos, BITS(9))
 #define EffectInfos_from(i) _EffectInfos_from(i, NULL)
-REGISTER_REGISTRY(RegisterEffectInfos)
+REGISTER_REGISTRY(EffectInfos)
 #define EFFECTINFO(name) \
     [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \
-    REGISTER(RegisterEffectInfos, EFFECTINFO, EffectInfos, name, m_id, NEW(EffectInfoGroup)) { \
+    REGISTER(EffectInfos, EFFECTINFO, name, m_id, NEW(EffectInfoGroup)) { \
         effectinfo_##name(this, NULL); \
     }
 
index 809398bb292fa907c1e4f0d1a074ff646236bfee..ab86ea6736eaca2b592cb6e212bdc1aa6b42392b 100644 (file)
@@ -7,9 +7,9 @@
 
 REGISTRY(Items, BITS(5))
 #define Items_from(i) _Items_from(i, NULL)
-REGISTER_REGISTRY(RegisterItems)
+REGISTER_REGISTRY(Items)
 /** If you register a new item, make sure to add it to all.inc */
-#define REGISTER_ITEM(id, class) REGISTER(RegisterItems, ITEM, Items, id, m_id, NEW(class))
+#define REGISTER_ITEM(id, class) REGISTER(Items, ITEM, id, m_id, NEW(class))
 
 REGISTRY_SORT(Items, 0)
 REGISTRY_CHECK(Items)
index 055777bf8493b51e0e15eb79e966c69abcf220a0..702798bbf861d3bfcb912ceac3b67a6afcd5052b 100644 (file)
@@ -44,13 +44,13 @@ ENDCLASS(Gametype)
 
 REGISTRY(Gametypes, BITS(4))
 #define Gametypes_from(i) _Gametypes_from(i, NULL)
-REGISTER_REGISTRY(RegisterGametypes)
+REGISTER_REGISTRY(Gametypes)
 REGISTRY_CHECK(Gametypes)
 int MAPINFO_TYPE_ALL;
 #define REGISTER_GAMETYPE(hname, sname, g_name, NAME, gteamplay, mutators, defaults, gdescription)          \
     int MAPINFO_TYPE_##NAME;                                                                                \
     bool NAME##_mapinfo(string k, string v) { return = false; }                                             \
-    REGISTER(RegisterGametypes, MAPINFO_TYPE, Gametypes, g_name, m_id,                                      \
+    REGISTER(Gametypes, MAPINFO_TYPE, g_name, m_id,                                      \
         NEW(Gametype, hname, #sname, #g_name, gteamplay, #sname " " mutators, defaults, gdescription)       \
     ) {                                                                                                     \
         /* same as `1 << m_id` */                                                                           \
index 6fb461c6beed194767fcb93f9211b48e3adb72cc..f21c6e482d10c5b3310557ee6eba9178d6c28c0e 100644 (file)
@@ -113,10 +113,10 @@ void HUD_MinigameMenu_CustomEntry(entity parent, string message, string event_ar
 
 REGISTRY(Minigames, BITS(3))
 #define Minigames_from(i) _Minigames_from(i, NULL)
-REGISTER_REGISTRY(RegisterMinigames)
+REGISTER_REGISTRY(Minigames)
 REGISTRY_CHECK(Minigames)
 #define REGISTER_MINIGAME(name,nicename) \
-    REGISTER(RegisterMinigames, MINIGAME, Minigames, name, m_id, new(minigame_descriptor)); \
+    REGISTER(Minigames, MINIGAME, name, m_id, new(minigame_descriptor)); \
     void name##_hud_board(vector, vector); \
     void name##_hud_status(vector, vector); \
     int name##_client_event(entity, string, ...); \
index f60b2d6dbaedae53314da1356aa1ed5f6a0e741d..eb6825ed600e52ad46df1c47af15717d3a10229d 100644 (file)
@@ -48,10 +48,10 @@ bool minigame_SendEntity(entity this, entity to, int sf);
 
 REGISTRY(Minigames, BITS(3))
 #define Minigames_from(i) _Minigames_from(i, NULL)
-REGISTER_REGISTRY(RegisterMinigames)
+REGISTER_REGISTRY(Minigames)
 REGISTRY_CHECK(Minigames)
 #define REGISTER_MINIGAME(name,nicename) \
-    REGISTER(RegisterMinigames, MINIGAME, Minigames, name, m_id, new(minigame_descriptor)); \
+    REGISTER(Minigames, MINIGAME, name, m_id, new(minigame_descriptor)); \
     int name##_server_event(entity, string, ...); \
     REGISTER_INIT_POST(MINIGAME, name) { \
         make_pure(this); \
index b81567427767f030fb5742c87be7089f4c56afe6..ac95c2c840a697a2b9e14d0d22277956c71a6416 100644 (file)
@@ -5,11 +5,11 @@
 
 REGISTRY(Models, BITS(9))
 #define Models_from(i) _Models_from(i, MDL_Null)
-REGISTER_REGISTRY(RegisterModels)
+REGISTER_REGISTRY(Models)
 
 #define MODEL(name, path) \
     string MDL_##name##_get() { return path; } \
-    REGISTER(RegisterModels, MDL, Models, name, m_id, NEW(Model, MDL_##name##_get))
+    REGISTER(Models, MDL, name, m_id, NEW(Model, MDL_##name##_get))
 
 PRECACHE(Models) {
     FOREACH(Models, true, LAMBDA({
index fd5978c91d4291936c15d05698b9410540bb14af..b771984f212b1b4ef3a680099e19e7059600662e 100644 (file)
@@ -8,12 +8,12 @@ string M_Model(string m_mdl);
 REGISTRY(Monsters, BITS(5))
 #define Monsters_from(i) _Monsters_from(i, MON_Null)
 #define get_monsterinfo(i) Monsters_from(i)
-REGISTER_REGISTRY(RegisterMonsters)
+REGISTER_REGISTRY(Monsters)
 REGISTRY_CHECK(Monsters)
 const int MON_FIRST = 1;
 #define MON_LAST (Monsters_COUNT - 1)
 /** If you register a new monster, make sure to add it to all.inc */
-#define REGISTER_MONSTER(id, inst) REGISTER(RegisterMonsters, MON, Monsters, id, monsterid, inst)
+#define REGISTER_MONSTER(id, inst) REGISTER(Monsters, MON, id, monsterid, inst)
 
 REGISTER_MONSTER(Null, NEW(Monster));
 
index 07a3c82375e7d3813d0f6fdcc6225fb0dae476bb..7cfc297896ab7fd9e6ca91789e5e481455a21afa 100644 (file)
@@ -210,7 +210,7 @@ void Mutator_Remove(Mutator mut)
         bool ret = MUTATORFUNCTION_##id##_hooks(mode); if (ret) return ret; \
     } \
     bool MUTATOR_##id##_check() { return dependence; } \
-    REGISTER(RegisterMutators, MUTATOR, Mutators, id, m_id, NEW(Mutator, #id, MUTATORFUNCTION_##id)) \
+    REGISTER(Mutators, MUTATOR, id, m_id, NEW(Mutator, #id, MUTATORFUNCTION_##id)) \
     { this.mutatorcheck = MUTATOR_##id##_check; } \
     [[accumulate]] bool MUTATORFUNCTION_##id(int mode)
 
index 5b641f7fbb361ec63cbbc599ccfb0c47fb292170..94a00b9de76bd8ea19a02fe009ad493f1e153066 100644 (file)
@@ -13,11 +13,11 @@ REGISTER_RADARICON(Buff, 1);
 
 REGISTRY(Buffs, BITS(4))
 #define Buffs_from(i) _Buffs_from(i, BUFF_Null)
-REGISTER_REGISTRY(RegisterBuffs)
+REGISTER_REGISTRY(Buffs)
 REGISTRY_CHECK(Buffs)
 
 #define REGISTER_BUFF(id) \
-    REGISTER(RegisterBuffs, BUFF, Buffs, id, m_id, NEW(Buff)); \
+    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); \
index a218b71a644e9895c2a1dd9abdb286f7a5dc6c28..2e4829354ac67b8081cf5af0dd7b6f1bb9361237 100644 (file)
@@ -20,10 +20,10 @@ const int PROJECTILE_NADE_MONSTER_BURN = 83;
 
 REGISTRY(Nades, BITS(4))
 #define Nades_from(i) _Nades_from(i, NADE_TYPE_Null)
-REGISTER_REGISTRY(RegisterNades)
+REGISTER_REGISTRY(Nades)
 REGISTRY_CHECK(Nades)
 
-#define REGISTER_NADE(id) REGISTER(RegisterNades, NADE_TYPE, Nades, id, m_id, NEW(Nade))
+#define REGISTER_NADE(id) REGISTER(Nades, NADE_TYPE, id, m_id, NEW(Nade))
 
 CLASS(Nade, Object)
     ATTRIB(Nade, m_id, int, 0)
index b98d28a68ee5e25ccb6fafe74ed757f7e37ed15c..9693d2809050cb5ff88b7d0072981795dfccb18c 100644 (file)
@@ -5,11 +5,11 @@
 
 REGISTRY(Waypoints, BITS(6))
 #define Waypoints_from(i) _Waypoints_from(i, WP_Null)
-REGISTER_REGISTRY(RegisterWaypoints)
+REGISTER_REGISTRY(Waypoints)
 REGISTRY_CHECK(Waypoints)
 
 /** If you register a new waypoint, make sure to add it to all.inc */
-#define REGISTER_WAYPOINT_(id, init) REGISTER(RegisterWaypoints, WP, Waypoints, id, m_id, init)
+#define REGISTER_WAYPOINT_(id, init) REGISTER(Waypoints, WP, id, m_id, init)
 
 CLASS(Waypoint, Object)
     ATTRIB(Waypoint, m_id, int, 0)
@@ -30,11 +30,11 @@ ENDCLASS(Waypoint)
 
 REGISTRY(RadarIcons, BITS(7))
 #define RadarIcons_from(i) _RadarIcons_from(i, RADARICON_NONE)
-REGISTER_REGISTRY(RegisterRadarIcons)
+REGISTER_REGISTRY(RadarIcons)
 REGISTRY_CHECK(RadarIcons)
 
 .int m_radaricon;
-#define REGISTER_RADARICON(id, num) REGISTER(RegisterRadarIcons, RADARICON, RadarIcons, id, m_id, new(RadarIcon)) { make_pure(this); this.m_radaricon = num; this.netname = #id; }
+#define REGISTER_RADARICON(id, num) REGISTER(RadarIcons, RADARICON, id, m_id, new(RadarIcon)) { make_pure(this); this.m_radaricon = num; this.netname = #id; }
 
 REGISTER_WAYPOINT(Null, "", '0 0 0', 1);
 
index e81206cd13f1f12d3f9c442bae8e0550c44c884b..8225db7368c30f5593c2c1e435897b0123cbb8d5 100644 (file)
@@ -5,11 +5,11 @@
 
 REGISTRY(Sounds, BITS(8))
 #define Sounds_from(i) _Sounds_from(i, SND_Null)
-REGISTER_REGISTRY(RegisterSounds)
+REGISTER_REGISTRY(Sounds)
 
 #define SOUND(name, path) \
     string SND_##name##_get() { return path; } \
-    REGISTER(RegisterSounds, SND, Sounds, name, m_id, NEW(Sound, SND_##name##_get))
+    REGISTER(Sounds, SND, name, m_id, NEW(Sound, SND_##name##_get))
 
 // Used in places where a string is required
 #define SND(id) Sound_fixpath(SND_##id)
index fa6ef43d423c0aaeed39086f324d6f0be8d1b2b9..fc79400434e4fd58fd4fbfdf85b9a30bc7a990e2 100644 (file)
@@ -9,7 +9,7 @@
 REGISTRY(Turrets, BITS(5))
 #define Turrets_from(i) _Turrets_from(i, TUR_Null)
 #define get_turretinfo(i) Turrets_from(i)
-REGISTER_REGISTRY(RegisterTurrets)
+REGISTER_REGISTRY(Turrets)
 REGISTRY_CHECK(Turrets)
 
 
@@ -70,7 +70,7 @@ GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt")
 const int TUR_FIRST = 1;
 #define TUR_LAST (Turrets_COUNT - 1)
 
-#define REGISTER_TURRET(id, inst) REGISTER(RegisterTurrets, TUR, Turrets, id, m_id, inst)
+#define REGISTER_TURRET(id, inst) REGISTER(Turrets, TUR, id, m_id, inst)
 
 REGISTER_TURRET(Null, NEW(Turret));
 
index d2d943c4e4d2afe88fa72e3d3108adbaf72694ed..3867cf1edd5490b7403750de6f38a5c12c436606 100644 (file)
@@ -6,14 +6,14 @@
 REGISTRY(Vehicles, BITS(3))
 #define Vehicles_from(i) _Vehicles_from(i, VEH_Null)
 #define get_vehicleinfo(i) Vehicles_from(i)
-REGISTER_REGISTRY(RegisterVehicles)
+REGISTER_REGISTRY(Vehicles)
 REGISTRY_CHECK(Vehicles)
 
 const int VEH_FIRST = 1;
 #define VEH_LAST (Vehicles_COUNT - 1)
 
 /** If you register a new vehicle, make sure to add it to all.inc */
-#define REGISTER_VEHICLE(id, inst) REGISTER(RegisterVehicles, VEH, Vehicles, id, vehicleid, inst)
+#define REGISTER_VEHICLE(id, inst) REGISTER(Vehicles, VEH, id, vehicleid, inst)
 
 #if defined(SVQC)
        #include "sv_vehicles.qh"
index af279506448160bb2cf89b5c60fed8c60d8ac237..93df313c05f6e75bd38a4d777d6dbad8799fb7bb 100644 (file)
@@ -37,7 +37,7 @@ WepSet ReadWepSet();
 REGISTRY(Weapons, 72) // Increase as needed. Can be up to 72.
 #define Weapons_from(i) _Weapons_from(i, WEP_Null)
 #define get_weaponinfo(i) Weapons_from(i)
-REGISTER_REGISTRY(RegisterWeapons)
+REGISTER_REGISTRY(Weapons)
 STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, LAMBDA(it.m_pickup = NEW(WeaponPickup, it))); }
 
 
@@ -96,7 +96,7 @@ GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") // WEAPON
 
 #define REGISTER_WEAPON(id, inst) \
     /* WepSet WEPSET_##id; */ \
-    REGISTER(RegisterWeapons, WEP, Weapons, id, m_id, inst)
+    REGISTER(Weapons, WEP, id, m_id, inst)
 
 // create cvars for weapon settings
 #define WEP_ADD_CVAR_NONE(wepname,name) [[last]] float autocvar_g_balance_##wepname##_##name;
index f6013f97a783c757060a65bf547c26ae22e5f24c..07385b092da1cbdac01a3803b91d84262b96b97a 100644 (file)
@@ -92,7 +92,7 @@
                        this.sourceLocFile = __FILE__; \
                        this.sourceLocLine = __LINE__; \
                } \
-               REGISTER(RegisterLinkedEntities, NET, LinkedEntities, id, m_id, new(net_linked_packet)) \
+               REGISTER(LinkedEntities, NET, id, m_id, new(net_linked_packet)) \
                { \
                        make_pure(this); \
                        this.netname = #id; \
 #else
        #define REGISTER_NET_LINKED(id) \
                const bool NET_##id##_istemp = false; \
-               REGISTER(RegisterLinkedEntities, NET, LinkedEntities, id, m_id, new(net_linked_packet)) \
+               REGISTER(LinkedEntities, NET, id, m_id, new(net_linked_packet)) \
                { \
                        make_pure(this); \
                        this.netname = #id; \
 
 REGISTRY(LinkedEntities, BITS(8) - 1)
 #define LinkedEntities_from(i) _LinkedEntities_from(i, NULL)
-REGISTER_REGISTRY(RegisterLinkedEntities)
+REGISTER_REGISTRY(LinkedEntities)
 REGISTRY_SORT(LinkedEntities, 0)
 REGISTRY_CHECK(LinkedEntities)
 STATIC_INIT(RegisterLinkedEntities_renumber)
@@ -122,7 +122,7 @@ STATIC_INIT(RegisterLinkedEntities_renumber)
 #ifdef CSQC
        #define REGISTER_NET_TEMP(id) \
                NET_HANDLE(id, bool); \
-               REGISTER(RegisterTempEntities, NET, TempEntities, id, m_id, new(net_temp_packet)) \
+               REGISTER(TempEntities, NET, id, m_id, new(net_temp_packet)) \
                { \
                        make_pure(this); \
                        this.netname = #id; \
@@ -131,7 +131,7 @@ STATIC_INIT(RegisterLinkedEntities_renumber)
 #else
        #define REGISTER_NET_TEMP(id) \
                const bool NET_##id##_istemp = true; \
-               REGISTER(RegisterTempEntities, NET, TempEntities, id, m_id, new(net_temp_packet)) \
+               REGISTER(TempEntities, NET, id, m_id, new(net_temp_packet)) \
                { \
                        make_pure(this); \
                        this.netname = #id; \
@@ -140,7 +140,7 @@ STATIC_INIT(RegisterLinkedEntities_renumber)
 
 REGISTRY(TempEntities, BITS(8) - 80)
 #define TempEntities_from(i) _TempEntities_from(i, NULL)
-REGISTER_REGISTRY(RegisterTempEntities)
+REGISTER_REGISTRY(TempEntities)
 REGISTRY_SORT(TempEntities, 0)
 REGISTRY_CHECK(TempEntities)
 STATIC_INIT(RegisterTempEntities_renumber)
index 59ddf25ff87ee30c627f14fc4cfd25b4ec23b072..52ab23377454bb92dfe75708ace67d428eac92e5 100644 (file)
@@ -3,11 +3,12 @@
 
 #include "oo.qh"
 
-#define REGISTER_REGISTRY(func) ACCUMULATE_FUNCTION(__static_init, func)
-
-#define REGISTER_INIT(ns, id) [[accumulate]] void Register_##ns##_##id##_init(entity this)
-#define REGISTER_INIT_POST(ns, id) [[accumulate]] void Register_##ns##_##id##_init_post(entity this)
-
+/**
+ * Declare a new registry.
+ *
+ * Don't forget to call `REGISTER_REGISTRY`:
+ *     REGISTER_REGISTRY(Foos)
+ */
 #define REGISTRY(id, max) \
        void Register##id() {} \
        const int id##_MAX = max; \
        int id##_COUNT; \
        entity _##id##_from(int i, entity null) { if (i >= 0 && i < id##_COUNT) { entity e = _##id[i]; if (e) return e; } return null; }
 
+REGISTRY(Registries, BITS(8))
+
 /** registered item identifier */
 .string registered_id;
 
 /**
- * Register a new entity with a global constructor.
+ * Register a new entity with a registry.
  * 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(RegisterFoos, FOO, FOOS, id, m_id, NEW(Foo)); \
+ *         REGISTER(Foos, FOO, id, m_id, NEW(Foo)); \
  *         REGISTER_INIT_POST(FOO, id) { \
  *             print("Registering foo #", this.m_id + 1, "\n"); \
  *         } \
  *         REGISTER_INIT(FOO, id)
  *
- * Don't forget to forward declare `initfunc` and call `REGISTER_REGISTRY`:
- *     void RegisterFoos();
- *     REGISTER_REGISTRY(RegisterFoos)
  *
- * @param initfunc  The global constructor to accumulate into
+ * @param registry  The registry to add each entity to.
  * @param ns        Short for namespace, prefix for each global (ns##_##id)
- * @param array     The array to add each entity to. Also requires `array##_first` and `array##_last` to be defined
  * @param id        The identifier of the current entity being registered
- * @param fld       The field to store the current count into
+ * @param fld       The field to store the locally unique unique entity id
  * @param inst      An expression to create a new instance, invoked for every registration
  */
-#define REGISTER(initfunc, ns, array, id, fld, inst) \
+#define REGISTER(registry, ns, id, fld, inst) \
        entity ns##_##id; \
        REGISTER_INIT(ns, id) {} \
        REGISTER_INIT_POST(ns, id) {} \
        void Register_##ns##_##id() \
        { \
-               if (array##_COUNT >= array##_MAX) LOG_FATALF("Registry capacity exceeded (%s)", ftos(array##_MAX)); \
-               entity this = inst; \
-               ns##_##id = this; \
+               if (registry##_COUNT >= registry##_MAX) LOG_FATALF("Registry capacity exceeded (%s)", ftos(registry##_MAX)); \
+               entity this = ns##_##id = inst; \
                this.registered_id = #id; \
-               this.fld = array##_COUNT; \
-               _##array[array##_COUNT++] = this; \
-               if (!array##_first) array##_first = this; \
-               if (array##_last)   array##_last.REGISTRY_NEXT = this; \
-               array##_last = this; \
+               this.fld = registry##_COUNT; \
+               _##registry[registry##_COUNT] = this; \
+               ++registry##_COUNT; \
+               if (!registry##_first) registry##_first = this; \
+               if (registry##_last)   registry##_last.REGISTRY_NEXT = this; \
+               registry##_last = this; \
                Register_##ns##_##id##_init(this); \
                Register_##ns##_##id##_init_post(this); \
        } \
-       ACCUMULATE_FUNCTION(initfunc, Register_##ns##_##id) \
+       ACCUMULATE_FUNCTION(Register##registry, Register_##ns##_##id) \
        REGISTER_INIT(ns, id)
 
+#define REGISTER_INIT(ns, id) [[accumulate]] void Register_##ns##_##id##_init(entity this)
+#define REGISTER_INIT_POST(ns, id) [[accumulate]] void Register_##ns##_##id##_init_post(entity this)
+
 /** internal next pointer */
 #define REGISTRY_NEXT enemy
 .entity REGISTRY_NEXT;
@@ -119,7 +121,7 @@ void Registry_send(string id, string hash);
                string h = REGISTRY_HASH(id) = strzone(digest_hex(algo, s)); \
                LOG_TRACEF(#id ": %s\n[%s]\n", h, s); \
        } \
-       [[accumulate]] void Registry_check(string r, string sv) \
+       void Registry_check(string r, string sv) \
        { \
                if (r == #id) \
                { \
@@ -130,6 +132,17 @@ void Registry_send(string id, string hash);
                        } \
                } \
        } \
-       [[accumulate]] void Registry_send_all() { Registry_send(#id, REGISTRY_HASH(id)); } \
+       void Registry_send_all() { Registry_send(#id, REGISTRY_HASH(id)); } \
+
+#define REGISTER_REGISTRY(...) EVAL(OVERLOAD(REGISTER_REGISTRY, __VA_ARGS__))
+#define REGISTER_REGISTRY_1(id) REGISTER_REGISTRY_2(id, #id)
+#define REGISTER_REGISTRY_2(id, str) \
+       ACCUMULATE_FUNCTION(__static_init, Register##id) \
+       CLASS(id##Registry, Object) \
+               ATTRIB(id##Registry, m_name, string, str) \
+               ATTRIB(id##Registry, REGISTRY_NEXT, entity, id##_first) \
+       ENDCLASS(id##Registry) \
+       REGISTER(Registries, REGISTRY, id, m_id, NEW(id##Registry));
+
 
 #endif
index f522023ef8aa662ebfb45d800ee9b5e736c9b66d..7dd2706fd240c798e8dff885bd916f122222335f 100644 (file)
@@ -20,7 +20,7 @@
        #define _STAT(id) g_stat_##id
        #define REGISTER_STAT(id, type) \
                type _STAT(id); \
-               REGISTER(RegisterStats, STAT, Stats, id, m_id, new(stat)) \
+               REGISTER(Stats, STAT, id, m_id, new(stat)) \
                { \
                        make_pure(this); \
                } \
@@ -43,7 +43,7 @@
        #define _STAT(id) stat_##id
        #define REGISTER_STAT(id, type) \
                .type _STAT(id); \
-               REGISTER(RegisterStats, STAT, Stats, id, m_id, new(stat)) \
+               REGISTER(Stats, STAT, id, m_id, new(stat)) \
                { \
                        make_pure(this); \
                } \
@@ -58,7 +58,7 @@
 const int STATS_ENGINE_RESERVE = 32 + (8 * 3); // Not sure how to handle vector stats yet, reserve them too
 
 REGISTRY(Stats, 220 - STATS_ENGINE_RESERVE)
-REGISTER_REGISTRY(RegisterStats)
+REGISTER_REGISTRY(Stats)
 REGISTRY_SORT(Stats, 0)
 REGISTRY_CHECK(Stats)
 STATIC_INIT(RegisterStats_renumber)
index 24a40edf04a267128957e6f15221b8cb382510e4..0db9f77f2e08faf4c98d61205561c7e5af704e6f 100644 (file)
@@ -6,10 +6,10 @@
 
 REGISTRY(Settings, BITS(3))
 #define Settings_from(i) _Settings_from(i, NULL)
-REGISTER_REGISTRY(RegisterSettings)
+REGISTER_REGISTRY(Settings)
 #define REGISTER_SETTINGS(id, impl) \
     LAZY_NEW(id, impl) \
-    REGISTER(RegisterSettings, MENU, Settings, id, m_id, NEW(Lazy, LAZY(id)))
+    REGISTER(Settings, MENU, id, m_id, NEW(Lazy, LAZY(id)))
 
 #endif
 #endif
index b74b6f01c5ca89e71c9b76d9265aa32bd7cd2f9b..76c49d852f572c2f1138c00eb538b25f5db56204 100644 (file)
@@ -103,12 +103,12 @@ void VoiceMessage(string type, string msg);
 REGISTRY(GlobalSounds, BITS(8) - 1)
 #define GlobalSounds_from(i) _GlobalSounds_from(i, NULL)
 #define REGISTER_GLOBALSOUND(id, str) \
-       REGISTER(RegisterGlobalSounds, GS, GlobalSounds, id, m_id, new(GlobalSound)) \
+       REGISTER(GlobalSounds, GS, id, m_id, new(GlobalSound)) \
        { \
                make_pure(this); \
                this.m_globalsoundstr = str; \
        }
-REGISTER_REGISTRY(RegisterGlobalSounds)
+REGISTER_REGISTRY(GlobalSounds)
 REGISTRY_SORT(GlobalSounds, 0)
 REGISTRY_CHECK(GlobalSounds)
 PRECACHE(GlobalSounds)