]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_phys.c
changed Host_Init to execute configs only once
[xonotic/darkplaces.git] / sv_phys.c
index df4990be4214146c73f9b7e0ae70dfdc74e5ba41..fa0101f3dfe59ab7a0b5817530b0c95f6140bb92 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -459,7 +459,7 @@ int SV_FlyMove (edict_t *ent, float time, float *stepnormal)
                ent->v->groundentity = EDICT_TO_PROG(hackongroundentity);
        }
        */
-       
+
        /*
        if ((blocked & 1) == 0 && bumpcount > 1)
        {
@@ -677,7 +677,7 @@ void SV_PushMove (edict_t *pusher, float movetime)
        num_moved = 0;
 
        numcheckentities = SV_EntitiesInBox(mins, maxs, MAX_EDICTS, checkentities);
-       for (e = 1;e < numcheckentities;e++)
+       for (e = 0;e < numcheckentities;e++)
        {
                check = checkentities[e];
                if (check->v->movetype == MOVETYPE_PUSH
@@ -692,7 +692,7 @@ void SV_PushMove (edict_t *pusher, float movetime)
                        if (!SV_ClipMoveToEntity(pusher, check->v->origin, check->v->mins, check->v->maxs, check->v->origin).startsolid)
                                continue;
 
-               if (forward[0] != 1) // quick way to check if any rotation is used
+               if (forward[0] != 1 || left[1] != 1) // quick way to check if any rotation is used
                {
                        VectorSubtract (check->v->origin, pusher->v->origin, org);
                        org2[0] = DotProduct (org, forward);
@@ -881,19 +881,17 @@ qboolean SV_CheckWater (edict_t *ent)
 
        ent->v->waterlevel = 0;
        ent->v->watertype = CONTENTS_EMPTY;
-       cont = SV_PointQ1Contents(point);
-       if (cont <= CONTENTS_WATER)
+       cont = SV_PointSuperContents(point);
+       if (cont & (SUPERCONTENTS_LIQUIDSMASK))
        {
-               ent->v->watertype = cont;
+               ent->v->watertype = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, cont);
                ent->v->waterlevel = 1;
                point[2] = ent->v->origin[2] + (ent->v->mins[2] + ent->v->maxs[2])*0.5;
-               cont = SV_PointQ1Contents(point);
-               if (cont <= CONTENTS_WATER)
+               if (SV_PointSuperContents(point) & (SUPERCONTENTS_LIQUIDSMASK))
                {
                        ent->v->waterlevel = 2;
                        point[2] = ent->v->origin[2] + ent->v->view_ofs[2];
-                       cont = SV_PointQ1Contents(point);
-                       if (cont <= CONTENTS_WATER)
+                       if (SV_PointSuperContents(point) & (SUPERCONTENTS_LIQUIDSMASK))
                                ent->v->waterlevel = 3;
                }
        }
@@ -1022,44 +1020,44 @@ void SV_WalkMove (edict_t *ent)
 
        if (sv_nostep.integer)
                return;
-       
+
        // if move didn't block on a step, return
        if (clip & 2)
        {
                // if move was not trying to move into the step, return
                if (fabs(start_velocity[0]) < 0.03125 && fabs(start_velocity[1]) < 0.03125)
                        return;
-       
+
                if (ent->v->movetype != MOVETYPE_FLY)
                {
                        // return if gibbed by a trigger
                        if (ent->v->movetype != MOVETYPE_WALK)
                                return;
-       
+
                        // only step up while jumping if that is enabled
                        if (!(sv_jumpstep.integer && sv_gameplayfix_stepwhilejumping.integer))
                                if (!oldonground && ent->v->waterlevel == 0)
                                        return;
                }
-       
+
                // try moving up and forward to go up a step
                // back to start pos
                VectorCopy (start_origin, ent->v->origin);
                VectorCopy (start_velocity, ent->v->velocity);
-       
+
                // move up
                VectorClear (upmove);
                upmove[2] = sv_stepheight.value;
                // FIXME: don't link?
                SV_PushEntity(ent, upmove);
-       
+
                // move forward
                ent->v->velocity[2] = 0;
                clip = SV_FlyMove (ent, sv.frametime, stepnormal);
                ent->v->velocity[2] += start_velocity[2];
-       
+
                SV_CheckVelocity(ent);
-       
+
                // check for stuckness, possibly due to the limited precision of floats
                // in the clipping hulls
                if (clip
@@ -1072,7 +1070,7 @@ void SV_WalkMove (edict_t *ent)
                        VectorCopy(originalmove_velocity, ent->v->velocity);
                        //clip = originalmove_clip;
                        ent->v->flags = originalmove_flags;
-                       ent->v->groundentity = originalmove_groundentity; 
+                       ent->v->groundentity = originalmove_groundentity;
                        // now try to unstick if needed
                        //clip = SV_TryUnstick (ent, oldvel);
                        return;
@@ -1114,7 +1112,7 @@ void SV_WalkMove (edict_t *ent)
                VectorCopy(originalmove_velocity, ent->v->velocity);
                //clip = originalmove_clip;
                ent->v->flags = originalmove_flags;
-               ent->v->groundentity = originalmove_groundentity; 
+               ent->v->groundentity = originalmove_groundentity;
        }
 
        SV_SetOnGround (ent);
@@ -1359,7 +1357,7 @@ void SV_Physics_Step (edict_t *ent)
                SV_LinkEdict(ent, true);
 
                // just hit ground
-               if (hitsound && (int)ent->v->flags & FL_ONGROUND)
+               if (hitsound && (int)ent->v->flags & FL_ONGROUND && gamemode != GAME_NEXUIZ)
                        SV_StartSound(ent, 0, "demon/dland2.wav", 255, 1);
        }
 
@@ -1379,7 +1377,7 @@ SV_Physics
 */
 void SV_Physics (void)
 {
-       int i;
+       int i, newnum_edicts;
        edict_t *ent;
        qbyte runmove[MAX_EDICTS];
 
@@ -1389,8 +1387,11 @@ void SV_Physics (void)
        pr_global_struct->time = sv.time;
        PR_ExecuteProgram (pr_global_struct->StartFrame, "QC function StartFrame is missing");
 
+       newnum_edicts = 0;
        for (i = 0, ent = sv.edicts;i < sv.num_edicts;i++, ent = NEXT_EDICT(ent))
-               runmove[i] = !ent->e->free;
+               if ((runmove[i] = !ent->e->free))
+                       newnum_edicts = i + 1;
+       sv.num_edicts = max(svs.maxclients + 1, newnum_edicts);
 
 //
 // treat each object in turn
@@ -1404,8 +1405,11 @@ void SV_Physics (void)
                if (pr_global_struct->force_retouch)
                        SV_LinkEdict (ent, true);       // force retouch even for stationary
 
-               if (i >= 1 && i <= svs.maxclients && svs.clients[i-1].spawned)
+               if (i >= 1 && i <= svs.maxclients)
                {
+                       // don't do physics on disconnected clients, FrikBot relies on this
+                       if (!svs.clients[i-1].spawned)
+                               continue;
                        // connected slot
                        // call standard client pre-think
                        SV_CheckVelocity (ent);
@@ -1483,7 +1487,7 @@ void SV_Physics (void)
                        break;
                }
 
-               if (i >= 1 && i <= svs.maxclients && svs.clients[i-1].spawned)
+               if (i >= 1 && i <= svs.maxclients)
                {
                        SV_CheckVelocity (ent);