]> de.git.xonotic.org Git - voretournament/voretournament.git/commitdiff
Move code in an already existing function, as that is better
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 2 Mar 2011 21:52:21 +0000 (23:52 +0200)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 2 Mar 2011 21:52:21 +0000 (23:52 +0200)
data/qcsrc/server/cl_weaponsystem.qc

index 004442c9e4242d0a3045e44fcfcec01af91746e2..8b06407c500c1bcbc39baed1823087243fa9ba20 100644 (file)
@@ -1567,8 +1567,42 @@ void W_DecreaseAmmo(.float ammo_type, float ammo_use, float ammo_reload)
 .float reload_complain;\r
 .string reload_sound;\r
 \r
-float W_ReloadCheck()\r
+void W_ReloadedAndReady()\r
 {\r
+       // finish the reloading process, and do the ammo transfer\r
+\r
+       self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading\r
+\r
+       // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load\r
+       if(!self.reload_ammo_min)\r
+               self.clip_load = self.reload_ammo_amount;\r
+       else\r
+       {\r
+               while(self.clip_load < self.reload_ammo_amount && self.(self.current_ammo)) // make sure we don't add more ammo than we have\r
+               {\r
+                       self.clip_load += 1;\r
+                       self.(self.current_ammo) -= 1;\r
+               }\r
+       }\r
+       self.weapon_load[self.weapon] = self.clip_load;\r
+\r
+       // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon,\r
+       // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,\r
+       // so your weapon is disabled for a few seconds without reason\r
+\r
+       //ATTACK_FINISHED(self) -= self.reload_time - 1;\r
+\r
+       w_ready();\r
+}\r
+\r
+void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, string sent_sound)\r
+{\r
+       // set global values to work with\r
+       self.reload_ammo_min = sent_ammo_min;\r
+       self.reload_ammo_amount = sent_ammo_amount;\r
+       self.reload_time = sent_time;\r
+       self.reload_sound = sent_sound;\r
+\r
        // check if we meet the necessary conditions to reload\r
 \r
        entity e;\r
@@ -1578,16 +1612,16 @@ float W_ReloadCheck()
        if not(e.spawnflags & WEP_FLAG_RELOADABLE)\r
        {\r
                dprint("Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE flag. Fix your code!\n");\r
-               return FALSE;\r
+               return;\r
        }\r
 \r
        // return if reloading is disabled for this weapon\r
        if(!self.reload_ammo_amount)\r
-               return FALSE;\r
+               return;\r
 \r
        // our weapon is fully loaded, no need to reload\r
        if (self.clip_load >= self.reload_ammo_amount)\r
-               return FALSE;\r
+               return;\r
 \r
        // no ammo, so nothing to load\r
        if(!self.(self.current_ammo) && self.reload_ammo_min)\r
@@ -1604,60 +1638,18 @@ float W_ReloadCheck()
                        self.clip_load = -1; // reload later\r
                        W_SwitchToOtherWeapon(self);\r
                }\r
-               return FALSE;\r
+               return;\r
        }\r
 \r
        if (self.weaponentity)\r
        {\r
                if (self.weaponentity.wframe == WFRAME_RELOAD)\r
-                       return FALSE;\r
+                       return;\r
 \r
                // allow switching away while reloading, but this will cause a new reload!\r
                self.weaponentity.state = WS_READY;\r
        }\r
 \r
-       return TRUE;\r
-}\r
-\r
-void W_ReloadedAndReady()\r
-{\r
-       // finish the reloading process, and do the ammo transfer\r
-\r
-       self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading\r
-\r
-       // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load\r
-       if(!self.reload_ammo_min)\r
-               self.clip_load = self.reload_ammo_amount;\r
-       else\r
-       {\r
-               while(self.clip_load < self.reload_ammo_amount && self.(self.current_ammo)) // make sure we don't add more ammo than we have\r
-               {\r
-                       self.clip_load += 1;\r
-                       self.(self.current_ammo) -= 1;\r
-               }\r
-       }\r
-       self.weapon_load[self.weapon] = self.clip_load;\r
-\r
-       // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon,\r
-       // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,\r
-       // so your weapon is disabled for a few seconds without reason\r
-\r
-       //ATTACK_FINISHED(self) -= self.reload_time - 1;\r
-\r
-       w_ready();\r
-}\r
-\r
-void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, string sent_sound)\r
-{\r
-       // set global values to work with\r
-       self.reload_ammo_min = sent_ammo_min;\r
-       self.reload_ammo_amount = sent_ammo_amount;\r
-       self.reload_time = sent_time;\r
-       self.reload_sound = sent_sound;\r
-\r
-       if(!W_ReloadCheck())\r
-               return;\r
-\r
        // now begin the reloading process\r
 \r
        sound (self, CHAN_WEAPON2, self.reload_sound, VOL_BASE, ATTN_NORM);\r