]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_phys.c
use checkdisk flag on model loading after ingame download, this should
[xonotic/darkplaces.git] / sv_phys.c
index 9c8b532b111ed547aee40bacc962a7e68de41328..c0142c5940125072a1e0de64364b00f6c723d3dc 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -174,7 +174,7 @@ trace_t SV_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int
        // clip to entities
        // because this uses World_EntitiestoBox, we know all entity boxes overlap
        // the clip region, so we can skip culling checks in the loop below
-       numtouchedicts = World_EntitiesInBox(&sv.world, clipboxmins, clipboxmaxs, MAX_EDICTS, touchedicts);
+       numtouchedicts = SV_EntitiesInBox(clipboxmins, clipboxmaxs, MAX_EDICTS, touchedicts);
        if (numtouchedicts > MAX_EDICTS)
        {
                // this never happens
@@ -340,7 +340,7 @@ trace_t SV_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
        // clip to entities
        // because this uses World_EntitiestoBox, we know all entity boxes overlap
        // the clip region, so we can skip culling checks in the loop below
-       numtouchedicts = World_EntitiesInBox(&sv.world, clipboxmins, clipboxmaxs, MAX_EDICTS, touchedicts);
+       numtouchedicts = SV_EntitiesInBox(clipboxmins, clipboxmaxs, MAX_EDICTS, touchedicts);
        if (numtouchedicts > MAX_EDICTS)
        {
                // this never happens
@@ -553,7 +553,7 @@ trace_t SV_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
        // clip to entities
        // because this uses World_EntitiestoBox, we know all entity boxes overlap
        // the clip region, so we can skip culling checks in the loop below
-       numtouchedicts = World_EntitiesInBox(&sv.world, clipboxmins, clipboxmaxs, MAX_EDICTS, touchedicts);
+       numtouchedicts = SV_EntitiesInBox(clipboxmins, clipboxmaxs, MAX_EDICTS, touchedicts);
        if (numtouchedicts > MAX_EDICTS)
        {
                // this never happens
@@ -662,7 +662,7 @@ int SV_PointSuperContents(const vec3_t point)
                return supercontents;
 
        // get list of entities at this point
-       numtouchedicts = World_EntitiesInBox(&sv.world, point, point, MAX_EDICTS, touchedicts);
+       numtouchedicts = SV_EntitiesInBox(point, point, MAX_EDICTS, touchedicts);
        if (numtouchedicts > MAX_EDICTS)
        {
                // this never happens
@@ -699,6 +699,34 @@ Linking entities into the world culling system
 ===============================================================================
 */
 
+int SV_EntitiesInBox(const vec3_t mins, const vec3_t maxs, int maxedicts, prvm_edict_t **resultedicts)
+{
+       vec3_t paddedmins, paddedmaxs;
+       if (maxedicts < 1 || resultedicts == NULL)
+               return 0;
+       VectorSet(paddedmins, mins[0] - 10, mins[1] - 10, mins[2] - 1);
+       VectorSet(paddedmaxs, maxs[0] + 10, maxs[1] + 10, maxs[2] + 1);
+       if (sv_areadebug.integer)
+       {
+               int numresultedicts = 0;
+               int edictindex;
+               prvm_edict_t *ed;
+               for (edictindex = 1;edictindex < prog->num_edicts;edictindex++)
+               {
+                       ed = PRVM_EDICT_NUM(edictindex);
+                       if (!ed->priv.required->free && BoxesOverlap(PRVM_serveredictvector(ed, absmin), PRVM_serveredictvector(ed, absmax), paddedmins, paddedmaxs))
+                       {
+                               resultedicts[numresultedicts++] = ed;
+                               if (numresultedicts == maxedicts)
+                                       break;
+                       }
+               }
+               return numresultedicts;
+       }
+       else
+               return World_EntitiesInBox(&sv.world, paddedmins, paddedmaxs, maxedicts, resultedicts);
+}
+
 void SV_LinkEdict_TouchAreaGrid_Call(prvm_edict_t *touch, prvm_edict_t *ent)
 {
        PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(touch);
@@ -737,7 +765,7 @@ void SV_LinkEdict_TouchAreaGrid(prvm_edict_t *ent)
 
        // build a list of edicts to touch, because the link loop can be corrupted
        // by IncreaseEdicts called during touch functions
-       numtouchedicts = World_EntitiesInBox(&sv.world, ent->priv.server->areamins, ent->priv.server->areamaxs, MAX_EDICTS, touchedicts);
+       numtouchedicts = SV_EntitiesInBox(ent->priv.server->areamins, ent->priv.server->areamaxs, MAX_EDICTS, touchedicts);
        if (numtouchedicts > MAX_EDICTS)
        {
                // this never happens
@@ -919,7 +947,7 @@ static int SV_TestEntityPosition (prvm_edict_t *ent, vec3_t offset)
        trace_t trace;
        contents = SV_GenericHitSuperContentsMask(ent);
        VectorAdd(PRVM_serveredictvector(ent, origin), offset, org);
-       trace = SV_TraceBox(org, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), PRVM_serveredictvector(ent, origin), MOVE_NOMONSTERS, ent, contents);
+       trace = SV_TraceBox(org, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), PRVM_serveredictvector(ent, origin), ((PRVM_serveredictfloat(ent, movetype) == MOVETYPE_FLY_WORLDONLY) ? MOVE_WORLDONLY : MOVE_NOMONSTERS), ent, contents);
        if (trace.startsupercontents & contents)
                return true;
        else
@@ -987,7 +1015,8 @@ void SV_CheckAllEnts (void)
                if (PRVM_serveredictfloat(check, movetype) == MOVETYPE_PUSH
                 || PRVM_serveredictfloat(check, movetype) == MOVETYPE_NONE
                 || PRVM_serveredictfloat(check, movetype) == MOVETYPE_FOLLOW
-                || PRVM_serveredictfloat(check, movetype) == MOVETYPE_NOCLIP)
+                || PRVM_serveredictfloat(check, movetype) == MOVETYPE_NOCLIP
+                || PRVM_serveredictfloat(check, movetype) == MOVETYPE_FLY_WORLDONLY)
                        continue;
 
                if (SV_TestEntityPosition (check, vec3_origin))
@@ -1449,6 +1478,120 @@ PUSHMOVE
 ===============================================================================
 */
 
+static qboolean SV_NudgeOutOfSolid_PivotIsKnownGood(prvm_edict_t *ent, vec3_t pivot)
+{
+       int bump;
+       trace_t stucktrace;
+       vec3_t stuckorigin;
+       vec3_t stuckmins, stuckmaxs;
+       vec3_t goodmins, goodmaxs;
+       vec3_t testorigin;
+       vec_t nudge;
+       vec3_t move;
+       VectorCopy(PRVM_serveredictvector(ent, origin), stuckorigin);
+       VectorCopy(PRVM_serveredictvector(ent, mins), stuckmins);
+       VectorCopy(PRVM_serveredictvector(ent, maxs), stuckmaxs);
+       VectorCopy(pivot, goodmins);
+       VectorCopy(pivot, goodmaxs);
+       for (bump = 0;bump < 6;bump++)
+       {
+               int coord = 2-(bump >> 1);
+               //int coord = (bump >> 1);
+               int dir = (bump & 1);
+               int subbump;
+
+               for(subbump = 0; ; ++subbump)
+               {
+                       VectorCopy(stuckorigin, testorigin);
+                       if(dir)
+                       {
+                               // pushing maxs
+                               testorigin[coord] += stuckmaxs[coord] - goodmaxs[coord];
+                       }
+                       else
+                       {
+                               // pushing mins
+                               testorigin[coord] += stuckmins[coord] - goodmins[coord];
+                       }
+
+                       stucktrace = SV_TraceBox(stuckorigin, goodmins, goodmaxs, testorigin, MOVE_NOMONSTERS, ent, SV_GenericHitSuperContentsMask(ent));
+                       if (stucktrace.bmodelstartsolid)
+                       {
+                               // BAD BAD, can't fix that
+                               return false;
+                       }
+
+                       if (stucktrace.fraction >= 1)
+                               break; // it WORKS!
+
+                       if(subbump >= 10)
+                       {
+                               // BAD BAD, can't fix that
+                               return false;
+                       }
+
+                       // we hit something... let's move out of it
+                       VectorSubtract(stucktrace.endpos, testorigin, move);
+                       nudge = DotProduct(stucktrace.plane.normal, move) + 0.03125f; // FIXME cvar this constant
+                       VectorMA(stuckorigin, nudge, stucktrace.plane.normal, stuckorigin);
+               }
+               /*
+               if(subbump > 0)
+                       Con_Printf("subbump: %d\n", subbump);
+               */
+
+               if(dir)
+               {
+                       // pushing maxs
+                       goodmaxs[coord] = stuckmaxs[coord];
+               }
+               else
+               {
+                       // pushing mins
+                       goodmins[coord] = stuckmins[coord];
+               }
+       }
+
+       // WE WIN
+       VectorCopy(stuckorigin, PRVM_serveredictvector(ent, origin));
+
+       return true;
+}
+
+static qboolean SV_NudgeOutOfSolid(prvm_edict_t *ent)
+{
+       int bump;
+       trace_t stucktrace;
+       vec3_t stuckorigin;
+       vec3_t stuckmins, stuckmaxs;
+       vec_t nudge;
+       vec_t separation = sv_gameplayfix_nudgeoutofsolid_separation.value;
+       if (sv.worldmodel && sv.worldmodel->brushq1.numclipnodes)
+               separation = 0.0f; // when using hulls, it can not be enlarged
+       VectorCopy(PRVM_serveredictvector(ent, origin), stuckorigin);
+       VectorCopy(PRVM_serveredictvector(ent, mins), stuckmins);
+       VectorCopy(PRVM_serveredictvector(ent, maxs), stuckmaxs);
+       stuckmins[0] -= separation;
+       stuckmins[1] -= separation;
+       stuckmins[2] -= separation;
+       stuckmaxs[0] += separation;
+       stuckmaxs[1] += separation;
+       stuckmaxs[2] += separation;
+       for (bump = 0;bump < 10;bump++)
+       {
+               stucktrace = SV_TraceBox(stuckorigin, stuckmins, stuckmaxs, stuckorigin, MOVE_NOMONSTERS, ent, SV_GenericHitSuperContentsMask(ent));
+               if (!stucktrace.bmodelstartsolid || stucktrace.startdepth >= 0)
+               {
+                       // found a good location, use it
+                       VectorCopy(stuckorigin, PRVM_serveredictvector(ent, origin));
+                       return true;
+               }
+               nudge = -stucktrace.startdepth;
+               VectorMA(stuckorigin, nudge, stucktrace.startdepthnormal, stuckorigin);
+       }
+       return false;
+}
+
 /*
 ============
 SV_PushEntity
@@ -1463,7 +1606,6 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
        int solid;
        int movetype;
        int type;
-       int bump;
        vec3_t mins, maxs;
        vec3_t original, original_velocity;
        vec3_t start;
@@ -1477,34 +1619,7 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
        // move start position out of solids
        if (sv_gameplayfix_nudgeoutofsolid.integer && sv_gameplayfix_nudgeoutofsolid_separation.value >= 0)
        {
-               trace_t stucktrace;
-               vec3_t stuckorigin;
-               vec3_t stuckmins, stuckmaxs;
-               vec_t nudge;
-               vec_t separation = sv_gameplayfix_nudgeoutofsolid_separation.value;
-               if (sv.worldmodel && sv.worldmodel->brushq1.numclipnodes)
-                       separation = 0.0f; // when using hulls, it can not be enlarged
-               VectorCopy(PRVM_serveredictvector(ent, origin), stuckorigin);
-               VectorCopy(mins, stuckmins);
-               VectorCopy(maxs, stuckmaxs);
-               stuckmins[0] -= separation;
-               stuckmins[1] -= separation;
-               stuckmins[2] -= separation;
-               stuckmaxs[0] += separation;
-               stuckmaxs[1] += separation;
-               stuckmaxs[2] += separation;
-               for (bump = 0;bump < 10;bump++)
-               {
-                       stucktrace = SV_TraceBox(stuckorigin, stuckmins, stuckmaxs, stuckorigin, MOVE_NOMONSTERS, ent, SV_GenericHitSuperContentsMask(ent));
-                       if (!stucktrace.bmodelstartsolid || stucktrace.startdepth >= 0)
-                       {
-                               // found a good location, use it
-                               VectorCopy(stuckorigin, PRVM_serveredictvector(ent, origin));
-                               break;
-                       }
-                       nudge = -stucktrace.startdepth;
-                       VectorMA(stuckorigin, nudge, stucktrace.startdepthnormal, stuckorigin);
-               }
+               SV_NudgeOutOfSolid(ent);
        }
 
        VectorCopy(PRVM_serveredictvector(ent, origin), start);
@@ -1512,6 +1627,8 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
 
        if (movetype == MOVETYPE_FLYMISSILE)
                type = MOVE_MISSILE;
+       else if (movetype == MOVETYPE_FLY_WORLDONLY)
+               type = MOVE_WORLDONLY;
        else if (solid == SOLID_TRIGGER || solid == SOLID_NOT)
                type = MOVE_NOMONSTERS; // only clip against bmodels
        else
@@ -1567,6 +1684,7 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
        trace_t trace, trace2;
        matrix4x4_t pusherfinalmatrix, pusherfinalimatrix;
        static unsigned short moved_edicts[MAX_EDICTS];
+       vec3_t pivot;
 
        if (!PRVM_serveredictvector(pusher, velocity)[0] && !PRVM_serveredictvector(pusher, velocity)[1] && !PRVM_serveredictvector(pusher, velocity)[2] && !PRVM_serveredictvector(pusher, avelocity)[0] && !PRVM_serveredictvector(pusher, avelocity)[1] && !PRVM_serveredictvector(pusher, avelocity)[2])
        {
@@ -1684,7 +1802,10 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
 // see if any solid entities are inside the final position
        num_moved = 0;
 
-       numcheckentities = World_EntitiesInBox(&sv.world, mins, maxs, MAX_EDICTS, checkentities);
+       if (PRVM_serveredictfloat(pusher, movetype) == MOVETYPE_FAKEPUSH) // Tenebrae's MOVETYPE_PUSH variant that doesn't push...
+               numcheckentities = 0;
+       else // MOVETYPE_PUSH
+               numcheckentities = SV_EntitiesInBox(mins, maxs, MAX_EDICTS, checkentities);
        for (e = 0;e < numcheckentities;e++)
        {
                prvm_edict_t *check = checkentities[e];
@@ -1695,7 +1816,7 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
                case MOVETYPE_PUSH:
                case MOVETYPE_FOLLOW:
                case MOVETYPE_NOCLIP:
-               case MOVETYPE_FAKEPUSH:
+               case MOVETYPE_FLY_WORLDONLY:
                        continue;
                default:
                        break;
@@ -1728,10 +1849,14 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
                        }
                }
 
+               VectorLerp(PRVM_serveredictvector(check, mins), 0.5f, PRVM_serveredictvector(check, maxs), pivot);
+               //VectorClear(pivot);
+
                if (rotated)
                {
                        vec3_t org2;
                        VectorSubtract (PRVM_serveredictvector(check, origin), PRVM_serveredictvector(pusher, origin), org);
+                       VectorAdd (org, pivot, org);
                        org2[0] = DotProduct (org, forward);
                        org2[1] = DotProduct (org, left);
                        org2[2] = DotProduct (org, up);
@@ -1780,72 +1905,55 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
                Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, PRVM_serveredictvector(pusher, mins), PRVM_serveredictvector(pusher, maxs), SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, PRVM_serveredictvector(check, origin), PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs), PRVM_serveredictvector(check, origin), checkcontents);
                if (trace.startsolid)
                {
-                       // try moving the contacted entity a tiny bit further to account for precision errors
                        vec3_t move2;
-                       PRVM_serveredictfloat(pusher, solid) = SOLID_NOT;
-                       VectorScale(move, 1.1, move2);
-                       VectorCopy (check->priv.server->moved_from, PRVM_serveredictvector(check, origin));
-                       VectorCopy (check->priv.server->moved_fromangles, PRVM_serveredictvector(check, angles));
-                       if(!SV_PushEntity (&trace2, check, move2, true, true))
-                       {
-                               // entity "check" got teleported
-                               continue;
-                       }
-                       PRVM_serveredictfloat(pusher, solid) = savesolid;
-                       Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, PRVM_serveredictvector(pusher, mins), PRVM_serveredictvector(pusher, maxs), SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, PRVM_serveredictvector(check, origin), PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs), PRVM_serveredictvector(check, origin), checkcontents);
-                       if (trace.startsolid)
+                       if(SV_NudgeOutOfSolid_PivotIsKnownGood(check, pivot))
                        {
-                               // try moving the contacted entity a tiny bit less to account for precision errors
-                               PRVM_serveredictfloat(pusher, solid) = SOLID_NOT;
-                               VectorScale(move, 0.9, move2);
-                               VectorCopy (check->priv.server->moved_from, PRVM_serveredictvector(check, origin));
-                               VectorCopy (check->priv.server->moved_fromangles, PRVM_serveredictvector(check, angles));
-                               if(!SV_PushEntity (&trace2, check, move2, true, true))
+                               // hack to invoke all necessary movement triggers
+                               VectorClear(move2);
+                               if(!SV_PushEntity(&trace2, check, move2, true, true))
                                {
                                        // entity "check" got teleported
                                        continue;
                                }
-                               PRVM_serveredictfloat(pusher, solid) = savesolid;
-                               Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, PRVM_serveredictvector(pusher, mins), PRVM_serveredictvector(pusher, maxs), SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, PRVM_serveredictvector(check, origin), PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs), PRVM_serveredictvector(check, origin), checkcontents);
-                               if (trace.startsolid)
-                               {
-                                       // still inside pusher, so it's really blocked
-
-                                       // fail the move
-                                       if (PRVM_serveredictvector(check, mins)[0] == PRVM_serveredictvector(check, maxs)[0])
-                                               continue;
-                                       if (PRVM_serveredictfloat(check, solid) == SOLID_NOT || PRVM_serveredictfloat(check, solid) == SOLID_TRIGGER)
-                                       {
-                                               // corpse
-                                               PRVM_serveredictvector(check, mins)[0] = PRVM_serveredictvector(check, mins)[1] = 0;
-                                               VectorCopy (PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs));
-                                               continue;
-                                       }
-
-                                       VectorCopy (pushorig, PRVM_serveredictvector(pusher, origin));
-                                       VectorCopy (pushang, PRVM_serveredictvector(pusher, angles));
-                                       PRVM_serveredictfloat(pusher, ltime) = pushltime;
-                                       SV_LinkEdict(pusher);
-
-                                       // move back any entities we already moved
-                                       for (i = 0;i < num_moved;i++)
-                                       {
-                                               prvm_edict_t *ed = PRVM_EDICT_NUM(moved_edicts[i]);
-                                               VectorCopy (ed->priv.server->moved_from, PRVM_serveredictvector(ed, origin));
-                                               VectorCopy (ed->priv.server->moved_fromangles, PRVM_serveredictvector(ed, angles));
-                                               SV_LinkEdict(ed);
-                                       }
-
-                                       // if the pusher has a "blocked" function, call it, otherwise just stay in place until the obstacle is gone
-                                       if (PRVM_serveredictfunction(pusher, blocked))
-                                       {
-                                               PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(pusher);
-                                               PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(check);
-                                               PRVM_ExecuteProgram (PRVM_serveredictfunction(pusher, blocked), "QC function self.blocked is missing");
-                                       }
-                                       break;
-                               }
+                               // we could fix it
+                               continue;
                        }
+
+                       // still inside pusher, so it's really blocked
+
+                       // fail the move
+                       if (PRVM_serveredictvector(check, mins)[0] == PRVM_serveredictvector(check, maxs)[0])
+                               continue;
+                       if (PRVM_serveredictfloat(check, solid) == SOLID_NOT || PRVM_serveredictfloat(check, solid) == SOLID_TRIGGER)
+                       {
+                               // corpse
+                               PRVM_serveredictvector(check, mins)[0] = PRVM_serveredictvector(check, mins)[1] = 0;
+                               VectorCopy (PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs));
+                               continue;
+                       }
+
+                       VectorCopy (pushorig, PRVM_serveredictvector(pusher, origin));
+                       VectorCopy (pushang, PRVM_serveredictvector(pusher, angles));
+                       PRVM_serveredictfloat(pusher, ltime) = pushltime;
+                       SV_LinkEdict(pusher);
+
+                       // move back any entities we already moved
+                       for (i = 0;i < num_moved;i++)
+                       {
+                               prvm_edict_t *ed = PRVM_EDICT_NUM(moved_edicts[i]);
+                               VectorCopy (ed->priv.server->moved_from, PRVM_serveredictvector(ed, origin));
+                               VectorCopy (ed->priv.server->moved_fromangles, PRVM_serveredictvector(ed, angles));
+                               SV_LinkEdict(ed);
+                       }
+
+                       // if the pusher has a "blocked" function, call it, otherwise just stay in place until the obstacle is gone
+                       if (PRVM_serveredictfunction(pusher, blocked))
+                       {
+                               PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(pusher);
+                               PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(check);
+                               PRVM_ExecuteProgram (PRVM_serveredictfunction(pusher, blocked), "QC function self.blocked is missing");
+                       }
+                       break;
                }
        }
        PRVM_serveredictvector(pusher, angles)[0] -= 360.0 * floor(PRVM_serveredictvector(pusher, angles)[0] * (1.0 / 360.0));
@@ -2184,7 +2292,8 @@ void SV_WalkMove (prvm_edict_t *ent)
        if (sv.frametime <= 0)
                return;
 
-       SV_CheckStuck (ent);
+       if (sv_gameplayfix_unstickplayers.integer)
+               SV_CheckStuck (ent);
 
        applygravity = !SV_CheckWater (ent) && PRVM_serveredictfloat(ent, movetype) == MOVETYPE_WALK && ! ((int)PRVM_serveredictfloat(ent, flags) & FL_WATERJUMP);
 
@@ -2210,6 +2319,8 @@ void SV_WalkMove (prvm_edict_t *ent)
                VectorSet(downmove, PRVM_serveredictvector(ent, origin)[0], PRVM_serveredictvector(ent, origin)[1], PRVM_serveredictvector(ent, origin)[2] - 1);
                if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_FLYMISSILE)
                        type = MOVE_MISSILE;
+               else if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_FLY_WORLDONLY)
+                       type = MOVE_WORLDONLY;
                else if (PRVM_serveredictfloat(ent, solid) == SOLID_TRIGGER || PRVM_serveredictfloat(ent, solid) == SOLID_NOT)
                        type = MOVE_NOMONSTERS; // only clip against bmodels
                else
@@ -2422,25 +2533,28 @@ SV_CheckWaterTransition
 */
 void SV_CheckWaterTransition (prvm_edict_t *ent)
 {
+       // LordHavoc: bugfixes in this function are keyed to the sv_gameplayfix_bugfixedcheckwatertransition cvar - if this cvar is 0 then all the original bugs should be reenabled for compatibility
        int cont;
        cont = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, SV_PointSuperContents(PRVM_serveredictvector(ent, origin)));
        if (!PRVM_serveredictfloat(ent, watertype))
        {
                // just spawned here
-               PRVM_serveredictfloat(ent, watertype) = cont;
-               PRVM_serveredictfloat(ent, waterlevel) = 1;
-               return;
+               if (!sv_gameplayfix_fixedcheckwatertransition.integer)
+               {
+                       PRVM_serveredictfloat(ent, watertype) = cont;
+                       PRVM_serveredictfloat(ent, waterlevel) = 1;
+                       return;
+               }
        }
-
        // DRESK - Support for Entity Contents Transition Event
        // NOTE: Call here BEFORE updating the watertype below,
        // and suppress watersplash sound if a valid function
        // call was made to allow for custom "splash" sounds.
-       if( !SV_CheckContentsTransition(ent, cont) )
+       else if( !SV_CheckContentsTransition(ent, cont) )
        { // Contents Transition Function Invalid; Potentially Play Water Sound
                // check if the entity crossed into or out of water
                if (sv_sound_watersplash.string && ((PRVM_serveredictfloat(ent, watertype) == CONTENTS_WATER || PRVM_serveredictfloat(ent, watertype) == CONTENTS_SLIME) != (cont == CONTENTS_WATER || cont == CONTENTS_SLIME)))
-                       SV_StartSound (ent, 0, sv_sound_watersplash.string, 255, 1);
+                       SV_StartSound (ent, 0, sv_sound_watersplash.string, 255, 1, false, 1.0f);
        }
 
        if (cont <= CONTENTS_WATER)
@@ -2451,7 +2565,7 @@ void SV_CheckWaterTransition (prvm_edict_t *ent)
        else
        {
                PRVM_serveredictfloat(ent, watertype) = CONTENTS_EMPTY;
-               PRVM_serveredictfloat(ent, waterlevel) = 0;
+               PRVM_serveredictfloat(ent, waterlevel) = sv_gameplayfix_fixedcheckwatertransition.integer ? 0 : cont;
        }
 }
 
@@ -2462,6 +2576,7 @@ SV_Physics_Toss
 Toss, bounce, and fly movement.  When onground, do nothing.
 =============
 */
+
 void SV_Physics_Toss (prvm_edict_t *ent)
 {
        trace_t trace;
@@ -2522,7 +2637,8 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                if (trace.bmodelstartsolid)
                {
                        // try to unstick the entity
-                       SV_UnstickEntity(ent);
+                       if (sv_gameplayfix_unstickentities.integer)
+                               SV_UnstickEntity(ent);
                        if(!SV_PushEntity (&trace, ent, move, false, true))
                                return; // teleported
                        if (ent->priv.server->free)
@@ -2683,7 +2799,7 @@ void SV_Physics_Step (prvm_edict_t *ent)
                                else
                                // Check for Engine Landing Sound
                                if(sv_sound_land.string)
-                                       SV_StartSound(ent, 0, sv_sound_land.string, 255, 1);
+                                       SV_StartSound(ent, 0, sv_sound_land.string, 255, 1, false, 1.0f);
                        }
                        ent->priv.server->waterposition_forceupdate = true;
                }
@@ -2750,6 +2866,7 @@ static void SV_Physics_Entity (prvm_edict_t *ent)
        case MOVETYPE_BOUNCEMISSILE:
        case MOVETYPE_FLYMISSILE:
        case MOVETYPE_FLY:
+       case MOVETYPE_FLY_WORLDONLY:
                // regular thinking
                if (SV_RunThink (ent))
                        SV_Physics_Toss (ent);
@@ -2922,6 +3039,7 @@ static void SV_Physics_ClientEntity(prvm_edict_t *ent)
                SV_Physics_Toss (ent);
                break;
        case MOVETYPE_FLY:
+       case MOVETYPE_FLY_WORLDONLY:
                SV_RunThink (ent);
                SV_WalkMove (ent);
                break;