]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_phys.c
changed a lot of Con_DPrint/Con_DPrintf calls to Con_Print/Con_Printf (non-technical...
[xonotic/darkplaces.git] / sv_phys.c
index b25bc527af729dfd6a4fc22e9e4285eb81a032d3..ee0239084cad2839d1bf1ad9229464e51337b3e8 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -155,7 +155,7 @@ qboolean SV_RunThink (edict_t *ent)
        pr_global_struct->time = thinktime;
        pr_global_struct->self = EDICT_TO_PROG(ent);
        pr_global_struct->other = EDICT_TO_PROG(sv.edicts);
-       PR_ExecuteProgram (ent->v->think, "NULL think function");
+       PR_ExecuteProgram (ent->v->think, "QC function self.think is missing");
        return !ent->e->free;
 }
 
@@ -178,14 +178,14 @@ void SV_Impact (edict_t *e1, edict_t *e2)
        {
                pr_global_struct->self = EDICT_TO_PROG(e1);
                pr_global_struct->other = EDICT_TO_PROG(e2);
-               PR_ExecuteProgram (e1->v->touch, "");
+               PR_ExecuteProgram (e1->v->touch, "QC function self.touch is missing");
        }
 
        if (e2->v->touch && e2->v->solid != SOLID_NOT)
        {
                pr_global_struct->self = EDICT_TO_PROG(e2);
                pr_global_struct->other = EDICT_TO_PROG(e1);
-               PR_ExecuteProgram (e2->v->touch, "");
+               PR_ExecuteProgram (e2->v->touch, "QC function self.touch is missing");
        }
 
        pr_global_struct->self = old_self;
@@ -592,13 +592,13 @@ void SV_PushMove (edict_t *pusher, float movetime)
                SV_LinkEdict (pusher, false);
                return;
        default:
-               Con_DPrintf("SV_PushMove: unrecognized solid type %f\n", pusher->v->solid);
+               Con_Printf("SV_PushMove: unrecognized solid type %f\n", pusher->v->solid);
                return;
        }
        index = (int) pusher->v->modelindex;
        if (index < 1 || index >= MAX_MODELS)
        {
-               Con_DPrintf("SV_PushMove: invalid modelindex %f\n", pusher->v->modelindex);
+               Con_Printf("SV_PushMove: invalid modelindex %f\n", pusher->v->modelindex);
                return;
        }
        pushermodel = sv.models[index];
@@ -769,7 +769,7 @@ void SV_PushMove (edict_t *pusher, float movetime)
                                {
                                        pr_global_struct->self = EDICT_TO_PROG(pusher);
                                        pr_global_struct->other = EDICT_TO_PROG(check);
-                                       PR_ExecuteProgram (pusher->v->blocked, "");
+                                       PR_ExecuteProgram (pusher->v->blocked, "QC function self.blocked is missing");
                                }
                                break;
                        }
@@ -812,7 +812,7 @@ void SV_Physics_Pusher (edict_t *ent)
                pr_global_struct->time = sv.time;
                pr_global_struct->self = EDICT_TO_PROG(ent);
                pr_global_struct->other = EDICT_TO_PROG(sv.edicts);
-               PR_ExecuteProgram (ent->v->think, "NULL think function");
+               PR_ExecuteProgram (ent->v->think, "QC function self.think is missing");
        }
 }
 
@@ -1025,6 +1025,12 @@ void SV_WalkMove (edict_t *ent)
        originalmove_flags = (int)ent->v->flags;
        originalmove_groundentity = ent->v->groundentity;
 
+       if ((int)ent->v->flags & FL_WATERJUMP)
+               return;
+
+       if (sv_nostep.integer)
+               return;
+       
        // if move didn't block on a step, return
        if (clip & 2)
        {
@@ -1032,12 +1038,6 @@ void SV_WalkMove (edict_t *ent)
                if (fabs(start_velocity[0]) < 0.03125 && fabs(start_velocity[1]) < 0.03125)
                        return;
        
-               if (sv_nostep.integer)
-                       return;
-               
-               if ((int)ent->v->flags & FL_WATERJUMP)
-                       return;
-       
                if (ent->v->movetype != MOVETYPE_FLY)
                {
                        // return if gibbed by a trigger
@@ -1092,7 +1092,8 @@ void SV_WalkMove (edict_t *ent)
                if (clip & 2 && sv_wallfriction.integer)
                        SV_WallFriction (ent, stepnormal);
        }
-       else if (!sv_gameplayfix_stepdown.integer || !oldonground || ((int)ent->v->flags & FL_ONGROUND))
+       // skip out if stepdown is enabled, moving downward, not in water, and the move started onground and ended offground
+       else if (!(sv_gameplayfix_stepdown.integer && ent->v->waterlevel < 2 && start_velocity[2] < (1.0 / 32.0) && oldonground && !((int)ent->v->flags & FL_ONGROUND)))
                return;
 
        // move down
@@ -1233,6 +1234,10 @@ void SV_Physics_Toss (edict_t *ent)
        if (!SV_RunThink (ent))
                return;
 
+       // don't stick to ground if onground and moving upward
+       if (ent->v->velocity[2] >= (1.0 / 32.0) && ((int)ent->v->flags & FL_ONGROUND))
+               ent->v->flags = (int)ent->v->flags & ~FL_ONGROUND;
+
 // if onground, return without moving
        if ((int)ent->v->flags & FL_ONGROUND)
        {
@@ -1351,6 +1356,10 @@ will fall if the floor is pulled out from under them.
 */
 void SV_Physics_Step (edict_t *ent)
 {
+       // don't stick to ground if onground and moving upward
+       if (ent->v->velocity[2] >= (1.0 / 32.0) && ((int)ent->v->flags & FL_ONGROUND))
+               ent->v->flags = (int)ent->v->flags & ~FL_ONGROUND;
+
        // freefall if not onground/fly/swim
        if (!((int)ent->v->flags & (FL_ONGROUND | FL_FLY | FL_SWIM)))
        {
@@ -1403,20 +1412,15 @@ void SV_Physics (void)
                if (pr_global_struct->force_retouch)
                        SV_LinkEdict (ent, true);       // force retouch even for stationary
 
-               if (i <= svs.maxclients)
+               if (i >= 1 && i <= svs.maxclients && svs.clients[i-1].spawned)
                {
-                       if (i > 0)
-                       {
-                               if (!svs.clients[i-1].spawned)
-                                       continue;
-                               // connected slot
-                               // call standard client pre-think
-                               SV_CheckVelocity (ent);
-                               pr_global_struct->time = sv.time;
-                               pr_global_struct->self = EDICT_TO_PROG(ent);
-                               PR_ExecuteProgram (pr_global_struct->PlayerPreThink, "QC function PlayerPreThink is missing");
-                               SV_CheckVelocity (ent);
-                       }
+                       // connected slot
+                       // call standard client pre-think
+                       SV_CheckVelocity (ent);
+                       pr_global_struct->time = sv.time;
+                       pr_global_struct->self = EDICT_TO_PROG(ent);
+                       PR_ExecuteProgram (pr_global_struct->PlayerPreThink, "QC function PlayerPreThink is missing");
+                       SV_CheckVelocity (ent);
                }
                else if (sv_freezenonclients.integer)
                        continue;
@@ -1485,7 +1489,7 @@ void SV_Physics (void)
                        break;
                }
 
-               if (i <= svs.maxclients && i > 0 && !ent->e->free)
+               if (i >= 1 && i <= svs.maxclients && svs.clients[i-1].spawned)
                {
                        SV_CheckVelocity (ent);
 
@@ -1509,7 +1513,7 @@ void SV_Physics (void)
                pr_global_struct->self = EDICT_TO_PROG(sv.edicts);
                pr_global_struct->other = EDICT_TO_PROG(sv.edicts);
                pr_global_struct->time = sv.time;
-               PR_ExecuteProgram ((func_t)(EndFrameQC - pr_functions), "");
+               PR_ExecuteProgram ((func_t)(EndFrameQC - pr_functions), "QC function EndFrame is missing");
        }
 
        if (!sv_freezenonclients.integer)