]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Registry: overflow check
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 7 Oct 2015 01:43:32 +0000 (12:43 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 7 Oct 2015 01:43:32 +0000 (12:43 +1100)
29 files changed:
qcsrc/client/weapons/projectile.qc
qcsrc/common/buffs/all.qh
qcsrc/common/effects/effectinfo.qc
qcsrc/common/effects/effects.qc
qcsrc/common/effects/effects.qh
qcsrc/common/items/all.qh
qcsrc/common/mapinfo.qc
qcsrc/common/mapinfo.qh
qcsrc/common/minigames/cl_minigames.qh
qcsrc/common/minigames/cl_minigames_hud.qc
qcsrc/common/minigames/minigames.qc
qcsrc/common/minigames/sv_minigames.qc
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/waypoints/all.qh
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/nades/all.qh
qcsrc/common/sounds/all.qh
qcsrc/common/turrets/all.qh
qcsrc/common/vehicles/all.qh
qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc
qcsrc/common/weapons/all.qh
qcsrc/lib/net.qh
qcsrc/lib/registry.qh
qcsrc/menu/gamesettings.qh
qcsrc/menu/xonotic/dialog_settings_game.qc
qcsrc/server/mutators/gamemode_keyhunt.qc

index fc08f7ffd025efabefdce1b8619100eaaf6a3b97..9d23e3cabdad77231eb403587b7335ba55e509d3 100644 (file)
@@ -47,7 +47,7 @@ void Projectile_DrawTrail(vector to)
        if (self.traileffect)
        {
                particles_alphamin = particles_alphamax = particles_fade = sqrt(self.alpha);
-               boxparticles(particleeffectnum(effects_ent[self.traileffect]), self, from, to, self.velocity, self.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
+               boxparticles(particleeffectnum(Effects[self.traileffect]), self, from, to, self.velocity, self.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
        }
 }
 
index 4cf371baac6c2c901226d7fd8fcc4878a954a8d7..709903470576ecc64ac342d61f2c3e4a3b994899 100644 (file)
@@ -8,11 +8,11 @@
 #include "../teams.qh"
 #include "../util.qh"
 
-REGISTRY(Buffs, 16)
+REGISTRY(Buffs, BIT(4))
 REGISTER_REGISTRY(RegisterBuffs)
 
 #define REGISTER_BUFF(id) \
-    REGISTER(RegisterBuffs, BUFF, Buffs, Buffs_COUNT, id, m_id, NEW(Buff)); \
+    REGISTER(RegisterBuffs, BUFF, Buffs, id, m_id, NEW(Buff)); \
     REGISTER_INIT_POST(BUFF, id) { \
         this.netname = this.m_name; \
         this.m_itemid = BIT(this.m_id - 1); \
index 932ce9b7264a54ba7317d548aed8efec0a99b673..731903b6353e7413c3d51db8970138fea9ee734d 100644 (file)
@@ -284,20 +284,13 @@ void effectinfo_dump(int fh, bool alsoprint)
 }
 
 
-void RegisterEffectInfo();
-const int MAX_EFFECTINFOS = 512;
-entity EFFECTINFOS[MAX_EFFECTINFOS], EFFECTINFOS_first, EFFECTINFOS_last;
-int EFFECTINFOS_COUNT;
-
+REGISTRY(EffectInfos, BIT(9))
+REGISTER_REGISTRY(RegisterEffectInfos)
 #define EFFECTINFO(name) \
     [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \
-    REGISTER(RegisterEffectInfo, EFFECTINFO, EFFECTINFOS, EFFECTINFOS_COUNT, name, m_id, NEW(EffectInfoGroup)) { \
+    REGISTER(RegisterEffectInfos, EFFECTINFO, EffectInfos, name, m_id, NEW(EffectInfoGroup)) { \
         effectinfo_##name(this, NULL); \
     }
-REGISTER_REGISTRY(RegisterEffectInfo)
-
-
-#define REGISTER_EFFECTINFO(id) var void effectinfo_##id(EffectInfoGroup parent)
 
 #define MY(f) this.effectinfo_##f
 #define DEF(name) EFFECTINFO(name)
index dd015e0f6b3a4a0080e5564bf8d2f7e2370669e8..78bb6755a9357d2d38ec20c8de65efef302a7e11 100644 (file)
@@ -1,9 +1,9 @@
 #ifdef CSQC
 void Read_Effect(bool is_new)
 {
-       int net_name = (EFFECT_COUNT >= 255) ? ReadShort() : ReadByte();
+       int net_name = (Effects_COUNT >= 255) ? ReadShort() : ReadByte();
 
-       entity eff = effects_ent[net_name];
+       entity eff = Effects[net_name];
 
        vector v, vel = '0 0 0';
        int eff_cnt = 1;
@@ -37,7 +37,7 @@ void Read_Effect(bool is_new)
 bool Net_Write_Effect(entity this, entity client, int sf)
 {
        WriteByte(MSG_ENTITY, ENT_CLIENT_EFFECT);
-       (EFFECT_COUNT >= 255)
+       (Effects_COUNT >= 255)
        ? WriteShort(MSG_ENTITY, self.m_id)
        : WriteByte(MSG_ENTITY, self.m_id);
        WriteCoord(MSG_ENTITY, self.eent_net_location_x);
@@ -81,7 +81,7 @@ void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
 void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt)
 {
        // problem with this is, we might not have all the available effects for it
-       FOREACH(effects_ent, it.eent_eff_name == eff_name, LAMBDA(
+       FOREACH(Effects, it.eent_eff_name == eff_name, LAMBDA(
                Send_Effect(it, eff_loc, eff_vel, eff_cnt);
                return;
        ));
index a1102e96a26fb6cf92eee01d0a69e78f08ca8f8b..21821758c3150cbfcadcd966153f8abdca667398 100644 (file)
@@ -10,14 +10,10 @@ void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt);
 
 #define particleeffectnum(e) _particleeffectnum(e.eent_eff_name)
 
-void RegisterEffects();
-const int MAX_EFFECTS = 512;
-entity effects_ent[MAX_EFFECTS], effects_ent_first, effects_ent_last;
-int EFFECT_COUNT;
-
-#define EFFECT(istrail, name, realname) \
-    REGISTER(RegisterEffects, EFFECT, effects_ent, EFFECT_COUNT, name, m_id, Create_Effect_Entity(realname, istrail));
+REGISTRY(Effects, BIT(8))
 REGISTER_REGISTRY(RegisterEffects)
+#define EFFECT(istrail, name, realname) \
+    REGISTER(RegisterEffects, EFFECT, Effects, name, m_id, Create_Effect_Entity(realname, istrail));
 
 .int m_id;
 .string eent_eff_name;
index 8097ab50fe70c1b22efe31cc98fd42fbcb8d8f5a..672ed707cd0c3bf271d98fd713ba3f44177ae32a 100644 (file)
@@ -3,10 +3,10 @@
 
 #include "item.qh"
 
-REGISTRY(Items, 24)
+REGISTRY(Items, BIT(5))
 REGISTER_REGISTRY(RegisterItems)
 /** If you register a new item, make sure to add it to all.inc */
-#define REGISTER_ITEM(id, class) REGISTER(RegisterItems, ITEM, Items, Items_COUNT, id, m_id, NEW(class))
+#define REGISTER_ITEM(id, class) REGISTER(RegisterItems, ITEM, Items, id, m_id, NEW(class))
 
 void Dump_Items();
 
index 8c898cc54992fe6b9ed674b7768bb563a11838f5..ba21ff43d9cac6da7b25050680d06f4baf5fe3df 100644 (file)
@@ -602,13 +602,13 @@ void _MapInfo_Map_ApplyGametype(string s, int pWantedType, int pThisType, int lo
 
 string _MapInfo_GetDefaultEx(float t)
 {
-       FOREACH(MAPINFO_TYPES, it.items == t, LAMBDA(return it.model2));
+       FOREACH(Gametypes, it.items == t, LAMBDA(return it.model2));
        return "";
 }
 
 float _MapInfo_GetTeamPlayBool(float t)
 {
-       FOREACH(MAPINFO_TYPES, it.items == t, LAMBDA(return it.team));
+       FOREACH(Gametypes, it.items == t, LAMBDA(return it.team));
        return false;
 }
 
@@ -723,14 +723,14 @@ int MapInfo_Type_FromString(string t)
        deprecate(assault, as);
        deprecate(race, rc);
        if (t == "all") return MAPINFO_TYPE_ALL;
-       FOREACH(MAPINFO_TYPES, it.mdl == t, LAMBDA(return it.items));
+       FOREACH(Gametypes, it.mdl == t, LAMBDA(return it.items));
        return 0;
 #undef deprecate
 }
 
 string MapInfo_Type_Description(float t)
 {
-       FOREACH(MAPINFO_TYPES, it.items == t, LAMBDA(return it.gametype_description));
+       FOREACH(Gametypes, it.items == t, LAMBDA(return it.gametype_description));
        return "";
 }
 
@@ -738,13 +738,13 @@ string MapInfo_Type_ToString(float t)
 {
        if(t == MAPINFO_TYPE_ALL)
                return "all";
-       FOREACH(MAPINFO_TYPES, it.items == t, LAMBDA(return it.mdl));
+       FOREACH(Gametypes, it.items == t, LAMBDA(return it.mdl));
        return "";
 }
 
 string MapInfo_Type_ToText(float t)
 {
-       FOREACH(MAPINFO_TYPES, it.items == t, LAMBDA(return it.message));
+       FOREACH(Gametypes, it.items == t, LAMBDA(return it.message));
        /* xgettext:no-c-format */
        return _("@!#%'n Tuba Throwing");
 }
@@ -1249,7 +1249,7 @@ int MapInfo_CurrentFeatures()
 int MapInfo_CurrentGametype()
 {
        int prev = cvar("gamecfg");
-       FOREACH(MAPINFO_TYPES, cvar(it.netname) && it.items != prev, LAMBDA(return it.items));
+       FOREACH(Gametypes, cvar(it.netname) && it.items != prev, LAMBDA(return it.items));
        if (prev) return prev;
        return MAPINFO_TYPE_DEATHMATCH;
 }
@@ -1275,7 +1275,7 @@ float MapInfo_CheckMap(string s) // returns 0 if the map can't be played with th
 
 void MapInfo_SwitchGameType(int t)
 {
-       FOREACH(MAPINFO_TYPES, true, LAMBDA(
+       FOREACH(Gametypes, true, LAMBDA(
                cvar_set(it.netname, (it.items == t) ? "1" : "0")
        ));
 }
index 19799df740069178ccc37aed0d8385a0c6ba169b..6faef6e05716be116e414e9db8615186f2b618e4 100644 (file)
@@ -38,22 +38,18 @@ CLASS(Gametype, Object)
     }
 ENDCLASS(Gametype)
 
-void RegisterGametypes();
-const int MAX_MAPINFO_TYPES = 24;
-entity MAPINFO_TYPES[MAX_MAPINFO_TYPES], MAPINFO_TYPES_first, MAPINFO_TYPES_last;
-int MAPINFO_TYPE_COUNT;
+REGISTRY(Gametypes, BIT(4))
+REGISTER_REGISTRY(RegisterGametypes)
 int MAPINFO_TYPE_ALL;
-
 #define REGISTER_GAMETYPE(hname, sname, g_name, NAME, gteamplay, defaults, gdescription)                    \
     int MAPINFO_TYPE_##NAME;                                                                                \
-    REGISTER(RegisterGametypes, MAPINFO_TYPE, MAPINFO_TYPES, MAPINFO_TYPE_COUNT, g_name, m_id,              \
+    REGISTER(RegisterGametypes, MAPINFO_TYPE, Gametypes, g_name, m_id,                                      \
         NEW(Gametype, hname, #sname, #g_name, gteamplay, defaults, gdescription)                            \
     ) {                                                                                                     \
         /* same as `1 << m_id` */                                                                           \
         MAPINFO_TYPE_##NAME = MAPINFO_TYPE_ALL + 1; MAPINFO_TYPE_ALL |= MAPINFO_TYPE_##NAME;                \
         this.items = MAPINFO_TYPE_##NAME;                                                                   \
     }
-REGISTER_REGISTRY(RegisterGametypes)
 
 #define IS_GAMETYPE(NAME) \
     (MapInfo_LoadedGametype == MAPINFO_TYPE_##NAME)
index 76d10986405891fa3d8e902983d33ce5ed6e0bb9..a073af89757a3562c63a20e7b97196e3a07dd1cc 100644 (file)
@@ -116,12 +116,10 @@ void HUD_MinigameMenu_CustomEntry(entity parent, string message, string event_ar
        while( (entityvar = findentity(entityvar,owner,active_minigame)) )
 
 
-void RegisterMinigames();
-const int MINIGAMES_MAX = 24;
-entity MINIGAMES[MINIGAMES_MAX], MINIGAMES_first, MINIGAMES_last;
-int MINIGAMES_COUNT;
+REGISTRY(Minigames, BIT(3))
+REGISTER_REGISTRY(RegisterMinigames)
 #define REGISTER_MINIGAME(name,nicename) \
-    REGISTER(RegisterMinigames, MINIGAME, MINIGAMES, MINIGAMES_COUNT, name, m_id, spawn()); \
+    REGISTER(RegisterMinigames, MINIGAME, Minigames, name, m_id, spawn()); \
     void name##_hud_board(vector, vector); \
     void name##_hud_status(vector, vector); \
     int name##_client_event(entity, string, ...); \
@@ -134,6 +132,5 @@ int MINIGAMES_COUNT;
                this.minigame_event = name##_client_event; \
     } \
     REGISTER_INIT(MINIGAME, name)
-REGISTER_REGISTRY(RegisterMinigames)
 
 #endif
index b0dba86c1ed9525cddb9f6f29b7818b3a9931c06..2a0b0362051f95426b7c2afd9d2dcc006278b9b1 100644 (file)
@@ -213,7 +213,7 @@ void HUD_MinigameMenu_ClickCreate()
        {
                entity curr;
                entity prev = self;
-               FOREACH(MINIGAMES, true, LAMBDA(
+               FOREACH(Minigames, true, LAMBDA(
                {
                        curr = HUD_MinigameMenu_SpawnSubEntry(
                                it.message, HUD_MinigameMenu_ClickCreate_Entry,  self );
index 6a24d37ad8033a17036e671a0e0de5dacc8dcadb..bc854952e7f9562dea72efdd50d91b15d81bc7b1 100644 (file)
@@ -2,7 +2,7 @@
 
 entity minigame_get_descriptor(string id)
 {
-       FOREACH(MINIGAMES, true, LAMBDA(
+       FOREACH(Minigames, true, LAMBDA(
        {
                if(it.netname == id)
                        return it;
index 7a428d8d087e36f69b0347683a971af836644cfd..c06e23c9c7961cd5c09e11797e3ee262504381e5 100644 (file)
@@ -350,7 +350,7 @@ void ClientCommand_minigame(int request, int argc, string command)
                }
                else if ( minig_cmd == "list" )
                {
-                       FOREACH(MINIGAMES, true, LAMBDA(
+                       FOREACH(Minigames, true, LAMBDA(
                        {
                                sprint(self,it.netname," (",it.message,") ","\n");
                        }));
index f00605316b6410f6b837c8e649d9d031e49a4f57..e36d690d9bc743247aabbc104a3f7971e6e24b5a 100644 (file)
@@ -46,12 +46,10 @@ entity minigame_sessions;
 
 bool minigame_SendEntity(entity this, entity to, int sf);
 
-void RegisterMinigames();
-const int MINIGAMES_MAX = 24;
-entity MINIGAMES[MINIGAMES_MAX], MINIGAMES_first, MINIGAMES_last;
-int MINIGAMES_COUNT;
+REGISTRY(Minigames, BIT(3))
+REGISTER_REGISTRY(RegisterMinigames)
 #define REGISTER_MINIGAME(name,nicename) \
-    REGISTER(RegisterMinigames, MINIGAME, MINIGAMES, MINIGAMES_COUNT, name, m_id, spawn()); \
+    REGISTER(RegisterMinigames, MINIGAME, Minigames, name, m_id, spawn()); \
     int name##_server_event(entity, string, ...); \
     REGISTER_INIT_POST(MINIGAME, name) { \
         this.classname = "minigame_descriptor"; \
@@ -60,6 +58,5 @@ int MINIGAMES_COUNT;
                this.minigame_event = name##_server_event; \
     } \
     REGISTER_INIT(MINIGAME, name)
-REGISTER_REGISTRY(RegisterMinigames)
 
 #endif
index 0f94644316607c6f8edf4b28e5d4425d05da234a..38c533449847ec6105d3d6fc9277f12e7564c062 100644 (file)
@@ -3,7 +3,7 @@
 
 #define setmodel(e, m) _setmodel((e), (m).model_str())
 
-REGISTRY(Models, 128)
+REGISTRY(Models, BIT(9))
 REGISTER_REGISTRY(RegisterModels)
 
 CLASS(Model, Object)
@@ -27,7 +27,7 @@ ENDCLASS(Model)
 
 #define MODEL(name, path) \
     string MDL_##name##_get() { return path; } \
-    REGISTER(RegisterModels, MDL, Models, Models_COUNT, name, m_id, NEW(Model, MDL_##name##_get))
+    REGISTER(RegisterModels, MDL, Models, name, m_id, NEW(Model, MDL_##name##_get))
 
 STATIC_INIT(RegisterModels_precache) {
     FOREACH(Models, true, LAMBDA({
index f31e976d69441411b6a2701a058022b996121500..39a928a85749b98f4299e728d583f9d6e4aaa47c 100644 (file)
@@ -3,12 +3,12 @@
 
 #include "monster.qh"
 
-REGISTRY(Monsters, 24)
+REGISTRY(Monsters, BIT(3))
 REGISTER_REGISTRY(RegisterMonsters)
 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, Monsters_COUNT, id, monsterid, inst)
+#define REGISTER_MONSTER(id, inst) REGISTER(RegisterMonsters, MON, Monsters, id, monsterid, inst)
 
 REGISTER_MONSTER(Null, NEW(Monster));
 
index 6fa77a858a21a2bceb2169d603c5b1a577111797..9a535a2960a35703cc16d7517114db24de675ce2 100644 (file)
@@ -220,7 +220,7 @@ noref int MUTATORS_COUNT;
         bool ret = MUTATORFUNCTION_##id##_hooks(mode); if (ret) return ret; \
     } \
     bool MUTATOR_##id##_check() { return dependence; } \
-    REGISTER(RegisterMutators, MUTATOR, MUTATORS, MUTATORS_COUNT, id, m_id, NEW(Mutator, #id, MUTATORFUNCTION_##id)) \
+    REGISTER(RegisterMutators, MUTATOR, MUTATORS, id, m_id, NEW(Mutator, #id, MUTATORFUNCTION_##id)) \
     { this.mutatorcheck = MUTATOR_##id##_check; } \
     [[accumulate]] bool MUTATORFUNCTION_##id(int mode)
 
index 790d08698858a2ff4c9b910f3bdf12a26f87d34d..6120888dbadbdb1991da9c6eadb18be17c601641 100644 (file)
@@ -3,13 +3,10 @@
 
 #include "waypointsprites.qh"
 
-void RegisterWaypoints();
-const int MAX_WAYPOINTS = 240;
-entity WAYPOINTS[MAX_WAYPOINTS], WAYPOINTS_first, WAYPOINTS_last;
-int WAYPOINT_COUNT;
-/** If you register a new waypoint, make sure to add it to all.inc */
-#define REGISTER_WAYPOINT_(id, init) REGISTER(RegisterWaypoints, WP, WAYPOINTS, WAYPOINT_COUNT, id, m_id, init)
+REGISTRY(Waypoints, BIT(6))
 REGISTER_REGISTRY(RegisterWaypoints)
+/** 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)
 
 CLASS(Waypoint, Object)
     ATTRIB(Waypoint, m_id, int, 0)
index bd4be8d7540aab05379cf84405d0cf614eed1e2d..89f9a0f0f1d4282220c2fc678952b8b49a255450 100644 (file)
@@ -259,7 +259,7 @@ string spritelookuptext(string s)
     if (s == WP_Monster.netname) return get_monsterinfo(self.wp_extra).monster_name;
 
     // need to loop, as our netname could be one of three
-    FOREACH(WAYPOINTS, it.netname == s, LAMBDA(
+    FOREACH(Waypoints, it.netname == s, LAMBDA(
         return it.m_name;
     ));
 
index 84b3900432dbf23b5a7812e02432d14fdc5206ad..ad51a1e55e3fd73a0a28f56db0f467685df7c472 100644 (file)
@@ -21,9 +21,9 @@ const int PROJECTILE_NADE_HEAL_BURN = 81;
 const int PROJECTILE_NADE_MONSTER = 82;
 const int PROJECTILE_NADE_MONSTER_BURN = 83;
 
-REGISTRY(Nades, 8)
+REGISTRY(Nades, BIT(3))
 REGISTER_REGISTRY(RegisterNades)
-#define REGISTER_NADE(id) REGISTER(RegisterNades, NADE_TYPE, Nades, Nades_COUNT, id, m_id, NEW(Nade))
+#define REGISTER_NADE(id) REGISTER(RegisterNades, NADE_TYPE, Nades, id, m_id, NEW(Nade))
 
 CLASS(Nade, Object)
     ATTRIB(Nade, m_id, int, 0)
index d567d0a446ab4db14dc831e2b513d129eb9f421e..90858f39d7841cf5f2c2f73d0c59fc37a637546f 100644 (file)
@@ -18,7 +18,7 @@
 // Used in places where a string is required
 #define SND(id) (SND_##id.sound_str())
 
-REGISTRY(Sounds, 128)
+REGISTRY(Sounds, BIT(8))
 REGISTER_REGISTRY(RegisterSounds)
 
 CLASS(Sound, Object)
@@ -42,7 +42,7 @@ ENDCLASS(Sound)
 
 #define SOUND(name, path) \
     string SND_##name##_get() { return path; } \
-    REGISTER(RegisterSounds, SND, Sounds, Sounds_COUNT, name, m_id, NEW(Sound, SND_##name##_get))
+    REGISTER(RegisterSounds, SND, Sounds, name, m_id, NEW(Sound, SND_##name##_get))
 
 STATIC_INIT(RegisterSounds_precache) {
     FOREACH(Sounds, true, LAMBDA({
index eb001bd4af40ad010d84fbf51cf00c4624ccea95..2b9a87d421ae67d446f4f0a21758493d1c3c1a02 100644 (file)
@@ -3,12 +3,12 @@
 
 #include "turret.qh"
 
-REGISTRY(Turrets, 24)
+REGISTRY(Turrets, BIT(5))
 REGISTER_REGISTRY(RegisterTurrets)
 const int TUR_FIRST = 1;
 #define TUR_LAST (Turrets_COUNT - 1)
 
-#define REGISTER_TURRET(id, inst) REGISTER(RegisterTurrets, TUR, Turrets, Turrets_COUNT, id, m_id, inst)
+#define REGISTER_TURRET(id, inst) REGISTER(RegisterTurrets, TUR, Turrets, id, m_id, inst)
 
 REGISTER_TURRET(Null, NEW(Turret));
 
index 706585597ffa8060ef1ac318df5ed57ce125c047..a44eb2209e673768ada5904ab7043e70df5e8273 100644 (file)
@@ -3,13 +3,13 @@
 
 #include "vehicle.qh"
 
-REGISTRY(Vehicles, 24)
+REGISTRY(Vehicles, BIT(3))
 REGISTER_REGISTRY(RegisterVehicles)
 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, Vehicles_COUNT, id, vehicleid, inst)
+#define REGISTER_VEHICLE(id, inst) REGISTER(RegisterVehicles, VEH, Vehicles, id, vehicleid, inst)
 
 #if defined(SVQC)
        #include "sv_vehicles.qh"
index c01f1f7ca1df5e731879edbf844ad49b36f305c8..0966ddf648d1577865355a93bccf3e98b949ed4c 100644 (file)
@@ -112,7 +112,7 @@ void bumble_raygun_draw()
 
     if(self.total_damages < time)
     {
-        boxparticles(particleeffectnum(effects_ent[self.traileffect]), self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
+        boxparticles(particleeffectnum(Effects[self.traileffect]), self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
         boxparticles(self.lip, self, self.move_origin, self.move_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
         self.total_damages = time + 0.1;
     }
index c1b8527afaa69437bc700ecb063ea01d23985e6e..c96061fe615c00833f0d0524d2f6868bda021d9f 100644 (file)
@@ -36,7 +36,7 @@ entity get_weaponinfo(int id);
 
 #define REGISTER_WEAPON(id, inst) \
        /* WepSet WEPSET_##id; */ \
-       REGISTER(RegisterWeapons, WEP, Weapons, Weapons_COUNT, id, m_id, inst)
+       REGISTER(RegisterWeapons, WEP, Weapons, id, m_id, inst)
 
 // create cvars for weapon settings
 #define WEP_ADD_CVAR_NONE(wepname,name) [[last]] float autocvar_g_balance_##wepname##_##name;
index de6525fe9e01c0de20225c2604fcf9aa131d5182..2928ce84aabd6a7d8fe777674efd504b19f4fbb4 100644 (file)
@@ -71,7 +71,7 @@ void UncustomizeEntitiesRun()
 #ifdef CSQC
     #define REGISTER_NET_LINKED(id, param) \
         void Ent_Read##id(entity this, param) { this = self; } \
-        REGISTER(RegisterLinkedEntities, NET, LinkedEntities, LinkedEntities_COUNT, id, m_id, spawn()) { \
+        REGISTER(RegisterLinkedEntities, NET, LinkedEntities, id, m_id, spawn()) { \
             this.netname = #id; \
             this.m_read = Ent_Read##id; \
         } \
@@ -79,12 +79,12 @@ void UncustomizeEntitiesRun()
 #else
     #define REGISTER_NET_LINKED(id, param) \
         const bool NET_##id##_istemp = false; \
-        REGISTER(RegisterLinkedEntities, NET, LinkedEntities, LinkedEntities_COUNT, id, m_id, spawn()) { \
+        REGISTER(RegisterLinkedEntities, NET, LinkedEntities, id, m_id, spawn()) { \
             this.netname = #id; \
         }
 #endif
 
-REGISTRY(LinkedEntities, 24)
+REGISTRY(LinkedEntities, BIT(0))
 REGISTER_REGISTRY(RegisterLinkedEntities)
 REGISTRY_SORT(LinkedEntities, netname, 0)
 STATIC_INIT(RegisterLinkedEntities_renumber) {
@@ -96,7 +96,7 @@ STATIC_INIT(RegisterLinkedEntities_renumber) {
 #ifdef CSQC
     #define REGISTER_NET_TEMP(id, param) \
         void Net_Read##id(entity this, param); \
-        REGISTER(RegisterTempEntities, NET, TempEntities, TempEntities_COUNT, id, m_id, spawn()) { \
+        REGISTER(RegisterTempEntities, NET, TempEntities, id, m_id, spawn()) { \
             this.netname = #id; \
             this.m_read = Net_Read##id; \
         } \
@@ -104,12 +104,12 @@ STATIC_INIT(RegisterLinkedEntities_renumber) {
 #else
     #define REGISTER_NET_TEMP(id, param) \
         const bool NET_##id##_istemp = true; \
-        REGISTER(RegisterTempEntities, NET, TempEntities, TempEntities_COUNT, id, m_id, spawn()) { \
+        REGISTER(RegisterTempEntities, NET, TempEntities, id, m_id, spawn()) { \
             this.netname = #id; \
         }
 #endif
 
-REGISTRY(TempEntities, 24)
+REGISTRY(TempEntities, BIT(0))
 REGISTER_REGISTRY(RegisterTempEntities)
 REGISTRY_SORT(TempEntities, netname, 0)
 STATIC_INIT(RegisterTempEntities_renumber) {
index 942c5b2bba5858921b8a1c19615cefb3905099e0..688a711912cd1e43694b1856d03a0493b09c10b5 100644 (file)
@@ -17,7 +17,7 @@
  * 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, FOOS_COUNT, id, m_id, NEW(Foo)); \
+ *         REGISTER(RegisterFoos, FOO, FOOS, id, m_id, NEW(Foo)); \
  *         REGISTER_INIT_POST(FOO, id) { \
  *             print("Registering foo #", this.m_id + 1, "\n"); \
  *         } \
  * @param initfunc  The global constructor to accumulate into
  * @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 counter   Global to count number of entries
  * @param id        The identifier of the current entity being registered
  * @param fld       The field to store the current count into
  * @param inst      An expression to create a new instance, invoked for every registration
  */
-#define REGISTER(initfunc, ns, array, counter, id, fld, inst)   \
+#define REGISTER(initfunc, ns, array, id, fld, inst)            \
     entity ns##_##id;                                           \
     REGISTER_INIT(ns, id) { }                                   \
     REGISTER_INIT_POST(ns, id) { }                              \
     .entity enemy; /* internal next pointer */                  \
     void Register_##ns##_##id() {                               \
+        if (array##_COUNT >= array##_MAX) LOG_FATALF("Registry capacity exceeded (%s)", ftos(array##_MAX)); \
         entity this = inst;                                     \
         ns##_##id = this;                                       \
-        this.fld = counter;                                     \
-        array[counter++] = this;                                \
+        this.fld = array##_COUNT;                               \
+        array[array##_COUNT++] = this;                          \
         if (!array##_first)    array##_first = this;            \
         if ( array##_last)     array##_last.enemy = this;       \
         array##_last = this;                                    \
index 5085d3b4a94c3e9cc1f9aeff37174297bab92550..7c7dc70db94987fd0a9ec17da3cffec0f9333713 100644 (file)
@@ -2,14 +2,11 @@
 #ifndef GAMESETTINGS_H
 #define GAMESETTINGS_H
 
-void RegisterSettings();
-const int MAX_SETTINGS = 24;
-Lazy SETTINGS[MAX_SETTINGS], SETTINGS_first, SETTINGS_last;
-int SETTINGS_COUNT;
+REGISTRY(Settings, BIT(3))
+REGISTER_REGISTRY(RegisterSettings)
 #define REGISTER_SETTINGS(id, impl) \
     LAZY_NEW(id, impl) \
-    REGISTER(RegisterSettings, MENU, SETTINGS, SETTINGS_COUNT, id, m_id, NEW(Lazy, LAZY(id)))
-REGISTER_REGISTRY(RegisterSettings)
+    REGISTER(RegisterSettings, MENU, Settings, id, m_id, NEW(Lazy, LAZY(id)))
 
 #endif
 #endif
index 16bc110adb2516d8c80b86aad5a51009e0f7e11d..69ab6758226e19356fd8d9cd459c93dcd5f6ebe7 100644 (file)
@@ -7,12 +7,12 @@
 CLASS(SettingSource, DataSource)
     METHOD(SettingSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
     {
-        Lazy l = SETTINGS[i];
+        Lazy l = Settings[i];
         entity it = l.m_get();
         if (returns) returns(it.title, string_null);
         return it;
     }
-    METHOD(SettingSource, reload, int(entity this, string filter)) { return SETTINGS_COUNT; }
+    METHOD(SettingSource, reload, int(entity this, string filter)) { return Settings_COUNT; }
 ENDCLASS(SettingSource)
 
 #include "listbox.qc"
index c02b42513bc9fae4bd26bb580026d79db0ab45eb..be45c3db0c3785f51f9d5f62744961b7c09ec117 100644 (file)
@@ -380,9 +380,9 @@ void kh_Key_AssignTo(entity key, entity player)  // runs every time a key is pic
                        {
                                if (!k.owner) continue;
                                entity first = WP_Null;
-                               FOREACH(WAYPOINTS, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, LAMBDA(first = it; break));
+                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, LAMBDA(first = it; break));
                                entity third = WP_Null;
-                               FOREACH(WAYPOINTS, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, LAMBDA(third = it; break));
+                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, LAMBDA(third = it; break));
                                WaypointSprite_UpdateSprites(k.owner.waypointsprite_attachedforcarrier, first, WP_KeyCarrierFinish, third);
                        }
                }
@@ -395,9 +395,9 @@ void kh_Key_AssignTo(entity key, entity player)  // runs every time a key is pic
                        {
                                if (!k.owner) continue;
                                entity first = WP_Null;
-                               FOREACH(WAYPOINTS, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, LAMBDA(first = it; break));
+                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, LAMBDA(first = it; break));
                                entity third = WP_Null;
-                               FOREACH(WAYPOINTS, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, LAMBDA(third = it; break));
+                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, LAMBDA(third = it; break));
                                WaypointSprite_UpdateSprites(k.owner.waypointsprite_attachedforcarrier, first, WP_KeyCarrierFriend, third);
                        }
                }