mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 23:11:38 +00:00
Change SV_ClipToLinks's clip.type to be flags.
More feature swiping from fte: the flags are needed for antilag, but I thought I'd grab the related features (mainly linking) while I was at it.
This commit is contained in:
parent
64bfde7320
commit
40da338674
4 changed files with 80 additions and 15 deletions
|
@ -55,6 +55,12 @@ typedef struct trace_s {
|
|||
#define MOVE_NORMAL 0
|
||||
#define MOVE_NOMONSTERS 1
|
||||
#define MOVE_MISSILE 2
|
||||
#define MOVE_HITMODEL 4
|
||||
#define MOVE_RESERVED 8
|
||||
#define MOVE_TRIGGERS 16 //triggers must be marked with FINDABLE_NONSOLID (an alternative to solid-corpse)
|
||||
#define MOVE_EVERYTHING 32 //can return triggers and non-solid items if they're marked with FINDABLE_NONSOLID (works even if the items are not properly linked)
|
||||
#define MOVE_LAGGED 64 //trace touches current last-known-state, instead of actual ents (just affects players for now)
|
||||
#define MOVE_ENTCHAIN 128 //chain of impacted ents, otherwise result shows only world
|
||||
|
||||
typedef struct areanode_s {
|
||||
int axis; // -1 = leaf node
|
||||
|
|
|
@ -385,12 +385,6 @@ typedef enum {
|
|||
#define FL_FINALIZED 8192
|
||||
#define FL_FINDABLE_NONSOLID 16384
|
||||
|
||||
#define TL_ANY_SOLID 0
|
||||
#define TL_BSP_ONLY 1
|
||||
// 2 used internally (MOVE_MISSILE)
|
||||
#define TL_TRIGGERS 3 // scan for triggers
|
||||
#define TL_EVERYTHING 4 // scan for anything
|
||||
|
||||
// entity effects
|
||||
|
||||
//define EF_BRIGHTFIELD 1
|
||||
|
|
|
@ -711,9 +711,66 @@ PF_touchworld (progs_t *pr)
|
|||
*sv_globals.self = oself;
|
||||
}
|
||||
|
||||
/*
|
||||
CPQW_traceline
|
||||
|
||||
Used for use tracing and shot targeting.
|
||||
Traces are blocked by bbox and exact bsp entityes, and also slide box
|
||||
entities if the tryents flag is set.
|
||||
|
||||
traceline (vector1, vector2, tryents)
|
||||
// float (vector v1, vector v2, float tryents) traceline
|
||||
*/
|
||||
#define TL_ANY_SOLID 0
|
||||
#define TL_BSP_ONLY 1
|
||||
#define TL_TRIGGERS 3 // scan for triggers
|
||||
#define TL_EVERYTHING 4 // scan for anything
|
||||
|
||||
static void
|
||||
CPQW_traceline (progs_t *pr)
|
||||
{
|
||||
float *v1, *v2;
|
||||
edict_t *ent;
|
||||
int nomonsters;
|
||||
trace_t trace;
|
||||
static int tl_to_move[] = {
|
||||
MOVE_NORMAL,
|
||||
MOVE_NORMAL,
|
||||
MOVE_NORMAL,
|
||||
MOVE_TRIGGERS,
|
||||
MOVE_EVERYTHING,
|
||||
};
|
||||
|
||||
v1 = P_VECTOR (pr, 0);
|
||||
v2 = P_VECTOR (pr, 1);
|
||||
nomonsters = P_FLOAT (pr, 2);
|
||||
ent = P_EDICT (pr, 3);
|
||||
|
||||
if (nomonsters < TL_ANY_SOLID || nomonsters > TL_EVERYTHING)
|
||||
nomonsters = TL_ANY_SOLID;
|
||||
nomonsters = tl_to_move[nomonsters];
|
||||
|
||||
trace = SV_Move (v1, vec3_origin, vec3_origin, v2, nomonsters, ent);
|
||||
|
||||
*sv_globals.trace_allsolid = trace.allsolid;
|
||||
*sv_globals.trace_startsolid = trace.startsolid;
|
||||
*sv_globals.trace_fraction = trace.fraction;
|
||||
*sv_globals.trace_inwater = trace.inwater;
|
||||
*sv_globals.trace_inopen = trace.inopen;
|
||||
VectorCopy (trace.endpos, *sv_globals.trace_endpos);
|
||||
VectorCopy (trace.plane.normal, *sv_globals.trace_plane_normal);
|
||||
*sv_globals.trace_plane_dist = trace.plane.dist;
|
||||
|
||||
if (trace.ent)
|
||||
*sv_globals.trace_ent = EDICT_TO_PROG (pr, trace.ent);
|
||||
else
|
||||
*sv_globals.trace_ent = EDICT_TO_PROG (pr, sv.edicts);
|
||||
}
|
||||
|
||||
#define CPQW (PR_RANGE_CPQW << PR_RANGE_SHIFT) |
|
||||
|
||||
static builtin_t builtins[] = {
|
||||
{"CPCW:traceline", CPQW_traceline, CPQW 16},
|
||||
{"CPQW:getuid", PF_getuid, CPQW 83},
|
||||
{"CPQW:strcat", PF_strcat, CPQW 84},
|
||||
{"CPQW:padstr", PF_padstr, CPQW 85},
|
||||
|
|
|
@ -755,13 +755,21 @@ ctl_do_clip (edict_t *touch, moveclip_t *clip, trace_t *trace)
|
|||
if (trace->allsolid || trace->startsolid
|
||||
|| trace->fraction < clip->trace.fraction) {
|
||||
trace->ent = touch;
|
||||
if (clip->trace.startsolid) {
|
||||
clip->trace = *trace;
|
||||
clip->trace.startsolid = true;
|
||||
} else
|
||||
clip->trace = *trace;
|
||||
} else if (trace->startsolid)
|
||||
clip->trace.startsolid = true;
|
||||
if (clip->type & MOVE_ENTCHAIN) {
|
||||
SVentity (touch, chain) = EDICT_TO_PROG (&sv_pr_state,
|
||||
clip->trace.ent
|
||||
? clip->trace.ent
|
||||
: sv.edicts);
|
||||
clip->trace.ent = touch;
|
||||
} else {
|
||||
if (clip->trace.startsolid) {
|
||||
clip->trace = *trace;
|
||||
clip->trace.startsolid = true;
|
||||
} else {
|
||||
clip->trace = *trace;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -777,7 +785,7 @@ SV_ClipToLinks (areanode_t *node, moveclip_t *clip)
|
|||
trace_t trace;
|
||||
int i;
|
||||
|
||||
if (clip->type == TL_EVERYTHING) {
|
||||
if (clip->type & MOVE_EVERYTHING) {
|
||||
touch = NEXT_EDICT (&sv_pr_state, sv.edicts);
|
||||
for (i = 1; i < sv.num_edicts; i++,
|
||||
touch = NEXT_EDICT (&sv_pr_state, touch)) {
|
||||
|
@ -789,7 +797,7 @@ SV_ClipToLinks (areanode_t *node, moveclip_t *clip)
|
|||
continue;
|
||||
ctl_do_clip (touch, clip, &trace);
|
||||
}
|
||||
} else if (clip->type == TL_TRIGGERS) {
|
||||
} else if (clip->type & MOVE_TRIGGERS) {
|
||||
for (l = node->solid_edicts.next; l != &node->solid_edicts; l = next) {
|
||||
next = l->next;
|
||||
touch = EDICT_FROM_AREA (l);
|
||||
|
|
Loading…
Reference in a new issue