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) if (!frontSector || !backSector)
continue; 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]]; sider = &sides[thisElem->line->sidenum[0]];
sidel = &sides[thisElem->line->sidenum[1]]; sidel = &sides[thisElem->line->sidenum[1]];
@ -563,14 +555,6 @@ static boolean areBottomtexturesMissing(sector_t *thisSector)
if (frontSector == NULL || backSector == NULL) if (frontSector == NULL || backSector == NULL)
continue; 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]]; sider = &sides[thisElem->line->sidenum[0]];
sidel = &sides[thisElem->line->sidenum[1]]; sidel = &sides[thisElem->line->sidenum[1]];
@ -603,15 +587,14 @@ static boolean areBottomtexturesMissing(sector_t *thisSector)
static boolean isCeilingFloating(sector_t *thisSector) static boolean isCeilingFloating(sector_t *thisSector)
{ {
sector_t *adjSector, *refSector = NULL, *frontSector, *backSector; sector_t *adjSector, *refSector = NULL, *frontSector, *backSector;
boolean floating = true;
linechain_t *thisElem, *nextElem; linechain_t *thisElem, *nextElem;
if (!thisSector) if (!thisSector)
return false; return false;
nextElem = thisSector->sectorLines; nextElem = thisSector->sectorLines;
while (NULL != nextElem) // walk through chain while (nextElem) // walk through chain
{ {
thisElem = nextElem; thisElem = nextElem;
nextElem = thisElem->next; nextElem = thisElem->next;
@ -625,10 +608,12 @@ static boolean isCeilingFloating(sector_t *thisSector)
adjSector = frontSector; adjSector = frontSector;
if (!adjSector) // assume floating sectors have surrounding sectors if (!adjSector) // assume floating sectors have surrounding sectors
{ return false;
floating = false;
break; #ifdef ESLOPE
} if (adjSector->c_slope) // Don't bother with slopes
return false;
#endif
if (!refSector) if (!refSector)
{ {
@ -637,23 +622,15 @@ static boolean isCeilingFloating(sector_t *thisSector)
} }
// if adjacent sector has same height or more than one adjacent sector exists -> stop // if adjacent sector has same height or more than one adjacent sector exists -> stop
if (thisSector->ceilingheight == adjSector->ceilingheight || if (thisSector->ceilingheight == adjSector->ceilingheight || refSector != adjSector)
refSector != adjSector) return false;
{
floating = false;
break;
}
} }
// now check for walltextures // now check for walltextures
if (floating) if (!areToptexturesMissing(thisSector))
{ return false;
if (!areToptexturesMissing(thisSector))
{ return true;
floating = false;
}
}
return floating;
} }
// //
@ -663,7 +640,6 @@ static boolean isCeilingFloating(sector_t *thisSector)
static boolean isFloorFloating(sector_t *thisSector) static boolean isFloorFloating(sector_t *thisSector)
{ {
sector_t *adjSector, *refSector = NULL, *frontSector, *backSector; sector_t *adjSector, *refSector = NULL, *frontSector, *backSector;
boolean floating = true;
linechain_t *thisElem, *nextElem; linechain_t *thisElem, *nextElem;
if (!thisSector) if (!thisSector)
@ -684,36 +660,30 @@ static boolean isFloorFloating(sector_t *thisSector)
else else
adjSector = frontSector; adjSector = frontSector;
if (NULL == adjSector) // assume floating sectors have surrounding sectors if (!adjSector) // assume floating sectors have surrounding sectors
{ return false;
floating = false;
break;
}
if (NULL == refSector) #ifdef ESLOPE
if (adjSector->f_slope) // Don't bother with slopes
return false;
#endif
if (!refSector)
{ {
refSector = adjSector; refSector = adjSector;
continue; continue;
} }
// if adjacent sector has same height or more than one adjacent sector exists -> stop // if adjacent sector has same height or more than one adjacent sector exists -> stop
if (thisSector->floorheight == adjSector->floorheight || if (thisSector->floorheight == adjSector->floorheight || refSector != adjSector)
refSector != adjSector) return false;
{
floating = false;
break;
}
} }
// now check for walltextures // now check for walltextures
if (floating) if (!areBottomtexturesMissing(thisSector))
{ return false;
if (!areBottomtexturesMissing(thisSector))
{ return true;
floating = false;
}
}
return floating;
} }
// //