From aeaaffcf07f0394ff77b4164383a1e5895cfebd3 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 1 Jun 2020 00:50:15 +1000 Subject: [PATCH] Implement wrath's workaround for #152: only apply nogravityonground while not moving --- cl_input.c | 8 ++++++-- sv_phys.c | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cl_input.c b/cl_input.c index ed7c44c3..a3ed56da 100644 --- a/cl_input.c +++ b/cl_input.c @@ -1312,6 +1312,7 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) vec3_t wishdir; vec3_t yawangles; trace_t trace; + qboolean moving; // jump if on ground with jump button pressed but only if it has been // released at least once since the last jump @@ -1378,6 +1379,7 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) VectorMA(s->velocity, accelspeed, wishdir, s->velocity); } gravity = cl.movevars_gravity * cl.movevars_entgravity * s->cmd.frametime; + moving = s->velocity[0] || s->velocity[1]; if(!(cl.moveflags & MOVEFLAG_NOGRAVITYONGROUND)) { if(cl.moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE) @@ -1387,9 +1389,10 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) } if (cls.protocol == PROTOCOL_QUAKEWORLD) s->velocity[2] = 0; + moving = s->velocity[0] || s->velocity[1]; if (VectorLength2(s->velocity)) CL_ClientMovement_Move(s); - if(!(cl.moveflags & MOVEFLAG_NOGRAVITYONGROUND) || !s->onground) + if(!(cl.moveflags & MOVEFLAG_NOGRAVITYONGROUND) || !s->onground || (s->onground && moving)) { if(cl.moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE) s->velocity[2] -= gravity * 0.5f; @@ -1448,8 +1451,9 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) s->velocity[2] -= gravity * 0.5f; else s->velocity[2] -= gravity; + moving = s->velocity[0] || s->velocity[1]; CL_ClientMovement_Move(s); - if(!(cl.moveflags & MOVEFLAG_NOGRAVITYONGROUND) || !s->onground) + if(!(cl.moveflags & MOVEFLAG_NOGRAVITYONGROUND) || !s->onground || (s->onground && moving)) { if(cl.moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE) s->velocity[2] -= gravity * 0.5f; diff --git a/sv_phys.c b/sv_phys.c index 9964c362..3c58d62d 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -1207,6 +1207,7 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo vec3_t end; #endif trace_t trace; + qboolean moving; if (time <= 0) return 0; gravity = 0; @@ -1216,7 +1217,7 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo if(applygravity) { gravity = SV_Gravity(ent); - + moving = PRVM_serveredictvector(ent, velocity)[0] || PRVM_serveredictvector(ent, velocity)[1]; if(!sv_gameplayfix_nogravityonground.integer || !((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND)) { if (sv_gameplayfix_gravityunaffectedbyticrate.integer) @@ -1420,9 +1421,11 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo if (sv_gameplayfix_easierwaterjump.integer && ((int)PRVM_serveredictfloat(ent, flags) & FL_WATERJUMP) && !(blocked & 8)) VectorCopy(primal_velocity, PRVM_serveredictvector(ent, velocity)); + // Mario: this workaround introduces a new bug: sliding down ramps occurs when moving sideways + moving = PRVM_serveredictvector(ent, velocity)[0] || PRVM_serveredictvector(ent, velocity)[1]; if(applygravity) { - if(!sv_gameplayfix_nogravityonground.integer || !((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND)) + if(!sv_gameplayfix_nogravityonground.integer || !((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND) || (((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND) && moving)) { if (sv_gameplayfix_gravityunaffectedbyticrate.integer) PRVM_serveredictvector(ent, velocity)[2] -= gravity * 0.5f; -- 2.39.2