From 2d1f5fc576d7faec6f3884bf501202ee41a5b9ee Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Nov 2021 09:42:43 +0100 Subject: [PATCH] - Exhumed: some cleanup. --- source/games/duke/src/premap_r.cpp | 1 - source/games/exhumed/src/init.cpp | 33 ++++++++++++++-------------- source/games/exhumed/src/object.cpp | 30 +++++++++++-------------- source/games/exhumed/src/runlist.cpp | 7 +++--- 4 files changed, 33 insertions(+), 38 deletions(-) diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 2d27a11ce..390791c00 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -494,7 +494,6 @@ void prelevel_r(int g) } case 42: { - int ii; sectortype* childsectnum = nullptr; dist = 0; speed = 0; diff --git a/source/games/exhumed/src/init.cpp b/source/games/exhumed/src/init.cpp index 98e4200cf..573b0f330 100644 --- a/source/games/exhumed/src/init.cpp +++ b/source/games/exhumed/src/init.cpp @@ -780,38 +780,37 @@ void LoadObjects() InitWallFace(); InitSectFlag(); - for (int nSector = 0; nSector < numsectors; nSector++) + for (auto& sect : sectors()) { - auto sectp = §or[nSector]; - int hitag = sectp->hitag; - int lotag = sectp->lotag; + int hitag = sect.hitag; + int lotag = sect.lotag; - sectp->hitag = 0; - sectp->lotag = 0; - sectp->extra = -1; + sect.hitag = 0; + sect.lotag = 0; + sect.extra = -1; if (hitag || lotag) { - sectp->lotag = runlist_HeadRun() + 1; - sectp->hitag = lotag; + sect.lotag = runlist_HeadRun() + 1; + sect.hitag = lotag; - runlist_ProcessSectorTag(nSector, lotag, hitag); + runlist_ProcessSectorTag(sectnum(§), lotag, hitag); } } - for (int nWall = 0; nWall < numwalls; nWall++) + for (auto& wal : walls()) { - wall[nWall].extra = -1; + wal.extra = -1; - int lotag = wall[nWall].lotag; - int hitag = wall[nWall].hitag; + int lotag = wal.lotag; + int hitag = wal.hitag; - wall[nWall].lotag = 0; + wal.lotag = 0; if (hitag || lotag) { - wall[nWall].lotag = runlist_HeadRun() + 1; - runlist_ProcessWallTag(nWall, lotag, hitag); + wal.lotag = runlist_HeadRun() + 1; + runlist_ProcessWallTag(wallnum(&wal), lotag, hitag); } } diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index add19fcc4..291f44d26 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -1583,42 +1583,38 @@ void DoFinale() DExhumedActor* BuildEnergyBlock(int nSector) { - int startwall = sector[nSector].wallptr; - int nWalls = sector[nSector].wallnum; - int x = 0; int y = 0; + + auto pSector = §or[nSector]; - for (int i = 0; i < nWalls; i++) + for(auto& wal : wallsofsector(pSector)) { - x += wall[startwall + i].x; - y += wall[startwall + i].y; + x += wal.x; + y += wal.y; - wall[startwall + i].picnum = kClockSymbol16; - wall[startwall + i].pal = 0; - wall[startwall + i].shade = 50; + wal.picnum = kClockSymbol16; + wal.pal = 0; + wal.shade = 50; } - int xAvg = x / nWalls; - int yAvg = y / nWalls; + int xAvg = x / pSector->wallnum; + int yAvg = y / pSector->wallnum; auto pActor = insertActor(nSector, 406); auto spr = &pActor->s(); - - int nextsector = wall[startwall].nextsector; - - spr->x = xAvg; + spr->x = xAvg; spr->y = yAvg; sector[nSector].extra = (int16_t)EnergyBlocks.Push(pActor); // GrabTimeSlot(3); - spr->z = sector[nextsector].floorz; + spr->z = pSector->firstWall()->nextSector()->floorz; // CHECKME - name of this variable? - int nRepeat = (spr->z - sector[nSector].floorz) >> 8; + int nRepeat = (spr->z - pSector->floorz) >> 8; if (nRepeat > 255) { nRepeat = 255; } diff --git a/source/games/exhumed/src/runlist.cpp b/source/games/exhumed/src/runlist.cpp index 6498a6fc5..526cee25a 100644 --- a/source/games/exhumed/src/runlist.cpp +++ b/source/games/exhumed/src/runlist.cpp @@ -1517,6 +1517,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag) void runlist_ProcessWallTag(int nWall, int nLotag, int nHitag) { + auto& wal = wall[nWall]; int nChannel = runlist_AllocChannel(nHitag % 1000); assert(nChannel >= 0 && nChannel < kMaxChannels); @@ -1536,7 +1537,7 @@ void runlist_ProcessWallTag(int nWall, int nLotag, int nHitag) case 1: { - int nWallFace = BuildWallFace(nChannel, nWall, 2, wall[nWall].picnum, wall[nWall].picnum + 1); + int nWallFace = BuildWallFace(nChannel, nWall, 2, wal.picnum, wal.picnum + 1); runlist_AddRunRec(sRunChannels[nChannel].a, nWallFace, 0x70000); auto nSwitch = BuildSwPressWall(nChannel, BuildLink(2, nEffectTag, 0), nWall); @@ -1554,7 +1555,7 @@ void runlist_ProcessWallTag(int nWall, int nLotag, int nHitag) case 7: // Regular switch { - int nWallFace = BuildWallFace(nChannel, nWall, 2, wall[nWall].picnum, wall[nWall].picnum + 1); + int nWallFace = BuildWallFace(nChannel, nWall, 2, wal.picnum, wal.picnum + 1); runlist_AddRunRec(sRunChannels[nChannel].a, nWallFace, 0x70000); auto nSwitch = BuildSwPressWall(nChannel, BuildLink(1, 1), nWall); @@ -1564,7 +1565,7 @@ void runlist_ProcessWallTag(int nWall, int nLotag, int nHitag) case 8: // Reverse switch { - int nWallFace = BuildWallFace(nChannel, nWall, 2, wall[nWall].picnum, wall[nWall].picnum + 1); + int nWallFace = BuildWallFace(nChannel, nWall, 2, wal.picnum, wal.picnum + 1); runlist_AddRunRec(sRunChannels[nChannel].a, nWallFace, 0x70000); auto nSwitch = BuildSwPressWall(nChannel, BuildLink(2, -1, 0), nWall);