Revert "prevent immediate re-flipping", streamline P_GetMobjGravity

This commit is contained in:
spherallic 2022-09-26 13:41:37 +02:00
parent 872a2001c8
commit 862fdaaa3d
2 changed files with 14 additions and 30 deletions

View file

@ -578,7 +578,7 @@ linedeftypes
title = "Per-Sector Gravity"; title = "Per-Sector Gravity";
prefix = "(1)"; prefix = "(1)";
flags64text = "[6] Flip in reverse gravity"; flags64text = "[6] Flip in reverse gravity";
flags8192text = "[13] Override MF2_OBJECTFLIP"; flags8192text = "[13] Reverse while inside";
} }
5 5

View file

@ -1431,10 +1431,9 @@ static void P_PlayerFlip(mobj_t *mo)
fixed_t P_GetMobjGravity(mobj_t *mo) fixed_t P_GetMobjGravity(mobj_t *mo)
{ {
fixed_t gravityadd = 0; fixed_t gravityadd = 0;
boolean no3dfloorgrav = true; // Custom gravity sector_t *gravsector = NULL; // Custom gravity
boolean goopgravity = false; boolean goopgravity = false;
boolean wasflip; boolean wasflip;
boolean alreadyflipped = false;
I_Assert(mo != NULL); I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo)); I_Assert(!P_MobjWasRemoved(mo));
@ -1445,7 +1444,6 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
if (mo->subsector->sector->ffloors) // Check for 3D floor gravity too. if (mo->subsector->sector->ffloors) // Check for 3D floor gravity too.
{ {
ffloor_t *rover; ffloor_t *rover;
fixed_t gravfactor;
for (rover = mo->subsector->sector->ffloors; rover; rover = rover->next) for (rover = mo->subsector->sector->ffloors; rover; rover = rover->next)
{ {
@ -1455,37 +1453,24 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
if ((rover->flags & (FF_SWIMMABLE|FF_GOOWATER)) == (FF_SWIMMABLE|FF_GOOWATER)) if ((rover->flags & (FF_SWIMMABLE|FF_GOOWATER)) == (FF_SWIMMABLE|FF_GOOWATER))
goopgravity = true; goopgravity = true;
gravfactor = P_GetSectorGravityFactor(rover->master->frontsector); if (P_GetSectorGravityFactor(rover->master->frontsector) == FRACUNIT)
if (gravfactor == FRACUNIT)
continue; continue;
gravityadd = -FixedMul(gravity, gravfactor); gravsector = rover->master->frontsector;
if ((rover->master->frontsector->flags & MSF_GRAVITYFLIP) && gravityadd > 0)
{
if (rover->master->frontsector->specialflags & SSF_GRAVITYOVERRIDE)
mo->flags2 &= ~MF2_OBJECTFLIP;
mo->eflags |= MFE_VERTICALFLIP;
alreadyflipped = true;
}
no3dfloorgrav = false;
break; break;
} }
} }
if (no3dfloorgrav) if (!gravsector) // If there is no 3D floor gravity, check sector's gravity
{ gravsector = mo->subsector->sector;
gravityadd = -FixedMul(gravity, P_GetSectorGravityFactor(mo->subsector->sector));
if ((mo->subsector->sector->flags & MSF_GRAVITYFLIP) && gravityadd > 0) gravityadd = -FixedMul(gravity, P_GetSectorGravityFactor(gravsector));
{
if (mo->subsector->sector->specialflags & SSF_GRAVITYOVERRIDE) if ((gravsector->flags & MSF_GRAVITYFLIP) && gravityadd > 0)
mo->flags2 &= ~MF2_OBJECTFLIP; {
mo->eflags |= MFE_VERTICALFLIP; if (gravsector->specialflags & SSF_GRAVITYOVERRIDE)
alreadyflipped = true; mo->flags2 &= ~MF2_OBJECTFLIP;
} mo->eflags |= MFE_VERTICALFLIP;
} }
// Less gravity underwater. // Less gravity underwater.
@ -1503,8 +1488,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
if (!(mo->flags2 & MF2_OBJECTFLIP) != !(mo->player->powers[pw_gravityboots])) // negated to turn numeric into bool - would be double negated, but not needed if both would be if (!(mo->flags2 & MF2_OBJECTFLIP) != !(mo->player->powers[pw_gravityboots])) // negated to turn numeric into bool - would be double negated, but not needed if both would be
{ {
gravityadd = -gravityadd; gravityadd = -gravityadd;
if (!alreadyflipped) // prevent re-flipping after a per-sector gravity flip mo->eflags ^= MFE_VERTICALFLIP;
mo->eflags ^= MFE_VERTICALFLIP;
} }
if (wasflip == !(mo->eflags & MFE_VERTICALFLIP)) // note!! == ! is not equivalent to != here - turns numeric into bool this way if (wasflip == !(mo->eflags & MFE_VERTICALFLIP)) // note!! == ! is not equivalent to != here - turns numeric into bool this way
P_PlayerFlip(mo); P_PlayerFlip(mo);