From: divverent Date: Tue, 1 Nov 2011 12:22:59 +0000 (+0000) Subject: impact handling: instead of detecting teleports by origin or angles changing, detect... X-Git-Tag: xonotic-v0.6.0~192 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b63b47c399b5e130ca395fafb18a138cf6cf4156;p=xonotic%2Fdarkplaces.git 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 ::stable-branch::merge=5c7ecb37b25afd86e8af339b4e4b654f5d81881b --- diff --git a/clvm_cmds.c b/clvm_cmds.c index a9c30b42..227e9f2b 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -59,6 +59,8 @@ void VM_CL_setorigin (void) } 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 ffcf3a16..247fea0f 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 db9b4fa0..f7bfff56 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -1607,7 +1607,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; @@ -1640,8 +1639,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); @@ -1659,7 +1657,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 7440b805..ad027b44 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -250,6 +250,8 @@ static void VM_SV_setorigin (void) } 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); }