more code cleanups

+ remove duped slopelanding stuff
mostly just unnesting stuffs, some mobj checks, etc
This commit is contained in:
alufolie91 committed 2026-07-21 14:44:56 +02:00
1 parent d5f68bf2aa
commit 3668c2c4f3
7 files changed
+292 -225

No files matched your search

+6 -6
View File
@@ -9048,15 +9048,15 @@ static boolean M_QuitMultiPlayerMenu(void)
if (!fastcmp(setupm_name, setupm_cvname->string))
{
// remove trailing whitespaces
for (l = strlen(setupm_name)-1;
(signed)l >= 0 && setupm_name[l] ==' '; l--)
setupm_name[l] =0;
COM_BufAddText(va("%s \"%s\"\n",setupm_cvname->name,setupm_name));
l = strlen(setupm_name)-1;
for (;(signed)l >= 0 && setupm_name[l] ==' '; l--)
setupm_name[l] = 0;
COM_BufAddText(va("%s \"%s\"\n", setupm_cvname->name, setupm_name));
}
// you know what? always putting these in the buffer won't hurt anything.
COM_BufAddText(va("%s \"%s\"\n",setupm_cvskin->name,skins[setupm_fakeskin].name));
COM_BufAddText(va("%s %d\n",setupm_cvcolor->name,setupm_fakecolor));
COM_BufAddText(va("%s \"%s\"\n", setupm_cvskin->name, skins[setupm_fakeskin].name));
COM_BufAddText(va("%s %d\n", setupm_cvcolor->name, setupm_fakecolor));
return true;
}
+2 -8
View File
@@ -10879,10 +10879,7 @@ void A_BrakLobShot(void *thing)
return; // Don't even bother if we've got nothing to aim at.
// Look up actor's current gravity situation
if (actor->subsector->sector->gravity)
g = FixedMul(gravity,(FixedDiv(*actor->subsector->sector->gravity>>FRACBITS, 1000)));
else
g = gravity;
g = P_GetSectorGravity(actor->subsector->sector);
// Look up distance between actor and its target
x = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y);
@@ -10997,10 +10994,7 @@ void A_NapalmScatter(void *thing)
airtime = 16<<FRACBITS;
// Look up actor's current gravity situation
if (actor->subsector->sector->gravity)
g = FixedMul(gravity,(FixedDiv(*actor->subsector->sector->gravity>>FRACBITS, 1000)));
else
g = gravity;
g = P_GetSectorGravity(actor->subsector->sector);
// vy = (g*(airtime-1))/2
vy = FixedMul(g,(airtime-(1<<FRACBITS)))>>1;
+6 -7
View File
@@ -1828,14 +1828,14 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
delta1 = abs(thing->z - midheight);
delta2 = abs(thingtop - midheight);
if (topheight > tmfloorz && delta1 < delta2
if ((topheight > tmfloorz) && (delta1 < delta2)
&& !(rover->flags & FF_REVERSEPLATFORM))
{
tmfloorz = tmdropoffz = topheight;
tmfloorslope = *rover->t_slope;
}
if (bottomheight < tmceilingz && delta1 >= delta2
if ((bottomheight < tmceilingz) && (delta1 >= delta2)
&& !(rover->flags & FF_PLATFORM)
&& !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE)))
{
@@ -1890,8 +1890,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
po->validcount = validcount;
if (!P_BBoxInsidePolyobj(po, tmbbox)
|| !(po->flags & POF_SOLID))
if (!(po->flags & POF_SOLID) || !P_BBoxInsidePolyobj(po, tmbbox))
{
plink = (polymaplink_t *)(plink->link.next);
continue;
@@ -2136,7 +2135,7 @@ static boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
po->validcount = validcount;
if (!P_PointInsidePolyobj(po, x, y) || !(po->flags & POF_SOLID))
if (!(po->flags & POF_SOLID) || !P_PointInsidePolyobj(po, x, y))
{
plink = (polymaplink_t *)(plink->link.next);
continue;
@@ -3767,7 +3766,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush)
delta1 = abs(thing->z - midheight);
delta2 = abs(thingtop - midheight);
if (bottomheight <= thing->ceilingz && delta1 >= delta2)
if ((bottomheight <= thing->ceilingz) && (delta1 >= delta2))
{
if (thing->flags & MF_PUSHABLE)
{
@@ -4277,7 +4276,7 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
delta1 = abs(z - midheight);
delta2 = abs(thingtop - midheight);
if (topheight > floorz && delta1 < delta2)
if ((topheight > floorz) && (delta1 < delta2))
floorz = topheight;
}
}
+28 -14
View File
@@ -326,7 +326,7 @@ void P_CameraLineOpening(line_t *linedef)
{
for (rover = front->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
fixed_t topheight, bottomheight, midheight;
if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || UNLIKELY(GETSECSPECIAL(rover->master->frontsector->special, 4) == 12))
continue;
@@ -334,8 +334,10 @@ void P_CameraLineOpening(line_t *linedef)
topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef);
bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef);
delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
midheight = (bottomheight + ((topheight - bottomheight) / 2));
delta1 = abs(mapcampointer->z - midheight);
delta2 = abs(thingtop - midheight);
if (bottomheight < lowestceiling && delta1 >= delta2)
lowestceiling = bottomheight;
@@ -354,7 +356,7 @@ void P_CameraLineOpening(line_t *linedef)
{
for (rover = back->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
fixed_t topheight, bottomheight, midheight;
if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || UNLIKELY(GETSECSPECIAL(rover->master->frontsector->special, 4) == 12))
continue;
@@ -362,8 +364,10 @@ void P_CameraLineOpening(line_t *linedef)
topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef);
bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef);
delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
midheight = (bottomheight + ((topheight - bottomheight) / 2));
delta1 = abs(mapcampointer->z - midheight);
delta2 = abs(thingtop - midheight);
if (bottomheight < lowestceiling && delta1 >= delta2)
lowestceiling = bottomheight;
@@ -524,7 +528,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
// Check for frontsector's fake floors
for (rover = front->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
fixed_t topheight, bottomheight, midheight;
if (!(rover->flags & FF_EXISTS))
continue;
@@ -538,8 +542,10 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
topheight = P_GetFOFTopZ(mobj, front, rover, tmx, tmy, linedef);
bottomheight = P_GetFOFBottomZ(mobj, front, rover, tmx, tmy, linedef);
delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
midheight = (bottomheight + ((topheight - bottomheight) / 2));
delta1 = abs(mobj->z - midheight);
delta2 = abs(thingtop - midheight);
if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF
{
@@ -567,7 +573,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
// Check for backsectors fake floors
for (rover = back->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
fixed_t topheight, bottomheight, midheight;
if (!(rover->flags & FF_EXISTS))
continue;
@@ -580,8 +586,10 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
topheight = P_GetFOFTopZ(mobj, back, rover, tmx, tmy, linedef);
bottomheight = P_GetFOFBottomZ(mobj, back, rover, tmx, tmy, linedef);
delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
midheight = (bottomheight + ((topheight - bottomheight) / 2));
delta1 = abs(mobj->z - midheight);
delta2 = abs(thingtop - midheight);
if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF
{
@@ -611,8 +619,10 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
{
const sector_t *polysec = linedef->backsector;
delta1 = abs(mobj->z - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2)));
delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2)));
const fixed_t polymid = (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight) / 2));
delta1 = abs(mobj->z - polymid);
delta2 = abs(thingtop - polymid);
if (polysec->floorheight < lowestceiling && delta1 >= delta2)
{
@@ -620,7 +630,9 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
ceilingslope = NULL;
}
else if (polysec->floorheight < highestceiling && delta1 >= delta2)
{
highestceiling = polysec->floorheight;
}
if (polysec->ceilingheight > highestfloor && delta1 < delta2)
{
@@ -628,7 +640,9 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
floorslope = NULL;
}
else if (polysec->ceilingheight > lowestfloor && delta1 < delta2)
{
lowestfloor = polysec->ceilingheight;
}
}
if (highestceiling < highceiling)
+236 -190
View File
@@ -969,8 +969,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
if (!(rover->master->frontsector->gravity))
continue;
gravityadd = -FixedMul(gravity,
(FixedDiv(*rover->master->frontsector->gravity>>FRACBITS, 1000)));
gravityadd = -P_GetSectorGravity(rover->master->frontsector);
if (rover->master->frontsector->verticalflip && gravityadd > 0)
mo->eflags |= MFE_VERTICALFLIP;
@@ -982,11 +981,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
if (no3dfloorgrav)
{
if (mo->subsector->sector->gravity)
gravityadd = -FixedMul(gravity,
(FixedDiv(*mo->subsector->sector->gravity>>FRACBITS, 1000)));
else
gravityadd = -gravity;
gravityadd = -P_GetSectorGravity(mo->subsector->sector);
if (mo->subsector->sector->verticalflip && gravityadd > 0)
mo->eflags |= MFE_VERTICALFLIP;
@@ -1006,8 +1001,10 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
gravityadd = -gravityadd;
mo->eflags ^= MFE_VERTICALFLIP;
}
if (wasflip == !(mo->eflags & MFE_VERTICALFLIP)) // note!! == ! is not equivalent to != here - turns numeric into bool this way
P_PlayerFlip(mo);
if (mo->player->kartstuff[k_pogospring])
gravityadd = (5*gravityadd)/2;
}
@@ -1017,12 +1014,17 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
if (mo->flags2 & MF2_OBJECTFLIP)
{
mo->eflags |= MFE_VERTICALFLIP;
if (mo->z + mo->height >= mo->ceilingz)
{
gravityadd = 0;
}
else if (gravityadd < 0) // Don't sink, only rise up
gravityadd *= -1;
{
gravityadd = -gravityadd;
}
}
else //Otherwise, sort through the other exceptions.
else // Otherwise, sort through the other exceptions.
{
switch (mo->type)
{
@@ -1083,7 +1085,9 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
// Goop has slower, reversed gravity
if (goopgravity)
{
gravityadd = -gravityadd/5;
}
gravityadd = FixedMul(gravityadd, mo->scale);
@@ -1121,10 +1125,8 @@ static void P_SceneryXYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy)
{
I_Assert(!P_MobjWasRemoved(mo));
const fixed_t fric_scale = FixedMul(FRACUNIT/32, mo->scale);
if (abs(mo->momx) < fric_scale
&& abs(mo->momy) < fric_scale)
if (abs(mo->momx) < FixedMul(FRACUNIT/32, mo->scale)
&& abs(mo->momy) < FixedMul(FRACUNIT/32, mo->scale))
{
mo->momx = 0;
mo->momy = 0;
@@ -1183,7 +1185,10 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy)
{
// if in a walking frame, stop moving
if (player->panim == PA_WALK && player->kartstuff[k_spinouttimer] == 0)
{
P_SetPlayerMobjState(mo, S_KART_STND1); // SRB2kart - was S_PLAY_STND
}
mo->momx = player->cmomx;
mo->momy = player->cmomy;
}
@@ -1204,7 +1209,9 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy)
}
}
else
{
P_SceneryXYFriction(mo, oldx, oldy);
}
}
static void P_PushableCheckBustables(mobj_t *mo)
@@ -1228,15 +1235,15 @@ static void P_PushableCheckBustables(mobj_t *mo)
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{
ffloor_t *rover;
fixed_t topheight, bottomheight;
if (!node->m_sector)
break;
if (!node->m_sector->ffloors)
continue;
ffloor_t *rover;
fixed_t topheight, bottomheight;
for (rover = node->m_sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BUSTUP))
@@ -1322,6 +1329,29 @@ static boolean P_CheckSkyHit(mobj_t *mo)
return false;
}
//
// P_SkullFlyReset
//
// Resets the Skull Fly to its spawn state after it collides with something.
//
static boolean P_SkullFlyReset(mobj_t *mo)
{
if (!mo->momx && !mo->momy && (mo->flags2 & MF2_SKULLFLY))
{
// the skull slammed into something
mo->flags2 &= ~MF2_SKULLFLY;
mo->momx = mo->momy = mo->momz = 0;
// set in 'search new direction' state?
if (mo->type != MT_EGGMOBILE)
P_SetMobjState(mo, mo->info->spawnstate);
return true;
}
return false;
}
//
// P_XYMovement
//
@@ -1338,23 +1368,12 @@ void P_XYMovement(mobj_t *mo)
I_Assert(!P_MobjWasRemoved(mo));
// if it's stopped
if (!mo->momx && !mo->momy)
if (P_SkullFlyReset(mo))
{
if (mo->flags2 & MF2_SKULLFLY)
{
// the skull slammed into something
mo->flags2 &= ~MF2_SKULLFLY;
mo->momx = mo->momy = mo->momz = 0;
// set in 'search new direction' state?
if (mo->type != MT_EGGMOBILE)
P_SetMobjState(mo, mo->info->spawnstate);
return;
}
return;
}
player = mo->player; //valid only if player avatar
player = mo->player; // valid only if player avatar
xmove = mo->momx;
ymove = mo->momy;
@@ -1412,7 +1431,9 @@ void P_XYMovement(mobj_t *mo)
}
}
//}
if (!P_TryMove(mo, mo->x + xmove, mo->y + ymove, true) && !(mo->eflags & MFE_SPRUNG))
if (!P_TryMove(mo, mo->x + xmove, mo->y + ymove, true)
&& !(P_MobjWasRemovedCompat(mo) || mo->eflags & MFE_SPRUNG))
{
// blocked move
moved = false;
@@ -1538,29 +1559,6 @@ void P_XYMovement(mobj_t *mo)
return;
}
// draw damage on wall
//SPLAT TEST ----------------------------------------------------------
#ifdef WALLSPLATS
if (blockingline && mo->type != MT_REDRING && mo->type != MT_FIREBALL
&& !(mo->flags2 & (MF2_AUTOMATIC|MF2_RAILRING|MF2_BOUNCERING|MF2_EXPLOSION|MF2_SCATTER)))
// set by last P_TryMove() that failed
{
divline_t divl;
divline_t misl;
fixed_t frac;
P_MakeDivline(blockingline, &divl);
misl.x = mo->x;
misl.y = mo->y;
misl.dx = mo->momx;
misl.dy = mo->momy;
frac = P_InterceptVector(&divl, &misl);
R_AddWallSplat(blockingline, P_PointOnLineSide(mo->x,mo->y,blockingline),
"A_DMG3", mo->z, frac, SPLATDRAWMODE_SHADE);
}
#endif
// --------------------------------------------------------- SPLAT TEST
P_ExplodeMissile(mo);
return;
}
@@ -1709,6 +1707,9 @@ static void P_SceneryXYMovement(mobj_t *mo)
if (!P_SceneryTryMove(mo, mo->x + mo->momx, mo->y + mo->momy))
P_SlideMove(mo, false);
if (P_MobjWasRemovedCompat(mo))
return;
if ((!(mo->eflags & MFE_VERTICALFLIP) && mo->z > mo->floorz) || (mo->eflags & MFE_VERTICALFLIP && mo->z+mo->height < mo->ceilingz))
return; // no friction when airborne
@@ -1736,7 +1737,7 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp
{
ffloor_t *rover;
fixed_t delta1, delta2, thingtop;
fixed_t topheight, bottomheight;
fixed_t topheight, bottomheight, midheight;
I_Assert(!P_MobjWasRemoved(mo));
@@ -1781,18 +1782,19 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp
}
}
const fixed_t mid = (bottomheight + ((topheight - bottomheight) / 2));
midheight = (bottomheight + ((topheight - bottomheight) / 2));
delta1 = abs(mo->z - mid);
delta2 = abs(thingtop - mid);
delta1 = abs(mo->z - midheight);
delta2 = abs(thingtop - midheight);
if (topheight > mo->floorz && delta1 < delta2
if (topheight > mo->floorz && (delta1 < delta2)
&& !(rover->flags & FF_REVERSEPLATFORM)
&& ((P_MobjFlip(mo)*mo->momz >= 0) || (!(rover->flags & FF_PLATFORM)))) // In reverse gravity, only clip for FOFs that are intangible from their bottom (the "top" you're falling through) if you're coming from above ("below" in your frame of reference)
{
mo->floorz = topheight;
}
if (bottomheight < mo->ceilingz && delta1 >= delta2
if (bottomheight < mo->ceilingz && (delta1 >= delta2)
&& !(rover->flags & FF_PLATFORM)
&& ((P_MobjFlip(mo)*mo->momz >= 0) || (!(rover->flags & FF_REVERSEPLATFORM)))) // In normal gravity, only clip for FOFs that are intangible from the top if you're coming from below
{
@@ -1812,7 +1814,7 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec)
polyobj_t *po = subsec->polyList;
sector_t *polysec;
fixed_t delta1, delta2, thingtop;
fixed_t polytop, polybottom;
fixed_t polytop, polybottom, polymid;
I_Assert(!P_MobjWasRemoved(mo));
@@ -1840,15 +1842,15 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec)
polybottom = INT32_MIN;
}
const fixed_t mid = polybottom + ((polytop - polybottom) / 2);
polymid = (polybottom + ((polytop - polybottom) / 2));
delta1 = abs(mo->z - mid);
delta2 = abs(thingtop - mid);
delta1 = abs(mo->z - polymid);
delta2 = abs(thingtop - polymid);
if (polytop > mo->floorz && delta1 < delta2)
if (polytop > mo->floorz && (delta1 < delta2))
mo->floorz = polytop;
if (polybottom < mo->ceilingz && delta1 >= delta2)
if (polybottom < mo->ceilingz && (delta1 >= delta2))
mo->ceilingz = polybottom;
po = (polyobj_t *)(po->link.next);
@@ -1895,12 +1897,17 @@ boolean P_CheckDeathPitCollide(mobj_t *mo)
const INT32 secspecial = GETSECSPECIAL(mo->subsector->sector->special, 1);
if (((mo->z <= mo->subsector->sector->floorheight
&& !(mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR))
|| (mo->z + mo->height >= mo->subsector->sector->ceilingheight
&& (mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING)))
&& (secspecial == 6 || secspecial == 7))
return true;
// Death Pit
if (secspecial == 6 || secspecial == 7)
{
const boolean flipped = (mo->eflags & MFE_VERTICALFLIP);
if (!flipped && (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR))
return (mo->z <= mo->subsector->sector->floorheight);
if (flipped && (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING))
return (mo->z + mo->height >= mo->subsector->sector->ceilingheight);
}
return false;
}
@@ -1909,10 +1916,14 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover)
{
I_Assert(!P_MobjWasRemoved(mo));
if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3
&& !(rover->master->flags & ML_BLOCKMONSTERS)
&& ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > P_GetFFloorTopZAt(rover, mo->x, mo->y) - FixedMul(16*FRACUNIT, mo->scale)))
if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3)
{
if (!(rover->master->flags & ML_BLOCKMONSTERS) &&
((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > P_GetFFloorTopZAt(rover, mo->x, mo->y) - FixedMul(16*FRACUNIT, mo->scale)))
{
return true;
}
}
return false;
}
@@ -2121,13 +2132,12 @@ static boolean P_ZMovement(mobj_t *mo)
if (mo->type == MT_JETJAW && mo->z + mo->height > mo->watertop)
mo->z = mo->watertop - mo->height;
}
}
// clip movement
if (((mo->z <= mo->floorz && !(mo->eflags & MFE_VERTICALFLIP))
|| (mo->z + mo->height >= mo->ceilingz && mo->eflags & MFE_VERTICALFLIP))
&& !(mo->flags & MF_NOCLIPHEIGHT))
&& !(mo->flags & MF_NOCLIPHEIGHT))
{
vector3_t mom;
mom.x = mo->momx;
@@ -2146,6 +2156,10 @@ static boolean P_ZMovement(mobj_t *mo)
}
P_CheckPosition(mo, mo->x, mo->y); // Sets mo->standingslope correctly
if (P_MobjWasRemovedCompat(mo)) // mobjs can be removed by P_CheckPosition -- Monster Iestyn 31/07/21
return false;
if (((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) && (mo->type != MT_STEAM))
{
mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope;
@@ -2183,6 +2197,7 @@ static boolean P_ZMovement(mobj_t *mo)
// Otherwise bounce up at half speed.
else
mom.z = -mom.z/2;
S_StartSound(mo, mo->info->activesound);
}
}
@@ -2300,7 +2315,9 @@ static boolean P_ZMovement(mobj_t *mo)
|| tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER))
mom.z = tmfloorthing->momz;
if (mo->standingslope) { // MT_STEAM will never have a standingslope, see above.
// MT_STEAM will never have a standingslope, see above.
if (mo->standingslope)
{
P_QuantizeMomentumToSlope(&mom, mo->standingslope);
}
@@ -2321,7 +2338,7 @@ static boolean P_ZMovement(mobj_t *mo)
if (((mo->z + mo->height > mo->ceilingz && !(mo->eflags & MFE_VERTICALFLIP))
|| (mo->z < mo->floorz && mo->eflags & MFE_VERTICALFLIP))
&& !(mo->flags & MF_NOCLIPHEIGHT))
&& !(mo->flags & MF_NOCLIPHEIGHT))
{
if (mo->eflags & MFE_VERTICALFLIP)
mo->z = mo->floorz;
@@ -2377,6 +2394,103 @@ static boolean P_ZMovement(mobj_t *mo)
return true;
}
// Check for "Mario" blocks to hit and bounce them
static void P_CheckMarioBlocks(mobj_t *mo)
{
msecnode_t *node;
// Only let the player punch
if (netgame && mo->player->spectator)
return;
// Search the touching sectors, from side-to-side...
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{
ffloor_t *rover;
if (!node->m_sector->ffloors)
continue;
for (rover = node->m_sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
continue;
// Come on, it's time to go...
if (!(rover->flags & FF_MARIO))
continue;
if (mo->eflags & MFE_VERTICALFLIP)
continue; // if you were flipped, your head isn't actually hitting your ceilingz is it?
if (*rover->bottomheight != mo->ceilingz)
continue; // The player's head hit the bottom!
// DO THE MARIO!
EV_MarioBlock(rover->master->frontsector, node->m_sector, *rover->topheight, mo);
}
} // Ugly ugly billions of braces! Argh!
}
// Check if we're on a polyobject that triggers a linedef executor.
static boolean P_PlayerPolyObjectZMovement(mobj_t *mo)
{
msecnode_t *node;
boolean stopmovecut = false;
// no polyobjects on the map
if (!numPolyObjects)
{
return false;
}
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{
sector_t *sec = node->m_sector;
subsector_t *newsubsec;
size_t i;
for (i = 0; i < numsubsectors; i++)
{
polyobj_t *po;
sector_t *polysec;
newsubsec = &subsectors[i];
if (newsubsec->sector != sec)
continue;
for (po = newsubsec->polyList; po; po = (polyobj_t *)(po->link.next))
{
if (!(po->flags & POF_SOLID))
continue;
if (!P_MobjInsidePolyobj(po, mo))
continue;
// We're inside it! Yess...
polysec = po->lines[0]->backsector;
// Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red
if ((mo->z == polysec->ceilingheight || mo->z + mo->height == polysec->floorheight) && po->thinker)
stopmovecut = true;
if (!(po->flags & POF_LDEXEC))
continue;
if (mo->z != polysec->ceilingheight)
continue;
// We're landing on a PO, so check for
// a linedef executor.
// Trigger tags are 32000 + the PO's ID number.
P_LinedefExecute((INT16)(32000 + po->id), mo, NULL);
}
}
}
return stopmovecut;
}
static void P_PlayerZMovement(mobj_t *mo)
{
I_Assert(!P_MobjWasRemoved(mo));
@@ -2410,8 +2524,8 @@ static void P_PlayerZMovement(mobj_t *mo)
mo->z += mo->momz;
// Have player fall through floor?
if (mo->player->playerstate == PST_DEAD
|| mo->player->playerstate == PST_REBORN)
if (mo->player->playerstate == PST_DEAD ||
mo->player->playerstate == PST_REBORN)
return;
if (mo->standingslope)
@@ -2426,15 +2540,21 @@ static void P_PlayerZMovement(mobj_t *mo)
if (P_IsObjectOnGround(mo) && !(mo->flags & MF_NOCLIPHEIGHT))
{
if (mo->eflags & MFE_VERTICALFLIP)
{
mo->z = mo->ceilingz - mo->height;
}
else
{
mo->z = mo->floorz;
}
if (nightsplayer(mo->player))
{
const boolean flipped = (mo->eflags & MFE_VERTICALFLIP);
// bounce off floor if you were flying towards it
if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 0 && mo->player->flyangle < 180)
|| (!(mo->eflags & MFE_VERTICALFLIP) && mo->player->flyangle > 180 && mo->player->flyangle <= 359))
if ((flipped && mo->player->flyangle > 0 && mo->player->flyangle < 180) ||
(!flipped && mo->player->flyangle > 180 && mo->player->flyangle <= 359))
{
if (mo->player->flyangle < 90 || mo->player->flyangle >= 270)
mo->player->flyangle += P_MobjFlip(mo)*90;
@@ -2442,20 +2562,26 @@ static void P_PlayerZMovement(mobj_t *mo)
mo->player->flyangle -= P_MobjFlip(mo)*90;
mo->player->speed = FixedMul(mo->player->speed, 4*FRACUNIT/5);
}
goto nightsdone;
}
// Get up if you fell.
if ((mo->state == &states[mo->info->painstate] || mo->state == &states[S_KART_SPIN])
&& mo->player->kartstuff[k_spinouttimer] == 0 && mo->player->kartstuff[k_squishedtimer] == 0) // SRB2kart
{
P_SetPlayerMobjState(mo, S_KART_STND1);
}
if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) {
#if 0 // praying that removing this dupe wont cause any issues...
if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope))
{
// Handle landing on slope during Z movement
P_HandleSlopeLanding(mo, (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope));
}
if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) {
#endif
if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope))
{
// Handle landing on slope during Z movement
P_HandleSlopeLanding(mo, (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope));
}
@@ -2464,88 +2590,28 @@ static void P_PlayerZMovement(mobj_t *mo)
{
mo->pmomz = 0; // We're on a new floor, don't keep doing platform movement.
if (!tmfloorthing || tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR)
|| tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER) // Spin Attack
if (!tmfloorthing || tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) ||
tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER) // Spin Attack
{
mo->eflags |= MFE_JUSTHITFLOOR; // Spin Attack
if (mo->eflags & MFE_JUSTHITFLOOR)
{
// Check if we're on a polyobject
// that triggers a linedef executor.
msecnode_t *node;
boolean stopmovecut = false;
if (numPolyObjects)
if (!P_PlayerPolyObjectZMovement(mo))
{
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{
sector_t *sec = node->m_sector;
subsector_t *newsubsec;
size_t i;
for (i = 0; i < numsubsectors; i++)
{
newsubsec = &subsectors[i];
if (newsubsec->sector != sec)
continue;
if (!newsubsec->polyList)
continue;
polyobj_t *po = newsubsec->polyList;
sector_t *polysec;
while (po)
{
if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID))
{
po = (polyobj_t *)(po->link.next);
continue;
}
// We're inside it! Yess...
polysec = po->lines[0]->backsector;
// Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red
if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker)
stopmovecut = true;
if (!(po->flags & POF_LDEXEC))
{
po = (polyobj_t *)(po->link.next);
continue;
}
if (mo->z == polysec->ceilingheight)
{
// We're landing on a PO, so check for
// a linedef executor.
// Trigger tags are 32000 + the PO's ID number.
P_LinedefExecute((INT16)(32000 + po->id), mo, NULL);
}
po = (polyobj_t *)(po->link.next);
}
}
}
}
if (!stopmovecut)
// Cut momentum in half when you hit the ground and
// aren't pressing any controls.
if (!(mo->player->cmd.forwardmove || mo->player->cmd.sidemove) && !mo->player->cmomx && !mo->player->cmomy
&& !(mo->player->kartstuff[k_spinouttimer]))
{
mo->momx = mo->momx/2;
mo->momy = mo->momy/2;
if (mo->player->cmd.buttons & BT_BRAKE && !(mo->player->cmd.forwardmove)) // FURTHER slowdown if you're braking.
// Cut momentum in half when you hit the ground and
// aren't pressing any controls.
if (!(mo->player->cmd.forwardmove || mo->player->cmd.sidemove) && !mo->player->cmomx && !mo->player->cmomy
&& !(mo->player->kartstuff[k_spinouttimer]))
{
mo->momx = mo->momx/2;
mo->momy = mo->momy/2;
if (mo->player->cmd.buttons & BT_BRAKE && !(mo->player->cmd.forwardmove)) // FURTHER slowdown if you're braking.
{
mo->momx = mo->momx/2;
mo->momy = mo->momy/2;
}
}
}
}
@@ -2623,14 +2689,17 @@ nightsdone:
if (nightsplayer(mo->player))
{
const boolean flipped = (mo->eflags & MFE_VERTICALFLIP);
// bounce off ceiling if you were flying towards it
if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 180 && mo->player->flyangle <= 359)
|| (!(mo->eflags & MFE_VERTICALFLIP) && mo->player->flyangle > 0 && mo->player->flyangle < 180))
if ((flipped && mo->player->flyangle > 180 && mo->player->flyangle <= 359)
|| (!flipped && mo->player->flyangle > 0 && mo->player->flyangle < 180))
{
if (mo->player->flyangle < 90 || mo->player->flyangle >= 270)
mo->player->flyangle -= P_MobjFlip(mo)*90;
else
mo->player->flyangle += P_MobjFlip(mo)*90;
mo->player->flyangle %= 360;
mo->player->speed = FixedMul(mo->player->speed, 4*FRACUNIT/5);
}
@@ -2639,31 +2708,8 @@ nightsdone:
// Check for "Mario" blocks to hit and bounce them
if (P_MobjFlip(mo)*mo->momz > 0)
{
msecnode_t *node;
if (CheckForMarioBlocks && !(netgame && mo->player->spectator)) // Only let the player punch
{
// Search the touching sectors, from side-to-side...
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{
ffloor_t *rover;
if (!node->m_sector->ffloors)
continue;
for (rover = node->m_sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
continue;
// Come on, it's time to go...
if (rover->flags & FF_MARIO
&& !(mo->eflags & MFE_VERTICALFLIP) // if you were flipped, your head isn't actually hitting your ceilingz is it?
&& *rover->bottomheight == mo->ceilingz) // The player's head hit the bottom!
// DO THE MARIO!
EV_MarioBlock(rover->master->frontsector, node->m_sector, *rover->topheight, mo);
}
} // Ugly ugly billions of braces! Argh!
}
if (CheckForMarioBlocks)
P_CheckMarioBlocks(mo);
// hit the ceiling
if (mariomode)
@@ -2801,7 +2847,7 @@ static boolean P_SceneryZMovement(mobj_t *mo)
// clip movement
if (((mo->z <= mo->floorz && !(mo->eflags & MFE_VERTICALFLIP))
|| (mo->z + mo->height >= mo->ceilingz && mo->eflags & MFE_VERTICALFLIP))
&& !(mo->flags & MF_NOCLIPHEIGHT))
&& !(mo->flags & MF_NOCLIPHEIGHT))
{
if (mo->eflags & MFE_VERTICALFLIP)
mo->z = mo->ceilingz - mo->height;
@@ -2831,7 +2877,7 @@ static boolean P_SceneryZMovement(mobj_t *mo)
if (((mo->z + mo->height > mo->ceilingz && !(mo->eflags & MFE_VERTICALFLIP))
|| (mo->z < mo->floorz && mo->eflags & MFE_VERTICALFLIP))
&& !(mo->flags & MF_NOCLIPHEIGHT))
&& !(mo->flags & MF_NOCLIPHEIGHT))
{
if (mo->eflags & MFE_VERTICALFLIP)
mo->z = mo->floorz;
@@ -2869,13 +2915,13 @@ void P_MobjCheckWater(mobj_t *mobj)
for (rover = sector->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
fixed_t topcheck, bottomcheck;
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE)
|| (((rover->flags & FF_BLOCKPLAYER) && mobj->player)
|| ((rover->flags & FF_BLOCKOTHERS) && !mobj->player)))
continue;
fixed_t topcheck, bottomcheck;
if (mobj->eflags & MFE_VERTICALFLIP)
{
topcheck = (thingtop - FixedMul(mobj->info->height/2, mobj->scale));
+12
View File
@@ -5302,6 +5302,18 @@ static void P_RunLevelLoadExecutors(void)
}
}
static fixed_t P_GetSectorGravityFactor(sector_t *sec)
{
return FixedDiv(*sec->gravity >> FRACBITS, 1000);
}
fixed_t P_GetSectorGravity(sector_t *sec)
{
if (sec && sec->gravity)
return FixedMul(gravity, P_GetSectorGravityFactor(sec));
return gravity;
}
/** After the map has loaded, scans for specials that spawn 3Dfloors and
* thinkers.
*
+2
View File
@@ -56,6 +56,8 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
void P_PlayerInSpecialSector(player_t *player);
void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *roversector);
fixed_t P_GetSectorGravity(sector_t *sec);
fixed_t P_FindLowestFloorSurrounding(sector_t *sec);
fixed_t P_FindHighestFloorSurrounding(sector_t *sec);