mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
Prevent tripbombs from being placed at extreme distances.
Technically, an overflow is still possible, but with unsigned integers it is highly unlikely to satisfy (sum_squares < 290*290) in practice. # Conflicts: # source/duke3d/src/player.cpp
This commit is contained in:
parent
10511c4fee
commit
f3ed580b82
1 changed files with 18 additions and 9 deletions
|
@ -1492,9 +1492,10 @@ static int32_t A_ShootHardcoded(int spriteNum, int projecTile, int shootAng, vec
|
|||
break;
|
||||
|
||||
if (hitData.wall >= 0 && hitData.sect >= 0)
|
||||
if (((hitData.pos.x - startPos.x) * (hitData.pos.x - startPos.x)
|
||||
+ (hitData.pos.y - startPos.y) * (hitData.pos.y - startPos.y))
|
||||
< (290 * 290))
|
||||
{
|
||||
uint32_t xdiff_sq = (hitData.pos.x - startPos.x) * (hitData.pos.x - startPos.x);
|
||||
uint32_t ydiff_sq = (hitData.pos.y - startPos.y) * (hitData.pos.y - startPos.y);
|
||||
if (xdiff_sq + ydiff_sq < (290 * 290))
|
||||
{
|
||||
// ST_2_UNDERWATER
|
||||
if (wall[hitData.wall].nextsector >= 0)
|
||||
|
@ -1506,6 +1507,7 @@ static int32_t A_ShootHardcoded(int spriteNum, int projecTile, int shootAng, vec
|
|||
placeMine = 1;
|
||||
}
|
||||
|
||||
}
|
||||
if (placeMine == 1)
|
||||
{
|
||||
int const tripBombMode = (playerNum < 0) ? 0 :
|
||||
|
@ -4306,12 +4308,15 @@ static void P_ProcessWeapon(int playerNum)
|
|||
if (wall[hitData.wall].overpicnum == BIGFORCE)
|
||||
break;
|
||||
|
||||
uint32_t xdiff_sq, ydiff_sq;
|
||||
int spriteNum = headspritesect[hitData.sect];
|
||||
while (spriteNum >= 0)
|
||||
{
|
||||
if (sprite[spriteNum].picnum == TRIPBOMB && klabs(sprite[spriteNum].z - hitData.pos.z) < ZOFFSET4 &&
|
||||
((sprite[spriteNum].x - hitData.pos.x) * (sprite[spriteNum].x - hitData.pos.x) +
|
||||
(sprite[spriteNum].y - hitData.pos.y) * (sprite[spriteNum].y - hitData.pos.y)) < (290 * 290))
|
||||
xdiff_sq = (sprite[spriteNum].x - hitData.pos.x) * (sprite[spriteNum].x - hitData.pos.x);
|
||||
ydiff_sq = (sprite[spriteNum].y - hitData.pos.y) * (sprite[spriteNum].y - hitData.pos.y);
|
||||
|
||||
if (sprite[spriteNum].picnum == TRIPBOMB && klabs(sprite[spriteNum].z - hitData.pos.z) < ZOFFSET4
|
||||
&& xdiff_sq + ydiff_sq < (290 * 290))
|
||||
break;
|
||||
spriteNum = nextspritesect[spriteNum];
|
||||
}
|
||||
|
@ -4320,8 +4325,11 @@ static void P_ProcessWeapon(int playerNum)
|
|||
if (spriteNum == -1 && hitData.wall >= 0 && (wall[hitData.wall].cstat & 16) == 0)
|
||||
if ((wall[hitData.wall].nextsector >= 0 && sector[wall[hitData.wall].nextsector].lotag <= 2) ||
|
||||
(wall[hitData.wall].nextsector == -1 && sector[hitData.sect].lotag <= 2))
|
||||
if (((hitData.pos.x - pPlayer->pos.x) * (hitData.pos.x - pPlayer->pos.x) +
|
||||
(hitData.pos.y - pPlayer->pos.y) * (hitData.pos.y - pPlayer->pos.y)) < (290 * 290))
|
||||
{
|
||||
xdiff_sq = (hitData.pos.x - pPlayer->pos.x) * (hitData.pos.x - pPlayer->pos.x);
|
||||
ydiff_sq = (hitData.pos.y - pPlayer->pos.y) * (hitData.pos.y - pPlayer->pos.y);
|
||||
|
||||
if (xdiff_sq + ydiff_sq < (290 * 290))
|
||||
{
|
||||
pPlayer->pos.z = pPlayer->opos.z;
|
||||
pPlayer->vel.z = 0;
|
||||
|
@ -4332,6 +4340,7 @@ static void P_ProcessWeapon(int playerNum)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PISTOL_WEAPON:
|
||||
|
@ -5214,7 +5223,7 @@ void P_ProcessInput(int playerNum)
|
|||
|
||||
if (!ud.noclip)
|
||||
pushmove(&pPlayer->pos, &pPlayer->cursectnum, pPlayer->clipdist - 1, (4L<<8), stepHeight, CLIPMASK0);
|
||||
|
||||
|
||||
// Shrinking code
|
||||
|
||||
if (sectorLotag == ST_2_UNDERWATER)
|
||||
|
|
Loading…
Reference in a new issue