mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +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
|
||||
|
||||
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)
|
||||
{
|
||||
int nXSector = sector[nSector].extra;
|
||||
|
@ -5779,6 +5764,8 @@ void actProcessSprites(void)
|
|||
if (pSprite->type == kThingDroppedLifeLeech && pXSprite->target == -1) {
|
||||
int nOwner = actOwnerIdToSpriteId(pSprite->owner);
|
||||
spritetype *pOwner = &sprite[nOwner];
|
||||
if (!IsPlayerSprite(pOwner))
|
||||
continue;
|
||||
PLAYER *pPlayer = &gPlayer[pOwner->type - kDudePlayer1];
|
||||
PLAYER *pPlayer2 = NULL;
|
||||
if (IsPlayerSprite(pSprite2))
|
||||
|
|
|
@ -179,22 +179,29 @@ extern int gDudeDrag;
|
|||
extern short gAffectedSectors[kMaxSectors];
|
||||
extern short gAffectedXWalls[kMaxXWalls];
|
||||
|
||||
#ifdef POLYMER
|
||||
extern
|
||||
#endif
|
||||
|
||||
inline bool IsPlayerSprite(spritetype const * const pSprite)
|
||||
template<typename T> bool IsPlayerSprite(T const * const pSprite)
|
||||
{
|
||||
if (pSprite->type >= kDudePlayer1 && pSprite->type <= kDudePlayer8)
|
||||
return 1;
|
||||
return 0;
|
||||
return pSprite->type >= kDudePlayer1 && pSprite->type <= kDudePlayer8;
|
||||
}
|
||||
|
||||
template<typename T> bool IsDudeSprite(T const * const pSprite)
|
||||
{
|
||||
if (pSprite->type >= kDudeBase && pSprite->type < kDudeMax)
|
||||
return 1;
|
||||
return 0;
|
||||
return pSprite->type >= kDudeBase && pSprite->type < kDudeMax;
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -208,9 +215,6 @@ void actAddGameLight(int lightRadius, int spriteNum, int zOffset, int lightRange
|
|||
void actDoLight(int spriteNum);
|
||||
#endif
|
||||
|
||||
bool IsItemSprite(spritetype *pSprite);
|
||||
bool IsWeaponSprite(spritetype *pSprite);
|
||||
bool IsAmmoSprite(spritetype *pSprite);
|
||||
bool IsUnderwaterSector(int nSector);
|
||||
int actSpriteOwnerToSpriteId(spritetype *pSprite);
|
||||
void actPropagateSpriteOwner(spritetype *pTarget, spritetype *pSource);
|
||||
|
|
|
@ -374,7 +374,7 @@ void FinishHim(int nSprite) // 13
|
|||
spritetype* pSprite = &sprite[nSprite];
|
||||
int nXSprite = pSprite->extra;
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -2322,7 +2322,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
|
|||
else
|
||||
{
|
||||
int top, bottom;
|
||||
GetSpriteExtents((spritetype *)pTSprite, &top, &bottom);
|
||||
GetSpriteExtents(pTSprite, &top, &bottom);
|
||||
if (getflorzofslope(pTSprite->sectnum, pTSprite->x, pTSprite->y) > bottom)
|
||||
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->picnum = 2272 + 2*pTXSprite->respawnPending;
|
||||
pTSprite->cstat &= ~514;
|
||||
if (((IsItemSprite((spritetype *)pTSprite) || IsAmmoSprite((spritetype *)pTSprite)) && gGameOptions.nItemSettings == 2)
|
||||
|| (IsWeaponSprite((spritetype *)pTSprite) && gGameOptions.nWeaponSettings == 3))
|
||||
if (((IsItemSprite(pTSprite) || IsAmmoSprite(pTSprite)) && gGameOptions.nItemSettings == 2)
|
||||
|| (IsWeaponSprite(pTSprite) && gGameOptions.nWeaponSettings == 3))
|
||||
{
|
||||
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 (powerupCheck(gView, kPwUpBeastVision) > 0) pTSprite->shade = -128;
|
||||
|
||||
if (IsPlayerSprite((spritetype *)pTSprite)) {
|
||||
if (IsPlayerSprite(pTSprite)) {
|
||||
PLAYER *pPlayer = &gPlayer[pTSprite->type-kDudePlayer1];
|
||||
if (powerupCheck(pPlayer, kPwUpShadowCloak) && !powerupCheck(gView, kPwUpBeastVision)) {
|
||||
pTSprite->cstat |= 2;
|
||||
|
@ -3561,7 +3561,7 @@ void viewDrawScreen(bool sceneonly)
|
|||
viewDrawInterface(delta);
|
||||
int zn = ((gView->zWeapon-gView->zView-(12<<8))>>7)+220;
|
||||
PLAYER *pPSprite = &gPlayer[gMe->pSprite->type-kDudePlayer1];
|
||||
if (pPSprite->hand == 1)
|
||||
if (IsPlayerSprite(gMe->pSprite) && pPSprite->hand == 1)
|
||||
{
|
||||
//static int lastClock;
|
||||
gChoke.sub_84110(160, zn);
|
||||
|
|
Loading…
Reference in a new issue