- some wall[] replaced.

This commit is contained in:
Christoph Oelckers 2021-11-21 17:10:38 +01:00
parent 378bf40143
commit 3f46507313
3 changed files with 28 additions and 24 deletions

View file

@ -148,12 +148,12 @@ bool CheckProximityPoint(int nX1, int nY1, int nZ1, int nX2, int nY2, int nZ2, i
return 1; return 1;
} }
bool CheckProximityWall(int nWall, int x, int y, int nDist) bool CheckProximityWall(walltype* pWall, int x, int y, int nDist)
{ {
int x1 = wall[nWall].x; int x1 = pWall->x;
int y1 = wall[nWall].y; int y1 = pWall->y;
int x2 = wall[wall[nWall].point2].x; int x2 = pWall->point2Wall()->x;
int y2 = wall[wall[nWall].point2].y; int y2 = pWall->point2Wall()->y;
nDist <<= 4; nDist <<= 4;
if (x1 < x2) if (x1 < x2)
{ {
@ -742,7 +742,7 @@ BitArray GetClosestSpriteSectors(int nSector, int x, int y, int nDist, TArray<in
{ {
if (search.Check(nNextSector)) // if we've already checked this sector, skip. This is bad, therefore only in compat mode. if (search.Check(nNextSector)) // if we've already checked this sector, skip. This is bad, therefore only in compat mode.
continue; continue;
withinRange = CheckProximityWall(wal.point2, x, y, nDist); withinRange = CheckProximityWall(wal.point2Wall(), x, y, nDist);
} }
else // new method using proper math and no bad shortcut. else // new method using proper math and no bad shortcut.
{ {

View file

@ -55,7 +55,7 @@ bool FindSector(int nX, int nY, int nZ, int *nSector);
bool FindSector(int nX, int nY, int *nSector); bool FindSector(int nX, int nY, int *nSector);
bool CheckProximity(DBloodActor *pSprite, int nX, int nY, int nZ, int nSector, int nDist); bool CheckProximity(DBloodActor *pSprite, int nX, int nY, int nZ, int nSector, int nDist);
bool CheckProximityPoint(int nX1, int nY1, int nZ1, int nX2, int nY2, int nZ2, int nDist); 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); bool CheckProximityWall(walltype* nWall, int x, int y, int nDist);
int GetWallAngle(walltype* pWall); int GetWallAngle(walltype* pWall);
void GetWallNormal(walltype* pWall, 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); 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);

View file

@ -2554,17 +2554,18 @@ void useObjResizer(DBloodActor* sourceactor, int targType, int targIndex, DBlood
break; break;
} }
case OBJ_WALL: case OBJ_WALL:
auto pWall = &wall[targIndex];
if (valueIsBetween(pXSource->data1, -1, 32767)) if (valueIsBetween(pXSource->data1, -1, 32767))
wall[targIndex].xrepeat = ClipRange(pXSource->data1, 0, 255); pWall->xrepeat = ClipRange(pXSource->data1, 0, 255);
if (valueIsBetween(pXSource->data2, -1, 32767)) if (valueIsBetween(pXSource->data2, -1, 32767))
wall[targIndex].yrepeat = ClipRange(pXSource->data2, 0, 255); pWall->yrepeat = ClipRange(pXSource->data2, 0, 255);
if (valueIsBetween(pXSource->data3, -1, 32767)) if (valueIsBetween(pXSource->data3, -1, 32767))
wall[targIndex].xpan_ = (float)ClipRange(pXSource->data3, 0, 255); pWall->xpan_ = (float)ClipRange(pXSource->data3, 0, 255);
if (valueIsBetween(pXSource->data4, -1, 65535)) if (valueIsBetween(pXSource->data4, -1, 65535))
wall[targIndex].ypan_ = (float)ClipRange(pXSource->data4, 0, 255); pWall->ypan_ = (float)ClipRange(pXSource->data4, 0, 255);
break; break;
} }
} }
@ -3543,42 +3544,45 @@ void useSeqSpawnerGen(DBloodActor* sourceactor, int objType, int index, DBloodAc
return; return;
case OBJ_WALL: case OBJ_WALL:
if (pXSource->data2 <= 0) {
auto pWall = &wall[index];
if (pXSource->data2 <= 0)
{ {
if (pXSource->data3 == 3 || pXSource->data3 == 1) if (pXSource->data3 == 3 || pXSource->data3 == 1)
seqKill(0, index); seqKill(0, index);
if ((pXSource->data3 == 3 || pXSource->data3 == 2) && (wall[index].cstat & CSTAT_WALL_MASKED)) if ((pXSource->data3 == 3 || pXSource->data3 == 2) && (pWall->cstat & CSTAT_WALL_MASKED))
seqKill(4, index); seqKill(4, index);
} }
else else
{ {
if (pXSource->data3 == 3 || pXSource->data3 == 1) if (pXSource->data3 == 3 || pXSource->data3 == 1)
seqSpawn(pXSource->data2, SS_WALL, index, -1); seqSpawn(pXSource->data2, SS_WALL, index, -1);
if (pXSource->data3 == 3 || pXSource->data3 == 2) { if (pXSource->data3 == 3 || pXSource->data3 == 2) {
if (wall[index].nextwall < 0) { if (pWall->nextwall < 0) {
if (pXSource->data3 == 3) if (pXSource->data3 == 3)
seqSpawn(pXSource->data2, SS_WALL, index, -1); seqSpawn(pXSource->data2, SS_WALL, index, -1);
} else { }
if (!(wall[index].cstat & CSTAT_WALL_MASKED)) else {
wall[index].cstat |= CSTAT_WALL_MASKED; if (!(pWall->cstat & CSTAT_WALL_MASKED))
pWall->cstat |= CSTAT_WALL_MASKED;
seqSpawn(pXSource->data2, SS_MASKED, index, -1); seqSpawn(pXSource->data2, SS_MASKED, index, -1);
} }
} }
if (pXSource->data4 > 0) if (pXSource->data4 > 0)
{ {
int cx, cy, cz; int cx, cy, cz;
cx = (wall[index].x + wall[wall[index].point2].x) >> 1; cx = (pWall->x + pWall->point2Wall()->x) >> 1;
cy = (wall[index].y + wall[wall[index].point2].y) >> 1; cy = (pWall->y + pWall->point2Wall()->y) >> 1;
int nSector = sectorofwall(index); int nSector = sectorofwall(index);
int32_t ceilZ, floorZ; int32_t ceilZ, floorZ;
getzsofslope(nSector, cx, cy, &ceilZ, &floorZ); getzsofslope(nSector, cx, cy, &ceilZ, &floorZ);
int32_t ceilZ2, floorZ2; int32_t ceilZ2, floorZ2;
getzsofslope(wall[index].nextsector, cx, cy, &ceilZ2, &floorZ2); getzsofslope(pWall->nextsector, cx, cy, &ceilZ2, &floorZ2);
ceilZ = ClipLow(ceilZ, ceilZ2); ceilZ = ClipLow(ceilZ, ceilZ2);
floorZ = ClipHigh(floorZ, floorZ2); floorZ = ClipHigh(floorZ, floorZ2);
cz = (ceilZ + floorZ) >> 1; cz = (ceilZ + floorZ) >> 1;
@ -3587,7 +3591,7 @@ void useSeqSpawnerGen(DBloodActor* sourceactor, int objType, int index, DBloodAc
} }
} }
return; return;
}
case OBJ_SPRITE: case OBJ_SPRITE:
{ {
auto pSprite = &iactor->s(); auto pSprite = &iactor->s();