]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Registry: hide arrays
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 1 Nov 2015 04:56:44 +0000 (15:56 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 1 Nov 2015 04:56:44 +0000 (15:56 +1100)
37 files changed:
qcsrc/client/hud.qc
qcsrc/client/hud.qh
qcsrc/client/hud_config.qc
qcsrc/client/weapons/projectile.qc
qcsrc/common/buffs/all.qh
qcsrc/common/command/all.qh
qcsrc/common/deathtypes/all.qc
qcsrc/common/deathtypes/all.qh
qcsrc/common/effects/all.qc
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.inc
qcsrc/common/models/all.qh
qcsrc/common/monsters/all.qh
qcsrc/common/mutators/base.qh
qcsrc/common/mutators/mutator/casings.qc
qcsrc/common/mutators/mutator/waypoints/all.qh
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/nades/all.qh
qcsrc/common/notifications.qh
qcsrc/common/sounds/all.inc
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/g_damage.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator/mutator_nades.qc

index b24d7cb387a77b8f8c9bf8df7992867fdef59872..070bcbff17b75d55b17d8779dd872eed6af0f46c 100644 (file)
@@ -846,8 +846,9 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan
        float bonusNades    = getstatf(STAT_NADE_BONUS);
        float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE);
        float bonusType     = getstati(STAT_NADE_BONUS_TYPE);
-       vector nadeColor    = Nades[bonusType].m_color;
-       string nadeIcon     = Nades[bonusType].m_icon;
+       Nade def = Nades_from(bonusType);
+       vector nadeColor    = def.m_color;
+       string nadeIcon     = def.m_icon;
 
        vector iconPos, textPos;
 
@@ -2221,7 +2222,7 @@ void HUD_Radar(void)
                                drawpic(coord - '8 8 0', "gfx/teamradar_icon_glow", '16 16 0', brightcolor, panel_fg_alpha, 0);
                        }
                }
-               entity icon = RadarIcons[tm.teamradar_icon];
+               entity icon = RadarIcons_from(tm.teamradar_icon);
                draw_teamradar_icon(tm.origin, icon, tm, spritelookupcolor(tm, icon.netname, tm.teamradar_color), panel_fg_alpha);
        }
        for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
@@ -4834,7 +4835,7 @@ void HUD_Main(void)
        hud_draw_maximized = 0;
        // draw panels in the order specified by panel_order array
        for(i = hud_panels_COUNT - 1; i >= 0; --i)
-               HUD_Panel_Draw(hud_panels[panel_order[i]]);
+               HUD_Panel_Draw(hud_panels_from(panel_order[i]));
 
        HUD_Vehicle();
 
index 95a80a9eedf328c79aae6b65e44f6158dfe6f485..60386ac1e683c1f2e26e1678ca309e67eed569e0 100644 (file)
@@ -7,6 +7,7 @@ bool HUD_Radar_Clickable();
 void HUD_Radar_Mouse();
 
 REGISTRY(hud_panels, BITS(6))
+#define hud_panels_from(i) _hud_panels_from(i, NULL)
 REGISTER_REGISTRY(Registerhud_panels)
 
 #define REGISTER_HUD_PANEL(id, draw_func, name, configflags, showflags) \
index 48b3c821d20cf35d5f4ec0330dc4c368d99de5b0..6b05078d51e0800eb0a359e04603c46f1ef67aab 100644 (file)
@@ -55,7 +55,7 @@ void HUD_Panel_ExportCfg(string cfgname)
                // common cvars for all panels
                for (int i = 0; i < hud_panels_COUNT; ++i)
                {
-                       panel = hud_panels[i];
+                       panel = hud_panels_from(i);
 
                        HUD_Write_PanelCvar_n("");
                        HUD_Write_PanelCvar_q("_pos");
@@ -234,7 +234,7 @@ vector HUD_Panel_CheckMove(vector myPos, vector mySize)
        vector myTarget = myPos;
        int i;
        for (i = 0; i < hud_panels_COUNT; ++i) {
-               panel = hud_panels[i];
+               panel = hud_panels_from(i);
                if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
                if(panel == highlightedPanel) continue;
                HUD_Panel_UpdatePosSize();
@@ -331,7 +331,7 @@ vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
        float ratio = mySize.x/mySize.y;
        int i;
        for (i = 0; i < hud_panels_COUNT; ++i) {
-               panel = hud_panels[i];
+               panel = hud_panels_from(i);
                if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
                if(panel == highlightedPanel) continue;
                HUD_Panel_UpdatePosSize();
@@ -783,7 +783,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                {
                        for(i = 0; i < hud_panels_COUNT; ++i)
                        {
-                               panel = hud_panels[i];
+                               panel = hud_panels_from(i);
                                if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
                                        continue;
                                if (panel == tab_panels[i] || panel == starting_panel)
@@ -932,7 +932,7 @@ float HUD_Panel_Check_Mouse_Pos(float allow_move)
                i = panel_order[j];
                j += 1;
 
-               panel = hud_panels[i];
+               panel = hud_panels_from(i);
                if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
                HUD_Panel_UpdatePosSize();
 
@@ -1014,7 +1014,7 @@ void HUD_Panel_Highlight(float allow_move)
                i = panel_order[j];
                j += 1;
 
-               panel = hud_panels[i];
+               panel = hud_panels_from(i);
                if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
                        continue;
                HUD_Panel_UpdatePosSize();
@@ -1024,7 +1024,7 @@ void HUD_Panel_Highlight(float allow_move)
                // move
                if(allow_move && mousepos.x > panel_pos.x && mousepos.y > panel_pos.y && mousepos.x < panel_pos.x + panel_size.x && mousepos.y < panel_pos.y + panel_size.y)
                {
-                       highlightedPanel = hud_panels[i];
+                       highlightedPanel = hud_panels_from(i);
                        HUD_Panel_FirstInDrawQ(i);
                        highlightedAction = 1;
                        panel_click_distance = mousepos - panel_pos;
@@ -1033,7 +1033,7 @@ void HUD_Panel_Highlight(float allow_move)
                // resize from topleft border
                else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
                {
-                       highlightedPanel = hud_panels[i];
+                       highlightedPanel = hud_panels_from(i);
                        HUD_Panel_FirstInDrawQ(i);
                        highlightedAction = 2;
                        resizeCorner = 1;
@@ -1044,7 +1044,7 @@ void HUD_Panel_Highlight(float allow_move)
                // resize from topright border
                else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
                {
-                       highlightedPanel = hud_panels[i];
+                       highlightedPanel = hud_panels_from(i);
                        HUD_Panel_FirstInDrawQ(i);
                        highlightedAction = 2;
                        resizeCorner = 2;
@@ -1056,7 +1056,7 @@ void HUD_Panel_Highlight(float allow_move)
                // resize from bottomleft border
                else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + panel_size.y + border)
                {
-                       highlightedPanel = hud_panels[i];
+                       highlightedPanel = hud_panels_from(i);
                        HUD_Panel_FirstInDrawQ(i);
                        highlightedAction = 2;
                        resizeCorner = 3;
@@ -1068,7 +1068,7 @@ void HUD_Panel_Highlight(float allow_move)
                // resize from bottomright border
                else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + panel_size.y + border)
                {
-                       highlightedPanel = hud_panels[i];
+                       highlightedPanel = hud_panels_from(i);
                        HUD_Panel_FirstInDrawQ(i);
                        highlightedAction = 2;
                        resizeCorner = 4;
@@ -1243,7 +1243,7 @@ void HUD_Configure_Frame()
                                setcursormode(1);
                        hudShiftState = 0;
                        for(i = hud_panels_COUNT - 1; i >= 0; --i)
-                               hud_panels[panel_order[i]].update_time = time;
+                               hud_panels_from(panel_order[i]).update_time = time;
                }
 
                // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
index 7d6abf31248ff93e8d037ac446b62c1dd34c846b..9969a89f140f9780cd593007a6e2d78def7e3692 100644 (file)
@@ -45,7 +45,7 @@ void Projectile_DrawTrail(entity this, vector to)
        if (this.traileffect)
        {
                particles_alphamin = particles_alphamax = particles_fade = sqrt(this.alpha);
-               boxparticles(particleeffectnum(Effects[this.traileffect]), this, from, to, this.velocity, this.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
+               boxparticles(particleeffectnum(Effects_from(this.traileffect)), this, from, to, this.velocity, this.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
        }
 }
 
index 450917390a3615a14dc0add6638ef172acf36f7a..073e3b3aad0197377ab47dc6d71e5069834e57e5 100644 (file)
@@ -9,6 +9,7 @@
 #include "../util.qh"
 
 REGISTRY(Buffs, BITS(4))
+#define Buffs_from(i) _Buffs_from(i, BUFF_Null)
 REGISTER_REGISTRY(RegisterBuffs)
 
 #define REGISTER_BUFF(id) \
index d1164f11ada6029b931fe3f4fddd17391b36a388..b2e85dd87a33eaefdb3b2b4a40602bdfe23acbe5 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "command.qh"
 REGISTRY(GENERIC_COMMANDS, BITS(7))
+#define GENERIC_COMMANDS_from(i) _GENERIC_COMMANDS_from(i, NULL)
 REGISTER_REGISTRY(RegisterGENERIC_COMMANDS)
 REGISTRY_SORT(GENERIC_COMMANDS, m_name, 0)
 
index 4fdafa9a82b6a5d54f92b9349eb9e3098f13f597..823a20f8e0467a5e97d1986c16de124389f1090f 100644 (file)
@@ -3,7 +3,7 @@
 string Deathtype_Name(int deathtype)
 {
        if (DEATH_ISSPECIAL(deathtype)) {
-               entity deathent = Deathtypes[deathtype - DT_FIRST];
+               entity deathent = Deathtypes_from(deathtype - DT_FIRST);
                if (!deathent) { backtrace("Deathtype_Name: Could not find deathtype entity!\n"); return ""; }
                return deathent.nent_name;
        }
index 9562ab7868c73c696cb1d0526c93461c0afafafd..28f5a16b782522a5164b084722fe442bcbb3fc42 100644 (file)
@@ -4,6 +4,7 @@
 #include "../notifications.qh"
 
 REGISTRY(Deathtypes, BITS(8))
+#define Deathtypes_from(i) _Deathtypes_from(i, NULL)
 REGISTER_REGISTRY(RegisterDeathtypes)
 
 .entity death_msgself;
@@ -32,11 +33,11 @@ const int DEATH_HITTYPEMASK = HITTYPE_SECONDARY | HITTYPE_SPLASH | HITTYPE_BOUNC
 const int DT_FIRST = BIT(13);
 
 #define DEATH_ISSPECIAL(t)      (t >= DT_FIRST)
-#define DEATH_IS(t, dt)         (DEATH_ISSPECIAL(t) && (Deathtypes[t - DT_FIRST]) == dt)
-#define DEATH_ENT(t)            (DEATH_ISSPECIAL(t) ?  (Deathtypes[t - DT_FIRST]) : NULL)
-#define DEATH_ISVEHICLE(t)      (DEATH_ISSPECIAL(t) && (Deathtypes[t - DT_FIRST]).death_msgextra == "vehicle")
-#define DEATH_ISTURRET(t)       (DEATH_ISSPECIAL(t) && (Deathtypes[t - DT_FIRST]).death_msgextra == "turret")
-#define DEATH_ISMONSTER(t)      (DEATH_ISSPECIAL(t) && (Deathtypes[t - DT_FIRST]).death_msgextra == "monster")
+#define DEATH_IS(t, dt)         (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)) == dt)
+#define DEATH_ENT(t)            (DEATH_ISSPECIAL(t) ?  (Deathtypes_from(t - DT_FIRST)) : NULL)
+#define DEATH_ISVEHICLE(t)      (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "vehicle")
+#define DEATH_ISTURRET(t)       (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "turret")
+#define DEATH_ISMONSTER(t)      (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "monster")
 #define DEATH_WEAPONOF(t)       (DEATH_ISSPECIAL(t) ? WEP_Null : get_weaponinfo((t) & DEATH_WEAPONMASK))
 #define DEATH_ISWEAPON(t, w)    (DEATH_WEAPONOF(t) == (w))
 
index 6b136fa49b4b880d79057dcc9fc4c4535727a997..a18d741f61a0c8571905ab435c13d11a885e8cab 100644 (file)
@@ -5,7 +5,7 @@ void Read_Effect(bool is_new)
 {
        int net_name = (Effects_COUNT >= 255) ? ReadShort() : ReadByte();
 
-       entity eff = Effects[net_name];
+       entity eff = Effects_from(net_name);
 
        vector v, vel = '0 0 0';
        int eff_cnt = 1;
index 39c67dc9628bdd9c9c3d9ffc057e4427d3fa55fd..5006ff090390c8e48bc6386b35df4c2215b44739 100644 (file)
@@ -11,6 +11,7 @@ void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt);
 #endif
 
 REGISTRY(Effects, BITS(8))
+#define Effects_from(i) _Effects_from(i, EFFECT_Null)
 REGISTER_REGISTRY(RegisterEffects)
 #define EFFECT(istrail, name, realname) \
     REGISTER(RegisterEffects, EFFECT, Effects, name, m_id, Create_Effect_Entity(realname, istrail));
index f85ad06b127f1063ce7f9919129cd1c5520ca17c..d6e929b2017b358b393dfdfd9b9fb2c845222f96 100644 (file)
@@ -320,6 +320,7 @@ 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)
 #define EFFECTINFO(name) \
     [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \
index 4d76aa3386dfb8cd54b0ad104f07017df9554a14..ca0189292ffa4b2dd4288b541541f988774c2ac0 100644 (file)
@@ -6,6 +6,7 @@
 #include "item.qh"
 
 REGISTRY(Items, BITS(5))
+#define Items_from(i) _Items_from(i, NULL)
 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, id, m_id, NEW(class))
index 3466d7ee32d2b2ff44001bd8def131b7995c03e7..24674b6d66a4ce79b0eb3353f800de946a2c302e 100644 (file)
@@ -43,6 +43,7 @@ CLASS(Gametype, Object)
 ENDCLASS(Gametype)
 
 REGISTRY(Gametypes, BITS(4))
+#define Gametypes_from(i) _Gametypes_from(i, NULL)
 REGISTER_REGISTRY(RegisterGametypes)
 int MAPINFO_TYPE_ALL;
 #define REGISTER_GAMETYPE(hname, sname, g_name, NAME, gteamplay, mutators, defaults, gdescription)          \
index 50eb5b42d33f69e4b7bde77248526f1e59ececd0..9a5131995ef210e1916a979894bbf775375c4658 100644 (file)
@@ -115,6 +115,7 @@ 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)
 #define REGISTER_MINIGAME(name,nicename) \
     REGISTER(RegisterMinigames, MINIGAME, Minigames, name, m_id, spawn()); \
index af23fd19323fe270d8601e51bc6050ba7f9f7b75..02c3c82fa32d399017de992346958fd8daa3273d 100644 (file)
@@ -47,6 +47,7 @@ entity minigame_sessions;
 bool minigame_SendEntity(entity this, entity to, int sf);
 
 REGISTRY(Minigames, BITS(3))
+#define Minigames_from(i) _Minigames_from(i, NULL)
 REGISTER_REGISTRY(RegisterMinigames)
 #define REGISTER_MINIGAME(name,nicename) \
     REGISTER(RegisterMinigames, MINIGAME, Minigames, name, m_id, spawn()); \
index f675d8a9e1fd2f0b95f5e2a940c26f1f76038255..bd1f0b9e75f0ea18f5074a87304311f70860c36d 100644 (file)
@@ -144,7 +144,7 @@ MODEL(GIB_ROBO_7,                       "models/gibs/robo7.md3");
 MODEL(GIB_ROBO_8,                       "models/gibs/robo8.md3");
 Model MDL_GIB_ROBO_RANDOM() {
     int i = floor(random() * 8);
-    return Models[MDL_GIB_ROBO_1.m_id + i];
+    return Models_from(MDL_GIB_ROBO_1.m_id + i);
 }
 
 MODEL(CASING_SHELL,                     "models/casing_shell.mdl");
@@ -346,7 +346,7 @@ MODEL(9,                                "models/sprites/9.spr32");
 MODEL(10,                               "models/sprites/10.spr32");
 Model MDL_NUM(int i) {
     if ((i >= 0 && i <= 10))
-        return Models[MDL_0.m_id + i];
+        return Models_from(MDL_0.m_id + i);
     return MDL_Null;
 }
 
index ed8a31a0dd2e82b9d04c8ea7f4e2af3c3d33606a..f38b23fff9f63508aac9e60a955fd2cf5d1a8d7a 100644 (file)
@@ -4,6 +4,7 @@
 #include "model.qh"
 
 REGISTRY(Models, BITS(9))
+#define Models_from(i) _Models_from(i, MDL_Null)
 REGISTER_REGISTRY(RegisterModels)
 
 #define MODEL(name, path) \
index f32470b58467b1613c3a0cff82bd765c5496ab91..5e46e8a80b56e6c3c6c93259a3a4126b0f6acafa 100644 (file)
@@ -6,6 +6,8 @@
 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)
 const int MON_FIRST = 1;
 #define MON_LAST (Monsters_COUNT - 1)
@@ -14,14 +16,6 @@ const int MON_FIRST = 1;
 
 REGISTER_MONSTER(Null, NEW(Monster));
 
-Monster get_monsterinfo(int id)
-{
-       if (id >= MON_FIRST && id <= MON_LAST) {
-               Monster m = Monsters[id];
-               if (m) return m;
-       }
-       return MON_Null;
-}
 
 #include "all.inc"
 
index ce98cd508e90a9fe0314e70d1baaa09a0cecc8e8..b125c145e4c2d31439616c2379fd05a23908513b 100644 (file)
@@ -155,6 +155,7 @@ CLASS(Mutator, Object)
 ENDCLASS(Mutator)
 
 REGISTRY(Mutators, BITS(6))
+#define Mutators_from(i) _Mutators_from(i, NULL)
 Mutator loaded_mutators[Mutators_MAX];
 
 bool Mutator_Add(Mutator mut)
index 319ab8e771baffef0cd8d7a5401f874659ebbdf1..249757b7b5d16591cfadb8e8290873e87c401895 100644 (file)
@@ -70,13 +70,13 @@ SOUND(BRASS1, W_Sound("brass1"));
 SOUND(BRASS2, W_Sound("brass2"));
 SOUND(BRASS3, W_Sound("brass3"));
 Sound SND_BRASS_RANDOM() {
-    return Sounds[SND_BRASS1.m_id + floor(prandom() * 3)];
+    return Sounds_from(SND_BRASS1.m_id + floor(prandom() * 3));
 }
 SOUND(CASINGS1, W_Sound("casings1"));
 SOUND(CASINGS2, W_Sound("casings2"));
 SOUND(CASINGS3, W_Sound("casings3"));
 Sound SND_CASINGS_RANDOM() {
-    return Sounds[SND_CASINGS1.m_id + floor(prandom() * 3)];
+    return Sounds_from(SND_CASINGS1.m_id + floor(prandom() * 3));
 }
 
 void Casing_Touch()
index 27797b7f4c05986f084214c76915558890a7c5df..d5187b4b868399bdaa0356368f554649ab59a8d6 100644 (file)
@@ -4,6 +4,7 @@
 #include "waypointsprites.qh"
 
 REGISTRY(Waypoints, BITS(6))
+#define Waypoints_from(i) _Waypoints_from(i, WP_Null)
 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)
@@ -26,6 +27,7 @@ ENDCLASS(Waypoint)
 #define REGISTER_WAYPOINT(id, text, color, blink) REGISTER_WAYPOINT_(id, NEW(Waypoint, #id, text, color, blink))
 
 REGISTRY(RadarIcons, BITS(7))
+#define RadarIcons_from(i) _RadarIcons_from(i, RADARICON_NONE)
 REGISTER_REGISTRY(RegisterRadarIcons)
 .int m_radaricon;
 #define REGISTER_RADARICON(id, num) REGISTER(RegisterRadarIcons, RADARICON, RadarIcons, id, m_id, new(RadarIcon)) { this.m_radaricon = num; this.netname = #id; }
index 16e8628b178cc1445539b1b2b24438d16e58dd54..491bff1c810646d1b2c6d4f425aa3c080828459e 100644 (file)
@@ -224,7 +224,7 @@ float spritelookupblinkvalue(string s)
         if (get_weaponinfo(self.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
             return 2;
     }
-    if (s == WP_Item.netname) return Items[self.wp_extra].m_waypointblink;
+    if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypointblink;
 
     return 1;
 }
@@ -232,8 +232,8 @@ float spritelookupblinkvalue(string s)
 vector spritelookupcolor(entity this, string s, vector def)
 {
     if (s == WP_Weapon.netname  || s == RADARICON_Weapon.netname) return get_weaponinfo(this.wp_extra).wpcolor;
-    if (s == WP_Item.netname    || s == RADARICON_Item.netname) return Items[this.wp_extra].m_color;
-    if (s == WP_Buff.netname    || s == RADARICON_Buff.netname) return Buffs[this.wp_extra].m_color;
+    if (s == WP_Item.netname    || s == RADARICON_Item.netname) return Items_from(this.wp_extra).m_color;
+    if (s == WP_Buff.netname    || s == RADARICON_Buff.netname) return Buffs_from(this.wp_extra).m_color;
     return def;
 }
 
@@ -241,8 +241,8 @@ string spritelookuptext(string s)
 {SELFPARAM();
     if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
     if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).m_name;
-    if (s == WP_Item.netname) return Items[self.wp_extra].m_waypoint;
-    if (s == WP_Buff.netname) return Buffs[self.wp_extra].m_prettyName;
+    if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypoint;
+    if (s == WP_Buff.netname) return Buffs_from(self.wp_extra).m_prettyName;
     if (s == WP_Monster.netname) return get_monsterinfo(self.wp_extra).monster_name;
 
     // need to loop, as our netname could be one of three
index 37c9bee5ff2578d068fcd5a9e9b8b3580c475cc5..9b2b6ec35e3746fffdc57ab7aba72e14f06f8171 100644 (file)
@@ -22,6 +22,7 @@ const int PROJECTILE_NADE_MONSTER = 82;
 const int PROJECTILE_NADE_MONSTER_BURN = 83;
 
 REGISTRY(Nades, BITS(4))
+#define Nades_from(i) _Nades_from(i, NADE_TYPE_Null)
 REGISTER_REGISTRY(RegisterNades)
 #define REGISTER_NADE(id) REGISTER(RegisterNades, NADE_TYPE, Nades, id, m_id, NEW(Nade))
 
index e1779b613f406daa60f9914660fbfcab4d730d32..076206fa76cc8108aa3aef537a4f4cc904f03249 100644 (file)
@@ -318,8 +318,8 @@ const float ARG_DC = 6; // unique result to durcnt/centerprint
     ARG_CASE(ARG_CS_SV,     "spree_end",     (autocvar_notification_show_sprees ? notif_arg_spree_inf(-1, "", "", f1) : "")) \
     ARG_CASE(ARG_CS_SV,     "spree_lost",    (autocvar_notification_show_sprees ? notif_arg_spree_inf(-2, "", "", f1) : "")) \
     ARG_CASE(ARG_CS_SV,     "item_wepname",  WEP_NAME(f1)) \
-    ARG_CASE(ARG_CS_SV,     "item_buffname", sprintf("%s%s", rgb_to_hexcolor(Buffs[f1].m_color), Buffs[f1].m_prettyName)) \
-    ARG_CASE(ARG_CS_SV,     "f3buffname",    sprintf("%s%s", rgb_to_hexcolor(Buffs[f3].m_color), Buffs[f3].m_prettyName)) \
+    ARG_CASE(ARG_CS_SV,     "item_buffname", sprintf("%s%s", rgb_to_hexcolor(Buffs_from(f1).m_color), Buffs_from(f1).m_prettyName)) \
+    ARG_CASE(ARG_CS_SV,     "f3buffname",    sprintf("%s%s", rgb_to_hexcolor(Buffs_from(f3).m_color), Buffs_from(f3).m_prettyName)) \
     ARG_CASE(ARG_CS_SV,     "item_wepammo",  (s1 != "" ? sprintf(_(" with %s"), s1) : "")) \
     ARG_CASE(ARG_DC,        "item_centime",  ftos(autocvar_notification_item_centerprinttime)) \
     ARG_CASE(ARG_SV,        "death_team",    Team_ColoredFullName(f1)) \
index 8a7dbbca37fafc2c155ba5b0fb2d40a3bc7b7456..87c28c353f30a5d8f1e83fc7085f5f8b2b1a1fe3 100644 (file)
@@ -36,7 +36,7 @@ SOUND(GRENADE_BOUNCE4, W_Sound("grenade_bounce4"));
 SOUND(GRENADE_BOUNCE5, W_Sound("grenade_bounce5"));
 SOUND(GRENADE_BOUNCE6, W_Sound("grenade_bounce6"));
 Sound SND_GRENADE_BOUNCE_RANDOM() {
-    return Sounds[SND_GRENADE_BOUNCE1.m_id + rint(random() * 5)];
+    return Sounds_from(SND_GRENADE_BOUNCE1.m_id + rint(random() * 5));
 }
 SOUND(GRENADE_FIRE, W_Sound("grenade_fire"));
 SOUND(GRENADE_IMPACT, W_Sound("grenade_impact"));
@@ -48,7 +48,7 @@ SOUND(HAGEXP1, W_Sound("hagexp1"));
 SOUND(HAGEXP2, W_Sound("hagexp2"));
 SOUND(HAGEXP3, W_Sound("hagexp3"));
 Sound SND_HAGEXP_RANDOM() {
-    return Sounds[SND_HAGEXP1.m_id + rint(random() * 2)];
+    return Sounds_from(SND_HAGEXP1.m_id + rint(random() * 2));
 }
 
 SOUND(HOOKBOMB_FIRE, W_Sound("hookbomb_fire"));
@@ -71,7 +71,7 @@ SOUND(NEXWHOOSH1, W_Sound("nexwhoosh1"));
 SOUND(NEXWHOOSH2, W_Sound("nexwhoosh2"));
 SOUND(NEXWHOOSH3, W_Sound("nexwhoosh3"));
 Sound SND_NEXWHOOSH_RANDOM() {
-    return Sounds[SND_NEXWHOOSH1.m_id + rint(random() * 2)];
+    return Sounds_from(SND_NEXWHOOSH1.m_id + rint(random() * 2));
 }
 SOUND(RELOAD, W_Sound("reload")); // until weapons have individual reload sounds, precache the reload sound here
 
@@ -79,7 +79,7 @@ SOUND(RIC1, W_Sound("ric1"));
 SOUND(RIC2, W_Sound("ric2"));
 SOUND(RIC3, W_Sound("ric3"));
 Sound SND_RIC_RANDOM() {
-    return Sounds[SND_RIC1.m_id + rint(random() * 2)];
+    return Sounds_from(SND_RIC1.m_id + rint(random() * 2));
 }
 
 SOUND(ROCKET_DET, W_Sound("rocket_det"));
@@ -260,7 +260,7 @@ SOUND(GIB_SPLAT02, "misc/gib_splat02.wav");
 SOUND(GIB_SPLAT03, "misc/gib_splat03.wav");
 SOUND(GIB_SPLAT04, "misc/gib_splat04.wav");
 Sound SND_GIB_SPLAT_RANDOM() {
-    return Sounds[SND_GIB_SPLAT01.m_id + floor(prandom() * 4)];
+    return Sounds_from(SND_GIB_SPLAT01.m_id + floor(prandom() * 4));
 }
 
 SOUND(HIT, "misc/hit.wav");
index d39c701d7f0a2887295f557a01747bbb4c8bf18a..fd56eeca37f89a865a4f64e0af758f3491014282 100644 (file)
@@ -4,6 +4,7 @@
 #include "sound.qh"
 
 REGISTRY(Sounds, BITS(8))
+#define Sounds_from(i) _Sounds_from(i, SND_Null)
 REGISTER_REGISTRY(RegisterSounds)
 
 #define SOUND(name, path) \
index fa16be08b2bcf16650880838aba33c7875d8f20e..0848478bfd9d8a4c65ac560e0000e07cb33c62a6 100644 (file)
@@ -7,6 +7,8 @@
 #include "turret.qh"
 
 REGISTRY(Turrets, BITS(5))
+#define Turrets_from(i) _Turrets_from(i, TUR_Null)
+#define get_turretinfo(i) Turrets_from(i)
 REGISTER_REGISTRY(RegisterTurrets)
 
 
@@ -71,15 +73,6 @@ const int TUR_FIRST = 1;
 
 REGISTER_TURRET(Null, NEW(Turret));
 
-Turret get_turretinfo(int id)
-{
-    if (id >= TUR_FIRST && id <= TUR_LAST) {
-        Turret t = Turrets[id];
-        if (t) return t;
-    }
-    return TUR_Null;
-}
-
 #include "all.inc"
 
 #endif
index 8a57182f8132757b1a6b4e0f97845c9702406f43..f5d643431b2a4cad714abfd8c6cfc6e700deada3 100644 (file)
@@ -4,6 +4,8 @@
 #include "vehicle.qh"
 
 REGISTRY(Vehicles, BITS(3))
+#define Vehicles_from(i) _Vehicles_from(i, VEH_Null)
+#define get_vehicleinfo(i) Vehicles_from(i)
 REGISTER_REGISTRY(RegisterVehicles)
 const int VEH_FIRST = 1;
 #define VEH_LAST (Vehicles_COUNT - 1)
@@ -19,15 +21,6 @@ const int VEH_FIRST = 1;
 
 REGISTER_VEHICLE(Null, NEW(Vehicle));
 
-Vehicle get_vehicleinfo(int id)
-{
-       if (id >= VEH_FIRST && id <= VEH_LAST) {
-               Vehicle v = Vehicles[id];
-               if (v) return v;
-       }
-       return VEH_Null;
-}
-
 #include "all.inc"
 
 #endif
index 722c6852e7ddf56d66844cdcc14b8de294c95a7e..d58e88701e5c41ac8c911cee3667a02bf892a486 100644 (file)
@@ -112,7 +112,7 @@ void bumble_raygun_draw(entity this)
 
     if(self.total_damages < time)
     {
-        boxparticles(particleeffectnum(Effects[self.traileffect]), self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
+        boxparticles(particleeffectnum(Effects_from(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 6ba62eb2f42afd3127adaea103c39b3b21239cb2..c8940898650f9f7b5f5692e15437ba2bb302d731 100644 (file)
@@ -34,9 +34,10 @@ WepSet ReadWepSet();
 #endif
 
 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)
 STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, LAMBDA(it.m_pickup = NEW(WeaponPickup, it))); }
-entity get_weaponinfo(int id);
 
 
 GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") // WEAPONTODO: make this work with other progs than just server
@@ -131,15 +132,6 @@ REGISTER_WEAPON(Null, NEW(Weapon));
 
 #include "all.inc"
 
-entity get_weaponinfo(int id)
-{
-    if (id >= WEP_FIRST && id <= WEP_LAST) {
-        Weapon w = Weapons[id];
-        if (w) return w;
-    }
-    return WEP_Null;
-}
-
 // TODO: remove after 0.8.2. Retains impulse number compatibility because 0.8.1 clients don't reload the weapons.cfg
 #define WEP_HARDCODED_IMPULSES 22
 
@@ -169,7 +161,7 @@ STATIC_INIT(register_weapons_done)
     #endif
     weaponorder_byid = "";
     for (int i = Weapons_MAX - 1; i >= 1; --i)
-        if (Weapons[i])
+        if (Weapons_from(i))
             weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
     weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1));
 }
index 39c9c8db881402ab4cdd066ad7effecad59775a6..1739ec69e4e04190094ccdf68174c9c18de0d550 100644 (file)
 #endif
 
 REGISTRY(LinkedEntities, BITS(4))
+#define LinkedEntities_from(i) _LinkedEntities_from(i, NULL)
 REGISTER_REGISTRY(RegisterLinkedEntities)
 REGISTRY_SORT(LinkedEntities, netname, 0)
 STATIC_INIT(RegisterLinkedEntities_renumber)
 {
        for (int i = 0; i < LinkedEntities_COUNT; ++i)
-               LinkedEntities[i].m_id = 100 + i;
+               LinkedEntities_from(i).m_id = 100 + i;
 }
 
 #ifdef CSQC
@@ -131,12 +132,13 @@ STATIC_INIT(RegisterLinkedEntities_renumber)
 #endif
 
 REGISTRY(TempEntities, BITS(4))
+#define TempEntities_from(i) _TempEntities_from(i, NULL)
 REGISTER_REGISTRY(RegisterTempEntities)
 REGISTRY_SORT(TempEntities, netname, 0)
 STATIC_INIT(RegisterTempEntities_renumber)
 {
        for (int i = 0; i < TempEntities_COUNT; ++i)
-               TempEntities[i].m_id = 115 + i;
+               TempEntities_from(i).m_id = 115 + i;
 }
 
 #ifndef MENUQC
index 811bbf31e08c4a609776cd772eb5cc07f5ada8cf..8da28619562ddcc8ac41be3bd6db98fa58837722 100644 (file)
@@ -9,8 +9,9 @@
 #define REGISTRY(id, max) \
        void Register##id() {} \
        const int id##_MAX = max; \
-       noref entity id[id##_MAX], id##_first, id##_last; \
-       int id##_COUNT;
+       noref entity _##id[id##_MAX], id##_first, id##_last; \
+       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; }
 
 /**
  * Register a new entity with a global constructor.
@@ -44,9 +45,9 @@
                entity this = inst;                                         \
                ns##_##id = this;                                           \
                this.fld = array##_COUNT;                                   \
-               array[array##_COUNT++] = this;                              \
+               _##array[array##_COUNT++] = this;                           \
                if (!array##_first)    array##_first = this;                \
-               if (array##_last)     array##_last.REGISTRY_NEXT = this;   \
+               if (array##_last)     array##_last.REGISTRY_NEXT = this;    \
                array##_last = this;                                        \
                Register_##ns##_##id##_init(this);                          \
                Register_##ns##_##id##_init_post(this);                     \
        {           \
                i += skip; j += skip;                                       \
                                                                     \
-               entity a = id[i], b = id[j];                                \
-               id[i] = b;                                                  \
-               id[j] = a;                                                  \
+               entity a = _##id[i], b = _##id[j];                          \
+               _##id[i] = b;                                               \
+               _##id[j] = a;                                               \
                                                                     \
                entity a_next = a.REGISTRY_NEXT, b_next = b.REGISTRY_NEXT;  \
                a.REGISTRY_NEXT = b_next;                                   \
                b.REGISTRY_NEXT = a_next;                                   \
                                                                     \
                if (i == 0) id##_first = b;                                 \
-               else id[i - 1].REGISTRY_NEXT = b;                           \
+               else _##id[i - 1].REGISTRY_NEXT = b;                        \
                                                                     \
                if (j == 0) id##_first = a;                                 \
-               else id[j - 1].REGISTRY_NEXT = a;                           \
+               else _##id[j - 1].REGISTRY_NEXT = a;                        \
        }                                                               \
        float _REGISTRY_CMP_##id(int i, int j, entity pass) \
        {           \
                i += skip; j += skip;                                       \
-               string a = id[i].field;                                     \
-               string b = id[j].field;                                     \
+               string a = _##id[i].field;                                  \
+               string b = _##id[j].field;                                  \
                return strcasecmp(a, b);                                    \
        }                                                               \
        STATIC_INIT(Registry_sort_##id) \
index 49c5f21dcf92c2cce64a4e3ddcae926f9b89761a..24a40edf04a267128957e6f15221b8cb382510e4 100644 (file)
@@ -5,6 +5,7 @@
 #include "xonotic/tab.qc"
 
 REGISTRY(Settings, BITS(3))
+#define Settings_from(i) _Settings_from(i, NULL)
 REGISTER_REGISTRY(RegisterSettings)
 #define REGISTER_SETTINGS(id, impl) \
     LAZY_NEW(id, impl) \
index 0a9907b808ab0441cd2074ff2d10fd77f18a5106..d8e7c4b65bec0066131d75ae8585ff59b0cdc920 100644 (file)
@@ -7,14 +7,14 @@
 CLASS(SettingSource, DataSource)
     METHOD(SettingSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
     {
-        Lazy l = Settings[i];
+        Lazy l = Settings_from(i);
         entity it = l.m_get();
         if (returns) returns(it.title, string_null);
         return it;
     }
     METHOD(SettingSource, getEntryTooltip, entity(entity this, int i, void(string theTooltip) returns))
     {
-        Lazy l = Settings[i];
+        Lazy l = Settings_from(i);
         entity it = l.m_get();
         if (returns) returns(it.tooltip);
         return it;
index 802eabd7fd7219d12b8eea680b1985e3eddfec2b..e1bd4e0abcd07efe741daece956f4156c169473c 100644 (file)
@@ -204,7 +204,7 @@ void Obituary_SpecialDeath(
 {
        if(DEATH_ISSPECIAL(deathtype))
        {
-               entity deathent = Deathtypes[deathtype - DT_FIRST];
+               entity deathent = Deathtypes_from(deathtype - DT_FIRST);
                if (!deathent) { backtrace("Obituary_SpecialDeath: Could not find deathtype entity!\n"); return; }
 
                if(murder)
index 0160d7687023188ef3892c93752143bbc0641609..87aeb4ee0298e29b96490c2fb7d0f6d1a0bb0b45 100644 (file)
@@ -296,7 +296,7 @@ string formatmessage(string msg)
                        case "l": replacement = NearestLocation(self.origin); break;
                        case "y": replacement = NearestLocation(cursor); break;
                        case "d": replacement = NearestLocation(self.death_origin); break;
-                       case "w": replacement = WEP_NAME((!self.weapon) ? (!self.switchweapon ? self.cnt : self.switchweapon) : self.weapon); break;
+                       case "w": replacement = WEP_NAME(((!self.weapon) ? (!self.switchweapon ? self.cnt : self.switchweapon) : self.weapon)); break;
                        case "W": replacement = ammoitems; break;
                        case "x": replacement = ((cursor_ent.netname == "" || !cursor_ent) ? "nothing" : cursor_ent.netname); break;
                        case "s": replacement = ftos(vlen(self.velocity - self.velocity_z * '0 0 1')); break;
index cc567d2b872ff5cd37198e2cb82e7127d3b418bc..c14ab12410de60bd73533fe4cebef99a9dd58e69 100644 (file)
@@ -64,7 +64,7 @@ void nade_timer_think()
 
 void nade_burn_spawn(entity _nade)
 {
-       CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[true], true);
+       CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[true], true);
 }
 
 void nade_spawn(entity _nade)
@@ -83,7 +83,7 @@ void nade_spawn(entity _nade)
 
        _nade.effects |= EF_LOWPRECISION;
 
-       CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[false], true);
+       CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[false], true);
 }
 
 void napalm_damage(float dist, float damage, float edgedamage, float burntime)
@@ -513,7 +513,7 @@ void nade_boom()
        entity expef = NULL;
        bool nade_blast = true;
 
-       switch ( Nades[self.nade_type] )
+       switch ( Nades_from(self.nade_type) )
        {
                case NADE_TYPE_NAPALM:
                        nade_blast = autocvar_g_nades_napalm_blast;
@@ -565,7 +565,7 @@ void nade_boom()
        }
 
        if(self.takedamage)
-       switch ( Nades[self.nade_type] )
+       switch ( Nades_from(self.nade_type) )
        {
                case NADE_TYPE_NAPALM: nade_napalm_boom(); break;
                case NADE_TYPE_ICE: nade_ice_boom(); break;
@@ -808,7 +808,7 @@ float nade_customize()
        {
                //self.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
                if(!self.traileffectnum)
-                       self.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[self.nade_type].m_projectile[false], self.team).eent_eff_name);
+                       self.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(self.nade_type).m_projectile[false], self.team).eent_eff_name);
                self.alpha = 1;
        }
 
@@ -852,8 +852,8 @@ void nade_prime()
        //setattachment(n, self, "bip01 l hand");
        n.exteriormodeltoclient = self;
        n.customizeentityforclient = nade_customize;
-       n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[n.nade_type].m_projectile[false], self.team).eent_eff_name);
-       n.colormod = Nades[n.nade_type].m_color;
+       n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(n.nade_type).m_projectile[false], self.team).eent_eff_name);
+       n.colormod = Nades_from(n.nade_type).m_color;
        n.realowner = self;
        n.colormap = self.colormap;
        n.glowmod = self.glowmod;
@@ -867,7 +867,7 @@ void nade_prime()
        int slot = 0; // TODO: unhardcode
        setattachment(fn, self.weaponentity[slot], "");
        fn.realowner = fn.owner = self;
-       fn.colormod = Nades[n.nade_type].m_color;
+       fn.colormod = Nades_from(n.nade_type).m_color;
        fn.colormap = self.colormap;
        fn.glowmod = self.glowmod;
        fn.think = SUB_Remove;