- adapted getzrange to the new interface.

This was mainly removing game side solutions in favor of a common one in the backend.
This commit is contained in:
Christoph Oelckers 2021-11-26 20:06:07 +01:00
parent 729076b79d
commit 70d7e81f4f
11 changed files with 61 additions and 80 deletions

View file

@ -367,21 +367,9 @@ void setVideoMode();
class F2DDrawer;
void getzrange(const vec3_t *pos, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
void getzrange_(const vec3_t *pos, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6)));
inline void getzrange(const vec3_t* pos, sectortype* sect, int32_t* ceilz, int32_t* ceilhit, int32_t* florz,
int32_t* florhit, int32_t walldist, uint32_t cliptype)
{
getzrange(pos, sector.IndexOf(sect), ceilz, ceilhit, florz, florhit, walldist, cliptype);
}
inline void getzrange(int x, int y, int z, int16_t sectnum, int32_t* ceilz, int32_t* ceilhit, int32_t* florz,
int32_t* florhit, int32_t walldist, uint32_t cliptype)
{
vec3_t v = { x, y, z };
getzrange(&v, sectnum, ceilz, ceilhit, florz, florhit, walldist, cliptype);
}
extern vec2_t hitscangoal;
int32_t hitscan_(const vec3_t* sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz,
@ -485,9 +473,6 @@ 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);
inline int32_t getceilzofslope(int sectnum, int32_t dax, int32_t day)
{
return getceilzofslopeptr((usectorptr_t)&sector[sectnum], dax, day);

View file

@ -935,7 +935,7 @@ int pushmove(vec3_t *const vect, int *const sectnum,
//
// getzrange
//
void getzrange(const vec3_t *pos, int16_t sectnum,
void getzrange_(const vec3_t *pos, int16_t sectnum,
int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit,
int32_t walldist, uint32_t cliptype)
{

View file

@ -336,6 +336,28 @@ inline void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16
neartag_(xs, ys, zs, sectnum, ange, neartagsector, neartagwall, neartagsprite, neartaghitdist, neartagrange, tagsearch);
}
[[deprecated]]
inline void getzrange(const vec3_t* pos, int16_t sectnum, int32_t* ceilz, int32_t* ceilhit, int32_t* florz,
int32_t* florhit, int32_t walldist, uint32_t cliptype)
{
getzrange(pos, sectnum, ceilz, ceilhit, florz, florhit, walldist, cliptype);
}
[[deprecated]]
inline void getzrange(const vec3_t* pos, sectortype* sect, int32_t* ceilz, int32_t* ceilhit, int32_t* florz,
int32_t* florhit, int32_t walldist, uint32_t cliptype)
{
getzrange_(pos, sector.IndexOf(sect), ceilz, ceilhit, florz, florhit, walldist, cliptype);
}
[[deprecated]]
inline void getzrange(int x, int y, int z, int16_t sectnum, int32_t* ceilz, int32_t* ceilhit, int32_t* florz,
int32_t* florhit, int32_t walldist, uint32_t cliptype)
{
vec3_t v = { x, y, z };
getzrange_(&v, sectnum, ceilz, ceilhit, florz, florhit, walldist, cliptype);
}
inline int hitscan(const vec3_t& start, const sectortype* startsect, const vec3_t& direction, HitInfoBase& hitinfo, unsigned cliptype)
@ -369,3 +391,12 @@ inline void neartag(const vec3_t& pos, sectortype* sect, int angle, HitInfoBase&
result.hitWall = ntwal == -1 ? nullptr : &wall[ntwal];
result.hitActor = ntsprt == -1 ? nullptr : actorArray[ntsprt];
}
inline void getzrange(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBase& ceilhit, int32_t* florz,
CollisionBase& florhit, int32_t walldist, uint32_t cliptype)
{
int fh, ch;
getzrange_(&pos, sector.IndexOf(sect), ceilz, &ch, florz, &fh, walldist, cliptype);
ceilhit.setFromEngine(ch);
florhit.setFromEngine(fh);
}

View file

@ -558,14 +558,12 @@ void GetZRange(DBloodActor *actor, int *ceilZ, Collision *ceilColl, int *floorZ,
{
assert(actor != NULL);
auto pSprite = &actor->s();
Collision scratch;
int floorHit, ceilHit;
int bakCstat = pSprite->cstat;
int32_t nTemp1, nTemp2;
int32_t nTemp1;
pSprite->cstat &= ~257;
getzrange(&pSprite->pos, pSprite->sector(), (int32_t*)ceilZ, &ceilHit, (int32_t*)floorZ, &floorHit, nDist, nMask);
ceilColl->setFromEngine(ceilHit);
floorColl->setFromEngine(floorHit);
getzrange(pSprite->pos, pSprite->sector(), (int32_t*)ceilZ, *ceilColl, (int32_t*)floorZ, *floorColl, nDist, nMask);
if (floorColl->type == kHitSector)
{
auto pSector = floorColl->hitSector;
@ -581,9 +579,8 @@ void GetZRange(DBloodActor *actor, int *ceilZ, Collision *ceilColl, int *floorZ,
{
auto link = actor->GetOwner();
vec3_t lpos = pSprite->pos + link->s().pos - actor->s().pos;
getzrange(&lpos, link->s().sectnum, &nTemp1, &nTemp2, (int32_t*)floorZ, &floorHit, nDist, nMask);
getzrange(lpos, link->s().sector(), &nTemp1, scratch, (int32_t*)floorZ, *floorColl, nDist, nMask);
*floorZ -= link->s().z - actor->s().z;
floorColl->setFromEngine(floorHit);
}
}
if (ceilColl->type == kHitSector)
@ -596,9 +593,8 @@ void GetZRange(DBloodActor *actor, int *ceilZ, Collision *ceilColl, int *floorZ,
{
auto link = actor->GetOwner();
vec3_t lpos = pSprite->pos + link->s().pos - actor->s().pos;
getzrange(&lpos, link->s().sectnum, (int32_t*)ceilZ, &ceilHit, &nTemp1, &nTemp2, nDist, nMask);
getzrange(lpos, link->s().sector(), (int32_t*)ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask);
*ceilZ -= link->s().z - actor->s().z;
ceilColl->setFromEngine(ceilHit);
}
}
pSprite->cstat = bakCstat;
@ -606,12 +602,10 @@ void GetZRange(DBloodActor *actor, int *ceilZ, Collision *ceilColl, int *floorZ,
void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int *ceilZ, Collision* ceilColl, int* floorZ, Collision* floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax)
{
int ceilHit, floorHit;
int32_t nTemp1, nTemp2;
Collision scratch;
int32_t nTemp1;
vec3_t lpos = { x, y, z };
getzrange(&lpos, pSector, (int32_t*)ceilZ, &ceilHit, (int32_t*)floorZ, &floorHit, nDist, nMask);
ceilColl->setFromEngine(ceilHit);
floorColl->setFromEngine(floorHit);
getzrange(lpos, pSector, (int32_t*)ceilZ, *ceilColl, (int32_t*)floorZ, *floorColl, nDist, nMask);
if (floorColl->type == kHitSector)
{
auto pSector = floorColl->hitSector;
@ -627,8 +621,7 @@ void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int *ceilZ, Collis
{
auto link = actor->GetOwner();
vec3_t newpos = lpos + link->s().pos - actor->s().pos;
getzrange(&newpos, link->s().sector(), &nTemp1, &nTemp2, (int32_t*)floorZ, &floorHit, nDist, nMask);
floorColl->setFromEngine(floorHit);
getzrange(newpos, link->s().sector(), &nTemp1, scratch, (int32_t*)floorZ, *floorColl, nDist, nMask);
*floorZ -= link->s().z - actor->s().z;
}
}
@ -642,8 +635,7 @@ void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int *ceilZ, Collis
{
auto link = actor->GetOwner();
vec3_t newpos = lpos + link->s().pos - actor->s().pos;
getzrange(&newpos, link->s().sectnum, (int32_t*)ceilZ, &ceilHit, &nTemp1, &nTemp2, nDist, nMask);
ceilColl->setFromEngine(ceilHit);
getzrange(newpos, link->s().sector(), (int32_t*)ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask);
*ceilZ -= link->s().z - actor->s().z;
}
}

View file

@ -4936,7 +4936,7 @@ void getglobalz(DDukeActor* actor)
auto cc = s->cstat2;
s->cstat2 |= CSTAT2_SPRITE_NOFIND; // don't clip against self. getzrange cannot detect this because it only receives a coordinate.
getzrange_ex(s->x, s->y, s->z - (FOURSLEIGHT), s->sector(), &actor->ceilingz, hz, &actor->floorz, lz, zr, CLIPMASK0);
getzrange({ s->x, s->y, s->z - (FOURSLEIGHT) }, s->sector(), &actor->ceilingz, hz, &actor->floorz, lz, zr, CLIPMASK0);
s->cstat2 = cc;
if( lz.type == kHitSprite && (lz.actor()->s->cstat&48) == 0 )
@ -5000,7 +5000,7 @@ void makeitfall(DDukeActor* actor)
if ((s->statnum == STAT_ACTOR || s->statnum == STAT_PLAYER || s->statnum == STAT_ZOMBIEACTOR || s->statnum == STAT_STANDABLE))
{
Collision c;
getzrange_ex(s->x, s->y, s->z - (FOURSLEIGHT), s->sector(), &actor->ceilingz, c, &actor->floorz, c, 127, CLIPMASK0);
getzrange({ s->x, s->y, s->z - (FOURSLEIGHT) }, s->sector(), &actor->ceilingz, c, &actor->floorz, c, 127, CLIPMASK0);
}
else
{

View file

@ -181,22 +181,6 @@ inline int movesprite_ex(DDukeActor* actor, int xchange, int ychange, int zchang
return f(actor, xchange, ychange, zchange, cliptype, result);
}
inline void getzrange_ex(int x, int y, int z, int sectnum, int32_t* ceilz, Collision& ceilhit, int32_t* florz, Collision& florhit, int32_t walldist, uint32_t cliptype)
{
int ch, fh;
getzrange(x, y, z, sectnum, ceilz, &ch, florz, &fh, walldist, cliptype);
ceilhit.setFromEngine(ch);
florhit.setFromEngine(fh);
}
inline void getzrange_ex(int x, int y, int z, sectortype* sect, int32_t* ceilz, Collision& ceilhit, int32_t* florz, Collision& florhit, int32_t walldist, uint32_t cliptype)
{
int ch, fh;
getzrange(x, y, z, sectnum(sect), ceilz, &ch, florz, &fh, walldist, cliptype);
ceilhit.setFromEngine(ch);
florhit.setFromEngine(fh);
}
END_DUKE_NS

View file

@ -2759,7 +2759,7 @@ void processinput_d(int snum)
p->spritebridge = 0;
shrunk = (s->yrepeat < 32);
getzrange_ex(p->pos.x, p->pos.y, p->pos.z, psectp, &cz, chz, &fz, clz, 163, CLIPMASK0);
getzrange(p->pos, psectp, &cz, chz, &fz, clz, 163, CLIPMASK0);
j = getflorzofslopeptr(psectp, p->pos.x, p->pos.y);

View file

@ -3413,12 +3413,12 @@ void processinput_r(int snum)
int tempfz;
if (s->clipdist == 64)
{
getzrange_ex(p->pos.x, p->pos.y, p->pos.z, psectp, &cz, chz, &fz, clz, 163L, CLIPMASK0);
getzrange(p->pos, psectp, &cz, chz, &fz, clz, 163L, CLIPMASK0);
tempfz = getflorzofslopeptr(psectp, p->pos.x, p->pos.y);
}
else
{
getzrange_ex(p->pos.x, p->pos.y, p->pos.z, psectp, &cz, chz, &fz, clz, 4L, CLIPMASK0);
getzrange(p->pos, psectp, &cz, chz, &fz, clz, 4L, CLIPMASK0);
tempfz = getflorzofslopeptr(psectp, p->pos.x, p->pos.y);
}

View file

@ -90,8 +90,9 @@ bool GameInterface::DrawAutomapPlayer(int mx, int my, int x, int y, int z, int a
if (i == nLocalPlayer)// || gGameOptions.nGameType == 1)
{
int nTile = pSprite->picnum;
int ceilZ, ceilHit, floorZ, floorHit;
getzrange(&pSprite->pos, pSprite->sectnum, &ceilZ, &ceilHit, &floorZ, &floorHit, (pSprite->clipdist << 2) + 16, CLIPMASK0);
int ceilZ, floorZ;
Collision ceilHit, floorHit;
getzrange(pSprite->pos, pSprite->sector(), &ceilZ, ceilHit, &floorZ, floorHit, (pSprite->clipdist << 2) + 16, CLIPMASK0);
int nTop, nBottom;
GetSpriteExtents(pSprite, &nTop, &nBottom);
int nScale = (pSprite->yrepeat + ((floorZ - nBottom) >> 8)) * z;

View file

@ -359,13 +359,9 @@ Collision movespritez(DExhumedActor* pActor, int z, int height, int, int clipdis
// This function will keep the player from falling off cliffs when you're too close to the edge.
// This function finds the highest and lowest z coordinates that your clipping BOX can get to.
int hihit, lohit;
vec3_t pos = pSprite->pos;
pos.z -= 256;
getzrange(&pos, pSprite->sectnum,
&sprceiling, &hihit, &sprfloor, &lohit, 128, CLIPMASK0);
hiHit.setFromEngine(hihit);
loHit.setFromEngine(lohit);
getzrange(pos, pSprite->sector(), &sprceiling, hiHit, &sprfloor, loHit, 128, CLIPMASK0);
int mySprfloor = sprfloor;

View file

@ -468,14 +468,6 @@ void WaterAdjust(const Collision& florhit, int32_t* loz)
}
}
static void getzrange(vec3_t* pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit, int32_t clipdist, int32_t clipmask)
{
int f, c;
::getzrange(pos, sectnum, hiz, &c, loz, &f, clipdist, clipmask);
ceilhit->setFromEngine(c);
florhit->setFromEngine(f);
}
void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit, int32_t clipdist, int32_t clipmask)
{
sectortype* sect = &sector[sectnum];
@ -491,13 +483,13 @@ void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit,
// early out to regular routine
if (sectnum < 0 || !FAF_ConnectArea(sect))
{
getzrange(&pos, sectnum, hiz, ceilhit, loz, florhit, clipdist, clipmask);
getzrange(pos, sect, hiz, *ceilhit, loz, *florhit, clipdist, clipmask);
SectorZadjust(*ceilhit, hiz, *florhit, loz);
WaterAdjust(*florhit, loz);
return;
}
getzrange(&pos, sectnum, hiz, ceilhit, loz, florhit, clipdist, clipmask);
getzrange(pos, sect, hiz, *ceilhit, loz, *florhit, clipdist, clipmask);
SkipFAFcheck = SectorZadjust(*ceilhit, hiz, *florhit, loz);
WaterAdjust(*florhit, loz);
@ -506,32 +498,32 @@ void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit,
if (FAF_ConnectCeiling(sect))
{
int uppersect = sectnum;
auto uppersect = sect;
int newz = *hiz - Z(2);
if (ceilhit->type == kHitSprite) return;
updatesectorz(pos.x, pos.y, newz, &uppersect);
if (uppersect < 0)
return; // _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d", x, y, newz);
if (uppersect == nullptr)
return;
vec3_t npos = pos;
npos.z = newz;
getzrange(&npos, uppersect, hiz, ceilhit, &foo1, &foo2, clipdist, clipmask);
getzrange(npos, uppersect, hiz, *ceilhit, &foo1, foo2, clipdist, clipmask);
SectorZadjust(*ceilhit, hiz, trash, nullptr);
}
else if (FAF_ConnectFloor(sect) && !TEST(sect->floorstat, FLOOR_STAT_FAF_BLOCK_HITSCAN))
{
int lowersect = sectnum;
auto lowersect = sect;
int newz = *loz + Z(2);
if (florhit->type == kHitSprite) return;
updatesectorz(pos.x, pos.y, newz, &lowersect);
if (lowersect < 0)
if (lowersect == nullptr)
return; // _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d", x, y, newz);
vec3_t npos = pos;
npos.z = newz;
getzrange(&npos, lowersect, &foo1, &foo2, loz, florhit, clipdist, clipmask);
getzrange(npos, lowersect, &foo1, foo2, loz, *florhit, clipdist, clipmask);
SectorZadjust(trash, nullptr, *florhit, loz);
WaterAdjust(*florhit, loz);
}