]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_phys.c
this commit adds video mode switching, and preferred mode is saved to config, no...
[xonotic/darkplaces.git] / sv_phys.c
index 0d89b119fa0dd04482e3406947f06dbdbaebfdf5..b89e114dfe21ef2cd8f4c145e069f9e2e4326df1 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -771,18 +771,18 @@ qboolean SV_CheckWater (edict_t *ent)
 
        ent->v.waterlevel = 0;
        ent->v.watertype = CONTENTS_EMPTY;
-       cont = Mod_PointInLeaf(point, sv.worldmodel)->contents;
+       cont = Mod_PointContents(point, sv.worldmodel);
        if (cont <= CONTENTS_WATER)
        {
                ent->v.watertype = cont;
                ent->v.waterlevel = 1;
                point[2] = ent->v.origin[2] + (ent->v.mins[2] + ent->v.maxs[2])*0.5;
-               cont = Mod_PointInLeaf(point, sv.worldmodel)->contents;
+               cont = Mod_PointContents(point, sv.worldmodel);
                if (cont <= CONTENTS_WATER)
                {
                        ent->v.waterlevel = 2;
                        point[2] = ent->v.origin[2] + ent->v.view_ofs[2];
-                       cont = Mod_PointInLeaf(point, sv.worldmodel)->contents;
+                       cont = Mod_PointContents(point, sv.worldmodel);
                        if (cont <= CONTENTS_WATER)
                                ent->v.waterlevel = 3;
                }
@@ -943,13 +943,11 @@ void SV_WalkMove (edict_t *ent)
 
        // check for stuckness, possibly due to the limited precision of floats
        // in the clipping hulls
-       /*
        if (clip
         && fabs(oldorg[1] - ent->v.origin[1]) < 0.03125
         && fabs(oldorg[0] - ent->v.origin[0]) < 0.03125)
                // stepping up didn't make any progress
                clip = SV_TryUnstick (ent, oldvel);
-       */
 
        // extra friction based on view angle
        if (clip & 2 && sv_wallfriction.integer)
@@ -961,7 +959,7 @@ void SV_WalkMove (edict_t *ent)
 
        if (downtrace.plane.normal[2] > 0.7)
        {
-               if (ent->v.solid == SOLID_BSP)
+               //if (ent->v.solid == SOLID_BSP)
                {
                        ent->v.flags =  (int)ent->v.flags | FL_ONGROUND;
                        ent->v.groundentity = EDICT_TO_PROG(downtrace.ent);
@@ -1137,8 +1135,8 @@ SV_CheckWaterTransition
 */
 void SV_CheckWaterTransition (edict_t *ent)
 {
-       int             cont;
-       cont = Mod_PointInLeaf(ent->v.origin, sv.worldmodel)->contents;
+       int cont;
+       cont = Mod_PointContents(ent->v.origin, sv.worldmodel);
        if (!ent->v.watertype)
        {
                // just spawned here
@@ -1149,7 +1147,7 @@ void SV_CheckWaterTransition (edict_t *ent)
 
        if (cont <= CONTENTS_WATER)
        {
-               if (ent->v.watertype == CONTENTS_EMPTY)
+               if (ent->v.watertype == CONTENTS_EMPTY && cont != CONTENTS_LAVA)
                        // just crossed into water
                        SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1);
 
@@ -1158,7 +1156,7 @@ void SV_CheckWaterTransition (edict_t *ent)
        }
        else
        {
-               if (ent->v.watertype != CONTENTS_EMPTY)
+               if (ent->v.watertype != CONTENTS_EMPTY && ent->v.watertype != CONTENTS_LAVA)
                        // just crossed into water
                        SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1);
 
@@ -1187,12 +1185,18 @@ void SV_Physics_Toss (edict_t *ent)
 // if onground, return without moving
        if ((int)ent->v.flags & FL_ONGROUND)
        {
+               VectorClear(ent->v.velocity);
                if (ent->v.groundentity == 0)
                        return;
+               // if ent was supported by a brush model on previous frame,
+               // and groundentity is now freed, set groundentity to 0 (floating)
                groundentity = PROG_TO_EDICT(ent->v.groundentity);
-               if (groundentity != NULL && groundentity->v.solid == SOLID_BSP)
+               if (groundentity->v.solid == SOLID_BSP)
+               {
                        ent->suspendedinairflag = true;
-               else if (ent->suspendedinairflag && (groundentity == NULL || groundentity->free))
+                       return;
+               }
+               else if (ent->suspendedinairflag && groundentity->free)
                {
                        // leave it suspended in the air
                        ent->v.groundentity = 0;
@@ -1205,9 +1209,7 @@ void SV_Physics_Toss (edict_t *ent)
        SV_CheckVelocity (ent);
 
 // add gravity
-       if (ent->v.movetype != MOVETYPE_FLY
-        && ent->v.movetype != MOVETYPE_BOUNCEMISSILE // LordHavoc: enabled MOVETYPE_BOUNCEMISSILE
-        && ent->v.movetype != MOVETYPE_FLYMISSILE)
+       if (ent->v.movetype == MOVETYPE_TOSS || ent->v.movetype == MOVETYPE_BOUNCE)
                SV_AddGravity (ent);
 
 // move angles
@@ -1218,40 +1220,41 @@ void SV_Physics_Toss (edict_t *ent)
        trace = SV_PushEntity (ent, move, vec3_origin);
        if (ent->free)
                return;
-       if (trace.fraction == 1)
-               return;
 
-       if (ent->v.movetype == MOVETYPE_BOUNCEMISSILE)
-       {
-               ClipVelocity (ent->v.velocity, trace.plane.normal, ent->v.velocity, 2.0);
-               ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND;
-       }
-       else if (ent->v.movetype == MOVETYPE_BOUNCE)
+       if (trace.fraction < 1)
        {
-               ClipVelocity (ent->v.velocity, trace.plane.normal, ent->v.velocity, 1.5);
-               // LordHavoc: fixed grenades not bouncing when fired down a slope
-               if (trace.plane.normal[2] > 0.7 && DotProduct(trace.plane.normal, ent->v.velocity) < 60)
+               if (ent->v.movetype == MOVETYPE_BOUNCEMISSILE)
                {
-                       ent->v.flags = (int)ent->v.flags | FL_ONGROUND;
-                       ent->v.groundentity = EDICT_TO_PROG(trace.ent);
-                       VectorClear (ent->v.velocity);
-                       VectorClear (ent->v.avelocity);
-               }
-               else
+                       ClipVelocity (ent->v.velocity, trace.plane.normal, ent->v.velocity, 2.0);
                        ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND;
-       }
-       else
-       {
-               ClipVelocity (ent->v.velocity, trace.plane.normal, ent->v.velocity, 1.0);
-               if (trace.plane.normal[2] > 0.7)
+               }
+               else if (ent->v.movetype == MOVETYPE_BOUNCE)
                {
-                       ent->v.flags = (int)ent->v.flags | FL_ONGROUND;
-                       ent->v.groundentity = EDICT_TO_PROG(trace.ent);
-                       VectorClear (ent->v.velocity);
-                       VectorClear (ent->v.avelocity);
+                       ClipVelocity (ent->v.velocity, trace.plane.normal, ent->v.velocity, 1.5);
+                       // LordHavoc: fixed grenades not bouncing when fired down a slope
+                       if (trace.plane.normal[2] > 0.7 && DotProduct(trace.plane.normal, ent->v.velocity) < 60)
+                       {
+                               ent->v.flags = (int)ent->v.flags | FL_ONGROUND;
+                               ent->v.groundentity = EDICT_TO_PROG(trace.ent);
+                               VectorClear (ent->v.velocity);
+                               VectorClear (ent->v.avelocity);
+                       }
+                       else
+                               ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND;
                }
                else
-                       ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND;
+               {
+                       ClipVelocity (ent->v.velocity, trace.plane.normal, ent->v.velocity, 1.0);
+                       if (trace.plane.normal[2] > 0.7)
+                       {
+                               ent->v.flags = (int)ent->v.flags | FL_ONGROUND;
+                               ent->v.groundentity = EDICT_TO_PROG(trace.ent);
+                               VectorClear (ent->v.velocity);
+                               VectorClear (ent->v.avelocity);
+                       }
+                       else
+                               ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND;
+               }
        }
 
 // check for in water
@@ -1288,7 +1291,7 @@ void SV_Physics_Step (edict_t *ent)
        {
                if (flags & FL_FLY)
                        fall = false;
-               else if ((flags & FL_SWIM) && Mod_PointInLeaf(ent->v.origin, sv.worldmodel)->contents != CONTENTS_EMPTY)
+               else if ((flags & FL_SWIM) && Mod_PointContents(ent->v.origin, sv.worldmodel) != CONTENTS_EMPTY)
                        fall = false;
        }
        if (fall && (flags & FL_ONGROUND) && ent->v.groundentity == 0)