Fix GetZRange regression

This commit is contained in:
nukeykt 2019-09-07 22:53:42 +09:00 committed by Christoph Oelckers
parent 78a3240c3e
commit ddf02bda17
5 changed files with 21 additions and 16 deletions

View file

@ -4774,7 +4774,7 @@ void MoveDude(spritetype *pSprite)
if (zvel[nSprite])
pSprite->z += zvel[nSprite]>>8;
int ceilZ, ceilHit, floorZ, floorHit;
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, CLIPMASK0);
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, CLIPMASK0, PARALLAXCLIP_CEILING|PARALLAXCLIP_FLOOR);
GetSpriteExtents(pSprite, &top, &bottom);
if (pSprite->hitag & 2)
{
@ -4817,7 +4817,7 @@ void MoveDude(spritetype *pSprite)
int nLink = CheckLink(pSprite);
if (nLink)
{
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, CLIPMASK0);
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, CLIPMASK0, PARALLAXCLIP_CEILING|PARALLAXCLIP_FLOOR);
if (pPlayer)
playerResetInertia(pPlayer);
switch (nLink)
@ -5025,7 +5025,7 @@ void MoveDude(spritetype *pSprite)
{
int floorZ2 = floorZ;
int floorHit2 = floorHit;
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, pSprite->clipdist<<2, CLIPMASK0);
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, pSprite->clipdist<<2, CLIPMASK0, PARALLAXCLIP_CEILING|PARALLAXCLIP_FLOOR);
if (bottom <= floorZ && pSprite->z - floorZ2 < bz)
{
floorZ = floorZ2;
@ -5549,7 +5549,7 @@ void actProcessSprites(void)
break;
case 431:
if (!Chance(0x4000) && nNextSprite >= 0) continue;
if (pSprite2->cstat & 0x10001) pXSprite->target = pSprite2->index;
if (pSprite2->cstat & CLIPMASK0) pXSprite->target = pSprite2->index;
else continue;
break;
case kGDXThingCustomDudeLifeLeech:

View file

@ -675,7 +675,7 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
return -1;
}
void GetZRange(spritetype *pSprite, int *ceilZ, int *ceilHit, int *floorZ, int *floorHit, int nDist, unsigned int nMask)
void GetZRange(spritetype *pSprite, int *ceilZ, int *ceilHit, int *floorZ, int *floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax)
{
dassert(pSprite != NULL);
int bakCstat = pSprite->cstat;
@ -685,7 +685,7 @@ void GetZRange(spritetype *pSprite, int *ceilZ, int *ceilHit, int *floorZ, int *
if (((*floorHit) & 0xc000) == 0x4000)
{
int nSector = (*floorHit) & 0x3fff;
if ((nMask & 0x2000) == 0 && (sector[nSector].floorstat & 1))
if ((nClipParallax & PARALLAXCLIP_FLOOR) == 0 && (sector[nSector].floorstat & 1))
*floorZ = 0x7fffffff;
if (sector[nSector].extra > 0)
{
@ -705,7 +705,7 @@ void GetZRange(spritetype *pSprite, int *ceilZ, int *ceilHit, int *floorZ, int *
if (((*ceilHit) & 0xc000) == 0x4000)
{
int nSector = (*ceilHit) & 0x3fff;
if ((nMask & 0x1000) == 0 && (sector[nSector].ceilingstat & 1))
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (sector[nSector].ceilingstat & 1))
*ceilZ = 0x80000000;
if (gLowerLink[nSector] >= 0)
{
@ -720,14 +720,14 @@ void GetZRange(spritetype *pSprite, int *ceilZ, int *ceilHit, int *floorZ, int *
pSprite->cstat = bakCstat;
}
void GetZRangeAtXYZ(int x, int y, int z, int nSector, int *ceilZ, int *ceilHit, int *floorZ, int *floorHit, int nDist, unsigned int nMask)
void GetZRangeAtXYZ(int x, int y, int z, int nSector, int *ceilZ, int *ceilHit, int *floorZ, int *floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax)
{
int32_t nTemp1, nTemp2;
getzrange_old(x, y, z, nSector, (int32_t*)ceilZ, (int32_t*)ceilHit, (int32_t*)floorZ, (int32_t*)floorHit, nDist, nMask);
if (((*floorHit) & 0xc000) == 0x4000)
{
int nSector = (*floorHit) & 0x3fff;
if ((nMask & 0x2000) == 0 && (sector[nSector].floorstat & 1))
if ((nClipParallax & PARALLAXCLIP_FLOOR) == 0 && (sector[nSector].floorstat & 1))
*floorZ = 0x7fffffff;
if (sector[nSector].extra > 0)
{
@ -747,7 +747,7 @@ void GetZRangeAtXYZ(int x, int y, int z, int nSector, int *ceilZ, int *ceilHit,
if (((*ceilHit) & 0xc000) == 0x4000)
{
int nSector = (*ceilHit) & 0x3fff;
if ((nMask & 0x1000) == 0 && (sector[nSector].ceilingstat & 1))
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (sector[nSector].ceilingstat & 1))
*ceilZ = 0x80000000;
if (gLowerLink[nSector] >= 0)
{

View file

@ -43,6 +43,11 @@ extern short gUpperLink[kMaxSectors];
extern short gLowerLink[kMaxSectors];
extern HITINFO gHitInfo;
enum {
PARALLAXCLIP_CEILING = 1,
PARALLAXCLIP_FLOOR = 2,
};
bool AreSectorsNeighbors(int sect1, int sect2);
bool FindSector(int nX, int nY, int nZ, int *nSector);
bool FindSector(int nX, int nY, int *nSector);
@ -55,8 +60,8 @@ void GetWallNormal(int nWall, int *pX, int *pY);
bool IntersectRay(int wx, int wy, int wdx, int wdy, int x1, int y1, int z1, int x2, int y2, int z2, int *ix, int *iy, int *iz);
int HitScan(spritetype *pSprite, int z, int dx, int dy, int dz, unsigned int nMask, int a8);
int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, int dz, int nRange, int ac);
void GetZRange(spritetype *pSprite, int *ceilZ, int *ceilHit, int *floorZ, int *floorHit, int nDist, unsigned int nMask);
void GetZRangeAtXYZ(int x, int y, int z, int nSector, int *ceilZ, int *ceilHit, int *floorZ, int *floorHit, int nDist, unsigned int nMask);
void GetZRange(spritetype *pSprite, int *ceilZ, int *ceilHit, int *floorZ, int *floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0);
void GetZRangeAtXYZ(int x, int y, int z, int nSector, int *ceilZ, int *ceilHit, int *floorZ, int *floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0);
int GetDistToLine(int x1, int y1, int x2, int y2, int x3, int y3);
unsigned int ClipMove(int *x, int *y, int *z, int *nSector, int xv, int yv, int wd, int cd, int fd, unsigned int nMask);
int GetClosestSectors(int nSector, int x, int y, int nDist, short *pSectors, char *pSectBit);

View file

@ -150,7 +150,7 @@ void sub_2541C(int x, int y, int z, short a)
{
int nTile = pSprite->picnum;
int ceilZ, ceilHit, floorZ, floorHit;
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, (pSprite->clipdist<<2)+16, CLIPMASK0);
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, (pSprite->clipdist<<2)+16, CLIPMASK0, PARALLAXCLIP_CEILING|PARALLAXCLIP_FLOOR);
int nTop, nBottom;
GetSpriteExtents(pSprite, &nTop, &nBottom);
int nScale = mulscale((pSprite->yrepeat+((floorZ-nBottom)>>8))*z, yxaspect, 16);

View file

@ -607,7 +607,7 @@ void fakeMoveDude(spritetype *pSprite)
if (sector[nSector].lotag >= 612 && sector[nSector].lotag <= 617)
{
short nSector2 = nSector;
pushmove_old((int32_t*)&predict.at50, (int32_t*)&predict.at54, (int32_t*)&predict.at58, &nSector2, wd, tz, bz, 0x10001);
pushmove_old((int32_t*)&predict.at50, (int32_t*)&predict.at54, (int32_t*)&predict.at58, &nSector2, wd, tz, bz, CLIPMASK0);
if (nSector2 != -1)
nSector = nSector2;
}
@ -670,7 +670,7 @@ void fakeMoveDude(spritetype *pSprite)
pTempSprite->z = predict.at58;
pTempSprite->sectnum = predict.at68;
int ceilZ, ceilHit, floorZ, floorHit;
GetZRange(pTempSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, 0x10001);
GetZRange(pTempSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, CLIPMASK0);
GetSpriteExtents(pTempSprite, &top, &bottom);
if (predict.at73 & 2)
{
@ -710,7 +710,7 @@ void fakeMoveDude(spritetype *pSprite)
{
int floorZ2 = floorZ;
int floorHit2 = floorHit;
GetZRange(pTempSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, pSprite->clipdist<<2, CLIPMASK0);
GetZRange(pTempSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, pSprite->clipdist<<2, CLIPMASK0, PARALLAXCLIP_CEILING|PARALLAXCLIP_FLOOR);
if (bottom <= floorZ && predict.at58-floorZ2 < bz)
{
floorZ = floorZ2;