]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_phys.c
changed "new engine string" prints to also include the current text stored in the...
[xonotic/darkplaces.git] / sv_phys.c
index 3635117cbeb2dea831793395c6b025ab8dcf0ac0..08e8aea87c51fee46e55efb034e4b8fb78276669 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -2003,11 +2003,56 @@ void SV_Physics_ClientMove(void)
 {
        prvm_edict_t *ent;
        ent = host_client->edict;
+
+       // call player physics, this needs the proper frametime
+       prog->globals.server->frametime = sv.frametime;
        SV_ClientThink();
+
+       // call standard client pre-think, with frametime = 0
+       prog->globals.server->time = sv.time;
+       prog->globals.server->frametime = 0;
+       prog->globals.server->self = PRVM_EDICT_TO_PROG(ent);
+       PRVM_ExecuteProgram (prog->globals.server->PlayerPreThink, "QC function PlayerPreThink is missing");
+       prog->globals.server->frametime = sv.frametime;
+
+       // make sure the velocity is sane (not a NaN)
+       SV_CheckVelocity(ent);
+       // LordHavoc: a hack to ensure that the (rather silly) id1 quakec
+       // player_run/player_stand1 does not horribly malfunction if the
+       // velocity becomes a number that is both == 0 and != 0
+       // (sounds to me like NaN but to be absolutely safe...)
+       if (DotProduct(ent->fields.server->velocity, ent->fields.server->velocity) < 0.0001)
+               VectorClear(ent->fields.server->velocity);
+
+       // perform MOVETYPE_WALK behavior
        if (!SV_CheckWater (ent) && ! ((int)ent->fields.server->flags & FL_WATERJUMP) )
                SV_AddGravity (ent);
        SV_CheckStuck (ent);
        SV_WalkMove (ent);
+
+       SV_CheckVelocity (ent);
+
+       SV_LinkEdict (ent, true);
+
+       SV_CheckVelocity (ent);
+
+       // call standard player post-think, with frametime = 0
+       prog->globals.server->time = sv.time;
+       prog->globals.server->frametime = 0;
+       prog->globals.server->self = PRVM_EDICT_TO_PROG(ent);
+       PRVM_ExecuteProgram (prog->globals.server->PlayerPostThink, "QC function PlayerPostThink is missing");
+       prog->globals.server->frametime = sv.frametime;
+
+       if(ent->fields.server->fixangle)
+       {
+               // angle fixing was requested by physics code...
+               // so store the current angles for later use
+               memcpy(host_client->fixangle_angles, ent->fields.server->angles, sizeof(host_client->fixangle_angles));
+               host_client->fixangle_angles_set = TRUE;
+
+               // and clear fixangle for the next frame
+               ent->fields.server->fixangle = 0;
+       }
 }
 
 void SV_Physics_ClientEntity(prvm_edict_t *ent)
@@ -2019,6 +2064,10 @@ void SV_Physics_ClientEntity(prvm_edict_t *ent)
                return;
        }
 
+       // don't run physics here if running asynchronously
+       if (host_client->clmovement_skipphysicsframes <= 0)
+               SV_ClientThink();
+
        // make sure the velocity is sane (not a NaN)
        SV_CheckVelocity(ent);
        // LordHavoc: a hack to ensure that the (rather silly) id1 quakec
@@ -2027,6 +2076,7 @@ void SV_Physics_ClientEntity(prvm_edict_t *ent)
        // (sounds to me like NaN but to be absolutely safe...)
        if (DotProduct(ent->fields.server->velocity, ent->fields.server->velocity) < 0.0001)
                VectorClear(ent->fields.server->velocity);
+
        // call standard client pre-think
        prog->globals.server->time = sv.time;
        prog->globals.server->self = PRVM_EDICT_TO_PROG(ent);
@@ -2060,7 +2110,12 @@ void SV_Physics_ClientEntity(prvm_edict_t *ent)
                SV_RunThink (ent);
                // don't run physics here if running asynchronously
                if (host_client->clmovement_skipphysicsframes <= 0)
-                       SV_Physics_ClientMove();
+               {
+                       if (!SV_CheckWater (ent) && ! ((int)ent->fields.server->flags & FL_WATERJUMP) )
+                               SV_AddGravity (ent);
+                       SV_CheckStuck (ent);
+                       SV_WalkMove (ent);
+               }
                break;
        case MOVETYPE_TOSS:
        case MOVETYPE_BOUNCE:
@@ -2087,11 +2142,11 @@ void SV_Physics_ClientEntity(prvm_edict_t *ent)
 
        SV_CheckVelocity (ent);
 
-       // call standard player post-think
        SV_LinkEdict (ent, true);
 
        SV_CheckVelocity (ent);
 
+       // call standard player post-think
        prog->globals.server->time = sv.time;
        prog->globals.server->self = PRVM_EDICT_TO_PROG(ent);
        PRVM_ExecuteProgram (prog->globals.server->PlayerPostThink, "QC function PlayerPostThink is missing");