- iterator loops in sectorfx.cpp.

This commit is contained in:
Christoph Oelckers 2021-11-19 20:08:50 +01:00
parent b3bf1bc037
commit c54137766c

View file

@ -138,14 +138,12 @@ void DoSectorLighting(void)
} }
if (pXSector->shadeWalls) if (pXSector->shadeWalls)
{ {
int nStartWall = pSector->wallptr; for(auto& wal : wallsofsector(pSector))
int nEndWall = nStartWall + pSector->wallnum;
for (int j = nStartWall; j < nEndWall; j++)
{ {
wall[j].shade -= v4; wal.shade -= v4;
if (pXSector->color) if (pXSector->color)
{ {
wall[j].pal = pSector->floorpal; wal.pal = pSector->floorpal;
} }
} }
} }
@ -182,14 +180,12 @@ void DoSectorLighting(void)
} }
if (pXSector->shadeWalls) if (pXSector->shadeWalls)
{ {
int nStartWall = pSector->wallptr; for (auto& wal : wallsofsector(pSector))
int nEndWall = nStartWall + pSector->wallnum;
for (int j = nStartWall; j < nEndWall; j++)
{ {
wall[j].shade = ClipRange(wall[j].shade+v4, -128, 127); wal.shade = ClipRange(wal.shade+v4, -128, 127);
if (pXSector->color && v4 != 0) if (pXSector->color && v4 != 0)
{ {
wall[j].pal = pSector->floorpal; wal.pal = pSector->floorpal;
} }
} }
} }
@ -200,45 +196,42 @@ void DoSectorLighting(void)
void UndoSectorLighting(void) void UndoSectorLighting(void)
{ {
for (int i = 0; i < numsectors; i++) for (auto& sect : sectors())
{ {
int nXSprite = sector[i].extra; if (sect.hasX())
if (nXSprite > 0)
{ {
XSECTOR *pXSector = &xsector[i]; XSECTOR *pXSector = &sect.xs();
if (pXSector->shade) if (pXSector->shade)
{ {
int v4 = pXSector->shade; int v4 = pXSector->shade;
if (pXSector->shadeFloor) if (pXSector->shadeFloor)
{ {
sector[i].floorshade -= v4; sect.floorshade -= v4;
if (pXSector->color) if (pXSector->color)
{ {
int nTemp = pXSector->floorpal; int nTemp = pXSector->floorpal;
pXSector->floorpal = sector[i].floorpal; pXSector->floorpal = sect.floorpal;
sector[i].floorpal = nTemp; sect.floorpal = nTemp;
} }
} }
if (pXSector->shadeCeiling) if (pXSector->shadeCeiling)
{ {
sector[i].ceilingshade -= v4; sect.ceilingshade -= v4;
if (pXSector->color) if (pXSector->color)
{ {
int nTemp = pXSector->ceilpal; int nTemp = pXSector->ceilpal;
pXSector->ceilpal = sector[i].ceilingpal; pXSector->ceilpal = sect.ceilingpal;
sector[i].ceilingpal = nTemp; sect.ceilingpal = nTemp;
} }
} }
if (pXSector->shadeWalls) if (pXSector->shadeWalls)
{ {
int nStartWall = sector[i].wallptr; for(auto& wal : wallsofsector(&sect))
int nEndWall = nStartWall + sector[i].wallnum;
for (int j = nStartWall; j < nEndWall; j++)
{ {
wall[j].shade -= v4; wal.shade -= v4;
if (pXSector->color) if (pXSector->color)
{ {
wall[j].pal = sector[i].floorpal; wal.pal = sect.floorpal;
} }
} }
} }