From 5c7ecb37b25afd86e8af339b4e4b654f5d81881b Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 1 Nov 2011 12:22:59 +0000 Subject: [PATCH] impact handling: instead of detecting teleports by origin or angles changing, detect teleports by calls to the setorigin() builtin git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11511 d7cf8633-e32d-0410-b094-e92efae38249 --- clvm_cmds.c | 2 ++ progsvm.h | 4 +++- sv_phys.c | 20 ++++++++++++++++---- svvm_cmds.c | 2 ++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/clvm_cmds.c b/clvm_cmds.c index 62b84db3..536aad05 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -52,6 +52,8 @@ static void VM_CL_setorigin (prvm_prog_t *prog) } org = PRVM_G_VECTOR(OFS_PARM1); VectorCopy (org, PRVM_clientedictvector(e, origin)); + if(e->priv.required->mark == PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN) + e->priv.required->mark = PRVM_EDICT_MARK_SETORIGIN_CAUGHT; CL_LinkEdict(e); } diff --git a/progsvm.h b/progsvm.h index 02f72287..0082938d 100644 --- a/progsvm.h +++ b/progsvm.h @@ -71,7 +71,9 @@ typedef struct prvm_edict_private_s { qboolean free; float freetime; - int mark; + int mark; // used during leaktest (0 = unref, >0 = referenced); special values during server physics: +#define PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN -1 +#define PRVM_EDICT_MARK_SETORIGIN_CAUGHT -2 const char *allocation_origin; } prvm_edict_private_t; diff --git a/sv_phys.c b/sv_phys.c index 94624f3f..c88ff4c4 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -1600,7 +1600,6 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q int movetype; int type; vec3_t mins, maxs; - vec3_t original, original_velocity; vec3_t start; vec3_t end; @@ -1633,8 +1632,7 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q VectorCopy(trace->endpos, PRVM_serveredictvector(ent, origin)); - VectorCopy(PRVM_serveredictvector(ent, origin), original); - VectorCopy(PRVM_serveredictvector(ent, velocity), original_velocity); + ent->priv.required->mark = PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN; // -2: setorigin running SV_LinkEdict(ent); @@ -1652,7 +1650,21 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q if((PRVM_serveredictfloat(ent, solid) >= SOLID_TRIGGER && trace->ent && (!((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND) || PRVM_serveredictedict(ent, groundentity) != PRVM_EDICT_TO_PROG(trace->ent)))) SV_Impact (ent, trace); - return VectorCompare(PRVM_serveredictvector(ent, origin), original);// && VectorCompare(PRVM_serveredictvector(ent, velocity), original_velocity); + if(ent->priv.required->mark == PRVM_EDICT_MARK_SETORIGIN_CAUGHT) + { + ent->priv.required->mark = 0; + return false; + } + else if(ent->priv.required->mark == PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN) + { + ent->priv.required->mark = 0; + return true; + } + else + { + Con_Printf("The edict mark had been overwritten! Please debug this.\n"); + return true; + } } diff --git a/svvm_cmds.c b/svvm_cmds.c index 39498ecc..f6b0d1b6 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -250,6 +250,8 @@ static void VM_SV_setorigin(prvm_prog_t *prog) } org = PRVM_G_VECTOR(OFS_PARM1); VectorCopy (org, PRVM_serveredictvector(e, origin)); + if(e->priv.required->mark == PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN) + e->priv.required->mark = PRVM_EDICT_MARK_SETORIGIN_CAUGHT; SV_LinkEdict(e); } -- 2.39.2