- some logic fixes in FMultiBlockLinesIterator.

This commit is contained in:
Christoph Oelckers 2016-02-19 16:13:36 +01:00
parent 02d7572343
commit 28799c4b51
2 changed files with 55 additions and 24 deletions

View file

@ -705,6 +705,38 @@ FMultiBlockLinesIterator::FMultiBlockLinesIterator(FPortalGroupArray &check, AAc
Reset(); Reset();
} }
bool FMultiBlockLinesIterator::GoUp(fixed_t x, fixed_t y)
{
if (continueup)
{
sector_t *sector = P_PointInSector(x, y);
if (!sector->PortalBlocksMovement(sector_t::ceiling))
{
startIteratorForGroup(sector->SkyBoxes[sector_t::ceiling]->Sector->PortalGroup);
portalflags = FFCF_NOFLOOR;
return true;
}
else continueup = false;
}
return false;
}
bool FMultiBlockLinesIterator::GoDown(fixed_t x, fixed_t y)
{
if (continuedown)
{
sector_t *sector = P_PointInSector(x, y);
if (!sector->PortalBlocksMovement(sector_t::floor))
{
startIteratorForGroup(sector->SkyBoxes[sector_t::floor]->Sector->PortalGroup);
portalflags = FFCF_NOCEILING;
return true;
}
else continuedown = false;
}
return false;
}
bool FMultiBlockLinesIterator::Next(FMultiBlockLinesIterator::CheckResult *item) bool FMultiBlockLinesIterator::Next(FMultiBlockLinesIterator::CheckResult *item)
{ {
line_t *line = blockIterator.Next(); line_t *line = blockIterator.Next();
@ -715,36 +747,33 @@ bool FMultiBlockLinesIterator::Next(FMultiBlockLinesIterator::CheckResult *item)
item->portalflags = portalflags; item->portalflags = portalflags;
return true; return true;
} }
else if (checklist[index] & FPortalGroupArray::UPPER) bool onlast = unsigned(index + 1) >= checklist.Size();
int nextflags = onlast ? 0 : checklist[index + 1] & FPortalGroupArray::FLAT;
if (portalflags == FFCF_NOFLOOR && nextflags != FPortalGroupArray::UPPER)
{ {
if (continueup) // if this is the last upper portal in the list, check if we need to go further up to find the real ceiling.
if (GoUp(offset.x, offset.y)) return Next(item);
}
else if (portalflags == FFCF_NOCEILING && nextflags != FPortalGroupArray::LOWER)
{ {
sector_t *sector = P_PointInSector(offset.x, offset.y); // if this is the last lower portal in the list, check if we need to go further down to find the real floor.
if (!sector->PortalBlocksMovement(sector_t::ceiling)) if (GoDown(offset.x, offset.y)) return Next(item);
}
if (onlast)
{
// We reached the end of the list. Check if we still need to check up- and downwards.
if (GoUp(checkpoint.x, checkpoint.y) ||
GoDown(checkpoint.x, checkpoint.y))
{ {
startIteratorForGroup(sector->SkyBoxes[sector_t::ceiling]->Sector->PortalGroup);
portalflags = FFCF_NOFLOOR;
return Next(item); return Next(item);
} }
return false;
} }
}
else if (checklist[index] & FPortalGroupArray::LOWER)
{
if (continuedown)
{
sector_t *sector = P_PointInSector(offset.x, offset.y);
if (!sector->PortalBlocksMovement(sector_t::floor))
{
startIteratorForGroup(sector->SkyBoxes[sector_t::floor]->Sector->PortalGroup);
portalflags = FFCF_NOCEILING;
return Next(item);
}
}
}
index++; index++;
if (index >= checklist.Size()) return false;
startIteratorForGroup(checklist[index] & ~FPortalGroupArray::FLAT); startIteratorForGroup(checklist[index] & ~FPortalGroupArray::FLAT);
switch (checklist[index] & FPortalGroupArray::FLAT) switch (nextflags)
{ {
case FPortalGroupArray::UPPER: case FPortalGroupArray::UPPER:
portalflags = FFCF_NOFLOOR; portalflags = FFCF_NOFLOOR;

View file

@ -211,6 +211,8 @@ class FMultiBlockLinesIterator
FBlockLinesIterator blockIterator; FBlockLinesIterator blockIterator;
FBoundingBox bbox; FBoundingBox bbox;
bool GoUp(fixed_t x, fixed_t y);
bool GoDown(fixed_t x, fixed_t y);
void startIteratorForGroup(int group); void startIteratorForGroup(int group);
public: public: