Moved my added slope checks in hw_trick.c to isCeilingFloating/isFloorFloating

I also optimised those two functions while I was there (why keep a "floating" variable when setting it to false guarantees the functions return false?)
This commit is contained in:
Monster Iestyn 2017-06-26 10:51:19 +01:00
parent 787d5b598d
commit 2107aab666
1 changed files with 28 additions and 58 deletions

View File

@ -507,14 +507,6 @@ static boolean areToptexturesMissing(sector_t *thisSector)
if (!frontSector || !backSector)
continue;
#ifdef ESLOPE
if (frontSector->c_slope || backSector->c_slope) // the slope's height can be completely different from original ceiling height
{
nomiss++;
break;
}
#endif
sider = &sides[thisElem->line->sidenum[0]];
sidel = &sides[thisElem->line->sidenum[1]];
@ -563,14 +555,6 @@ static boolean areBottomtexturesMissing(sector_t *thisSector)
if (frontSector == NULL || backSector == NULL)
continue;
#ifdef ESLOPE
if (frontSector->f_slope || backSector->f_slope) // the slope's height can be completely different from original floor height
{
nomiss++;
break;
}
#endif
sider = &sides[thisElem->line->sidenum[0]];
sidel = &sides[thisElem->line->sidenum[1]];
@ -603,67 +587,6 @@ static boolean areBottomtexturesMissing(sector_t *thisSector)
static boolean isCeilingFloating(sector_t *thisSector)
{
sector_t *adjSector, *refSector = NULL, *frontSector, *backSector;
boolean floating = true;
linechain_t *thisElem, *nextElem;
if (!thisSector)
return false;
nextElem = thisSector->sectorLines;
while (NULL != nextElem) // walk through chain
{
thisElem = nextElem;
nextElem = thisElem->next;
frontSector = thisElem->line->frontsector;
backSector = thisElem->line->backsector;
if (frontSector == thisSector)
adjSector = backSector;
else
adjSector = frontSector;
if (!adjSector) // assume floating sectors have surrounding sectors
{
floating = false;
break;
}
if (!refSector)
{
refSector = adjSector;
continue;
}
// if adjacent sector has same height or more than one adjacent sector exists -> stop
if (thisSector->ceilingheight == adjSector->ceilingheight ||
refSector != adjSector)
{
floating = false;
break;
}
}
// now check for walltextures
if (floating)
{
if (!areToptexturesMissing(thisSector))
{
floating = false;
}
}
return floating;
}
//
// check if no adjacent sector has same ceiling height
// FIXME: throw that together with isCeilingFloating??
//
static boolean isFloorFloating(sector_t *thisSector)
{
sector_t *adjSector, *refSector = NULL, *frontSector, *backSector;
boolean floating = true;
linechain_t *thisElem, *nextElem;
if (!thisSector)
@ -684,36 +607,83 @@ static boolean isFloorFloating(sector_t *thisSector)
else
adjSector = frontSector;
if (NULL == adjSector) // assume floating sectors have surrounding sectors
{
floating = false;
break;
}
if (!adjSector) // assume floating sectors have surrounding sectors
return false;
if (NULL == refSector)
#ifdef ESLOPE
if (adjSector->c_slope) // Don't bother with slopes
return false;
#endif
if (!refSector)
{
refSector = adjSector;
continue;
}
// if adjacent sector has same height or more than one adjacent sector exists -> stop
if (thisSector->floorheight == adjSector->floorheight ||
refSector != adjSector)
{
floating = false;
break;
}
if (thisSector->ceilingheight == adjSector->ceilingheight || refSector != adjSector)
return false;
}
// now check for walltextures
if (floating)
if (!areToptexturesMissing(thisSector))
return false;
return true;
}
//
// check if no adjacent sector has same ceiling height
// FIXME: throw that together with isCeilingFloating??
//
static boolean isFloorFloating(sector_t *thisSector)
{
sector_t *adjSector, *refSector = NULL, *frontSector, *backSector;
linechain_t *thisElem, *nextElem;
if (!thisSector)
return false;
nextElem = thisSector->sectorLines;
while (nextElem) // walk through chain
{
thisElem = nextElem;
nextElem = thisElem->next;
frontSector = thisElem->line->frontsector;
backSector = thisElem->line->backsector;
if (frontSector == thisSector)
adjSector = backSector;
else
adjSector = frontSector;
if (!adjSector) // assume floating sectors have surrounding sectors
return false;
#ifdef ESLOPE
if (adjSector->f_slope) // Don't bother with slopes
return false;
#endif
if (!refSector)
{
refSector = adjSector;
continue;
}
// if adjacent sector has same height or more than one adjacent sector exists -> stop
if (thisSector->floorheight == adjSector->floorheight || refSector != adjSector)
return false;
}
// now check for walltextures
if (!areBottomtexturesMissing(thisSector))
{
floating = false;
}
}
return floating;
return false;
return true;
}
//