From 43484d755f33629395d8dba63cf9b3515222d21c Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 23 Feb 2006 05:29:16 +0000 Subject: [PATCH] removed runmove array in favor of using a private entity flag to prevent movement on the first physics frame an entity exists in, this makes projectiles fired by cl_movement 1 clients behave properly git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6010 d7cf8633-e32d-0410-b094-e92efae38249 --- sv_main.c | 2 ++ sv_phys.c | 22 ++++++++++------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sv_main.c b/sv_main.c index 923617c6..57530854 100644 --- a/sv_main.c +++ b/sv_main.c @@ -1977,6 +1977,8 @@ void SV_VM_CB_InitEdict(prvm_edict_t *e) // LordHavoc: for consistency set these here int num = PRVM_NUM_FOR_EDICT(e) - 1; + e->priv.server->move = false; // don't move on first frame + if (num >= 0 && num < svs.maxclients) { prvm_eval_t *val; diff --git a/sv_phys.c b/sv_phys.c index d760ea3e..e505b289 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -1394,8 +1394,12 @@ void SV_Physics_Step (prvm_edict_t *ent) //============================================================================ -static void SV_Physics_Entity (prvm_edict_t *ent, qboolean runmove) +static void SV_Physics_Entity (prvm_edict_t *ent) { + // don't run a move on newly spawned projectiles as it messes up movement + // interpolation and rocket trails + qboolean runmove = ent->priv.server->move; + ent->priv.server->move = true; switch ((int) ent->fields.server->movetype) { case MOVETYPE_PUSH: @@ -1550,9 +1554,8 @@ SV_Physics */ void SV_Physics (void) { - int i, newnum_edicts; + int i; prvm_edict_t *ent; - unsigned char runmove[MAX_EDICTS]; // let the progs know that a new frame has started prog->globals.server->self = PRVM_EDICT_TO_PROG(prog->edicts); @@ -1561,14 +1564,6 @@ void SV_Physics (void) prog->globals.server->frametime = sv.frametime; PRVM_ExecuteProgram (prog->globals.server->StartFrame, "QC function StartFrame is missing"); - // don't run a move on newly spawned projectiles as it messes up movement - // interpolation and rocket trails - newnum_edicts = 0; - for (i = 0, ent = prog->edicts;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent)) - if ((runmove[i] = !ent->priv.server->free)) - newnum_edicts = i + 1; - prog->num_edicts = max(svs.maxclients + 1, newnum_edicts); - // // treat each object in turn // @@ -1597,7 +1592,7 @@ void SV_Physics (void) if (!sv_freezenonclients.integer) for (;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent)) if (!ent->priv.server->free) - SV_Physics_Entity(ent, runmove[i]); + SV_Physics_Entity(ent); if (prog->globals.server->force_retouch > 0) prog->globals.server->force_retouch = max(0, prog->globals.server->force_retouch - 1); @@ -1611,6 +1606,9 @@ void SV_Physics (void) PRVM_ExecuteProgram ((func_t)(EndFrameQC - prog->functions), "QC function EndFrame is missing"); } + // decrement prog->num_edicts if the highest number entities died + for (;PRVM_EDICT_NUM(prog->num_edicts - 1)->priv.server->free;prog->num_edicts--); + if (!sv_freezenonclients.integer) sv.time += sv.frametime; } -- 2.39.2