diff --git a/source/games/exhumed/src/lighting.cpp b/source/games/exhumed/src/lighting.cpp index 27cb5c6a6..e1b24ef96 100644 --- a/source/games/exhumed/src/lighting.cpp +++ b/source/games/exhumed/src/lighting.cpp @@ -594,14 +594,9 @@ void DoGlows() sectp->ceilingshade += nShade; sectp->floorshade += nShade; - int startwall = sectp->wallptr; - int endwall = startwall + sectp->wallnum - 1; - - for (int nWall = startwall; nWall <= endwall; nWall++) + for(auto& wal : wallsofsector(sectp)) { - wall[nWall].shade += nShade; - - // CHECKME - ASM has edx decreasing here. why? + wal.shade += nShade; } } } @@ -643,14 +638,9 @@ void DoFlickers() sectp->ceilingshade += shade; sectp->floorshade += shade; - int startwall = sectp->wallptr; - int endwall = startwall + sectp->wallnum - 1; - - for (int nWall = endwall; nWall >= startwall; nWall--) + for(auto& wal : wallsofsector(sectp)) { - wall[nWall].shade += shade; - - // CHECKME - ASM has edx decreasing here. why? + wal.shade += shade; } } } diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index ffc04434f..18f1f1f9b 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -810,22 +810,18 @@ void CreatePushBlock(int nSector) { auto sectp = §or[nSector]; int nBlock = GrabPushBlock(); - int i; - - int startwall = sectp->wallptr; - int nWalls = sectp->wallnum; int xSum = 0; int ySum = 0; - for (i = 0; i < nWalls; i++) + for (auto& wal : wallsofsector(sectp)) { - xSum += wall[startwall + i].x; - ySum += wall[startwall + i].y; + xSum += wal.x; + ySum += wal.y; } - int xAvg = xSum / nWalls; - int yAvg = ySum / nWalls; + int xAvg = xSum / sectp->wallnum; + int yAvg = ySum / sectp->wallnum; sBlockInfo[nBlock].x = xAvg; sBlockInfo[nBlock].y = yAvg; @@ -842,10 +838,10 @@ void CreatePushBlock(int nSector) int var_28 = 0; - for (i = 0; i < nWalls; i++) + for (auto& wal : wallsofsector(sectp)) { - uint32_t xDiff = abs(xAvg - wall[startwall + i].x); - uint32_t yDiff = abs(yAvg - wall[startwall + i].y); + uint32_t xDiff = abs(xAvg - wal.x); + uint32_t yDiff = abs(yAvg - wal.y); uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; @@ -893,11 +889,9 @@ void MoveSector(int nSector, int nAngle, int *nXVel, int *nYVel) int nSectFlag = sector[nSector].Flag; int nFloorZ = pSector->floorz; - int startwall = pSector->wallptr; - int nWalls = pSector->wallnum; - walltype *pStartWall = &wall[startwall]; - int nNextSector = wall[startwall].nextsector; + walltype *pStartWall = pSector->firstWall(); + sectortype* pNextSector = pStartWall->nextSector(); BlockInfo *pBlockInfo = &sBlockInfo[nBlock]; @@ -909,7 +903,7 @@ void MoveSector(int nSector, int nAngle, int *nXVel, int *nYVel) pos.y = sBlockInfo[nBlock].y; int y_b = sBlockInfo[nBlock].y; - int nSectorB = nSector; + auto nSectorB = nSector; int nZVal; @@ -918,16 +912,16 @@ void MoveSector(int nSector, int nAngle, int *nXVel, int *nYVel) if (nSectFlag & kSectUnderwater) { nZVal = pSector->ceilingz; - pos.z = sector[nNextSector].ceilingz + 256; + pos.z = pNextSector->ceilingz + 256; - pSector->ceilingz = sector[nNextSector].ceilingz; + pSector->ceilingz = pNextSector->ceilingz; } else { nZVal = pSector->floorz; - pos.z = sector[nNextSector].floorz - 256; + pos.z = pNextSector->floorz - 256; - pSector->floorz = sector[nNextSector].floorz; + pSector->floorz = pNextSector->floorz; } clipmove(&pos, &nSectorB, nXVect, nYVect, pBlockInfo->field_8, 0, 0, CLIPMASK1); @@ -935,7 +929,7 @@ void MoveSector(int nSector, int nAngle, int *nXVel, int *nYVel) int yvect = pos.y - y_b; int xvect = pos.x - x_b; - if (nSectorB != nNextSector && nSectorB != nSector) + if (§or[nSectorB] != pNextSector && nSectorB != nSector) { yvect = 0; xvect = 0; @@ -1020,8 +1014,8 @@ void MoveSector(int nSector, int nAngle, int *nXVel, int *nYVel) } } } - - it.Reset(nNextSector); + int nNextSector = sectnum(pNextSector); + it.Reset(pNextSector); while (auto pActor = it.Next()) { auto pSprite = &pActor->s(); @@ -1055,11 +1049,9 @@ void MoveSector(int nSector, int nAngle, int *nXVel, int *nYVel) } } - for (int i = 0; i < nWalls; i++) + for(auto& wal : wallsofsector(pSector)) { - dragpoint(startwall, xvect + pStartWall->x, yvect + pStartWall->y); - pStartWall++; - startwall++; + dragpoint(&wal, xvect + wal.x, yvect + wal.y); } pBlockInfo->x += xvect; diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index dfc60379f..add19fcc4 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -934,32 +934,11 @@ void InitSlide() SlideData.Clear(); } -int IdentifySector(int nVal) -{ - for (int i = 0; i < numsectors; i++) - { - for (int j = 0; ; j++) - { - if (j < sector[i].wallnum) - { - int nWall = sector[i].wallptr; - if (nWall + j == nVal) - return i; - } - else { - break; - } - } - } - - return -1; -} - int BuildSlide(int nChannel, int nStartWall, int nWall1, int ecx, int nWall2, int nWall3, int nWall4) { auto nSlide = SlideData.Reserve(1); - int nSector =IdentifySector(nStartWall); + int nSector = wall[nStartWall].sector; SlideData[nSlide].nRunRec = -1; SlideData[nSlide].nChannel = nChannel; diff --git a/source/games/exhumed/src/ramses.cpp b/source/games/exhumed/src/ramses.cpp index 22a56afe9..7a8a290be 100644 --- a/source/games/exhumed/src/ramses.cpp +++ b/source/games/exhumed/src/ramses.cpp @@ -161,13 +161,10 @@ void InitSpiritHead() void DimSector(int nSector) { - int startwall = sector[nSector].wallptr; - int nWalls = sector[nSector].wallnum; - - for (int i = 0; i < nWalls; i++) + for(auto& wal : wallsofsector(nSector)) { - if (wall[startwall+i].shade < 40) { - wall[startwall+i].shade++; + if (wal.shade < 40) { + wal.shade++; } }