From 7a504e27d29582048141c49d6539c95f9af27e93 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 17 Nov 2021 22:48:05 +0100 Subject: [PATCH] - premap_d --- source/games/duke/src/premap_d.cpp | 67 ++++++++++++++---------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index d95428d09..5e6847a4b 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -272,7 +272,7 @@ void cacheit_d(void) void prelevel_d(int g) { - int i, j, startwall, endwall, lotaglist; + int i, j, lotaglist; short lotags[65]; prelevel_common(g); @@ -376,24 +376,21 @@ void prelevel_d(int g) mirrorcnt = 0; - for (i = 0; i < numwalls; i++) + for (auto& wal : walls()) { - walltype* wal; - wal = &wall[i]; - - if (wal->overpicnum == MIRROR && (wal->cstat & 32) != 0) + if (wal.overpicnum == MIRROR && (wal.cstat & 32) != 0) { - j = wal->nextsector; - auto sectp = §or[j]; + auto sectp = wal.nextSector(); if (mirrorcnt > 63) I_Error("Too many mirrors (64 max.)"); - if ((j >= 0) && sectp->ceilingpicnum != MIRROR) + if (sectp->ceilingpicnum != MIRROR) { + assert(wallnum(&wal) > 0); sectp->ceilingpicnum = MIRROR; sectp->floorpicnum = MIRROR; - mirrorwall[mirrorcnt] = i; - mirrorsector[mirrorcnt] = j; + mirrorwall[mirrorcnt] = wallnum(&wal); + mirrorsector[mirrorcnt] = sectnum(sectp); mirrorcnt++; continue; } @@ -405,55 +402,55 @@ void prelevel_d(int g) animwall[numanimwalls].tag = 0; animwall[numanimwalls].wallnum = 0; - switch (wal->overpicnum) + switch (wal.overpicnum) { case FANSHADOW: case FANSPRITE: - wal->cstat |= 65; - animwall[numanimwalls].wallnum = i; + wal.cstat |= 65; + animwall[numanimwalls].wallnum = wallnum(&wal); numanimwalls++; break; case W_FORCEFIELD: - for (j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) tloadtile(W_FORCEFIELD + j); [[fallthrough]]; case W_FORCEFIELD + 1: case W_FORCEFIELD + 2: - if (wal->shade > 31) - wal->cstat = 0; - else wal->cstat |= 85 + 256; + if (wal.shade > 31) + wal.cstat = 0; + else wal.cstat |= 85 + 256; - if (wal->lotag && wal->nextwall >= 0) - wal->nextWall()->lotag = wal->lotag; + if (wal.lotag && wal.nextwall >= 0) + wal.nextWall()->lotag = wal.lotag; [[fallthrough]]; case BIGFORCE: - animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].wallnum = wallnum(&wal); numanimwalls++; continue; } - wal->extra = -1; + wal.extra = -1; - switch (wal->picnum) + switch (wal.picnum) { case W_TECHWALL1: case W_TECHWALL2: case W_TECHWALL3: case W_TECHWALL4: - animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].wallnum = wallnum(&wal); // animwall[numanimwalls].tag = -1; numanimwalls++; break; case SCREENBREAK6: case SCREENBREAK7: case SCREENBREAK8: - for (j = SCREENBREAK6; j < SCREENBREAK9; j++) + for (int j = SCREENBREAK6; j < SCREENBREAK9; j++) tloadtile(j); - animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].wallnum = wallnum(&wal); animwall[numanimwalls].tag = -1; numanimwalls++; break; @@ -462,11 +459,11 @@ void prelevel_d(int g) case FEMPIC2: case FEMPIC3: - wal->extra = wal->picnum; + wal.extra = wal.picnum; animwall[numanimwalls].tag = -1; - animwall[numanimwalls].wallnum = i; - animwall[numanimwalls].tag = wal->picnum; + animwall[numanimwalls].wallnum = wallnum(&wal); + animwall[numanimwalls].tag = wal.picnum; numanimwalls++; break; @@ -488,8 +485,8 @@ void prelevel_d(int g) case SCREENBREAK18: case SCREENBREAK19: - animwall[numanimwalls].wallnum = i; - animwall[numanimwalls].tag = wal->picnum; + animwall[numanimwalls].wallnum = wallnum(&wal); + animwall[numanimwalls].tag = wal.picnum; numanimwalls++; break; } @@ -498,12 +495,10 @@ void prelevel_d(int g) //Invalidate textures in sector behind mirror for (i = 0; i < mirrorcnt; i++) { - startwall = sector[mirrorsector[i]].wallptr; - endwall = startwall + sector[mirrorsector[i]].wallnum; - for (j = startwall; j < endwall; j++) + for (auto& wal : wallsofsector(mirrorsector[i])) { - wall[j].picnum = MIRROR; - wall[j].overpicnum = MIRROR; + wal.picnum = MIRROR; + wal.overpicnum = MIRROR; } } }