Improved compatibility of blocking lines handling

Only the first blocking line changes contact state during line iteration
This reverts 3b818171d5

https://forum.zdoom.org/viewtopic.php?t=57870
This commit is contained in:
alexey.lysiuk 2017-12-31 11:34:12 +02:00
parent a5ded11994
commit 40fd816d54

View file

@ -856,7 +856,7 @@ static int LineIsBelow(line_t *line, AActor *actor)
//==========================================================================
static // killough 3/26/98: make static
bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::CheckResult &cres, const FBoundingBox &box, FCheckPosition &tm)
bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::CheckResult &cres, const FBoundingBox &box, FCheckPosition &tm, const bool wasfit)
{
line_t *ld = cres.line;
bool rail = false;
@ -901,6 +901,8 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
{
double portz = cres.line->frontsector->GetPortalPlaneZ(sector_t::ceiling);
if (tm.thing->Z() < portz && tm.thing->Z() + tm.thing->MaxStepHeight >= portz && tm.floorz < portz)
{
if (wasfit)
{
tm.floorz = portz;
tm.floorsector = cres.line->frontsector;
@ -908,6 +910,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
tm.floorterrain = 0;
tm.portalstep = true;
tm.portalgroup = cres.line->frontsector->GetOppositePortalGroup(sector_t::ceiling);
}
return true;
}
}
@ -916,7 +919,10 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
{
P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee);
}
if (wasfit)
{
tm.thing->BlockingLine = ld;
}
CheckForPushSpecial(ld, 0, tm.thing);
return false;
}
@ -947,6 +953,8 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
int state = LineIsAbove(cres.line, tm.thing);
if (state == -1) return true;
if (state == 1)
{
if (wasfit)
{
// the line should not block but we should set the ceilingz to the portal boundary so that we can't float up into that line.
double portalz = cres.line->frontsector->GetPortalPlaneZ(sector_t::floor);
@ -955,6 +963,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
tm.ceilingz = portalz;
tm.ceilingsector = cres.line->frontsector;
}
}
return true;
}
}
@ -964,6 +973,8 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
int state = LineIsBelow(cres.line, tm.thing);
if (state == -1) return true;
if (state == 1)
{
if (wasfit)
{
double portalz = cres.line->frontsector->GetPortalPlaneZ(sector_t::ceiling);
if (portalz > tm.floorz)
@ -972,6 +983,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
tm.floorsector = cres.line->frontsector;
tm.floorterrain = 0;
}
}
return true;
}
}
@ -981,7 +993,10 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
{
P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee);
}
if (wasfit)
{
tm.thing->BlockingLine = ld;
}
// Calculate line side based on the actor's original position, not the new one.
CheckForPushSpecial(ld, P_PointOnLineSide(cres.Position, ld), tm.thing);
return false;
@ -999,10 +1014,13 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
{
double portz = tm.thing->Sector->GetPortalPlaneZ(sector_t::ceiling);
if (tm.thing->Z() < portz && tm.thing->Z() + tm.thing->MaxStepHeight >= portz && tm.floorz < portz)
{
if (wasfit)
{
// Actor is stepping through a portal.
tm.portalstep = true;
tm.portalgroup = tm.thing->Sector->GetOppositePortalGroup(sector_t::ceiling);
}
return true;
}
}
@ -1042,6 +1060,8 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
open.bottom += 32;
}
if (wasfit)
{
// adjust floor / ceiling heights
if (!(cres.portalflags & FFCF_NOCEILING))
{
@ -1079,6 +1099,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
tm.dropoffz = open.lowfloor;
}
}
}
// if contacted a special line, add it to the list
spechit_t spec;
@ -1881,7 +1902,7 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, boo
while (it.Next(&lcres))
{
bool thisresult = PIT_CheckLine(it, lcres, it.Box(), tm);
bool thisresult = PIT_CheckLine(it, lcres, it.Box(), tm, good);
good &= thisresult;
if (thisresult)
{
@ -5920,10 +5941,7 @@ bool P_AdjustFloorCeil(AActor *thing, FChangePosition *cpos)
}
bool isgood = P_CheckPosition(thing, thing->Pos(), tm);
// This is essentially utterly broken because it even uses the return from a failed P_CheckPosition but the entire logic will break down if that isn't done.
// However, if tm.floorz is greater than tm.ceilingz we have a real problem that needs to be dealt with exolicitly.
if (!(thing->flags4 & MF4_ACTLIKEBRIDGE) && tm.floorz <= tm.ceilingz)
if (!(thing->flags4 & MF4_ACTLIKEBRIDGE))
{
thing->floorz = tm.floorz;
thing->ceilingz = tm.ceilingz;