make the weapon declaration lines more self explaining
authordiv0 <div0@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Fri, 22 Jan 2010 20:05:53 +0000 (20:05 +0000)
committerdiv0 <div0@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Fri, 22 Jan 2010 20:05:53 +0000 (20:05 +0000)
git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8525 f962a42d-fe04-0410-a3ab-8c8b0445ebaa

23 files changed:
data/qcsrc/client/sbar.qc
data/qcsrc/common/items.qc
data/qcsrc/common/items.qh
data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c
data/qcsrc/server/cl_weapons.qc
data/qcsrc/server/cl_weaponsystem.qc
data/qcsrc/server/miscfunctions.qc
data/qcsrc/server/w_campingrifle.qc
data/qcsrc/server/w_crylink.qc
data/qcsrc/server/w_electro.qc
data/qcsrc/server/w_fireball.qc
data/qcsrc/server/w_grenadelauncher.qc
data/qcsrc/server/w_hagar.qc
data/qcsrc/server/w_hlac.qc
data/qcsrc/server/w_hook.qc
data/qcsrc/server/w_laser.qc
data/qcsrc/server/w_minstanex.qc
data/qcsrc/server/w_nex.qc
data/qcsrc/server/w_porto.qc
data/qcsrc/server/w_rocketlauncher.qc
data/qcsrc/server/w_shotgun.qc
data/qcsrc/server/w_tuba.qc
data/qcsrc/server/w_uzi.qc

index 208a6c5..e0419ac 100644 (file)
@@ -2388,7 +2388,7 @@ void Sbar_DrawAccuracyStats()
                border_colour = (i == activeweapon) ? '1 1 1' : '0 0 0';  // white or black border
 
                if (weapon_damage) {
-                       if (self.weapon_type == WEP_TYPE_SPLASH) {
+                       if (self.spawnflags & WEP_TYPE_SPLASH) {
                                weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
 
                                fill_colour_x = 1 - 0.015 * weapon_stats;
@@ -2438,7 +2438,7 @@ void Sbar_DrawAccuracyStats()
                                drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 9 0' * sbar_fontsize_y, ftos(max(0, weapon_damage - weapon_hit)), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
                                ++count_splash;
-                       } else if (self.weapon_type == WEP_TYPE_HITSCAN) {
+                       } else if (self.spawnflags & WEP_TYPE_HITSCAN) {
                                weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
 
                                fill_colour_x = 1 - 0.015 * weapon_stats;
index de32afd..e9ff445 100644 (file)
@@ -2,7 +2,7 @@
 entity weapon_info[24];
 entity dummy_weapon_info;
 
-void register_weapon(float id, float(float) func, float ammotype, float i, float normalweapon, float canclimb, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname)
+void register_weapon(float id, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname)
 {
        entity e;
        weapon_info[id - 1] = e = spawn();
@@ -15,16 +15,9 @@ void register_weapon(float id, float(float) func, float ammotype, float i, float
        e.weapon_func = func;
        e.mdl = modelname;
        e.model = strzone(strcat("models/weapons/g_", modelname, ".md3"));
-       e.spawnflags = 0;
+       e.spawnflags = weapontype;
        e.model2 = strzone(strcat("wpn-", e.mdl));
-       if(normalweapon > 0)
-               e.spawnflags |= WEPSPAWNFLAG_NORMAL;
-       if(normalweapon < 0)
-               e.spawnflags |= WEPSPAWNFLAG_HIDDEN;
-       if(canclimb)
-               e.spawnflags |= WEPSPAWNFLAG_CANCLIMB;
        e.impulse = i;
-       e.weapon_type = weapontype;
        e.bot_pickupbasevalue = pickupbasevalue;
 }
 float w_null(float dummy)
@@ -46,7 +39,6 @@ void register_weapons_done()
        dummy_weapon_info.model = "";
        dummy_weapon_info.spawnflags = 0;
        dummy_weapon_info.impulse = -1;
-       dummy_weapon_info.weapon_type = WEP_TYPE_OTHER;
        dummy_weapon_info.bot_pickupbasevalue = 0;
        dummy_weapon_info.model2 = "";
 
index 262f43c..3900b08 100644 (file)
@@ -2,9 +2,13 @@ float BOT_PICKUP_RATING_LOW    = 2500;
 float BOT_PICKUP_RATING_MID    = 5000;
 float BOT_PICKUP_RATING_HIGH   = 10000;
 
-float WEP_TYPE_OTHER   = 0;    // e.g: Hook, Port-o-launch, etc
-float WEP_TYPE_SPLASH  = 1;
-float WEP_TYPE_HITSCAN = 2;
+float WEP_TYPE_OTHER   = 0x00; // e.g: Hook, Port-o-launch, etc
+float WEP_TYPE_SPLASH  = 0x01;
+float WEP_TYPE_HITSCAN = 0x02;
+float WEP_TYPEMASK      = 0x0F;
+float WEP_FLAG_CANCLIMB = 0x10;
+float WEP_FLAG_NORMAL   = 0x20;
+float WEP_FLAG_HIDDEN   = 0x40;
 
 float  IT_UNLIMITED_WEAPON_AMMO  = 1;
 // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
@@ -55,10 +59,6 @@ string W_FixWeaponOrder(string order, float complete);
 string W_NameWeaponOrder(string order);
 string W_NumberWeaponOrder(string order);
 
-#define WEPSPAWNFLAG_NORMAL 1
-#define WEPSPAWNFLAG_CANCLIMB 2
-#define WEPSPAWNFLAG_HIDDEN 4
-
 // entity properties of weaponinfo:
 .float weapon; // WEP_...
 .float weapons; // WEPBIT_...
@@ -70,7 +70,6 @@ string W_NumberWeaponOrder(string order);
 .string model; // full name of g_ model
 .float spawnflags; // WEPSPAWNFLAG_... combined
 .float impulse; // weapon impulse
-.float weapon_type; // see WEP_TYPE_* constants
 .float bot_pickupbasevalue; // bot weapon priority
 .string model2; // wpn- sprite name
 
@@ -78,7 +77,7 @@ string W_NumberWeaponOrder(string order);
 
 // dynamic weapon adding
 float w_null(float dummy);
-void register_weapon(float id, float(float) func, float ammotype, float i, float normalweapon, float canclimb, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname);
+void register_weapon(float id, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname);
 void register_weapons_done();
 
 float WEP_COUNT;
@@ -86,7 +85,7 @@ float WEP_FIRST = 1;
 float WEP_LAST;
 #define WEP_MAXCOUNT 24
 float WEPBIT_ALL;
-#define REGISTER_WEAPON_2(id,bit,func,ammotype,i,normalweapon,canclimb,weapontype,pickupbasevalue,modelname,shortname,wname) \
+#define REGISTER_WEAPON_2(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
        float id; \
        float bit; \
        float func(float); \
@@ -95,15 +94,15 @@ float WEPBIT_ALL;
                WEP_LAST = (id = WEP_FIRST + WEP_COUNT); \
                WEPBIT_ALL |= (bit = power2of(WEP_COUNT)); \
                ++WEP_COUNT; \
-               register_weapon(id,func,ammotype,i,normalweapon,canclimb,weapontype,pickupbasevalue,modelname,shortname,wname); \
+               register_weapon(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \
        } \
        ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id)
 #ifdef SVQC
-#define REGISTER_WEAPON(id,func,ammotype,i,normalweapon,canclimb,weapontype,pickupbasevalue,modelname,shortname,wname) \
-       REGISTER_WEAPON_2(WEP_##id,WEPBIT_##id,func,ammotype,i,normalweapon,canclimb,weapontype,pickupbasevalue,modelname,shortname,wname)
+#define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
+       REGISTER_WEAPON_2(WEP_##id,WEPBIT_##id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
 #else
-#define REGISTER_WEAPON(id,func,ammotype,i,normalweapon,canclimb,weapontype,pickupbasevalue,modelname,shortname,wname) \
-       REGISTER_WEAPON_2(WEP_##id,WEPBIT_##id,w_null,ammotype,i,normalweapon,canclimb,weapontype,pickupbasevalue,modelname,shortname,wname)
+#define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
+       REGISTER_WEAPON_2(WEP_##id,WEPBIT_##id,w_null,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
 #endif
 
 #include "../server/w_all.qc"
index cb976ba..fddc7cd 100644 (file)
@@ -219,7 +219,7 @@ void fillNexuizMutatorsDialog(entity me)
        for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
        {
                w = get_weaponinfo(i);
-               if(w.spawnflags & WEPSPAWNFLAG_HIDDEN)
+               if(w.spawnflags & WEP_FLAG_HIDDEN)
                        continue;
                if(j & 1 == 0)
                        me.TR(me);
index da9d715..bf7090e 100644 (file)
@@ -446,7 +446,7 @@ float NixNex_CanChooseWeapon(float wpn)
        {
                if(wpn == WEP_LASER && g_nixnex_with_laser)
                        return FALSE;
-               if not(e.spawnflags & WEPSPAWNFLAG_NORMAL)
+               if not(e.spawnflags & WEP_FLAG_NORMAL)
                        return FALSE;
        }
        return TRUE;
index 06fe7ee..c3cc837 100644 (file)
@@ -151,7 +151,7 @@ void W_SetupShot_Dir_ProjectileSize(entity ent, vector s_forward, vector mi, vec
        if not(inWarmupStage) {
                entity w;
                w = get_weaponinfo(ent.weapon);
-               if(w.weapon_type == WEP_TYPE_SPLASH) {  // splash damage
+               if(w.spawnflags & WEP_TYPE_SPLASH) {  // splash damage
                        ent.stats_fired[ent.weapon - 1] += maxdamage;
                        ent.stat_fired = ent.weapon + 64 * floor(ent.stats_fired[ent.weapon - 1]);
                }
index 3283700..65155f2 100644 (file)
@@ -911,7 +911,7 @@ float want_weapon(string cvarprefix, entity weaponinfo, float allguns)
        if (t < 0) // "default" weapon selection
        {
                if (g_lms || g_ca || allguns)
-                       t = (weaponinfo.spawnflags & WEPSPAWNFLAG_NORMAL);
+                       t = (weaponinfo.spawnflags & WEP_FLAG_NORMAL);
                else if(t < -1)
                        t = 0;
                else if (g_race || g_cts)
@@ -969,7 +969,7 @@ void readplayerstartcvars()
                for (j = WEP_FIRST; j <= WEP_LAST; ++j)
                {
                        e = get_weaponinfo(j);
-                       if (e.spawnflags & WEPSPAWNFLAG_NORMAL)
+                       if (e.spawnflags & WEP_FLAG_NORMAL)
                        {
                                g_weaponarena |= e.weapons;
                                weapon_action(e.weapon, WR_PRECACHE);
index fe56fca..e831376 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(CAMPINGRIFLE,     w_campingrifle, IT_NAILS,         3,  1, 0, WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_MID,  "campingrifle", "campingrifle",    "Rifle");
+REGISTER_WEAPON(CAMPINGRIFLE, w_campingrifle, IT_NAILS, 3, WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_MID, "campingrifle", "campingrifle", "Rifle");
 #else
 //Camping rifle Primary mode: manually operated bolt*, Secondary: full automatic**
 //* Manually operating the bolt means that all the power of the gas is used to propell the bullet. In this mode the bolt is prevented from moving backwards in response to the firing of the bullet.
index 26abb61..a7bc0bc 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(CRYLINK,          w_crylink,      IT_CELLS,         6,  1, 0, WEP_TYPE_SPLASH , BOT_PICKUP_RATING_MID,  "crylink",      "crylink",         "Crylink");
+REGISTER_WEAPON(CRYLINK, w_crylink, IT_CELLS, 6, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "crylink", "crylink", "Crylink");
 #else
 .float gravity;
 
index d678423..ff5446f 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(ELECTRO,          w_electro,      IT_CELLS,         5,  1, 0, WEP_TYPE_SPLASH , BOT_PICKUP_RATING_MID,  "electro",      "electro",         "Electro");
+REGISTER_WEAPON(ELECTRO, w_electro, IT_CELLS, 5, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "electro", "electro", "Electro");
 #else
 .float electro_count;
 .float electro_secondarytime;
index 5a63d66..adcff90 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(FIREBALL,         w_fireball,     IT_ROCKETS,       9,  0, 0, WEP_TYPE_SPLASH,  BOT_PICKUP_RATING_MID,  "fireball",     "fireball",        "Fireball");
+REGISTER_WEAPON(FIREBALL, w_fireball, IT_ROCKETS, 9, WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "fireball", "fireball", "Fireball");
 #else
 .float bot_secondary_fireballmooth; // whatever a mooth is
 .vector fireball_impactvec;
index 217f5e5..31fa998 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(GRENADE_LAUNCHER, w_glauncher,    IT_ROCKETS,       4,  1, 1, WEP_TYPE_SPLASH , BOT_PICKUP_RATING_MID,  "gl",           "grenadelauncher", "Mortar");
+REGISTER_WEAPON(GRENADE_LAUNCHER, w_glauncher, IT_ROCKETS, 4, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "gl", "grenadelauncher", "Mortar");
 #else
 void W_Grenade_Explode (void)
 {
index fb114bc..6d22960 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(HAGAR,            w_hagar,        IT_ROCKETS,       8,  1, 1, WEP_TYPE_SPLASH , BOT_PICKUP_RATING_MID,  "hagar",        "hagar",           "Hagar");
+REGISTER_WEAPON(HAGAR, w_hagar, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "hagar", "hagar", "Hagar");
 #else
 // NO bounce protection, as bounces are limited!
 void W_Hagar_Explode (void)
index aea9ecb..a96aa66 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(HLAC,             w_hlac,         IT_CELLS,         6,  1, 0, WEP_TYPE_SPLASH,  BOT_PICKUP_RATING_MID,  "hlac",         "hlac",            "Heavy Laser Assault Cannon");
+REGISTER_WEAPON(HLAC, w_hlac, IT_CELLS, 6, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "hlac", "hlac", "Heavy Laser Assault Cannon");
 #else
 .float HLAC_bulletcounter;
 void W_HLAC_Touch (void)
index 62e9746..7924049 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(HOOK,             w_hook,         IT_CELLS|IT_FUEL, 0,  0, 1, WEP_TYPE_SPLASH,  0,                      "hookgun",      "hook",            "Grappling Hook");
+REGISTER_WEAPON(HOOK, w_hook, IT_CELLS|IT_FUEL, 0, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "hookgun", "hook", "Grappling Hook");
 #else
 .float dmg;
 .float dmg_edge;
index db61d7d..a8a097c 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(LASER,            w_laser,        0,                1,  1, 1, WEP_TYPE_SPLASH,  0,                      "laser",        "laser",           "Laser");
+REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "laser", "laser", "Laser");
 #else
 void(float imp) W_SwitchWeapon;
 
index 175a6ec..089af24 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(MINSTANEX,        w_minstanex,    IT_CELLS,         7, -1, 1, WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "minstanex",    "minstanex",       "MinstaNex");
+REGISTER_WEAPON(MINSTANEX, w_minstanex, IT_CELLS, 7, WEP_FLAG_HIDDEN | WEP_FLAG_CANCLIMB | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "minstanex", "minstanex", "MinstaNex");
 #else
 .float minstanex_lasthit;
 
index 34b16ec..766fd62 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(NEX,              w_nex,          IT_CELLS,         7,  1, 0, WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "nex",          "nex",             "Nex");
+REGISTER_WEAPON(NEX, w_nex, IT_CELLS, 7, WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "nex", "nex", "Nex");
 #else
 void SendCSQCNexBeamParticle() {
        WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
index db11065..63695c0 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(PORTO,            w_porto,        0,                0,  0, 0, WEP_TYPE_OTHER,   0,                      "porto" ,       "porto",           "Port-O-Launch");
+REGISTER_WEAPON(PORTO, w_porto, 0, 0, WEP_TYPE_OTHER, 0, "porto" , "porto", "Port-O-Launch");
 #else
 .entity porto_current;
 .vector porto_v_angle; // holds "held" view angles
index e4996a6..97772e5 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(ROCKET_LAUNCHER,  w_rlauncher,    IT_ROCKETS,       9,  1, 1, WEP_TYPE_SPLASH , BOT_PICKUP_RATING_HIGH, "rl",           "rocketlauncher",  "Rocket Launcher");
+REGISTER_WEAPON(ROCKET_LAUNCHER, w_rlauncher, IT_ROCKETS, 9, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_HIGH, "rl", "rocketlauncher", "Rocket Launcher");
 #else
 .float rl_release;
 .float rl_detonate_later;
index 26d994e..a65dd50 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(SHOTGUN,          w_shotgun,      IT_SHELLS,        2,  1, 0, WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_LOW,  "shotgun",      "shotgun",         "Shotgun");
+REGISTER_WEAPON(SHOTGUN, w_shotgun, IT_SHELLS, 2, WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_LOW, "shotgun", "shotgun", "Shotgun");
 #else
 void W_Shotgun_Attack (void)
 {
index 6a4e3b0..9074ba8 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(TUBA,             w_tuba,         0,                1, -1, 0, WEP_TYPE_SPLASH,  BOT_PICKUP_RATING_MID,  "tuba",         "tuba",            "@!#%'n Tuba");
+REGISTER_WEAPON(TUBA, w_tuba, 0, 1, WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "tuba", "tuba", "@!#%'n Tuba");
 #else
 //#define TUBA_NOTE(n) strcat("weapons/tuba_note", ftos(n), ".wav")
 .float tuba_notecount;
index c81ad0d..c519b2d 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(UZI,              w_uzi,          IT_NAILS,         3,  1, 0, WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_MID,  "uzi",          "uzi",             "Machine Gun");
+REGISTER_WEAPON(UZI, w_uzi, IT_NAILS, 3, WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_MID, "uzi", "uzi", "Machine Gun");
 #else
 // leilei's fancy muzzleflash stuff
 void W_Uzi_Flash_Go() {