]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_phys.c
reworked userdir path selection, now has 4 "tiers":
[xonotic/darkplaces.git] / sv_phys.c
index 5c0919776639cbfe96a98fb1fd89f7c1c127eafd..7558be896a987111e13bffa2f26f8f174138c480 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -299,7 +299,7 @@ trace_t SV_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
 #endif
 
        // clip to world
-       Collision_ClipLineToWorld(&cliptrace, sv.worldmodel, clipstart, clipend, hitsupercontentsmask);
+       Collision_ClipLineToWorld(&cliptrace, sv.worldmodel, clipstart, clipend, hitsupercontentsmask, false);
        cliptrace.bmodelstartsolid = cliptrace.startsolid;
        if (cliptrace.startsolid || cliptrace.fraction < 1)
                cliptrace.ent = prog->edicts;
@@ -393,7 +393,7 @@ trace_t SV_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
                if (type == MOVE_MISSILE && (int)touch->fields.server->flags & FL_MONSTER)
                        Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.server->mins, touch->fields.server->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
                else
-                       Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.server->mins, touch->fields.server->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask);
+                       Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.server->mins, touch->fields.server->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, false);
 
                Collision_CombineTraces(&cliptrace, &trace, (void *)touch, touch->fields.server->solid == SOLID_BSP);
        }
@@ -1128,16 +1128,14 @@ qboolean SV_RunThink (prvm_edict_t *ent)
 SV_Impact
 
 Two entities have touched, so run their touch functions
-returns true if the impact kept the origin of the touching entity intact
 ==================
 */
 extern void VM_SetTraceGlobals(const trace_t *trace);
 extern sizebuf_t vm_tempstringsbuf;
-qboolean SV_Impact (prvm_edict_t *e1, trace_t *trace)
+void SV_Impact (prvm_edict_t *e1, trace_t *trace)
 {
        int restorevm_tempstringsbuf_cursize;
        int old_self, old_other;
-       vec3_t org;
        prvm_edict_t *e2 = (prvm_edict_t *)trace->ent;
        prvm_eval_t *val;
 
@@ -1145,8 +1143,6 @@ qboolean SV_Impact (prvm_edict_t *e1, trace_t *trace)
        old_other = prog->globals.server->other;
        restorevm_tempstringsbuf_cursize = vm_tempstringsbuf.cursize;
 
-       VectorCopy(e1->fields.server->origin, org);
-
        VM_SetTraceGlobals(trace);
 
        prog->globals.server->time = sv.time;
@@ -1179,8 +1175,6 @@ qboolean SV_Impact (prvm_edict_t *e1, trace_t *trace)
        prog->globals.server->self = old_self;
        prog->globals.server->other = old_other;
        vm_tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
-
-       return VectorCompare(e1->fields.server->origin, org);
 }
 
 
@@ -1236,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)
@@ -1298,12 +1297,24 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo
                        //Con_Printf("step %f %f %f : ", ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2]);
                        VectorSet(steppush, 0, 0, stepheight);
                        VectorCopy(ent->fields.server->origin, org);
-                       SV_PushEntity(&steptrace, ent, steppush, false, false);
+                       if(!SV_PushEntity(&steptrace, ent, steppush, false, false))
+                       {
+                               blocked |= 8;
+                               break;
+                       }
                        //Con_Printf("%f %f %f : ", ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2]);
-                       SV_PushEntity(&steptrace2, ent, push, false, false);
+                       if(!SV_PushEntity(&steptrace2, ent, push, false, false))
+                       {
+                               blocked |= 8;
+                               break;
+                       }
                        //Con_Printf("%f %f %f : ", ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2]);
                        VectorSet(steppush, 0, 0, org[2] - ent->fields.server->origin[2]);
-                       SV_PushEntity(&steptrace3, ent, steppush, false, false);
+                       if(!SV_PushEntity(&steptrace3, ent, steppush, false, false))
+                       {
+                               blocked |= 8;
+                               break;
+                       }
                        //Con_Printf("%f %f %f : ", ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2]);
                        // accept the new position if it made some progress...
                        if (fabs(ent->fields.server->origin[0] - org[0]) >= 0.03125 || fabs(ent->fields.server->origin[1] - org[1]) >= 0.03125)
@@ -1468,7 +1479,7 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
 {
        int type;
        int bump;
-       vec3_t original;
+       vec3_t original, original_velocity;
        vec3_t end;
 
        VectorCopy(ent->fields.server->origin, original);
@@ -1498,8 +1509,11 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
        if (trace->bmodelstartsolid && failonbmodelstartsolid)
                return true;
 
-
        VectorCopy (trace->endpos, ent->fields.server->origin);
+
+       VectorCopy(ent->fields.server->origin, original);
+       VectorCopy(ent->fields.server->velocity, original_velocity);
+
        SV_LinkEdict(ent);
 
 #if 0
@@ -1514,9 +1528,9 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
                SV_LinkEdict_TouchAreaGrid(ent);
 
        if((ent->fields.server->solid >= SOLID_TRIGGER && trace->ent && (!((int)ent->fields.server->flags & FL_ONGROUND) || ent->fields.server->groundentity != PRVM_EDICT_TO_PROG(trace->ent))))
-               return SV_Impact (ent, trace);
+               SV_Impact (ent, trace);
 
-       return true;
+       return VectorCompare(ent->fields.server->origin, original) && VectorCompare(ent->fields.server->velocity, original_velocity);
 }
 
 
@@ -2142,7 +2156,13 @@ Only used by players
 */
 void SV_WalkMove (prvm_edict_t *ent)
 {
-       int clip, oldonground, originalmove_clip, originalmove_flags, originalmove_groundentity, hitsupercontentsmask, type;
+       int clip;
+       int oldonground;
+       //int originalmove_clip;
+       int originalmove_flags;
+       int originalmove_groundentity;
+       int hitsupercontentsmask;
+       int type;
        vec3_t upmove, downmove, start_origin, start_velocity, stepnormal, originalmove_origin, originalmove_velocity;
        trace_t downtrace, trace;
        qboolean applygravity;
@@ -2206,7 +2226,7 @@ void SV_WalkMove (prvm_edict_t *ent)
 
        VectorCopy(ent->fields.server->origin, originalmove_origin);
        VectorCopy(ent->fields.server->velocity, originalmove_velocity);
-       originalmove_clip = clip;
+       //originalmove_clip = clip;
        originalmove_flags = (int)ent->fields.server->flags;
        originalmove_groundentity = ent->fields.server->groundentity;