From: havoc Date: Tue, 3 Apr 2007 02:44:30 +0000 (+0000) Subject: changed PlayerPrethink/think/PlayerPostThink to occur regardless of movement predicti... X-Git-Tag: xonotic-v0.1.0preview~3382 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e325f9fd11a67ffd1c0f686c24df1679556d960a;p=xonotic%2Fdarkplaces.git changed PlayerPrethink/think/PlayerPostThink to occur regardless of movement prediction, so they are guarenteed to run every server frame like in quake/quakeworld, only the movement itself is done elsewhere and only for MOVETYPE_WALK cases, this means that animations keep proper sync regardless of prediction timing git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7037 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/server.h b/server.h index 02d76f87..b977a63a 100644 --- a/server.h +++ b/server.h @@ -362,6 +362,7 @@ void SV_BroadcastPrint(const char *msg); void SV_BroadcastPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1); void SV_Physics (void); +void SV_Physics_ClientMove (void); void SV_Physics_ClientEntity (prvm_edict_t *ent); qboolean SV_PlayerCheckGround (prvm_edict_t *ent); diff --git a/sv_phys.c b/sv_phys.c index 6ce4f9e1..3635117c 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -1999,20 +1999,26 @@ static void SV_Physics_Entity (prvm_edict_t *ent) } } -void SV_Physics_ClientEntity (prvm_edict_t *ent) +void SV_Physics_ClientMove(void) { - SV_ApplyClientMove(); - // make sure the velocity is sane (not a NaN) - SV_CheckVelocity(ent); - // LordHavoc: QuakeC replacement for SV_ClientThink (player movement) - if (prog->funcoffsets.SV_PlayerPhysics && sv_playerphysicsqc.integer) + prvm_edict_t *ent; + ent = host_client->edict; + SV_ClientThink(); + if (!SV_CheckWater (ent) && ! ((int)ent->fields.server->flags & FL_WATERJUMP) ) + SV_AddGravity (ent); + SV_CheckStuck (ent); + SV_WalkMove (ent); +} + +void SV_Physics_ClientEntity(prvm_edict_t *ent) +{ + // don't do physics on disconnected clients, FrikBot relies on this + if (!host_client->spawned) { - prog->globals.server->time = sv.time; - prog->globals.server->self = PRVM_EDICT_TO_PROG(ent); - PRVM_ExecuteProgram (prog->funcoffsets.SV_PlayerPhysics, "QC function SV_PlayerPhysics is missing"); + memset(&host_client->cmd, 0, sizeof(host_client->cmd)); + return; } - else - 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 @@ -2042,45 +2048,43 @@ void SV_Physics_ClientEntity (prvm_edict_t *ent) SV_Physics_Follow (ent); break; case MOVETYPE_NOCLIP: - if (SV_RunThink(ent)) - { - SV_CheckWater(ent); - VectorMA(ent->fields.server->origin, sv.frametime, ent->fields.server->velocity, ent->fields.server->origin); - VectorMA(ent->fields.server->angles, sv.frametime, ent->fields.server->avelocity, ent->fields.server->angles); - } + SV_RunThink(ent); + SV_CheckWater(ent); + VectorMA(ent->fields.server->origin, sv.frametime, ent->fields.server->velocity, ent->fields.server->origin); + VectorMA(ent->fields.server->angles, sv.frametime, ent->fields.server->avelocity, ent->fields.server->angles); break; case MOVETYPE_STEP: SV_Physics_Step (ent); break; case MOVETYPE_WALK: - if (SV_RunThink (ent)) - { - if (!SV_CheckWater (ent) && ! ((int)ent->fields.server->flags & FL_WATERJUMP) ) - SV_AddGravity (ent); - SV_CheckStuck (ent); - SV_WalkMove (ent); - } + SV_RunThink (ent); + // don't run physics here if running asynchronously + if (host_client->clmovement_skipphysicsframes <= 0) + SV_Physics_ClientMove(); break; case MOVETYPE_TOSS: case MOVETYPE_BOUNCE: case MOVETYPE_BOUNCEMISSILE: case MOVETYPE_FLYMISSILE: // regular thinking - if (SV_RunThink (ent)) - SV_Physics_Toss (ent); + SV_RunThink (ent); + SV_Physics_Toss (ent); break; case MOVETYPE_FLY: - if (SV_RunThink (ent)) - { - SV_CheckWater (ent); - SV_WalkMove (ent); - } + SV_RunThink (ent); + SV_CheckWater (ent); + SV_WalkMove (ent); break; default: Con_Printf ("SV_Physics_ClientEntity: bad movetype %i\n", (int)ent->fields.server->movetype); break; } + // decrement the countdown variable used to decide when to go back to + // synchronous physics + if (host_client->clmovement_skipphysicsframes > 0) + host_client->clmovement_skipphysicsframes--; + SV_CheckVelocity (ent); // call standard player post-think @@ -2134,19 +2138,8 @@ void SV_Physics (void) // run physics on the client entities for (i = 1, ent = PRVM_EDICT_NUM(i), host_client = svs.clients;i <= svs.maxclients;i++, ent = PRVM_NEXT_EDICT(ent), host_client++) - { if (!ent->priv.server->free) - { - // don't do physics on disconnected clients, FrikBot relies on this - if (!host_client->spawned) - memset(&host_client->cmd, 0, sizeof(host_client->cmd)); - // don't run physics here if running asynchronously - else if (host_client->clmovement_skipphysicsframes > 0) - host_client->clmovement_skipphysicsframes--; - else SV_Physics_ClientEntity(ent); - } - } // run physics on all the non-client entities if (!sv_freezenonclients.integer) diff --git a/sv_user.c b/sv_user.c index f6bc1f18..dd265371 100644 --- a/sv_user.c +++ b/sv_user.c @@ -379,10 +379,25 @@ the move fields specify an intended velocity in pix/sec the angle fields specify an exact angular motion in degrees =================== */ +extern cvar_t sv_playerphysicsqc; void SV_ClientThink (void) { vec3_t v_angle; + SV_ApplyClientMove(); + // make sure the velocity is sane (not a NaN) + SV_CheckVelocity(host_client->edict); + + // LordHavoc: QuakeC replacement for SV_ClientThink (player movement) + if (prog->funcoffsets.SV_PlayerPhysics && sv_playerphysicsqc.integer) + { + prog->globals.server->time = sv.time; + prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict); + PRVM_ExecuteProgram (prog->funcoffsets.SV_PlayerPhysics, "QC function SV_PlayerPhysics is missing"); + SV_CheckVelocity(host_client->edict); + return; + } + if (host_client->edict->fields.server->movetype == MOVETYPE_NONE) return; @@ -409,6 +424,7 @@ void SV_ClientThink (void) if ( (int)host_client->edict->fields.server->flags & FL_WATERJUMP ) { SV_WaterJump (); + SV_CheckVelocity(host_client->edict); return; } @@ -426,10 +442,12 @@ void SV_ClientThink (void) if ((host_client->edict->fields.server->waterlevel >= 2) && (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP)) { SV_WaterMove (); + SV_CheckVelocity(host_client->edict); return; } SV_AirMove (); + SV_CheckVelocity(host_client->edict); } /* @@ -597,9 +615,9 @@ void SV_ExecuteClientMoves(void) if (sv.frametime > 0.05) { prog->globals.server->frametime = sv.frametime = moveframetime * 0.5f; - SV_Physics_ClientEntity(host_client->edict); + SV_Physics_ClientMove(); } - SV_Physics_ClientEntity(host_client->edict); + SV_Physics_ClientMove(); sv.frametime = oldframetime2; prog->globals.server->frametime = oldframetime; host_client->clmovement_skipphysicsframes = sv_clmovement_waitforinput.integer;