From d4f2ef6f6527dc6cb655f32b5010ca07d60cba8f Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Fri, 11 Feb 2011 22:35:37 +0200 Subject: [PATCH] Attempt to sort the code in a better way --- qcsrc/server/cl_weaponsystem.qc | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 2c8fd6cbd..83f8745da 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -1699,13 +1699,6 @@ void W_ReloadEnd() void W_ReloadStart() { - // return if reloading is disabled for this weapon - if(!self.reload_ammo_amount) - return; - - if(!W_ReloadCheck(self.(self.current_ammo), self.reload_ammo_min)) - return; - sound (self, CHAN_WEAPON2, self.reload_sound, VOL_BASE, ATTN_NORM); // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon, @@ -1722,18 +1715,31 @@ void W_ReloadStart() void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, string sent_sound) { + // set global values to work with + self.reload_ammo_min = sent_ammo_min; + self.reload_ammo_amount = sent_ammo_amount; + self.reload_time = sent_time; + self.reload_sound = sent_sound; + entity e; e = get_weaponinfo(self.weapon); - if not(e.spawnflags & WEP_FLAG_RELOADABLE) // don't reload weapons that don't have the RELOADABLE flag + + // check if we can reload or not + + // don't reload weapons that don't have the RELOADABLE flag + if not(e.spawnflags & WEP_FLAG_RELOADABLE) { - dprint("Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE spawnflag. Fix your code!"); + dprint("Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE flag. Fix your code!\n"); return; } - self.reload_ammo_min = sent_ammo_min; - self.reload_ammo_amount = sent_ammo_amount; - self.reload_time = sent_time; - self.reload_sound = sent_sound; + // return if reloading is disabled for this weapon + if(!self.reload_ammo_amount) + return; + + if(!W_ReloadCheck(self.(self.current_ammo), self.reload_ammo_min)) + return; + // now we can begin the actual reloading W_ReloadStart(); } \ No newline at end of file -- 2.39.2