From: Mario Date: Tue, 5 Jun 2018 06:45:02 +0000 (+1000) Subject: Replace uses of the .weapons field with STAT(WEAPONS, player), doesn't replace the... X-Git-Tag: xonotic-v0.8.5~2109^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a368182e18dcde15d82e5294b8e6d5cde9c5994c;p=xonotic%2Fxonotic-data.pk3dir.git Replace uses of the .weapons field with STAT(WEAPONS, player), doesn't replace the non-player uses yet --- diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index fa718eb16..38f976685 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -195,9 +195,9 @@ void GiveBall(entity plyr, entity ball) ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold; } - plyr.(weaponentity).weapons = plyr.weapons; + plyr.(weaponentity).weapons = STAT(WEAPONS, plyr); plyr.m_switchweapon = plyr.(weaponentity).m_weapon; - plyr.weapons = WEPSET(NEXBALL); + STAT(WEAPONS, plyr) = WEPSET(NEXBALL); Weapon w = WEP_NEXBALL; w.wr_resetplayer(w, plyr); plyr.(weaponentity).m_switchweapon = WEP_NEXBALL; @@ -830,7 +830,7 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink) if(player.(weaponentity).weapons) { - player.weapons = player.(weaponentity).weapons; + STAT(WEAPONS, player) = player.(weaponentity).weapons; Weapon w = WEP_NEXBALL; w.wr_resetplayer(w, player); player.(weaponentity).m_switchweapon = player.m_switchweapon; @@ -866,9 +866,9 @@ MUTATOR_HOOKFUNCTION(nb, PlayerSpawn) } if (nexball_mode & NBM_BASKETBALL) - player.weapons |= WEPSET(NEXBALL); + STAT(WEAPONS, player) |= WEPSET(NEXBALL); else - player.weapons = '0 0 0'; + STAT(WEAPONS, player) = '0 0 0'; return false; } diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 2637aeef2..01458c911 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -1229,7 +1229,7 @@ void havocbot_goalrating_ons_offenseitems(entity this, float ratingscale, vector // Needs weapons? int c = 0; FOREACH(Weapons, it != WEP_Null, { - if(this.weapons & (it.m_wepset)) + if(STAT(WEAPONS, this) & (it.m_wepset)) if(++c >= 4) break; }); diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 9e0f50d92..dbd04a70a 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -1253,7 +1253,7 @@ MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST) { entity player = M_ARGV(0, entity); - if (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) { + if (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) { nades_CheckThrow(player); return true; } @@ -1265,7 +1265,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) if (!IS_PLAYER(player)) { return; } - if (player.nade && (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton); + if (player.nade && (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton); entity held_nade = player.nade; if (held_nade) diff --git a/qcsrc/common/mutators/mutator/nix/sv_nix.qc b/qcsrc/common/mutators/mutator/nix/sv_nix.qc index e88ff9b55..a9aa7f06f 100644 --- a/qcsrc/common/mutators/mutator/nix/sv_nix.qc +++ b/qcsrc/common/mutators/mutator/nix/sv_nix.qc @@ -63,7 +63,7 @@ REGISTER_MUTATOR(nix, expr_evaluate(cvar_string("g_nix")) && !autocvar_g_instagi SetResourceAmount(it, RESOURCE_CELLS, start_ammo_cells); SetResourceAmount(it, RESOURCE_PLASMA, start_ammo_plasma); SetResourceAmount(it, RESOURCE_FUEL, start_ammo_fuel); - it.weapons = start_weapons; + STAT(WEAPONS, it) = start_weapons; for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { .entity weaponentity = weaponentities[slot]; @@ -208,10 +208,10 @@ void NIX_GiveCurrentWeapon(entity this) this.nix_nextincr = time + autocvar_g_balance_nix_incrtime; } - this.weapons = '0 0 0'; + STAT(WEAPONS, this) = '0 0 0'; if(g_nix_with_blaster) - this.weapons |= WEPSET(BLASTER); - this.weapons |= e.m_wepset; + STAT(WEAPONS, this) |= WEPSET(BLASTER); + STAT(WEAPONS, this) |= e.m_wepset; Weapon w = Weapons_from(nix_weapon); for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) diff --git a/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc b/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc index c5bf2262e..709989776 100644 --- a/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc +++ b/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc @@ -15,7 +15,7 @@ MUTATOR_HOOKFUNCTION(pinata, PlayerDies) continue; FOREACH(Weapons, it != WEP_Null, { - if(frag_target.weapons & WepSet_FromWeapon(it)) + if(STAT(WEAPONS, frag_target) & WepSet_FromWeapon(it)) if(frag_target.(weaponentity).m_weapon != it) if(W_IsWeaponThrowable(frag_target, it.m_id)) W_ThrowNewWeapon(frag_target, it.m_id, false, CENTER_OR_VIEWOFS(frag_target), randomvec() * 175 + '0 0 325', weaponentity); 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 7ac4504ec..4bf3957fb 100644 --- a/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qc +++ b/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qc @@ -8,7 +8,7 @@ MUTATOR_HOOKFUNCTION(weaponarena_random, PlayerSpawn) if (!g_weaponarena_random) return; entity player = M_ARGV(0, entity); - if (g_weaponarena_random_with_blaster) player.weapons &= ~WEPSET(BLASTER); + if (g_weaponarena_random_with_blaster) STAT(WEAPONS, player) &= ~WEPSET(BLASTER); W_RandomWeapons(player, g_weaponarena_random); - if (g_weaponarena_random_with_blaster) player.weapons |= WEPSET(BLASTER); + 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 37a29f101..757fa2ca5 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -402,33 +402,6 @@ bool have_pickup_item(entity this) return true; } -/* -float Item_Customize() -{ - if(this.spawnshieldtime) - return true; - if(this.weapons & ~other.weapons) - { - this.colormod = '0 0 0'; - this.glowmod = this.colormod; - this.alpha = 0.5 + 0.5 * g_ghost_items; // halfway more alpha - return true; - } - else - { - if(g_ghost_items) - { - this.colormod = stov(autocvar_g_ghost_items_color); - this.glowmod = this.colormod; - this.alpha = g_ghost_items; - return true; - } - else - return false; - } -} -*/ - void Item_Show (entity e, float mode) { e.effects &= ~(EF_ADDITIVE | EF_STARDUST | EF_FULLBRIGHT | EF_NODEPTHTEST); @@ -728,7 +701,7 @@ void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names, FOREACH(Weapons, it != WEP_Null, { // Finding a weapon which player doesn't have. - if (!(receiver.weapons & it.m_wepset) && (it.netname == weapon)) + if (!(STAT(WEAPONS, receiver) & it.m_wepset) && (it.netname == weapon)) { RandomSelection_AddEnt(it, 1, 1); break; @@ -739,7 +712,7 @@ void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names, { return; } - receiver.weapons |= RandomSelection_chosen_ent.m_wepset; + STAT(WEAPONS, receiver) |= RandomSelection_chosen_ent.m_wepset; if (RandomSelection_chosen_ent.ammo_type == RESOURCE_NONE) { continue; @@ -801,7 +774,7 @@ float Item_GiveTo(entity item, entity player) if(player.(weaponentity).m_switchweapon == w_getbestweapon(player, weaponentity)) _switchweapon |= BIT(slot); - if(!(player.weapons & WepSet_FromWeapon(player.(weaponentity).m_switchweapon))) + if(!(STAT(WEAPONS, player) & WepSet_FromWeapon(player.(weaponentity).m_switchweapon))) _switchweapon |= BIT(slot); } } @@ -818,7 +791,7 @@ float Item_GiveTo(entity item, entity player) { WepSet w; w = item.weapons; - w &= ~player.weapons; + w &= ~STAT(WEAPONS, player); if (w || (item.spawnshieldtime && item.pickup_anyway > 0)) { @@ -1067,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(player.weapons & item.weapons) + if(STAT(WEAPONS, player) & item.weapons) { // If I can pick it up if(!item.spawnshieldtime) @@ -1078,7 +1051,7 @@ float weapon_pickupevalfunc(entity player, entity item) // reduce weapon value if bot already got a good arsenal float c = 1; int weapons_value = 0; - FOREACH(Weapons, it != WEP_Null && (player.weapons & it.m_wepset), { + FOREACH(Weapons, it != WEP_Null && (STAT(WEAPONS, player) & it.m_wepset), { weapons_value += it.bot_pickupbasevalue; }); c -= bound(0, weapons_value / 20000, 1) * 0.5; @@ -1112,7 +1085,7 @@ float ammo_pickupevalfunc(entity player, entity item) else { FOREACH(Weapons, it != WEP_Null, { - if(!(player.weapons & (it.m_wepset))) + if(!(STAT(WEAPONS, player) & (it.m_wepset))) continue; switch(it.ammo_type) @@ -1609,30 +1582,30 @@ float GiveWeapon(entity e, float wpn, float op, float val) { WepSet v0, v1; WepSet s = WepSet_FromWeapon(Weapons_from(wpn)); - v0 = (e.weapons & s); + v0 = (STAT(WEAPONS, e) & s); switch(op) { case OP_SET: if(val > 0) - e.weapons |= s; + STAT(WEAPONS, e) |= s; else - e.weapons &= ~s; + STAT(WEAPONS, e) &= ~s; break; case OP_MIN: case OP_PLUS: if(val > 0) - e.weapons |= s; + STAT(WEAPONS, e) |= s; break; case OP_MAX: if(val <= 0) - e.weapons &= ~s; + STAT(WEAPONS, e) &= ~s; break; case OP_MINUS: if(val > 0) - e.weapons &= ~s; + STAT(WEAPONS, e) &= ~s; break; } - v1 = (e.weapons & s); + v1 = (STAT(WEAPONS, e) & s); return (v0 != v1); } @@ -1850,7 +1823,7 @@ float GiveItems(entity e, float beginarg, float endarg) FOREACH(Weapons, it != WEP_Null, { POSTGIVE_WEAPON(e, it, SND_WEAPONPICKUP, SND_Null); if(!(save_weapons & (it.m_wepset))) - if(e.weapons & (it.m_wepset)) + if(STAT(WEAPONS, e) & (it.m_wepset)) it.wr_init(it); }); POSTGIVE_VALUE(e, strength_finished, 1, SND_POWERUP, SND_POWEROFF); @@ -1866,7 +1839,7 @@ float GiveItems(entity e, float beginarg, float endarg) POSTGIVE_VALUE_ROT(e, health, 1, pauserothealth_finished, autocvar_g_balance_pause_health_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, SND_MEGAHEALTH, SND_Null); if(e.superweapons_finished <= 0) - if(e.weapons & WEPSET_SUPERWEAPONS) + if(STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS) e.superweapons_finished = autocvar_g_balance_superweapons_time; if(e.strength_finished <= 0) @@ -1886,7 +1859,7 @@ float GiveItems(entity e, float beginarg, float endarg) { .entity weaponentity = weaponentities[slot]; if(e.(weaponentity).m_weapon != WEP_Null || slot == 0) - if(!(e.weapons & WepSet_FromWeapon(e.(weaponentity).m_switchweapon))) + if(!(STAT(WEAPONS, e) & WepSet_FromWeapon(e.(weaponentity).m_switchweapon))) _switchweapon |= BIT(slot); } diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index 315a10037..bd46599aa 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -124,9 +124,9 @@ void GiveSound(entity e, float v0, float v1, float t, Sound snd_incr, Sound snd_ void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .float regenfield, float regentime); -#define PREGIVE_WEAPONS(e) WepSet save_weapons; save_weapons = e.weapons +#define PREGIVE_WEAPONS(e) WepSet save_weapons; save_weapons = STAT(WEAPONS, e) #define PREGIVE(e,f) float save_##f; save_##f = (e).f -#define POSTGIVE_WEAPON(e,b,snd_incr,snd_decr) GiveSound((e), !!(save_weapons & WepSet_FromWeapon(b)), !!(e.weapons & WepSet_FromWeapon(b)), 0, snd_incr, snd_decr) +#define POSTGIVE_WEAPON(e,b,snd_incr,snd_decr) GiveSound((e), !!(save_weapons & WepSet_FromWeapon(b)), !!(STAT(WEAPONS, e) & WepSet_FromWeapon(b)), 0, snd_incr, snd_decr) #define POSTGIVE_BIT(e,f,b,snd_incr,snd_decr) GiveSound((e), save_##f & (b), (e).f & (b), 0, snd_incr, snd_decr) #define POSTGIVE_VALUE(e,f,t,snd_incr,snd_decr) GiveSound((e), save_##f, (e).f, t, snd_incr, snd_decr) #define POSTGIVE_VALUE_ROT(e,f,t,rotfield,rottime,regenfield,regentime,snd_incr,snd_decr) GiveRot((e), save_##f, (e).f, rotfield, rottime, regenfield, regentime); GiveSound((e), save_##f, (e).f, t, snd_incr, snd_decr) diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 898889149..b7c65ed96 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -196,7 +196,11 @@ string W_FixWeaponOrder_ForceComplete(string order) void W_RandomWeapons(entity e, 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) { @@ -209,7 +213,11 @@ 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 } string GetAmmoPicture(int ammotype) diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index f778e164b..ca460f089 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -37,7 +37,7 @@ void W_Porto_Fail(entity this, float failhard) this.realowner.porto_current = NULL; - if(this.cnt < 0 && !failhard && this.realowner.playerid == this.playerid && !IS_DEAD(this.realowner) && !(this.realowner.weapons & WEPSET(PORTO))) + if(this.cnt < 0 && !failhard && this.realowner.playerid == this.playerid && !IS_DEAD(this.realowner) && !(STAT(WEAPONS, this.realowner) & WEPSET(PORTO))) { setsize(this, '-16 -16 0', '16 16 32'); setorigin(this, this.origin + trace_plane_normal); diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 7ce6efa45..f52974020 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -109,7 +109,7 @@ void havocbot_ai(entity this) this.aistatus |= AI_STATUS_ATTACKING; this.aistatus &= ~AI_STATUS_ROAMING; - if(this.weapons) + if(STAT(WEAPONS, this)) { if (autocvar_bot_nofire || IS_INDEPENDENT_PLAYER(this)) { @@ -204,7 +204,7 @@ void havocbot_ai(entity this) if(this.(weaponentity).clip_load >= 0) // only if we're not reloading a weapon already { FOREACH(Weapons, it != WEP_Null, { - if((this.weapons & (it.m_wepset)) && (it.spawnflags & WEP_FLAG_RELOADABLE) && (this.(weaponentity).weapon_load[it.m_id] < it.reloading_ammo)) + if((STAT(WEAPONS, this) & (it.m_wepset)) && (it.spawnflags & WEP_FLAG_RELOADABLE) && (this.(weaponentity).weapon_load[it.m_id] < it.reloading_ammo)) { this.(weaponentity).m_switchweapon = it; break; @@ -1238,7 +1238,7 @@ LABEL(scan_targets) // I want to do a second scan if no enemy was found or I don't have weapons // TODO: Perform the scan when using the rifle (requires changes on the rifle code) - if(best || this.weapons) // || this.weapon == WEP_RIFLE.m_id + if(best || STAT(WEAPONS, this)) // || this.weapon == WEP_RIFLE.m_id break; if(scan_transparent) break; diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index e46943601..5fe9e3ada 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 && !(player.weapons & item.weapons)) {return true;} + if (item.weapons && !(STAT(WEAPONS, player) & item.weapons)) {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 976d5a7b9..9620ce545 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 = this.weapons; + this.personal.weapons = 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; - this.weapons = this.personal.weapons; + STAT(WEAPONS, this) = this.personal.weapons; 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/client.qc b/qcsrc/server/client.qc index 270a4d1af..c17a12367 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -361,7 +361,7 @@ void PutObserverInServer(entity this) this.revival_time = 0; this.items = 0; - this.weapons = '0 0 0'; + STAT(WEAPONS, this) = '0 0 0'; this.drawonlytoclient = this; this.viewloc = NULL; @@ -563,7 +563,7 @@ void PutPlayerInServer(entity this) this.ammo_fuel = warmup_start_ammo_fuel; this.health = warmup_start_health; this.armorvalue = warmup_start_armorvalue; - this.weapons = WARMUP_START_WEAPONS; + STAT(WEAPONS, this) = WARMUP_START_WEAPONS; } else { this.ammo_shells = start_ammo_shells; this.ammo_nails = start_ammo_nails; @@ -573,7 +573,7 @@ void PutPlayerInServer(entity this) this.ammo_fuel = start_ammo_fuel; this.health = start_health; this.armorvalue = start_armorvalue; - this.weapons = start_weapons; + STAT(WEAPONS, this) = start_weapons; if (MUTATOR_CALLHOOK(ForbidRandomStartWeapons, this) == false) { GiveRandomWeapons(this, random_start_weapons_count, @@ -584,7 +584,7 @@ void PutPlayerInServer(entity this) PS(this).dual_weapons = '0 0 0'; - this.superweapons_finished = (this.weapons & WEPSET_SUPERWEAPONS) ? time + autocvar_g_balance_superweapons_time : 0; + this.superweapons_finished = (STAT(WEAPONS, this) & WEPSET_SUPERWEAPONS) ? time + autocvar_g_balance_superweapons_time : 0; this.items = start_items; @@ -1549,7 +1549,7 @@ void player_powerups(entity this) } if (this.items & IT_SUPERWEAPON) { - if (!(this.weapons & WEPSET_SUPERWEAPONS)) + if (!(STAT(WEAPONS, this) & WEPSET_SUPERWEAPONS)) { this.superweapons_finished = 0; this.items = this.items - (this.items & IT_SUPERWEAPON); @@ -1566,13 +1566,13 @@ void player_powerups(entity this) if (time > this.superweapons_finished) { this.items = this.items - (this.items & IT_SUPERWEAPON); - this.weapons &= ~WEPSET_SUPERWEAPONS; + STAT(WEAPONS, this) &= ~WEPSET_SUPERWEAPONS; //Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_SUPERWEAPON_BROKEN, this.netname); Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_SUPERWEAPON_BROKEN); } } } - else if(this.weapons & WEPSET_SUPERWEAPONS) + else if(STAT(WEAPONS, this) & WEPSET_SUPERWEAPONS) { if (time < this.superweapons_finished || (this.items & IT_UNLIMITED_SUPERWEAPONS)) { @@ -1584,7 +1584,7 @@ void player_powerups(entity this) else { this.superweapons_finished = 0; - this.weapons &= ~WEPSET_SUPERWEAPONS; + STAT(WEAPONS, this) &= ~WEPSET_SUPERWEAPONS; } } else @@ -1786,7 +1786,7 @@ void SpectateCopy(entity this, entity spectatee) this.invincible_finished = spectatee.invincible_finished; this.superweapons_finished = spectatee.superweapons_finished; STAT(PRESSED_KEYS, this) = STAT(PRESSED_KEYS, spectatee); - this.weapons = spectatee.weapons; + STAT(WEAPONS, this) = STAT(WEAPONS, spectatee); this.punchangle = spectatee.punchangle; this.view_ofs = spectatee.view_ofs; this.velocity = spectatee.velocity; diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index a1e129402..4f973bb9e 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -107,7 +107,7 @@ void target_init_use(entity this, entity actor, entity trigger) SetResourceAmount(actor, RESOURCE_PLASMA, start_ammo_plasma); SetResourceAmount(actor, RESOURCE_FUEL, start_ammo_fuel); - actor.weapons = start_weapons; + STAT(WEAPONS, actor) = start_weapons; if (this.spawnflags & 32) { // TODO diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index afe5814a5..bb25fd097 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -190,7 +190,8 @@ void FixClientCvars(entity e); // WEAPONTODO: remove this //WepSet weaponsInMap; -#define weapons _STAT(WEAPONS) +//#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 diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index f87bce9e8..ea1f2aee8 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -66,7 +66,7 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype, .entity we // 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 = attacker.(weaponentity).m_weapon; - else if(!(attacker.weapons & (culprit.m_wepset))) culprit = attacker.(weaponentity).m_weapon; + else if(!(STAT(WEAPONS, attacker) & (culprit.m_wepset))) culprit = attacker.(weaponentity).m_weapon; if(g_weaponarena_random_with_blaster && culprit == WEP_BLASTER) // WEAPONTODO: Shouldn't this be in a mutator? { @@ -85,7 +85,7 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype, .entity we GiveFrags_randomweapons.weapons = start_weapons; // all others (including the culprit): remove - GiveFrags_randomweapons.weapons &= ~attacker.weapons; + GiveFrags_randomweapons.weapons &= ~STAT(WEAPONS, attacker); GiveFrags_randomweapons.weapons &= ~(culprit.m_wepset); // among the remaining ones, choose one by random @@ -93,13 +93,13 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype, .entity we if(GiveFrags_randomweapons.weapons) { - attacker.weapons |= GiveFrags_randomweapons.weapons; - attacker.weapons &= ~(culprit.m_wepset); + STAT(WEAPONS, attacker) |= GiveFrags_randomweapons.weapons; + STAT(WEAPONS, attacker) &= ~(culprit.m_wepset); } } // after a frag, choose another random weapon set - if (!(attacker.weapons & WepSet_FromWeapon(attacker.(weaponentity).m_weapon))) + if (!(STAT(WEAPONS, attacker) & WepSet_FromWeapon(attacker.(weaponentity).m_weapon))) W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker, weaponentity), weaponentity); } diff --git a/qcsrc/server/weapons/common.qc b/qcsrc/server/weapons/common.qc index 90aca172c..06615c4ea 100644 --- a/qcsrc/server/weapons/common.qc +++ b/qcsrc/server/weapons/common.qc @@ -30,7 +30,7 @@ void W_GiveWeapon(entity e, int wep) { if (!wep) return; - e.weapons |= WepSet_FromWeapon(Weapons_from(wep)); + STAT(WEAPONS, e) |= WepSet_FromWeapon(Weapons_from(wep)); if (IS_PLAYER(e)) { Send_Notification(NOTIF_ONE, e, MSG_MULTI, ITEM_WEAPON_GOT, wep); diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index f059dfba9..c2a9c32ac 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -52,7 +52,7 @@ bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andam // ignore hook button when using other offhand equipment if (this.offhand != OFFHAND_HOOK) - if (wpn == WEP_HOOK && !((this.weapons | weaponsInMap) & WepSet_FromWeapon(wpn))) + if (wpn == WEP_HOOK && !((STAT(WEAPONS, this) | weaponsInMap) & WepSet_FromWeapon(wpn))) complain = 0; if (complain) @@ -66,7 +66,7 @@ bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andam } if (autocvar_g_weaponswitch_debug == 2 && weaponslot(weaponentity) > 0 && !(wpn.spawnflags & WEP_FLAG_DUALWIELD) && !(PS(this).dual_weapons & wpn.m_wepset)) return false; // no complaints needed - if (this.weapons & WepSet_FromWeapon(wpn)) + if (STAT(WEAPONS, this) & WepSet_FromWeapon(wpn)) { if (andammo) { @@ -161,12 +161,12 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl FOREACH(Weapons, it != WEP_Null, { if(i != weaponwant) if(it.impulse == imp || imp < 0) - if((this.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset))) + if((STAT(WEAPONS, this) & (it.m_wepset)) || (weaponsInMap & (it.m_wepset))) have_other = true; }); // skip weapons we don't own that aren't normal and aren't in the map - if(!(this.weapons & wepset)) + if(!(STAT(WEAPONS, this) & wepset)) if(!(weaponsInMap & wepset)) if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other) continue; @@ -217,12 +217,12 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl FOREACH(Weapons, it != WEP_Null, { if(i != weaponwant) if(it.impulse == imp || imp < 0) - if((this.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset))) + if((STAT(WEAPONS, this) & (it.m_wepset)) || (weaponsInMap & (it.m_wepset))) have_other = true; }); // skip weapons we don't own that aren't normal and aren't in the map - if(!(this.weapons & wepset)) + if(!(STAT(WEAPONS, this) & wepset)) if(!(weaponsInMap & wepset)) if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other) continue; @@ -252,11 +252,11 @@ void W_SwitchToOtherWeapon(entity this, .entity weaponentity) // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway) Weapon ww; WepSet set = WepSet_FromWeapon(this.(weaponentity).m_weapon); - if (this.weapons & set) + if (STAT(WEAPONS, this) & set) { - this.weapons &= ~set; + STAT(WEAPONS, this) &= ~set; ww = w_getbestweapon(this, weaponentity); - this.weapons |= set; + STAT(WEAPONS, this) |= set; } else { diff --git a/qcsrc/server/weapons/throwing.qc b/qcsrc/server/weapons/throwing.qc index ae745efd6..821a02327 100644 --- a/qcsrc/server/weapons/throwing.qc +++ b/qcsrc/server/weapons/throwing.qc @@ -65,7 +65,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto int superweapons = 1; FOREACH(Weapons, it != WEP_Null, { WepSet set = it.m_wepset; - if((set & WEPSET_SUPERWEAPONS) && (own.weapons & set)) ++superweapons; + if((set & WEPSET_SUPERWEAPONS) && (STAT(WEAPONS, own) & set)) ++superweapons; }); if(superweapons <= 1) { @@ -183,8 +183,8 @@ void W_ThrowWeapon(entity this, .entity weaponentity, vector velo, vector delta, return; WepSet set = WepSet_FromWeapon(w); - if(!(this.weapons & set)) return; - this.weapons &= ~set; + if(!(STAT(WEAPONS, this) & set)) return; + STAT(WEAPONS, this) &= ~set; W_SwitchWeapon_Force(this, w_getbestweapon(this, weaponentity), weaponentity); string a = W_ThrowNewWeapon(this, w.m_id, doreduce, this.origin + delta, velo, weaponentity); @@ -197,7 +197,7 @@ void SpawnThrownWeapon(entity this, vector org, Weapon wep, .entity weaponentity { //entity wep = this.(weaponentity).m_weapon; - if(this.weapons & WepSet_FromWeapon(wep)) + if(STAT(WEAPONS, this) & WepSet_FromWeapon(wep)) if(W_IsWeaponThrowable(this, wep.m_id)) W_ThrowNewWeapon(this, wep.m_id, false, org, randomvec() * 125 + '0 0 200', weaponentity); } diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 8bfcbb79c..011d5cbc1 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -559,7 +559,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity) // server framerate is very low and the weapon fire rate very high for (int c = 0; c < W_TICSPERFRAME; ++c) { - if (w != WEP_Null && !(actor.weapons & WepSet_FromWeapon(w))) + if (w != WEP_Null && !(STAT(WEAPONS, actor) & WepSet_FromWeapon(w))) { if (this.m_weapon == this.m_switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity); w = WEP_Null; @@ -576,7 +576,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity) key_pressed = false; Weapon off = actor.offhand; - if (off && (!(actor.weapons & WEPSET(HOOK)) || off != OFFHAND_HOOK)) + if (off && (!(STAT(WEAPONS, actor) & WEPSET(HOOK)) || off != OFFHAND_HOOK)) { if (off.offhand_think) off.offhand_think(off, actor, key_pressed); }