]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Weapons: make WepSet_FromWeapon more verbose, making Weapons_from uses more obvious
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 5 Dec 2015 09:57:09 +0000 (20:57 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 5 Dec 2015 09:57:09 +0000 (20:57 +1100)
50 files changed:
qcsrc/client/hud/hud.qh
qcsrc/client/hud/panel/ammo.qc
qcsrc/client/hud/panel/notify.qc
qcsrc/client/hud/panel/weapons.qc
qcsrc/client/main.qh
qcsrc/client/scoreboard.qc
qcsrc/client/view.qc
qcsrc/common/deathtypes/all.qh
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
qcsrc/common/mutators/mutator/new_toys/new_toys.qc
qcsrc/common/mutators/mutator/nix/nix.qc
qcsrc/common/mutators/mutator/overkill/hmg.qc
qcsrc/common/mutators/mutator/overkill/overkill.qc
qcsrc/common/mutators/mutator/overkill/rpc.qc
qcsrc/common/mutators/mutator/pinata/pinata.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/playerstats.qc
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/all.qh
qcsrc/common/weapons/config.qc
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/crylink.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/hlac.qc
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/mortar.qc
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/dpdefs/doc.md [new file with mode: 0644]
qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
qcsrc/menu/xonotic/keybinder.qc
qcsrc/menu/xonotic/weaponslist.qc
qcsrc/server/bot/havocbot/havocbot.qc
qcsrc/server/cl_impulse.qc
qcsrc/server/cl_player.qc
qcsrc/server/g_damage.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/t_items.qc
qcsrc/server/weapons/common.qc
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/spawning.qc
qcsrc/server/weapons/throwing.qc
qcsrc/server/weapons/weaponsystem.qc

index 764a526b9b950e91c8ca847ad27a0862f4f22828..d30a87273514636a87d1fd9b2ca6903c96e0f67d 100644 (file)
@@ -77,8 +77,8 @@ float complain_weapon_time;
 int ps_primary, ps_secondary;
 int ts_primary, ts_secondary;
 
-int last_switchweapon;
-int last_activeweapon;
+Weapon last_switchweapon;
+Weapon last_activeweapon;
 float weapontime;
 float weaponprevtime;
 
index 80cfdd69c1791e816aec4d1efe047a1a1ac3ac0e..6c37aa13a89ea740d944d2a46aec0bd1d1c0bb9c 100644 (file)
@@ -158,6 +158,7 @@ void HUD_Ammo()
                ammo_size.y = newSize;
        }
 
+       Weapon wep = switchweapon;
        int i;
        bool infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO);
        row = column = 0;
@@ -172,7 +173,7 @@ void HUD_Ammo()
                        DrawAmmoItem(
                                pos,
                                ammo_size,
-                               (get_weaponinfo(switchweapon)).ammo_field,
+                               wep.ammo_field,
                                true,
                                infinite_ammo
                        );
@@ -196,7 +197,7 @@ void HUD_Ammo()
                                pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y),
                                ammo_size,
                                ammotype,
-                               ((get_weaponinfo(switchweapon)).ammo_field == ammotype),
+                               (wep.ammo_field == ammotype),
                                infinite_ammo
                        );
 
index 821c993fafe30d1abcfe2001847e7c1adcb0008f..3c4b9c10514236a10d5be3f633ebe3c48587a5bb 100644 (file)
@@ -106,7 +106,7 @@ void HUD_Notify()
                {
                        attacker = sprintf(_("Player %d"), count + 1);
                        victim = sprintf(_("Player %d"), count + 2);
-                       icon = get_weaponinfo(min(WEP_FIRST + count * 2, WEP_LAST)).model2;
+                       icon = Weapons_from(min(WEP_FIRST + count * 2, WEP_LAST)).model2;
                        alpha = bound(0, 1.2 - count / entry_count, 1);
                }
                else
index 818663242adf4098143b4ce33a9eb8ddd362fcfb..8970332cd105def4f719790ddfabd38f217e44ec 100644 (file)
@@ -77,18 +77,10 @@ void HUD_Weapons()
                weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
 
                weapon_cnt = 0;
-               for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-               {
-                       setself(get_weaponinfo(i));
-                       if(self.impulse >= 0)
-                       {
-                               weaponorder[weapon_cnt] = self;
-                               ++weapon_cnt;
-                       }
-               }
+               FOREACH(Weapons, it != WEP_Null && it.impulse >= 0, LAMBDA(weaponorder[weapon_cnt++] = it));
                for(i = weapon_cnt; i < Weapons_MAX; ++i)
-                       weaponorder[i] = world;
-               heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
+                       weaponorder[i] = NULL;
+               heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, NULL);
 
                weaponorder_cmp_str = string_null;
        }
@@ -100,7 +92,7 @@ void HUD_Weapons()
        {
                if(!weapons_stat)
                        for(i = WEP_FIRST; i <= WEP_LAST; i += floor((WEP_LAST-WEP_FIRST)/5))
-                               weapons_stat |= WepSet_FromWeapon(i);
+                               weapons_stat |= WepSet_FromWeapon(Weapons_from(i));
 
                #if 0
                /// debug code
@@ -109,7 +101,7 @@ void HUD_Weapons()
                        weapons_stat = '0 0 0';
                        float countw = 1 + floor((floor(time * cvar("wep_add"))) % (Weapons_COUNT - 1));
                        for(i = WEP_FIRST; i <= countw; ++i)
-                               weapons_stat |= WepSet_FromWeapon(i);
+                               weapons_stat |= WepSet_FromWeapon(Weapons_from(i));
                }
                #endif
        }
@@ -126,7 +118,7 @@ void HUD_Weapons()
                // do we own this weapon?
                weapon_count = 0;
                for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
-                       if((weapons_stat & WepSet_FromWeapon(weaponorder[i].weapon)) || (weaponorder[i].weapon == complain_weapon))
+                       if((weapons_stat & WepSet_FromWeapon(Weapons_from(weaponorder[i].weapon))) || (weaponorder[i].weapon == complain_weapon))
                                ++weapon_count;
 
 
@@ -140,11 +132,10 @@ void HUD_Weapons()
                // get the all-weapons layout
                int nHidden = 0;
                WepSet weapons_stat = WepSet_GetFromStat();
-               for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
-                       Weapon w = get_weaponinfo(i);
-                       if (weapons_stat & w.m_wepset) continue;
-                       if (w.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
-               }
+               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                       if (weapons_stat & it.m_wepset) continue;
+                       if (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
+               ));
                vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, padded_panel_size, aspect);
                columns = table_size.x;
                rows = table_size.y;
@@ -348,14 +339,14 @@ void HUD_Weapons()
                // retrieve information about the current weapon to be drawn
                setself(weaponorder[i]);
                weapon_id = self.impulse;
-               isCurrent = (self.weapon == switchweapon);
+               isCurrent = (self.weapon == switchweapon.m_id);
 
                // skip if this weapon doesn't exist
                if(!self || weapon_id < 0) { continue; }
 
                // skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon
                if(autocvar_hud_panel_weapons_onlyowned)
-               if (!((weapons_stat & WepSet_FromWeapon(self.weapon)) || (self.weapon == complain_weapon)))
+               if (!((weapons_stat & WepSet_FromWeapon(Weapons_from(self.weapon))) || (self.weapon == complain_weapon)))
                        continue;
 
                // figure out the drawing position of weapon
@@ -379,7 +370,7 @@ void HUD_Weapons()
                }
 
                // drawing all the weapon items
-               if(weapons_stat & WepSet_FromWeapon(self.weapon))
+               if(weapons_stat & WepSet_FromWeapon(Weapons_from(self.weapon)))
                {
                        // draw the weapon image
                        if(isCurrent)
index a6aebc61c64cfa608f4367e68d11137962734c70..91d5de09bd1b36de04e1b32c4735bd52e18b480c 100644 (file)
@@ -2,6 +2,7 @@
 #define CLIENT_MAIN_H
 
 #include "../common/constants.qh"
+#include "../common/weapons/all.qh"
 
 // --------------------------------------------------------------------------
 // MENU Functionality
@@ -94,9 +95,9 @@ bool button_zoom;
 bool spectatorbutton_zoom;
 bool button_attack2;
 
-int activeweapon;
-int switchingweapon;
-#define switchweapon STAT(SWITCHWEAPON)
+Weapon activeweapon;
+Weapon switchingweapon;
+Weapon switchweapon;
 float current_viewzoom;
 float zoomin_effect;
 float warmup_stage;
index 1f864a540db584f6d31babdce8ebf2ee2597d093..4d9a8c69d0c35c91fe9496da174b91d33ea29e9c 100644 (file)
@@ -1001,17 +1001,15 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        WepSet weapons_inmap = WepSet_GetFromStat_InMap();
        float initial_posx = pos.x;
        int disownedcnt = 0;
-       for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
-               Weapon e = get_weaponinfo(i);
-               setself(e);
-               if (!self.weapon) continue;
+       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+               if (!it.weapon) continue;
 
                int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
-               WepSet set = e.m_wepset;
+               WepSet set = it.m_wepset;
                if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
                        ++disownedcnt;
-       }
+       ));
 
        int weapon_cnt = (Weapons_COUNT - 1) - disownedcnt;
        if (weapon_cnt <= 0) return pos;
@@ -1065,13 +1063,11 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        vector tmpos = pos;
 
        int column = 0;
-       for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
-               Weapon e = get_weaponinfo(i);
-               setself(e);
-               if (!self.weapon) continue;
+       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+               if (!it.weapon) continue;
                int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
-               WepSet set = e.m_wepset;
+               WepSet set = it.m_wepset;
                if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
                        continue;
 
@@ -1082,7 +1078,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                        weapon_alpha = 0.2 * scoreboard_alpha_fg;
 
                // weapon icon
-               drawpic_aspect_skin(tmpos, self.model2, '1 0 0' * weapon_width + '0 1 0' * weapon_height, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(tmpos, it.model2, '1 0 0' * weapon_width + '0 1 0' * weapon_height, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
                // the accuracy
                if (weapon_stats >= 0) {
                        weapons_with_stats += 1;
@@ -1107,7 +1103,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                        pos.y += height;
                }
                ++column;
-       }
+       ));
 
        if (weapons_with_stats)
                average_accuracy = floor((average_accuracy * 100 / weapons_with_stats) + 0.5);
index 112aec6c20fd57eedc3bd78cbfe60c70a0574926..85fea0d1b77c81406d4f4930beffd48895f05e69 100644 (file)
@@ -276,7 +276,7 @@ void viewmodel_draw(entity this)
        float a = this.alpha;
        int c = stof(getplayerkeyvalue(current_player, "colors"));
        vector g;
-       Weapon wep = Weapons_from(activeweapon);
+       Weapon wep = activeweapon;
        if (!(g = wep.wr_glow(wep))) g = colormapPaletteColor(c & 0x0F, true) * 2;
        entity me = CSQCModel_server2csqc(player_localentnum - 1);
        int fx = ((me.csqcmodel_effects & EFMASK_CHEAP)
@@ -293,7 +293,7 @@ void viewmodel_draw(entity this)
        }
        {
                static string name_last;
-               string name = Weapons_from(activeweapon).mdl;
+               string name = wep.mdl;
                if (name != name_last)
                {
                        name_last = name;
@@ -348,7 +348,7 @@ void Porto_Draw(entity this)
        vector p, dir, ang, q, nextdir;
        float portal_number, portal1_idx;
 
-       if(activeweapon != WEP_PORTO.m_id || spectatee_status || gametype == MAPINFO_TYPE_NEXBALL)
+       if(activeweapon != WEP_PORTO || spectatee_status || gametype == MAPINFO_TYPE_NEXBALL)
                return;
        if(g_balance_porto_secondary)
                return;
@@ -448,7 +448,7 @@ vector GetCurrentFov(float fov)
        zoomdir = button_zoom;
        if(hud == HUD_NORMAL)
        if(switchweapon == activeweapon)
-       if((activeweapon == WEP_VORTEX.m_id && vortex_scope) || (activeweapon == WEP_RIFLE.m_id && rifle_scope)) // do NOT use switchweapon here
+       if((activeweapon == WEP_VORTEX && vortex_scope) || (activeweapon == WEP_RIFLE && rifle_scope)) // do NOT use switchweapon here
                zoomdir += button_attack2;
        if(spectatee_status > 0 || isdemo())
        {
@@ -635,17 +635,17 @@ float TrueAimCheck()
 
        switch(activeweapon) // WEAPONTODO
        {
-               case WEP_TUBA.m_id: // no aim
-               case WEP_PORTO.m_id: // shoots from eye
-               case WEP_NEXBALL.m_id: // shoots from eye
-               case WEP_HOOK.m_id: // no trueaim
-               case WEP_MORTAR.m_id: // toss curve
+               case WEP_TUBA: // no aim
+               case WEP_PORTO: // shoots from eye
+               case WEP_NEXBALL: // shoots from eye
+               case WEP_HOOK: // no trueaim
+               case WEP_MORTAR: // toss curve
                        return SHOTTYPE_HITWORLD;
-               case WEP_VORTEX.m_id:
-               case WEP_VAPORIZER.m_id:
+               case WEP_VORTEX:
+               case WEP_VAPORIZER:
                        mv = MOVE_NORMAL;
                        break;
-               case WEP_RIFLE.m_id:
+               case WEP_RIFLE:
                        ta = trueaim_rifle;
                        mv = MOVE_NORMAL;
                        if(zoomscript_caught)
@@ -654,19 +654,19 @@ float TrueAimCheck()
                                return EnemyHitCheck();
                        }
                        break;
-               case WEP_DEVASTATOR.m_id: // projectile has a size!
+               case WEP_DEVASTATOR: // projectile has a size!
                        mi = '-3 -3 -3';
                        ma = '3 3 3';
                        break;
-               case WEP_FIREBALL.m_id: // projectile has a size!
+               case WEP_FIREBALL: // projectile has a size!
                        mi = '-16 -16 -16';
                        ma = '16 16 16';
                        break;
-               case WEP_SEEKER.m_id: // projectile has a size!
+               case WEP_SEEKER: // projectile has a size!
                        mi = '-2 -2 -2';
                        ma = '2 2 2';
                        break;
-               case WEP_ELECTRO.m_id: // projectile has a size!
+               case WEP_ELECTRO: // projectile has a size!
                        mi = '0 0 -3';
                        ma = '0 0 -3';
                        break;
@@ -813,7 +813,7 @@ void HitSound()
 
        static float hitsound_time_prev = 0;
        // HACK: the only way to get the arc to sound consistent with pitch shift is to ignore cl_hitsound_antispam_time
-       float arc_hack = activeweapon == WEP_ARC.m_id && autocvar_cl_hitsound >= 2;
+       float arc_hack = activeweapon == WEP_ARC && autocvar_cl_hitsound >= 2;
        if (arc_hack || COMPARE_INCREASING(time, hitsound_time_prev) > autocvar_cl_hitsound_antispam_time)
        {
                if (autocvar_cl_hitsound && unaccounted_damage)
@@ -919,7 +919,7 @@ void HUD_Crosshair()
 
                if(autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1))
                {
-                       e = get_weaponinfo(switchingweapon);
+                       e = switchingweapon;
                        if(e)
                        {
                                if(autocvar_crosshair_per_weapon)
@@ -1149,7 +1149,7 @@ void HUD_Crosshair()
 
 
                                // handle the values
-                               if (autocvar_crosshair_ring && activeweapon == WEP_VORTEX.m_id && vortex_charge && autocvar_crosshair_ring_vortex) // ring around crosshair representing velocity-dependent damage for the vortex
+                               if (autocvar_crosshair_ring && activeweapon == WEP_VORTEX && vortex_charge && autocvar_crosshair_ring_vortex) // ring around crosshair representing velocity-dependent damage for the vortex
                                {
                                        if (vortex_chargepool || use_vortex_chargepool) {
                                                use_vortex_chargepool = 1;
@@ -1169,14 +1169,14 @@ void HUD_Crosshair()
                                        ring_rgb = wcross_color;
                                        ring_image = "gfx/crosshair_ring_nexgun.tga";
                                }
-                               else if (autocvar_crosshair_ring && activeweapon == WEP_MINE_LAYER.m_id && minelayer_maxmines && autocvar_crosshair_ring_minelayer)
+                               else if (autocvar_crosshair_ring && activeweapon == WEP_MINE_LAYER && minelayer_maxmines && autocvar_crosshair_ring_minelayer)
                                {
                                        ring_value = bound(0, STAT(LAYED_MINES) / minelayer_maxmines, 1); // if you later need to use the count of bullets in another place, then add a float for it. For now, no need to.
                                        ring_alpha = autocvar_crosshair_ring_minelayer_alpha;
                                        ring_rgb = wcross_color;
                                        ring_image = "gfx/crosshair_ring.tga";
                                }
-                               else if (activeweapon == WEP_HAGAR.m_id && STAT(HAGAR_LOAD) && autocvar_crosshair_ring_hagar)
+                               else if (activeweapon == WEP_HAGAR && STAT(HAGAR_LOAD) && autocvar_crosshair_ring_hagar)
                                {
                                        ring_value = bound(0, STAT(HAGAR_LOAD) / hagar_maxrockets, 1);
                                        ring_alpha = autocvar_crosshair_ring_hagar_alpha;
@@ -1199,12 +1199,12 @@ void HUD_Crosshair()
 
                                        // Note: This is to stop Taoki from complaining that the image doesn't match all potential balances.
                                        // if a new image for another weapon is added, add the code (and its respective file/value) here
-                                       if ((activeweapon == WEP_RIFLE.m_id) && (weapon_clipsize == 80))
+                                       if ((activeweapon == WEP_RIFLE) && (weapon_clipsize == 80))
                                                ring_image = "gfx/crosshair_ring_rifle.tga";
                                        else
                                                ring_image = "gfx/crosshair_ring.tga";
                                }
-                               else if ( autocvar_crosshair_ring && autocvar_crosshair_ring_arc && arc_heat && activeweapon == WEP_ARC.m_id )
+                               else if ( autocvar_crosshair_ring && autocvar_crosshair_ring_arc && arc_heat && activeweapon == WEP_ARC )
                                {
                                        ring_value = arc_heat;
                                        ring_alpha = (1-arc_heat)*autocvar_crosshair_ring_arc_cold_alpha +
@@ -1707,10 +1707,12 @@ void CSQC_UpdateView(float w, float h)
        ColorTranslateMode = autocvar_cl_stripcolorcodes;
 
        // currently switching-to weapon (for crosshair)
-       switchingweapon = STAT(SWITCHINGWEAPON);
+       switchingweapon = Weapons_from(STAT(SWITCHINGWEAPON));
 
        // actually active weapon (for zoom)
-       activeweapon = getstati(STAT_ACTIVEWEAPON);
+       activeweapon = Weapons_from(getstati(STAT_ACTIVEWEAPON));
+
+       switchweapon = Weapons_from(STAT(SWITCHWEAPON));
 
        f = (serverflags & SERVERFLAG_TEAMPLAY);
        if(f != teamplay)
@@ -1739,7 +1741,7 @@ void CSQC_UpdateView(float w, float h)
        {
                last_activeweapon = activeweapon;
 
-               e = get_weaponinfo(activeweapon);
+               e = activeweapon;
                if(e.netname != "")
                        localcmd(strcat("\ncl_hook_activeweapon ", e.netname), "\n");
                else
@@ -1872,7 +1874,7 @@ void CSQC_UpdateView(float w, float h)
 
        if(autocvar_cl_reticle)
        {
-               Weapon wep = get_weaponinfo(activeweapon);
+               Weapon wep = activeweapon;
                // Draw the aiming reticle for weapons that use it
                // reticle_type is changed to the item we are zooming / aiming with, to decide which reticle to use
                // It must be a persisted float for fading out to work properly (you let go of the zoom button for
index dcf64b11f3d635b6dac5224de9d93977ac87585c..3c953bcf9d4756ddda33d8cd807fdc005476e03b 100644 (file)
@@ -40,7 +40,7 @@ const int DT_FIRST = BIT(13);
 #define DEATH_ISVEHICLE(t)      (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "vehicle")
 #define DEATH_ISTURRET(t)       (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "turret")
 #define DEATH_ISMONSTER(t)      (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "monster")
-#define DEATH_WEAPONOF(t)       (DEATH_ISSPECIAL(t) ? WEP_Null : get_weaponinfo((t) & DEATH_WEAPONMASK))
+#define DEATH_WEAPONOF(t)       (DEATH_ISSPECIAL(t) ? WEP_Null : Weapons_from((t) & DEATH_WEAPONMASK))
 #define DEATH_ISWEAPON(t, w)    (DEATH_WEAPONOF(t) == (w))
 
 string Deathtype_Name(int deathtype);
index 8c8237aeed626d99994af52dafedb48e06e4e93b..9cafd1a23a60c070906bac2c4fc0de68684264ed 100644 (file)
@@ -1342,7 +1342,7 @@ void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float s
        for(i = WEP_FIRST; i <= WEP_LAST ; ++i)
        {
                // Find weapon
-               if(self.weapons & WepSet_FromWeapon(i))
+               if(self.weapons & WepSet_FromWeapon(Weapons_from(i)))
                if(++c>=4)
                        break;
        }
index 5235e58e62df2c0faac3de32a2550cb51c1c11cc..2a0df8c642cce3b1157525e477675a64a833cb2e 100644 (file)
@@ -79,14 +79,14 @@ REGISTER_MUTATOR(nt, cvar("g_new_toys") && !cvar("g_instagib") && !cvar("g_overk
                // mark the guns as ok to use by e.g. impulse 99
                for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
                        if(nt_IsNewToy(i))
-                               get_weaponinfo(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
+                               Weapons_from(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
        }
 
        MUTATOR_ONROLLBACK_OR_REMOVE
        {
                for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
                        if(nt_IsNewToy(i))
-                               get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
+                               Weapons_from(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
        }
 
        MUTATOR_ONREMOVE
@@ -168,7 +168,7 @@ MUTATOR_HOOKFUNCTION(nt, SetStartItems)
 
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
        {
-               entity e = get_weaponinfo(i);
+               entity e = Weapons_from(i);
                if(!e.weapon)
                        continue;
 
@@ -177,7 +177,7 @@ MUTATOR_HOOKFUNCTION(nt, SetStartItems)
                for (j = 0; j < n; ++j)
                        for (k = WEP_FIRST; k <= WEP_LAST; ++k)
                        {
-                               Weapon w = get_weaponinfo(k);
+                               Weapon w = Weapons_from(k);
                                if (w.netname == argv(j))
                                {
                                        WepSet seti = e.m_wepset;
index 73b08bce8be60c72eec2e5d062df2d218c832e16..a07ad44cac4a25d6d96959810a5324c4f9d5b077 100644 (file)
@@ -45,7 +45,7 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill"
 
                for (int i = WEP_FIRST; i <= WEP_LAST; ++i)
                        if (NIX_CanChooseWeapon(i)) {
-                               Weapon w = get_weaponinfo(i);
+                               Weapon w = Weapons_from(i);
                                w.wr_init(w);
                        }
        }
@@ -78,7 +78,7 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill"
 
 bool NIX_CanChooseWeapon(int wpn)
 {
-       entity e = get_weaponinfo(wpn);
+       entity e = Weapons_from(wpn);
        if(!e.weapon) // skip dummies
                return false;
        if(g_weaponarena)
@@ -124,12 +124,12 @@ void NIX_GiveCurrentWeapon()
                        nix_nextchange = time; // start the first round now!
                else
                        nix_nextchange = time + autocvar_g_balance_nix_roundtime;
-               // Weapon w = get_weaponinfo(nix_weapon);
+               // Weapon w = Weapons_from(nix_weapon);
                // w.wr_init(w); // forget it, too slow
        }
 
        // get weapon info
-       entity e = get_weaponinfo(nix_weapon);
+       entity e = Weapons_from(nix_weapon);
 
        if(nix_nextchange != self.nix_lastchange_id) // this shall only be called once per round!
        {
index 7f2341fb0e53a7b2f8e7741ee9b1d5c6b47b526d..8341f7c71d4230faa24cf86286e3f29a742f7c7b 100644 (file)
@@ -61,8 +61,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone
                return;
        }
 
-       Weapon w = get_weaponinfo(actor.weapon);
-       if(!w.wr_checkammo1(w))
+       if(!thiswep.wr_checkammo1(thiswep))
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -108,8 +107,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone
                METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(hmg, reload_ammo) && actor.clip_load < WEP_CVAR(hmg, ammo)) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        } else
                        {
                                if (fire & 1)
index 5528bdf80bb8bdca536eb7eb1b8b6b6da19f32fe..05b6ddde34ae3bb9560259da179eca784ebe8d82 100644 (file)
@@ -63,7 +63,7 @@ void ok_DecreaseCharge(entity ent, int wep)
 {
        if(!ent.ok_use_ammocharge) return;
 
-       entity wepent = get_weaponinfo(wep);
+       entity wepent = Weapons_from(wep);
 
        if(wepent.weapon == 0)
                return; // dummy
@@ -73,7 +73,7 @@ void ok_DecreaseCharge(entity ent, int wep)
 
 void ok_IncreaseCharge(entity ent, int wep)
 {
-       entity wepent = get_weaponinfo(wep);
+       entity wepent = Weapons_from(wep);
 
        if(wepent.weapon == 0)
                return; // dummy
@@ -87,7 +87,7 @@ float ok_CheckWeaponCharge(entity ent, int wep)
 {
        if(!ent.ok_use_ammocharge) return true;
 
-       entity wepent = get_weaponinfo(wep);
+       entity wepent = Weapons_from(wep);
 
        if(wepent.weapon == 0)
                return 0; // dummy
@@ -229,7 +229,7 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
                        self.ok_notice_time = time + 2;
                        play2(self, SND(DRYFIRE));
                }
-               Weapon wpn = get_weaponinfo(self.weapon);
+               Weapon wpn = Weapons_from(self.weapon);
                .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                if(self.(weaponentity).state != WS_CLEAR)
                        w_ready(wpn, self, weaponentity, (self.BUTTON_ATCK ? 1 : 0) | (self.BUTTON_ATCK2 ? 2 : 0));
index 05aa9239d718f0514e8208aa149e4b666f24000e..94f1bd10cf5ba38bf4242ec4a0564e083377a0f1 100644 (file)
@@ -156,8 +156,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep)
                METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(rpc, reload_ammo) && actor.clip_load < WEP_CVAR(rpc, ammo)) {
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        } else
                        {
                                if (fire & 1)
index a806b2958a94de70d73cc9f7f82baaf1c1254763..99c1321c1aaa37062f84830272978a5efdaea0fc 100644 (file)
@@ -4,7 +4,7 @@ REGISTER_MUTATOR(pinata, cvar("g_pinata") && !cvar("g_instagib") && !cvar("g_ove
 MUTATOR_HOOKFUNCTION(pinata, PlayerDies)
 {SELFPARAM();
        for(int j = WEP_FIRST; j <= WEP_LAST; ++j)
-       if(self.weapons & WepSet_FromWeapon(j))
+       if(self.weapons & WepSet_FromWeapon(Weapons_from(j)))
        if(self.switchweapon != j)
        if(W_IsWeaponThrowable(j))
                W_ThrowNewWeapon(self, j, false, self.origin + (self.mins + self.maxs) * 0.5, randomvec() * 175 + '0 0 325');
index fd21947d6fdeffa2cfba866fc75bcde6930ba928..9db086a8bbc0b5acffc2e1a4ebaa0eb6ea5fa3e8 100644 (file)
@@ -221,7 +221,7 @@ void Ent_WaypointSprite()
 float spritelookupblinkvalue(string s)
 {SELFPARAM();
     if (s == WP_Weapon.netname) {
-        if (get_weaponinfo(self.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
+        if (Weapons_from(self.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
             return 2;
     }
     if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypointblink;
@@ -231,7 +231,7 @@ float spritelookupblinkvalue(string s)
 
 vector spritelookupcolor(entity this, string s, vector def)
 {
-    if (s == WP_Weapon.netname  || s == RADARICON_Weapon.netname) return get_weaponinfo(this.wp_extra).wpcolor;
+    if (s == WP_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 (MUTATOR_CALLHOOK(WP_Format, this, s))
     {
@@ -243,7 +243,7 @@ vector spritelookupcolor(entity this, string s, vector def)
 string spritelookuptext(string s)
 {SELFPARAM();
     if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
-    if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).m_name;
+    if (s == WP_Weapon.netname) return Weapons_from(self.wp_extra).m_name;
     if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypoint;
     if (s == WP_Monster.netname) return get_monsterinfo(self.wp_extra).monster_name;
     if (MUTATOR_CALLHOOK(WP_Format, this, s))
index 7584e3353c081c50fe7768682f81ec871d5e08d5..2d9398ad7ede56de2b00681aa9fa5fd65c62ad2a 100644 (file)
@@ -106,23 +106,16 @@ float PlayerStats_GameReport_Event(string prefix, string event_id, float value)
 
 void PlayerStats_GameReport_Accuracy(entity p)
 {
-       int i;
-
-       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-       {
-               entity w = get_weaponinfo(i);
-
-               #define ACCMAC(suffix,field) \
-                       PS_GR_P_ADDVAL(p, sprintf("acc-%s-%s", w.netname, suffix), p.accuracy.(field[i-1]));
-
+       #define ACCMAC(suffix, field) \
+               PS_GR_P_ADDVAL(p, sprintf("acc-%s-%s", it.netname, suffix), p.accuracy.(field[i-1]));
+       FOREACH(Weapons, it != WEP_Null, LAMBDA(
                ACCMAC("hit", accuracy_hit)
                ACCMAC("fired", accuracy_fired)
                ACCMAC("cnt-hit", accuracy_cnt_hit)
                ACCMAC("cnt-fired", accuracy_cnt_fired)
                ACCMAC("frags", accuracy_frags)
-
-               #undef ACCMAC
-       }
+       ));
+       #undef ACCMAC
 }
 
 void PlayerStats_GameReport_FinalizePlayer(entity p)
@@ -240,17 +233,13 @@ void PlayerStats_GameReport_Init() // initiated before InitGameplayMode so that
                PlayerStats_GameReport_AddEvent(PLAYERSTATS_RANK);
 
                // accuracy stats
-               entity w;
-               float i;
-               for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-               {
-                       w = get_weaponinfo(i);
-                       PlayerStats_GameReport_AddEvent(strcat("acc-", w.netname, "-hit"));
-                       PlayerStats_GameReport_AddEvent(strcat("acc-", w.netname, "-fired"));
-                       PlayerStats_GameReport_AddEvent(strcat("acc-", w.netname, "-cnt-hit"));
-                       PlayerStats_GameReport_AddEvent(strcat("acc-", w.netname, "-cnt-fired"));
-                       PlayerStats_GameReport_AddEvent(strcat("acc-", w.netname, "-frags"));
-               }
+               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                       PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-hit"));
+                       PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-fired"));
+                       PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-cnt-hit"));
+                       PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-cnt-fired"));
+                       PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-frags"));
+               ));
 
                PlayerStats_GameReport_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_3);
                PlayerStats_GameReport_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_5);
index a12e8556aafa8a83f37fcfb6a8b948184e39433e..fc3bd9167a27121b7376da6c33cb684be0dbac14 100644 (file)
@@ -101,10 +101,10 @@ string W_FixWeaponOrder(string order, float complete)
 }
 string W_NameWeaponOrder_MapFunc(string s)
 {
-       entity wi;
-       if (s == "0" || stof(s))
+       int i = stof(s);
+       if (s == "0" || i)
        {
-               wi = get_weaponinfo(stof(s));
+               entity wi = Weapons_from(i);
                if (wi != WEP_Null) return wi.netname;
        }
        return s;
@@ -129,11 +129,9 @@ string W_NameWeaponOrder(string order)
 }
 string W_NumberWeaponOrder_MapFunc(string s)
 {
-       int i;
        if (s == "0" || stof(s)) return s;
        s = W_UndeprecateName(s);
-       for (i = WEP_FIRST; i <= WEP_LAST; ++i)
-               if (s == get_weaponinfo(i).netname) return ftos(i);
+       FOREACH(Weapons, it != WEP_Null && it.netname == s, LAMBDA(return ftos(i)));
        return s;
 }
 string W_NumberWeaponOrder(string order)
@@ -152,17 +150,17 @@ void W_FixWeaponOrder_BuildImpulseList_swap(int i, int j, entity pass)
 }
 float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
 {
-       entity e1, e2;
-       float d;
-       e1 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[i]);
-       e2 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[j]);
-       d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10;
+       int si = W_FixWeaponOrder_BuildImpulseList_buf[i];
+       Weapon e1 = Weapons_from(si);
+       int sj = W_FixWeaponOrder_BuildImpulseList_buf[j];
+       Weapon e2 = Weapons_from(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, " "),
-               sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[i]), 0)
+               sprintf(" %d ", si), 0)
               -
               strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "),
-               sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[j]), 0)
+               sprintf(" %d ", sj), 0)
        ;  // low char index first!
 }
 string W_FixWeaponOrder_BuildImpulseList(string o)
@@ -202,9 +200,10 @@ void W_RandomWeapons(entity e, float n)
        {
                RandomSelection_Init();
                for (j = WEP_FIRST; j <= WEP_LAST; ++j)
-                       if (remaining & WepSet_FromWeapon(j)) RandomSelection_Add(world, j, string_null, 1, 1);
-               result |= WepSet_FromWeapon(RandomSelection_chosen_float);
-               remaining &= ~WepSet_FromWeapon(RandomSelection_chosen_float);
+                       if (remaining & WepSet_FromWeapon(Weapons_from(j))) RandomSelection_Add(NULL, j, string_null, 1, 1);
+               Weapon w = Weapons_from(RandomSelection_chosen_float);
+               result |= WepSet_FromWeapon(w);
+               remaining &= ~WepSet_FromWeapon(w);
        }
        e.weapons = result;
 }
index 47568b31a072fc94127d679fc6219aa910e1c88d..7e4d390ba698ef4be96ed7ff6c53c954f94a83ed 100644 (file)
@@ -32,13 +32,12 @@ WepSet ReadWepSet();
 
 REGISTRY(Weapons, 72) // Increase as needed. Can be up to 72.
 #define Weapons_from(i) _Weapons_from(i, WEP_Null)
-#define get_weaponinfo(i) Weapons_from(i)
 REGISTER_REGISTRY(Weapons)
 STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, LAMBDA(it.m_pickup = NEW(WeaponPickup, it))); }
 
 .WepSet m_wepset;
 #define WEPSET(id) (WEP_##id.m_wepset)
-#define WepSet_FromWeapon(i) (Weapons_from(i).m_wepset)
+#define WepSet_FromWeapon(it) ((it).m_wepset)
 WepSet _WepSet_FromWeapon(int i);
 STATIC_INIT(WepSets)
 {
@@ -169,7 +168,7 @@ STATIC_INIT(register_weapons_done)
     for (int i = Weapons_MAX - 1; i >= 1; --i)
         if (Weapons_from(i))
             weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
-    weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1));
+    weaponorder_byid = strzone(substring(weaponorder_byid, 1, -1));
 }
 
 #ifndef MENUQC
index 3ee4a684a26bff97bd44c17482e62ca6b5137a8c..ad90baa6fe3eb399445421a0a239c8d25ad4e52a 100644 (file)
@@ -24,17 +24,15 @@ float W_Config_Queue_Compare(int root, int child, entity pass)
 
 void Dump_Weapon_Settings()
 {
-       int i, x, totalsettings = 0;
-       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-       {
+       int totalweapons = 0, totalsettings = 0;
+       FOREACH(Weapons, it != WEP_Null, LAMBDA(
                // step 1: clear the queue
                WEP_CONFIG_COUNT = 0;
-               for(x = 0; x <= MAX_WEP_CONFIG; ++x)
+               for (int x = 0; x <= MAX_WEP_CONFIG; ++x)
                        { wep_config_queue[x] = string_null; }
 
                // step 2: build new queue
-               Weapon w = get_weaponinfo(i);
-               w.wr_config(w);
+               it.wr_config(it);
 
                // step 3: sort queue
                heapsort(WEP_CONFIG_COUNT, W_Config_Queue_Swap, W_Config_Queue_Compare, world);
@@ -43,22 +41,23 @@ void Dump_Weapon_Settings()
                WEP_CONFIG_WRITETOFILE(sprintf(
                        "// {{{ #%d: %s%s\n",
                        i,
-                       WEP_NAME(i),
-                       (((get_weaponinfo(i)).spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "")
+                       it.m_name,
+                       ((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "")
                ));
-               for(x = 0; x <= WEP_CONFIG_COUNT; ++x) { WEP_CONFIG_WRITETOFILE(wep_config_queue[x]); }
+               for (int x = 0; x <= WEP_CONFIG_COUNT; ++x) { WEP_CONFIG_WRITETOFILE(wep_config_queue[x]); }
                WEP_CONFIG_WRITETOFILE("// }}}\n");
 
                // step 5: debug info
-               LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, WEP_NAME(i), WEP_CONFIG_COUNT));
+               LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, it.m_name, WEP_CONFIG_COUNT));
+               totalweapons += 1;
                totalsettings += WEP_CONFIG_COUNT;
-       }
+       ));
 
        // clear queue now that we're finished
        WEP_CONFIG_COUNT = 0;
-       for(x = 0; x <= MAX_WEP_CONFIG; ++x)
+       for(int x = 0; x <= MAX_WEP_CONFIG; ++x)
                { wep_config_queue[x] = string_null; }
 
        // extra information
-       LOG_INFO(sprintf("Totals: %d weapons, %d settings\n", (i - 1), totalsettings));
+       LOG_INFO(sprintf("Totals: %d weapons, %d settings\n", totalweapons, totalsettings));
 }
index 3f09e914a6e23db8741b12d9f150977a07302a10..bc98da4330f81278254b76c9296d1a4b12f24552 100644 (file)
@@ -218,6 +218,6 @@ string W_Model(string w_mdl);
 
 // other useful macros
 #define WEP_AMMO(wpn) (WEP_##wpn.ammo_field) // only used inside weapon files/with direct name, don't duplicate prefix
-#define WEP_NAME(wpn) ((get_weaponinfo(wpn)).m_name)
+#define WEP_NAME(wpn) ((Weapons_from(wpn)).m_name)
 
 #endif
index 209bd2dd0e62f43754cd88272dc27f151df13a72..300622289b8af9656fcab2214a3c61239140c946 100644 (file)
@@ -575,8 +575,7 @@ void W_Crylink_Attack2(Weapon thiswep)
                METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_crylink_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        }
 
                        if(fire & 1)
index d6ffd50d68b5acd281a97aa91cd24f7419eb09dd..6a841c9eb4186eac9cd17a2b64afb7a67a0d0a87 100644 (file)
@@ -526,8 +526,7 @@ void W_Devastator_Attack(Weapon thiswep)
                METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(devastator, reload_ammo) && actor.clip_load < WEP_CVAR(devastator, ammo)) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        } else {
                                if(fire & 1)
                                {
index 0f48bb2591688df274c36ccea961186d9d94140a..30dd6d74a3813394a268c59532577ed099d5fd65 100644 (file)
@@ -461,8 +461,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, i
 
                                if(!ammo_amount)
                                {
-                                       Weapon w = get_weaponinfo(actor.weapon);
-                                       w.wr_reload(w);
+                                       thiswep.wr_reload(thiswep);
                                        return;
                                }
                        }
index 859b54c959416077166498d37e5f097e3d59b773..a5066017a974855caeeb9b7994c79b40ca572e61 100644 (file)
@@ -386,8 +386,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, .entity weaponentity)
                self.hagar_warning = false;
 
                // we aren't checking ammo during an attack, so we must do it here
-               Weapon w = get_weaponinfo(self.weapon);
-               if(!(w.wr_checkammo1(w) + w.wr_checkammo2(w)))
+               if(!(thiswep.wr_checkammo1(thiswep) + thiswep.wr_checkammo2(thiswep)))
                if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        // note: this doesn't force the switch
@@ -412,8 +411,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, .entity weaponentity)
                        if(loadable_secondary)
                                W_Hagar_Attack2_Load(thiswep, weaponentity); // must always run each frame
                        if(autocvar_g_balance_hagar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        } else if((fire & 1) && !actor.hagar_load && !actor.hagar_loadblock) // not while secondary is loaded or awaiting reset
                        {
                                if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hagar, refire)))
index 252cc96e34988c5c1698f864d4eb2a0a197e98f8..f99c700735d358e79d089f11c1b0f2c8fc66cdc2 100644 (file)
@@ -169,8 +169,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int
 
        if(actor.BUTTON_ATCK)
        {
-               Weapon w = get_weaponinfo(actor.weapon);
-               if(!w.wr_checkammo1(w))
+               if(!thiswep.wr_checkammo1(thiswep))
                if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -213,8 +212,7 @@ void W_HLAC_Attack2_Frame(Weapon thiswep)
                METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_hlac_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        } else if(fire & 1)
                        {
                                if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hlac, refire)))
index 553381818394bf4df9b27d9539a13c7b3830efc4..7e79bc929f4c4538d0d7e9c8f89c93ef8e4f01ef 100644 (file)
@@ -146,8 +146,7 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentit
        }
        if(actor.BUTTON_ATCK)
        {
-               Weapon w = get_weaponinfo(actor.weapon);
-               if(!w.wr_checkammo2(w))
+               if(!thiswep.wr_checkammo2(thiswep))
                if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -173,8 +172,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity
                return;
        }
 
-       Weapon w = get_weaponinfo(actor.weapon);
-       if(!w.wr_checkammo1(w))
+       if(!thiswep.wr_checkammo1(thiswep))
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -252,8 +250,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
                METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(machinegun, reload_ammo) && actor.clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        } else
                        if(WEP_CVAR(machinegun, mode) == 1)
                        {
@@ -267,8 +264,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
                                if(fire & 2)
                                if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
                                {
-                                       Weapon w = get_weaponinfo(actor.weapon);
-                                       if(!w.wr_checkammo2(w))
+                                       if(!thiswep.wr_checkammo2(thiswep))
                                        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                                        {
                                                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
index 1365e61b992c62646e6d47489be593580a1e563c..2f1459f83d4735ba6e9a75934a7b0ebfb932e71f 100644 (file)
@@ -506,8 +506,7 @@ float W_MineLayer_PlacedMines(float detonate)
                        {
                                // not if we're holding the minelayer without enough ammo, but can detonate existing mines
                                if(!(W_MineLayer_PlacedMines(false) && actor.WEP_AMMO(MINE_LAYER) < WEP_CVAR(minelayer, ammo))) {
-                                       Weapon w = get_weaponinfo(actor.weapon);
-                                       w.wr_reload(w);
+                                       thiswep.wr_reload(thiswep);
                                }
                        }
                        else if(fire & 1)
index 36a3c0c9e66f9c5ee515ad17d057cf8bff2dc4d6..223d13ffb2dbb6a1452f672659c850d78e88e39d 100644 (file)
@@ -335,8 +335,7 @@ void W_Mortar_Attack2(Weapon thiswep)
                METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_mortar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo))) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        } else if(fire & 1)
                        {
                                if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(mortar, refire)))
index be9788fcc7414649398387b3be54be5685c4a990..a639747db7f2c9493bec6be49ab50e7136d88bad 100644 (file)
@@ -161,8 +161,7 @@ void W_Rifle_BulletHail(.entity weaponentity, float mode, void() AttackFunc, WFR
                METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_rifle_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo))) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        } else
                        {
                                actor.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), actor.rifle_accumulator, time);
@@ -179,8 +178,7 @@ void W_Rifle_BulletHail(.entity weaponentity, float mode, void() AttackFunc, WFR
                                        if(WEP_CVAR(rifle, secondary))
                                        {
                                                if(WEP_CVAR_SEC(rifle, reload)) {
-                                                       Weapon w = get_weaponinfo(actor.weapon);
-                                                       w.wr_reload(w);
+                                                       thiswep.wr_reload(thiswep);
                                                } else
                                                {
                                                        if(weapon_prepareattack_check(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(rifle, refire)))
index 533b7c944acfaa58fbe7ec437a75ecdb65280bcb..01c7feb887848f1ce0c157e2f19fd33c048323d0 100644 (file)
@@ -607,8 +607,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
                METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_seeker_reload_ammo && actor.clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        } else if(fire & 1)
                        {
                                if(WEP_CVAR(seeker, type) == 1)
index 3ac26958ad00d82e946a76218d4367a32a207b25..c50eff100e81f04bb69551bc54d1eae0c6bc3af6 100644 (file)
@@ -197,8 +197,7 @@ void W_Shotgun_Attack2(Weapon thiswep, entity actor, .entity weaponentity, int f
 // alternate secondary weapon frames
 void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
-       Weapon w = get_weaponinfo(actor.weapon);
-       if (!w.wr_checkammo2(w))
+       if (!thiswep.wr_checkammo2(thiswep))
        if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -212,8 +211,7 @@ void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity
 }
 void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
-       Weapon w = get_weaponinfo(actor.weapon);
-       if (!w.wr_checkammo2(w))
+       if (!thiswep.wr_checkammo2(thiswep))
        if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -240,8 +238,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity
                        {
                                // don't force reload an empty shotgun if its melee attack is active
                                if(WEP_CVAR(shotgun, secondary) < 2) {
-                                       Weapon w = get_weaponinfo(actor.weapon);
-                                       w.wr_reload(w);
+                                       thiswep.wr_reload(thiswep);
                                }
                        }
                        else
index a3c4c1f97db9db76f1710982eeb4e204ac4dee0a..7ab692f24dcd8779ca711bdb88f23367aab168da 100644 (file)
@@ -347,11 +347,9 @@ void W_RocketMinsta_Attack3 ()
                        float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
                        // if the laser uses load, we also consider its ammo for reloading
                        if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && actor.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        } else if(WEP_CVAR(vaporizer, reload_ammo) && actor.clip_load < vaporizer_ammo) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        }
                        if((fire & 1) && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor))
                        {
index a3caf7aabce3550602f084d95698efca28b5c574..ded0eede4617043675147fb80c52c1aca7ea1a3b 100644 (file)
@@ -230,8 +230,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
                                }
 
                        if(autocvar_g_balance_vortex_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo))) { // forced reload
-                               Weapon w = get_weaponinfo(actor.weapon);
-                               w.wr_reload(w);
+                               thiswep.wr_reload(thiswep);
                        } else
                        {
                                if(fire & 1)
diff --git a/qcsrc/dpdefs/doc.md b/qcsrc/dpdefs/doc.md
new file mode 100644 (file)
index 0000000..4ee5532
--- /dev/null
@@ -0,0 +1,224 @@
+# CSQC
+
+```
+
+// input:
+//   self
+.void() predraw;
+
+// input:
+//   time
+//   self
+.void() think;
+
+// 0 = keydown, key, character (EXT_CSQC)
+// 1 = keyup, key, character (EXT_CSQC)
+// 2 = mousemove relative, x, y (EXT_CSQC)
+// 3 = mousemove absolute, x, y (DP_CSQC)
+bool CSQC_InputEvent(int eventtype, int x, int y);
+
+void CSQC_UpdateView(int width, int height);
+bool CSQC_ConsoleCommand(string cmd);
+bool CSQC_Parse_TempEntity();
+bool CSQC_Parse_StuffCmd(string msg);
+bool CSQC_Parse_Print(string msg);
+bool CSQC_Parse_CenterPrint(string msg);
+bool CSQC_Event_Sound(int ent, int channel, string sample, float volume, float attenuation, vector pos, float speed, int flags);
+
+entity CSQC_Ent_Spawn(int entnum);
+void CSQC_Ent_Update(bool isnew);
+void CSQC_Ent_Remove();
+
+void CSQC_Init();
+void CSQC_Shutdown();
+
+// input:
+//   time
+//   self
+//   v_forward: forward
+//   v_right: right
+//   v_up: up
+// output:
+//   origin
+//   v_forward: forward
+//   v_right: right
+//   v_up: up
+//   trace_endpos: visorigin 
+.vector camera_transform(vector pos, vector ang);
+
+```
+
+# SVQC
+
+```
+
+.entity clientcamera;
+
+// input:
+//   time
+//   self
+void ClientDisconnect();
+
+// input:
+//   time
+void SV_Shutdown();
+
+// input:
+//   time
+void SV_PausedTic(float elapsed);
+
+// input:
+//   time
+//   self
+void SV_ChangeTeam(int color);
+
+// input:
+//   time
+//   self
+void ClientKill();
+
+// input:
+//   time
+//   self
+void RestoreGame();
+
+// input:
+//   time
+//   self
+//   parm1..n
+void ClientConnect();
+
+// input:
+//   time
+//   self
+//   parm1..n
+void PutClientInServer();
+
+// return false to remove
+.bool SendEntity(entity to, int sf);
+
+// input:
+//   time
+//   self
+void SV_OnEntityPreSpawnFunction();
+
+// input:
+//   time
+//   self
+void SV_OnEntityNoSpawnFunction();
+
+// input:
+//   time
+//   self
+void SV_OnEntityPostSpawnFunction();
+
+// input:
+//   time
+// output:
+//   parm1..n
+void SetNewParms();
+
+// input:
+//   
+.bool customizeentityforclient();
+
+// input:
+//   time
+//   self
+// output:
+//   parm1..n
+void SetChangeParms();
+
+// input:
+//   time
+//   self
+//   other
+//   trace_allsolid
+//   trace_startsolid
+//   trace_fraction
+//   trace_inwater
+//   trace_inopen
+//   trace_endpos: self.origin
+//   trace_plane_normal
+//   trace_plane_dist
+//   trace_ent: other
+//   trace_dpstartcontents
+//   trace_dphitcontents
+//   trace_dphitq3surfaceflags
+//   trace_dphittexturename
+.void touch();
+
+// when .watertype changes:
+.void contentstransition(int prev, int current);
+
+// input:
+//   time
+//   self
+//   other
+.void blocked();
+
+// input:
+//   time
+//   self
+.void movetypesteplandevent(vector vel);
+
+// input:
+//   time
+//   self
+void PlayerPreThink();
+
+// input:
+//   time
+//   self
+void PlayerPostThink();
+
+// input:
+//   time
+//   frametime
+void StartFrame();
+
+// input:
+//   time
+void EndFrame();
+
+// input:
+//   time
+//   self
+void SV_PlayerPhysics();
+
+// input:
+//   time
+//   self
+void SV_ParseClientCommand(string cmd);
+
+```
+
+# MENUQC
+
+```
+
+void m_keydown(int key, int ascii);
+
+void m_keyup(int key, int ascii);
+
+void m_draw(int width, int height);
+
+void m_toggle(int mode);
+
+int m_gethostcachecategory(int entry);
+
+void m_shutdown();
+
+void m_init();
+
+```
+
+# All
+
+```
+
+void URI_Get_Callback(int id, int status, string data);
+
+void GameCommand(string cmd);
+
+```
index 2f3cd47b02e592696c1daf4e6974b83220b19b62..8b9ddf9b252860304e03ad6fb96c5dc2131547d0 100644 (file)
@@ -52,7 +52,7 @@ string WeaponArenaString()
        {
                for(j = WEP_FIRST; j <= WEP_LAST; ++j)
                {
-                       e = get_weaponinfo(j);
+                       e = Weapons_from(j);
                        if(argv(i) == e.netname)
                                s = strcat(s, " & ", e.m_name);
                }
@@ -253,7 +253,7 @@ void XonoticMutatorsDialog_fill(entity me)
                        e.cvarOffValue = "0";
        for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
        {
-               w = get_weaponinfo(i);
+               w = Weapons_from(i);
                if(w.spawnflags & WEP_FLAG_HIDDEN)
                        continue;
                if((j & 1) == 0)
index a64c77b0fff568b4776fe9d4d9ed725ff7e02ccc..112a346828ebf098deb74f4985e855414cd79583 100644 (file)
@@ -78,26 +78,21 @@ void Xonotic_KeyBinds_Read()
 
        int i;
 
-       #define ADD_TO_W_LIST(pred) do { \
-               for(i = WEP_FIRST; i <= WEP_LAST; ++i) \
-               { \
-                       wep = get_weaponinfo(i); \
-                       if(wep.impulse == imp && (pred)) \
-                               w_list = strcat(w_list, WEP_NAME(i), " / "); \
-               } \
-       } while(0)
-
-       int imp;
-       entity wep;
-       string w_list = "";
-       for(imp = 1; imp <= 9; ++imp)
+       #define ADD_TO_W_LIST(pred) \
+               FOREACH(Weapons, it != WEP_Null, LAMBDA( \
+                       if (it.impulse != imp) continue; \
+                       if (!(pred)) continue; \
+                       w_list = strcat(w_list, it.m_name, " / "); \
+               ))
+
+       for(int imp = 1; imp <= 9; ++imp)
        {
-               ADD_TO_W_LIST(!(wep.flags & WEP_FLAG_MUTATORBLOCKED) && !(wep.flags & WEP_FLAG_SUPERWEAPON));
-               ADD_TO_W_LIST(wep.flags & WEP_FLAG_SUPERWEAPON);
-               ADD_TO_W_LIST(wep.flags & WEP_FLAG_MUTATORBLOCKED);
+        string w_list = "";
+               ADD_TO_W_LIST(!(it.flags & WEP_FLAG_MUTATORBLOCKED) && !(it.flags & WEP_FLAG_SUPERWEAPON));
+               ADD_TO_W_LIST(it.flags & WEP_FLAG_SUPERWEAPON);
+               ADD_TO_W_LIST(it.flags & WEP_FLAG_MUTATORBLOCKED);
                if(w_list)
                        KEYBIND_DEF(strcat("weapon_group_", itos(imp)), substring(w_list, 0, -4));
-               w_list = "";
                if(imp == 0)
                        break;
                if(imp == 9)
index c1189dd9ba5c702214c50c0ecea30e4613f713b7..8a3fbd670e669d42640e1864a917f481f4f5ac7f 100644 (file)
@@ -87,7 +87,7 @@ string XonoticWeaponsList_toString(entity me)
        s = "";
        for(i = 0; i < n; ++i)
        {
-               e = get_weaponinfo(stof(argv(i)));
+               e = Weapons_from(stof(argv(i)));
                s = strcat(s, e.m_name, ", ");
        }
        return substring(s, 0, strlen(s) - 2);
@@ -102,7 +102,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 = get_weaponinfo(stof(argv(i)));
+       e = Weapons_from(stof(argv(i)));
        string msg = e.m_name;
        if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
                msg = strcat(msg, "*");
index dd0109ce2fba337275eec28b6eebf69ce9a2a74d..9a74d38415aa6b545fcb646b8f1ed25da238be0b 100644 (file)
@@ -104,7 +104,7 @@ void havocbot_ai()
 
                if(self.weapons)
                {
-                       Weapon w = get_weaponinfo(self.weapon);
+                       Weapon w = Weapons_from(self.weapon);
                        w.wr_aim(w);
                        if (autocvar_bot_nofire || IS_INDEPENDENT_PLAYER(self))
                        {
@@ -173,7 +173,7 @@ void havocbot_ai()
                {
                        for (int i = WEP_FIRST; i <= WEP_LAST; ++i)
                        {
-                               entity e = get_weaponinfo(i);
+                               entity e = Weapons_from(i);
                                if ((self.weapons & (e.m_wepset)) && (e.spawnflags & WEP_FLAG_RELOADABLE) && (self.weapon_load[i] < e.reloading_ammo))
                                        self.switchweapon = i;
                        }
@@ -995,7 +995,7 @@ float havocbot_chooseweapon_checkreload(int new_weapon)
                float i, other_weapon_available = false;
                for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                {
-                       Weapon w = get_weaponinfo(i);
+                       Weapon w = Weapons_from(i);
                        // if we are out of ammo for all other weapons, it's an emergency to switch to anything else
                        if (w.wr_checkammo1(w) + w.wr_checkammo2(w))
                                other_weapon_available = true;
index ab5ad3b527be7dcd27d2c162e9ce7ec11803fa26..05cd17d0d99a9dc9b8d8e564c62e66fc7fe6ef71 100644 (file)
@@ -139,7 +139,7 @@ void ImpulseCommands ()
                                        break;
                                case 20:
                                        if(!forbidWeaponUse(self)) {
-                                               Weapon w = get_weaponinfo(self.weapon);
+                                               Weapon w = Weapons_from(self.weapon);
                                                w.wr_reload(w);
                                        }
                                        break;
index 1b0e46038acf1c0696c124dd6afca95569c49b4a..d7ce1f66aedd85785d6f95b62416b4456e37f66f 100644 (file)
@@ -482,7 +482,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, int deathtyp
        if(DIFF_TEAM(self, attacker))
        {
                if(DEATH_ISSPECIAL(deathtype))
-                       awep = get_weaponinfo(attacker.weapon);
+                       awep = Weapons_from(attacker.weapon);
                else
                        awep = DEATH_WEAPONOF(deathtype);
                valid_damage_for_weaponstats = 1;
@@ -548,7 +548,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, int deathtyp
                MUTATOR_CALLHOOK(PlayerDies, inflictor, attacker, self, deathtype);
                excess = frag_damage;
 
-               Weapon wep = get_weaponinfo(self.weapon);
+               Weapon wep = Weapons_from(self.weapon);
                wep.wr_playerdeath(wep);
 
                RemoveGrapplingHook(self);
@@ -631,7 +631,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, int deathtyp
                // reset fields the weapons may use just in case
                for (j = WEP_FIRST; j <= WEP_LAST; ++j)
                {
-                       Weapon w = get_weaponinfo(j);
+                       Weapon w = Weapons_from(j);
                        w.wr_resetplayer(w);
                        for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                        {
index dcd75023e6a9c393be0be286b7b2ed1d00f5eb0f..dfabd9d3dc9758b24fbbe9b0a843c581685bfe4c 100644 (file)
@@ -61,8 +61,8 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype)
        {
                // after a frag, exchange the current weapon (or the culprit, if detectable) by a new random weapon
                Weapon culprit = DEATH_WEAPONOF(deathtype);
-               if(!culprit) culprit = get_weaponinfo(attacker.weapon);
-               else if(!(attacker.weapons & (culprit.m_wepset))) culprit = get_weaponinfo(attacker.weapon);
+               if(!culprit) culprit = Weapons_from(attacker.weapon);
+               else if(!(attacker.weapons & (culprit.m_wepset))) culprit = Weapons_from(attacker.weapon);
 
                if(g_weaponarena_random_with_blaster && culprit == WEP_BLASTER) // WEAPONTODO: Shouldn't this be in a mutator?
                {
@@ -95,7 +95,7 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype)
                }
 
                // after a frag, choose another random weapon set
-               if (!(attacker.weapons & WepSet_FromWeapon(attacker.weapon)))
+               if (!(attacker.weapons & WepSet_FromWeapon(Weapons_from(attacker.weapon))))
                        W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker));
        }
 
index ddf10818fe520e05b9aade437b41170e3d171781..e7eed32b43c5931998ca8425ab7a784f542b350c 100644 (file)
@@ -526,7 +526,7 @@ void readplayerstartcvars()
                g_weaponarena_list = "All Weapons";
                for (j = WEP_FIRST; j <= WEP_LAST; ++j)
                {
-                       e = get_weaponinfo(j);
+                       e = Weapons_from(j);
                        if (!(e.spawnflags & WEP_FLAG_MUTATORBLOCKED))
                                g_weaponarena_weapons |= (e.m_wepset);
                }
@@ -537,7 +537,7 @@ void readplayerstartcvars()
                g_weaponarena_list = "Most Weapons";
                for (j = WEP_FIRST; j <= WEP_LAST; ++j)
                {
-                       e = get_weaponinfo(j);
+                       e = Weapons_from(j);
                        if (!(e.spawnflags & WEP_FLAG_MUTATORBLOCKED))
                                if (e.spawnflags & WEP_FLAG_NORMAL)
                                        g_weaponarena_weapons |= (e.m_wepset);
@@ -558,7 +558,7 @@ void readplayerstartcvars()
                        s = argv(i);
                        for (j = WEP_FIRST; j <= WEP_LAST; ++j)
                        {
-                               e = get_weaponinfo(j);
+                               e = Weapons_from(j);
                                if (e.netname == s)
                                {
                                        g_weaponarena_weapons |= (e.m_wepset);
@@ -590,7 +590,7 @@ void readplayerstartcvars()
        {
                for (i = WEP_FIRST; i <= WEP_LAST; ++i)
                {
-                       e = get_weaponinfo(i);
+                       e = Weapons_from(i);
                        int w = want_weapon(e, false);
                        WepSet s = e.m_wepset;
                        if(w & 1)
@@ -653,7 +653,7 @@ void readplayerstartcvars()
                        warmup_start_weapons_defaultmask = '0 0 0';
                        for (i = WEP_FIRST; i <= WEP_LAST; ++i)
                        {
-                               e = get_weaponinfo(i);
+                               e = Weapons_from(i);
                                int w = want_weapon(e, g_warmup_allguns);
                                WepSet s = (e.m_wepset);
                                if(w & 1)
@@ -683,7 +683,7 @@ void readplayerstartcvars()
                precache_weapons |= warmup_start_weapons;
        for (i = WEP_FIRST; i <= WEP_LAST; ++i)
        {
-               e = get_weaponinfo(i);
+               e = Weapons_from(i);
                if(precache_weapons & (e.m_wepset)) {
                        e.wr_init(e);
                }
index 0976e60e581c4751a8701bf293529ca57faad2ec..8198338674923266b1e25261dedf21808e3428fb 100644 (file)
@@ -340,7 +340,7 @@ void readlevelcvars()
                game_starttime = time + cvar("g_start_delay");
 
        for(int i = WEP_FIRST; i <= WEP_LAST; ++i) {
-               Weapon w = get_weaponinfo(i);
+               Weapon w = Weapons_from(i);
                w.wr_init(w);
        }
 
index 3fb6998e9ce43fd3d1640e2376bf93410591a976..97f63fc298db513777a5c84201a3e0738ede88b6 100644 (file)
@@ -491,7 +491,7 @@ void Item_RespawnCountdown ()
                        MUTATOR_CALLHOOK(Item_RespawnCountdown, string_null, '0 0 0');
                        do {
                                {
-                                       entity wi = get_weaponinfo(self.weapon);
+                                       entity wi = Weapons_from(self.weapon);
                                        if (wi.m_id) {
                                                entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Weapon);
                                                wp.wp_extra = wi.m_id;
@@ -645,7 +645,7 @@ float Item_GiveTo(entity item, entity player)
        if (player.switchweapon == w_getbestweapon(player))
                _switchweapon = true;
 
-       if (!(player.weapons & WepSet_FromWeapon(player.switchweapon)))
+       if (!(player.weapons & WepSet_FromWeapon(Weapons_from(player.switchweapon))))
                _switchweapon = true;
 
        pickedup |= Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
@@ -667,7 +667,7 @@ float Item_GiveTo(entity item, entity player)
                {
                        pickedup = true;
                        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-                       if(it & WepSet_FromWeapon(i))
+                       if(it & WepSet_FromWeapon(Weapons_from(i)))
                        {
                                W_DropEvent(wr_pickup, player, i, item);
                                W_GiveWeapon(player, i);
@@ -929,7 +929,7 @@ float commodity_pickupevalfunc(entity player, entity item)
        // Detect needed ammo
        for(i = WEP_FIRST; i <= WEP_LAST ; ++i)
        {
-               wi = get_weaponinfo(i);
+               wi = Weapons_from(i);
 
                if (!(player.weapons & (wi.m_wepset)))
                        continue;
@@ -1023,7 +1023,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
        }
 
        if(weaponid)
-               this.weapons = WepSet_FromWeapon(weaponid);
+               this.weapons = WepSet_FromWeapon(Weapons_from(weaponid));
 
        this.flags = FL_ITEM | itemflags;
 
@@ -1126,7 +1126,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
                        this.is_item = true;
                }
 
-               weaponsInMap |= WepSet_FromWeapon(weaponid);
+               weaponsInMap |= WepSet_FromWeapon(Weapons_from(weaponid));
 
                precache_model(this.model);
                precache_sound(this.item_pickupsound);
@@ -1442,13 +1442,13 @@ spawnfunc(target_items)
                        {
                                for(j = WEP_FIRST; j <= WEP_LAST; ++j)
                                {
-                                       e = get_weaponinfo(j);
+                                       e = Weapons_from(j);
                                        s = W_UndeprecateName(argv(i));
                                        if(s == e.netname)
                                        {
                                                self.weapons |= (e.m_wepset);
                                                if(self.spawnflags == 0 || self.spawnflags == 2) {
-                                                       Weapon w = get_weaponinfo(e.weapon);
+                                                       Weapon w = Weapons_from(e.weapon);
                                                        w.wr_init(w);
                                                }
                                                break;
@@ -1504,7 +1504,7 @@ spawnfunc(target_items)
                if(self.armorvalue != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "armor");
                for(j = WEP_FIRST; j <= WEP_LAST; ++j)
                {
-                       e = get_weaponinfo(j);
+                       e = Weapons_from(j);
                        if(e.weapon)
                                self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (e.m_wepset)), e.netname);
                }
@@ -1517,10 +1517,10 @@ spawnfunc(target_items)
        {
                for(j = WEP_FIRST; j <= WEP_LAST; ++j)
                {
-                       e = get_weaponinfo(j);
+                       e = Weapons_from(j);
                        if(argv(i) == e.netname)
                        {
-                               Weapon w = get_weaponinfo(e.weapon);
+                               Weapon w = Weapons_from(e.weapon);
                                w.wr_init(w);
                                break;
                        }
@@ -1562,7 +1562,7 @@ spawnfunc(item_jetpack)
 float GiveWeapon(entity e, float wpn, float op, float val)
 {
        WepSet v0, v1;
-       WepSet s = WepSet_FromWeapon(wpn);
+       WepSet s = WepSet_FromWeapon(Weapons_from(wpn));
        v0 = (e.weapons & s);
        switch(op)
        {
@@ -1688,7 +1688,7 @@ float GiveItems(entity e, float beginarg, float endarg)
                        case "allweapons":
                                for(j = WEP_FIRST; j <= WEP_LAST; ++j)
                                {
-                                       wi = get_weaponinfo(j);
+                                       wi = Weapons_from(j);
                                        if(wi.weapon)
                                                if (!(wi.spawnflags & WEP_FLAG_MUTATORBLOCKED))
                                                        got += GiveWeapon(e, j, op, val);
@@ -1753,7 +1753,7 @@ float GiveItems(entity e, float beginarg, float endarg)
                        default:
                                for(j = WEP_FIRST; j <= WEP_LAST; ++j)
                                {
-                                       wi = get_weaponinfo(j);
+                                       wi = Weapons_from(j);
                                        if(cmd == wi.netname)
                                        {
                                                got += GiveWeapon(e, j, op, val);
@@ -1774,13 +1774,13 @@ float GiveItems(entity e, float beginarg, float endarg)
        POSTGIVE_BIT(e, items, ITEM_Jetpack.m_itemid, SND(ITEMPICKUP), string_null);
        for(j = WEP_FIRST; j <= WEP_LAST; ++j)
        {
-               wi = get_weaponinfo(j);
+               wi = Weapons_from(j);
                if(wi.weapon)
                {
-                       POSTGIVE_WEAPON(e, j, SND(WEAPONPICKUP), string_null);
+                       POSTGIVE_WEAPON(e, Weapons_from(j), SND(WEAPONPICKUP), string_null);
                        if (!(save_weapons & (wi.m_wepset)))
                                if(e.weapons & (wi.m_wepset)) {
-                                       Weapon w = get_weaponinfo(wi.weapon);
+                                       Weapon w = Weapons_from(wi.weapon);
                                        w.wr_init(w);
                                }
                }
@@ -1813,7 +1813,7 @@ float GiveItems(entity e, float beginarg, float endarg)
        else
                e.superweapons_finished += time;
 
-       if (!(e.weapons & WepSet_FromWeapon(e.switchweapon)))
+       if (!(e.weapons & WepSet_FromWeapon(Weapons_from(e.switchweapon))))
                _switchweapon = true;
        if(_switchweapon)
                W_SwitchWeapon_Force(e, w_getbestweapon(e));
index ef3d185c03e64f63ba6ab6474b66cb054bbc3789..b100259ef541987941cda6d4a1bdf4508097940b 100644 (file)
@@ -14,7 +14,7 @@ void W_GiveWeapon (entity e, float wep)
        if (!wep)
                return;
 
-       e.weapons |= WepSet_FromWeapon(wep);
+       e.weapons |= WepSet_FromWeapon(Weapons_from(wep));
 
        setself(e);
 
index 8efa15b3243ad38faaa14956dda8c9af0ecc64d4..b301da6f2e46ff7eb44cf0929fbce458b0537deb 100644 (file)
@@ -26,7 +26,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
 
        // ignore hook button when using other offhand equipment
        if (cl.offhand != OFFHAND_HOOK)
-       if (wpn == WEP_HOOK.m_id && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn)))
+       if (wpn == WEP_HOOK.m_id && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(Weapons_from(wpn))))
            complain = 0;
 
        if(complain)
@@ -38,7 +38,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        sprint(self, "Invalid weapon\n");
                return false;
        }
-       if (cl.weapons & WepSet_FromWeapon(wpn))
+       if (cl.weapons & WepSet_FromWeapon(Weapons_from(wpn)))
        {
                if (andammo)
                {
@@ -49,7 +49,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        else
                        {
                                setself(cl);
-                               Weapon w = get_weaponinfo(wpn);
+                               Weapon w = Weapons_from(wpn);
                                f = w.wr_checkammo1(w) + w.wr_checkammo2(w);
 
                                // always allow selecting the Mine Layer if we placed mines, so that we can detonate them
@@ -77,7 +77,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
        {
                // DRESK - 3/16/07
                // Report Proper Weapon Status / Modified Weapon Ownership Message
-               if (weaponsInMap & WepSet_FromWeapon(wpn))
+               if (weaponsInMap & WepSet_FromWeapon(Weapons_from(wpn)))
                {
                        Send_WeaponComplain(cl, wpn, 1);
 
@@ -139,7 +139,7 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
        while(rest != "")
        {
                weaponwant = stof(car(rest)); rest = cdr(rest);
-               wep = get_weaponinfo(weaponwant);
+               wep = Weapons_from(weaponwant);
                wepset = wep.m_wepset;
                if(imp >= 0)
                if(wep.impulse != imp)
@@ -148,7 +148,7 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                float i, have_other = false;
                for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                {
-                       Weapon e = get_weaponinfo(i);
+                       Weapon e = Weapons_from(i);
                        if(i != weaponwant)
                        if(e.impulse == imp || imp < 0)
                        if((pl.weapons & (e.m_wepset)) || (weaponsInMap & (e.m_wepset)))
@@ -197,7 +197,7 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                while(rest != "")
                {
                        weaponwant = stof(car(rest)); rest = cdr(rest);
-                       wep = get_weaponinfo(weaponwant);
+                       wep = Weapons_from(weaponwant);
                        wepset = wep.m_wepset;
                        if(imp >= 0)
                                if(wep.impulse != imp)
@@ -206,7 +206,7 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                        float i, have_other = false;
                        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                        {
-                               Weapon w = get_weaponinfo(i);
+                               Weapon w = Weapons_from(i);
                                if(i != weaponwant)
                                if(w.impulse == imp || imp < 0)
                                if((pl.weapons & (w.m_wepset)) || (weaponsInMap & (w.m_wepset)))
@@ -242,7 +242,7 @@ void W_SwitchToOtherWeapon(entity pl)
 {
        // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway)
        int ww;
-       WepSet set = WepSet_FromWeapon(pl.weapon);
+       WepSet set = WepSet_FromWeapon(Weapons_from(pl.weapon));
        if(pl.weapons & set)
        {
                pl.weapons &= ~set;
@@ -265,7 +265,7 @@ void W_SwitchWeapon(float imp)
                        self.selectweapon = imp; // update selectweapon ANYWAY
        }
        else if(!forbidWeaponUse(self)) {
-               Weapon w = get_weaponinfo(self.weapon);
+               Weapon w = Weapons_from(self.weapon);
                w.wr_reload(w);
        }
 }
index 923c2aa4ad30867be0671acca2ac51180454fb02..c362913d45aa3cc8f2039640b39d62c791204ba0 100644 (file)
@@ -18,7 +18,7 @@ string W_Apply_Weaponreplace(string in)
 
                for(j = WEP_FIRST; j <= WEP_LAST; ++j)
                {
-                       e = get_weaponinfo(j);
+                       e = Weapons_from(j);
                        if(e.netname == s)
                        {
                                replacement = e.weaponreplace;
@@ -64,7 +64,7 @@ void weapon_defaultspawnfunc(entity this, Weapon e)
                                int j;
                                for (j = WEP_FIRST; j <= WEP_LAST; ++j)
                                {
-                                       e = get_weaponinfo(j);
+                                       e = Weapons_from(j);
                                        if (e.netname == s)
                                        {
                                                entity replacement = spawn();
@@ -87,7 +87,7 @@ void weapon_defaultspawnfunc(entity this, Weapon e)
                        int j;
                        for (j = WEP_FIRST; j <= WEP_LAST; ++j)
                        {
-                               e = get_weaponinfo(j);
+                               e = Weapons_from(j);
                                if (e.netname == s)
                                {
                                        wpn = j;
@@ -107,7 +107,7 @@ void weapon_defaultspawnfunc(entity this, Weapon e)
                }
        }
 
-       e = get_weaponinfo(wpn);
+       e = Weapons_from(wpn);
 
        if (!this.respawntime)
        {
index 6f4546e01c4a26100076628aff9826da5461f0cd..652ec92005aba884ea26c3955b42644fb33a6726 100644 (file)
@@ -34,7 +34,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
 {SELFPARAM();
        float thisammo, i;
        string s;
-       Weapon info = get_weaponinfo(wpn);
+       Weapon info = Weapons_from(wpn);
        var .int ammotype = info.ammo_field;
 
        entity wep = new(droppedweapon);
@@ -47,7 +47,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
 
        W_DropEvent(wr_drop,own,wpn,wep);
 
-       if(WepSet_FromWeapon(wpn) & WEPSET_SUPERWEAPONS)
+       if(WepSet_FromWeapon(Weapons_from(wpn)) & WEPSET_SUPERWEAPONS)
        {
                if(own.items & IT_UNLIMITED_SUPERWEAPONS)
                {
@@ -58,7 +58,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                        float superweapons = 1;
                        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                        {
-                               WepSet set = WepSet_FromWeapon(i);
+                               WepSet set = WepSet_FromWeapon(Weapons_from(i));
                                if ((set & WEPSET_SUPERWEAPONS) && (own.weapons & set)) ++superweapons;
                        }
                        if(superweapons <= 1)
@@ -148,17 +148,17 @@ bool W_IsWeaponThrowable(bool w)
         return false;
 
        #if 0
-       if(start_weapons & WepSet_FromWeapon(w))
+       if(start_weapons & WepSet_FromWeapon(Weapons_from(w)))
        {
                // start weapons that take no ammo can't be dropped (this prevents dropping the laser, as long as it continues to use no ammo)
                if(start_items & IT_UNLIMITED_WEAPON_AMMO)
                        return false;
-               if((get_weaponinfo(w)).ammo_field == ammo_none)
+               if((Weapons_from(w)).ammo_field == ammo_none)
                        return false;
        }
        return true;
        #else
-       return (get_weaponinfo(w)).weaponthrowable;
+       return (Weapons_from(w)).weaponthrowable;
        #endif
 }
 
@@ -178,7 +178,7 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce)
        if(!W_IsWeaponThrowable(w))
                return;
 
-       WepSet set = WepSet_FromWeapon(w);
+       WepSet set = WepSet_FromWeapon(Weapons_from(w));
        if(!(self.weapons & set)) return;
        self.weapons &= ~set;
 
@@ -191,7 +191,7 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce)
 
 void SpawnThrownWeapon(vector org, float w)
 {SELFPARAM();
-       if(self.weapons & WepSet_FromWeapon(self.weapon))
+       if(self.weapons & WepSet_FromWeapon(Weapons_from(self.weapon)))
                if(W_IsWeaponThrowable(self.weapon))
                        W_ThrowNewWeapon(self, self.weapon, false, org, randomvec() * 125 + '0 0 200');
 }
index 7e10c8a60bd6bed192533096ca1a45cae6649b4d..7607ae18c57ce2a1a7f8386173abe3eb55ba1cb7 100644 (file)
@@ -518,7 +518,7 @@ void W_WeaponFrame(entity actor)
        // server framerate is very low and the weapon fire rate very high
        for (int c = 0; c < W_TICSPERFRAME; ++c)
        {
-               if (w && !(actor.weapons & WepSet_FromWeapon(w)))
+               if (w && !(actor.weapons & WepSet_FromWeapon(Weapons_from(w))))
                {
                        if (actor.weapon == actor.switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
                        w = 0;