mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add P_GetMidtextureTopBottom
This commit is contained in:
parent
308a4ba345
commit
f52afc0491
2 changed files with 82 additions and 37 deletions
115
src/p_maputl.c
115
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 (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
texmid = texbottom+(textop-texbottom)/2;
|
||||
|
||||
delta1 = abs(mobj->z - texmid);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue