From 27af8a52e9eac64ab5e01eb73708f6ca3b02bff8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 18 Nov 2021 00:42:52 +0100 Subject: [PATCH] - the final walls What is left now of wall[] and wallnum() needs to remain. --- source/games/duke/src/funct.h | 2 +- source/games/duke/src/player_r.cpp | 2 +- source/games/duke/src/sectors_d.cpp | 10 ++++------ source/games/duke/src/sectors_r.cpp | 23 ++++++++++------------- source/games/duke/src/spawn.cpp | 20 +++++++++----------- 5 files changed, 25 insertions(+), 32 deletions(-) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index de2e74638..ec872dafa 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -154,7 +154,7 @@ int getanimationgoal(int animtype, int animindex); bool isanearoperator(int lotag); bool isanunderoperator(int lotag); int setanimation(int animsect, int animtype, int animindex, int thegoal, int thevel); -void dofurniture(int wallNum, int sectnum, int playerNum); +void dofurniture(walltype* wallNum, sectortype* sectnum, int playerNum); void dotorch(); int hitawall(struct player_struct* pl, walltype** hitWall); int hits(DDukeActor* snum); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index d5070ce37..e68804e9a 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3807,7 +3807,7 @@ HORIZONLY: { if (wal->lotag < 44) { - dofurniture(clip.index, p->cursectnum, snum); + dofurniture(clip.wall(), p->cursector(), snum); pushmove(&p->pos, &p->cursectnum, 172L, (4L << 8), (4L << 8), CLIPMASK0); } else diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 15517850a..c488a3fdb 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -855,14 +855,12 @@ void checkhitwall_d(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw if (!wal->lotag) return; - sn = wal->nextsector; - if (sn < 0) return; + if (wal->nextsector < 0) return; darkestwall = 0; - wal = &wall[sector[sn].wallptr]; - for (int i = sector[sn].wallnum; i > 0; i--, wal++) - if (wal->shade > darkestwall) - darkestwall = wal->shade; + for (auto& wl : wallsofsector(wal->nextSector())) + if (wl.shade > darkestwall) + darkestwall = wl.shade; j = krand() & 1; DukeStatIterator it(STAT_EFFECTOR); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 29a48bdf5..6848469d0 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -1079,7 +1079,6 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw case RRTILE3643 + 3: { int sect; - int startwall, endwall; sect = wal->nextWall()->nextsector; DukeSectIterator it(sect); while (auto act = it.Next()) @@ -1087,14 +1086,13 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw s = act->s; if (s->lotag == 6) { - //for (j = 0; j < 16; j++) RANDOMSCRAP(s, -1); This never spawned anything due to the -1. act->spriteextra++; if (act->spriteextra == 25) { - startwall = s->sector()->wallptr; - endwall = startwall + s->sector()->wallnum; - for (i = startwall; i < endwall; i++) - sector[wall[i].nextsector].lotag = 0; + for(auto& wl : wallsofsector(s->sectnum)) + { + if (wl.nextsector >= 0) wl.nextSector()->lotag = 0; + } s->sector()->lotag = 0; S_StopSound(act->s->lotag); S_PlayActorSound(400, act); @@ -2792,9 +2790,8 @@ void checksectors_r(int snum) // //--------------------------------------------------------------------------- -void dofurniture(int wl, int sect, int snum) +void dofurniture(walltype* wlwal, sectortype* sectp, int snum) { - auto wlwal = &wall[wl]; int nextsect = wlwal->nextsector; int var_C; int x; @@ -2809,7 +2806,7 @@ void dofurniture(int wl, int sect, int snum) var_C = 1; max_x = max_y = -0x20000; min_x = min_y = 0x20000; - var_cx = sector[sect].hitag; + var_cx = sectp->hitag; if (var_cx > 16) var_cx = 16; else if (var_cx == 0) @@ -2831,16 +2828,16 @@ void dofurniture(int wl, int sect, int snum) max_y += var_cx + 1; min_x -= var_cx + 1; min_y -= var_cx + 1; - ins = inside(max_x, max_y, sect); + ins = inside(max_x, max_y, sectnum(sectp)); if (!ins) var_C = 0; - ins = inside(max_x, min_y, sect); + ins = inside(max_x, min_y, sectnum(sectp)); if (!ins) var_C = 0; - ins = inside(min_x, min_y, sect); + ins = inside(min_x, min_y, sectnum(sectp)); if (!ins) var_C = 0; - ins = inside(min_x, max_y, sect); + ins = inside(min_x, max_y, sectnum(sectp)); if (!ins) var_C = 0; if (var_C) diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 8d58082a1..a8d8ff964 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -742,20 +742,18 @@ void spawneffector(DDukeActor* actor) if (sp->ang == 512) { - startwall = sectp->wallptr; - endwall = startwall + sectp->wallnum; - for (int j = startwall; j < endwall; j++) + for (auto& wl : wallsofsector(sectp)) { - int x = wall[j].nextsector; - if (x >= 0) - if (!(sector[x].ceilingstat & 1)) + if (wl.nextsector >= 0) + { + auto nsec = wl.nextSector(); + if (!(nsec->ceilingstat & 1)) { - sectp->ceilingpicnum = - sector[x].ceilingpicnum; - sectp->ceilingshade = - sector[x].ceilingshade; - break; //Leave earily + sectp->ceilingpicnum = nsec->ceilingpicnum; + sectp->ceilingshade = nsec->ceilingshade; + break; //Leave early } + } } } }