From f52afc0491e15ed93825c77b7fa292086aa1de0f Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 1 Aug 2022 07:16:53 -0700 Subject: [PATCH 1/2] Add P_GetMidtextureTopBottom --- src/p_maputl.c | 117 +++++++++++++++++++++++++++++++++---------------- src/p_maputl.h | 2 + 2 files changed, 82 insertions(+), 37 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index 37a24267c..09e5cdd5d 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -485,6 +485,83 @@ void P_CameraLineOpening(line_t *linedef) } } +boolean +P_GetMidtextureTopBottom +( line_t * linedef, + fixed_t x, + fixed_t y, + fixed_t * return_top, + fixed_t * return_bottom) +{ + side_t *side = &sides[linedef->sidenum[0]]; + fixed_t textop, texbottom, texheight; + INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid + + sector_t *front = linedef->frontsector; + sector_t *back = linedef->backsector; + fixed_t z; + + if (!texnum) + return false; + + textop = P_GetSectorCeilingZAt(front, x, y); + texbottom = P_GetSectorFloorZAt(front, x, y); + + if (back) + { + z = P_GetSectorCeilingZAt(back, x, y); + + if (z < textop) + textop = z; + + z = P_GetSectorFloorZAt(back, x, y); + + if (z > texbottom) + texbottom = z; + } + + // Get the midtexture's height + texheight = textures[texnum]->height << FRACBITS; + + // Set texbottom and textop to the Z coordinates of the texture's boundaries +#if 0 + // don't remove this code unless solid midtextures + // on non-solid polyobjects should NEVER happen in the future + if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { + if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat + texbottom = back->floorheight + side->rowoffset; + textop = back->ceilingheight + side->rowoffset; + } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { + texbottom = back->floorheight + side->rowoffset; + textop = texbottom + texheight*(side->repeatcnt+1); + } else { + textop = back->ceilingheight + side->rowoffset; + texbottom = textop - texheight*(side->repeatcnt+1); + } + } else +#endif + { + if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat + texbottom += side->rowoffset; + textop += side->rowoffset; + } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { + texbottom += side->rowoffset; + textop = texbottom + texheight*(side->repeatcnt+1); + } else { + textop += side->rowoffset; + texbottom = textop - texheight*(side->repeatcnt+1); + } + } + + if (return_top) + *return_top = textop; + + if (return_bottom) + *return_bottom = texbottom; + + return true; +} + void P_LineOpening(line_t *linedef, mobj_t *mobj) { enum { FRONT, BACK }; @@ -596,45 +673,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if ((linedef->flags & ML_EFFECT4 || (mobj->player && P_IsLineTripWire(linedef) && !K_TripwirePass(mobj->player))) && !linedef->polyobj // don't do anything for polyobjects! ...for now ) { - side_t *side = &sides[linedef->sidenum[0]]; - fixed_t textop, texbottom, texheight; + fixed_t textop, texbottom; fixed_t texmid, delta1, delta2; - INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid - - if (texnum) { - // Get the midtexture's height - texheight = textures[texnum]->height << FRACBITS; - - // Set texbottom and textop to the Z coordinates of the texture's boundaries -#if 0 - // don't remove this code unless solid midtextures - // on non-solid polyobjects should NEVER happen in the future - if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = back->floorheight + side->rowoffset; - textop = back->ceilingheight + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = back->floorheight + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = back->ceilingheight + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); - } - } else -#endif - { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = openbottom + side->rowoffset; - textop = opentop + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = openbottom + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = opentop + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); - } - } + if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) + { texmid = texbottom+(textop-texbottom)/2; delta1 = abs(mobj->z - texmid); diff --git a/src/p_maputl.h b/src/p_maputl.h index c17ad5d33..29e7d4de9 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -56,6 +56,8 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing, fixed_t x,fixed_t y); boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y); void P_HitSpecialLines(mobj_t *thing, fixed_t x, fixed_t y, fixed_t momx, fixed_t momy); +boolean P_GetMidtextureTopBottom(line_t *linedef, fixed_t x, fixed_t y, fixed_t *return_top, fixed_t *return_bottom); + extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling; extern pslope_t *opentopslope, *openbottomslope; extern ffloor_t *openfloorrover, *openceilingrover; From d11179d9aa1a609d328f245d333a0a3b343724b7 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 1 Aug 2022 07:17:40 -0700 Subject: [PATCH 2/2] Don't hitlag tripwire when passing above --- src/p_map.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 473ded5fe..138988cfb 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -263,9 +263,6 @@ static boolean P_SpecialIsLinedefCrossType(line_t *ld) { boolean linedefcrossspecial = false; - if (P_IsLineTripWire(ld)) - return true; - switch (ld->special) { case 2001: // Finish line @@ -1675,6 +1672,20 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) { add_spechit(ld); } + else if (P_IsLineTripWire(ld)) + { + fixed_t textop, texbottom; + + P_GetMidtextureTopBottom(ld, tmx, tmy, + &textop, &texbottom); + + /* The effect handling is done later but it won't + know the height values anymore. So don't even add + this line to the list unless this thing clips the + tripwire's midtexture. */ + if (tmthing->z <= textop && thingtop >= texbottom) + add_spechit(ld); + } return BMIT_CONTINUE; }