X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Fweaponsystem.qc;h=c7e365614b63e46fedd11c6a58e714903d1c9fb3;hb=f1296f5b79150dee1992cefa19c286851451df2d;hp=f8949b15601919e1b863084a1e5653ab3f94d9c2;hpb=19e5fa4ee9a0bb59c1cec92a1b0501b14f8ccb63;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index f8949b156..c7e365614 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -5,6 +5,7 @@ #include "../command/common.qh" #include "../mutators/_mod.qh" #include "../round_handler.qh" +#include "../resources.qh" #include #include #include @@ -471,6 +472,8 @@ void W_WeaponFrame(Player actor, .entity weaponentity) if (this.m_switchweapon == WEP_Null) { + if (this.state != WS_CLEAR) + w_ready(this.m_weapon, actor, weaponentity, button_atck | (button_atck2 << 1)); this.m_weapon = WEP_Null; this.m_switchingweapon = WEP_Null; this.state = WS_CLEAR; @@ -668,21 +671,22 @@ void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponenti w_ent.clip_load -= ammo_use; w_ent.(weapon_load[w_ent.m_weapon.m_id]) = w_ent.clip_load; } - else if (wep.ammo_field != ammo_none) + else if (wep.ammo_type != RESOURCE_NONE) { - actor.(wep.ammo_field) -= ammo_use; - if (actor.(wep.ammo_field) < 0) + float ammo = GetResourceAmount(actor, wep.ammo_type); + if (ammo < ammo_use) { backtrace(sprintf( "W_DecreaseAmmo(%.2f): '%s' subtracted too much %s from '%s', resulting with '%.2f' left... " "Please notify Samual immediately with a copy of this backtrace!\n", ammo_use, wep.netname, - GetAmmoPicture(wep.ammo_field), + GetAmmoPicture(wep.ammo_type), actor.netname, - actor.(wep.ammo_field) + ammo )); } + SetResourceAmount(actor, wep.ammo_type, ammo - ammo_use); } } @@ -702,16 +706,17 @@ void W_ReloadedAndReady(Weapon thiswep, entity actor, .entity weaponentity, int w_ent.clip_load = w_ent.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load - if (!w_ent.reload_ammo_min || (actor.items & IT_UNLIMITED_WEAPON_AMMO) || wpn.ammo_field == ammo_none) + if (!w_ent.reload_ammo_min || (actor.items & IT_UNLIMITED_WEAPON_AMMO) || wpn.ammo_type == RESOURCE_NONE) { w_ent.clip_load = w_ent.reload_ammo_amount; } else { // make sure we don't add more ammo than we have - float load = min(w_ent.reload_ammo_amount - w_ent.clip_load, actor.(wpn.ammo_field)); + float ammo = GetResourceAmount(actor, wpn.ammo_type); + float load = min(w_ent.reload_ammo_amount - w_ent.clip_load, ammo); w_ent.clip_load += load; - actor.(wpn.ammo_field) -= load; + SetResourceAmount(actor, wpn.ammo_type, ammo - load); } w_ent.(weapon_load[w_ent.m_weapon.m_id]) = w_ent.clip_load; @@ -754,9 +759,9 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen if (this.clip_load >= this.reload_ammo_amount) return; // no ammo, so nothing to load - if (e.ammo_field != ammo_none) + if (e.ammo_type != RESOURCE_NONE) { - if (!actor.(e.ammo_field) && this.reload_ammo_min) + if (!GetResourceAmount(actor, e.ammo_type) && this.reload_ammo_min) { if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) {