]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
- fix tracing against networked players on the client (properly check if a client...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 16 Jan 2009 09:04:59 +0000 (09:04 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 16 Jan 2009 09:04:59 +0000 (09:04 +0000)
- add float trace_networkentity to client VM, which helped debugging this

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8654 d7cf8633-e32d-0410-b094-e92efae38249

cl_collision.c
clvm_cmds.c
progsvm.h
prvm_edict.c

index 1aedfe74bc3a281e4251ef6974963136396c1daf..10e8f4c23b59c4ea092528b3e6a6695cc6288751 100644 (file)
@@ -317,9 +317,12 @@ trace_t CL_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const
        {
                vec3_t origin, entmins, entmaxs;
                matrix4x4_t entmatrix, entinversematrix;
-               for (i = 1;i < cl.maxclients+1;i++)
+               for (i = 1;i <= cl.maxclients;i++)
                {
                        entity_render_t *ent = &cl.entities[i].render;
+                       // don't hit players that don't exist
+                       if (!cl.scores[i-1].name[0])
+                               continue;
                        // don't hit ourselves
                        if (i == cl.playerentity)
                                continue;
index 8f72cc46bc7a393816426ca98471bfe2f68e747c..e9b8c4352414f308e987ae632a6b8118f19c8234 100644 (file)
@@ -230,12 +230,20 @@ static void VM_CL_spawn (void)
        VM_RETURN_EDICT(ed);
 }
 
+void CL_VM_SetTraceGlobals(const trace_t *trace, int svent)
+{
+       prvm_eval_t *val;
+       VM_SetTraceGlobals(trace);
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_networkentity)))
+               val->_float = svent;
+}
+
 // #16 float(vector v1, vector v2, float movetype, entity ignore) traceline
 static void VM_CL_traceline (void)
 {
        float   *v1, *v2;
        trace_t trace;
-       int             move;
+       int             move, svent;
        prvm_edict_t    *ent;
 
        VM_SAFEPARMCOUNTRANGE(4, 4, VM_CL_traceline);
@@ -250,9 +258,9 @@ static void VM_CL_traceline (void)
        if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v1[2]) || IS_NAN(v2[2]))
                PRVM_ERROR("%s: NAN errors detected in traceline('%f %f %f', '%f %f %f', %i, entity %i)\n", PRVM_NAME, v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], move, PRVM_EDICT_TO_PROG(ent));
 
-       trace = CL_Move(v1, vec3_origin, vec3_origin, v2, move, ent, CL_GenericHitSuperContentsMask(ent), true, true, NULL, true);
+       trace = CL_Move(v1, vec3_origin, vec3_origin, v2, move, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
 
-       VM_SetTraceGlobals(&trace);
+       CL_VM_SetTraceGlobals(&trace, svent);
 }
 
 /*
@@ -271,7 +279,7 @@ static void VM_CL_tracebox (void)
 {
        float   *v1, *v2, *m1, *m2;
        trace_t trace;
-       int             move;
+       int             move, svent;
        prvm_edict_t    *ent;
 
        VM_SAFEPARMCOUNTRANGE(6, 8, VM_CL_tracebox); // allow more parameters for future expansion
@@ -288,12 +296,12 @@ static void VM_CL_tracebox (void)
        if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v1[2]) || IS_NAN(v2[2]))
                PRVM_ERROR("%s: NAN errors detected in tracebox('%f %f %f', '%f %f %f', '%f %f %f', '%f %f %f', %i, entity %i)\n", PRVM_NAME, v1[0], v1[1], v1[2], m1[0], m1[1], m1[2], m2[0], m2[1], m2[2], v2[0], v2[1], v2[2], move, PRVM_EDICT_TO_PROG(ent));
 
-       trace = CL_Move(v1, m1, m2, v2, move, ent, CL_GenericHitSuperContentsMask(ent), true, true, NULL, true);
+       trace = CL_Move(v1, m1, m2, v2, move, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
 
-       VM_SetTraceGlobals(&trace);
+       CL_VM_SetTraceGlobals(&trace, svent);
 }
 
-trace_t CL_Trace_Toss (prvm_edict_t *tossent, prvm_edict_t *ignore)
+trace_t CL_Trace_Toss (prvm_edict_t *tossent, prvm_edict_t *ignore, int *svent)
 {
        int i;
        float gravity;
@@ -343,6 +351,7 @@ static void VM_CL_tracetoss (void)
        trace_t trace;
        prvm_edict_t    *ent;
        prvm_edict_t    *ignore;
+       int svent;
 
        prog->xfunction->builtinsprofile += 600;
 
@@ -356,9 +365,9 @@ static void VM_CL_tracetoss (void)
        }
        ignore = PRVM_G_EDICT(OFS_PARM1);
 
-       trace = CL_Trace_Toss (ent, ignore);
+       trace = CL_Trace_Toss (ent, ignore, &svent);
 
-       VM_SetTraceGlobals(&trace);
+       CL_VM_SetTraceGlobals(&trace, svent);
 }
 
 
@@ -2827,7 +2836,7 @@ qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean
        float           dz;
        vec3_t          oldorg, neworg, end, traceendpos;
        trace_t         trace;
-       int                     i;
+       int                     i, svent;
        prvm_edict_t            *enemy;
        prvm_eval_t     *val;
 
@@ -2851,9 +2860,9 @@ qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean
                                if (dz < 30)
                                        neworg[2] += 8;
                        }
-                       trace = CL_Move (ent->fields.client->origin, ent->fields.client->mins, ent->fields.client->maxs, neworg, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, NULL, true);
+                       trace = CL_Move (ent->fields.client->origin, ent->fields.client->mins, ent->fields.client->maxs, neworg, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
                        if (settrace)
-                               VM_SetTraceGlobals(&trace);
+                               CL_VM_SetTraceGlobals(&trace, svent);
 
                        if (trace.fraction == 1)
                        {
@@ -2879,16 +2888,16 @@ qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean
        VectorCopy (neworg, end);
        end[2] -= sv_stepheight.value*2;
 
-       trace = CL_Move (neworg, ent->fields.client->mins, ent->fields.client->maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, NULL, true);
+       trace = CL_Move (neworg, ent->fields.client->mins, ent->fields.client->maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
        if (settrace)
-               VM_SetTraceGlobals(&trace);
+               CL_VM_SetTraceGlobals(&trace, svent);
 
        if (trace.startsolid)
        {
                neworg[2] -= sv_stepheight.value;
-               trace = CL_Move (neworg, ent->fields.client->mins, ent->fields.client->maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, NULL, true);
+               trace = CL_Move (neworg, ent->fields.client->mins, ent->fields.client->maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
                if (settrace)
-                       VM_SetTraceGlobals(&trace);
+                       CL_VM_SetTraceGlobals(&trace, svent);
                if (trace.startsolid)
                        return false;
        }
index cabd7b40b1807b7ec0b4d8028c32c982424570fa..ccf69f857fb6db97ac6cefd7c48b074e6454b638 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -242,6 +242,7 @@ typedef struct prvm_prog_globaloffsets_s
        int trace_plane_normal; // ssqc / csqc
        int trace_plane_dist; // ssqc / csqc
        int trace_ent; // ssqc / csqc
+       int trace_networkentity; // csqc
        int trace_dphitcontents; // ssqc / csqc
        int trace_dphitq3surfaceflags; // ssqc / csqc
        int trace_dphittexturename; // ssqc / csqc
index f1fb2a2841eb1649defd771030e3f0a9572c51dc..2a7c222e0ba2191729bfbe954f3ecd80e73a69a1 100644 (file)
@@ -1520,6 +1520,7 @@ void PRVM_FindOffsets(void)
        prog->globaloffsets.trace_plane_normal            = PRVM_ED_FindGlobalOffset("trace_plane_normal");
        prog->globaloffsets.trace_plane_dist              = PRVM_ED_FindGlobalOffset("trace_plane_dist");
        prog->globaloffsets.trace_ent                     = PRVM_ED_FindGlobalOffset("trace_ent");
+       prog->globaloffsets.trace_networkentity           = PRVM_ED_FindGlobalOffset("trace_networkentity");
        prog->globaloffsets.trace_dphitcontents           = PRVM_ED_FindGlobalOffset("trace_dphitcontents");
        prog->globaloffsets.trace_dphitq3surfaceflags     = PRVM_ED_FindGlobalOffset("trace_dphitq3surfaceflags");
        prog->globaloffsets.trace_dphittexturename        = PRVM_ED_FindGlobalOffset("trace_dphittexturename");