]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_phys.c
make shader permutatiosn eat less memory again. 864MB was justt oo much.
[xonotic/darkplaces.git] / sv_phys.c
index 9c67efdb36b6d92c577ea3977726bcf431bbaeee..24b17ef7bd77dfe0423eec84a8967acbb3f0fbc8 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -82,16 +82,24 @@ int SV_GenericHitSuperContentsMask(const prvm_edict_t *passedict)
 SV_Move
 ==================
 */
+#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+#if COLLISIONPARANOID >= 1
+trace_t SV_Move_(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t pEnd, int type, prvm_edict_t *passedict, int hitsupercontentsmask)
+#else
+trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t pEnd, int type, prvm_edict_t *passedict, int hitsupercontentsmask)
+#endif
+#else
 #if COLLISIONPARANOID >= 1
 trace_t SV_Move_(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask)
 #else
 trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask)
 #endif
+#endif
 {
        vec3_t hullmins, hullmaxs;
        int i, bodysupercontents;
        int passedictprog;
-       float pitchsign;
+       float pitchsign = 1;
        qboolean pointtrace;
        prvm_edict_t *traceowner, *touch;
        trace_t trace;
@@ -112,6 +120,20 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const
        // list of entities to test for collisions
        int numtouchedicts;
        prvm_edict_t *touchedicts[MAX_EDICTS];
+#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+       vec3_t end;
+       vec_t len = 0;
+
+       if(!VectorCompare(start, pEnd))
+       {
+               // TRICK: make the trace 1 qu longer!
+               VectorSubtract(pEnd, start, end);
+               len = VectorNormalizeLength(end);
+               VectorAdd(pEnd, end, end);
+       }
+       else
+               VectorCopy(pEnd, end);
+#endif
 
        VectorCopy(start, clipstart);
        VectorCopy(end, clipend);
@@ -129,7 +151,7 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const
        if (cliptrace.startsolid || cliptrace.fraction < 1)
                cliptrace.ent = prog->edicts;
        if (type == MOVE_WORLDONLY)
-               return cliptrace;
+               goto finished;
 
        if (type == MOVE_MISSILE)
        {
@@ -219,7 +241,7 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const
                        // if the modelindex is 0, it shouldn't be SOLID_BSP!
                        if (modelindex > 0 && modelindex < MAX_MODELS)
                                model = sv.models[(int)touch->fields.server->modelindex];
-                       pitchsign = 1;
+                       //pitchsign = 1;
                        if (
                                ((modelindex = (int)touch->fields.server->modelindex) >= 1 && modelindex < MAX_MODELS && (model = sv.models[(int)touch->fields.server->modelindex]))
                                ?
@@ -246,6 +268,11 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const
                Collision_CombineTraces(&cliptrace, &trace, (void *)touch, touch->fields.server->solid == SOLID_BSP);
        }
 
+finished:
+#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+       if(!VectorCompare(start, pEnd))
+               Collision_ShortenTrace(&cliptrace, len / (len + 1), pEnd);
+#endif
        return cliptrace;
 }
 
@@ -2008,7 +2035,8 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                        // and groundentity is now freed, set groundentity to 0 (world)
                        // which leaves it suspended in the air
                        ent->fields.server->groundentity = 0;
-                       return;
+                       if (sv_gameplayfix_noairborncorpse_allowsuspendeditems.integer)
+                               return;
                }
        }
        ent->priv.server->suspendedinairflag = false;
@@ -2224,7 +2252,7 @@ static void SV_Physics_Entity (prvm_edict_t *ent)
        //  ents in the first frame regardless)
        qboolean runmove = ent->priv.server->move;
        ent->priv.server->move = true;
-       if (!runmove && sv_gameplayfix_delayprojectiles.integer)
+       if (!runmove && sv_gameplayfix_delayprojectiles.integer > 0)
                return;
        switch ((int) ent->fields.server->movetype)
        {
@@ -2460,9 +2488,17 @@ void SV_Physics (void)
 
        // run physics on all the non-client entities
        if (!sv_freezenonclients.integer)
+       {
                for (;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
                        if (!ent->priv.server->free)
                                SV_Physics_Entity(ent);
+               // make a second pass to see if any ents spawned this frame and make
+               // sure they run their move/think
+               if (sv_gameplayfix_delayprojectiles.integer < 0)
+                       for (i = svs.maxclients + 1, ent = PRVM_EDICT_NUM(i);i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
+                               if (!ent->priv.server->move && !ent->priv.server->free)
+                                       SV_Physics_Entity(ent);
+       }
 
        if (prog->globals.server->force_retouch > 0)
                prog->globals.server->force_retouch = max(0, prog->globals.server->force_retouch - 1);