- WallBreakPosition

This commit is contained in:
Christoph Oelckers 2021-11-24 22:23:58 +01:00
parent d6cd291030
commit de5377cb2c
3 changed files with 17 additions and 17 deletions

View file

@ -729,15 +729,15 @@ bool UserBreakWall(WALLp wp)
return false; return false;
} }
int WallBreakPosition(walltype* wp, int *sectnum, int *x, int *y, int *z, int *ang) int WallBreakPosition(walltype* wp, sectortype** sectp, int *x, int *y, int *z, int *ang)
{ {
int nx,ny; int nx,ny;
int wall_ang; int wall_ang;
wall_ang = NORM_ANGLE(getangle(wp->delta())+512); wall_ang = NORM_ANGLE(getangle(wp->delta())+512);
*sectnum = wp->sector; *sectp = wp->sectorp();
ASSERT(*sectnum >= 0); ASSERT(*sectp);
// midpoint of wall // midpoint of wall
*x = (wp->x + wp->x) >> 1; *x = (wp->x + wp->x) >> 1;
@ -746,7 +746,7 @@ int WallBreakPosition(walltype* wp, int *sectnum, int *x, int *y, int *z, int *a
if (!wp->twoSided()) if (!wp->twoSided())
{ {
// white wall // white wall
*z = (sector[*sectnum].floorz + sector[*sectnum].ceilingz) >> 1; *z = ((*sectp)->floorz + (*sectp)->ceilingz) >> 1;
} }
else else
{ {
@ -757,15 +757,15 @@ int WallBreakPosition(walltype* wp, int *sectnum, int *x, int *y, int *z, int *a
// floor and ceiling meet // floor and ceiling meet
if (next_sect->floorz == next_sect->ceilingz) if (next_sect->floorz == next_sect->ceilingz)
*z = (sector[*sectnum].floorz + sector[*sectnum].ceilingz) >> 1; *z = ((*sectp)->floorz + (*sectp)->ceilingz) >> 1;
else else
// floor is above other sector // floor is above other sector
if (next_sect->floorz < sector[*sectnum].floorz) if (next_sect->floorz < (*sectp)->floorz)
*z = (next_sect->floorz + sector[*sectnum].floorz) >> 1; *z = (next_sect->floorz + (*sectp)->floorz) >> 1;
else else
// ceiling is below other sector // ceiling is below other sector
if (next_sect->ceilingz > sector[*sectnum].ceilingz) if (next_sect->ceilingz > (*sectp)->ceilingz)
*z = (next_sect->ceilingz + sector[*sectnum].ceilingz) >> 1; *z = (next_sect->ceilingz + (*sectp)->ceilingz) >> 1;
} }
*ang = wall_ang; *ang = wall_ang;
@ -776,8 +776,8 @@ int WallBreakPosition(walltype* wp, int *sectnum, int *x, int *y, int *z, int *a
*x += nx; *x += nx;
*y += ny; *y += ny;
updatesectorz(*x,*y,*z,sectnum); updatesectorz(*x,*y,*z,sectp);
if (*sectnum < 0) if (*sectp == nullptr)
{ {
*x = INT32_MAX; // don't spawn shrap, just change wall *x = INT32_MAX; // don't spawn shrap, just change wall
return false; return false;
@ -799,7 +799,7 @@ bool HitBreakWall(WALLp wp, int hit_x, int hit_y, int hit_z, int ang, int type)
//if (hit_x == INT32_MAX) //if (hit_x == INT32_MAX)
{ {
int sectnum; sectortype* sectnum = nullptr;
WallBreakPosition(wp, &sectnum, &hit_x, &hit_y, &hit_z, &ang); WallBreakPosition(wp, &sectnum, &hit_x, &hit_y, &hit_z, &ang);
} }
@ -1030,7 +1030,7 @@ int HitBreakSprite(DSWActor* breakActor, int type)
void DoWallBreakMatch(int match) void DoWallBreakMatch(int match)
{ {
int sectnum; sectortype* sectnum = nullptr;
int x,y,z; int x,y,z;
int wall_ang; int wall_ang;

View file

@ -52,7 +52,7 @@ BREAK_INFOp SetupWallForBreak(WALLp wallp);
BREAK_INFOp SetupSpriteForBreak(DSWActor* actor); BREAK_INFOp SetupSpriteForBreak(DSWActor* actor);
bool HitBreakWall(WALLp wp, int, int, int, int ang, int type); bool HitBreakWall(WALLp wp, int, int, int, int ang, int type);
bool CheckBreakToughness(BREAK_INFOp break_info, int ID); bool CheckBreakToughness(BREAK_INFOp break_info, int ID);
int WallBreakPosition(walltype* hit_wall, int *sectnum, int *x, int *y, int *z, int *ang); int WallBreakPosition(walltype* wp, sectortype** sectp, int* x, int* y, int* z, int* ang);
void SortBreakInfo(void); void SortBreakInfo(void);
void DoWallBreakMatch(int match); void DoWallBreakMatch(int match);

View file

@ -7302,7 +7302,6 @@ void TraverseBreakableWalls(short start_sect, int x, int y, int z, short ang, in
int dist; int dist;
int break_count; int break_count;
int sectnum;
int wall_ang; int wall_ang;
int hit_x,hit_y,hit_z; int hit_x,hit_y,hit_z;
@ -7331,9 +7330,10 @@ void TraverseBreakableWalls(short start_sect, int x, int y, int z, short ang, in
if (dist > radius) if (dist > radius)
continue; continue;
if (WallBreakPosition(&wal, &sectnum, &hit_x, &hit_y, &hit_z, &wall_ang)) sectortype* sectp = nullptr;
if (WallBreakPosition(&wal, &sectp, &hit_x, &hit_y, &hit_z, &wall_ang))
{ {
if (hit_x != INT32_MAX && sectnum >= 0 && FAFcansee(x, y, z, &sector[start_sect], hit_x, hit_y, hit_z, &sector[sectnum])) if (hit_x != INT32_MAX && sectp != nullptr && FAFcansee(x, y, z, &sector[start_sect], hit_x, hit_y, hit_z, sectp))
{ {
HitBreakWall(&wal, INT32_MAX, INT32_MAX, INT32_MAX, ang, 0); HitBreakWall(&wal, INT32_MAX, INT32_MAX, INT32_MAX, ang, 0);