- refactored those unwieldy intercept position calculations into a subfunction.

This commit is contained in:
Christoph Oelckers 2016-03-03 00:58:25 +01:00
commit 6b1485a89f
3 changed files with 26 additions and 23 deletions

View file

@ -2837,8 +2837,7 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t
}
// set openrange, opentop, openbottom
P_LineOpening(open, slidemo, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac),
it.Trace().y + FixedMul(it.Trace().dy, in->frac));
P_LineOpening(open, slidemo, li, it.InterceptPoint(in));
if (open.range < slidemo->height)
goto isblocking; // doesn't fit
@ -3192,8 +3191,7 @@ bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_
}
P_LineOpening(open, slidemo, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac),
it.Trace().y + FixedMul(it.Trace().dy, in->frac)); // set openrange, opentop, openbottom
P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); // set openrange, opentop, openbottom
if (open.range < slidemo->height)
goto bounceblocking; // doesn't fit
@ -3811,8 +3809,7 @@ struct aim_t
// Crosses a two sided line.
// A two sided line will restrict the possible target ranges.
FLineOpening open;
P_LineOpening(open, NULL, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac),
it.Trace().y + FixedMul(it.Trace().dy, in->frac), FIXED_MIN, 0, FFCF_NODROPOFF);
P_LineOpening(open, NULL, li, it.InterceptPoint(in), FIXED_MIN, 0, FFCF_NODROPOFF);
// The following code assumes that portals on the front of the line have already been processed.
@ -4985,8 +4982,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end
}
else
{
P_LineOpening(open, NULL, in->d.line, it.Trace().x + FixedMul(it.Trace().dx, in->frac),
it.Trace().y + FixedMul(it.Trace().dy, in->frac));
P_LineOpening(open, NULL, in->d.line, it.InterceptPoint(in));
}
if (open.range <= 0 ||
(in->d.line->special != 0 && (i_compatflags & COMPATF_USEBLOCKING)))
@ -5094,8 +5090,7 @@ bool P_NoWayTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t e
if (ld->special) continue;
if (ld->isLinePortal()) return false;
if (ld->flags&(ML_BLOCKING | ML_BLOCKEVERYTHING | ML_BLOCK_PLAYERS)) return true;
P_LineOpening(open, NULL, ld, it.Trace().x + FixedMul(it.Trace().dx, in->frac),
it.Trace().y + FixedMul(it.Trace().dy, in->frac));
P_LineOpening(open, NULL, ld, it.InterceptPoint(in));
if (open.range <= 0 ||
open.bottom > usething->Z() + usething->MaxStepHeight ||
open.top < usething->Top()) return true;
@ -5179,8 +5174,7 @@ bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
{ // Check line
if (in->d.line->special != UsePuzzleItem)
{
P_LineOpening(open, NULL, in->d.line, it.Trace().x + FixedMul(it.Trace().dx, in->frac),
it.Trace().y + FixedMul(it.Trace().dy, in->frac));
P_LineOpening(open, NULL, in->d.line, it.InterceptPoint(in));
if (open.range <= 0)
{
return false; // can't use through a wall