Some simplifications after MI pointed out that the sector heights are the only thing accessed outside of the iteration.

This commit is contained in:
toasterbabe 2016-06-07 17:55:03 +01:00
parent 9d221f4f3f
commit 9df72a966e

View file

@ -2959,19 +2959,11 @@ static void P_DoTeeter(player_t *player)
if (checkedforteeter && !teeter) // Backup code if (checkedforteeter && !teeter) // Backup code
{ {
subsector_t *subsec[4]; // changed abcd into array instead sector_t *sec;
fixed_t subsecfloorheight[4]; fixed_t secfloorheight[4];
fixed_t subsecceilingheight[4]; fixed_t secceilingheight[4];
UINT8 i; UINT8 i;
// Following is replaced by xsign and ysign code
/*
subsec[0] = R_PointInSubsector(player->mo->x + FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y + FixedMul(5*FRACUNIT, player->mo->scale));
subsec[1] = R_PointInSubsector(player->mo->x - FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y + FixedMul(5*FRACUNIT, player->mo->scale));
subsec[2] = R_PointInSubsector(player->mo->x + FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y - FixedMul(5*FRACUNIT, player->mo->scale));
subsec[3] = R_PointInSubsector(player->mo->x - FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y - FixedMul(5*FRACUNIT, player->mo->scale));
*/
teeter = false; teeter = false;
roverfloor = false; roverfloor = false;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
@ -2983,23 +2975,23 @@ static void P_DoTeeter(player_t *player)
fixed_t checkx = player->mo->x + (xsign*FixedMul(5*FRACUNIT, player->mo->scale)); fixed_t checkx = player->mo->x + (xsign*FixedMul(5*FRACUNIT, player->mo->scale));
fixed_t checky = player->mo->y + (ysign*FixedMul(5*FRACUNIT, player->mo->scale)); fixed_t checky = player->mo->y + (ysign*FixedMul(5*FRACUNIT, player->mo->scale));
subsec[i] = R_PointInSubsector(checkx, checky); sec = R_PointInSubsector(checkx, checky)->sector;
subsecceilingheight[i] = subsec[i]->sector->ceilingheight; secceilingheight[i] = sec->ceilingheight;
subsecfloorheight[i] = subsec[i]->sector->floorheight; secfloorheight[i] = sec->floorheight;
#ifdef ESLOPE #ifdef ESLOPE
if (subsec[i]->sector->c_slope) if (sec->c_slope)
subsecceilingheight[i] = P_GetZAt(subsec[i]->sector->c_slope, checkx, checky); secceilingheight[i] = P_GetZAt(sec->c_slope, checkx, checky);
if (subsec[i]->sector->f_slope) if (sec->f_slope)
subsecfloorheight[i] = P_GetZAt(subsec[i]->sector->f_slope, checkx, checky); secfloorheight[i] = P_GetZAt(sec->f_slope, checkx, checky);
#endif #endif
#undef xsign #undef xsign
#undef ysign #undef ysign
if (!(subsec[i]->sector->ffloors)) if (!(sec->ffloors))
continue; // move on to the next subsector continue; // move on to the next subsector
for (rover = subsec[i]->sector->ffloors; rover; rover = rover->next) for (rover = sec->ffloors; rover; rover = rover->next)
{ {
if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_EXISTS)) continue;
@ -3020,12 +3012,12 @@ static void P_DoTeeter(player_t *player)
if (player->mo->eflags & MFE_VERTICALFLIP) if (player->mo->eflags & MFE_VERTICALFLIP)
{ {
if (bottomheight > subsecceilingheight[i]) // Above the ceiling if (bottomheight > secceilingheight[i]) // Above the ceiling
continue; continue;
if (bottomheight > player->mo->z + player->mo->height + tiptop if (bottomheight > player->mo->z + player->mo->height + tiptop
|| (topheight < player->mo->z || (topheight < player->mo->z
&& player->mo->z + player->mo->height < subsecceilingheight[i] - tiptop)) && player->mo->z + player->mo->height < secceilingheight[i] - tiptop))
{ {
teeter = true; teeter = true;
roverfloor = true; roverfloor = true;
@ -3039,12 +3031,12 @@ static void P_DoTeeter(player_t *player)
} }
else else
{ {
if (topheight < subsecfloorheight[i]) // Below the floor if (topheight < secfloorheight[i]) // Below the floor
continue; continue;
if (topheight < player->mo->z - tiptop if (topheight < player->mo->z - tiptop
|| (bottomheight > player->mo->z + player->mo->height || (bottomheight > player->mo->z + player->mo->height
&& player->mo->z > subsecfloorheight[i] + tiptop)) && player->mo->z > secfloorheight[i] + tiptop))
{ {
teeter = true; teeter = true;
roverfloor = true; roverfloor = true;
@ -3062,18 +3054,18 @@ static void P_DoTeeter(player_t *player)
if (player->mo->eflags & MFE_VERTICALFLIP) if (player->mo->eflags & MFE_VERTICALFLIP)
{ {
if (!teeter && !roverfloor && (subsecceilingheight[0] > player->mo->ceilingz + tiptop if (!teeter && !roverfloor && (secceilingheight[0] > player->mo->ceilingz + tiptop
|| subsecceilingheight[1] > player->mo->ceilingz + tiptop || secceilingheight[1] > player->mo->ceilingz + tiptop
|| subsecceilingheight[2] > player->mo->ceilingz + tiptop || secceilingheight[2] > player->mo->ceilingz + tiptop
|| subsecceilingheight[3] > player->mo->ceilingz + tiptop)) || secceilingheight[3] > player->mo->ceilingz + tiptop))
teeter = true; teeter = true;
} }
else else
{ {
if (!teeter && !roverfloor && (subsecfloorheight[0] < player->mo->floorz - tiptop if (!teeter && !roverfloor && (secfloorheight[0] < player->mo->floorz - tiptop
|| subsecfloorheight[1] < player->mo->floorz - tiptop || secfloorheight[1] < player->mo->floorz - tiptop
|| subsecfloorheight[2] < player->mo->floorz - tiptop || secfloorheight[2] < player->mo->floorz - tiptop
|| subsecfloorheight[3] < player->mo->floorz - tiptop)) || secfloorheight[3] < player->mo->floorz - tiptop))
teeter = true; teeter = true;
} }
} }