mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 19:20:46 +00:00
Blood: prevent player struct OOB issues
# Conflicts: # source/blood/src/view.cpp
This commit is contained in:
parent
389ac695de
commit
438fa1b267
4 changed files with 26 additions and 35 deletions
|
@ -2436,21 +2436,6 @@ THINGINFO_EXTRA gThingInfoExtra[] = {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool IsItemSprite(spritetype *pSprite)
|
|
||||||
{
|
|
||||||
return pSprite->type >= kItemBase && pSprite->type < kItemMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsWeaponSprite(spritetype *pSprite)
|
|
||||||
{
|
|
||||||
return pSprite->type >= kItemWeaponBase && pSprite->type < kItemWeaponMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsAmmoSprite(spritetype *pSprite)
|
|
||||||
{
|
|
||||||
return pSprite->type >= kItemAmmoBase && pSprite->type < kItemAmmoMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsUnderwaterSector(int nSector)
|
bool IsUnderwaterSector(int nSector)
|
||||||
{
|
{
|
||||||
int nXSector = sector[nSector].extra;
|
int nXSector = sector[nSector].extra;
|
||||||
|
@ -5779,6 +5764,8 @@ void actProcessSprites(void)
|
||||||
if (pSprite->type == kThingDroppedLifeLeech && pXSprite->target == -1) {
|
if (pSprite->type == kThingDroppedLifeLeech && pXSprite->target == -1) {
|
||||||
int nOwner = actOwnerIdToSpriteId(pSprite->owner);
|
int nOwner = actOwnerIdToSpriteId(pSprite->owner);
|
||||||
spritetype *pOwner = &sprite[nOwner];
|
spritetype *pOwner = &sprite[nOwner];
|
||||||
|
if (!IsPlayerSprite(pOwner))
|
||||||
|
continue;
|
||||||
PLAYER *pPlayer = &gPlayer[pOwner->type - kDudePlayer1];
|
PLAYER *pPlayer = &gPlayer[pOwner->type - kDudePlayer1];
|
||||||
PLAYER *pPlayer2 = NULL;
|
PLAYER *pPlayer2 = NULL;
|
||||||
if (IsPlayerSprite(pSprite2))
|
if (IsPlayerSprite(pSprite2))
|
||||||
|
|
|
@ -179,22 +179,29 @@ extern int gDudeDrag;
|
||||||
extern short gAffectedSectors[kMaxSectors];
|
extern short gAffectedSectors[kMaxSectors];
|
||||||
extern short gAffectedXWalls[kMaxXWalls];
|
extern short gAffectedXWalls[kMaxXWalls];
|
||||||
|
|
||||||
#ifdef POLYMER
|
template<typename T> bool IsPlayerSprite(T const * const pSprite)
|
||||||
extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline bool IsPlayerSprite(spritetype const * const pSprite)
|
|
||||||
{
|
{
|
||||||
if (pSprite->type >= kDudePlayer1 && pSprite->type <= kDudePlayer8)
|
return pSprite->type >= kDudePlayer1 && pSprite->type <= kDudePlayer8;
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> bool IsDudeSprite(T const * const pSprite)
|
template<typename T> bool IsDudeSprite(T const * const pSprite)
|
||||||
{
|
{
|
||||||
if (pSprite->type >= kDudeBase && pSprite->type < kDudeMax)
|
return pSprite->type >= kDudeBase && pSprite->type < kDudeMax;
|
||||||
return 1;
|
}
|
||||||
return 0;
|
|
||||||
|
template<typename T> bool IsItemSprite(T const * const pSprite)
|
||||||
|
{
|
||||||
|
return pSprite->type >= kItemBase && pSprite->type < kItemMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T> bool IsWeaponSprite(T const * const pSprite)
|
||||||
|
{
|
||||||
|
return pSprite->type >= kItemWeaponBase && pSprite->type < kItemWeaponMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T> bool IsAmmoSprite(T const * const pSprite)
|
||||||
|
{
|
||||||
|
return pSprite->type >= kItemAmmoBase && pSprite->type < kItemAmmoMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void actBurnSprite(int nSource, XSPRITE *pXSprite, int nTime)
|
inline void actBurnSprite(int nSource, XSPRITE *pXSprite, int nTime)
|
||||||
|
@ -208,9 +215,6 @@ void actAddGameLight(int lightRadius, int spriteNum, int zOffset, int lightRange
|
||||||
void actDoLight(int spriteNum);
|
void actDoLight(int spriteNum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool IsItemSprite(spritetype *pSprite);
|
|
||||||
bool IsWeaponSprite(spritetype *pSprite);
|
|
||||||
bool IsAmmoSprite(spritetype *pSprite);
|
|
||||||
bool IsUnderwaterSector(int nSector);
|
bool IsUnderwaterSector(int nSector);
|
||||||
int actSpriteOwnerToSpriteId(spritetype *pSprite);
|
int actSpriteOwnerToSpriteId(spritetype *pSprite);
|
||||||
void actPropagateSpriteOwner(spritetype *pTarget, spritetype *pSource);
|
void actPropagateSpriteOwner(spritetype *pTarget, spritetype *pSource);
|
||||||
|
|
|
@ -374,7 +374,7 @@ void FinishHim(int nSprite) // 13
|
||||||
spritetype* pSprite = &sprite[nSprite];
|
spritetype* pSprite = &sprite[nSprite];
|
||||||
int nXSprite = pSprite->extra;
|
int nXSprite = pSprite->extra;
|
||||||
XSPRITE* pXSprite = &xsprite[nXSprite];
|
XSPRITE* pXSprite = &xsprite[nXSprite];
|
||||||
if (playerSeqPlaying(&gPlayer[pSprite->type - kDudePlayer1], 16) && pXSprite->target == gMe->nSprite)
|
if (IsPlayerSprite(pSprite) && playerSeqPlaying(&gPlayer[pSprite->type - kDudePlayer1], 16) && pXSprite->target == gMe->nSprite)
|
||||||
sndStartSample(3313, -1, 1, 0);
|
sndStartSample(3313, -1, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2322,7 +2322,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int top, bottom;
|
int top, bottom;
|
||||||
GetSpriteExtents((spritetype *)pTSprite, &top, &bottom);
|
GetSpriteExtents(pTSprite, &top, &bottom);
|
||||||
if (getflorzofslope(pTSprite->sectnum, pTSprite->x, pTSprite->y) > bottom)
|
if (getflorzofslope(pTSprite->sectnum, pTSprite->x, pTSprite->y) > bottom)
|
||||||
nAnim = 1;
|
nAnim = 1;
|
||||||
}
|
}
|
||||||
|
@ -2406,8 +2406,8 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
|
||||||
pTSprite->shade = -128;
|
pTSprite->shade = -128;
|
||||||
pTSprite->picnum = 2272 + 2*pTXSprite->respawnPending;
|
pTSprite->picnum = 2272 + 2*pTXSprite->respawnPending;
|
||||||
pTSprite->cstat &= ~514;
|
pTSprite->cstat &= ~514;
|
||||||
if (((IsItemSprite((spritetype *)pTSprite) || IsAmmoSprite((spritetype *)pTSprite)) && gGameOptions.nItemSettings == 2)
|
if (((IsItemSprite(pTSprite) || IsAmmoSprite(pTSprite)) && gGameOptions.nItemSettings == 2)
|
||||||
|| (IsWeaponSprite((spritetype *)pTSprite) && gGameOptions.nWeaponSettings == 3))
|
|| (IsWeaponSprite(pTSprite) && gGameOptions.nWeaponSettings == 3))
|
||||||
{
|
{
|
||||||
pTSprite->xrepeat = pTSprite->yrepeat = 48;
|
pTSprite->xrepeat = pTSprite->yrepeat = 48;
|
||||||
}
|
}
|
||||||
|
@ -2544,7 +2544,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
|
||||||
if (pXSector && pXSector->color) pTSprite->pal = pSector->floorpal;
|
if (pXSector && pXSector->color) pTSprite->pal = pSector->floorpal;
|
||||||
if (powerupCheck(gView, kPwUpBeastVision) > 0) pTSprite->shade = -128;
|
if (powerupCheck(gView, kPwUpBeastVision) > 0) pTSprite->shade = -128;
|
||||||
|
|
||||||
if (IsPlayerSprite((spritetype *)pTSprite)) {
|
if (IsPlayerSprite(pTSprite)) {
|
||||||
PLAYER *pPlayer = &gPlayer[pTSprite->type-kDudePlayer1];
|
PLAYER *pPlayer = &gPlayer[pTSprite->type-kDudePlayer1];
|
||||||
if (powerupCheck(pPlayer, kPwUpShadowCloak) && !powerupCheck(gView, kPwUpBeastVision)) {
|
if (powerupCheck(pPlayer, kPwUpShadowCloak) && !powerupCheck(gView, kPwUpBeastVision)) {
|
||||||
pTSprite->cstat |= 2;
|
pTSprite->cstat |= 2;
|
||||||
|
@ -3561,7 +3561,7 @@ void viewDrawScreen(bool sceneonly)
|
||||||
viewDrawInterface(delta);
|
viewDrawInterface(delta);
|
||||||
int zn = ((gView->zWeapon-gView->zView-(12<<8))>>7)+220;
|
int zn = ((gView->zWeapon-gView->zView-(12<<8))>>7)+220;
|
||||||
PLAYER *pPSprite = &gPlayer[gMe->pSprite->type-kDudePlayer1];
|
PLAYER *pPSprite = &gPlayer[gMe->pSprite->type-kDudePlayer1];
|
||||||
if (pPSprite->hand == 1)
|
if (IsPlayerSprite(gMe->pSprite) && pPSprite->hand == 1)
|
||||||
{
|
{
|
||||||
//static int lastClock;
|
//static int lastClock;
|
||||||
gChoke.sub_84110(160, zn);
|
gChoke.sub_84110(160, zn);
|
||||||
|
|
Loading…
Reference in a new issue