mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-27 09:20:51 +00:00
Blood: fix potential view sprite overflows
This commit is contained in:
parent
557cd7e734
commit
ced8a83331
1 changed files with 58 additions and 1 deletions
|
@ -70,6 +70,9 @@ static void RotateXZ(int *pX, int *, int *pZ, int ang)
|
||||||
|
|
||||||
template<typename T> tspritetype* viewInsertTSprite(spritetype* tsprite, int& spritesortcnt, int nSector, int nStatnum, T const * const pSprite)
|
template<typename T> tspritetype* viewInsertTSprite(spritetype* tsprite, int& spritesortcnt, int nSector, int nStatnum, T const * const pSprite)
|
||||||
{
|
{
|
||||||
|
if (spritesortcnt >= MAXSPRITESONSCREEN)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
int nTSprite = spritesortcnt;
|
int nTSprite = spritesortcnt;
|
||||||
tspritetype *pTSprite = &tsprite[nTSprite];
|
tspritetype *pTSprite = &tsprite[nTSprite];
|
||||||
memset(pTSprite, 0, sizeof(tspritetype));
|
memset(pTSprite, 0, sizeof(tspritetype));
|
||||||
|
@ -95,7 +98,7 @@ template<typename T> tspritetype* viewInsertTSprite(spritetype* tsprite, int& sp
|
||||||
return pTSprite;
|
return pTSprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int effectDetail[] = {
|
static const int effectDetail[kViewEffectMax] = {
|
||||||
4, 4, 4, 4, 0, 0, 0, 0, 0, 1, 4, 4, 0, 0, 0, 1, 0, 0, 0
|
4, 4, 4, 4, 0, 0, 0, 0, 0, 1, 4, 4, 0, 0, 0, 1, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -134,6 +137,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
int ang = (PlayClock*2048)/120;
|
int ang = (PlayClock*2048)/120;
|
||||||
int nRand1 = dword_172CE0[i][0];
|
int nRand1 = dword_172CE0[i][0];
|
||||||
int nRand2 = dword_172CE0[i][1];
|
int nRand2 = dword_172CE0[i][1];
|
||||||
|
@ -157,6 +163,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
int top, bottom;
|
int top, bottom;
|
||||||
GetSpriteExtents(pTSprite, &top, &bottom);
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
pNSprite->shade = -128;
|
pNSprite->shade = -128;
|
||||||
pNSprite->pal = 0;
|
pNSprite->pal = 0;
|
||||||
pNSprite->z = top;
|
pNSprite->z = top;
|
||||||
|
@ -170,6 +179,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectTesla:
|
case kViewEffectTesla:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
pNSprite->z = pTSprite->z;
|
pNSprite->z = pTSprite->z;
|
||||||
pNSprite->cstat |= 2;
|
pNSprite->cstat |= 2;
|
||||||
pNSprite->shade = -128;
|
pNSprite->shade = -128;
|
||||||
|
@ -181,6 +193,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectShoot:
|
case kViewEffectShoot:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
pNSprite->shade = -128;
|
pNSprite->shade = -128;
|
||||||
pNSprite->pal = 0;
|
pNSprite->pal = 0;
|
||||||
pNSprite->xrepeat = pNSprite->yrepeat = 64;
|
pNSprite->xrepeat = pNSprite->yrepeat = 64;
|
||||||
|
@ -190,6 +205,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectReflectiveBall:
|
case kViewEffectReflectiveBall:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
pNSprite->shade = 26;
|
pNSprite->shade = 26;
|
||||||
pNSprite->pal = 0;
|
pNSprite->pal = 0;
|
||||||
pNSprite->cstat |= 2;
|
pNSprite->cstat |= 2;
|
||||||
|
@ -200,6 +218,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectPhase:
|
case kViewEffectPhase:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
int top, bottom;
|
int top, bottom;
|
||||||
GetSpriteExtents(pTSprite, &top, &bottom);
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
||||||
pNSprite->shade = 26;
|
pNSprite->shade = 26;
|
||||||
|
@ -225,6 +246,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
{
|
{
|
||||||
int nSector = pTSprite->sectnum;
|
int nSector = pTSprite->sectnum;
|
||||||
auto pNSprite = viewInsertTSprite<tspritetype>(tsprite, spritesortcnt, nSector, 32767, NULL);
|
auto pNSprite = viewInsertTSprite<tspritetype>(tsprite, spritesortcnt, nSector, 32767, NULL);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
int nLen = 128+(i<<7);
|
int nLen = 128+(i<<7);
|
||||||
int x = MulScale(nLen, Cos(nAng), 30);
|
int x = MulScale(nLen, Cos(nAng), 30);
|
||||||
pNSprite->x = pTSprite->x + x;
|
pNSprite->x = pTSprite->x + x;
|
||||||
|
@ -249,6 +273,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectFlame:
|
case kViewEffectFlame:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
pNSprite->shade = -128;
|
pNSprite->shade = -128;
|
||||||
pNSprite->z = pTSprite->z;
|
pNSprite->z = pTSprite->z;
|
||||||
pNSprite->picnum = 908;
|
pNSprite->picnum = 908;
|
||||||
|
@ -259,6 +286,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectSmokeHigh:
|
case kViewEffectSmokeHigh:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
int top, bottom;
|
int top, bottom;
|
||||||
GetSpriteExtents(pTSprite, &top, &bottom);
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
||||||
pNSprite->z = top;
|
pNSprite->z = top;
|
||||||
|
@ -275,6 +305,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectSmokeLow:
|
case kViewEffectSmokeLow:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
int top, bottom;
|
int top, bottom;
|
||||||
GetSpriteExtents(pTSprite, &top, &bottom);
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
||||||
pNSprite->z = bottom;
|
pNSprite->z = bottom;
|
||||||
|
@ -291,6 +324,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectTorchHigh:
|
case kViewEffectTorchHigh:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
int top, bottom;
|
int top, bottom;
|
||||||
GetSpriteExtents(pTSprite, &top, &bottom);
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
||||||
pNSprite->z = top;
|
pNSprite->z = top;
|
||||||
|
@ -302,6 +338,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectTorchLow:
|
case kViewEffectTorchLow:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
int top, bottom;
|
int top, bottom;
|
||||||
GetSpriteExtents(pTSprite, &top, &bottom);
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
||||||
pNSprite->z = bottom;
|
pNSprite->z = bottom;
|
||||||
|
@ -315,6 +354,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
if (r_shadows)
|
if (r_shadows)
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
pNSprite->z = getflorzofslope(pTSprite->sectnum, pNSprite->x, pNSprite->y);
|
pNSprite->z = getflorzofslope(pTSprite->sectnum, pNSprite->x, pNSprite->y);
|
||||||
pNSprite->shade = 127;
|
pNSprite->shade = 127;
|
||||||
pNSprite->cstat |= 2;
|
pNSprite->cstat |= 2;
|
||||||
|
@ -331,6 +373,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectFlareHalo:
|
case kViewEffectFlareHalo:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
pNSprite->shade = -128;
|
pNSprite->shade = -128;
|
||||||
pNSprite->pal = 2;
|
pNSprite->pal = 2;
|
||||||
pNSprite->cstat |= 2;
|
pNSprite->cstat |= 2;
|
||||||
|
@ -343,6 +388,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectCeilGlow:
|
case kViewEffectCeilGlow:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
sectortype *pSector = §or[pTSprite->sectnum];
|
sectortype *pSector = §or[pTSprite->sectnum];
|
||||||
pNSprite->x = pTSprite->x;
|
pNSprite->x = pTSprite->x;
|
||||||
pNSprite->y = pTSprite->y;
|
pNSprite->y = pTSprite->y;
|
||||||
|
@ -359,6 +407,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectFloorGlow:
|
case kViewEffectFloorGlow:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
sectortype *pSector = §or[pTSprite->sectnum];
|
sectortype *pSector = §or[pTSprite->sectnum];
|
||||||
pNSprite->x = pTSprite->x;
|
pNSprite->x = pTSprite->x;
|
||||||
pNSprite->y = pTSprite->y;
|
pNSprite->y = pTSprite->y;
|
||||||
|
@ -376,6 +427,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
case kViewEffectSpear:
|
case kViewEffectSpear:
|
||||||
{
|
{
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
pNSprite->z = pTSprite->z;
|
pNSprite->z = pTSprite->z;
|
||||||
if (gDetail > 1)
|
if (gDetail > 1)
|
||||||
pNSprite->cstat |= 514;
|
pNSprite->cstat |= 514;
|
||||||
|
@ -393,6 +447,9 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
||||||
const int nTile = weaponIcon.nTile;
|
const int nTile = weaponIcon.nTile;
|
||||||
if (nTile < 0) break;
|
if (nTile < 0) break;
|
||||||
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
|
||||||
|
if (!pNSprite)
|
||||||
|
break;
|
||||||
|
|
||||||
pNSprite->x = pTSprite->x;
|
pNSprite->x = pTSprite->x;
|
||||||
pNSprite->y = pTSprite->y;
|
pNSprite->y = pTSprite->y;
|
||||||
pNSprite->z = pTSprite->z-(32<<8);
|
pNSprite->z = pTSprite->z-(32<<8);
|
||||||
|
|
Loading…
Reference in a new issue