]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/registry_API' into 'master'
authorMario <mario.mario@y7mail.com>
Fri, 29 May 2020 09:46:59 +0000 (09:46 +0000)
committerMario <mario.mario@y7mail.com>
Fri, 29 May 2020 09:46:59 +0000 (09:46 +0000)
Registry API

See merge request xonotic/xonotic-data.pk3dir!821

84 files changed:
qcsrc/client/commands/cl_cmd.qh
qcsrc/client/hud/hud.qc
qcsrc/client/hud/hud.qh
qcsrc/client/hud/hud_config.qc
qcsrc/client/hud/panel/notify.qc
qcsrc/client/hud/panel/radar.qc
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/hud/panel/weapons.qc
qcsrc/client/main.qc
qcsrc/client/view.qc
qcsrc/client/weapons/projectile.qc
qcsrc/common/animdecide.qh
qcsrc/common/command/reg.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/effects/qc/casings.qc
qcsrc/common/effects/qc/globalsound.qc
qcsrc/common/effects/qc/globalsound.qh
qcsrc/common/ent_cs.qc
qcsrc/common/impulses/all.qh
qcsrc/common/items/all.qh
qcsrc/common/items/inventory.qh
qcsrc/common/mapinfo.qc
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/monsters/sv_monsters.qc
qcsrc/common/mutators/base.qh
qcsrc/common/mutators/mutator/buffs/buffs.qc
qcsrc/common/mutators/mutator/buffs/buffs.qh
qcsrc/common/mutators/mutator/buffs/cl_buffs.qc
qcsrc/common/mutators/mutator/itemstime/itemstime.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/nades/nades.qh
qcsrc/common/mutators/mutator/nix/sv_nix.qc
qcsrc/common/mutators/mutator/stale_move_negation/sv_stale_move_negation.qc
qcsrc/common/mutators/mutator/waypoints/all.qh
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/notifications/all.qh
qcsrc/common/scores.qh
qcsrc/common/sounds/all.inc
qcsrc/common/sounds/all.qh
qcsrc/common/t_items.qc
qcsrc/common/turrets/all.qh
qcsrc/common/turrets/config.qc
qcsrc/common/util.qc
qcsrc/common/vehicles/all.qh
qcsrc/common/vehicles/cl_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/all.qh
qcsrc/common/wepent.qc
qcsrc/lib/net.qh
qcsrc/lib/registry.qh
qcsrc/lib/stats.qh
qcsrc/menu/gamesettings.qh
qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
qcsrc/menu/xonotic/dialog_settings_game.qc
qcsrc/menu/xonotic/serverlist.qc
qcsrc/menu/xonotic/weaponslist.qc
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/bot.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/scripting.qc
qcsrc/server/command/common.qh
qcsrc/server/command/reg.qh
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc
qcsrc/server/impulse.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/weapons/accuracy.qh
qcsrc/server/weapons/common.qc
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/selection.qh
qcsrc/server/weapons/spawning.qc
qcsrc/server/weapons/throwing.qc
qcsrc/server/weapons/weaponsystem.qc

index f6f96501aee2abb928a8de29ca923f602f80ea6b..725baa408e9c0c47dd748a596e26a751e1b05683 100644 (file)
@@ -8,10 +8,11 @@ void ConsoleCommand_macro_init();
 void LocalCommand_macro_write_aliases(int fh);
 
 REGISTRY(CLIENT_COMMANDS, BITS(7))
-#define CLIENT_COMMANDS_from(i) _CLIENT_COMMANDS_from(i, NULL)
 REGISTER_REGISTRY(CLIENT_COMMANDS)
 REGISTRY_SORT(CLIENT_COMMANDS)
 
+REGISTRY_DEFINE_GET(CLIENT_COMMANDS, NULL)
+
 #define CLIENT_COMMAND(id, description) \
        CLASS(clientcommand_##id, Command) \
                ATTRIB(clientcommand_##id, m_name, string, #id); \
index 3a13048d823b6398cdde1c7b9c52ced193a33449..91770fd724ecc9b3b477ce5d279a88077e0448d0 100644 (file)
@@ -408,7 +408,7 @@ void HUD_Vehicle()
        if(hud == HUD_BUMBLEBEE_GUN)
                CSQC_BUMBLE_GUN_HUD();
        else {
-               Vehicle info = Vehicles_from(hud);
+               Vehicle info = REGISTRY_GET(Vehicles, hud);
                info.vr_hud(info);
        }
 
@@ -667,18 +667,18 @@ void HUD_Main()
 
        // cache the panel order into the panel_order array
        if(autocvar__hud_panelorder != hud_panelorder_prev) {
-               for(i = 0; i < hud_panels_COUNT; ++i)
+               for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
                        panel_order[i] = -1;
                string s = "";
                int p_num;
                bool warning = false;
                int argc = tokenize_console(autocvar__hud_panelorder);
-               if (argc > hud_panels_COUNT)
+               if (argc > REGISTRY_COUNT(hud_panels))
                        warning = true;
                //first detect wrong/missing panel numbers
-               for(i = 0; i < hud_panels_COUNT; ++i) {
+               for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
                        p_num = stoi(argv(i));
-                       if (p_num >= 0 && p_num < hud_panels_COUNT) { //correct panel number?
+                       if (p_num >= 0 && p_num < REGISTRY_COUNT(hud_panels)) { //correct panel number?
                                if (panel_order[p_num] == -1) //found for the first time?
                                        s = strcat(s, ftos(p_num), " ");
                                panel_order[p_num] = 1; //mark as found
@@ -686,7 +686,7 @@ void HUD_Main()
                        else
                                warning = true;
                }
-               for(i = 0; i < hud_panels_COUNT; ++i) {
+               for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
                        if (panel_order[i] == -1) {
                                warning = true;
                                s = strcat(s, ftos(i), " "); //add missing panel number
@@ -700,15 +700,15 @@ void HUD_Main()
 
                //now properly set panel_order
                tokenize_console(s);
-               for(i = 0; i < hud_panels_COUNT; ++i) {
+               for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
                        panel_order[i] = stof(argv(i));
                }
        }
 
        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_from(panel_order[i]));
+       for(i = REGISTRY_COUNT(hud_panels) - 1; i >= 0; --i)
+               HUD_Panel_Draw(REGISTRY_GET(hud_panels, panel_order[i]));
 
        HUD_Vehicle();
 
index 2c12a6150ee560b528fdabb787029b209c80091f..38ca8a0187c9845f43bbfcc40c37ee66b7c30961 100644 (file)
@@ -11,9 +11,10 @@ bool HUD_WouldShowCursor();
 bool QuickMenu_IsOpened();
 
 REGISTRY(hud_panels, BITS(6))
-#define hud_panels_from(i) _hud_panels_from(i, NULL)
 REGISTER_REGISTRY(hud_panels)
 
+REGISTRY_DEFINE_GET(hud_panels, NULL)
+
 #define _REGISTER_HUD_PANEL(id, draw_func, export_func, configflags, showflags) \
        void draw_func(); \
        void export_func(int fh); \
@@ -43,7 +44,7 @@ REGISTER_REGISTRY(hud_panels)
                ); \
 MACRO_END
 
-int panel_order[hud_panels_MAX];
+int panel_order[REGISTRY_MAX(hud_panels)];
 string hud_panelorder_prev;
 
 bool hud_draw_maximized;
@@ -89,7 +90,7 @@ float highlightedAction; // 0 = nothing, 1 = move, 2 = resize
 
 const float BORDER_MULTIPLIER = 4;
 float scoreboard_bottom;
-int weapon_accuracy[Weapons_MAX];
+int weapon_accuracy[REGISTRY_MAX(Weapons)];
 
 entity complain_weapon;
 int complain_weapon_type;
index c4ae095ac3c559c7c3fd67a06084f990f0246e0a..9b768e0258ddcfe566b60b456cca7c119f84b1bd 100644 (file)
@@ -60,9 +60,9 @@ void HUD_Panel_ExportCfg(string cfgname)
                HUD_Write("\n");
 
                // common cvars for all panels
-               for (int i = 0; i < hud_panels_COUNT; ++i)
+               for (int i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
                {
-                       panel = hud_panels_from(i);
+                       panel = REGISTRY_GET(hud_panels, i);
 
                        HUD_Write_PanelCvar("_pos");
                        HUD_Write_PanelCvar("_size");
@@ -102,8 +102,8 @@ vector HUD_Panel_CheckMove(vector myPos, vector mySize)
        vector myCenter, targCenter;
        vector myTarget = myPos;
        int i;
-       for (i = 0; i < hud_panels_COUNT; ++i) {
-               panel = hud_panels_from(i);
+       for (i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
+               panel = REGISTRY_GET(hud_panels, i);
                if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
                if(panel == highlightedPanel) continue;
                HUD_Panel_UpdatePosSize();
@@ -199,8 +199,8 @@ vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
        vector dist;
        float ratio = mySize.x/mySize.y;
        int i;
-       for (i = 0; i < hud_panels_COUNT; ++i) {
-               panel = hud_panels_from(i);
+       for (i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
+               panel = REGISTRY_GET(hud_panels, i);
                if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
                if(panel == highlightedPanel) continue;
                HUD_Panel_UpdatePosSize();
@@ -500,13 +500,13 @@ void HUD_Panel_Arrow_Action(float nPrimary)
        }
 }
 
-entity tab_panels[hud_panels_MAX];
+entity tab_panels[REGISTRY_MAX(hud_panels)];
 entity tab_panel;
 vector tab_panel_pos;
 float tab_backward;
 void reset_tab_panels()
 {
-       for (int i = 0; i < hud_panels_COUNT; ++i)
+       for (int i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
                tab_panels[i] = NULL;
 }
 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
@@ -645,9 +645,9 @@ LABEL(find_tab_panel)
                k=0;
                while(++k)
                {
-                       for(i = 0; i < hud_panels_COUNT; ++i)
+                       for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
                        {
-                               panel = hud_panels_from(i);
+                               panel = REGISTRY_GET(hud_panels, i);
                                if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
                                        continue;
                                if (panel == tab_panels[i] || panel == starting_panel)
@@ -794,12 +794,12 @@ LABEL(find_tab_panel)
 int HUD_Panel_Check_Mouse_Pos(bool allow_move)
 {
        int i, j = 0;
-       while(j < hud_panels_COUNT)
+       while(j < REGISTRY_COUNT(hud_panels))
        {
                i = panel_order[j];
                j += 1;
 
-               panel = hud_panels_from(i);
+               panel = REGISTRY_GET(hud_panels, i);
                if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
                HUD_Panel_UpdatePosSize();
 
@@ -840,7 +840,7 @@ void HUD_Panel_FirstInDrawQ(float id)
        int i;
        int place = -1;
        // find out where in the array our current id is, save into place
-       for(i = 0; i < hud_panels_COUNT; ++i)
+       for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
        {
                if(panel_order[i] == id)
                {
@@ -850,7 +850,7 @@ void HUD_Panel_FirstInDrawQ(float id)
        }
        // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
        if(place == -1)
-               place = hud_panels_COUNT - 1;
+               place = REGISTRY_COUNT(hud_panels) - 1;
 
        // move all ids up by one step in the array until "place"
        for(i = place; i > 0; --i)
@@ -862,7 +862,7 @@ void HUD_Panel_FirstInDrawQ(float id)
 
        // let's save them into the cvar by some strcat trickery
        string s = "";
-       for(i = 0; i < hud_panels_COUNT; ++i)
+       for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
        {
                s = strcat(s, ftos(panel_order[i]), " ");
        }
@@ -874,12 +874,12 @@ void HUD_Panel_Highlight(float allow_move)
 {
        int i, j = 0;
 
-       while(j < hud_panels_COUNT)
+       while(j < REGISTRY_COUNT(hud_panels))
        {
                i = panel_order[j];
                j += 1;
 
-               panel = hud_panels_from(i);
+               panel = REGISTRY_GET(hud_panels, i);
                if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
                        continue;
                HUD_Panel_UpdatePosSize();
@@ -889,7 +889,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_from(i);
+                       highlightedPanel = REGISTRY_GET(hud_panels, i);
                        HUD_Panel_FirstInDrawQ(i);
                        highlightedAction = 1;
                        panel_click_distance = mousepos - panel_pos;
@@ -898,7 +898,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_from(i);
+                       highlightedPanel = REGISTRY_GET(hud_panels, i);
                        HUD_Panel_FirstInDrawQ(i);
                        highlightedAction = 2;
                        resizeCorner = 1;
@@ -909,7 +909,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_from(i);
+                       highlightedPanel = REGISTRY_GET(hud_panels, i);
                        HUD_Panel_FirstInDrawQ(i);
                        highlightedAction = 2;
                        resizeCorner = 2;
@@ -921,7 +921,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_from(i);
+                       highlightedPanel = REGISTRY_GET(hud_panels, i);
                        HUD_Panel_FirstInDrawQ(i);
                        highlightedAction = 2;
                        resizeCorner = 3;
@@ -933,7 +933,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_from(i);
+                       highlightedPanel = REGISTRY_GET(hud_panels, i);
                        HUD_Panel_FirstInDrawQ(i);
                        highlightedAction = 2;
                        resizeCorner = 4;
@@ -1082,8 +1082,8 @@ void HUD_Configure_Frame()
                if(!hud_configure_prev)
                {
                        hudShiftState = 0;
-                       for(i = hud_panels_COUNT - 1; i >= 0; --i)
-                               hud_panels_from(panel_order[i]).update_time = time;
+                       for(i = REGISTRY_COUNT(hud_panels) - 1; i >= 0; --i)
+                               REGISTRY_GET(hud_panels, panel_order[i]).update_time = time;
                }
 
                // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
index bfb23bf2c7e6bf2183bf092d09b55964958226f1..0dfb11db766bf0865ab7fd999e9b9d4cbd2e4ba5 100644 (file)
@@ -126,7 +126,7 @@ void HUD_Notify()
                {
                        attacker = sprintf(_("Player %d"), count + 1);
                        victim = sprintf(_("Player %d"), count + 2);
-                       icon = Weapons_from(min(WEP_FIRST + count * 2, WEP_LAST)).model2;
+                       icon = REGISTRY_GET(Weapons, min(WEP_FIRST + count * 2, WEP_LAST)).model2;
                        alpha = bound(0, 1.2 - count / entry_count, 1);
                }
                else
index b75b36d33fbd632bda6c81609e76bd2b2fb1cbfe..e31aa01e91724a4efbf271d15737c5cbeb13111e 100644 (file)
@@ -368,7 +368,7 @@ void HUD_Radar()
                                drawpic(coord - '8 8 0', "gfx/teamradar_icon_glow", '16 16 0', brightcolor, panel_fg_alpha, 0);
                        }
                }
-               entity icon = RadarIcons_from(it.teamradar_icon);
+               entity icon = REGISTRY_GET(RadarIcons, it.teamradar_icon);
                draw_teamradar_icon(it.origin, icon, it, spritelookupcolor(it, icon.netname, it.teamradar_color), panel_fg_alpha);
        });
        AL_EACH(_entcs, e, it != NULL, {
index 962759011a9e3d2b13e9f5e69d228f1e0cb75a6d..a7efc181a0b1680a94ccdb01d9ea18afda3f549c 100644 (file)
@@ -1192,11 +1192,11 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
                }
        });
 
-       int weapon_cnt = (Weapons_COUNT - 1) - disownedcnt - nHidden;
+       int weapon_cnt = (REGISTRY_COUNT(Weapons) - 1) - disownedcnt - nHidden;
        if (weapon_cnt <= 0) return pos;
 
        int rows = 1;
-       if (autocvar_hud_panel_scoreboard_accuracy_doublerows && weapon_cnt >= floor((Weapons_COUNT - nHidden - 1) * 0.5))
+       if (autocvar_hud_panel_scoreboard_accuracy_doublerows && weapon_cnt >= floor((REGISTRY_COUNT(Weapons) - nHidden - 1) * 0.5))
                rows = 2;
        int columnns = ceil(weapon_cnt / rows);
 
index f7444daaa3572cd063eaa62f454430f8ef353db0..633e37b55d6181daf041a37c1cea40a38ea3308f 100644 (file)
@@ -37,7 +37,7 @@ void HUD_Weapons_Export(int fh)
        HUD_Write_Cvar("hud_panel_weapons_selection_speed");
 }
 
-entity weaponorder[Weapons_MAX];
+entity weaponorder[REGISTRY_MAX(Weapons)];
 void weaponorder_swap(int i, int j, entity pass)
 {
        TC(int, i); TC(int, j);
@@ -61,7 +61,7 @@ int weaponorder_cmp(int i, int j, entity pass)
                if (weapons_stat & WepSet_FromWeapon(it)) continue; \
                if (it.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_SPECIALATTACK)) nHidden += 1; \
        }); \
-       vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, panel_size, aspect); \
+       vector table_size = HUD_GetTableSize_BestItemAR((REGISTRY_COUNT(Weapons) - 1) - nHidden, panel_size, aspect); \
        columns = table_size.x; \
        rows = table_size.y; \
        weapon_size.x = panel_size.x / columns; \
@@ -135,7 +135,7 @@ void HUD_Weapons()
 
                int weapon_cnt = 0;
                FOREACH(Weapons, it != WEP_Null && it.impulse >= 0, weaponorder[weapon_cnt++] = it);
-               for(i = weapon_cnt; i < Weapons_MAX; ++i)
+               for(i = weapon_cnt; i < REGISTRY_MAX(Weapons); ++i)
                        weaponorder[i] = NULL;
                heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, NULL);
 
@@ -178,8 +178,8 @@ void HUD_Weapons()
                                if (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
                        });
                        weapons_stat = '0 0 0';
-                       float countw = 1 + floor((floor(time * cvar("wep_add"))) % ((Weapons_COUNT - 1) - nHidden));
-                       for(i = 0, j = 0; i <= (Weapons_COUNT - 1) && j < countw; ++i)
+                       float countw = 1 + floor((floor(time * cvar("wep_add"))) % ((REGISTRY_COUNT(Weapons) - 1) - nHidden));
+                       for(i = 0, j = 0; i <= (REGISTRY_COUNT(Weapons) - 1) && j < countw; ++i)
                        {
                                if(weaponorder[i].spawnflags & WEP_FLAG_MUTATORBLOCKED)
                                        continue;
@@ -272,7 +272,7 @@ void HUD_Weapons()
                        panel_pos.y += (old_panel_size.y - panel_size.y) / 2;
        }
        else
-               weapon_count = (Weapons_COUNT - 1);
+               weapon_count = (REGISTRY_COUNT(Weapons) - 1);
 
        // animation for fading in/out the panel respectively when not in use
        if(!autocvar__hud_configure)
index 55868e5c79d29b6a692b91a78402682a9b16bae8..39201fd72e6a90501281cd6f46e5041e9b1c41f5 100644 (file)
@@ -1229,7 +1229,7 @@ NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew)
 NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
 {
        int weapon_id = ReadByte();
-       complain_weapon = Weapons_from(weapon_id);
+       complain_weapon = REGISTRY_GET(Weapons, weapon_id);
        complain_weapon_type = ReadByte();
        return = true;
 
index baf749ff47ee44d929a6329f0e8602e589e836cb..f3ffebac67e0dd2434466b15bfe711c297c1e3e9 100644 (file)
@@ -787,7 +787,7 @@ void View_EventChase(entity this)
                {
                        if(hud != HUD_BUMBLEBEE_GUN)
                        {
-                               Vehicle info = Vehicles_from(hud);
+                               Vehicle info = REGISTRY_GET(Vehicles, hud);
                                vehicle_viewdist = info.height;
                                vehicle_viewofs = info.view_ofs;
                                if(vehicle_viewdist < 0) // when set below 0, this vehicle doesn't use third person view (gunner slots)
@@ -898,7 +898,7 @@ void HUD_Crosshair_Vehicle(entity this)
 {
        if(hud != HUD_BUMBLEBEE_GUN)
        {
-               Vehicle info = Vehicles_from(hud);
+               Vehicle info = REGISTRY_GET(Vehicles, hud);
                info.vr_crosshair(info, this);
        }
 }
@@ -1538,7 +1538,7 @@ void SpecialCommand()
                        {
                                slot.x = bound(0, (random() * vid_conwidth + 1), vid_conwidth);
                                slot.y = 1; // start it off 0 so we can use it
-                               slot.z = floor(random() * Weapons_MAX);
+                               slot.z = floor(random() * REGISTRY_MAX(Weapons));
                                sc_spawntime = time + bound(0.4, random(), 0.75); // prevent spawning another one for this amount of time!
                                vector newcolor = randomvec() * 2;
                                newcolor.x = bound(0.4, newcolor.x, 1);
@@ -1552,7 +1552,7 @@ void SpecialCommand()
                        vector splash_size = '0 0 0';
                        splash_size.x = max(vid_conwidth, vid_conheight) * SPECIALCOMMAND_SIZE;
                        splash_size.y = max(vid_conwidth, vid_conheight) * SPECIALCOMMAND_SIZE;
-                       entity wep = Weapons_from(slot.z);
+                       entity wep = REGISTRY_GET(Weapons, slot.z);
                        if(wep == WEP_Null)
                                drawpic(vec2(slot), "gfx/smile", vec2(splash_size), specialcommand_colors[j], 0.95, DRAWFLAG_NORMAL);
                        else
index 067c0badb7da09a184c192daf1841d47c782da81..fcdac111e401aedbbd01c54a14a82bf294179385 100644 (file)
@@ -48,7 +48,8 @@ void Projectile_DrawTrail(entity this, vector to)
        if (this.traileffect)
        {
                particles_alphamin = particles_alphamax = particles_fade = sqrt(this.alpha);
-               boxparticles(particleeffectnum(Effects_from(this.traileffect)), this, from, to, this.velocity, this.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
+               entity eff = REGISTRY_GET(Effects, this.traileffect);
+               boxparticles(particleeffectnum(eff), this, from, to, this.velocity, this.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
        }
 }
 
index 16feb948c35d5c2264b9bdc21329c531c47ae2d9..bfbba7cb80b5ebb7a32988175e40878390deb773 100644 (file)
@@ -24,7 +24,8 @@ ENDCLASS(Animation)
 
 REGISTRY(Animations, BITS(8))
 REGISTER_REGISTRY(Animations)
-#define Animations_from(id) _Animations_from(id, NULL)
+
+REGISTRY_DEFINE_GET(Animations, NULL)
 #define WriteAnimation(to, it) WriteRegistered(Animations, to, it)
 #define ReadAnimation() ReadRegistered(Animations)
 #define REGISTER_ANIMATION(id, framenames) \
index a6f669fd91e04c461a2710837ae760e070c9523a..abb40b509de08165e613a1eae1f7c6b32c7ef06d 100644 (file)
@@ -2,10 +2,11 @@
 
 #include "command.qh"
 REGISTRY(GENERIC_COMMANDS, BITS(7))
-#define GENERIC_COMMANDS_from(i) _GENERIC_COMMANDS_from(i, NULL)
 REGISTER_REGISTRY(GENERIC_COMMANDS)
 REGISTRY_SORT(GENERIC_COMMANDS)
 
+REGISTRY_DEFINE_GET(GENERIC_COMMANDS, NULL)
+
 .bool m_menubased; // switch to tell whether this alias should be registered as a menu or client based command
 
 #define GENERIC_COMMAND(id, description, menubased) \
index 823a20f8e0467a5e97d1986c16de124389f1090f..6bc2995b232b2cc57a051c41b16b83957107b5ad 100644 (file)
@@ -3,7 +3,7 @@
 string Deathtype_Name(int deathtype)
 {
        if (DEATH_ISSPECIAL(deathtype)) {
-               entity deathent = Deathtypes_from(deathtype - DT_FIRST);
+               entity deathent = REGISTRY_GET(Deathtypes, deathtype - DT_FIRST);
                if (!deathent) { backtrace("Deathtype_Name: Could not find deathtype entity!\n"); return ""; }
                return deathent.nent_name;
        }
index 2169c8bd762bd3abe5e708e1f24e1b8b99333740..f4b49801872c8be06fff89cd4a04e08dca055312 100644 (file)
@@ -3,10 +3,11 @@
 #include <common/notifications/all.qh>
 
 REGISTRY(Deathtypes, BITS(8))
-#define Deathtypes_from(i) _Deathtypes_from(i, NULL)
 REGISTER_REGISTRY(Deathtypes)
 REGISTRY_CHECK(Deathtypes)
 
+REGISTRY_DEFINE_GET(Deathtypes, NULL)
+
 .entity death_msgself;
 .entity death_msgmurder;
 .string death_msgextra;
@@ -32,12 +33,12 @@ 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_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 : Weapons_from((t) & DEATH_WEAPONMASK))
+#define DEATH_IS(t, dt)         (DEATH_ISSPECIAL(t) && (REGISTRY_GET(Deathtypes, t - DT_FIRST)) == dt)
+#define DEATH_ENT(t)            (DEATH_ISSPECIAL(t) ?  (REGISTRY_GET(Deathtypes, t - DT_FIRST)) : NULL)
+#define DEATH_ISVEHICLE(t)      (DEATH_ISSPECIAL(t) && (REGISTRY_GET(Deathtypes, t - DT_FIRST)).death_msgextra == "vehicle")
+#define DEATH_ISTURRET(t)       (DEATH_ISSPECIAL(t) && (REGISTRY_GET(Deathtypes, t - DT_FIRST)).death_msgextra == "turret")
+#define DEATH_ISMONSTER(t)      (DEATH_ISSPECIAL(t) && (REGISTRY_GET(Deathtypes, t - DT_FIRST)).death_msgextra == "monster")
+#define DEATH_WEAPONOF(t)       (DEATH_ISSPECIAL(t) ? WEP_Null : REGISTRY_GET(Weapons, (t) & DEATH_WEAPONMASK))
 #define DEATH_ISWEAPON(t, w)    (DEATH_WEAPONOF(t) == (w))
 
 string Deathtype_Name(int deathtype);
index 9732be2e3bf65e82f125b176f8ed2f709d2879d6..9ee58f5fe1c07323097ca2c08ff2f9df091bf34f 100644 (file)
@@ -4,9 +4,9 @@ REGISTER_NET_TEMP(net_effect)
 #ifdef CSQC
 NET_HANDLE(net_effect, bool isNew)
 {
-       int net_name = (Effects_COUNT >= 255) ? ReadShort() : ReadByte();
+       int net_name = (REGISTRY_COUNT(Effects) >= 255) ? ReadShort() : ReadByte();
 
-       entity eff = Effects_from(net_name);
+       entity eff = REGISTRY_GET(Effects, net_name);
 
        vector vel = '0 0 0';
        int eff_cnt = 1;
@@ -34,7 +34,7 @@ bool Net_Write_Effect(entity this, entity client, int sf)
        int channel = MSG_ONE;
        msg_entity = client;
        WriteHeader(channel, net_effect);
-       (Effects_COUNT >= 255)
+       (REGISTRY_COUNT(Effects) >= 255)
        ? WriteShort(channel, this.m_id)
        : WriteByte(channel, this.m_id);
        WriteVector(channel, this.eent_net_location);
index 7581618375bd5bfc0b949b0b023435db4bebdd8e..fe7bbc31a595596debb3be13632472e11d7cf905 100644 (file)
@@ -8,11 +8,11 @@ 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(Effects)
 REGISTRY_CHECK(Effects)
 #define EFFECT(istrail, name, realname) \
     REGISTER(Effects, EFFECT, name, m_id, Create_Effect_Entity(realname, istrail));
 
 EFFECT(0, Null, string_null)
+REGISTRY_DEFINE_GET(Effects, EFFECT_Null)
 #include "all.inc"
index 79d31eb46bc5efdb473e4322a02b985101511401..6b97dd91b55fa94abeb488e48fd5a6cdc45eb9f2 100644 (file)
@@ -322,8 +322,9 @@ GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt", fa
 
 
 REGISTRY(EffectInfos, BITS(9))
-#define EffectInfos_from(i) _EffectInfos_from(i, NULL)
 REGISTER_REGISTRY(EffectInfos)
+
+REGISTRY_DEFINE_GET(EffectInfos, NULL)
 #define EFFECTINFO(name) \
     ACCUMULATE void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \
     REGISTER(EffectInfos, EFFECTINFO, name, m_id, NEW(EffectInfoGroup)) { \
index d07557f9ac011be83a17d6cd2aacaa74bce1a1bb..68eccb461227c1e7797adab66a7985b320ee1c31 100644 (file)
@@ -81,13 +81,13 @@ SOUND(BRASS1, W_Sound("brass1"));
 SOUND(BRASS2, W_Sound("brass2"));
 SOUND(BRASS3, W_Sound("brass3"));
 Sound SND_BRASS_RANDOM() {
-    return Sounds_from(SND_BRASS1.m_id + floor(prandom() * 3));
+    return REGISTRY_GET(Sounds, 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_from(SND_CASINGS1.m_id + floor(prandom() * 3));
+    return REGISTRY_GET(Sounds, SND_CASINGS1.m_id + floor(prandom() * 3));
 }
 
 void Casing_Touch(entity this, entity toucher)
index 9fc46ff67537b6cbf42d9a33e03e467feda2772b..4e8467e8a45746bb0c2fd364358a404843f566d5 100644 (file)
@@ -85,7 +85,7 @@
 
                NET_HANDLE(globalsound, bool isnew)
                {
-                       entity gs = GlobalSounds_from(ReadByte());
+                       entity gs = REGISTRY_GET(GlobalSounds, ReadByte());
                        float r = ReadByte() / 255;
                        string sample = GlobalSound_sample(gs.m_globalsoundstr, r);
                        int who = ReadByte();
 
                NET_HANDLE(playersound, bool isnew)
                {
-                       entity ps = PlayerSounds_from(ReadByte());
+                       entity ps = REGISTRY_GET(PlayerSounds, ReadByte());
                        float r = ReadByte() / 255;
                        int who = ReadByte();
                        entity e = entcs_receiver(who - 1);
index b5631ed5fd246774277adb823dae760d31700b9d..2b6b52896f88fd3ec4d935c74dc20f8efaca256a 100644 (file)
@@ -11,7 +11,6 @@
 ..string m_playersoundfld;
 
 REGISTRY(PlayerSounds, BITS(8) - 1)
-#define PlayerSounds_from(i) _PlayerSounds_from(i, NULL)
 #define REGISTER_PLAYERSOUND(id) \
        .string _playersound_##id; \
        REGISTER(PlayerSounds, playersound, id, m_id, new_pure(PlayerSound)) \
@@ -21,6 +20,8 @@ REGISTRY(PlayerSounds, BITS(8) - 1)
        }
 REGISTER_REGISTRY(PlayerSounds)
 REGISTRY_SORT(PlayerSounds)
+
+REGISTRY_DEFINE_GET(PlayerSounds, NULL)
 STATIC_INIT(PlayerSounds_renumber)
 {
        FOREACH(PlayerSounds, true, it.m_id = i);
@@ -84,7 +85,6 @@ REGISTER_VOICEMSG(seenenemy, VOICETYPE_TEAMRADIO, false)
 
 .string m_globalsoundstr;
 REGISTRY(GlobalSounds, BITS(8) - 1)
-#define GlobalSounds_from(i) _GlobalSounds_from(i, NULL)
 #define REGISTER_GLOBALSOUND(id, str) \
        REGISTER(GlobalSounds, GS, id, m_id, new_pure(GlobalSound)) \
        { \
@@ -92,6 +92,8 @@ REGISTRY(GlobalSounds, BITS(8) - 1)
        }
 REGISTER_REGISTRY(GlobalSounds)
 REGISTRY_SORT(GlobalSounds)
+
+REGISTRY_DEFINE_GET(GlobalSounds, NULL)
 STATIC_INIT(GlobalSounds_renumber)
 {
        FOREACH(GlobalSounds, true, it.m_id = i);
index 2675d3201867c3397c4ecdba7db65cc7d3f23553..a7aa27961139530a73a9a7feda0d4ae1fe8d54f4 100644 (file)
@@ -6,10 +6,11 @@
 #endif
 
 REGISTRY(EntCSProps, BITS(16) - 1)
-#define EntCSProps_from(i) _EntCSProps_from(i, NULL)
 REGISTER_REGISTRY(EntCSProps)
 REGISTRY_SORT(EntCSProps)
 REGISTRY_CHECK(EntCSProps)
+
+REGISTRY_DEFINE_GET(EntCSProps, NULL)
 STATIC_INIT(EntCSProps_renumber) { FOREACH(EntCSProps, true, it.m_id = i); }
 
 // these entcs_props ids need to be referenced directly
index e5a2b7b6019a6bb7309908b51989426b208bdca7..d870e6d2c232cf7825a94f46711831e96afc4320 100644 (file)
@@ -3,6 +3,8 @@
 REGISTRY(IMPULSES, 255)
 REGISTER_REGISTRY(IMPULSES)
 REGISTRY_SORT(IMPULSES)
+
+REGISTRY_DEFINE_GET(IMPULSES, NULL)
 STATIC_INIT(IMPULSES_renumber)
 {
        FOREACH(IMPULSES, true, it.m_id = i);
index 3ae473503db46e24d8f8877a2fb05cd998142082..840eb0a88b05c33f98e9ed2954cc6d7d74058123 100644 (file)
@@ -6,7 +6,6 @@
 
 // 24 so it matches the limit for the .items field
 REGISTRY(Items, 24)
-#define Items_from(i) _Items_from(i, NULL)
 #ifdef GAMEQC
 REGISTRY_DEPENDS(Items, Models)
 #endif
@@ -15,6 +14,8 @@ REGISTER_REGISTRY(Items)
 
 REGISTRY_SORT(Items)
 REGISTRY_CHECK(Items)
+
+REGISTRY_DEFINE_GET(Items, NULL)
 STATIC_INIT(Items) { FOREACH(Items, true, it.m_id = i); }
 
 void Dump_Items();
index 9f0a43a0750959f08d1847886e09e88ea017673d..1c9d21669d2b8d9502d1e5f69d6a8c91fb549ecd 100644 (file)
@@ -5,7 +5,7 @@
 #ifdef GAMEQC
 CLASS(Inventory, Object)
     /** Stores counts of items, the id being the index */
-    ATTRIBARRAY(Inventory, inv_items, int, Items_MAX);
+    ATTRIBARRAY(Inventory, inv_items, int, REGISTRY_MAX(Items));
     /** Previous state */
     ATTRIB(Inventory, inventory, Inventory);
 ENDCLASS(Inventory)
@@ -16,7 +16,7 @@ ENDCLASS(Inventory)
 REGISTER_NET_LINKED(ENT_CLIENT_INVENTORY)
 
 const int Inventory_groups_minor = 8; // exactly 1 byte
-const int Inventory_groups_major = 3; // ceil(Items_MAX / Inventory_groups_minor)
+const int Inventory_groups_major = 3; // ceil(REGISTRY_MAX(Items) / Inventory_groups_minor)
 
 #define G_MAJOR(id) (floor((id) / Inventory_groups_minor))
 #define G_MINOR(id) ((id) % Inventory_groups_minor)
@@ -38,7 +38,7 @@ NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew)
             if (!(minorBits & BIT(j))) {
                 continue;
             }
-            const GameItem it = Items_from(Inventory_groups_minor * i + j);
+            const GameItem it = REGISTRY_GET(Items, Inventory_groups_minor * i + j);
             .int fld = inv_items[it.m_id];
             int prev = this.(fld);
             int next = this.(fld) = ReadByte();
@@ -86,7 +86,7 @@ void Inventory_Write(Inventory data)
                        if (!(minorBits & BIT(j)))
                                continue;
 
-                       const entity it = Items_from(Inventory_groups_minor * i + j);
+                       const entity it = REGISTRY_GET(Items, Inventory_groups_minor * i + j);
                        WriteByte(MSG_ENTITY, data.inv_items[it.m_id]);
                }
        }
index f771b0f83cfea0d7c2a9545c96ea28f04af00d10..ae387e3db9a576df164c92765a250bd1d9681923 100644 (file)
@@ -1147,7 +1147,7 @@ int MapInfo_CurrentFeatures()
 
 Gametype MapInfo_CurrentGametype()
 {
-       Gametype prev = Gametypes_from(cvar("gamecfg"));
+       Gametype prev = REGISTRY_GET(Gametypes, cvar("gamecfg"));
        FOREACH(Gametypes, cvar(it.netname) && it != prev, return it);
        return prev ? prev : MAPINFO_TYPE_DEATHMATCH;
 }
index b669ba1f7b63aa2a8c74ab7bc7e1f91caaed1de3..4d598e88caa2346378b9295fdd7dc36c7ec59dbc 100644 (file)
@@ -101,9 +101,10 @@ CLASS(Gametype, Object)
 ENDCLASS(Gametype)
 
 REGISTRY(Gametypes, 24)
-#define Gametypes_from(i) _Gametypes_from(i, NULL)
 REGISTER_REGISTRY(Gametypes)
 REGISTRY_CHECK(Gametypes)
+
+REGISTRY_DEFINE_GET(Gametypes, NULL)
 #define REGISTER_GAMETYPE(NAME, inst) REGISTER(Gametypes, MAPINFO_TYPE, NAME, m_id, inst)
 
 #define IS_GAMETYPE(NAME) (MapInfo_LoadedGametype == MAPINFO_TYPE_##NAME)
index 415984a2a8a914b17822a98a69a861d927315c2d..5b4b8a3bd3300f37b976bce5a4102d9dfab485bb 100644 (file)
@@ -101,9 +101,10 @@ void minigame_prompt();
 
 
 REGISTRY(Minigames, BITS(4))
-#define Minigames_from(i) _Minigames_from(i, NULL)
 REGISTER_REGISTRY(Minigames)
 REGISTRY_CHECK(Minigames)
+
+REGISTRY_DEFINE_GET(Minigames, NULL)
 #define REGISTER_MINIGAME(name,nicename) \
     REGISTER(Minigames, MINIGAME_##name, m_id, new_pure(minigame_descriptor)); \
     void name##_hud_board(vector, vector); \
index b5015a1f40fd3e452d83ce2d23ed5a510ce63c4c..28a524d0463a5f59ebcd53fdd7004a6910dd09a8 100644 (file)
@@ -46,9 +46,10 @@ entity minigame_sessions;
 bool minigame_SendEntity(entity this, entity to, int sf);
 
 REGISTRY(Minigames, BITS(4))
-#define Minigames_from(i) _Minigames_from(i, NULL)
 REGISTER_REGISTRY(Minigames)
 REGISTRY_CHECK(Minigames)
+
+REGISTRY_DEFINE_GET(Minigames, NULL)
 #define REGISTER_MINIGAME(name,nicename) \
     REGISTER(Minigames, MINIGAME_##name, m_id, new_pure(minigame_descriptor)); \
     int name##_server_event(entity, string, ...); \
index eb95d7c28260d2a81ad306a1a37b00c97b4802ca..fe5c7b93d47ac40803901a18c847c4fa45b3e389 100644 (file)
@@ -147,7 +147,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_from(MDL_GIB_ROBO_1.m_id + i);
+    return REGISTRY_GET(Models, MDL_GIB_ROBO_1.m_id + i);
 }
 
 MODEL(CASING_SHELL,                     "models/casing_shell.mdl");
@@ -350,7 +350,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_from(MDL_0.m_id + i);
+        return REGISTRY_GET(Models, MDL_0.m_id + i);
     return MDL_Null;
 }
 
index ce98629411fd0cd6c3ce798a813acf5dd0fd602f..c4f865ddb9f056c1b35008d1eb814adeaab988d9 100644 (file)
@@ -3,7 +3,6 @@
 #include "model.qh"
 
 REGISTRY(Models, BITS(9))
-#define Models_from(i) _Models_from(i, MDL_Null)
 REGISTER_REGISTRY(Models)
 
 #define MODEL(name, path) \
@@ -20,4 +19,5 @@ PRECACHE(Models) {
 }
 
 MODEL(Null, "null");
+REGISTRY_DEFINE_GET(Models, MDL_Null)
 #include "all.inc"
index c9e5ad37ba6448ed85374378affde2e871a6197c..58840159ef60c60a386dbc5a817b3ad52ae93bc8 100644 (file)
@@ -3,14 +3,14 @@
 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)
+#define get_monsterinfo(i) REGISTRY_GET(Monsters, i)
 REGISTER_REGISTRY(Monsters)
 REGISTRY_CHECK(Monsters)
 const int MON_FIRST = 1;
-#define MON_LAST (Monsters_COUNT - 1)
+#define MON_LAST (REGISTRY_COUNT(Monsters) - 1)
 #define REGISTER_MONSTER(id, inst) REGISTER(Monsters, MON, id, monsterid, inst)
 
 #include "monster.qh"
 
 REGISTER_MONSTER(Null, NEW(Monster));
+REGISTRY_DEFINE_GET(Monsters, MON_Null)
index 4f2139cc170a56c78d49548f47b360e8ca8e78b3..d85b16b0e7988d92d694e6e7911bc4f489913d4b 100644 (file)
@@ -78,7 +78,7 @@ bool Monster_ValidTarget(entity this, entity targ)
 
        if((targ == this)
        || (autocvar_g_monsters_lineofsight && !checkpvs(this.origin + this.view_ofs, targ)) // enemy cannot be seen
-       || (IS_VEHICLE(targ) && !((Monsters_from(this.monsterid)).spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless
+       || (IS_VEHICLE(targ) && !((REGISTRY_GET(Monsters, this.monsterid)).spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless
        || (time < game_starttime) // monsters do nothing before match has started
        || (targ.takedamage == DAMAGE_NO)
        || (game_stopped)
@@ -260,7 +260,7 @@ void Monster_Sound_Precache(string f)
 
 void Monster_Sounds_Precache(entity this)
 {
-       string m = (Monsters_from(this.monsterid)).m_model.model_str();
+       string m = (REGISTRY_GET(Monsters, this.monsterid)).m_model.model_str();
        float globhandle, n, i;
        string f;
 
@@ -465,7 +465,7 @@ void Monster_UpdateModel(entity this)
        this.anim_die2   = animfixfps(this, '9 1 0.01', '0 0 0');*/
 
        // then get the real values
-       Monster mon = Monsters_from(this.monsterid);
+       Monster mon = REGISTRY_GET(Monsters, this.monsterid);
        mon.mr_anim(mon, this);
 }
 
@@ -977,7 +977,7 @@ void Monster_Dead(entity this, entity attacker, float gibbed)
 
        CSQCModel_UnlinkEntity(this);
 
-       Monster mon = Monsters_from(this.monsterid);
+       Monster mon = REGISTRY_GET(Monsters, this.monsterid);
        mon.mr_death(mon, this);
 
        if(this.candrop && this.weapon)
@@ -1008,7 +1008,7 @@ void Monster_Damage(entity this, entity inflictor, entity attacker, float damage
        float take = v.x;
        //float save = v.y;
 
-       Monster mon = Monsters_from(this.monsterid);
+       Monster mon = REGISTRY_GET(Monsters, this.monsterid);
        take = mon.mr_pain(mon, this, take, attacker, deathtype);
 
        if(take)
@@ -1235,7 +1235,7 @@ void Monster_Think(entity this)
                this.last_enemycheck = time + 1; // check for enemies every second
        }
 
-       Monster mon = Monsters_from(this.monsterid);
+       Monster mon = REGISTRY_GET(Monsters, this.monsterid);
        if(mon.mr_think(mon, this))
        {
                Monster_Move(this, this.speed2, this.speed, this.stopspeed);
@@ -1251,7 +1251,7 @@ void Monster_Think(entity this)
 
 bool Monster_Spawn_Setup(entity this)
 {
-       Monster mon = Monsters_from(this.monsterid);
+       Monster mon = REGISTRY_GET(Monsters, this.monsterid);
        mon.mr_setup(mon, this);
 
        // ensure some basic needs are met
@@ -1317,7 +1317,7 @@ bool Monster_Spawn_Setup(entity this)
 bool Monster_Spawn(entity this, bool check_appear, int mon_id)
 {
        // setup the basic required properties for a monster
-       entity mon = Monsters_from(mon_id);
+       entity mon = REGISTRY_GET(Monsters, mon_id);
        if(!mon.monsterid) { return false; } // invalid monster
 
        if(!autocvar_g_monsters) { Monster_Remove(this); return false; }
index cc4cc0129593044474468adff6b9434636fcdcf9..2b4d3e34cbe23f61c1bd84ed587dbe705b07edfe 100644 (file)
@@ -165,7 +165,8 @@ CLASS(Mutator, Object)
 ENDCLASS(Mutator)
 
 REGISTRY(Mutators, BITS(7))
-#define Mutators_from(i) _Mutators_from(i, NULL)
+
+REGISTRY_DEFINE_GET(Mutators, NULL)
 bool Mutator_Add(Mutator mut);
 void Mutator_Remove(Mutator mut);
 bool mutator_log = false;
index 4a5dcc82aaa1ded918115799619f366f321b3d87..2ab07ddf28fd1785297497b87122ad43e613537a 100644 (file)
@@ -2,7 +2,7 @@
 
 string BUFF_NAME(int i)
 {
-    Buff b = Buffs_from(i);
+    Buff b = REGISTRY_GET(Buffs, i);
     return strcat(rgb_to_hexcolor(b.m_color), b.m_name);
 }
 
index b381db4be19a6f0d9c8338f4f406d7f2f3a6e868..91f56066f61b0f7a9eed9532cdff15c9ffb295a5 100644 (file)
@@ -13,7 +13,6 @@ REGISTER_RADARICON(Buff, 1);
 #endif
 
 REGISTRY(Buffs, BITS(5))
-#define Buffs_from(i) _Buffs_from(i, BUFF_Null)
 REGISTER_REGISTRY(Buffs)
 REGISTRY_CHECK(Buffs)
 
@@ -72,4 +71,5 @@ entity buff_FirstFromFlags(int _buffs);
 REGISTER_BUFF(Null);
 BUFF_SPAWNFUNCS(random, BUFF_Null)
 
+REGISTRY_DEFINE_GET(Buffs, BUFF_Null)
 #include "all.inc"
index 349ca20b872c17f468117dccecaa1152128778ca..f33e3ff63a93fe1a1bbea3dfb5936f3a09f108d6 100644 (file)
@@ -15,7 +15,7 @@ MUTATOR_HOOKFUNCTION(cl_buffs, WP_Format)
     string s = M_ARGV(1, string);
     if (s == WP_Buff.netname || s == RADARICON_Buff.netname)
     {
-        Buff b = Buffs_from(this.wp_extra);
+        Buff b = REGISTRY_GET(Buffs, this.wp_extra);
         M_ARGV(2, vector) = b.m_color;
         M_ARGV(3, string) = b.m_name;
         M_ARGV(4, string) = strcat("buff_", b.netname);
index 78a5624c31b98bf74829377557fa7af956927944..e99a6af5dc0dea52328e637e97bd27dcc601f9c2 100644 (file)
@@ -16,8 +16,8 @@ void IT_Write(entity e, int i, float f) {
 
 #ifdef CSQC
 // reserve one more spot for superweapons time
-float ItemsTime_time[Items_MAX + 1];
-float ItemsTime_availableTime[Items_MAX + 1];
+float ItemsTime_time[REGISTRY_MAX(Items) + 1];
+float ItemsTime_availableTime[REGISTRY_MAX(Items) + 1];
 NET_HANDLE(itemstime, bool isNew)
 {
     int i = ReadByte();
@@ -33,7 +33,7 @@ STATIC_INIT(ItemsTime_Init) {
        FOREACH(Items, true, {
                ItemsTime_time[it.m_id] = -1;
        });
-       ItemsTime_time[Items_MAX] = -1;
+       ItemsTime_time[REGISTRY_MAX(Items)] = -1;
 }
 
 int autocvar_hud_panel_itemstime = 2;
@@ -71,13 +71,13 @@ bool Item_ItemsTime_Allow(GameItem it)
 #ifdef SVQC
 
 // reserve one more spot for superweapons time
-float it_times[Items_MAX + 1];
+float it_times[REGISTRY_MAX(Items) + 1];
 
 STATIC_INIT(ItemsTime_Init) {
        FOREACH(Items, Item_ItemsTime_Allow(it), {
                it_times[it.m_id] = -1;
        });
-       it_times[Items_MAX] = -1;
+       it_times[REGISTRY_MAX(Items)] = -1;
 }
 
 void Item_ItemsTime_ResetTimes()
@@ -85,7 +85,7 @@ void Item_ItemsTime_ResetTimes()
     FOREACH(Items, Item_ItemsTime_Allow(it), {
         it_times[it.m_id] = (it_times[it.m_id] == -1) ? -1 : 0;
     });
-    it_times[Items_MAX] = (it_times[Items_MAX] == -1) ? -1 : 0;
+    it_times[REGISTRY_MAX(Items)] = (it_times[REGISTRY_MAX(Items)] == -1) ? -1 : 0;
 }
 
 void Item_ItemsTime_ResetTimesForPlayer(entity e)
@@ -93,7 +93,7 @@ void Item_ItemsTime_ResetTimesForPlayer(entity e)
     FOREACH(Items, Item_ItemsTime_Allow(it), {
         IT_Write(e, it.m_id, (it_times[it.m_id] == -1) ? -1 : 0);
     });
-    IT_Write(e, Items_MAX, (it_times[Items_MAX] == -1) ? -1 : 0);
+    IT_Write(e, REGISTRY_MAX(Items), (it_times[REGISTRY_MAX(Items)] == -1) ? -1 : 0);
 }
 
 void Item_ItemsTime_SetTimesForPlayer(entity e)
@@ -101,7 +101,7 @@ void Item_ItemsTime_SetTimesForPlayer(entity e)
     FOREACH(Items, Item_ItemsTime_Allow(it), {
         IT_Write(e, it.m_id, it_times[it.m_id]);
     });
-    IT_Write(e, Items_MAX, it_times[Items_MAX]);
+    IT_Write(e, REGISTRY_MAX(Items), it_times[REGISTRY_MAX(Items)]);
 }
 
 void Item_ItemsTime_SetTime(entity e, float t)
@@ -115,7 +115,7 @@ void Item_ItemsTime_SetTime(entity e, float t)
                if (!item.instanceOfWeaponPickup)
                        it_times[item.m_id] = t;
                else if (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS)
-                       it_times[Items_MAX] = t;
+                       it_times[REGISTRY_MAX(Items)] = t;
     }
 }
 
@@ -295,21 +295,21 @@ void HUD_ItemsTime()
         FOREACH(Items, Item_ItemsTime_Allow(it), {
             count += (Item_ItemsTime_GetTime(it.m_id) > time || -Item_ItemsTime_GetTime(it.m_id) > time);
         });
-        count += (Item_ItemsTime_GetTime(Items_MAX) > time || -Item_ItemsTime_GetTime(Items_MAX) > time);
+        count += (Item_ItemsTime_GetTime(REGISTRY_MAX(Items)) > time || -Item_ItemsTime_GetTime(REGISTRY_MAX(Items)) > time);
     }
     else if (autocvar_hud_panel_itemstime_hidespawned == 2)
     {
         FOREACH(Items, Item_ItemsTime_Allow(it), {
             count += (Item_ItemsTime_GetTime(it.m_id) > time);
         });
-        count += (Item_ItemsTime_GetTime(Items_MAX) > time);
+        count += (Item_ItemsTime_GetTime(REGISTRY_MAX(Items)) > time);
     }
     else
     {
         FOREACH(Items, Item_ItemsTime_Allow(it), {
             count += (Item_ItemsTime_GetTime(it.m_id) != -1);
         });
-        count += (Item_ItemsTime_GetTime(Items_MAX) != -1);
+        count += (Item_ItemsTime_GetTime(REGISTRY_MAX(Items)) != -1);
     }
     if (count == 0)
         return;
@@ -426,13 +426,13 @@ LABEL(iteration)
             row = 0;
             column = column + 1;
         }
-        if(id == Items_MAX) // can happen only in the last fake iteration
+        if(id == REGISTRY_MAX(Items)) // can happen only in the last fake iteration
                break;
     });
     // add another fake iteration for superweapons time
-    if(id < Items_MAX && Item_ItemsTime_GetTime(Items_MAX) != -1)
+    if(id < REGISTRY_MAX(Items) && Item_ItemsTime_GetTime(REGISTRY_MAX(Items)) != -1)
     {
-               id = Items_MAX;
+               id = REGISTRY_MAX(Items);
                icon = "superweapons";
                goto iteration;
     }
index 9ac33b45bb328a612a395fb74f5a206fd62a7644..7dffc0f4d0fc9a8d4b6122f00709feb82d2ad127 100644 (file)
@@ -125,7 +125,7 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan
        float bonusNades    = STAT(NADE_BONUS);
        float bonusProgress = STAT(NADE_BONUS_SCORE);
        float bonusType     = STAT(NADE_BONUS_TYPE);
-       Nade def = Nades_from(bonusType);
+       Nade def = REGISTRY_GET(Nades, bonusType);
        vector nadeColor    = def.m_color;
        string nadeIcon     = def.m_icon;
 
@@ -181,7 +181,7 @@ void nade_timer_think(entity this)
 
 void nade_burn_spawn(entity _nade)
 {
-       CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
+       CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
 }
 
 void nade_spawn(entity _nade)
@@ -199,7 +199,7 @@ void nade_spawn(entity _nade)
 
        _nade.effects |= EF_LOWPRECISION;
 
-       CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
+       CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
 }
 
 void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
@@ -714,7 +714,7 @@ void nade_boom(entity this)
        entity expef = NULL;
        bool nade_blast = true;
 
-       switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
+       switch ( REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this)) )
        {
                case NADE_TYPE_NAPALM:
                        nade_blast = autocvar_g_nades_napalm_blast;
@@ -776,7 +776,7 @@ void nade_boom(entity this)
        }
 
        if(this.takedamage)
-       switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
+       switch ( REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this)) )
        {
                case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
                case NADE_TYPE_ICE: nade_ice_boom(this); break;
@@ -1074,7 +1074,10 @@ bool nade_customize(entity this, entity client)
        {
                //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
                if(!this.traileffectnum)
-                       this.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, this)).m_projectile[false], this.team).eent_eff_name);
+               {
+                       entity nade = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this));
+                       this.traileffectnum = _particleeffectnum(Nade_TrailEffect(nade.m_projectile[false], this.team).eent_eff_name);
+               }
                this.alpha = 1;
        }
 
@@ -1088,7 +1091,7 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
        STAT(NADE_BONUS_TYPE, n) = max(1, ntype);
        n.pokenade_type = pntype;
 
-       if(Nades_from(STAT(NADE_BONUS_TYPE, n)) == NADE_TYPE_Null)
+       if(REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)) == NADE_TYPE_Null)
                STAT(NADE_BONUS_TYPE, n) = NADE_TYPE_NORMAL.m_id;
 
        .entity weaponentity = weaponentities[0]; // TODO: unhardcode
@@ -1097,8 +1100,8 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
        //setattachment(n, player, "bip01 l hand");
        n.exteriormodeltoclient = player;
        setcefc(n, nade_customize);
-       n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, n)).m_projectile[false], player.team).eent_eff_name);
-       n.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
+       n.traileffectnum = _particleeffectnum(Nade_TrailEffect(REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_projectile[false], player.team).eent_eff_name);
+       n.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_color;
        n.realowner = nowner;
        n.colormap = player.colormap;
        n.glowmod = player.glowmod;
@@ -1109,19 +1112,19 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
        n.projectiledeathtype = DEATH_NADE.m_id;
        n.weaponentity_fld = weaponentity;
        n.nade_lifetime = ntime;
-       n.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
+       n.alpha = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_alpha;
 
        setmodel(fn, MDL_NADE_VIEW);
        //setattachment(fn, player.(weaponentity), "");
        fn.viewmodelforclient = player;
        fn.realowner = fn.owner = player;
-       fn.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
+       fn.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_color;
        fn.colormap = player.colormap;
        fn.glowmod = player.glowmod;
        setthink(fn, SUB_Remove);
        fn.nextthink = n.wait;
        fn.weaponentity_fld = weaponentity;
-       fn.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
+       fn.alpha = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_alpha;
 
        player.nade = n;
        player.fake_nade = fn;
index d76eb941450274fb626b8f1732ef4ecebf88e4f1..963dbce38d5d9253c36933f4632c18b272bc8c3b 100644 (file)
@@ -22,7 +22,6 @@ const int PROJECTILE_NADE_VEIL = 86;
 const int PROJECTILE_NADE_VEIL_BURN = 87;
 
 REGISTRY(Nades, BITS(4))
-#define Nades_from(i) _Nades_from(i, NADE_TYPE_Null)
 REGISTER_REGISTRY(Nades)
 REGISTRY_CHECK(Nades)
 
@@ -42,6 +41,7 @@ CLASS(Nade, Object)
 ENDCLASS(Nade)
 
 REGISTER_NADE(Null);
+REGISTRY_DEFINE_GET(Nades, NADE_TYPE_Null)
 
 Nade Nade_FromProjectile(int proj)
 {
index 7214a699e1122e759026f2b5995ee4a99305a943..b399d3c62f68893cc2822eb09ac23bf3a891a1aa 100644 (file)
@@ -80,7 +80,7 @@ REGISTER_MUTATOR(nix, expr_evaluate(cvar_string("g_nix")) && !MUTATOR_IS_ENABLED
 
 bool NIX_CanChooseWeapon(int wpn)
 {
-       entity e = Weapons_from(wpn);
+       entity e = REGISTRY_GET(Weapons, wpn);
        if (e == WEP_Null) return false; // skip dummies
        if(g_weaponarena)
        {
@@ -125,12 +125,12 @@ void NIX_GiveCurrentWeapon(entity this)
                        nix_nextchange = time; // start the first round now!
                else
                        nix_nextchange = time + autocvar_g_balance_nix_roundtime;
-               // Weapon w = Weapons_from(nix_weapon);
+               // Weapon w = REGISTRY_GET(Weapons, nix_weapon);
                // w.wr_init(w); // forget it, too slow
        }
 
        // get weapon info
-       entity wpn = Weapons_from(nix_weapon);
+       entity wpn = REGISTRY_GET(Weapons, nix_weapon);
 
        if(nix_nextchange != this.nix_lastchange_id) // this shall only be called once per round!
        {
index c54a8a69306f4d7682be9e71003d584dca762a73..04785f8d69c99c7c02205c2c6028fe78b2a3af25 100644 (file)
@@ -14,7 +14,7 @@ MUTATOR_HOOKFUNCTION(mutator_smneg, BuildMutatorsPrettyString) {
     M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Stale-move negation");
 }
 
-.float x_smneg_weight[Weapons_MAX];
+.float x_smneg_weight[REGISTRY_MAX(Weapons)];
 
 float smneg_multiplier(float weight) {
     float a = autocvar_g_smneg_bonus_asymptote;
index 13260023760f977ea1a70cea96c92928635eb10b..fa1cbd31a1548d45a15770902c71fe858ccaa805 100644 (file)
@@ -3,7 +3,6 @@
 #include "waypointsprites.qh"
 
 REGISTRY(Waypoints, BITS(7))
-#define Waypoints_from(i) _Waypoints_from(i, WP_Null)
 REGISTER_REGISTRY(Waypoints)
 REGISTRY_CHECK(Waypoints)
 
@@ -30,7 +29,6 @@ ENDCLASS(Waypoint)
 #define REGISTER_WAYPOINT(id, text, icon, color, blink) REGISTER_WAYPOINT_(id, NEW(Waypoint, #id, text, icon, color, blink))
 
 REGISTRY(RadarIcons, BITS(7))
-#define RadarIcons_from(i) _RadarIcons_from(i, RADARICON_NONE)
 REGISTER_REGISTRY(RadarIcons)
 REGISTRY_CHECK(RadarIcons)
 
@@ -38,8 +36,11 @@ REGISTRY_CHECK(RadarIcons)
 #define REGISTER_RADARICON(id, num) REGISTER(RadarIcons, RADARICON, id, m_id, new_pure(RadarIcon)) { this.m_radaricon = num; this.netname = #id; }
 
 REGISTER_WAYPOINT(Null, "", "", '0 0 0', 1);
+REGISTRY_DEFINE_GET(Waypoints, WP_Null)
 
 REGISTER_RADARICON(NONE,            0);
+REGISTRY_DEFINE_GET(RadarIcons, RADARICON_NONE)
+
 REGISTER_RADARICON(FLAG,            1);
 REGISTER_RADARICON(FLAGCARRIER,     1);
 
index 0b4fe28ff33bfde36cb81653d0cac7ac3c291ae5..786971645f2063a7498e2f08d90e00a5e27d1ebd 100644 (file)
@@ -213,10 +213,10 @@ void Ent_WaypointSprite(entity this, bool isnew)
 float spritelookupblinkvalue(entity this, string s)
 {
     if (s == WP_Weapon.netname) {
-        if (Weapons_from(this.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
+        if (REGISTRY_GET(Weapons, this.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
             return 2;
     }
-    if (s == WP_Item.netname) return Items_from(this.wp_extra).m_waypointblink;
+    if (s == WP_Item.netname) return REGISTRY_GET(Items, this.wp_extra).m_waypointblink;
     if(s == WP_FlagReturn.netname) return 2;
 
     return 1;
@@ -224,8 +224,8 @@ float spritelookupblinkvalue(entity this, string s)
 
 vector spritelookupcolor(entity this, string s, vector def)
 {
-    if (s == WP_Weapon.netname  || s == RADARICON_Weapon.netname) return Weapons_from(this.wp_extra).wpcolor;
-    if (s == WP_Item.netname    || s == RADARICON_Item.netname) return Items_from(this.wp_extra).m_color;
+    if (s == WP_Weapon.netname  || s == RADARICON_Weapon.netname) return REGISTRY_GET(Weapons, this.wp_extra).wpcolor;
+    if (s == WP_Item.netname    || s == RADARICON_Item.netname) return REGISTRY_GET(Items, this.wp_extra).m_color;
     if (MUTATOR_CALLHOOK(WP_Format, this, s))
     {
         return M_ARGV(2, vector);
@@ -238,8 +238,8 @@ string spritelookuptext(entity this, string s)
        if(autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
                return "Spam"; // no need to translate this debug string
     if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
-    if (s == WP_Weapon.netname) return Weapons_from(this.wp_extra).m_name;
-    if (s == WP_Item.netname) return Items_from(this.wp_extra).m_waypoint;
+    if (s == WP_Weapon.netname) return REGISTRY_GET(Weapons, this.wp_extra).m_name;
+    if (s == WP_Item.netname) return REGISTRY_GET(Items, this.wp_extra).m_waypoint;
     if (s == WP_Monster.netname) return get_monsterinfo(this.wp_extra).monster_name;
     if (MUTATOR_CALLHOOK(WP_Format, this, s))
     {
@@ -257,9 +257,9 @@ string spritelookuptext(entity this, string s)
 string spritelookupicon(entity this, string s)
 {
     // TODO: needs icons! //if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
-    if (s == WP_Weapon.netname) return Weapons_from(this.wp_extra).model2;
-    if (s == WP_Item.netname) return Items_from(this.wp_extra).m_icon;
-    if (s == WP_Vehicle.netname) return Vehicles_from(this.wp_extra).m_icon;
+    if (s == WP_Weapon.netname) return REGISTRY_GET(Weapons, this.wp_extra).model2;
+    if (s == WP_Item.netname) return REGISTRY_GET(Items, this.wp_extra).m_icon;
+    if (s == WP_Vehicle.netname) return REGISTRY_GET(Vehicles, this.wp_extra).m_icon;
     //if (s == WP_Monster.netname) return get_monsterinfo(this.wp_extra).m_icon;
     if (MUTATOR_CALLHOOK(WP_Format, this, s))
     {
index 3b009b25637a296b28cf93d2978e858df993cf73..bbaa8845e8de8ad4636a6bc2a0db5cfb25813c69 100644 (file)
@@ -435,7 +435,7 @@ string BUFF_NAME(int i);
        ARG_CASE(ARG_CS_SV,     "spree_inf",     (autocvar_notification_show_sprees ? notif_arg_spree_inf(1, input, s2, f2) : "")) \
        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",  Weapons_from(f1).m_name) \
+       ARG_CASE(ARG_CS_SV,     "item_wepname",  REGISTRY_GET(Weapons, f1).m_name) \
        ARG_CASE(ARG_CS_SV,     "item_buffname", BUFF_NAME(f1)) \
        ARG_CASE(ARG_CS_SV,     "f3buffname",    BUFF_NAME(f3)) \
        ARG_CASE(ARG_CS_SV,     "item_wepammo",  (f2 > 0 ? notif_arg_item_wepammo(f1, f2) : "")) \
@@ -633,7 +633,7 @@ string notif_arg_spree_inf(float type, string input, string player, float spree)
 string notif_arg_item_wepammo(float f1, float f2)
 {
        string ammoitems = "";
-       Weapon wep = Weapons_from(f1);
+       Weapon wep = REGISTRY_GET(Weapons, f1);
        switch (wep.ammo_type)
        {
                case RES_SHELLS:  ammoitems = ITEM_Shells.m_name;      break;
@@ -701,6 +701,8 @@ string notif_arg_item_wepammo(float f1, float f2)
 REGISTRY(Notifications, BITS(11))
 REGISTER_REGISTRY(Notifications)
 REGISTRY_SORT(Notifications);
+
+REGISTRY_DEFINE_GET(Notifications, NULL)
 STATIC_INIT(Notifications) { FOREACH(Notifications, true, it.m_id = i); }
 REGISTRY_CHECK(Notifications)
 
@@ -730,7 +732,7 @@ string Get_Notif_CvarName(Notification notif)
 
 Notification Get_Notif_Ent(MSG net_type, int net_name)
 {
-       Notification it = _Notifications_from(net_name, NULL);
+       Notification it = REGISTRY_GET(Notifications, net_name);
        if (it.nent_type != net_type) {
                LOG_WARNF("Get_Notif_Ent(%s (%d), %s (%d)): Improper net type '%s'!",
                        Get_Notif_TypeName(net_type), net_type,
index 377a780770300554275d3685e3e6d53e90122bb8..3bc6c55636c65fa4e3875d0bf2b328e0f3a0aa02 100644 (file)
@@ -4,10 +4,11 @@
 
 #define REGISTER_SP(id) REGISTER(Scores, SP, id, m_id, new_pure(PlayerScoreField))
 REGISTRY(Scores, MAX_SCORE);
-#define Scores_from(i) _Scores_from(i, NULL)
 REGISTER_REGISTRY(Scores)
 REGISTRY_SORT(Scores);
 REGISTRY_CHECK(Scores);
+
+REGISTRY_DEFINE_GET(Scores, NULL)
 STATIC_INIT(Scores_renumber) { FOREACH(Scores, true, it.m_id = i); }
 
 /*
index 29f2946b059d7d4c65c9f2c9cf1e8cef3da52753..58b145a4c2cd647e28372fdb7488fc204de6d02d 100644 (file)
@@ -39,7 +39,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_from(SND_GRENADE_BOUNCE1.m_id + rint(random() * 5));
+    return REGISTRY_GET(Sounds, SND_GRENADE_BOUNCE1.m_id + rint(random() * 5));
 }
 SOUND(GRENADE_FIRE, W_Sound("grenade_fire"));
 SOUND(GRENADE_IMPACT, W_Sound("grenade_impact"));
@@ -51,7 +51,7 @@ SOUND(HAGEXP1, W_Sound("hagexp1"));
 SOUND(HAGEXP2, W_Sound("hagexp2"));
 SOUND(HAGEXP3, W_Sound("hagexp3"));
 Sound SND_HAGEXP_RANDOM() {
-    return Sounds_from(SND_HAGEXP1.m_id + rint(random() * 2));
+    return REGISTRY_GET(Sounds, SND_HAGEXP1.m_id + rint(random() * 2));
 }
 
 SOUND(HOOKBOMB_FIRE, W_Sound("hookbomb_fire"));
@@ -74,7 +74,7 @@ SOUND(NEXWHOOSH1, W_Sound("nexwhoosh1"));
 SOUND(NEXWHOOSH2, W_Sound("nexwhoosh2"));
 SOUND(NEXWHOOSH3, W_Sound("nexwhoosh3"));
 Sound SND_NEXWHOOSH_RANDOM() {
-    return Sounds_from(SND_NEXWHOOSH1.m_id + rint(random() * 2));
+    return REGISTRY_GET(Sounds, SND_NEXWHOOSH1.m_id + rint(random() * 2));
 }
 SOUND(RELOAD, W_Sound("reload")); // until weapons have individual reload sounds, precache the reload sound here
 
@@ -82,7 +82,7 @@ SOUND(RIC1, W_Sound("ric1"));
 SOUND(RIC2, W_Sound("ric2"));
 SOUND(RIC3, W_Sound("ric3"));
 Sound SND_RIC_RANDOM() {
-    return Sounds_from(SND_RIC1.m_id + rint(random() * 2));
+    return REGISTRY_GET(Sounds, SND_RIC1.m_id + rint(random() * 2));
 }
 
 SOUND(ROCKET_DET, W_Sound("rocket_det"));
@@ -265,7 +265,7 @@ SOUND(GIB_SPLAT02, "misc/gib_splat02");
 SOUND(GIB_SPLAT03, "misc/gib_splat03");
 SOUND(GIB_SPLAT04, "misc/gib_splat04");
 Sound SND_GIB_SPLAT_RANDOM() {
-    return Sounds_from(SND_GIB_SPLAT01.m_id + floor(prandom() * 4));
+    return REGISTRY_GET(Sounds, SND_GIB_SPLAT01.m_id + floor(prandom() * 4));
 }
 
 SOUND(HIT, "misc/hit");
index b7b296341b5a02ba5829035e158f13ad673cbefe..6d011e21ad0b3f9cb29102fc438fca1e47233b7c 100644 (file)
@@ -3,7 +3,6 @@
 #include "sound.qh"
 
 REGISTRY(Sounds, BITS(9))
-#define Sounds_from(i) _Sounds_from(i, SND_Null)
 REGISTER_REGISTRY(Sounds)
 
 #define SOUND(name, path) \
@@ -18,5 +17,6 @@ PRECACHE(Sounds) {
 }
 
 SOUND(Null, "misc/null");
+REGISTRY_DEFINE_GET(Sounds, SND_Null)
 #include "all.inc"
 #include "all.qc"
index 20ffe812e617e8a80283c3c7e87f2d6d2f05d4fd..37cb77a7a2c1d3372d2cada530968afbf663a6a3 100644 (file)
@@ -508,7 +508,7 @@ void Item_RespawnCountdown(entity this)
                {
                        do {
                                {
-                                       entity wi = Weapons_from(this.weapon);
+                                       entity wi = REGISTRY_GET(Weapons, this.weapon);
                                        if (wi != WEP_Null) {
                                                entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, this, '0 0 64', NULL, 0, this, waypointsprite_attached, true, RADARICON_Weapon);
                                                wp.wp_extra = wi.m_id;
@@ -856,7 +856,7 @@ bool Item_GiveTo(entity item, entity player)
                {
                        .entity weaponentity = weaponentities[slot];
                        if(player.(weaponentity).m_weapon != WEP_Null || slot == 0)
-                               W_SwitchWeapon_Force(player, Weapons_from(item.weapon), weaponentity);
+                               W_SwitchWeapon_Force(player, REGISTRY_GET(Weapons, item.weapon), weaponentity);
                }
                return true;
        }
@@ -1203,7 +1203,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
        }
 
        if(weaponid)
-               STAT(WEAPONS, this) = WepSet_FromWeapon(Weapons_from(weaponid));
+               STAT(WEAPONS, this) = WepSet_FromWeapon(REGISTRY_GET(Weapons, weaponid));
 
        this.flags = FL_ITEM | itemflags;
        IL_PUSH(g_items, this);
@@ -1307,7 +1307,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
                        this.is_item = true;
                }
 
-               weaponsInMap |= WepSet_FromWeapon(Weapons_from(weaponid));
+               weaponsInMap |= WepSet_FromWeapon(REGISTRY_GET(Weapons, weaponid));
 
                if (   def.instanceOfPowerup
                        || def.instanceOfWeaponPickup
@@ -1591,7 +1591,7 @@ spawnfunc(target_items)
 float GiveWeapon(entity e, float wpn, float op, float val)
 {
        WepSet v0, v1;
-       WepSet s = WepSet_FromWeapon(Weapons_from(wpn));
+       WepSet s = WepSet_FromWeapon(REGISTRY_GET(Weapons, wpn));
        v0 = (STAT(WEAPONS, e) & s);
        switch(op)
        {
index 9dedc89cb780253a184b45ed3f1dba2da1744d9b..5727234e26cb36f5e8d3195881886fa2f21a73ff 100644 (file)
@@ -6,8 +6,7 @@
 #include "turret.qh"
 
 REGISTRY(Turrets, BITS(5))
-#define Turrets_from(i) _Turrets_from(i, TUR_Null)
-#define get_turretinfo(i) Turrets_from(i)
+#define get_turretinfo(i) REGISTRY_GET(Turrets, i)
 REGISTER_REGISTRY(Turrets)
 REGISTRY_CHECK(Turrets)
 
@@ -112,10 +111,11 @@ GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt", false)
 
 
 const int TUR_FIRST = 1;
-#define TUR_LAST (Turrets_COUNT - 1)
+#define TUR_LAST (REGISTRY_COUNT(Turrets) - 1)
 
 #define REGISTER_TURRET(id, inst) REGISTER(Turrets, TUR, id, m_id, inst)
 
 REGISTER_TURRET(Null, NEW(Turret));
+REGISTRY_DEFINE_GET(Turrets, TUR_Null)
 
 #include "turret/_mod.qh"
index 19b64ff07233abd2f112fac5aeb168be184a7f16..8ecd190e320753a3f6a21af398df40ceb8721fb0 100644 (file)
@@ -77,7 +77,7 @@ void Dump_Turret_Settings()
 
        // extra information
        if (TUR_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1)
-               LOG_INFOF("Totals: %d turrets, %d settings", (Turrets_COUNT - 1), totalsettings);
+               LOG_INFOF("Totals: %d turrets, %d settings", (REGISTRY_COUNT(Turrets) - 1), totalsettings);
 
        // clear queue now that we're finished
        TUR_CONFIG_COUNT = 0;
index 3b7513013dc036475976c872d628ec572d8a4b67..3567a2b095d522857ec2e2e4454de22c3e2d3dd5 100644 (file)
@@ -508,7 +508,7 @@ string fixPriorityList(string order, float from, float to, float subtract, float
                n = tokenize_console(neworder);
                for(w = to; w >= from; --w)
                {
-                       int wflags = Weapons_from(w).spawnflags;
+                       int wflags = REGISTRY_GET(Weapons, w).spawnflags;
                        if(wflags & WEP_FLAG_SPECIALATTACK)
                                continue;
                        for(i = 0; i < n; ++i)
index ed44be777bf369acd3cc2ad697b89cb03b5bfd11..2e4a2be5043b9a51d2eef18c92ae3eb090128454 100644 (file)
@@ -3,12 +3,11 @@
 #include "vehicle.qh"
 
 REGISTRY(Vehicles, BITS(4))
-#define Vehicles_from(i) _Vehicles_from(i, VEH_Null)
 REGISTER_REGISTRY(Vehicles)
 REGISTRY_CHECK(Vehicles)
 
 const int VEH_FIRST = 1;
-#define VEH_LAST (Vehicles_COUNT - 1)
+#define VEH_LAST (REGISTRY_COUNT(Vehicles) - 1)
 
 #define REGISTER_VEHICLE(id, inst) REGISTER(Vehicles, VEH, id, vehicleid, inst)
 
@@ -19,5 +18,6 @@ const int VEH_FIRST = 1;
 #endif
 
 REGISTER_VEHICLE(Null, NEW(Vehicle));
+REGISTRY_DEFINE_GET(Vehicles, VEH_Null)
 
 #include "vehicle/_mod.qh"
index 06c8484ff8eec45d17be6d3f18e0caaa6d1f2c5b..667c1f75a31b65587fcd9a9886c000affa454606 100644 (file)
@@ -134,7 +134,7 @@ NET_HANDLE(TE_CSQC_VEHICLESETUP, bool isnew)
                AuxiliaryXhair[0].axh_image = vCROSS_BURST; // Plasma cannons
                AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Raygun
        } else {
-               Vehicle info = Vehicles_from(hud_id);
+               Vehicle info = REGISTRY_GET(Vehicles, hud_id);
        info.vr_setup(info, NULL);
        }
 }
index 3ec02901dc14c06435cc35f4d5b738ad940f7add..cc2e13e223fb6c1b827430a67b2b82531c3b4428 100644 (file)
@@ -450,7 +450,7 @@ void vehicles_reset_colors(entity this, entity player)
        this.velocity  = '0 0 0';
        this.effects   = eff;
 
-       Vehicle info = Vehicles_from(this.vehicleid);
+       Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid);
        info.vr_setcolors(info, this);
 }
 
@@ -741,7 +741,7 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag
 
                antilag_clear(this, this);
 
-               Vehicle info = Vehicles_from(this.vehicleid);
+               Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid);
                info.vr_death(info, this);
                vehicles_setreturn(this);
        }
@@ -931,7 +931,7 @@ void vehicles_touch(entity this, entity toucher)
                }
 
                if(this.play_time < time) {
-                       Vehicle info = Vehicles_from(this.vehicleid);
+                       Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid);
                        info.vr_impact(info, this);
                }
 
@@ -976,7 +976,7 @@ void vehicles_enter(entity pl, entity veh)
        || (pl.vehicle)
        ) { return; }
 
-       Vehicle info = Vehicles_from(veh.vehicleid);
+       Vehicle info = REGISTRY_GET(Vehicles, veh.vehicleid);
 
        if(autocvar_g_vehicles_enter) // vehicle's touch function should handle this if entering via use key is disabled (TODO)
        if(veh.vehicle_flags & VHF_MULTISLOT)
@@ -1115,7 +1115,7 @@ void vehicles_think(entity this)
        if(this.owner)
                STAT(VEHICLESTAT_W2MODE, this.owner) = STAT(VEHICLESTAT_W2MODE, this);
 
-       Vehicle info = Vehicles_from(this.vehicleid);
+       Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid);
        info.vr_think(info, this);
 
        vehicles_painframe(this);
@@ -1188,7 +1188,7 @@ void vehicles_spawn(entity this)
        });
 
 
-       Vehicle info = Vehicles_from(this.vehicleid);
+       Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid);
        info.vr_spawn(info, this);
 
        vehicles_reset_colors(this, NULL);
index 81fd93aa02d5e2da6178ac312b0a056cbcfee878..0afd31f8c77e00d6bdc7b349efdbc15837d0d6e6 100644 (file)
@@ -96,7 +96,8 @@ void bumble_raygun_draw(entity this)
 
     if(this.bumble_raygun_nextdraw < time)
     {
-        boxparticles(particleeffectnum(Effects_from(this.traileffect)), this, this.origin, this.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
+        entity eff = REGISTRY_GET(Effects, this.traileffect);
+        boxparticles(particleeffectnum(eff), this, this.origin, this.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
         boxparticles(this.lip, this, this.bumble_origin, this.bumble_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
         this.bumble_raygun_nextdraw = time + 0.1;
     }
index a8d1376d1d86b60781be17f990ff41f835f88996..736ed9c9d23be1050ff57350be5a4cbe2bca2b97 100644 (file)
 WepSet _WepSet_FromWeapon(int a)
 {
        a -= WEP_FIRST;
-       if (Weapons_MAX > 24)
+       if (REGISTRY_MAX(Weapons) > 24)
                if (a >= 24)
                {
                        a -= 24;
-                       if (Weapons_MAX > 48)
+                       if (REGISTRY_MAX(Weapons) > 48)
                                if (a >= 24)
                                {
                                        a -= 24;
@@ -76,8 +76,8 @@ WepSet _WepSet_FromWeapon(int a)
 #ifdef SVQC
        void WriteWepSet(float dst, WepSet w)
        {
-               if (Weapons_MAX > 48) WriteInt72_t(dst, w);
-               else if (Weapons_MAX > 24) WriteInt48_t(dst, w);
+               if (REGISTRY_MAX(Weapons) > 48) WriteInt72_t(dst, w);
+               else if (REGISTRY_MAX(Weapons) > 24) WriteInt48_t(dst, w);
                else WriteInt24_t(dst, w.x);
        }
 #endif
@@ -92,8 +92,8 @@ WepSet _WepSet_FromWeapon(int a)
        }
        WepSet ReadWepSet()
        {
-               if (Weapons_MAX > 48) return ReadInt72_t();
-               if (Weapons_MAX > 24) return ReadInt48_t();
+               if (REGISTRY_MAX(Weapons) > 48) return ReadInt72_t();
+               if (REGISTRY_MAX(Weapons) > 24) return ReadInt48_t();
                return ReadInt24_t() * '1 0 0';
        }
 #endif
@@ -107,7 +107,7 @@ string W_NameWeaponOrder_MapFunc(string s)
        int i = stof(s);
        if (s == "0" || i)
        {
-               entity wi = Weapons_from(i);
+               entity wi = REGISTRY_GET(Weapons, i);
                if (wi != WEP_Null) return wi.netname;
        }
        return s;
@@ -144,7 +144,7 @@ string W_NumberWeaponOrder(string order)
        return mapPriorityList(order, W_NumberWeaponOrder_MapFunc);
 }
 
-float W_FixWeaponOrder_BuildImpulseList_buf[Weapons_MAX];
+float W_FixWeaponOrder_BuildImpulseList_buf[REGISTRY_MAX(Weapons)];
 string W_FixWeaponOrder_BuildImpulseList_order;
 void W_FixWeaponOrder_BuildImpulseList_swap(int i, int j, entity pass)
 {
@@ -156,9 +156,9 @@ void W_FixWeaponOrder_BuildImpulseList_swap(int i, int j, entity pass)
 float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
 {
        int si = W_FixWeaponOrder_BuildImpulseList_buf[i];
-       Weapon e1 = Weapons_from(si);
+       Weapon e1 = REGISTRY_GET(Weapons, si);
        int sj = W_FixWeaponOrder_BuildImpulseList_buf[j];
-       Weapon e2 = Weapons_from(sj);
+       Weapon e2 = REGISTRY_GET(Weapons, sj);
        int d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10;
        if (d != 0) return -d;  // high impulse first!
        return strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "),
index 26b40084bfe82b4013862d1d6c4fae03621c74ff..bcd4d51a4af4cf9f7937bb36668b745d3ecabe90 100644 (file)
@@ -25,7 +25,6 @@ WepSet ReadWepSet();
 #include <common/util.qh>
 
 REGISTRY(Weapons, 72) // Increase as needed. Can be up to 72.
-#define Weapons_from(i) _Weapons_from(i, WEP_Null)
 REGISTER_REGISTRY(Weapons)
 STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, it.m_pickup = NEW(WeaponPickup, it)); }
 
@@ -126,8 +125,9 @@ STATIC_INIT_LATE(W_PROP_reloader)
     [[alias("WEP_" #id)]] Weapon _wep_##sname
 
 REGISTER_WEAPON(Null, NEW(Weapon));
+REGISTRY_DEFINE_GET(Weapons, WEP_Null)
 
-Weapon Weapons_fromstr(string s)
+Weapon Weapon_from_name(string s)
 {
     FOREACH(Weapons, it != WEP_Null && it.netname == s, return it);
     return WEP_Null;
@@ -256,7 +256,7 @@ const .float reloading_time = reload_time;
             .void(Weapon this, int i) wr_net;
             NET_HANDLE(WeaponUpdate, bool isnew)
             {
-                Weapon w = Weapons_from(ReadByte());
+                Weapon w = REGISTRY_GET(Weapons, ReadByte());
                 for (int i; (i = ReadByte()); )
                 {
                     w.wr_net(w, i);
@@ -297,7 +297,7 @@ const .float reloading_time = reload_time;
 #define WEP_CVAR_BOTH(wepname, isprimary, name) ((isprimary) ? WEP_CVAR_PRI(wepname, name) : WEP_CVAR_SEC(wepname, name))
 
 const int WEP_FIRST = 1;
-#define WEP_LAST (Weapons_COUNT - 1)
+#define WEP_LAST (REGISTRY_COUNT(Weapons) - 1)
 WepSet WEPSET_ALL;
 WepSet WEPSET_SUPERWEAPONS;
 
@@ -308,7 +308,7 @@ WepSet WEPSET_SUPERWEAPONS;
 
 // TODO: invert after 0.8.2. Will require moving 'best weapon' impulses
 #define WEP_IMPULSE_BEGIN 230
-#define WEP_IMPULSE_END bound(WEP_IMPULSE_BEGIN, WEP_IMPULSE_BEGIN + (Weapons_COUNT - 1) - 1, 253)
+#define WEP_IMPULSE_END bound(WEP_IMPULSE_BEGIN, WEP_IMPULSE_BEGIN + (REGISTRY_COUNT(Weapons) - 1) - 1, 253)
 
 REGISTRY_SORT(Weapons, WEP_HARDCODED_IMPULSES + 1)
 REGISTRY_CHECK(Weapons)
@@ -332,8 +332,8 @@ STATIC_INIT(register_weapons_done)
     FOREACH(Weapons, true, it.wr_init(it));
     #endif
     weaponorder_byid = "";
-    for (int i = Weapons_MAX - 1; i >= 1; --i)
-        if (Weapons_from(i))
+    for (int i = REGISTRY_MAX(Weapons) - 1; i >= 1; --i)
+        if (REGISTRY_GET(Weapons, i))
             weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
     weaponorder_byid = strzone(substring(weaponorder_byid, 1, -1));
 }
index 38ef3bd1f7d4c5303e5f639f5c6306711d1385ba..5e78207d4a7986ea754e0a0dc692e96d86b391c1 100644 (file)
@@ -8,15 +8,15 @@ MACRO_END
 #define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
        PROP(false, m_switchweapon, WEPENT_SET_NORMAL, \
        { WriteByte(chan, this.m_switchweapon.m_id); }, \
-       { (viewmodels[this.m_wepent_slot]).switchweapon = Weapons_from(ReadByte()); }) \
+       { (viewmodels[this.m_wepent_slot]).switchweapon = REGISTRY_GET(Weapons, ReadByte()); }) \
     \
     PROP(false, m_switchingweapon, WEPENT_SET_NORMAL, \
        { WriteByte(chan, this.m_switchingweapon.m_id); }, \
-       { (viewmodels[this.m_wepent_slot]).switchingweapon = Weapons_from(ReadByte()); }) \
+       { (viewmodels[this.m_wepent_slot]).switchingweapon = REGISTRY_GET(Weapons, ReadByte()); }) \
     \
     PROP(false, m_weapon, WEPENT_SET_NORMAL, \
        { WriteByte(chan, this.m_weapon.m_id); }, \
-       { (viewmodels[this.m_wepent_slot]).activeweapon = Weapons_from(ReadByte()); }) \
+       { (viewmodels[this.m_wepent_slot]).activeweapon = REGISTRY_GET(Weapons, ReadByte()); }) \
     \
     PROP(false, m_alpha, WEPENT_SET_NORMAL, \
        { WriteByte(chan, rint(bound(-1, 254 * this.m_alpha, 254) - -1)); }, \
index a6c363b8f7cc87e9ea337ff7b3d4aa14d95d8b6d..71950fb73cb67120d632a4d70ed0fd4bb60f276a 100644 (file)
@@ -40,10 +40,11 @@ string _net_prevmsgstr;
 #define REGISTER_NET_S2C(id) REGISTER_NET_TEMP(id)
 
 REGISTRY(TempEntities, BITS(8) - 80)
-#define TempEntities_from(i) _TempEntities_from(i, NULL)
 REGISTER_REGISTRY(TempEntities)
 REGISTRY_SORT(TempEntities)
 REGISTRY_CHECK(TempEntities)
+
+REGISTRY_DEFINE_GET(TempEntities, NULL)
 STATIC_INIT(TempEntities_renumber) { FOREACH(TempEntities, true, it.m_id = 80 + i); }
 
 
@@ -72,10 +73,11 @@ STATIC_INIT(TempEntities_renumber) { FOREACH(TempEntities, true, it.m_id = 80 +
 #endif
 
 REGISTRY(LinkedEntities, BITS(8) - 1)
-#define LinkedEntities_from(i) _LinkedEntities_from(i, NULL)
 REGISTER_REGISTRY(LinkedEntities)
 REGISTRY_SORT(LinkedEntities)
 REGISTRY_CHECK(LinkedEntities)
+
+REGISTRY_DEFINE_GET(LinkedEntities, NULL)
 STATIC_INIT(LinkedEntities_renumber) { FOREACH(LinkedEntities, true, it.m_id = 1 + i); }
 
 
@@ -98,10 +100,11 @@ STATIC_INIT(LinkedEntities_renumber) { FOREACH(LinkedEntities, true, it.m_id = 1
 #endif
 
 REGISTRY(C2S_Protocol, BITS(8) - 1)
-#define C2S_Protocol_from(i) _C2S_Protocol_from(i, NULL)
 REGISTER_REGISTRY(C2S_Protocol)
 REGISTRY_SORT(C2S_Protocol)
 REGISTRY_CHECK(C2S_Protocol)
+
+REGISTRY_DEFINE_GET(C2S_Protocol, NULL)
 STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); }
 
 #ifdef SVQC
@@ -170,7 +173,7 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); }
                STRING_ITERATOR_SET(g_buf, buf, 0);
                for (int C2S; (C2S = ReadByte()) >= 0; )
                {
-                       entity reader = C2S_Protocol_from(C2S);
+                       entity reader = REGISTRY_GET(C2S_Protocol, C2S);
                        if (reader && reader.m_read && reader.m_read(NULL, sender, true)) continue;
                        LOG_SEVEREF("Net_ClientCommand() with malformed C2S=%d", C2S);
                        return;
@@ -283,7 +286,7 @@ MACRO_END
 
 // serialization: old
 
-#define ReadRegistered(r) r##_from(Read_byte())
+#define ReadRegistered(r) REGISTRY_GET(r, Read_byte())
 #define WriteRegistered(r, to, it) Write_byte(to, it.m_id)
 
 #define Read_byte() ReadByte()
index a48e83ac1a32593f7ccced9044b55de4308d7b79..fdcc730a068527b73b4a1e2291fc910616e9b53f 100644 (file)
        #define _R_DEL(r)
 #endif
 
+#define REGISTRY_MAX(id) id##_MAX
+#define REGISTRY_COUNT(id) id##_COUNT
 /**
  * Declare a new registry.
  *
- * Don't forget to call `REGISTER_REGISTRY`:
+ * Don't forget to call REGISTER_REGISTRY and REGISTRY_DEFINE_GET:
  *     REGISTER_REGISTRY(Foos)
+ *     REGISTRY_DEFINE_GET(Foos, null_ent)
  */
 #define REGISTRY(id, max) \
        void Register##id(); \
        noref entity id##_first, id##_last; \
        _R_MAP(_##id, id##_MAX); \
        SHUTDOWN(id) { _R_DEL(_##id); } \
-       entity _##id##_from(int i, entity null) { if (i >= 0 && i < id##_COUNT) { entity e = _R_GET(_##id, i); if (e) return e; } return null; }
+
+#define REGISTRY_DEFINE_GET(id, null) \
+       entity id##_from(int i) { if (i >= 0 && i < id##_COUNT) { entity e = _R_GET(_##id, i); if (e) return e; } return null; }
+
+#define REGISTRY_GET(id, i) id##_from(i)
 
 /** Add registry dependencies to a registry */
 #define REGISTRY_DEPENDS(id, dep) void Register##dep(); void REGISTRY_DEPENDS_(id) { Register##dep(); }
@@ -129,14 +136,14 @@ MACRO_END
                entity a = _R_GET(_##id, i), b = _R_GET(_##id, j); \
                _R_SET(_##id, i, b); \
                _R_SET(_##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 _R_GET(_##id, i - 1).REGISTRY_NEXT = b; \
-        \
+               \
                if (j == 0) id##_first = a; \
                else _R_GET(_##id, j - 1).REGISTRY_NEXT = a; \
        } \
@@ -189,10 +196,7 @@ void Registry_send(string id, string hash);
        } \
        void Registry_send_all() { Registry_send(#id, REGISTRY_HASH(id)); } \
 
-#define REGISTER_REGISTRY(...) EVAL_REGISTER_REGISTRY(OVERLOAD(REGISTER_REGISTRY, __VA_ARGS__))
-#define EVAL_REGISTER_REGISTRY(...) __VA_ARGS__
-#define REGISTER_REGISTRY_1(id) REGISTER_REGISTRY_2(id, #id)
-#define REGISTER_REGISTRY_2(id, str) \
+#define _REGISTER_REGISTRY(id, str) \
        ACCUMULATE_FUNCTION(__static_init_1, Register##id) \
        CLASS(id##Registry, Object) \
                ATTRIB(id##Registry, m_name, string, str); \
@@ -201,6 +205,8 @@ void Registry_send(string id, string hash);
        ENDCLASS(id##Registry) \
        REGISTER(Registries, REGISTRY, id, m_id, NEW(id##Registry)); \
        METHOD(id##Registry, m_reload, void()) { \
-           id##_state = 0; \
+               id##_state = 0; \
                Register##id(); \
        }
+
+#define REGISTER_REGISTRY(id) _REGISTER_REGISTRY(id, #id)
index 5a2b53b69f3796da2c23802c617567d221ddbeb6..9bd4a3af94802718fcbd51e0e27046c5b366b6db 100644 (file)
@@ -168,6 +168,8 @@ REGISTRY(Stats, 256 - STATS_ENGINE_RESERVE)
 REGISTER_REGISTRY(Stats)
 REGISTRY_SORT(Stats)
 REGISTRY_CHECK(Stats)
+
+REGISTRY_DEFINE_GET(Stats, NULL)
 STATIC_INIT(Stats_renumber)
 {
        FOREACH(Stats, true, {
index 80133b8b374dd7bb9d7dfa86373cfa3a984f06e3..291b55b27aefff385e756c294ffcfc9a4b4067a9 100644 (file)
@@ -5,8 +5,9 @@
 #include "xonotic/tab.qh"
 
 REGISTRY(Settings, BITS(3))
-#define Settings_from(i) _Settings_from(i, NULL)
 REGISTER_REGISTRY(Settings)
+
+REGISTRY_DEFINE_GET(Settings, NULL)
 #define REGISTER_SETTINGS(id, impl) \
     LAZY_NEW(id, impl) \
     REGISTER(Settings, MENU, id, m_id, NEW(Lazy, LAZY(id)))
index eac6f754d8082755219a8ce81c3f91ba0fad97c6..7ef5172965ea72611f81b43887b5047f97d5536d 100644 (file)
@@ -37,7 +37,7 @@ string WeaponArenaString()
        s = "";
        for(int j = 0; j < n; ++j)
        {
-               Weapon wep = Weapons_fromstr(argv(j));
+               Weapon wep = Weapon_from_name(argv(j));
                if(wep != WEP_Null)
                {
                        s = cons_mid(s, " & ", wep.m_name);
@@ -255,7 +255,7 @@ void XonoticMutatorsDialog_fill(entity me)
                me.TDempty(me, 0.1); // fix initial position
        for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
        {
-               w = Weapons_from(i);
+               w = REGISTRY_GET(Weapons, i);
                if (w.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_SPECIALATTACK))
                        continue;
                if ((j % 3) == 0)
index ba10d276ebfb119b32955dc73b2243e46b9dd414..b617d4915d4925787c06450c55c343deaade6567 100644 (file)
@@ -4,19 +4,19 @@
 
 METHOD(SettingSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
 {
-    Lazy l = Settings_from(i);
+    Lazy l = REGISTRY_GET(Settings, 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_from(i);
+    Lazy l = REGISTRY_GET(Settings, i);
     entity it = l.m_get();
     if (returns) returns(it.titleTooltip);
     return it;
 }
-METHOD(SettingSource, reload, int(entity this, string filter)) { return Settings_COUNT; }
+METHOD(SettingSource, reload, int(entity this, string filter)) { return REGISTRY_COUNT(Settings); }
 
 string XonoticRegisteredSettingsList_cb_name;
 string XonoticRegisteredSettingsList_cb_tooltip;
index 21278f720cc6e37c1ed13d78dc5eca8280885c33..65797e2bffc827e7e48c57a11693eee78fb4d85f 100644 (file)
@@ -623,7 +623,7 @@ void ServerList_TypeSort_Click(entity btn, entity me)
                // the type was found
                // choose the next one
                flag = true;
-               s = MapInfo_Type_ToString(Gametypes_from(it.m_id + 1));
+               s = MapInfo_Type_ToString(REGISTRY_GET(Gametypes, it.m_id + 1));
                if (s == "") s = MapInfo_Type_ToString(first);
                break;
        });
index 7b3d7375b7760018cf4ab267e3f8d2daab6bc137..157d22ffee2453db8d1713a90dc647f918ec4049 100644 (file)
@@ -76,7 +76,7 @@ string XonoticWeaponsList_toString(entity me)
        s = "";
        for(i = 0; i < n; ++i)
        {
-               e = Weapons_from(stof(argv(i)));
+               e = REGISTRY_GET(Weapons, stof(argv(i)));
                s = strcat(s, e.m_name, ", ");
        }
        return substring(s, 0, strlen(s) - 2);
@@ -91,7 +91,7 @@ void XonoticWeaponsList_drawListBoxItem(entity me, int i, vector absSize, bool i
                me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
        }
-       e = Weapons_from(stof(argv(i)));
+       e = REGISTRY_GET(Weapons, stof(argv(i)));
        string msg = e.m_name;
        if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
                msg = strcat(msg, "*");
index f8285f634d82f0b920ead3a79c3af60712a778f6..81baa2c196dd5042c2610de8707282272527797e 100644 (file)
@@ -25,9 +25,9 @@ const int WAYPOINTFLAG_NORELINK__DEPRECATED = BIT(20);
 const int WPFLAGMASK_NORELINK = (WAYPOINTFLAG_TELEPORT | WAYPOINTFLAG_LADDER | WAYPOINTFLAG_JUMP | WAYPOINTFLAG_CUSTOM_JP | WAYPOINTFLAG_SUPPORT);
 
 float bot_custom_weapon;
-float bot_weapons_close[Weapons_MAX];
-float bot_weapons_far[Weapons_MAX];
-float bot_weapons_mid[Weapons_MAX];
+float bot_weapons_close[REGISTRY_MAX(Weapons)];
+float bot_weapons_far[REGISTRY_MAX(Weapons)];
+float bot_weapons_mid[REGISTRY_MAX(Weapons)];
 float skill;
 
 .float bot_tracewalk_time;
index 7b30b62dfabbd720111f6cafad9296c231ce7a66..57de9f05cefecc0376946dd8d5ec26ae0017f689 100644 (file)
@@ -350,14 +350,14 @@ void bot_custom_weapon_priority_setup()
                        tokens = tokenizebyseparator(W_NumberWeaponOrder(autocvar_bot_ai_custom_weapon_priority_##dist)," "); \
                        bot_weapons_##dist[0] = -1; \
                        c = 0; \
-                       for(i = 0; i < tokens && c < Weapons_COUNT; ++i) { \
+                       for(i = 0; i < tokens && c < REGISTRY_COUNT(Weapons); ++i) { \
                                w = stof(argv(i)); \
                                if (w >= WEP_FIRST && w <= WEP_LAST) { \
                                        bot_weapons_##dist[c] = w; \
                                        ++c; \
                                } \
                        } \
-                       if (c < Weapons_COUNT) \
+                       if (c < REGISTRY_COUNT(Weapons)) \
                                bot_weapons_##dist[c] = -1; \
                } \
        MACRO_END
index 6515cc44efad6bdcbb63a6f11c55f16586ed7bab..d0c6da839ceb26d2b902657ef494f308b3bbeccf 100644 (file)
@@ -1476,13 +1476,13 @@ void havocbot_chooseweapon(entity this, .entity weaponentity)
 
                // Choose weapons for far distance
                if ( distance > bot_distance_far ) {
-                       for(i=0; i < Weapons_COUNT && bot_weapons_far[i] != -1 ; ++i){
+                       for(i=0; i < REGISTRY_COUNT(Weapons) && bot_weapons_far[i] != -1 ; ++i){
                                w = bot_weapons_far[i];
-                               if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
+                               if ( client_hasweapon(this, REGISTRY_GET(Weapons, w), weaponentity, true, false) )
                                {
                                        if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, weaponentity, w))
                                                continue;
-                                       this.(weaponentity).m_switchweapon = Weapons_from(w);
+                                       this.(weaponentity).m_switchweapon = REGISTRY_GET(Weapons, w);
                                        return;
                                }
                        }
@@ -1490,26 +1490,26 @@ void havocbot_chooseweapon(entity this, .entity weaponentity)
 
                // Choose weapons for mid distance
                if ( distance > bot_distance_close) {
-                       for(i=0; i < Weapons_COUNT && bot_weapons_mid[i] != -1 ; ++i){
+                       for(i=0; i < REGISTRY_COUNT(Weapons) && bot_weapons_mid[i] != -1 ; ++i){
                                w = bot_weapons_mid[i];
-                               if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
+                               if ( client_hasweapon(this, REGISTRY_GET(Weapons, w), weaponentity, true, false) )
                                {
                                        if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, weaponentity, w))
                                                continue;
-                                       this.(weaponentity).m_switchweapon = Weapons_from(w);
+                                       this.(weaponentity).m_switchweapon = REGISTRY_GET(Weapons, w);
                                        return;
                                }
                        }
                }
 
                // Choose weapons for close distance
-               for(i=0; i < Weapons_COUNT && bot_weapons_close[i] != -1 ; ++i){
+               for(i=0; i < REGISTRY_COUNT(Weapons) && bot_weapons_close[i] != -1 ; ++i){
                        w = bot_weapons_close[i];
-                       if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
+                       if ( client_hasweapon(this, REGISTRY_GET(Weapons, w), weaponentity, true, false) )
                        {
                                if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, weaponentity, w))
                                        continue;
-                               this.(weaponentity).m_switchweapon = Weapons_from(w);
+                               this.(weaponentity).m_switchweapon = REGISTRY_GET(Weapons, w);
                                return;
                        }
                }
index 9c2c6825db0342164159eef90cd99c0e59f8ca91..955d15af6a7b270b71ee7b4467dae04c937f696d 100644 (file)
@@ -588,10 +588,10 @@ float bot_cmd_select_weapon(entity this)
                if(this.(weaponentity).m_weapon == WEP_Null && slot != 0)
                        continue;
 
-               if(client_hasweapon(this, Weapons_from(id), weaponentity, true, false))
+               if(client_hasweapon(this, REGISTRY_GET(Weapons, id), weaponentity, true, false))
                {
                        success = true;
-                       this.(weaponentity).m_switchweapon = Weapons_from(id);
+                       this.(weaponentity).m_switchweapon = REGISTRY_GET(Weapons, id);
                }
        }
 
index f03a815de26b6de896ddee64a71dc6e05e0476c2..ea3af546935bb3903ee290a3e2e504d62be058ef 100644 (file)
@@ -2,10 +2,11 @@
 
 #include <common/command/_mod.qh>
 REGISTRY(COMMON_COMMANDS, BITS(7))
-#define COMMON_COMMANDS_from(i) _COMMON_COMMANDS_from(i, NULL)
 REGISTER_REGISTRY(COMMON_COMMANDS)
 REGISTRY_SORT(COMMON_COMMANDS)
 
+REGISTRY_DEFINE_GET(COMMON_COMMANDS, NULL)
+
 #define COMMON_COMMAND(id, description) \
        CLASS(commoncommand_##id, Command) \
                ATTRIB(commoncommand_##id, m_name, string, #id); \
index 8115d712ebe9f46b39f131a9c1dce48f74250377..71ace677ab47d0b0ed829e379f9ee56e10031526 100644 (file)
@@ -1,10 +1,11 @@
 #pragma once
 
 REGISTRY(SERVER_COMMANDS, BITS(7))
-#define SERVER_COMMANDS_from(i) _SERVER_COMMANDS_from(i, NULL)
 REGISTER_REGISTRY(SERVER_COMMANDS)
 REGISTRY_SORT(SERVER_COMMANDS)
 
+REGISTRY_DEFINE_GET(SERVER_COMMANDS, NULL)
+
 #define SERVER_COMMAND(id, description) \
        CLASS(servercommand_##id, Command) \
                ATTRIB(servercommand_##id, m_name, string, #id); \
index 9d7421987c1ce254c5ce4da58139214d594a6d53..a8ec77959af89a584a3b4f03b2806a04e2cb37b2 100644 (file)
@@ -195,7 +195,7 @@ void FixClientCvars(entity e);
 
 float bot_waypoints_for_items;
 
-.float attack_finished_for[Weapons_MAX * MAX_WEAPONSLOTS];
+.float attack_finished_for[REGISTRY_MAX(Weapons) * MAX_WEAPONSLOTS];
 .float attack_finished_single[MAX_WEAPONSLOTS];
 #if INDEPENDENT_ATTACK_FINISHED
 #define ATTACK_FINISHED_FOR(ent, w, slot) ((ent).(attack_finished_for[((w) - WEP_FIRST) * MAX_WEAPONSLOTS + (slot)]))
@@ -296,7 +296,7 @@ string matchid;
 
 bool radar_showennemies;
 
-.float weapon_load[Weapons_MAX];
+.float weapon_load[REGISTRY_MAX(Weapons)];
 .int ammo_none; // used by the reloading system, must always be 0
 .int clip_load;
 .int old_clip_load;
index 555a73472fb35cff23435bc2c9b7f2cdfbc66525..e5363db7738fd9a79b5206fbcaa0262110350a49 100644 (file)
@@ -129,7 +129,7 @@ void Obituary_SpecialDeath(
                return;
        }
 
-       entity deathent = Deathtypes_from(deathtype - DT_FIRST);
+       entity deathent = REGISTRY_GET(Deathtypes, deathtype - DT_FIRST);
        if (!deathent)
        {
                backtrace("Obituary_SpecialDeath: Could not find deathtype entity!\n");
index 49685d49d7ec088c9a3a5a83c993dadbb7f89bbf..62acd99d8df93ac608b6d32b431529da000189c3 100644 (file)
@@ -149,7 +149,7 @@ X(9, next)
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) \
                { \
                        .entity weaponentity = weaponentities[slot]; \
-                       W_SwitchWeapon_TryOthers(this, Weapons_from(WEP_FIRST + i), weaponentity); \
+                       W_SwitchWeapon_TryOthers(this, REGISTRY_GET(Weapons, WEP_FIRST + i), weaponentity); \
                        if(autocvar_g_weaponswitch_debug != 1) \
                                break; \
                } \
index 9dd468c2d74982c15a6e83691debb4b4c9254bcb..d4d5d349449163c529ab6b5223ec7056dcb5814b 100644 (file)
@@ -243,7 +243,7 @@ string WeaponNameFromWeaponentity(entity this, .entity weaponentity)
                return wepent.m_weapon.m_name;
        else if(wepent.m_switchweapon != WEP_Null)
                return wepent.m_switchweapon.m_name;
-       return "none"; //Weapons_from(wepent.cnt).m_name;
+       return "none"; //REGISTRY_GET(Weapons, wepent.cnt).m_name;
 }
 
 string formatmessage(entity this, string msg)
@@ -719,7 +719,7 @@ void readplayerstartcvars()
                for (int j = 0; j < t; ++j)
                {
                        s = argv(j);
-                       Weapon wep = Weapons_fromstr(s);
+                       Weapon wep = Weapon_from_name(s);
                        if(wep != WEP_Null)
                        {
                                g_weaponarena_weapons |= (wep.m_wepset);
index 627698aa217c6f0bb21e4edf534cde9ee823833c..5d10e85bdf8dc5d8d74ed468ca20ffc38f466000 100644 (file)
@@ -9,12 +9,12 @@ REPLICATE(cvar_cl_accuracy_data_share, bool, "cl_accuracy_data_share");
 REPLICATE(cvar_cl_accuracy_data_receive, bool, "cl_accuracy_data_receive");
 
 .entity accuracy;
-.float accuracy_frags[Weapons_MAX];
+.float accuracy_frags[REGISTRY_MAX(Weapons)];
 
-.float accuracy_hit[Weapons_MAX];
-.float accuracy_fired[Weapons_MAX];
-.float accuracy_cnt_hit[Weapons_MAX];
-.float accuracy_cnt_fired[Weapons_MAX];
+.float accuracy_hit[REGISTRY_MAX(Weapons)];
+.float accuracy_fired[REGISTRY_MAX(Weapons)];
+.float accuracy_cnt_hit[REGISTRY_MAX(Weapons)];
+.float accuracy_cnt_fired[REGISTRY_MAX(Weapons)];
 
 
 // init/free
index 06615c4eac8575465aed85fe57cbe5181c423940..9486404b9bb008820ad66be17f2b17e001a564fb 100644 (file)
@@ -30,7 +30,7 @@ void W_GiveWeapon(entity e, int wep)
 {
        if (!wep) return;
 
-       STAT(WEAPONS, e) |= WepSet_FromWeapon(Weapons_from(wep));
+       STAT(WEAPONS, e) |= WepSet_FromWeapon(REGISTRY_GET(Weapons, wep));
 
        if (IS_PLAYER(e)) {
            Send_Notification(NOTIF_ONE, e, MSG_MULTI, ITEM_WEAPON_GOT, wep);
index f1866eab089311a0ce2c2a052d6b9b3fbaf00031..3f821b44fa8deb3e7507f6c62d0e0ee7525aa892 100644 (file)
@@ -151,7 +151,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl
        while(rest != "")
        {
                weaponwant = stof(car(rest)); rest = cdr(rest);
-               wep = Weapons_from(weaponwant);
+               wep = REGISTRY_GET(Weapons, weaponwant);
                wepset = wep.m_wepset;
                if(imp >= 0)
                if(wep.impulse != imp)
@@ -207,7 +207,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl
                while(rest != "")
                {
                        weaponwant = stof(car(rest)); rest = cdr(rest);
-                       wep = Weapons_from(weaponwant);
+                       wep = REGISTRY_GET(Weapons, weaponwant);
                        wepset = wep.m_wepset;
                        if(imp >= 0)
                                if(wep.impulse != imp)
@@ -301,7 +301,7 @@ void W_CycleWeapon(entity this, string weaponorder, float dir, .entity weaponent
        float w;
        w = W_GetCycleWeapon(this, weaponorder, dir, -1, 1, true, weaponentity);
        if(w > 0)
-               W_SwitchWeapon(this, Weapons_from(w), weaponentity);
+               W_SwitchWeapon(this, REGISTRY_GET(Weapons, w), weaponentity);
 }
 
 void W_NextWeaponOnImpulse(entity this, float imp, .entity weaponentity)
@@ -309,7 +309,7 @@ void W_NextWeaponOnImpulse(entity this, float imp, .entity weaponentity)
        float w;
        w = W_GetCycleWeapon(this, CS(this).cvar_cl_weaponpriority, +1, imp, 1, (CS(this).cvar_cl_weaponimpulsemode == 0), weaponentity);
        if(w > 0)
-               W_SwitchWeapon(this, Weapons_from(w), weaponentity);
+               W_SwitchWeapon(this, REGISTRY_GET(Weapons, w), weaponentity);
 }
 
 // next weapon
@@ -337,7 +337,7 @@ void W_PreviousWeapon(entity this, float list, .entity weaponentity)
 // previously used if exists and has ammo, (second) best otherwise
 void W_LastWeapon(entity this, .entity weaponentity)
 {
-       Weapon wep = Weapons_from(this.(weaponentity).cnt);
+       Weapon wep = REGISTRY_GET(Weapons, this.(weaponentity).cnt);
        if (client_hasweapon(this, wep, weaponentity, true, false))
                W_SwitchWeapon(this, wep, weaponentity);
        else
index dd21e6419da58f6772f3f541f18c588e782b71d1..2fff84e4fb5a4980064b91f0f0a120295d492f7a 100644 (file)
@@ -12,7 +12,7 @@ bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andam
 .int weaponcomplainindex;
 float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing, .entity weaponentity);
 
-#define w_getbestweapon(ent,wepent) Weapons_from(W_GetCycleWeapon(ent, CS(ent).cvar_cl_weaponpriority, 0, -1, false, true, wepent))
+#define w_getbestweapon(ent,wepent) REGISTRY_GET(Weapons, W_GetCycleWeapon(ent, CS(ent).cvar_cl_weaponpriority, 0, -1, false, true, wepent))
 
 void W_SwitchWeapon_Force(Player this, Weapon w, .entity weaponentity);
 
index 93c49af9bddb7c7fe02cdd47018d5ce34a3758dd..881d431ae4d4a8b43d4f68804c6f41c7b0ff8ab9 100644 (file)
@@ -14,7 +14,7 @@ string W_Apply_Weaponreplace(string in)
        string out = "";
        FOREACH_WORD(in, true, {
                string replacement = "";
-               Weapon w = Weapons_fromstr(it);
+               Weapon w = Weapon_from_name(it);
                if (w)
                {
             replacement = w.weaponreplace;
@@ -55,7 +55,7 @@ void weapon_defaultspawnfunc(entity this, Weapon wpn)
                        for (int i = 1; i < t; ++i)
                        {
                                s = argv(i);
-                               Weapon wep = Weapons_fromstr(s);
+                               Weapon wep = Weapon_from_name(s);
                                if(wep != WEP_Null)
                                {
                                        entity replacement = spawn();
@@ -68,7 +68,7 @@ void weapon_defaultspawnfunc(entity this, Weapon wpn)
                if (t >= 1) // always the case!
                {
                        s = argv(0);
-                       wpn = Weapons_fromstr(s);
+                       wpn = Weapon_from_name(s);
                }
                if (wpn == WEP_Null)
                {
index ba039fc1055baf6655a3bc91724635df4d69281f..e36bc68c62af99b39d543d4811140b9c35cee65a 100644 (file)
@@ -36,7 +36,7 @@ void thrown_wep_think(entity this)
 // returns amount of ammo used, or -1 for failure, or 0 for no ammo count
 float W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo, .entity weaponentity)
 {
-       Weapon info = Weapons_from(wpn);
+       Weapon info = REGISTRY_GET(Weapons, wpn);
        int ammotype = info.ammo_type;
 
        entity wep = spawn();
@@ -51,7 +51,7 @@ float W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector
 
        W_DropEvent(wr_drop,own,wpn,wep,weaponentity);
 
-       if(WepSet_FromWeapon(Weapons_from(wpn)) & WEPSET_SUPERWEAPONS)
+       if(WepSet_FromWeapon(REGISTRY_GET(Weapons, wpn)) & WEPSET_SUPERWEAPONS)
        {
                Item_SetExpiring(wep, true);
                if(own.items & IT_UNLIMITED_SUPERWEAPONS)
@@ -138,7 +138,7 @@ bool W_IsWeaponThrowable(entity this, int w)
        if (w == WEP_Null.m_id)
                return false;
 
-       return (Weapons_from(w)).weaponthrowable;
+       return (REGISTRY_GET(Weapons, w)).weaponthrowable;
 }
 
 // toss current weapon
index 5f4f6f8332deb1d0b4d171c31a839922b4267bd3..a10274ab6861b620c5d38470daad2f6dc6bf4a0b 100644 (file)
@@ -55,7 +55,7 @@ bool CL_Weaponentity_CustomizeEntityForClient(entity this, entity client)
 
 vector CL_Weapon_GetShotOrg(int wpn)
 {
-       entity wi = Weapons_from(wpn);
+       entity wi = REGISTRY_GET(Weapons, wpn);
        entity e = spawn();
        CL_WeaponEntity_SetModel(e, wi.mdl, false);
        vector ret = e.movedir;
@@ -846,7 +846,7 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen
 
 void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity)
 {
-       Weapon w = Weapons_from(weapon_type);
+       Weapon w = REGISTRY_GET(Weapons, weapon_type);
        weapon_dropevent_item = weapon_item;
        w.event(w, player, weaponentity);
 }