From 9b64f9e9a888f325fb7499271bb0098ac4f07da1 Mon Sep 17 00:00:00 2001 From: divverent Date: Mon, 5 Apr 2010 13:47:58 +0000 Subject: [PATCH] 1. network sv_gameplayfix_gravityunaffectedbyticrate to the client, and predict properly 2. new cvar sv_gameplayfix_nogravityonground (also supported by cl_movement) When that cvar is activated, walking on downward slopes is a little bumpy. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10069 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_input.c | 20 ++++++++++++++++++-- quakedef.h | 2 ++ server.h | 1 + sv_main.c | 5 ++++- sv_phys.c | 5 +++++ 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/cl_input.c b/cl_input.c index 6aaf8139..4c94d38e 100644 --- a/cl_input.c +++ b/cl_input.c @@ -1260,6 +1260,7 @@ void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) vec_t addspeed; vec_t accelspeed; vec_t f; + vec_t gravity; vec3_t forward; vec3_t right; vec3_t up; @@ -1332,11 +1333,20 @@ 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); } - s->velocity[2] -= cl.movevars_gravity * cl.movevars_entgravity * s->cmd.frametime; + 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; 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; } else { @@ -1395,8 +1405,14 @@ void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) if(cl.movevars_aircontrol) CL_ClientMovement_Physics_CPM_PM_Aircontrol(s, wishdir, wishspeed2); } - s->velocity[2] -= cl.movevars_gravity * cl.movevars_entgravity * s->cmd.frametime; + 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; CL_ClientMovement_Move(s); + if(cl.moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE) + s->velocity[2] -= gravity * 0.5f; } } diff --git a/quakedef.h b/quakedef.h index b308f60e..55e8e6ac 100644 --- a/quakedef.h +++ b/quakedef.h @@ -264,6 +264,8 @@ extern char engineversion[128]; // moveflags values #define MOVEFLAG_VALID 0x80000000 #define MOVEFLAG_Q2AIRACCELERATE 0x00000001 +#define MOVEFLAG_NOGRAVITYONGROUND 0x00000002 +#define MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE 0x00000004 // stock defines diff --git a/server.h b/server.h index 62d11f0d..0d597762 100644 --- a/server.h +++ b/server.h @@ -424,6 +424,7 @@ extern cvar_t sv_gameplayfix_droptofloorstartsolid_nudgetocorrect; extern cvar_t sv_gameplayfix_easierwaterjump; extern cvar_t sv_gameplayfix_findradiusdistancetobox; extern cvar_t sv_gameplayfix_gravityunaffectedbyticrate; +extern cvar_t sv_gameplayfix_nogravityonground; extern cvar_t sv_gameplayfix_grenadebouncedownslopes; extern cvar_t sv_gameplayfix_multiplethinksperframe; extern cvar_t sv_gameplayfix_noairborncorpse; diff --git a/sv_main.c b/sv_main.c index 1112d5c6..e1330214 100644 --- a/sv_main.c +++ b/sv_main.c @@ -100,6 +100,7 @@ cvar_t sv_gameplayfix_noairborncorpse_allowsuspendeditems = {0, "sv_gameplayfix_ cvar_t sv_gameplayfix_nudgeoutofsolid = {0, "sv_gameplayfix_nudgeoutofsolid", "1", "attempts to fix physics errors (where an object ended up in solid for some reason)"}; cvar_t sv_gameplayfix_nudgeoutofsolid_bias = {0, "sv_gameplayfix_nudgeoutofsolid_bias", "0", "over-correction on nudgeoutofsolid logic, to prevent constant contact"}; cvar_t sv_gameplayfix_q2airaccelerate = {0, "sv_gameplayfix_q2airaccelerate", "0", "Quake2-style air acceleration"}; +cvar_t sv_gameplayfix_nogravityonground = {0, "sv_gameplayfix_nogravityonground", "0", "Quake2-style air acceleration"}; cvar_t sv_gameplayfix_setmodelrealbox = {0, "sv_gameplayfix_setmodelrealbox", "1", "fixes a bug in Quake that made setmodel always set the entity box to ('-16 -16 -16', '16 16 16') rather than properly checking the model box, breaks some poorly coded mods"}; cvar_t sv_gameplayfix_slidemoveprojectiles = {0, "sv_gameplayfix_slidemoveprojectiles", "1", "allows MOVETYPE_FLY/FLYMISSILE/TOSS/BOUNCE/BOUNCEMISSILE entities to finish their move in a frame even if they hit something, fixes 'gravity accumulation' bug for grenades on steep slopes"}; cvar_t sv_gameplayfix_stepdown = {0, "sv_gameplayfix_stepdown", "0", "attempts to step down stairs, not just up them (prevents the familiar thud..thud..thud.. when running down stairs and slopes)"}; @@ -412,6 +413,7 @@ void SV_Init (void) Cvar_RegisterVariable (&sv_gameplayfix_nudgeoutofsolid); Cvar_RegisterVariable (&sv_gameplayfix_nudgeoutofsolid_bias); Cvar_RegisterVariable (&sv_gameplayfix_q2airaccelerate); + Cvar_RegisterVariable (&sv_gameplayfix_nogravityonground); Cvar_RegisterVariable (&sv_gameplayfix_setmodelrealbox); Cvar_RegisterVariable (&sv_gameplayfix_slidemoveprojectiles); Cvar_RegisterVariable (&sv_gameplayfix_stepdown); @@ -517,7 +519,6 @@ void SV_Init (void) } if (gamemode == GAME_NEXUIZ) { - // rogue mission pack has a guardian boss that does not wake up if findradius returns one of the entities around its spawn area Cvar_SetValueQuick (&sv_gameplayfix_q2airaccelerate, 1); } @@ -1932,6 +1933,8 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t // note: these are not sent in protocols with lower MAX_CL_STATS limits stats[STAT_MOVEFLAGS] = MOVEFLAG_VALID | (sv_gameplayfix_q2airaccelerate.integer ? MOVEFLAG_Q2AIRACCELERATE : 0) + | (sv_gameplayfix_nogravityonground.integer ? MOVEFLAG_NOGRAVITYONGROUND : 0) + | (sv_gameplayfix_gravityunaffectedbyticrate.integer ? MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE : 0) ; statsf[STAT_MOVEVARS_TICRATE] = sys_ticrate.value; statsf[STAT_MOVEVARS_TIMESCALE] = slowmo.value; diff --git a/sv_phys.c b/sv_phys.c index d7ae93f4..78633253 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -1230,6 +1230,11 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo if (time <= 0) return 0; gravity = 0; + + if(sv_gameplayfix_nogravityonground.integer) + if((int)ent->fields.server->flags & FL_ONGROUND) + applygravity = false; + if (applygravity) { if (sv_gameplayfix_gravityunaffectedbyticrate.integer) -- 2.39.2