From e2d79b4682aec2471d40a8db4e48c0adf28caefc Mon Sep 17 00:00:00 2001 From: "Richard C. Gobeille" Date: Wed, 13 May 2020 16:55:58 -0700 Subject: [PATCH] engine: add yax_getflorzofslope() and yax_getceilzofslope() --- source/build/include/build.h | 3 +++ source/build/src/engine.cpp | 24 ++++++++++++++++++++++++ source/duke3d/src/gameexec.cpp | 27 ++++----------------------- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index f2d84bc73..83c5b7ef6 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -963,6 +963,9 @@ void getzsofslopeptr(usectorptr_t sec, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) ATTRIBUTE((nonnull(1,4,5))); void yax_getzsofslope(int sectNum, int playerX, int playerY, int32_t* pCeilZ, int32_t* pFloorZ); +int32_t yax_getceilzofslope(int const sectnum, vec2_t const vect); +int32_t yax_getflorzofslope(int const sectnum, vec2_t const vect); + static FORCE_INLINE int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day) { return getceilzofslopeptr((usectorptr_t)§or[sectnum], dax, day); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 7109dc665..f8f79d54c 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -5298,6 +5298,30 @@ floor: else if (!didFloor) goto floor; } + +int32_t yax_getceilzofslope(int const sectnum, vec2_t const vect) +{ + if ((sector[sectnum].ceilingstat&512)==0) + { + int const nsect = yax_getneighborsect(vect.x, vect.y, sectnum, YAX_CEILING); + if (nsect >= 0) + return getcorrectceilzofslope(nsect, vect.x, vect.y); + } + + return getcorrectceilzofslope(sectnum, vect.x, vect.y); +} + +int32_t yax_getflorzofslope(int const sectnum, vec2_t const vect) +{ + if ((sector[sectnum].floorstat&512)==0) + { + int const nsect = yax_getneighborsect(vect.x, vect.y, sectnum, YAX_FLOOR); + if (nsect >= 0) + return getcorrectflorzofslope(nsect, vect.x, vect.y); + } + + return getcorrectflorzofslope(sectnum, vect.x, vect.y); +} #endif // diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 365443c77..422cdb426 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -627,23 +627,13 @@ static inline void VM_FacePlayer(int const shift) : getangle(vm.pPlayer->pos.x - vm.pSprite->x, vm.pPlayer->pos.y - vm.pSprite->y)); } -////////// TROR get*zofslope ////////// -// These rather belong into the engine. - static int32_t VM_GetCeilZOfSlope(void) { vec2_t const vect = vm.pSprite->pos.vec2; int const sectnum = vm.pSprite->sectnum; -#ifdef YAX_ENABLE - if ((sector[sectnum].ceilingstat&512)==0) - { - int const nsect = yax_getneighborsect(vect.x, vect.y, sectnum, YAX_CEILING); - if (nsect >= 0) - return getceilzofslope(nsect, vect.x, vect.y); - } -#endif - return getceilzofslope(sectnum, vect.x, vect.y); + return yax_getceilzofslope(sectnum, vect); + } #ifndef EDUKE32_STANDALONE @@ -652,20 +642,11 @@ static int32_t VM_GetFlorZOfSlope(void) vec2_t const vect = vm.pSprite->pos.vec2; int const sectnum = vm.pSprite->sectnum; -#ifdef YAX_ENABLE - if ((sector[sectnum].floorstat&512)==0) - { - int const nsect = yax_getneighborsect(vect.x, vect.y, sectnum, YAX_FLOOR); - if (nsect >= 0) - return getflorzofslope(nsect, vect.x, vect.y); - } -#endif - return getflorzofslope(sectnum, vect.x, vect.y); + return yax_getflorzofslope(sectnum, vect); + } #endif -//////////////////// - static int32_t A_GetWaterZOffset(int spritenum); GAMEEXEC_STATIC void VM_Move(void)