- use wall pointers in gib code.

This commit is contained in:
Christoph Oelckers 2021-11-23 19:54:59 +01:00
parent f07fafea9c
commit 2721a59dc4
4 changed files with 16 additions and 37 deletions

View file

@ -519,8 +519,8 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
{
int bakCstat = pWall->cstat;
pWall->cstat &= ~64;
int bakCstat2 = wall[pWall->nextwall].cstat;
wall[pWall->nextwall].cstat &= ~64;
int bakCstat2 = pWall->nextWall()->cstat;
pWall->nextWall()->cstat &= ~64;
gHitInfo.clearObj();
x1 = gHitInfo.hitx;
y1 = gHitInfo.hity;
@ -531,7 +531,7 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
dx, dy, dz << 4, &hitData, CLIPMASK1);
gHitInfo.set(&hitData);
pWall->cstat = bakCstat;
wall[pWall->nextwall].cstat = bakCstat2;
pWall->nextWall()->cstat = bakCstat2;
continue;
}
return 4;

View file

@ -251,25 +251,6 @@ GIBLIST gibList[] = {
{ NULL, 0, gibFleshGargoyle, 5, 0 },
};
void gibCalcWallArea(int a1, int &a2, int &a3, int &a4, int &a5, int &a6, int &a7, int &a8)
{
walltype *pWall = &wall[a1];
a2 = (pWall->x+pWall->point2Wall()->x)>>1;
a3 = (pWall->y+pWall->point2Wall()->y)>>1;
int nSector = sectorofwall(a1);
int32_t ceilZ, floorZ;
getzsofslope(nSector, a2, a3, &ceilZ, &floorZ);
int32_t ceilZ2, floorZ2;
getzsofslope(pWall->nextsector, a2, a3, &ceilZ2, &floorZ2);
ceilZ = ClipLow(ceilZ, ceilZ2);
floorZ = ClipHigh(floorZ, floorZ2);
a7 = floorZ-ceilZ;
a5 = pWall->point2Wall()->x-pWall->x;
a6 = pWall->point2Wall()->y-pWall->y;
a8 = (a7>>8)*approxDist(a5>>4, a6>>4);
a4 = (ceilZ+floorZ)>>1;
}
int ChanceToCount(int a1, int a2)
{
int vb = a2;
@ -445,18 +426,17 @@ void GibSprite(DBloodActor* actor, GIBTYPE nGibType, CGibPosition *pPos, CGibVel
}
}
void GibFX(int nWall, GIBFX * pGFX, int a3, int a4, int a5, int a6, CGibVelocity * pVel)
void GibFX(walltype* pWall, GIBFX * pGFX, int a3, int a4, int a5, int a6, CGibVelocity * pVel)
{
assert(nWall >= 0 && nWall < numwalls);
walltype *pWall = &wall[nWall];
assert(pWall);
int nCount = ChanceToCount(pGFX->chance, pGFX->at9);
int nSector = sectorofwall(nWall);
auto pSector = pWall->sectorp();
for (int i = 0; i < nCount; i++)
{
int r1 = Random(a6);
int r2 = Random(a5);
int r3 = Random(a4);
auto pGib = gFX.fxSpawnActor(pGFX->fxId, nSector, pWall->x+r3, pWall->y+r2, a3+r1, 0);
auto pGib = gFX.fxSpawnActor(pGFX->fxId, pSector, pWall->x+r3, pWall->y+r2, a3+r1, 0);
if (pGib)
{
if (pGFX->at1 < 0)
@ -477,20 +457,19 @@ void GibFX(int nWall, GIBFX * pGFX, int a3, int a4, int a5, int a6, CGibVelocity
}
}
void GibWall(int nWall, GIBTYPE nGibType, CGibVelocity *pVel)
void GibWall(walltype* pWall, GIBTYPE nGibType, CGibVelocity *pVel)
{
assert(nWall >= 0 && nWall < numwalls);
assert(pWall);
assert(nGibType >= 0 && nGibType < kGibMax);
int cx, cy, cz, wx, wy, wz;
walltype *pWall = &wall[nWall];
cx = (pWall->x+pWall->point2Wall()->x)>>1;
cy = (pWall->y+pWall->point2Wall()->y)>>1;
int nSector = sectorofwall(nWall);
auto pSector = pWall->sectorp();
int32_t ceilZ, floorZ;
getzsofslope(nSector, cx, cy, &ceilZ, &floorZ);
getzsofslopeptr(pSector, cx, cy, &ceilZ, &floorZ);
int32_t ceilZ2, floorZ2;
getzsofslope(pWall->nextsector, cx, cy, &ceilZ2, &floorZ2);
getzsofslopeptr(pWall->nextSector(), cx, cy, &ceilZ2, &floorZ2);
ceilZ = ClipLow(ceilZ, ceilZ2);
floorZ = ClipHigh(floorZ, floorZ2);
@ -500,12 +479,12 @@ void GibWall(int nWall, GIBTYPE nGibType, CGibVelocity *pVel)
cz = (ceilZ+floorZ)>>1;
GIBLIST *pGib = &gibList[nGibType];
sfxPlay3DSound(cx, cy, cz, pGib->at10, nSector);
sfxPlay3DSound(cx, cy, cz, pGib->at10, pSector);
for (int i = 0; i < pGib->Kills; i++)
{
GIBFX *pGibFX = &pGib->gibFX[i];
assert(pGibFX->chance > 0);
GibFX(nWall, pGibFX, ceilZ, wx, wy, wz, pVel);
GibFX(pWall, pGibFX, ceilZ, wx, wy, wz, pVel);
}
}

View file

@ -72,5 +72,5 @@ public:
};
void GibSprite(DBloodActor *pSprite, GIBTYPE nGibType, CGibPosition *pPos, CGibVelocity *pVel);
void GibWall(int nWall, GIBTYPE nGibType, CGibVelocity *pVel);
void GibWall(walltype* pWall, GIBTYPE nGibType, CGibVelocity *pVel);
END_BLD_NS

View file

@ -685,7 +685,7 @@ void OperateWall(walltype* pWall, EVENT event) {
CGibVelocity vel(100, 100, 250);
int nType = ClipRange(pXWall->data, 0, 31);
if (nType > 0)
GibWall(wallnum(pWall), (GIBTYPE)nType, &vel);
GibWall(pWall, (GIBTYPE)nType, &vel);
}
}
return;