From: Jānis Rūcis <parasti@gmail.com>
Date: Wed, 26 May 2010 17:29:18 +0000 (+0300)
Subject: Attempt to sanitize sv_jumpspeedcap_min/sv_jumpspeedcap_max
X-Git-Tag: xonotic-v0.1.0preview~570^2^2~1
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5655f0dd36ff7b0f7d9c571695902e45c534621f;p=xonotic%2Fxonotic-data.pk3dir.git

Attempt to sanitize sv_jumpspeedcap_min/sv_jumpspeedcap_max
---

diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg
index a30856168a..ba35cce8a6 100644
--- a/defaultXonotic.cfg
+++ b/defaultXonotic.cfg
@@ -330,9 +330,9 @@ set sv_player_crouch_maxs "16 16 25" "maxs of a crouched playermodel"
 
 set sv_pogostick 1 "don't require releasing the space bar for jumping again"
 set sv_doublejump 0 "allow Quake 2-style double jumps"
-set sv_jumpspeedcap_min "" "wont perform a doublejump if z-axis speed is higher than sv_jumpvelocity * this"
-set sv_jumpspeedcap_max "" "wont perform a doublejump if z-axis speed is higher than sv_jumpvelocity * this"
-set sv_jumpspeedcap_max_disable_on_ramps 0 "disable max jumpspeedcap on ramps to preserve the old rampjump style"
+set sv_jumpspeedcap_min "" "lower bound on the baseline velocity of a jump; final velocity will be >= (jumpheight * min + jumpheight)"
+set sv_jumpspeedcap_max "" "upper bound on the baseline velocity of a jump; final velocity will be <= (jumpheight * max + jumpheight)"
+set sv_jumpspeedcap_max_disable_on_ramps 0 "disable upper baseline velocity bound on ramps to preserve the old rampjump style"
 
 seta sv_precacheplayermodels 1
 seta sv_precacheweapons 0
diff --git a/qcsrc/server/cl_physics.qc b/qcsrc/server/cl_physics.qc
index c0aa4ffb1f..0051d8759a 100644
--- a/qcsrc/server/cl_physics.qc
+++ b/qcsrc/server/cl_physics.qc
@@ -95,16 +95,34 @@ void PlayerJump (void)
 		mjumpheight = mjumpheight * cvar("g_minstagib_speed_jumpheight");
 	}
 
+	// sv_jumpspeedcap_min/sv_jumpspeedcap_max act as baseline
+	// velocity bounds.  Final velocity is bound between (jumpheight *
+	// min + jumpheight) and (jumpheight * max + jumpheight);
+
 	if(cvar_string("sv_jumpspeedcap_min") != "")
-		self.velocity_z = max(cvar("sv_jumpvelocity") * cvar("sv_jumpspeedcap_min"), self.velocity_z);
-	if(cvar_string("sv_jumpspeedcap_max") != "") {
+	{
+		float minjumpspeed;
+
+		minjumpspeed = mjumpheight * cvar("sv_jumpspeedcap_min");
+
+		if (self.velocity_z < minjumpspeed)
+			mjumpheight += minjumpspeed - self.velocity_z;
+	}
+
+	if(cvar_string("sv_jumpspeedcap_max") != "")
+	{
+		// don't do jump speedcaps on ramps to preserve old xonotic ramjump style
 		tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
-		if(trace_fraction < 1 && trace_plane_normal_z < 0.98 && cvar("sv_jumpspeedcap_max_disable_on_ramps")) {
-			// don't do jump speedcaps on ramps to preserve old xonotic ramjump style
-			//print("Trace plane normal z: ", ftos(trace_plane_normal_z), ", disabling speed cap!\n");
+
+		if(!(trace_fraction < 1 && trace_plane_normal_z < 0.98 && cvar("sv_jumpspeedcap_max_disable_on_ramps")))
+		{
+			float maxjumpspeed;
+
+			maxjumpspeed = mjumpheight * cvar("sv_jumpspeedcap_max");
+
+			if (self.velocity_z > maxjumpspeed)
+				mjumpheight -= self.velocity_z - maxjumpspeed;
 		}
-		else
-			self.velocity_z = min(cvar("sv_jumpvelocity") * cvar("sv_jumpspeedcap_max"), self.velocity_z) + trace_ent.velocity_z;
 	}
 
 	if(!(self.lastflags & FL_ONGROUND))