- iterating through portal groups must check for situations where badly constructed maps let items end up in another portal group.

This commit is contained in:
Christoph Oelckers 2018-01-29 18:00:55 +01:00
parent 1e9fdca755
commit 6107f36ad2
2 changed files with 19 additions and 10 deletions

View file

@ -809,11 +809,13 @@ bool FMultiBlockLinesIterator::GoUp(double x, double y)
{ {
if (!cursector->PortalBlocksMovement(sector_t::ceiling)) if (!cursector->PortalBlocksMovement(sector_t::ceiling))
{ {
startIteratorForGroup(cursector->GetOppositePortalGroup(sector_t::ceiling)); if (startIteratorForGroup(cursector->GetOppositePortalGroup(sector_t::ceiling)))
{
portalflags = FFCF_NOFLOOR; portalflags = FFCF_NOFLOOR;
return true; return true;
} }
else continueup = false; }
continueup = false;
} }
return false; return false;
} }
@ -830,11 +832,13 @@ bool FMultiBlockLinesIterator::GoDown(double x, double y)
{ {
if (!cursector->PortalBlocksMovement(sector_t::floor)) if (!cursector->PortalBlocksMovement(sector_t::floor))
{ {
startIteratorForGroup(cursector->GetOppositePortalGroup(sector_t::floor)); if (startIteratorForGroup(cursector->GetOppositePortalGroup(sector_t::floor)))
{
portalflags = FFCF_NOCEILING; portalflags = FFCF_NOCEILING;
return true; return true;
} }
else continuedown = false; }
continuedown = false;
} }
return false; return false;
} }
@ -906,14 +910,19 @@ bool FMultiBlockLinesIterator::Next(FMultiBlockLinesIterator::CheckResult *item)
// //
//=========================================================================== //===========================================================================
void FMultiBlockLinesIterator::startIteratorForGroup(int group) bool FMultiBlockLinesIterator::startIteratorForGroup(int group)
{ {
offset = Displacements.getOffset(basegroup, group); offset = Displacements.getOffset(basegroup, group);
offset.X += checkpoint.X; offset.X += checkpoint.X;
offset.Y += checkpoint.Y; offset.Y += checkpoint.Y;
cursector = group == startsector->PortalGroup ? startsector : P_PointInSector(offset); cursector = group == startsector->PortalGroup ? startsector : P_PointInSector(offset);
// If we ended up in a different group,
// presumably because the spot to be checked is too far outside the actual portal group,
// the search needs to abort.
if (cursector->PortalGroup != group) return false;
bbox.setBox(offset.X, offset.Y, checkpoint.Z); bbox.setBox(offset.X, offset.Y, checkpoint.Z);
blockIterator.init(bbox); blockIterator.init(bbox);
return true;
} }
//=========================================================================== //===========================================================================

View file

@ -240,7 +240,7 @@ class FMultiBlockLinesIterator
bool GoUp(double x, double y); bool GoUp(double x, double y);
bool GoDown(double x, double y); bool GoDown(double x, double y);
void startIteratorForGroup(int group); bool startIteratorForGroup(int group);
public: public: