]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
implemented sv_gameplayfix_nudgeoutofsolid
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 25 Oct 2009 13:47:37 +0000 (13:47 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 25 Oct 2009 13:47:37 +0000 (13:47 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9400 d7cf8633-e32d-0410-b094-e92efae38249

collision.c
server.h
sv_main.c
sv_phys.c

index e6cdf0d5479b7f9f5214629cffcff54f81e6497c..d7fe855e70d28977e85e67e9c000ef4d1b48fe78 100644 (file)
@@ -629,10 +629,10 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *trace_sta
        vec4_t endplane;
        vec4_t newimpactplane;
        texture_t *hittexture = NULL;
-       vec_t startdepth = trace->startdepth;
+       vec_t startdepth = 1;
        vec3_t startdepthnormal;
 
-       VectorCopy(trace->startdepthnormal, startdepthnormal);
+       VectorClear(startdepthnormal);
        Vector4Clear(newimpactplane);
 
        // Separating Axis Theorem:
@@ -686,10 +686,10 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *trace_sta
                //Con_Printf("%c%i: startdist = %f, enddist = %f, startdist / (startdist - enddist) = %f\n", nplane2 != nplane ? 'b' : 'a', nplane2, startdist, enddist, startdist / (startdist - enddist));
 
                // aside from collisions, this is also used for error correction
-               if (startdist < 0 && trace->startdepth < startdist)
+               if (startdist < 0 && (startdepth < startdist || startdepth == 1))
                {
-                       trace->startdepth = startdist;
-                       VectorCopy(startplane, trace->startdepthnormal);
+                       startdepth = startdist;
+                       VectorCopy(startplane, startdepthnormal);
                }
 
                if (startdist > enddist)
@@ -803,7 +803,7 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *trace_sta
                                trace->allsolid = true;
                        VectorCopy(newimpactplane, trace->plane.normal);
                        trace->plane.dist = newimpactplane[3];
-                       if (trace->startdepth < startdepth)
+                       if (trace->startdepth > startdepth)
                        {
                                trace->startdepth = startdepth;
                                VectorCopy(startdepthnormal, trace->startdepthnormal);
@@ -822,10 +822,10 @@ void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const
        vec4_t endplane;
        vec4_t newimpactplane;
        texture_t *hittexture = NULL;
-       vec_t startdepth = trace->startdepth;
+       vec_t startdepth = 1;
        vec3_t startdepthnormal;
 
-       VectorCopy(trace->startdepthnormal, startdepthnormal);
+       VectorClear(startdepthnormal);
        Vector4Clear(newimpactplane);
 
        // Separating Axis Theorem:
@@ -849,10 +849,10 @@ void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const
                //Con_Printf("%c%i: startdist = %f, enddist = %f, startdist / (startdist - enddist) = %f\n", nplane2 != nplane ? 'b' : 'a', nplane2, startdist, enddist, startdist / (startdist - enddist));
 
                // aside from collisions, this is also used for error correction
-               if (startdist < 0 && trace->startdepth < startdist)
+               if (startdist < 0 && (startdepth < startdist || startdepth == 1))
                {
-                       trace->startdepth = startdist;
-                       VectorCopy(startplane, trace->startdepthnormal);
+                       startdepth = startdist;
+                       VectorCopy(startplane, startdepthnormal);
                }
 
                if (startdist > enddist)
@@ -949,7 +949,7 @@ void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const
                                trace->allsolid = true;
                        VectorCopy(newimpactplane, trace->plane.normal);
                        trace->plane.dist = newimpactplane[3];
-                       if (trace->startdepth < startdepth)
+                       if (trace->startdepth > startdepth)
                        {
                                trace->startdepth = startdepth;
                                VectorCopy(startdepthnormal, trace->startdepthnormal);
@@ -1806,6 +1806,11 @@ void Collision_CombineTraces(trace_t *cliptrace, const trace_t *trace, void *tou
                cliptrace->startsolid = true;
                if (cliptrace->realfraction == 1)
                        cliptrace->ent = touch;
+               if (cliptrace->startdepth > trace->startdepth)
+               {
+                       cliptrace->startdepth = trace->startdepth;
+                       VectorCopy(trace->startdepthnormal, cliptrace->startdepthnormal);
+               }
        }
        // don't set this except on the world, because it can easily confuse
        // monsters underwater if there's a bmodel involved in the trace
index 53ada65534e1d9bf097b9db8c7b1de163b05ee7f..6a19f1b78bfe705f7fd49a635b10aa4aa648fe7d 100644 (file)
--- a/server.h
+++ b/server.h
@@ -423,17 +423,18 @@ extern cvar_t sv_gameplayfix_droptofloorstartsolid;
 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_grenadebouncedownslopes;
 extern cvar_t sv_gameplayfix_multiplethinksperframe;
-extern cvar_t sv_gameplayfix_slidemoveprojectiles;
 extern cvar_t sv_gameplayfix_noairborncorpse;
 extern cvar_t sv_gameplayfix_noairborncorpse_allowsuspendeditems;
+extern cvar_t sv_gameplayfix_nudgeoutofsolid;
 extern cvar_t sv_gameplayfix_setmodelrealbox;
+extern cvar_t sv_gameplayfix_slidemoveprojectiles;
 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 ac717fab2507e571c6aa3e95987ff4462a68050f..e3f5f45b8fc7c4009f3320bcc47491a358b798e9 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -92,18 +92,19 @@ cvar_t sv_gameplayfix_droptofloorstartsolid = {0, "sv_gameplayfix_droptofloorsta
 cvar_t sv_gameplayfix_droptofloorstartsolid_nudgetocorrect = {0, "sv_gameplayfix_droptofloorstartsolid_nudgetocorrect", "1", "tries to nudge stuck items and monsters out of walls before droptofloor is performed"};
 cvar_t sv_gameplayfix_easierwaterjump = {0, "sv_gameplayfix_easierwaterjump", "1", "changes water jumping to make it easier to get out of water (exactly like in QuakeWorld)"};
 cvar_t sv_gameplayfix_findradiusdistancetobox = {0, "sv_gameplayfix_findradiusdistancetobox", "1", "causes findradius to check the distance to the corner of a box rather than the center of the box, makes findradius detect bmodels such as very large doors that would otherwise be unaffected by splash damage"};
+cvar_t sv_gameplayfix_gravityunaffectedbyticrate = {0, "sv_gameplayfix_gravityunaffectedbyticrate", "0", "fix some ticrate issues in physics."};
 cvar_t sv_gameplayfix_grenadebouncedownslopes = {0, "sv_gameplayfix_grenadebouncedownslopes", "1", "prevents MOVETYPE_BOUNCE (grenades) from getting stuck when fired down a downward sloping surface"};
 cvar_t sv_gameplayfix_multiplethinksperframe = {0, "sv_gameplayfix_multiplethinksperframe", "1", "allows entities to think more often than the server framerate, primarily useful for very high fire rate weapons"};
-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_noairborncorpse = {0, "sv_gameplayfix_noairborncorpse", "1", "causes entities (corpses, items, etc) sitting ontop of moving entities (players) to fall when the moving entity (player) is no longer supporting them"};
 cvar_t sv_gameplayfix_noairborncorpse_allowsuspendeditems = {0, "sv_gameplayfix_noairborncorpse_allowsuspendeditems", "1", "causes entities sitting ontop of objects that are instantaneously remove to float in midair (special hack to allow a common level design trick for floating items)"};
+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_q2airaccelerate = {0, "sv_gameplayfix_q2airaccelerate", "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)"};
 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_gameplayfix_q2airaccelerate = {0, "sv_gameplayfix_q2airaccelerate", "0", "Quake2-style air acceleration"};
 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)"};
@@ -401,18 +402,19 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_gameplayfix_droptofloorstartsolid_nudgetocorrect);
        Cvar_RegisterVariable (&sv_gameplayfix_easierwaterjump);
        Cvar_RegisterVariable (&sv_gameplayfix_findradiusdistancetobox);
+       Cvar_RegisterVariable (&sv_gameplayfix_gravityunaffectedbyticrate);
        Cvar_RegisterVariable (&sv_gameplayfix_grenadebouncedownslopes);
        Cvar_RegisterVariable (&sv_gameplayfix_multiplethinksperframe);
-       Cvar_RegisterVariable (&sv_gameplayfix_slidemoveprojectiles);
        Cvar_RegisterVariable (&sv_gameplayfix_noairborncorpse);
        Cvar_RegisterVariable (&sv_gameplayfix_noairborncorpse_allowsuspendeditems);
+       Cvar_RegisterVariable (&sv_gameplayfix_nudgeoutofsolid);
+       Cvar_RegisterVariable (&sv_gameplayfix_q2airaccelerate);
        Cvar_RegisterVariable (&sv_gameplayfix_setmodelrealbox);
+       Cvar_RegisterVariable (&sv_gameplayfix_slidemoveprojectiles);
        Cvar_RegisterVariable (&sv_gameplayfix_stepdown);
        Cvar_RegisterVariable (&sv_gameplayfix_stepwhilejumping);
        Cvar_RegisterVariable (&sv_gameplayfix_swiminbmodels);
        Cvar_RegisterVariable (&sv_gameplayfix_upwardvelocityclearsongroundflag);
-       Cvar_RegisterVariable (&sv_gameplayfix_gravityunaffectedbyticrate);
-       Cvar_RegisterVariable (&sv_gameplayfix_q2airaccelerate);
        Cvar_RegisterVariable (&sv_gravity);
        Cvar_RegisterVariable (&sv_idealpitchscale);
        Cvar_RegisterVariable (&sv_jumpstep);
index e189ee92e2722efe722ad9f813f10e9cbbec5187..71ba23eed3dfd98cb15cd1bef8d4379354d13ea8 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -1482,8 +1482,11 @@ Returns true if the push did not result in the entity being teleported by QC cod
 static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, qboolean failonbmodelstartsolid, qboolean dolink)
 {
        int type;
+       int bump;
+       vec3_t original;
        vec3_t end;
 
+       VectorCopy(ent->fields.server->origin, original);
        VectorAdd (ent->fields.server->origin, push, end);
 
        if (ent->fields.server->movetype == MOVETYPE_FLYMISSILE)
@@ -1494,9 +1497,22 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
                type = MOVE_NORMAL;
 
        *trace = SV_TraceBox(ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, end, type, ent, SV_GenericHitSuperContentsMask(ent));
+       bump = 0;
+       while (trace->startsolid && sv_gameplayfix_nudgeoutofsolid.integer)
+       {
+               VectorMA(ent->fields.server->origin, -trace->startdepth, trace->startdepthnormal, ent->fields.server->origin);
+               *trace = SV_TraceBox(ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, end, type, ent, SV_GenericHitSuperContentsMask(ent));
+               bump++;
+               if (bump > 10)
+               {
+                       VectorCopy(original, ent->fields.server->origin);
+                       break;
+               }
+       }
        if (trace->bmodelstartsolid && failonbmodelstartsolid)
                return true;
 
+
        VectorCopy (trace->endpos, ent->fields.server->origin);
        SV_LinkEdict(ent);