From 83c0ad55f21c4ecf11dc68e569ae9cc8783ae65e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 5 Aug 2022 18:43:48 +0200 Subject: [PATCH] - rewrote nextsectorneighborzptr with a better parameter interface --- source/build/include/build.h | 7 --- source/build/src/engine.cpp | 32 ------------ source/core/gamefuncs.cpp | 32 ++++++++++++ source/core/gamefuncs.h | 18 +++++++ source/games/duke/src/bowling.cpp | 2 +- source/games/duke/src/sectors.cpp | 22 ++++----- source/games/duke/src/spawn.cpp | 4 +- source/games/exhumed/src/runlist.cpp | 74 ++++++++++++++-------------- source/games/sw/src/sector.cpp | 2 +- 9 files changed, 102 insertions(+), 91 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 499796aeb..6a4bc3072 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -176,13 +176,6 @@ inline constexpr uint32_t uhypsq(int32_t const dx, int32_t const dy) void rotatepoint(vec2_t const pivot, vec2_t p, int16_t const daang, vec2_t * const p2) ATTRIBUTE((nonnull(4))); -sectortype* nextsectorneighborzptr(sectortype* sectp, int refz, int topbottom, int direction); -inline sectortype* safenextsectorneighborzptr(sectortype* sectp, int refz, int topbottom, int direction) -{ - auto sect = nextsectorneighborzptr(sectp, refz, topbottom, direction); - return sect == nullptr ? sectp : sect; -} - int32_t lintersect(int32_t originX, int32_t originY, int32_t originZ, int32_t destX, int32_t destY, int32_t destZ, int32_t lineStartX, int32_t lineStartY, int32_t lineEndX, int32_t lineEndY, diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index c26afcf37..20bf7e006 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -248,38 +248,6 @@ int32_t getangle(int32_t xvect, int32_t yvect) } -// -// nextsectorneighborz -// -// -1: ceiling or up -// 1: floor or down -sectortype* nextsectorneighborzptr(sectortype* sectp, int refz, int topbottom, int direction) -{ - int nextz = (direction==1) ? INT32_MAX : INT32_MIN; - sectortype* sectortouse = nullptr; - - for(auto& wal : wallsofsector(sectp)) - { - if (wal.twoSided()) - { - auto ns = wal.nextSector(); - - const int32_t testz = (topbottom == 1) ? ns->floorz : ns->ceilingz; - - const int32_t update = (direction == 1) ? - (nextz > testz && testz > refz) : - (nextz < testz && testz < refz); - - if (update) - { - nextz = testz; - sectortouse = ns; - } - } - } - return sectortouse; -} - // // cansee diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index 84a77685d..5329c9464 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -515,6 +515,38 @@ int inside(double x, double y, const sectortype* sect) return -1; } +//========================================================================== +// +// find the closest neighboring sector plane in the given direction. +// Does not consider slopes, just like the original! +// +//========================================================================== + +sectortype* nextsectorneighborzptr(sectortype* sectp, int startz, int flags) +{ + int factor = (flags & Find_Up)? -1 : 1; + int bestz = INT_MAX; + sectortype* bestsec = (flags & Find_Safe)? sectp : nullptr; + const auto planez = (flags & Find_Ceiling)? §ortype::ceilingz : §ortype::floorz; + + startz *= factor; + for(auto& wal : wallsofsector(sectp)) + { + if (wal.twoSided()) + { + auto nextsec = wal.nextSector(); + auto nextz = factor * nextsec->*planez; + + if (startz < nextz && nextz < bestz) + { + bestz = nextz; + bestsec = nextsec; + } + } + } + return bestsec; +} + //========================================================================== // // diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index c5cfc03bd..165a88ce2 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -180,6 +180,24 @@ int getflorzofslopeptr(const sectortype* sec, int dax, int day); void getzsofslopeptr(const sectortype* sec, int dax, int day, int* ceilz, int* florz); void getzsofslopeptr(const sectortype* sec, double dax, double day, double* ceilz, double* florz); +enum EFindNextSector +{ + Find_Floor = 0, + Find_Ceiling = 1, + + Find_Down = 0, + Find_Up = 2, + + Find_Safe = 4, + + Find_CeilingUp = Find_Ceiling | Find_Up, + Find_CeilingDown = Find_Ceiling | Find_Down, + Find_FloorUp = Find_Floor | Find_Up, + Find_FloorDown = Find_Floor | Find_Down, +}; +sectortype* nextsectorneighborzptr(sectortype* sectp, int startz, int flags); + + // y is negated so that the orientation is the same as in GZDoom, in order to use its utilities. // The render code should NOT use Build coordinates for anything! diff --git a/source/games/duke/src/bowling.cpp b/source/games/duke/src/bowling.cpp index e96ec56c0..13099e780 100644 --- a/source/games/duke/src/bowling.cpp +++ b/source/games/duke/src/bowling.cpp @@ -74,7 +74,7 @@ int pinsectorresetup(sectortype* sec) if (j == -1) { - j = safenextsectorneighborzptr(sec, sec->ceilingz, -1, -1)->ceilingz; + j = nextsectorneighborzptr(sec, sec->ceilingz, Find_CeilingUp | Find_Safe)->ceilingz; setanimation(sec, anim_ceilingz, sec, j, 64); return 1; } diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index aa3ef2adc..54459f449 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -660,10 +660,10 @@ static void handle_st16(sectortype* sptr, DDukeActor* actor) if (i == -1) { - sectp = nextsectorneighborzptr(sptr, sptr->floorz, 1, 1); + sectp = nextsectorneighborzptr(sptr, sptr->floorz, Find_FloorDown); if (sectp == nullptr) { - sectp = nextsectorneighborzptr(sptr, sptr->floorz, 1, -1); + sectp = nextsectorneighborzptr(sptr, sptr->floorz, Find_FloorUp); if (sectp == nullptr) return; setanimation(sptr, anim_floorz, sptr, sectp->floorz, sptr->extra); } @@ -687,8 +687,8 @@ static void handle_st18(sectortype* sptr, DDukeActor* actor) if (i == -1) { - auto sectp = nextsectorneighborzptr(sptr, sptr->floorz, 1, -1); - if (sectp == nullptr) sectp = nextsectorneighborzptr(sptr, sptr->floorz, 1, 1); + auto sectp = nextsectorneighborzptr(sptr, sptr->floorz, Find_FloorUp); + if (sectp == nullptr) sectp = nextsectorneighborzptr(sptr, sptr->floorz, Find_FloorDown); if (sectp == nullptr) return; int j = sectp->floorz; int q = sptr->extra; @@ -710,9 +710,9 @@ static void handle_st29(sectortype* sptr, DDukeActor* actor) int j; if (sptr->lotag & 0x8000) - j = safenextsectorneighborzptr(sptr, sptr->ceilingz, 1, 1)->floorz; + j = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_FloorDown | Find_Safe)->floorz; else - j = safenextsectorneighborzptr(sptr, sptr->ceilingz, -1, -1)->ceilingz; + j = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_CeilingUp | Find_Safe)->ceilingz; DukeStatIterator it(STAT_EFFECTOR); while (auto act2 = it.Next()) @@ -762,7 +762,7 @@ REDODOOR: } else { - auto sectp = nextsectorneighborzptr(sptr, sptr->ceilingz, -1, -1); + auto sectp = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_CeilingUp); if (sectp) j = sectp->ceilingz; else @@ -791,14 +791,14 @@ static void handle_st21(sectortype* sptr, DDukeActor* actor) if (i >= 0) { if (animategoal[i] == sptr->ceilingz) - animategoal[i] = safenextsectorneighborzptr(sptr, sptr->ceilingz, 1, 1)->floorz; + animategoal[i] = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_FloorDown | Find_Safe)->floorz; else animategoal[i] = sptr->ceilingz; j = animategoal[i]; } else { if (sptr->ceilingz == sptr->floorz) - j = safenextsectorneighborzptr(sptr, sptr->ceilingz, 1, 1)->floorz; + j = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_FloorDown | Find_Safe)->floorz; else j = sptr->ceilingz; sptr->lotag ^= 0x8000; @@ -825,9 +825,9 @@ static void handle_st22(sectortype* sptr, DDukeActor* actor) } else { - q = safenextsectorneighborzptr(sptr, sptr->floorz, 1, 1)->floorz; + q = nextsectorneighborzptr(sptr, sptr->floorz, Find_FloorDown | Find_Safe)->floorz; j = setanimation(sptr, anim_floorz, sptr, q, sptr->extra); - q = safenextsectorneighborzptr(sptr, sptr->ceilingz, -1, -1)->ceilingz; + q = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_CeilingUp | Find_Safe)->ceilingz; j = setanimation(sptr, anim_ceilingz, sptr, q, sptr->extra); } diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 105939d6a..cf43477e5 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -750,8 +750,8 @@ void spawneffector(DDukeActor* actor, TArray* actors) case SE_17_WARP_ELEVATOR: { actor->temp_data[2] = sectp->floorz; //Stopping loc - actor->temp_data[3] = safenextsectorneighborzptr(sectp, sectp->floorz, -1, -1)->ceilingz; - actor->temp_data[4] = safenextsectorneighborzptr(sectp, sectp->ceilingz, 1, 1)->floorz; + actor->temp_data[3] = nextsectorneighborzptr(sectp, sectp->floorz, Find_CeilingUp | Find_Safe)->ceilingz; + actor->temp_data[4] = nextsectorneighborzptr(sectp, sectp->ceilingz, Find_FloorDown | Find_Safe)->floorz; if (numplayers < 2) { diff --git a/source/games/exhumed/src/runlist.cpp b/source/games/exhumed/src/runlist.cpp index 1a77f53ab..8c57c088f 100644 --- a/source/games/exhumed/src/runlist.cpp +++ b/source/games/exhumed/src/runlist.cpp @@ -615,7 +615,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) This function searches z-coordinates of neighboring sectors to find the closest (next) ceiling starting at the given z-coordinate (thez). */ - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, -1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_CeilingUp | Find_Safe); int nElev = BuildElevC(0, nChannel, pSector, FindWallSprites(pSector), nSpeed * 100, nSpeed * 100, 2, pSector->floorz, nextSectorP->ceilingz); @@ -634,7 +634,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 2: // Floor Doom door { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); int nElev = BuildElevF(nChannel, pSector, FindWallSprites(pSector), nSpeed * 100, nSpeed * 100, 2, pSector->ceilingz, nextSectorP->floorz); @@ -683,7 +683,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 5: // Permanent floor raise { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz + 1, -1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz + 1, Find_CeilingUp | Find_Safe); if (nextSectorP == nullptr) break; int nElev = BuildElevF(nChannel, pSector, FindWallSprites(pSector), nSpeed * 100, nSpeed * 100, 2, pSector->floorz, nextSectorP->ceilingz); @@ -694,7 +694,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 6: // Touchplate floor lower, single { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorUp | Find_Safe); if (nextSectorP == nullptr) break; @@ -712,7 +712,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 7: // Touchplate floor lower, multiple { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -732,7 +732,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 8: // Permanent floor lower { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -744,7 +744,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 9: // Switch activated lift down { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -760,7 +760,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 10: // Touchplate Floor Raise { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorUp | Find_Safe); if (nextSectorP == nullptr) break; @@ -789,7 +789,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) */ int zVal = 0; - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorUp | Find_Safe); if (nextSectorP != nullptr) { zVal = nextSectorP->floorz; } @@ -809,7 +809,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) */ int zVal = 0; - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorUp | Find_Safe); if (nextSectorP != nullptr) { zVal = nextSectorP->floorz; } @@ -833,7 +833,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) */ int zVal = 0; - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP != nullptr) { zVal = nextSectorP->floorz; } @@ -850,7 +850,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 15: // Sector raise/lower { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorUp | Find_Safe); if (nextSectorP == nullptr) break; @@ -925,7 +925,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) */ int zVal = 0; - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP) { zVal = nextSectorP->floorz; } @@ -942,7 +942,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 24: // Ceiling door, channel trigger only { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, -1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_CeilingUp | Find_Safe); if (nextSectorP == nullptr) break; @@ -958,7 +958,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 25: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -974,7 +974,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 26: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -990,7 +990,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 27: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -1006,7 +1006,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 28: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -1022,7 +1022,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 31: // Touchplate { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -1038,7 +1038,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 32: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -1050,7 +1050,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 33: // Ceiling Crusher { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, -1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_CeilingUp | Find_Safe); if (nextSectorP == nullptr) break; @@ -1062,7 +1062,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 34: // Triggerable Ceiling Crusher(Inactive) { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, -1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_CeilingUp | Find_Safe); if (nextSectorP == nullptr) break; @@ -1088,7 +1088,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 37: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -1100,7 +1100,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 39: // Touchplate { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -1163,7 +1163,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) */ int zVal = 0; - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, -1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_CeilingDown | Find_Safe); if (nextSectorP != nullptr) { zVal = nextSectorP->ceilingz; } @@ -1176,7 +1176,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 49: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, -1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_CeilingUp | Find_Safe); if (nextSectorP == nullptr) break; @@ -1188,7 +1188,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 50: // Floor lower / raise { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -1264,7 +1264,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 54: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, -1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_CeilingUp | Find_Safe); if (nextSectorP == nullptr) break; @@ -1280,7 +1280,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 55: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, -1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_CeilingUp | Find_Safe); if (nextSectorP == nullptr) break; @@ -1296,7 +1296,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 56: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, -1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_CeilingUp | Find_Safe); if (nextSectorP == nullptr) break; @@ -1308,7 +1308,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 57: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -1333,7 +1333,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) nEnergyChan = nChannel; } - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, -1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_CeilingUp | Find_Safe); int nElev = BuildElevC(0, nChannel, pSector, FindWallSprites(pSector), nSpeed * 100, nSpeed * 100, 2, pSector->floorz, nextSectorP->ceilingz); @@ -1344,7 +1344,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 59: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -1369,7 +1369,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) while (1) { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorUp | Find_Safe); if (nextSectorP == nullptr || var_1C >= 8) { break; } @@ -1393,7 +1393,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) while (1) { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr || var_20 >= 8) { break; } @@ -1419,7 +1419,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 68: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->floorz, 1, 1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->floorz, Find_FloorDown | Find_Safe); if (nextSectorP == nullptr) break; @@ -1432,7 +1432,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) case 70: case 71: { - auto nextSectorP = safenextsectorneighborzptr(pSector, pSector->ceilingz, -1, -1); + auto nextSectorP = nextsectorneighborzptr(pSector, pSector->ceilingz, Find_CeilingUp | Find_Safe); if (nextSectorP == nullptr) break; diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 8ae857cca..d39f39e70 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -630,7 +630,7 @@ void DoSpringBoardDown(void) { int destz; - destz = safenextsectorneighborzptr(sbp->sectp, sbp->sectp->floorz, 1, 1)->floorz; + destz = nextsectorneighborzptr(sbp->sectp, sbp->sectp->floorz, Find_FloorDown | Find_Safe)->floorz; AnimSet(ANIM_Floorz, sbp->sectp, destz, 256);