From 3366966e825c0f7f3a75c934469cb30dc6a88b3c Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 5 Jun 2018 17:23:55 +1000 Subject: [PATCH] Purge .weapons field --- .../gamemodes/gamemode/nexball/nexball.qc | 10 ++++---- .../gamemode/onslaught/sv_onslaught.qc | 2 +- .../mutators/mutator/itemstime/itemstime.qc | 4 ++-- .../sv_weaponarena_random.qc | 2 +- qcsrc/common/t_items.qc | 24 +++++++++---------- qcsrc/common/weapons/all.qc | 13 ++-------- qcsrc/common/weapons/all.qh | 1 - qcsrc/common/weapons/weapon.qh | 4 +--- qcsrc/server/bot/default/havocbot/roles.qc | 2 +- qcsrc/server/cheats.qc | 4 ++-- qcsrc/server/defs.qh | 3 --- qcsrc/server/g_damage.qc | 14 +++++------ qcsrc/server/mutators/events.qh | 2 +- 13 files changed, 35 insertions(+), 50 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 38f976685..426b341a6 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -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) diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 01458c911..c4f4d32c4 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -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); diff --git a/qcsrc/common/mutators/mutator/itemstime/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime/itemstime.qc index c2402ef46..1379d586f 100644 --- a/qcsrc/common/mutators/mutator/itemstime/itemstime.qc +++ b/qcsrc/common/mutators/mutator/itemstime/itemstime.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qc b/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qc index 4bf3957fb..f4f7e3447 100644 --- a/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qc +++ b/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qc @@ -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); } diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 757fa2ca5..8be48b530 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -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"); diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index b7c65ed96..f118a0466 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -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) diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 0af475900..2a151d1af 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -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) diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index 460d95af6..a3f2336a9 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -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); diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index 5fe9e3ada..4c70c1b1b 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qc +++ b/qcsrc/server/bot/default/havocbot/roles.qc @@ -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;} diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 9620ce545..22e77b4ea 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -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; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index bb25fd097..5230bd8ea 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -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; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index ea1f2aee8..efefed1dc 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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); } } diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index d1ba087a2..3f35fe9ea 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -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) \ -- 2.39.2