]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
impact handling: instead of detecting teleports by origin or angles changing, detect...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 1 Nov 2011 12:22:59 +0000 (12:22 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 1 Nov 2011 12:22:59 +0000 (12:22 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11511 d7cf8633-e32d-0410-b094-e92efae38249

clvm_cmds.c
progsvm.h
sv_phys.c
svvm_cmds.c

index 62b84db36843aee60a0fcab2e8c69059bb8caa75..536aad05e51791c6ef7d601a8fd2e2ff649308e5 100644 (file)
@@ -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);
 }
 
index 02f7228741a583b9a7987462230a80d613b5c83f..0082938d6a6a422ecb7f40a2883fc2624fbd0f34 100644 (file)
--- 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;
 
index 94624f3f3017f4cb58ee0409691df733c7be55c3..c88ff4c452193c721fa782bb2844169c824ff836 100644 (file)
--- 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;
+       }
 }
 
 
index 39498eccf4940fda068e64aadd2f3c75fdc5135d..f6b0d1b697e89f4c637c5f73e7deb9e15d8b7742 100644 (file)
@@ -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);
 }