]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Purge .weapons field
authorMario <mario@smbclan.net>
Tue, 5 Jun 2018 07:23:55 +0000 (17:23 +1000)
committerMario <mario@smbclan.net>
Tue, 5 Jun 2018 07:26:34 +0000 (17:26 +1000)
13 files changed:
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/common/mutators/mutator/itemstime/itemstime.qc
qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qc
qcsrc/common/t_items.qc
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/all.qh
qcsrc/common/weapons/weapon.qh
qcsrc/server/bot/default/havocbot/roles.qc
qcsrc/server/cheats.qc
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc
qcsrc/server/mutators/events.qh

index 38f976685df110853ca73d364c27a90b59192000..426b341a63a077b1316305a435d0975241b490ea 100644 (file)
@@ -195,7 +195,7 @@ void GiveBall(entity plyr, entity ball)
                ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
        }
 
-       plyr.(weaponentity).weapons = STAT(WEAPONS, plyr);
+       STAT(WEAPONS, plyr.(weaponentity)) = STAT(WEAPONS, plyr);
        plyr.m_switchweapon = plyr.(weaponentity).m_weapon;
        STAT(WEAPONS, plyr) = WEPSET(NEXBALL);
        Weapon w = WEP_NEXBALL;
@@ -828,15 +828,15 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink)
                        {
                                .entity weaponentity = weaponentities[slot];
 
-                               if(player.(weaponentity).weapons)
+                               if(STAT(WEAPONS, player.(weaponentity)))
                                {
-                                       STAT(WEAPONS, player) = player.(weaponentity).weapons;
+                                       STAT(WEAPONS, player) = STAT(WEAPONS, player.(weaponentity));
                                        Weapon w = WEP_NEXBALL;
                                        w.wr_resetplayer(w, player);
                                        player.(weaponentity).m_switchweapon = player.m_switchweapon;
                                        W_SwitchWeapon(player, player.(weaponentity).m_switchweapon, weaponentity);
 
-                                       player.(weaponentity).weapons = '0 0 0';
+                                       STAT(WEAPONS, player.(weaponentity)) = '0 0 0';
                                }
                        }
                }
@@ -862,7 +862,7 @@ MUTATOR_HOOKFUNCTION(nb, PlayerSpawn)
        for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
                .entity weaponentity = weaponentities[slot];
-               player.(weaponentity).weapons = '0 0 0';
+               STAT(WEAPONS, player.(weaponentity)) = '0 0 0';
        }
 
        if (nexball_mode & NBM_BASKETBALL)
index 01458c91181b5017625118fca1fcafb5dcbaeefb..c4f4d32c4262f282d49a12872d9f23a7970ae313 100644 (file)
@@ -1248,7 +1248,7 @@ void havocbot_goalrating_ons_offenseitems(entity this, float ratingscale, vector
        {
                // gather health and armor only
                if (it.solid)
-               if ( ((it.health || it.armorvalue) && needarmor) || (it.weapons && needweapons ) )
+               if ( ((it.health || it.armorvalue) && needarmor) || (STAT(WEAPONS, it) && needweapons ) )
                if (vdist(it.origin - org, <, sradius))
                {
                        int t = it.bot_pickupevalfunc(this, it);
index c2402ef4608c95d7b1f5fbb84e8f70768ffed1e9..1379d586f10fd4da14b9f82d98571cd00bbe6c78 100644 (file)
@@ -124,7 +124,7 @@ void Item_ItemsTime_SetTime(entity e, float t)
     {
                if (!item.instanceOfWeaponPickup)
                        it_times[item.m_id] = t;
-               else if (e.weapons & WEPSET_SUPERWEAPONS)
+               else if (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS)
                        it_times[Items_MAX] = t;
     }
 }
@@ -139,7 +139,7 @@ float Item_ItemsTime_UpdateTime(entity e, float t)
     bool isavailable = (t == 0);
     IL_EACH(g_items, it != e,
     {
-        if(!(it.itemdef == e.itemdef || ((e.weapons & WEPSET_SUPERWEAPONS) && (it.weapons & WEPSET_SUPERWEAPONS))))
+        if(!(it.itemdef == e.itemdef || ((STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS) && (STAT(WEAPONS, it) & WEPSET_SUPERWEAPONS))))
             continue;
         if (it.scheduledrespawntime <= time)
             isavailable = true;
index 4bf3957fb8e4ceadb530d618e9260b2adc6f6ccf..f4f7e344743319d65b57d19834c4c9110617d6c5 100644 (file)
@@ -9,6 +9,6 @@ MUTATOR_HOOKFUNCTION(weaponarena_random, PlayerSpawn)
     entity player = M_ARGV(0, entity);
 
     if (g_weaponarena_random_with_blaster) STAT(WEAPONS, player) &= ~WEPSET(BLASTER);
-    W_RandomWeapons(player, g_weaponarena_random);
+    STAT(WEAPONS, player) = W_RandomWeapons(player, STAT(WEAPONS, player), g_weaponarena_random);
     if (g_weaponarena_random_with_blaster) STAT(WEAPONS, player) |= WEPSET(BLASTER);
 }
index 757fa2ca51c7a47ee4499a682e4c63f2cc9477c9..8be48b53001a313cfb40ad288bb3401430df40b8 100644 (file)
@@ -396,7 +396,7 @@ bool have_pickup_item(entity this)
                if(autocvar_g_pickup_items == 0)
                        return false;
                if(g_weaponarena)
-                       if(this.weapons || this.itemdef.instanceOfAmmo) // no item or ammo pickups in weaponarena
+                       if(STAT(WEAPONS, this) || this.itemdef.instanceOfAmmo) // no item or ammo pickups in weaponarena
                                return false;
        }
        return true;
@@ -425,7 +425,7 @@ void Item_Show (entity e, float mode)
        }
        else
        {
-               bool nostay = def.instanceOfWeaponPickup ? !!(def.m_weapon.weapons & WEPSET_SUPERWEAPONS) : false // no weapon-stay on superweapons
+               bool nostay = def.instanceOfWeaponPickup ? !!(def.m_weapon.m_wepset & WEPSET_SUPERWEAPONS) : false // no weapon-stay on superweapons
                        || e.team // weapon stay isn't supported for teamed weapons
                        ;
                if(def.instanceOfWeaponPickup && !nostay && g_weapon_stay)
@@ -485,7 +485,7 @@ void Item_Respawn (entity this)
        sound(this, CH_TRIGGER, this.itemdef.m_respawnsound, VOL_BASE, ATTEN_NORM);     // play respawn sound
        setorigin(this, this.origin);
 
-    if (Item_ItemsTime_Allow(this.itemdef) || (this.weapons & WEPSET_SUPERWEAPONS))
+    if (Item_ItemsTime_Allow(this.itemdef) || (STAT(WEAPONS, this) & WEPSET_SUPERWEAPONS))
        {
                float t = Item_ItemsTime_UpdateTime(this, 0);
                Item_ItemsTime_SetTime(this, t);
@@ -570,13 +570,13 @@ void Item_RespawnThink(entity this)
 void Item_ScheduleRespawnIn(entity e, float t)
 {
        // if the respawn time is longer than 10 seconds, show a waypoint, otherwise, just respawn normally
-       if ((Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS) || MUTATOR_CALLHOOK(Item_ScheduleRespawn, e, t)) && (t - ITEM_RESPAWN_TICKS) > 0)
+       if ((Item_ItemsTime_Allow(e.itemdef) || (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS) || MUTATOR_CALLHOOK(Item_ScheduleRespawn, e, t)) && (t - ITEM_RESPAWN_TICKS) > 0)
        {
                setthink(e, Item_RespawnCountdown);
                e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
                e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
                e.item_respawncounter = 0;
-               if(Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS))
+               if(Item_ItemsTime_Allow(e.itemdef) || (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS))
                {
                        t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime);
                        Item_ItemsTime_SetTime(e, t);
@@ -590,7 +590,7 @@ void Item_ScheduleRespawnIn(entity e, float t)
                e.scheduledrespawntime = time + t;
                e.wait = time + t;
 
-               if(Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS))
+               if(Item_ItemsTime_Allow(e.itemdef) || (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS))
                {
                        t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime);
                        Item_ItemsTime_SetTime(e, t);
@@ -790,7 +790,7 @@ float Item_GiveTo(entity item, entity player)
        if (item.itemdef.instanceOfWeaponPickup)
        {
                WepSet w;
-               w = item.weapons;
+               w = STAT(WEAPONS, item);
                w &= ~STAT(WEAPONS, player);
 
                if (w || (item.spawnshieldtime && item.pickup_anyway > 0))
@@ -981,7 +981,7 @@ void Item_Reset(entity this)
        {
                WaypointSprite_Kill(this.waypointsprite_attached);
        }
-       if (this.itemdef.instanceOfPowerup || (this.weapons & WEPSET_SUPERWEAPONS)) // do not spawn powerups initially!
+       if (this.itemdef.instanceOfPowerup || (STAT(WEAPONS, this) & WEPSET_SUPERWEAPONS)) // do not spawn powerups initially!
        {
                Item_ScheduleInitialRespawn(this);
        }
@@ -1040,7 +1040,7 @@ float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickup
 float weapon_pickupevalfunc(entity player, entity item)
 {
        // See if I have it already
-       if(STAT(WEAPONS, player) & item.weapons)
+       if(STAT(WEAPONS, player) & STAT(WEAPONS, item))
        {
                // If I can pick it up
                if(!item.spawnshieldtime)
@@ -1201,7 +1201,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
        }
 
        if(weaponid)
-               this.weapons = WepSet_FromWeapon(Weapons_from(weaponid));
+               STAT(WEAPONS, this) = WepSet_FromWeapon(Weapons_from(weaponid));
 
        this.flags = FL_ITEM | itemflags;
        IL_PUSH(g_items, this);
@@ -1510,7 +1510,7 @@ spawnfunc(target_items)
                                        s = W_UndeprecateName(argv(j));
                                        if(s == it.netname)
                                        {
-                                               this.weapons |= (it.m_wepset);
+                                               STAT(WEAPONS, this) |= (it.m_wepset);
                                                if(this.spawnflags == 0 || this.spawnflags == 2)
                                                        it.wr_init(it);
                                                break;
@@ -1563,7 +1563,7 @@ spawnfunc(target_items)
                if(this.health != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, this.health), "health");
                if(this.armorvalue != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, this.armorvalue), "armor");
                FOREACH(Buffs, it != BUFF_Null, this.netname = sprintf("%s %s%d %s", this.netname, itemprefix, !!(STAT(BUFFS, this) & (it.m_itemid)), it.m_name));
-               FOREACH(Weapons, it != WEP_Null, this.netname = sprintf("%s %s%d %s", this.netname, itemprefix, !!(this.weapons & (it.m_wepset)), it.netname));
+               FOREACH(Weapons, it != WEP_Null, this.netname = sprintf("%s %s%d %s", this.netname, itemprefix, !!(STAT(WEAPONS, this) & (it.m_wepset)), it.netname));
        }
        this.netname = strzone(this.netname);
        //print(this.netname, "\n");
index b7c65ed960ff6e13eb7696d56c2718db25d7ab47..f118a04667f39c181eb0dee13eede8cc59d42973 100644 (file)
@@ -194,13 +194,8 @@ string W_FixWeaponOrder_ForceComplete(string order)
        return W_FixWeaponOrder(order, 1);
 }
 
-void W_RandomWeapons(entity e, int n)
+WepSet W_RandomWeapons(entity e, WepSet remaining, int n)
 {
-#ifdef SVQC
-       WepSet remaining = STAT(WEAPONS, e);
-#else
-       WepSet remaining = e.weapons;
-#endif
        WepSet result = '0 0 0';
        for (int j = 0; j < n; ++j)
        {
@@ -213,11 +208,7 @@ void W_RandomWeapons(entity e, int n)
                result |= WepSet_FromWeapon(w);
                remaining &= ~WepSet_FromWeapon(w);
        }
-#ifdef SVQC
-       STAT(WEAPONS, e) = result;
-#else
-       e.weapons = result;
-#endif
+       return result;
 }
 
 string GetAmmoPicture(int ammotype)
index 0af47590078a8dde4c44257de429ff240e0dd19e..2a151d1afcc0d402acc31fd6689ace7f50b0624e 100644 (file)
@@ -304,7 +304,6 @@ STATIC_INIT(register_weapons_done)
         WepSet set = it.m_wepset = _WepSet_FromWeapon(it.m_id = i);
         WEPSET_ALL |= set;
         if ((it.spawnflags) & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set;
-        it.weapons = set;
         if (it == WEP_Null) continue;
         int imp = WEP_IMPULSE_BEGIN + it.m_id - 1;
         if (imp <= WEP_IMPULSE_END)
index 460d95af65e685253865e8cdd65d1abc35fd6ece..a3f2336a9487b275a8a130a031295c462072d77b 100644 (file)
@@ -44,8 +44,6 @@ CLASS(Weapon, Object)
     ATTRIB(Weapon, m_canonical_spawnfunc, string);
     /** control what happens when this weapon is spawned */
     METHOD(Weapon, m_spawnfunc_hookreplace, Weapon(Weapon this, entity e)) { return this; }
-    /** A: WEPSET_id : WEPSET_... */
-    ATTRIB(Weapon, weapons, WepSet, '0 0 0');
     /** M: ammotype  : main ammo type */
     ATTRIB(Weapon, ammo_type, int, RESOURCE_NONE);
     /** M: impulse   : weapon impulse */
@@ -211,7 +209,7 @@ string W_NumberWeaponOrder(string order);
 string W_FixWeaponOrder_BuildImpulseList(string o);
 string W_FixWeaponOrder_AllowIncomplete(entity this, string order);
 string W_FixWeaponOrder_ForceComplete(string order);
-void W_RandomWeapons(entity e, int n);
+WepSet W_RandomWeapons(entity e, WepSet remaining, int n);
 
 string GetAmmoPicture(int ammotype);
 
index 5fe9e3adabc23cab01e1479903efb2bf6b61ff39..4c70c1b1bda385a12ee7edf1b25bc97273f36da5 100644 (file)
@@ -51,7 +51,7 @@ bool havocbot_goalrating_item_can_be_left_to_teammate(entity this, entity player
 {
        if (item.health && player.health <= this.health) {return true;}
        if (item.armorvalue && player.armorvalue <= this.armorvalue) {return true;}
-       if (item.weapons && !(STAT(WEAPONS, player) & item.weapons)) {return true;}
+       if (STAT(WEAPONS, item) && !(STAT(WEAPONS, player) & STAT(WEAPONS, item))) {return true;}
        if (item.ammo_shells && player.ammo_shells <= this.ammo_shells) {return true;}
        if (item.ammo_nails && player.ammo_nails <= this.ammo_nails) {return true;}
        if (item.ammo_rockets && player.ammo_rockets <= this.ammo_rockets) {return true;}
index 9620ce545e75bdd3dc5b49b8724746278fe95c7e..22e77b4eacf941a27fc41c334924d8dff7644173 100644 (file)
@@ -159,7 +159,7 @@ float CheatImpulse(entity this, int imp)
                        this.personal.ammo_fuel = this.ammo_fuel;
                        this.personal.health = max(1, this.health);
                        this.personal.armorvalue = this.armorvalue;
-                       this.personal.weapons = STAT(WEAPONS, this);
+                       STAT(WEAPONS, this.personal) = STAT(WEAPONS, this);
                        this.personal.items = this.items;
                        this.personal.pauserotarmor_finished = this.pauserotarmor_finished;
                        this.personal.pauserothealth_finished = this.pauserothealth_finished;
@@ -218,7 +218,7 @@ float CheatImpulse(entity this, int imp)
                                this.ammo_fuel = this.personal.ammo_fuel;
                                this.health = this.personal.health;
                                this.armorvalue = this.personal.armorvalue;
-                               STAT(WEAPONS, this) = this.personal.weapons;
+                               STAT(WEAPONS, this) = STAT(WEAPONS, this.personal);
                                this.items = this.personal.items;
                                this.pauserotarmor_finished = time + this.personal.pauserotarmor_finished - this.personal.teleport_time;
                                this.pauserothealth_finished = time + this.personal.pauserothealth_finished - this.personal.teleport_time;
index bb25fd09765799b2b515d87d4147c625233a8b8e..5230bd8ea6ac1279c964cf61a8f052cedfa5806a 100644 (file)
@@ -190,9 +190,6 @@ void FixClientCvars(entity e);
 // WEAPONTODO: remove this
 //WepSet weaponsInMap;
 
-//#define weapons _STAT(WEAPONS)
-.WepSet weapons; // WEAPONTODO: remove this too, items can safely use the stat, weapon code shouldn't need it!
-
 .float respawn_countdown; // next number to count
 
 float bot_waypoints_for_items;
index ea1f2aee811d71824e44382a18919dfe429a8d99..efefed1dc74f2451892ea7a184cf446f55d75511 100644 (file)
@@ -80,20 +80,20 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype, .entity we
                        }
 
                        if(warmup_stage)
-                               GiveFrags_randomweapons.weapons = WARMUP_START_WEAPONS;
+                               STAT(WEAPONS, GiveFrags_randomweapons) = WARMUP_START_WEAPONS;
                        else
-                               GiveFrags_randomweapons.weapons = start_weapons;
+                               STAT(WEAPONS, GiveFrags_randomweapons) = start_weapons;
 
                        // all others (including the culprit): remove
-                       GiveFrags_randomweapons.weapons &= ~STAT(WEAPONS, attacker);
-                       GiveFrags_randomweapons.weapons &= ~(culprit.m_wepset);
+                       STAT(WEAPONS, GiveFrags_randomweapons) &= ~STAT(WEAPONS, attacker);
+                       STAT(WEAPONS, GiveFrags_randomweapons) &= ~(culprit.m_wepset);
 
                        // among the remaining ones, choose one by random
-                       W_RandomWeapons(GiveFrags_randomweapons, 1);
+                       STAT(WEAPONS, GiveFrags_randomweapons) = W_RandomWeapons(GiveFrags_randomweapons, STAT(WEAPONS, GiveFrags_randomweapons), 1);
 
-                       if(GiveFrags_randomweapons.weapons)
+                       if(STAT(WEAPONS, GiveFrags_randomweapons))
                        {
-                               STAT(WEAPONS, attacker) |= GiveFrags_randomweapons.weapons;
+                               STAT(WEAPONS, attacker) |= STAT(WEAPONS, GiveFrags_randomweapons);
                                STAT(WEAPONS, attacker) &= ~(culprit.m_wepset);
                        }
                }
index d1ba087a2e0ba9e2e2d1743e9d63669560f900f8..3f35fe9eaa39e816f3a8bf9c063cc4977c735087 100644 (file)
@@ -241,7 +241,7 @@ MUTATOR_HOOKABLE(CustomizeWaypoint, EV_CustomizeWaypoint);
 MUTATOR_HOOKABLE(FilterItemDefinition, EV_FilterItemDefinition);
 
 /**
- * checks if the current item may be spawned (.items and .weapons may be read and written to, as well as the ammo_ fields)
+ * checks if the current item may be spawned (.items may be read and written to, as well as the ammo_ fields)
  * return error to request removal
  */
 #define EV_FilterItem(i, o) \