]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix an issue with jump speed caps and slopes
authorMario <zacjardine@y7mail.com>
Wed, 5 Aug 2015 14:52:33 +0000 (00:52 +1000)
committerMario <zacjardine@y7mail.com>
Wed, 5 Aug 2015 14:52:33 +0000 (00:52 +1000)
qcsrc/client/main.qc
qcsrc/common/physics.qc
qcsrc/common/physics.qh
qcsrc/common/stats.qh
qcsrc/server/autocvars.qh

index 697dbd356d968558e2e4d1f30dc684962f88a7ea..f385040ae10bcbac314dc08857ac3ec2e609cc0d 100644 (file)
@@ -119,6 +119,9 @@ void CSQC_Init(void)
        registercvar("cl_nade_type", "3");
        registercvar("cl_pokenade_type", "zombie");
 
+       registercvar("cl_jumpspeedcap_min", "");
+       registercvar("cl_jumpspeedcap_max", "");
+
        gametype = 0;
 
        // hud_fields uses strunzone on the titles!
index 5e5a9d042b16a78cd0b67fdd1a0eb15fab300e16..4143ad3b11a71e651fba7b32e129f132692ea702 100644 (file)
@@ -84,8 +84,6 @@ void Physics_AddStats()
        addstat(STAT_DOUBLEJUMP, AS_INT, stat_doublejump);
 
        // jump speed caps
-       addstat(STAT_MOVEVARS_JUMPSPEEDCAP_MIN, AS_FLOAT, stat_jumpspeedcap_min);
-       addstat(STAT_MOVEVARS_JUMPSPEEDCAP_MIN, AS_FLOAT, stat_jumpspeedcap_min);
        addstat(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, AS_INT, stat_jumpspeedcap_disable_onramps);
 
        // hacks
@@ -147,8 +145,6 @@ void Physics_UpdateStats(float maxspd_mod)
        self.stat_jetpack_maxspeed_up = PHYS_JETPACK_MAXSPEED_UP;
        self.stat_jetpack_fuel = PHYS_JETPACK_FUEL;
 
-       self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN;
-       self.stat_jumpspeedcap_max = PHYS_JUMPSPEEDCAP_MAX;
        self.stat_jumpspeedcap_disable_onramps = PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS;
 
        self.stat_sv_friction_on_land = PHYS_FRICTION_ONLAND;
@@ -602,22 +598,22 @@ bool PlayerJump (void)
        // velocity bounds.  Final velocity is bound between (jumpheight *
        // min + jumpheight) and (jumpheight * max + jumpheight);
 
-       if(PHYS_JUMPSPEEDCAP_MIN)
+       if(PHYS_JUMPSPEEDCAP_MIN != "")
        {
-               float minjumpspeed = mjumpheight * PHYS_JUMPSPEEDCAP_MIN;
+               float minjumpspeed = mjumpheight * stof(PHYS_JUMPSPEEDCAP_MIN);
 
                if (self.velocity_z < minjumpspeed)
                        mjumpheight += minjumpspeed - self.velocity_z;
        }
 
-       if(PHYS_JUMPSPEEDCAP_MAX)
+       if(PHYS_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 && PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS))
                {
-                       float maxjumpspeed = mjumpheight * PHYS_JUMPSPEEDCAP_MAX;
+                       float maxjumpspeed = mjumpheight * stof(PHYS_JUMPSPEEDCAP_MAX);
 
                        if (self.velocity_z > maxjumpspeed)
                                mjumpheight -= self.velocity_z - maxjumpspeed;
@@ -1832,6 +1828,17 @@ void PM_Main()
                stuffcmd(self, strcat("cl_sidespeed ", temps, "\n"));
                stuffcmd(self, strcat("cl_upspeed ", temps, "\n"));
        }
+
+       if(self.stat_jumpspeedcap_min != PHYS_JUMPSPEEDCAP_MIN)
+       {
+               self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN;
+               stuffcmd(self, strcat("cl_jumpspeedcap_min ", PHYS_JUMPSPEEDCAP_MIN, "\n"));
+       }
+       if(self.stat_jumpspeedcap_max != PHYS_JUMPSPEEDCAP_MAX)
+       {
+               self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MAX;
+               stuffcmd(self, strcat("cl_jumpspeedcap_max ", PHYS_JUMPSPEEDCAP_MAX, "\n"));
+       }
 #endif
 
        if(PHYS_DEAD(self))
index 17de7b22733aa414700b9b0fa7f09b4b14f1b4af..25d476b10dad4fd35a9ca5ebaf884c2476a5ff4b 100644 (file)
@@ -119,8 +119,8 @@ bool IsFlying(entity a);
        #define PHYS_BUGRIGS_REVERSE_SPINNING           getstatf(STAT_BUGRIGS_REVERSE_SPINNING)
        #define PHYS_BUGRIGS_REVERSE_STOPPING           getstatf(STAT_BUGRIGS_REVERSE_STOPPING)
 
-       #define PHYS_JUMPSPEEDCAP_MIN                           getstatf(STAT_MOVEVARS_JUMPSPEEDCAP_MIN)
-       #define PHYS_JUMPSPEEDCAP_MAX                           getstatf(STAT_MOVEVARS_JUMPSPEEDCAP_MAX)
+       #define PHYS_JUMPSPEEDCAP_MIN                           cvar_string("cl_jumpspeedcap_min")
+       #define PHYS_JUMPSPEEDCAP_MAX                           cvar_string("cl_jumpspeedcap_max")
        #define PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS       getstati(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS)
 
        #define PHYS_TRACK_CANJUMP(s)                           getstati(STAT_MOVEVARS_TRACK_CANJUMP)
@@ -191,8 +191,8 @@ bool IsFlying(entity a);
 
        .float stat_doublejump;
 
-       .float stat_jumpspeedcap_min;
-       .float stat_jumpspeedcap_max;
+       .string stat_jumpspeedcap_min;
+       .string stat_jumpspeedcap_max;
        .float stat_jumpspeedcap_disable_onramps;
 
        .float stat_jetpack_accel_side;
index fdb9da2a9266482d7dc394fa62ed3dfabdc8f946..a1a95572fbd18bd2e29bf75dc84559a71f3210fe 100644 (file)
@@ -246,8 +246,8 @@ const int STAT_GAMEPLAYFIX_EASIERWATERJUMP            = 190;
 const int STAT_MOVEVARS_FRICTION_SLICK                = 191;
 const int STAT_MOVEVARS_FRICTION_ONLAND               = 192;
 const int STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS  = 193;
-const int STAT_MOVEVARS_JUMPSPEEDCAP_MAX              = 194;
-const int STAT_MOVEVARS_JUMPSPEEDCAP_MIN              = 195;
+// 194 empty?
+// 195 empty?
 const int STAT_DOUBLEJUMP                             = 196;
 const int STAT_MOVEVARS_TRACK_CANJUMP                 = 197;
 const int STAT_MULTIJUMP_ADD                          = 198;
index d4f4786a938e0c56eedb22f7a04c0475291cfc4a..d972e379bb8d9b36c2368529ebc2365b64f28ae7 100644 (file)
@@ -625,9 +625,9 @@ float autocvar_sv_gameplayfix_q2airaccelerate;
 int autocvar_sv_gentle;
 #define autocvar_sv_gravity cvar("sv_gravity")
 string autocvar_sv_intermission_cdtrack;
-float autocvar_sv_jumpspeedcap_max;
+string autocvar_sv_jumpspeedcap_max;
 float autocvar_sv_jumpspeedcap_max_disable_on_ramps;
-float autocvar_sv_jumpspeedcap_min;
+string autocvar_sv_jumpspeedcap_min;
 float autocvar_sv_jumpvelocity;
 bool autocvar_sv_logscores_bots;
 bool autocvar_sv_logscores_console;