- Blood: use wall pointers in wall utilities exclusively.

This commit is contained in:
Christoph Oelckers 2021-11-21 09:45:50 +01:00
parent 93cdaee9f0
commit 1fc99d4733
6 changed files with 18 additions and 21 deletions

View file

@ -2596,10 +2596,10 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, int x, int y,
//
//---------------------------------------------------------------------------
int actWallBounceVector(int* x, int* y, int nWall, int a4)
int actWallBounceVector(int* x, int* y, walltype* pWall, int a4)
{
int wx, wy;
GetWallNormal(nWall, &wx, &wy);
GetWallNormal(pWall, &wx, &wy);
int t = DMulScale(*x, wx, *y, wy, 16);
int t2 = mulscale16r(t, a4 + 0x10000);
*x -= MulScale(wx, t2, 16);
@ -4632,8 +4632,7 @@ static Collision MoveThing(DBloodActor* actor)
Collision &coll = actor->hit.hit;
if (coll.type == kHitWall)
{
int nHitWall = coll.index;
actWallBounceVector(&actor->xvel, &actor->yvel, nHitWall, pThingInfo->elastic);
actWallBounceVector(&actor->xvel, &actor->yvel, coll.wall(), pThingInfo->elastic);
switch (pSprite->type)
{
case kThingZombieHead:
@ -4894,8 +4893,7 @@ void MoveDude(DBloodActor* actor)
}
case kHitWall:
{
int nHitWall = coll.index;
walltype* pHitWall = &wall[nHitWall];
walltype* pHitWall = coll.wall();
XWALL* pHitXWall = nullptr;
if (pHitWall->hasX()) pHitXWall = &pHitWall->xw();
@ -4915,7 +4913,7 @@ void MoveDude(DBloodActor* actor)
// ???
}
}
actWallBounceVector((int*)&actor->xvel, (int*)&actor->yvel, nHitWall, 0);
actWallBounceVector((int*)&actor->xvel, (int*)&actor->yvel, pHitWall, 0);
break;
}
}

View file

@ -212,7 +212,7 @@ void TreeToGibCallback(int, int);
bool IsUnderwaterSector(sectortype* pSector);
void actInit();
int actWallBounceVector(int *x, int *y, int nWall, int a4);
int actWallBounceVector(int *x, int *y, walltype* pWall, int a4);
int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5);
void actRadiusDamage(DBloodActor* source, int x, int y, int z, int nSector, int nDist, int a7, int a8, DAMAGE_TYPE a9, int a10, int a11);
DBloodActor *actDropObject(DBloodActor *pSprite, int nType);

View file

@ -63,13 +63,13 @@ struct Collision
return type;
}
walltype* wall()
walltype* wall() const
{
assert(type == kHitWall);
return &::wall[index];
}
sectortype* sector()
sectortype* sector() const
{
assert(type == kHitSector);
return &::sector[index];

View file

@ -290,14 +290,13 @@ int GetWallAngle(walltype* pWall)
return getangle(delta.x, delta.y);
}
void GetWallNormal(int nWall, int *pX, int *pY)
void GetWallNormal(walltype* pWall, int *pX, int *pY)
{
assert(validWallIndex(nWall));
int nWall2 = wall[nWall].point2;
int dX = -(wall[nWall2].y - wall[nWall].y);
dX >>= 4;
int dY = wall[nWall2].x - wall[nWall].x;
dY >>= 4;
auto delta = pWall->delta();
int dX = -delta.y >> 4;
int dY = delta.x >> 4;
int nLength = ksqrt(dX*dX+dY*dY);
if (nLength <= 0)
nLength = 1;

View file

@ -57,7 +57,7 @@ bool CheckProximity(DBloodActor *pSprite, int nX, int nY, int nZ, int nSector, i
bool CheckProximityPoint(int nX1, int nY1, int nZ1, int nX2, int nY2, int nZ2, int nDist);
bool CheckProximityWall(int nWall, int x, int y, int nDist);
int GetWallAngle(walltype* pWall);
void GetWallNormal(int nWall, int *pX, int *pY);
void GetWallNormal(walltype* pWall, 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(DBloodActor *pSprite, int z, int dx, int dy, int dz, unsigned int nMask, int a8);
int VectorScan(DBloodActor *pSprite, int nOffset, int nZOffset, int dx, int dy, int dz, int nRange, int ac);

View file

@ -1695,7 +1695,7 @@ void debrisMove(int listIndex)
return;
}
int top, bottom, i;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
Collision moveHit;
@ -1739,8 +1739,7 @@ void debrisMove(int listIndex)
if (actor->hit.hit.type == kHitWall)
{
moveHit = actor->hit.hit;
i = moveHit.index;
actWallBounceVector(&actor->xvel, &actor->yvel, i, tmpFraction);
actWallBounceVector(&actor->xvel, &actor->yvel, moveHit.wall(), tmpFraction);
}
}
@ -1795,6 +1794,7 @@ void debrisMove(int listIndex)
}
int i;
if ((i = CheckLink(actor)) != 0)
{
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, clipDist, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);