From 6e03f87671559decd719e704676018e021902062 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 28 Sep 2022 14:01:20 +0200 Subject: [PATCH] - floatified GetZRange --- source/games/blood/src/gameutil.cpp | 24 ++++++++++++------------ source/games/blood/src/gameutil.h | 10 ++-------- source/games/blood/src/nnexts.cpp | 2 +- source/games/blood/src/view.cpp | 3 --- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index 6c8be6285..732d5afc2 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -474,46 +474,46 @@ int VectorScan(DBloodActor* actor, double nOffset, double nZOffset, const DVecto // //--------------------------------------------------------------------------- -void GetZRange(DBloodActor* actor, int* ceilZ, Collision* ceilColl, int* floorZ, Collision* floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax) +void GetZRange(DBloodActor* actor, double* ceilZ, Collision* ceilColl, double* floorZ, Collision* floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax) { assert(actor != nullptr); Collision scratch; auto bakCstat = actor->spr.cstat; - int32_t nTemp1; + double nTemp1; actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; - getzrange(actor->int_pos(), actor->sector(), (int32_t*)ceilZ, *ceilColl, (int32_t*)floorZ, *floorColl, nDist, nMask); + getzrange(actor->spr.pos, actor->sector(), ceilZ, *ceilColl, floorZ, *floorColl, nDist, nMask); if (floorColl->type == kHitSector) { auto pSector = floorColl->hitSector; if ((nClipParallax & PARALLAXCLIP_FLOOR) == 0 && (pSector->floorstat & CSTAT_SECTOR_SKY)) - *floorZ = 0x7fffffff; + *floorZ = 0x800000; if (pSector->hasX()) { XSECTOR* pXSector = &pSector->xs(); - *floorZ += pXSector->Depth << 10; + *floorZ += pXSector->Depth << 2; } auto linkActor = barrier_cast(pSector->upperLink); if (linkActor) { auto linkOwner = linkActor->GetOwner(); - vec3_t lpos = actor->int_pos() + linkOwner->int_pos() - linkActor->int_pos(); - getzrange(lpos, linkOwner->sector(), &nTemp1, scratch, (int32_t*)floorZ, *floorColl, nDist, nMask); - *floorZ -= linkOwner->int_pos().Z - linkActor->int_pos().Z; + auto lpos = actor->spr.pos + linkOwner->spr.pos - linkActor->spr.pos; + getzrange(lpos, linkOwner->sector(), &nTemp1, scratch, floorZ, *floorColl, nDist, nMask); + *floorZ -= linkOwner->spr.pos.Z - linkActor->spr.pos.Z; } } if (ceilColl->type == kHitSector) { auto pSector = ceilColl->hitSector; if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pSector->ceilingstat & CSTAT_SECTOR_SKY)) - *ceilZ = 0x80000000; + *ceilZ = -(int)0x800000; auto linkActor = barrier_cast(pSector->lowerLink); if (linkActor) { auto linkOwner = linkActor->GetOwner(); - vec3_t lpos = actor->int_pos() + linkOwner->int_pos() - linkActor->int_pos(); - getzrange(lpos, linkOwner->sector(), (int32_t*)ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask); - *ceilZ -= linkOwner->int_pos().Z - linkActor->int_pos().Z; + auto lpos = actor->spr.pos + linkOwner->spr.pos - linkActor->spr.pos; + getzrange(lpos, linkOwner->sector(), ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask); + *ceilZ -= linkOwner->spr.pos.Z - linkActor->spr.pos.Z; } } actor->spr.cstat = bakCstat; diff --git a/source/games/blood/src/gameutil.h b/source/games/blood/src/gameutil.h index 1ca98a044..4c39cb328 100644 --- a/source/games/blood/src/gameutil.h +++ b/source/games/blood/src/gameutil.h @@ -52,14 +52,8 @@ inline int HitScan_(DBloodActor* pSprite, double z, const DVector3& pos, unsigne } int VectorScan(DBloodActor* pSprite, double nOffset, double nZOffset, const DVector3& vel, double nRange, int ac); -void GetZRange(DBloodActor* pSprite, int* ceilZ, Collision* ceilHit, int* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0); -void GetZRange(DBloodActor* pSprite, double* ceilZ, Collision* ceilHit, double* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0) -{ - int cz, fz; - GetZRange(pSprite, &cz, ceilHit, &fz, floorHit, nDist, nMask, nClipParallax); - *ceilZ = cz * zinttoworld; - *floorZ = fz * zinttoworld; -} +void GetZRange(DBloodActor* pSprite, double* ceilZ, Collision* ceilHit, double* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0); + void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int* ceilZ, Collision* ceilHit, int* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0); void GetZRangeAtXYZ(const DVector3& pos, sectortype* pSector, double* ceilZ, Collision* ceilHit, double* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0) { diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index df69f32a5..f296e53fb 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -8401,7 +8401,7 @@ DBloodActor* aiPatrolSearchTargets(DBloodActor* actor) patrolBonkles[i].max = ClipLow((gGameOptions.nDifficulty + 1) >> 1, 1); } - int i, j, mod, sndCnt = 0, seeChance, hearChance; + int i, mod, sndCnt = 0, seeChance, hearChance; bool stealth = (actor->xspr.unused1 & kDudeFlagStealth); bool blind = (actor->xspr.dudeGuard); bool deaf = (actor->xspr.dudeDeaf); diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 6d74399c9..25054c699 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -742,9 +742,6 @@ void viewDrawScreen(bool sceneonly) bDeliriumOld = bDelirium && gDeliriumBlur; int nClipDist = pPlayer->actor->int_clipdist(); - int vec, vf4; - Collision c1, c2; - GetZRange(pPlayer->actor, &vf4, &c1, &vec, &c2, nClipDist, 0); if (sceneonly) return; double look_anghalf = pPlayer->angle.look_anghalf(interpfrac); DrawCrosshair(kCrosshairTile, pPlayer->actor->xspr.health >> 4, -look_anghalf, 0, 2);