P_TryMove: reduce the amount of R_PointInSubsector per call

and also P_PlayerTouchingSectorSpecial
since either are in a loop that often runs multiple times per call
This commit is contained in:
alufolie91 committed 2026-05-12 15:38:13 +02:00
1 parent 58c7dfa1ac
commit 60f845bf9e
4 files changed
+21 -18

No files matched your search

-1
View File
@@ -1894,7 +1894,6 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies)
{
if (nobaddies->sector->lines[i]->special == 223)
{
upperbound = nobaddies->sector->ceilingheight;
lowerbound = nobaddies->sector->floorheight;
+18 -15
View File
@@ -2373,6 +2373,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
fixed_t radius = thing->radius;
fixed_t thingtop ;//= thing->z + thing->height;
fixed_t startingonground = P_IsObjectOnGround(thing);
INT32 special = -1;
floatok = false;
if (radius < MAXRADIUS/2)
@@ -2406,21 +2407,31 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
if (!(thing->flags & MF_NOCLIP))
{
//All things are affected by their scale.
fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale);
INT32 special = 0;
// All things are affected by their scale.
fixed_t maxstep;
if (tmceilingz - tmfloorz < thing->height)
{
if (tmfloorthing)
tmhitthing = tmfloorthing;
return false; // doesn't fit
}
maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale);
if (thing->player)
{
special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1);
if (special == -1)
special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1);
// If using type Section1:13, double the maxstep.
if (P_PlayerTouchingSectorSpecial(thing->player, 1, 13) || special == 13)
if (special == 13 || P_PlayerTouchingSectorSpecial(thing->player, 1, 13))
{
maxstep <<= 1;
}
// If using type Section1:12, no maxstep. For ledges you don't want the player to climb! (see: Egg Zeppelin & SMK port walls)
else if (P_PlayerTouchingSectorSpecial(thing->player, 1, 12) || special == 12)
else if (special == 12 || P_PlayerTouchingSectorSpecial(thing->player, 1, 12))
{
maxstep = 0;
}
@@ -2431,14 +2442,6 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
maxstep = 0;
}
if (tmceilingz - tmfloorz < thing->height)
{
if (tmfloorthing)
tmhitthing = tmfloorthing;
return false; // doesn't fit
}
floatok = true;
thingtop = thing->z + thing->height;
@@ -2469,7 +2472,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
}
}
else if (maxstep > 0 && !(thing->player &&
(P_PlayerTouchingSectorSpecial(thing->player, 1, 14) || special == 14))) // Step down
(special == 14 || P_PlayerTouchingSectorSpecial(thing->player, 1, 14)))) // Step down
{
// If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS
// step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more.
+1 -1
View File
@@ -1859,7 +1859,7 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec)
while (po)
{
if (!(po->flags & POF_SOLID) || !P_MobjInsidePolyobj(po, mo))
if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID))
{
po = (polyobj_t *)(po->link.next);
continue;
+2 -1
View File
@@ -4441,12 +4441,13 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector)
}
f_affectpoint = P_GetSpecialBottomZ(player->mo, sector, sector);
c_affectpoint = P_GetSpecialTopZ(player->mo, sector, sector);
// Only go further if on the ground
if ((sector->flags & SF_FLIPSPECIAL_FLOOR) && !(sector->flags & SF_FLIPSPECIAL_CEILING) && player->mo->z != f_affectpoint)
return;
c_affectpoint = P_GetSpecialTopZ(player->mo, sector, sector);
if ((sector->flags & SF_FLIPSPECIAL_CEILING) && !(sector->flags & SF_FLIPSPECIAL_FLOOR) && player->mo->z + player->mo->height != c_affectpoint)
return;