Clip watertop and waterbottom between other sector and FOFs

This commit is contained in:
James R 2021-12-05 22:38:59 -08:00
parent be34cd699b
commit f0c9e49a2b

View file

@ -2956,6 +2956,8 @@ void P_MobjCheckWater(mobj_t *mobj)
player_t *p = mobj->player; // Will just be null if not a player.
fixed_t height = mobj->height;
boolean wasgroundpounding = false;
fixed_t top2 = P_GetSectorCeilingZAt(sector, mobj->x, mobj->y);
fixed_t bot2 = P_GetSectorFloorZAt(sector, mobj->x, mobj->y);
// Default if no water exists.
mobj->watertop = mobj->waterbottom = mobj->z - 1000*FRACUNIT;
@ -2966,14 +2968,21 @@ void P_MobjCheckWater(mobj_t *mobj)
for (rover = sector->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE)
|| (((rover->flags & FF_BLOCKPLAYER) && mobj->player)
|| ((rover->flags & FF_BLOCKOTHERS) && !mobj->player)))
continue;
topheight = P_GetFFloorTopZAt (rover, mobj->x, mobj->y);
bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y);
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE)
|| (((rover->flags & FF_BLOCKPLAYER) && mobj->player)
|| ((rover->flags & FF_BLOCKOTHERS) && !mobj->player)))
{
if (topheight < top2 && topheight > thingtop)
top2 = topheight;
if (bottomheight > bot2 && bottomheight < mobj->z)
bot2 = bottomheight;
continue;
}
if (mobj->eflags & MFE_VERTICALFLIP)
{
if (topheight < (thingtop - (height>>1))
@ -3011,6 +3020,12 @@ void P_MobjCheckWater(mobj_t *mobj)
}
}
if (mobj->watertop > top2)
mobj->watertop = top2;
if (mobj->waterbottom < bot2)
mobj->waterbottom = bot2;
// Spectators and dead players don't get to do any of the things after this.
if (p && (p->spectator || p->playerstate != PST_LIVE))
return;