]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_phys.c
Add THREADDISABLE define to make builds with whole threading system disabled.
[xonotic/darkplaces.git] / sv_phys.c
index d1de5a39cd8ef0848e2f79d07526ba39cfad6987..c88ff4c452193c721fa782bb2844169c824ff836 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -1600,7 +1600,6 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
        int movetype;
        int type;
        vec3_t mins, maxs;
-       vec3_t original, original_velocity;
        vec3_t start;
        vec3_t end;
 
@@ -1633,8 +1632,7 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
 
        VectorCopy(trace->endpos, PRVM_serveredictvector(ent, origin));
 
-       VectorCopy(PRVM_serveredictvector(ent, origin), original);
-       VectorCopy(PRVM_serveredictvector(ent, velocity), original_velocity);
+       ent->priv.required->mark = PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN; // -2: setorigin running
 
        SV_LinkEdict(ent);
 
@@ -1652,7 +1650,21 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
        if((PRVM_serveredictfloat(ent, solid) >= SOLID_TRIGGER && trace->ent && (!((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND) || PRVM_serveredictedict(ent, groundentity) != PRVM_EDICT_TO_PROG(trace->ent))))
                SV_Impact (ent, trace);
 
-       return VectorCompare(PRVM_serveredictvector(ent, origin), original) && VectorCompare(PRVM_serveredictvector(ent, velocity), original_velocity);
+       if(ent->priv.required->mark == PRVM_EDICT_MARK_SETORIGIN_CAUGHT)
+       {
+               ent->priv.required->mark = 0;
+               return false;
+       }
+       else if(ent->priv.required->mark == PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN)
+       {
+               ent->priv.required->mark = 0;
+               return true;
+       }
+       else
+       {
+               Con_Printf("The edict mark had been overwritten! Please debug this.\n");
+               return true;
+       }
 }
 
 
@@ -2589,6 +2601,9 @@ void SV_Physics_Toss (prvm_edict_t *ent)
        vec_t movetime;
        int bump;
        prvm_edict_t *groundentity;
+       float d, ent_gravity;
+       float bouncefactor;
+       float bouncestop;
 
 // if onground, return without moving
        if ((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND)
@@ -2634,8 +2649,8 @@ void SV_Physics_Toss (prvm_edict_t *ent)
        for (bump = 0;bump < MAX_CLIP_PLANES && movetime > 0;bump++)
        {
        // move origin
-               VectorScale (PRVM_serveredictvector(ent, velocity), movetime, move);
-               if(!SV_PushEntity (&trace, ent, move, true, true))
+               VectorScale(PRVM_serveredictvector(ent, velocity), movetime, move);
+               if(!SV_PushEntity(&trace, ent, move, true, true))
                        return; // teleported
                if (ent->priv.server->free)
                        return;
@@ -2644,7 +2659,7 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                        // try to unstick the entity
                        if (sv_gameplayfix_unstickentities.integer)
                                SV_UnstickEntity(ent);
-                       if(!SV_PushEntity (&trace, ent, move, false, true))
+                       if(!SV_PushEntity(&trace, ent, move, false, true))
                                return; // teleported
                        if (ent->priv.server->free)
                                return;
@@ -2652,22 +2667,19 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                if (trace.fraction == 1)
                        break;
                movetime *= 1 - min(1, trace.fraction);
-               if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_BOUNCEMISSILE)
+               switch((int)PRVM_serveredictfloat(ent, movetype))
                {
-                       float bouncefactor;
+               case MOVETYPE_BOUNCEMISSILE:
                        bouncefactor = PRVM_serveredictfloat(ent, bouncefactor);
                        if (!bouncefactor)
                                bouncefactor = 1.0f;
 
-                       ClipVelocity (PRVM_serveredictvector(ent, velocity), trace.plane.normal, PRVM_serveredictvector(ent, velocity), 1 + bouncefactor);
+                       ClipVelocity(PRVM_serveredictvector(ent, velocity), trace.plane.normal, PRVM_serveredictvector(ent, velocity), 1 + bouncefactor);
                        PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) & ~FL_ONGROUND;
-               }
-               else if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_BOUNCE)
-               {
-                       float d, ent_gravity;
-                       float bouncefactor;
-                       float bouncestop;
-
+                       if (!sv_gameplayfix_slidemoveprojectiles.integer)
+                               movetime = 0;
+                       break;
+               case MOVETYPE_BOUNCE:
                        bouncefactor = PRVM_serveredictfloat(ent, bouncefactor);
                        if (!bouncefactor)
                                bouncefactor = 0.5f;
@@ -2676,39 +2688,31 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                        if (!bouncestop)
                                bouncestop = 60.0f / 800.0f;
 
-                       ClipVelocity (PRVM_serveredictvector(ent, velocity), trace.plane.normal, PRVM_serveredictvector(ent, velocity), 1 + bouncefactor);
+                       ClipVelocity(PRVM_serveredictvector(ent, velocity), trace.plane.normal, PRVM_serveredictvector(ent, velocity), 1 + bouncefactor);
                        ent_gravity = PRVM_serveredictfloat(ent, gravity);
                        if (!ent_gravity)
                                ent_gravity = 1.0f;
                        // LordHavoc: fixed grenades not bouncing when fired down a slope
                        if (sv_gameplayfix_grenadebouncedownslopes.integer)
+                               d = fabs(DotProduct(trace.plane.normal, PRVM_serveredictvector(ent, velocity)));
+                       else
+                               d = PRVM_serveredictvector(ent, velocity)[2];
+                       if (trace.plane.normal[2] > 0.7 && d < sv_gravity.value * bouncestop * ent_gravity)
                        {
-                               d = DotProduct(trace.plane.normal, PRVM_serveredictvector(ent, velocity));
-                               if (trace.plane.normal[2] > 0.7 && fabs(d) < sv_gravity.value * bouncestop * ent_gravity)
-                               {
-                                       PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) | FL_ONGROUND;
-                                       PRVM_serveredictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent);
-                                       VectorClear (PRVM_serveredictvector(ent, velocity));
-                                       VectorClear (PRVM_serveredictvector(ent, avelocity));
-                               }
-                               else
-                                       PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) & ~FL_ONGROUND;
+                               PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) | FL_ONGROUND;
+                               PRVM_serveredictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent);
+                               VectorClear(PRVM_serveredictvector(ent, velocity));
+                               VectorClear(PRVM_serveredictvector(ent, avelocity));
+                               movetime = 0;
                        }
                        else
                        {
-                               if (trace.plane.normal[2] > 0.7 && PRVM_serveredictvector(ent, velocity)[2] < sv_gravity.value * bouncestop * ent_gravity)
-                               {
-                                       PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) | FL_ONGROUND;
-                                       PRVM_serveredictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent);
-                                       VectorClear (PRVM_serveredictvector(ent, velocity));
-                                       VectorClear (PRVM_serveredictvector(ent, avelocity));
-                               }
-                               else
-                                       PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) & ~FL_ONGROUND;
+                               PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) & ~FL_ONGROUND;
+                               if (!sv_gameplayfix_slidemoveprojectiles.integer)
+                                       movetime = 0;
                        }
-               }
-               else
-               {
+                       break;
+               default:
                        ClipVelocity (PRVM_serveredictvector(ent, velocity), trace.plane.normal, PRVM_serveredictvector(ent, velocity), 1.0);
                        if (trace.plane.normal[2] > 0.7)
                        {
@@ -2721,9 +2725,9 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                        }
                        else
                                PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) & ~FL_ONGROUND;
-               }
-               if (!sv_gameplayfix_slidemoveprojectiles.integer || (PRVM_serveredictfloat(ent, movetype) != MOVETYPE_BOUNCE && PRVM_serveredictfloat(ent, movetype) == MOVETYPE_BOUNCEMISSILE) || ((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND))
+                       movetime = 0;
                        break;
+               }
        }
 
 // check for in water