r4282 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Tue Sep 2 07:12:09 EDT 2008
Author: div0
Date: 2008-09-02 07:12:09 -0400 (Tue, 02 Sep 2008)
New Revision: 4282
Modified:
trunk/data/qcsrc/server/cl_weapons.qc
Log:
slightly improve weapon cycle functions
Modified: trunk/data/qcsrc/server/cl_weapons.qc
===================================================================
--- trunk/data/qcsrc/server/cl_weapons.qc 2008-09-02 11:08:01 UTC (rev 4281)
+++ trunk/data/qcsrc/server/cl_weapons.qc 2008-09-02 11:12:09 UTC (rev 4282)
@@ -217,7 +217,7 @@
self.switchweapon = weaponwant;
};
-void W_CycleWeapon(string weaponorder, float dir)
+float W_GetCycleWeapon(string weaponorder, float dir)
{
float n, i, weaponwant, first_valid, prev_valid, switchtonext, switchtolast;
n = tokenize(weaponorder);
@@ -233,10 +233,7 @@
if(client_hasweapon(self, weaponwant, TRUE, FALSE))
{
if(switchtonext)
- {
- W_SwitchWeapon(weaponwant);
- return;
- }
+ return weaponwant;
if(first_valid < 0)
first_valid = weaponwant;
prev_valid = weaponwant;
@@ -245,7 +242,7 @@
if(dir >= 0)
switchtonext = 1;
else if(prev_valid >= 0)
- W_SwitchWeapon(prev_valid);
+ return prev_valid;
else
{
switchtolast = 1;
@@ -257,15 +254,24 @@
if(first_valid >= 0)
{
if(switchtolast)
- W_SwitchWeapon(prev_valid);
+ return prev_valid;
else
- W_SwitchWeapon(first_valid);
- return;
+ return first_valid;
}
- // none available
- sprint(self, "You do not have any of the specified weapons.\n");
+ return -1;
}
+void W_CycleWeapon(string weaponorder, float dir)
+{
+ float w;
+ w = W_GetCycleWeapon(weaponorder, dir);
+ if(w >= 0)
+ W_SwitchWeapon(w);
+ else
+ // none available
+ sprint(self, "You do not have any of the specified weapons.\n");
+}
+
// Bringed back weapon frame
void W_WeaponFrame()
{
More information about the nexuiz-commits
mailing list