From 07728facea4ee14f68961b0ae8747560646c2cd7 Mon Sep 17 00:00:00 2001 From: divverent Date: Mon, 9 Jan 2012 15:12:09 +0000 Subject: [PATCH] fix c/s consistency of sv_gameplayfix_nogravityonground and sv_gameplayfix_gravityunaffectedbyticrate git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11643 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=827eab62fd4e8e50c3c25b98fd504e0b35e8cd04 --- cl_input.c | 38 ++++++++++++++++++++++++-------------- sv_phys.c | 34 +++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/cl_input.c b/cl_input.c index 51a5f8dd..bda39418 100644 --- a/cl_input.c +++ b/cl_input.c @@ -972,8 +972,12 @@ static void CL_ClientMovement_Move(cl_clientmovement_state_t *s) if (trace.fraction == 1) break; - //if (trace.plane.normal[2] > 0.7) - // s->onground = true; + // this is only really needed for nogravityonground combined with gravityunaffectedbyticrate + // I'm pretty sure I commented it out solely because it seemed redundant + // this got commented out in a change that supposedly makes the code match QW better + // so if this is broken, maybe put it in an if(cls.protocol != PROTOCOL_QUAKEWORLD) block + if (trace.plane.normal[2] > 0.7) + s->onground = true; t -= t * trace.fraction; @@ -1366,20 +1370,23 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) accelspeed = min(cl.movevars_accelerate * s->cmd.frametime * wishspeed, addspeed); VectorMA(s->velocity, accelspeed, wishdir, s->velocity); } - if(cl.moveflags & MOVEFLAG_NOGRAVITYONGROUND) - gravity = 0; - else - gravity = cl.movevars_gravity * cl.movevars_entgravity * s->cmd.frametime; - if(cl.moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE) - s->velocity[2] -= gravity * 0.5f; - else - s->velocity[2] -= gravity; + gravity = cl.movevars_gravity * cl.movevars_entgravity * s->cmd.frametime; + if(!(cl.moveflags & MOVEFLAG_NOGRAVITYONGROUND)) + { + if(cl.moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE) + s->velocity[2] -= gravity * 0.5f; + else + s->velocity[2] -= gravity; + } if (cls.protocol == PROTOCOL_QUAKEWORLD) s->velocity[2] = 0; if (VectorLength2(s->velocity)) CL_ClientMovement_Move(s); - if(cl.moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE) - s->velocity[2] -= gravity * 0.5f; + if(!(cl.moveflags & MOVEFLAG_NOGRAVITYONGROUND) || !s->onground) + { + if(cl.moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE) + s->velocity[2] -= gravity * 0.5f; + } } else { @@ -1435,8 +1442,11 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) else s->velocity[2] -= gravity; CL_ClientMovement_Move(s); - if(cl.moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE) - s->velocity[2] -= gravity * 0.5f; + if(!(cl.moveflags & MOVEFLAG_NOGRAVITYONGROUND) || !s->onground) + { + if(cl.moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE) + s->velocity[2] -= gravity * 0.5f; + } } } diff --git a/sv_phys.c b/sv_phys.c index c88ff4c4..e063526f 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -1235,23 +1235,19 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo return 0; gravity = 0; - if(sv_gameplayfix_nogravityonground.integer) - if((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND) - applygravity = false; - - if (applygravity) + if(applygravity) { - if (sv_gameplayfix_gravityunaffectedbyticrate.integer) - { - gravity = SV_Gravity(ent) * 0.5f; - PRVM_serveredictvector(ent, velocity)[2] -= gravity; - } - else + gravity = SV_Gravity(ent); + + if(!sv_gameplayfix_nogravityonground.integer || !((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND)) { - applygravity = false; - PRVM_serveredictvector(ent, velocity)[2] -= SV_Gravity(ent); + if (sv_gameplayfix_gravityunaffectedbyticrate.integer) + PRVM_serveredictvector(ent, velocity)[2] -= gravity * 0.5f; + else + PRVM_serveredictvector(ent, velocity)[2] -= gravity; } } + blocked = 0; VectorCopy(PRVM_serveredictvector(ent, velocity), original_velocity); VectorCopy(PRVM_serveredictvector(ent, velocity), primal_velocity); @@ -1437,8 +1433,16 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo // LordHavoc: this came from QW and allows you to get out of water more easily if (sv_gameplayfix_easierwaterjump.integer && ((int)PRVM_serveredictfloat(ent, flags) & FL_WATERJUMP) && !(blocked & 8)) VectorCopy(primal_velocity, PRVM_serveredictvector(ent, velocity)); - if (applygravity && !((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND)) - PRVM_serveredictvector(ent, velocity)[2] -= gravity; + + if(applygravity) + { + if(!sv_gameplayfix_nogravityonground.integer || !((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND)) + { + if (sv_gameplayfix_gravityunaffectedbyticrate.integer) + PRVM_serveredictvector(ent, velocity)[2] -= gravity * 0.5f; + } + } + return blocked; } -- 2.39.2