]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added cvar sv_gameplayfix_gravityunaffectedbyticrate - off by default
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 16 Feb 2009 04:45:04 +0000 (04:45 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 16 Feb 2009 04:45:04 +0000 (04:45 +0000)
but seems to work

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8712 d7cf8633-e32d-0410-b094-e92efae38249

server.h
sv_main.c
sv_phys.c
svvm_cmds.c

index 0307bb520106f286ca32e46d72c95afb7ea32c0c..7095d4364ac55b3b27f49f31ff6b3fec3170598f 100644 (file)
--- a/server.h
+++ b/server.h
@@ -408,6 +408,7 @@ extern cvar_t sv_gameplayfix_stepdown;
 extern cvar_t sv_gameplayfix_stepwhilejumping;
 extern cvar_t sv_gameplayfix_swiminbmodels;
 extern cvar_t sv_gameplayfix_upwardvelocityclearsongroundflag;
+extern cvar_t sv_gameplayfix_gravityunaffectedbyticrate;
 extern cvar_t sv_gravity;
 extern cvar_t sv_idealpitchscale;
 extern cvar_t sv_jumpstep;
index 75d43359ef19e3c295f5b74cb541c6f27c6b06c4..c1a328f28700059baa4c747a082e0f244be9e799 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -92,6 +92,7 @@ cvar_t sv_gameplayfix_stepdown = {0, "sv_gameplayfix_stepdown", "0", "attempts t
 cvar_t sv_gameplayfix_stepwhilejumping = {0, "sv_gameplayfix_stepwhilejumping", "1", "applies step-up onto a ledge even while airborn, useful if you would otherwise just-miss the floor when running across small areas with gaps (for instance running across the moving platforms in dm2, or jumping to the megahealth and red armor in dm2 rather than using the bridge)"};
 cvar_t sv_gameplayfix_swiminbmodels = {0, "sv_gameplayfix_swiminbmodels", "1", "causes pointcontents (used to determine if you are in a liquid) to check bmodel entities as well as the world model, so you can swim around in (possibly moving) water bmodel entities"};
 cvar_t sv_gameplayfix_upwardvelocityclearsongroundflag = {0, "sv_gameplayfix_upwardvelocityclearsongroundflag", "1", "prevents monsters, items, and most other objects from being stuck to the floor when pushed around by damage, and other situations in mods"};
+cvar_t sv_gameplayfix_gravityunaffectedbyticrate = {0, "sv_gameplayfix_gravityunaffectedbyticrate", "0", "fix some ticrate issues in physics."};
 cvar_t sv_gravity = {CVAR_NOTIFY, "sv_gravity","800", "how fast you fall (512 = roughly earth gravity)"};
 cvar_t sv_idealpitchscale = {0, "sv_idealpitchscale","0.8", "how much to look up/down slopes and stairs when not using freelook"};
 cvar_t sv_jumpstep = {CVAR_NOTIFY, "sv_jumpstep", "0", "whether you can step up while jumping (sv_gameplayfix_stepwhilejumping must also be 1)"};
@@ -367,6 +368,7 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_gameplayfix_stepwhilejumping);
        Cvar_RegisterVariable (&sv_gameplayfix_swiminbmodels);
        Cvar_RegisterVariable (&sv_gameplayfix_upwardvelocityclearsongroundflag);
+       Cvar_RegisterVariable (&sv_gameplayfix_gravityunaffectedbyticrate);
        Cvar_RegisterVariable (&sv_gravity);
        Cvar_RegisterVariable (&sv_idealpitchscale);
        Cvar_RegisterVariable (&sv_jumpstep);
index 886d640bd816782afee9a819d2b37ca8a2f9b037..45d43e36884b75fb37807c42afe9c6f48f613f28 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -756,17 +756,32 @@ Returns the clipflags if the velocity was modified (hit something solid)
 If stepnormal is not NULL, the plane normal of any vertical wall hit will be stored
 ============
 */
+static float SV_Gravity (prvm_edict_t *ent);
 // LordHavoc: increased from 5 to 32
 #define MAX_CLIP_PLANES 32
-int SV_FlyMove (prvm_edict_t *ent, float time, float *stepnormal, int hitsupercontentsmask)
+static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, float *stepnormal, int hitsupercontentsmask)
 {
        int blocked, bumpcount;
        int i, j, impact, numplanes;
-       float d, time_left;
+       float d, time_left, gravity;
        vec3_t dir, end, planes[MAX_CLIP_PLANES], primal_velocity, original_velocity, new_velocity;
        trace_t trace;
        if (time <= 0)
                return 0;
+       gravity = 0;
+       if (applygravity)
+       {
+               if (sv_gameplayfix_gravityunaffectedbyticrate.integer)
+               {
+                       gravity = SV_Gravity(ent) * 0.5f;
+                       ent->fields.server->velocity[2] -= gravity;
+               }
+               else
+               {
+                       applygravity = false;
+                       ent->fields.server->velocity[2] -= SV_Gravity(ent);
+               }
+       }
        blocked = 0;
        VectorCopy(ent->fields.server->velocity, original_velocity);
        VectorCopy(ent->fields.server->velocity, primal_velocity);
@@ -980,16 +995,18 @@ int SV_FlyMove (prvm_edict_t *ent, float time, float *stepnormal, int hitsuperco
        // LordHavoc: this came from QW and allows you to get out of water more easily
        if (sv_gameplayfix_easierwaterjump.integer && ((int)ent->fields.server->flags & FL_WATERJUMP))
                VectorCopy(primal_velocity, ent->fields.server->velocity);
+       if (applygravity && !((int)ent->fields.server->flags & FL_ONGROUND))
+               ent->fields.server->velocity[2] -= gravity;
        return blocked;
 }
 
 /*
 ============
-SV_AddGravity
+SV_Gravity
 
 ============
 */
-void SV_AddGravity (prvm_edict_t *ent)
+static float SV_Gravity (prvm_edict_t *ent)
 {
        float ent_gravity;
        prvm_eval_t *val;
@@ -999,7 +1016,7 @@ void SV_AddGravity (prvm_edict_t *ent)
                ent_gravity = val->_float;
        else
                ent_gravity = 1.0;
-       ent->fields.server->velocity[2] -= ent_gravity * sv_gravity.value * sv.frametime;
+       return ent_gravity * sv_gravity.value * sv.frametime;
 }
 
 
@@ -1628,12 +1645,17 @@ void SV_WalkMove (prvm_edict_t *ent)
        int clip, oldonground, originalmove_clip, originalmove_flags, originalmove_groundentity, hitsupercontentsmask;
        vec3_t upmove, downmove, start_origin, start_velocity, stepnormal, originalmove_origin, originalmove_velocity;
        trace_t downtrace;
+       qboolean applygravity;
 
        // if frametime is 0 (due to client sending the same timestamp twice),
        // don't move
        if (sv.frametime <= 0)
                return;
 
+       SV_CheckStuck (ent);
+
+       applygravity = !SV_CheckWater (ent) && ent->fields.server->movetype == MOVETYPE_WALK && ! ((int)ent->fields.server->flags & FL_WATERJUMP);
+
        hitsupercontentsmask = SV_GenericHitSuperContentsMask(ent);
 
        SV_CheckVelocity(ent);
@@ -1644,13 +1666,14 @@ void SV_WalkMove (prvm_edict_t *ent)
        VectorCopy (ent->fields.server->origin, start_origin);
        VectorCopy (ent->fields.server->velocity, start_velocity);
 
-       clip = SV_FlyMove (ent, sv.frametime, NULL, hitsupercontentsmask);
+       clip = SV_FlyMove (ent, sv.frametime, applygravity, NULL, hitsupercontentsmask);
 
        // if the move did not hit the ground at any point, we're not on ground
        if (!(clip & 1))
                ent->fields.server->flags = (int)ent->fields.server->flags & ~FL_ONGROUND;
 
        SV_CheckVelocity(ent);
+       SV_LinkEdict (ent, true);
 
        VectorCopy(ent->fields.server->origin, originalmove_origin);
        VectorCopy(ent->fields.server->velocity, originalmove_velocity);
@@ -1696,10 +1719,11 @@ void SV_WalkMove (prvm_edict_t *ent)
 
                // move forward
                ent->fields.server->velocity[2] = 0;
-               clip = SV_FlyMove (ent, sv.frametime, stepnormal, hitsupercontentsmask);
+               clip = SV_FlyMove (ent, sv.frametime, applygravity, stepnormal, hitsupercontentsmask);
                ent->fields.server->velocity[2] += start_velocity[2];
 
                SV_CheckVelocity(ent);
+               SV_LinkEdict (ent, true);
 
                // check for stuckness, possibly due to the limited precision of floats
                // in the clipping hulls
@@ -1763,6 +1787,7 @@ void SV_WalkMove (prvm_edict_t *ent)
        }
 
        SV_CheckVelocity(ent);
+       SV_LinkEdict (ent, true);
 }
 
 //============================================================================
@@ -1900,7 +1925,7 @@ void SV_Physics_Toss (prvm_edict_t *ent)
 
 // add gravity
        if (ent->fields.server->movetype == MOVETYPE_TOSS || ent->fields.server->movetype == MOVETYPE_BOUNCE)
-               SV_AddGravity (ent);
+               ent->fields.server->velocity[2] -= SV_Gravity(ent);
 
 // move angles
        VectorMA (ent->fields.server->angles, sv.frametime, ent->fields.server->avelocity, ent->fields.server->angles);
@@ -2017,9 +2042,8 @@ void SV_Physics_Step (prvm_edict_t *ent)
                        if ((ent->fields.server->velocity[2] >= (1.0 / 32.0) && sv_gameplayfix_upwardvelocityclearsongroundflag.integer) || ent->fields.server->groundentity)
                        {
                                ent->fields.server->flags -= FL_ONGROUND;
-                               SV_AddGravity(ent);
                                SV_CheckVelocity(ent);
-                               SV_FlyMove(ent, sv.frametime, NULL, SV_GenericHitSuperContentsMask(ent));
+                               SV_FlyMove(ent, sv.frametime, true, NULL, SV_GenericHitSuperContentsMask(ent));
                                SV_LinkEdict(ent, true);
                                ent->priv.server->waterposition_forceupdate = true;
                        }
@@ -2029,9 +2053,8 @@ void SV_Physics_Step (prvm_edict_t *ent)
                        // freefall if not onground
                        int hitsound = ent->fields.server->velocity[2] < sv_gravity.value * -0.1;
 
-                       SV_AddGravity(ent);
                        SV_CheckVelocity(ent);
-                       SV_FlyMove(ent, sv.frametime, NULL, SV_GenericHitSuperContentsMask(ent));
+                       SV_FlyMove(ent, sv.frametime, true, NULL, SV_GenericHitSuperContentsMask(ent));
                        SV_LinkEdict(ent, true);
 
                        // just hit ground
@@ -2109,13 +2132,7 @@ static void SV_Physics_Entity (prvm_edict_t *ent)
                break;
        case MOVETYPE_WALK:
                if (SV_RunThink (ent))
-               {
-                       if (!SV_CheckWater (ent) && ! ((int)ent->fields.server->flags & FL_WATERJUMP) )
-                               SV_AddGravity (ent);
-                       SV_CheckStuck (ent);
                        SV_WalkMove (ent);
-                       SV_LinkEdict (ent, true);
-               }
                break;
        case MOVETYPE_TOSS:
        case MOVETYPE_BOUNCE:
@@ -2158,17 +2175,8 @@ void SV_Physics_ClientMove(void)
                VectorClear(ent->fields.server->velocity);
 
        // perform MOVETYPE_WALK behavior
-       if (!SV_CheckWater (ent) && ! ((int)ent->fields.server->flags & FL_WATERJUMP) )
-               SV_AddGravity (ent);
-       SV_CheckStuck (ent);
        SV_WalkMove (ent);
 
-       SV_CheckVelocity (ent);
-
-       SV_LinkEdict (ent, true);
-
-       SV_CheckVelocity (ent);
-
        // call standard player post-think, with frametime = 0
        prog->globals.server->time = sv.time;
        prog->globals.server->frametime = 0;
@@ -2246,12 +2254,7 @@ void SV_Physics_ClientEntity(prvm_edict_t *ent)
                SV_RunThink (ent);
                // don't run physics here if running asynchronously
                if (host_client->clmovement_skipphysicsframes <= 0)
-               {
-                       if (!SV_CheckWater (ent) && ! ((int)ent->fields.server->flags & FL_WATERJUMP) )
-                               SV_AddGravity (ent);
-                       SV_CheckStuck (ent);
                        SV_WalkMove (ent);
-               }
                break;
        case MOVETYPE_TOSS:
        case MOVETYPE_BOUNCE:
@@ -2263,7 +2266,6 @@ void SV_Physics_ClientEntity(prvm_edict_t *ent)
                break;
        case MOVETYPE_FLY:
                SV_RunThink (ent);
-               SV_CheckWater (ent);
                SV_WalkMove (ent);
                break;
        default:
index b7de99778b0765668d1b9502e230798d7beebebe..42173caf307fb6f974655dc0305aaf72bd889c1d 100644 (file)
@@ -637,7 +637,7 @@ static trace_t SV_Trace_Toss (prvm_edict_t *tossent, prvm_edict_t *ignore)
                gravity = val->_float;
        else
                gravity = 1.0;
-       gravity *= sv_gravity.value * 0.05;
+       gravity *= sv_gravity.value * 0.025;
 
        for (i = 0;i < 200;i++) // LordHavoc: sanity check; never trace more than 10 seconds
        {
@@ -648,6 +648,7 @@ static trace_t SV_Trace_Toss (prvm_edict_t *tossent, prvm_edict_t *ignore)
                VectorAdd (tossent->fields.server->origin, move, end);
                trace = SV_Move (tossent->fields.server->origin, tossent->fields.server->mins, tossent->fields.server->maxs, end, MOVE_NORMAL, tossent, SV_GenericHitSuperContentsMask(tossent));
                VectorCopy (trace.endpos, tossent->fields.server->origin);
+               tossent->fields.server->velocity[2] -= gravity;
 
                if (trace.fraction < 1)
                        break;