From 58261f7580bb32917bf5d6dba88ba99a0b8dad10 Mon Sep 17 00:00:00 2001 From: Shpoike Date: Sat, 6 Mar 2021 04:51:40 +0000 Subject: [PATCH] Stop monsters from being able to step into the lower part of solid pushers (fixing bug from content-overridees feature). --- Quake/sv_phys.c | 2 +- Quake/world.c | 37 ++++++++++++++++++++++++------------- Quake/world.h | 4 +++- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Quake/sv_phys.c b/Quake/sv_phys.c index e585dd8c..4a62e772 100644 --- a/Quake/sv_phys.c +++ b/Quake/sv_phys.c @@ -744,7 +744,7 @@ void SV_PushMove (edict_t *pusher, float movetime) // see if the ent's bbox is inside the pusher's final position if (pusher->v.skin < 0) { //a more precise check... - if (!SV_ClipMoveToEntity (pusher, check->v.origin, check->v.mins, check->v.maxs, check->v.origin).startsolid) + if (!SV_ClipMoveToEntity (pusher, check->v.origin, check->v.mins, check->v.maxs, check->v.origin, CONTENTMASK_ANYSOLID).startsolid) continue; } else diff --git a/Quake/world.c b/Quake/world.c index 530a61f2..06390245 100644 --- a/Quake/world.c +++ b/Quake/world.c @@ -810,7 +810,7 @@ Handles selection or creation of a clipping hull, and offseting (and eventually rotation) of the end points ================== */ -trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end) +trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, unsigned int hitcontents) { trace_t trace; vec3_t offset; @@ -928,14 +928,24 @@ static void SV_ClipToLinks ( areanode_t *node, moveclip_t *clip ) continue; // don't clip against owner } - if ((int)touch->v.flags & FL_MONSTER) - trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end); + if (touch->v.skin < 0) + { + if (!(clip->hitcontents & (1<<-(int)touch->v.skin))) + continue; //not solid, don't bother trying to clip. + if ((int)touch->v.flags & FL_MONSTER) + trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end, ~(1<<-CONTENTS_EMPTY)); + else + trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins, clip->maxs, clip->end, ~(1<<-CONTENTS_EMPTY)); + if (trace.contents != CONTENTS_EMPTY) + trace.contents = touch->v.skin; + } else - trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins, clip->maxs, clip->end); - if (trace.contents == CONTENTS_SOLID && touch->v.skin < 0) - trace.contents = touch->v.skin; - if (!((1<<(-trace.contents)) & clip->hitcontents)) - continue; + { + if ((int)touch->v.flags & FL_MONSTER) + trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end, clip->hitcontents); + else + trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins, clip->maxs, clip->end, clip->hitcontents); + } if (trace.allsolid || trace.startsolid || trace.fraction < clip->trace.fraction) @@ -1154,8 +1164,13 @@ trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, e memset ( &clip, 0, sizeof ( moveclip_t ) ); + if (type & MOVE_HITALLCONTENTS) + clip.hitcontents = ~0u; + else + clip.hitcontents = CONTENTMASK_ANYSOLID; + // clip to world - clip.trace = SV_ClipMoveToEntity ( qcvm->edicts, start, mins, maxs, end ); + clip.trace = SV_ClipMoveToEntity ( qcvm->edicts, start, mins, maxs, end, clip.hitcontents ); clip.start = start; clip.end = end; @@ -1163,10 +1178,6 @@ trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, e clip.maxs = maxs; clip.type = type&3; clip.passedict = passedict; - if (type & MOVE_HITALLCONTENTS) - clip.hitcontents = ~0u; - else - clip.hitcontents = (1<<(-CONTENTS_SOLID)) | (1<<(-CONTENTS_CLIP)); if (type == MOVE_MISSILE) { diff --git a/Quake/world.h b/Quake/world.h index 177a3496..675d880a 100644 --- a/Quake/world.h +++ b/Quake/world.h @@ -73,7 +73,9 @@ int SV_TruePointContents (vec3_t p); edict_t *SV_TestEntityPosition (edict_t *ent); -trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end); +#define CONTENTMASK(c) (1u<<(-CONTENTS_##c)) +#define CONTENTMASK_ANYSOLID (CONTENTMASK(SOLID) | CONTENTMASK(CLIP)) +trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, unsigned int hitcontents); trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, edict_t *passedict); // mins and maxs are reletive