mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
use validSectorIndex checks where appropriate.
Let’s hope that this sloppiness doesn’t have negative effects with broken maps. # Conflicts: # source/games/sw/src/sprite.cpp # Conflicts: # source/games/duke/src/prediction.cpp # source/games/duke/src/render.cpp
This commit is contained in:
parent
ae8e642785
commit
999ec3c95a
36 changed files with 86 additions and 91 deletions
|
@ -318,7 +318,7 @@ int32_t insertsprite(int16_t sectnum, int16_t statnum)
|
|||
|
||||
if (newspritenum >= 0)
|
||||
{
|
||||
assert((unsigned)sectnum < MAXSECTORS);
|
||||
assert(validSectorIndex(sectnum));
|
||||
|
||||
do_insertsprite_at_headofsect(newspritenum, sectnum);
|
||||
Numsprites++;
|
||||
|
|
|
@ -39,7 +39,7 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, int *psectnum,
|
|||
short bakcstat;
|
||||
int newdist;
|
||||
|
||||
assert(*psectnum >= 0 && *psectnum < MAXSECTORS);
|
||||
assert(validSectorIndex(*psectnum));
|
||||
|
||||
// Calculate new pos to shoot backwards, using averaged values from the big three.
|
||||
int nx = gi->chaseCamX(ang);
|
||||
|
@ -61,7 +61,7 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, int *psectnum,
|
|||
return false;
|
||||
}
|
||||
|
||||
assert(*psectnum >= 0 && *psectnum < MAXSECTORS);
|
||||
assert(validSectorIndex(*psectnum));
|
||||
|
||||
// If something is in the way, make pp->camera_dist lower if necessary
|
||||
if (abs(nx) + abs(ny) > abs(hx) + abs(hy))
|
||||
|
|
|
@ -48,7 +48,7 @@ class SectIterator
|
|||
public:
|
||||
SectIterator(int stat)
|
||||
{
|
||||
assert(stat >= 0 && stat < MAXSECTORS);
|
||||
assert(validSectorIndex(stat));
|
||||
next = headspritesect[stat];
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
|
||||
void Reset(int stat)
|
||||
{
|
||||
assert(stat >= 0 && stat < MAXSECTORS);
|
||||
assert(validSectorIndex(stat));
|
||||
next = headspritesect[stat];
|
||||
}
|
||||
|
||||
|
|
|
@ -4173,7 +4173,7 @@ static void actKickObject(DBloodActor* kicker, DBloodActor* kicked)
|
|||
static void actTouchFloor(DBloodActor* actor, int nSector)
|
||||
{
|
||||
assert(actor != nullptr);
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
sectortype* pSector = §or[nSector];
|
||||
XSECTOR* pXSector = nullptr;
|
||||
if (pSector->extra > 0) pXSector = &xsector[pSector->extra];
|
||||
|
@ -4583,7 +4583,7 @@ void actAirDrag(DBloodActor* actor, int a2)
|
|||
int wind_x = 0;
|
||||
int wind_y = 0;
|
||||
int nSector = pSprite->sectnum;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
sectortype* pSector = §or[nSector];
|
||||
int nXSector = pSector->extra;
|
||||
if (nXSector > 0)
|
||||
|
@ -4616,7 +4616,7 @@ static Collision MoveThing(DBloodActor* actor)
|
|||
assert(pSprite->type >= kThingBase && pSprite->type < kThingMax);
|
||||
const THINGINFO* pThingInfo = &thingInfo[pSprite->type - kThingBase];
|
||||
int nSector = pSprite->sectnum;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
int top, bottom;
|
||||
Collision lhit;
|
||||
|
||||
|
@ -4635,7 +4635,7 @@ static Collision MoveThing(DBloodActor* actor)
|
|||
assert(nSector >= 0);
|
||||
if (pSprite->sectnum != nSector)
|
||||
{
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
ChangeActorSect(actor, nSector);
|
||||
}
|
||||
|
||||
|
@ -4659,7 +4659,7 @@ static Collision MoveThing(DBloodActor* actor)
|
|||
}
|
||||
else
|
||||
{
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
FindSector(pSprite->x, pSprite->y, pSprite->z, &nSector);
|
||||
}
|
||||
|
||||
|
@ -4838,7 +4838,7 @@ void MoveDude(DBloodActor* actor)
|
|||
int nSector = pSprite->sectnum;
|
||||
int nAiStateType = (pXSprite->aiState) ? pXSprite->aiState->stateType : -1;
|
||||
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
|
||||
if (actor->xvel || actor->yvel)
|
||||
{
|
||||
|
@ -4934,12 +4934,12 @@ void MoveDude(DBloodActor* actor)
|
|||
}
|
||||
else
|
||||
{
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
FindSector(pSprite->x, pSprite->y, pSprite->z, &nSector);
|
||||
}
|
||||
if (pSprite->sectnum != nSector)
|
||||
{
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
XSECTOR* pXSector;
|
||||
int nXSector = sector[pSprite->sectnum].extra;
|
||||
if (nXSector > 0)
|
||||
|
@ -5447,7 +5447,7 @@ int MoveMissile(DBloodActor* actor)
|
|||
updatesector(pos.x, pos.y, &nSector);
|
||||
if (nSector >= 0 && nSector != pSprite->sectnum)
|
||||
{
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
ChangeActorSect(actor, nSector);
|
||||
}
|
||||
CheckLink(actor);
|
||||
|
|
|
@ -149,7 +149,7 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRange)
|
|||
x += MulScale(nRange, Cos(nAngle), 30);
|
||||
y += MulScale(nRange, Sin(nAngle), 30);
|
||||
int nSector = pSprite->sectnum;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
if (!FindSector(x, y, z, &nSector))
|
||||
return false;
|
||||
int floorZ = getflorzofslope(nSector, x, y);
|
||||
|
|
|
@ -279,7 +279,7 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n
|
|||
int y = MulScale(nLen, Sin(nAng), 30);
|
||||
pNSprite->y = pTSprite->y + y;
|
||||
pNSprite->z = pTSprite->z;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
FindSector(pNSprite->x, pNSprite->y, pNSprite->z, &nSector);
|
||||
pNSprite->sectnum = nSector;
|
||||
pNSprite->owner = pTSprite->owner;
|
||||
|
|
|
@ -350,7 +350,7 @@ void EnemyBubble(DBloodActor* actor, int) // 11
|
|||
|
||||
void CounterCheck(DBloodActor*, int nSector) // 12
|
||||
{
|
||||
if (nSector < 0 || nSector >= kMaxSectors) return;
|
||||
if (!validSectorIndex(nSector)) return;
|
||||
if (sector[nSector].type != kSectorCounter) return;
|
||||
if (sector[nSector].extra <= 0) return;
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ void dbCrypt(char *pPtr, int nLength, int nKey)
|
|||
void InsertSpriteSect(int nSprite, int nSector)
|
||||
{
|
||||
assert(nSprite >= 0 && nSprite < kMaxSprites);
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
int nOther = headspritesect[nSector];
|
||||
if (nOther >= 0)
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ void RemoveSpriteSect(int nSprite)
|
|||
{
|
||||
assert(nSprite >= 0 && nSprite < kMaxSprites);
|
||||
int nSector = sprite[nSprite].sectnum;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
int nOther = nextspritesect[nSprite];
|
||||
if (nOther < 0)
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ int DeleteSprite(int nSprite)
|
|||
}
|
||||
assert(sprite[nSprite].statnum >= 0 && sprite[nSprite].statnum < kMaxStatus);
|
||||
RemoveSpriteStat(nSprite);
|
||||
assert(sprite[nSprite].sectnum >= 0 && sprite[nSprite].sectnum < kMaxSectors);
|
||||
assert(validSectorIndex(sprite[nSprite].sectnum));
|
||||
RemoveSpriteSect(nSprite);
|
||||
InsertSpriteStat(nSprite, kMaxStatus);
|
||||
#ifdef NOONE_EXTENSIONS
|
||||
|
@ -227,8 +227,8 @@ int DeleteSprite(int nSprite)
|
|||
int ChangeSpriteSect(int nSprite, int nSector)
|
||||
{
|
||||
assert(nSprite >= 0 && nSprite < kMaxSprites);
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(sprite[nSprite].sectnum >= 0 && sprite[nSprite].sectnum < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
assert(validSectorIndex(sprite[nSprite].sectnum));
|
||||
RemoveSpriteSect(nSprite);
|
||||
InsertSpriteSect(nSprite, nSector);
|
||||
return 0;
|
||||
|
@ -244,7 +244,7 @@ int ChangeSpriteStat(int nSprite, int nStatus)
|
|||
assert(nSprite >= 0 && nSprite < kMaxSprites);
|
||||
assert(nStatus >= 0 && nStatus < kMaxStatus);
|
||||
assert(sprite[nSprite].statnum >= 0 && sprite[nSprite].statnum < kMaxStatus);
|
||||
assert(sprite[nSprite].sectnum >= 0 && sprite[nSprite].sectnum < kMaxSectors);
|
||||
assert(validSectorIndex(sprite[nSprite].sectnum));
|
||||
RemoveSpriteStat(nSprite);
|
||||
InsertSpriteStat(nSprite, nStatus);
|
||||
return 0;
|
||||
|
|
|
@ -197,7 +197,7 @@ void CFX::fxProcess(void)
|
|||
spritetype *pSprite = &actor->s();
|
||||
viewBackupSpriteLoc(actor);
|
||||
int nSector = pSprite->sectnum;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
assert(pSprite->type < kFXMax);
|
||||
FXDATA *pFXData = &gFXData[pSprite->type];
|
||||
actAirDrag(actor, pFXData->drag);
|
||||
|
@ -226,7 +226,7 @@ void CFX::fxProcess(void)
|
|||
}
|
||||
if (nSector != pSprite->sectnum)
|
||||
{
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
ChangeActorSect(actor, nSector);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ HITINFO gHitInfo;
|
|||
|
||||
bool AreSectorsNeighbors(int sect1, int sect2)
|
||||
{
|
||||
assert(sect1 >= 0 && sect1 < kMaxSectors);
|
||||
assert(sect2 >= 0 && sect2 < kMaxSectors);
|
||||
assert(validSectorIndex(sect1));
|
||||
assert(validSectorIndex(sect2));
|
||||
if (sector[sect1].wallnum < sector[sect2].wallnum)
|
||||
{
|
||||
for (int i = 0; i < sector[sect1].wallnum; i++)
|
||||
|
@ -72,7 +72,7 @@ bool AreSectorsNeighbors(int sect1, int sect2)
|
|||
bool FindSector(int nX, int nY, int nZ, int *nSector)
|
||||
{
|
||||
int32_t nZFloor, nZCeil;
|
||||
assert(*nSector >= 0 && *nSector < kMaxSectors);
|
||||
assert(validSectorIndex(*nSector));
|
||||
if (inside(nX, nY, *nSector))
|
||||
{
|
||||
getzsofslope(*nSector, nX, nY, &nZCeil, &nZFloor);
|
||||
|
@ -112,7 +112,7 @@ bool FindSector(int nX, int nY, int nZ, int *nSector)
|
|||
|
||||
bool FindSector(int nX, int nY, int *nSector)
|
||||
{
|
||||
assert(*nSector >= 0 && *nSector < kMaxSectors);
|
||||
assert(validSectorIndex(*nSector));
|
||||
if (inside(nX, nY, *nSector))
|
||||
{
|
||||
return 1;
|
||||
|
@ -405,7 +405,7 @@ int HitScan(DBloodActor *actor, int z, int dx, int dy, int dz, unsigned int nMas
|
|||
gHitInfo.set(&hitData);
|
||||
hitscangoal.x = hitscangoal.y = 0x1ffffff;
|
||||
pSprite->cstat = bakCstat;
|
||||
if (gHitInfo.hitwall >= kMaxWalls || gHitInfo.hitsect >= kMaxSectors)
|
||||
if (gHitInfo.hitwall >= numwalls || gHitInfo.hitsect >= numsectors)
|
||||
return -1;
|
||||
if (gHitInfo.hitactor != nullptr)
|
||||
return 3;
|
||||
|
@ -456,7 +456,7 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
|
|||
pSprite->cstat = bakCstat;
|
||||
while (nNum--)
|
||||
{
|
||||
if (gHitInfo.hitwall >= kMaxWalls || gHitInfo.hitsect >= kMaxSectors)
|
||||
if (gHitInfo.hitwall >= numwalls || gHitInfo.hitsect >= numsectors)
|
||||
return -1;
|
||||
if (nRange && approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y) > nRange)
|
||||
return -1;
|
||||
|
|
|
@ -1697,7 +1697,7 @@ void debrisMove(int listIndex)
|
|||
gPhysSpritesList[listIndex] = nullptr;
|
||||
return;
|
||||
}
|
||||
else if (pSprite->sectnum < 0 || pSprite->sectnum >= kMaxSectors)
|
||||
else if (validSectorIndex(pSprite->sectnum))
|
||||
{
|
||||
gPhysSpritesList[listIndex] = nullptr;
|
||||
return;
|
||||
|
@ -1760,7 +1760,7 @@ void debrisMove(int listIndex)
|
|||
|
||||
if (pSprite->sectnum != nSector)
|
||||
{
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
ChangeActorSect(actor, nSector);
|
||||
nSector = pSprite->sectnum;
|
||||
}
|
||||
|
@ -2883,7 +2883,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, int objIndex, D
|
|||
pXLower = &aLower->x();
|
||||
|
||||
// must be sure we found exact same upper link
|
||||
for (int i = 0; i < kMaxSectors; i++)
|
||||
for (int i = 0; i < numsectors; i++)
|
||||
{
|
||||
auto aUpper = getUpperLink(i);
|
||||
if (aUpper == nullptr || aUpper->x().data1 != pXLower->data1) continue;
|
||||
|
@ -3055,7 +3055,7 @@ void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor)
|
|||
if (aLink)
|
||||
{
|
||||
// must be sure we found exact same upper link
|
||||
for (int i = 0; i < kMaxSectors; i++)
|
||||
for (int i = 0; i < numsectors; i++)
|
||||
{
|
||||
auto aUpper = getUpperLink(i);
|
||||
if (aUpper == nullptr || aUpper->x().data1 != aLink->x().data1) continue;
|
||||
|
@ -9187,7 +9187,7 @@ void clampSprite(DBloodActor* actor, int which)
|
|||
{
|
||||
auto pSprite = &actor->s();
|
||||
int zTop, zBot;
|
||||
if (pSprite->sectnum >= 0 && pSprite->sectnum < kMaxSectors)
|
||||
if (validSectorIndex(pSprite->sectnum))
|
||||
{
|
||||
GetSpriteExtents(pSprite, &zTop, &zBot);
|
||||
if (which & 0x01)
|
||||
|
|
|
@ -1678,7 +1678,7 @@ void playerProcess(PLAYER *pPlayer)
|
|||
nSector = pSprite->sectnum;
|
||||
actDamageSprite(actor, actor, kDamageFall, 500<<4);
|
||||
}
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
ChangeActorSect(actor, nSector);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -366,7 +366,7 @@ static void fakeMoveDude(spritetype *pSprite)
|
|||
int tz = (predict.z-top)/4;
|
||||
int wd = pSprite->clipdist*4;
|
||||
int nSector = predict.sectnum;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
if (predict.xvel || predict.yvel)
|
||||
{
|
||||
if (pPlayer && gNoClip)
|
||||
|
@ -417,7 +417,7 @@ static void fakeMoveDude(spritetype *pSprite)
|
|||
}
|
||||
if (predict.sectnum != nSector)
|
||||
{
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
predict.sectnum = nSector;
|
||||
}
|
||||
bool bUnderwater = 0;
|
||||
|
@ -571,7 +571,7 @@ static void fakeActAirDrag(spritetype *, int num)
|
|||
int xvec = 0;
|
||||
int yvec = 0;
|
||||
int nSector = predict.sectnum;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
sectortype *pSector = §or[nSector];
|
||||
int nXSector = pSector->extra;
|
||||
if (nXSector > 0)
|
||||
|
|
|
@ -261,7 +261,7 @@ void DoSectorPanning(void)
|
|||
int nXSector = panList[i];
|
||||
XSECTOR *pXSector = &xsector[nXSector];
|
||||
int nSector = pXSector->reference;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
sectortype *pSector = §or[nSector];
|
||||
assert(pSector->extra == nXSector);
|
||||
if (pXSector->panAlways || pXSector->busy)
|
||||
|
|
|
@ -130,7 +130,7 @@ void UpdateCeiling(int nXSector, SEQFRAME* pFrame)
|
|||
{
|
||||
assert(nXSector > 0 && nXSector < kMaxXSectors);
|
||||
int nSector = xsector[nXSector].reference;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
sectortype* pSector = §or[nSector];
|
||||
assert(pSector->extra == nXSector);
|
||||
pSector->ceilingpicnum = seqGetTile(pFrame);
|
||||
|
@ -149,7 +149,7 @@ void UpdateFloor(int nXSector, SEQFRAME* pFrame)
|
|||
{
|
||||
assert(nXSector > 0 && nXSector < kMaxXSectors);
|
||||
int nSector = xsector[nXSector].reference;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
sectortype* pSector = §or[nSector];
|
||||
assert(pSector->extra == nXSector);
|
||||
pSector->floorpicnum = seqGetTile(pFrame);
|
||||
|
|
|
@ -1431,7 +1431,7 @@ void OperateTeleport(unsigned int nSector, XSECTOR *pXSector)
|
|||
spritetype *pDest = &nDest->s();
|
||||
assert(pDest->statnum == kStatMarker);
|
||||
assert(pDest->type == kMarkerWarpDest);
|
||||
assert(pDest->sectnum >= 0 && pDest->sectnum < kMaxSectors);
|
||||
assert(validSectorIndex(pDest->sectnum));
|
||||
BloodSectIterator it(nSector);
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
|
@ -2022,7 +2022,7 @@ void trInit(void)
|
|||
pXWall->busy = 65536;
|
||||
}
|
||||
}
|
||||
assert((numsectors >= 0) && (numsectors < kMaxSectors));
|
||||
|
||||
for (int i = 0; i < numsectors; i++)
|
||||
{
|
||||
sectortype *pSector = §or[i];
|
||||
|
|
|
@ -170,7 +170,7 @@ void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsec
|
|||
int vZ = FixedToInt(MulScale(zm, 1280, 3))-(16<<8);
|
||||
int bakCstat = pSprite->cstat;
|
||||
pSprite->cstat &= ~256;
|
||||
assert(*vsectnum >= 0 && *vsectnum < kMaxSectors);
|
||||
assert(validSectorIndex(*vsectnum));
|
||||
FindSector(*pX, *pY, *pZ, vsectnum);
|
||||
int nHSector;
|
||||
int hX, hY;
|
||||
|
@ -204,7 +204,7 @@ void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsec
|
|||
int myclock = PlayClock + MulScale(4, smoothratio, 16);
|
||||
othercameradist = ClipHigh(othercameradist+((myclock-othercameraclock)<<10), 65536);
|
||||
othercameraclock = myclock;
|
||||
assert(*vsectnum >= 0 && *vsectnum < kMaxSectors);
|
||||
assert(validSectorIndex(*vsectnum));
|
||||
FindSector(*pX, *pY, *pZ, vsectnum);
|
||||
pSprite->cstat = bakCstat;
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ void warpInit(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < kMaxSectors; i++)
|
||||
for (int i = 0; i < numsectors; i++)
|
||||
{
|
||||
auto actor = getUpperLink(i);
|
||||
if (actor && actor->hasX())
|
||||
|
@ -171,7 +171,7 @@ void warpInit(void)
|
|||
spritetype *pSprite = &actor->s();
|
||||
XSPRITE *pXSprite = &actor->x();
|
||||
int nLink = pXSprite->data1;
|
||||
for (int j = 0; j < kMaxSectors; j++)
|
||||
for (int j = 0; j < numsectors; j++)
|
||||
{
|
||||
auto actor2 = getLowerLink(j);
|
||||
if (actor2 && actor2->hasX())
|
||||
|
@ -209,7 +209,7 @@ int CheckLink(DBloodActor *actor)
|
|||
aLower = aUpper->GetOwner();
|
||||
assert(aLower);
|
||||
spritetype *pLower = &aLower->s();
|
||||
assert(pLower->sectnum >= 0 && pLower->sectnum < kMaxSectors);
|
||||
assert(validSectorIndex(pLower->sectnum));
|
||||
ChangeActorSect(actor, pLower->sectnum);
|
||||
pSprite->x += pLower->x-pUpper->x;
|
||||
pSprite->y += pLower->y-pUpper->y;
|
||||
|
@ -236,7 +236,7 @@ int CheckLink(DBloodActor *actor)
|
|||
aUpper = aLower->GetOwner();
|
||||
assert(aUpper);
|
||||
spritetype *pUpper = &aUpper->s();
|
||||
assert(pUpper->sectnum >= 0 && pUpper->sectnum < kMaxSectors);
|
||||
assert(validSectorIndex(pUpper->sectnum));
|
||||
ChangeActorSect(actor, pUpper->sectnum);
|
||||
pSprite->x += pUpper->x-pLower->x;
|
||||
pSprite->y += pUpper->y-pLower->y;
|
||||
|
@ -270,7 +270,7 @@ int CheckLink(int *x, int *y, int *z, int *nSector)
|
|||
lower = upper->GetOwner();
|
||||
assert(lower);
|
||||
spritetype *pLower = &lower->s();
|
||||
assert(pLower->sectnum >= 0 && pLower->sectnum < kMaxSectors);
|
||||
assert(validSectorIndex(pLower->sectnum));
|
||||
*nSector = pLower->sectnum;
|
||||
*x += pLower->x-pUpper->x;
|
||||
*y += pLower->y-pUpper->y;
|
||||
|
@ -296,7 +296,7 @@ int CheckLink(int *x, int *y, int *z, int *nSector)
|
|||
upper = lower->GetOwner();
|
||||
assert(upper);
|
||||
spritetype *pUpper = &upper->s();
|
||||
assert(pUpper->sectnum >= 0 && pUpper->sectnum < kMaxSectors);
|
||||
assert(validSectorIndex(pUpper->sectnum));
|
||||
*nSector = pUpper->sectnum;
|
||||
*x += pUpper->x-pLower->x;
|
||||
*y += pUpper->y-pLower->y;
|
||||
|
|
|
@ -2255,7 +2255,7 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f
|
|||
if (callsetsprite) setsprite(actor, s->pos);
|
||||
|
||||
// this was after the slope calls, but we should avoid calling that for invalid sectors.
|
||||
if (s->sectnum < 0 || s->sectnum >= MAXSECTORS)
|
||||
if (!validSectorIndex(s->sectnum));
|
||||
{
|
||||
deletesprite(actor);
|
||||
return false;
|
||||
|
@ -5300,7 +5300,7 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO
|
|||
|
||||
int j = s->sectnum;
|
||||
pushmove(&s->pos, &j, 128, (4 << 8), (4 << 8), CLIPMASK0);
|
||||
if (j != s->sectnum && j >= 0 && j < MAXSECTORS)
|
||||
if (j != s->sectnum && validSectorIndex(j))
|
||||
changeactorsect(actor, j);
|
||||
|
||||
S_PlayActorSound(thud, actor);
|
||||
|
|
|
@ -3048,7 +3048,7 @@ void moveactors_d(void)
|
|||
auto s = act->s;
|
||||
sect = s->sectnum;
|
||||
|
||||
if (s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS)
|
||||
if (s->xrepeat == 0 || !validSectorIndex(sect))
|
||||
{
|
||||
deletesprite(act);
|
||||
continue;
|
||||
|
|
|
@ -2854,7 +2854,7 @@ void moveactors_r(void)
|
|||
auto s = act->s;
|
||||
bool deleteafterexecute = false; // taking a cue here from RedNukem to not run scripts on deleted sprites.
|
||||
|
||||
if( s->xrepeat == 0 || s->sectnum < 0 || s->sectnum >= MAXSECTORS)
|
||||
if( s->xrepeat == 0 || !validSectorIndex(s->sectnum))
|
||||
{
|
||||
deletesprite(act);
|
||||
continue;
|
||||
|
|
|
@ -2117,7 +2117,7 @@ int ParseState::parse(void)
|
|||
break;
|
||||
case concmd_spawn:
|
||||
insptr++;
|
||||
if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
|
||||
if(validSectorIndex(g_sp->sectnum))
|
||||
spawn(g_ac,*insptr);
|
||||
insptr++;
|
||||
break;
|
||||
|
@ -2151,7 +2151,7 @@ int ParseState::parse(void)
|
|||
insptr++;
|
||||
bool weap = fi.spawnweapondebris(g_sp->picnum, dnum);
|
||||
|
||||
if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
|
||||
if(validSectorIndex(g_sp->sectnum))
|
||||
for(j=(*insptr)-1;j>=0;j--)
|
||||
{
|
||||
if(weap)
|
||||
|
@ -2862,7 +2862,7 @@ int ParseState::parse(void)
|
|||
|
||||
lIn = *insptr++;
|
||||
lIn = GetGameVarID(lIn, g_ac, g_p);
|
||||
if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
|
||||
if(validSectorIndex(g_sp->sectnum))
|
||||
lReturn = spawn(g_ac, lIn);
|
||||
|
||||
SetGameVarID(g_iReturnVarID, ActorToScriptIndex(lReturn), g_ac, g_p);
|
||||
|
@ -2872,7 +2872,7 @@ int ParseState::parse(void)
|
|||
{
|
||||
DDukeActor* lReturn = nullptr;
|
||||
insptr++;
|
||||
if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
|
||||
if(validSectorIndex(g_sp->sectnum))
|
||||
lReturn = spawn(g_ac, *insptr);
|
||||
insptr++;
|
||||
SetGameVarID(g_iReturnVarID, ActorToScriptIndex(lReturn), g_ac, g_p);
|
||||
|
@ -3672,7 +3672,7 @@ void LoadActor(DDukeActor *actor, int p, int x)
|
|||
|
||||
s.killit_flag = 0;
|
||||
|
||||
if (actor->s->sectnum < 0 || actor->s->sectnum >= MAXSECTORS)
|
||||
if(!validSectorIndex(actor->s->sectnum))
|
||||
{
|
||||
deletesprite(actor);
|
||||
return;
|
||||
|
@ -3761,7 +3761,7 @@ void execute(DDukeActor *actor,int p,int x)
|
|||
|
||||
s.killit_flag = 0;
|
||||
|
||||
if(actor->s->sectnum < 0 || actor->s->sectnum >= MAXSECTORS)
|
||||
if(!validSectorIndex(actor->s->sectnum))
|
||||
{
|
||||
if(badguy(actor))
|
||||
ps[p].actors_killed++;
|
||||
|
|
|
@ -2900,7 +2900,7 @@ void processinput_d(int snum)
|
|||
s->xvel = clamp(ksqrt((p->pos.x - p->bobposx) * (p->pos.x - p->bobposx) + (p->pos.y - p->bobposy) * (p->pos.y - p->bobposy)), 0, 512);
|
||||
if (p->on_ground) p->bobcounter += p->GetActor()->s->xvel >> 1;
|
||||
|
||||
p->backuppos(ud.clipping == 0 && (p->cursector()->floorpicnum == MIRROR || p->cursectnum < 0 || p->cursectnum >= MAXSECTORS));
|
||||
p->backuppos(ud.clipping == 0 && (p->cursector()->floorpicnum == MIRROR || !validSectorIndex(p->cursectnum)));
|
||||
|
||||
// Shrinking code
|
||||
|
||||
|
|
|
@ -3597,7 +3597,7 @@ void processinput_r(int snum)
|
|||
s->xvel = clamp(ksqrt((p->pos.x - p->bobposx) * (p->pos.x - p->bobposx) + (p->pos.y - p->bobposy) * (p->pos.y - p->bobposy)), 0, 512);
|
||||
if (p->on_ground) p->bobcounter += p->GetActor()->s->xvel >> 1;
|
||||
|
||||
p->backuppos(ud.clipping == 0 && (p->cursector()->floorpicnum == MIRROR || p->cursectnum < 0 || p->cursectnum >= MAXSECTORS));
|
||||
p->backuppos(ud.clipping == 0 && (p->cursector()->floorpicnum == MIRROR || !validSectorIndex(p->cursectnum < 0)));
|
||||
|
||||
// Shrinking code
|
||||
|
||||
|
|
|
@ -273,7 +273,6 @@ void displayrooms(int snum, double smoothratio)
|
|||
videoSetCorrectedAspect();
|
||||
|
||||
auto sect = p->cursector();
|
||||
if (sect == nullptr) return;
|
||||
|
||||
GlobalMapFog = fogactive ? 0x999999 : 0;
|
||||
GlobalFogDensity = fogactive ? 350.f : 0.f;
|
||||
|
|
|
@ -1426,7 +1426,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
|
|||
s->xvel = -(pspr->extra << 2);
|
||||
j = s->sectnum;
|
||||
pushmove(&s->pos, &j, 128L, (4 << 8), (4 << 8), CLIPMASK0);
|
||||
if (j != s->sectnum && j >= 0 && j < MAXSECTORS)
|
||||
if (j != s->sectnum && validSectorIndex(j))
|
||||
changeactorsect(targ, j);
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ void AIAnim::Tick(RunListEvent* ev)
|
|||
|
||||
if (pSpriteB->sectnum != pSprite->sectnum)
|
||||
{
|
||||
if (pSpriteB->sectnum < 0 || pSpriteB->sectnum >= kMaxSectors)
|
||||
if (!validSectorIndex(pSpriteB))
|
||||
{
|
||||
DestroyAnim(pActor);
|
||||
return;
|
||||
|
|
|
@ -174,7 +174,7 @@ void IgniteSprite(DExhumedActor* pActor)
|
|||
|
||||
void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActor* pHitActor, int x, int y, int z, int nSector)
|
||||
{
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
|
||||
bulletInfo *pBulletInfo = &BulletInfo[pBullet->nType];
|
||||
|
||||
|
@ -582,8 +582,6 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
|
|||
{
|
||||
spritetype *pTargetSprite = &pTarget->s();
|
||||
|
||||
// assert(pTargetSprite->sectnum <= kMaxSectors);
|
||||
|
||||
if (pTargetSprite->cstat & 0x101)
|
||||
{
|
||||
sBullet.nType = nType;
|
||||
|
@ -594,7 +592,7 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
|
|||
|
||||
int nHeight = GetActorHeight(pTarget);
|
||||
|
||||
assert(pTargetSprite->sectnum >= 0 && pTargetSprite->sectnum < kMaxSectors);
|
||||
assert(validSectorIndex(pTargetSprite->sectnum));
|
||||
|
||||
BulletHitsSprite(&sBullet, pActor, pTarget, pTargetSprite->x, pTargetSprite->y, pTargetSprite->z - (nHeight >> 1), pTargetSprite->sectnum);
|
||||
DeleteActor(sBullet.pActor);
|
||||
|
|
|
@ -830,7 +830,7 @@ loc_flag:
|
|||
auto t = sPlayerInput[nPlayer].pTarget;
|
||||
// only autoaim if target is in front of the player.
|
||||
auto pTargetSprite = &t->s();
|
||||
assert(pTargetSprite->sectnum < kMaxSectors);
|
||||
assert(validSectorIndex(pTargetSprite->sectnum));
|
||||
int angletotarget = bvectangbam(pTargetSprite->x - pPlayerSprite->x, pTargetSprite->y - pPlayerSprite->y).asbuild();
|
||||
int anglediff = (pPlayerSprite->ang - angletotarget) & 2047;
|
||||
if (anglediff < 512 || anglediff > 1536)
|
||||
|
|
|
@ -214,7 +214,7 @@ void InitLights()
|
|||
|
||||
void AddFlash(int nSector, int x, int y, int z, int val)
|
||||
{
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
auto sectp = §or[nSector];
|
||||
|
||||
int var_28 = 0;
|
||||
|
@ -415,7 +415,7 @@ void UndoFlashes()
|
|||
{
|
||||
case 0:
|
||||
{
|
||||
assert(nIndex >= 0 && nIndex < kMaxSectors);
|
||||
assert(validSectorIndex(nIndex));
|
||||
|
||||
pShade = §or[nIndex].floorshade;
|
||||
break;
|
||||
|
@ -431,7 +431,7 @@ void UndoFlashes()
|
|||
|
||||
case 2:
|
||||
{
|
||||
assert(nIndex >= 0 && nIndex < kMaxSectors);
|
||||
assert(validSectorIndex(nIndex));
|
||||
|
||||
pShade = §or[nIndex].ceilingshade;
|
||||
break;
|
||||
|
|
|
@ -300,7 +300,7 @@ Collision movespritez(DExhumedActor* pActor, int z, int height, int, int clipdis
|
|||
{
|
||||
spritetype* pSprite = &pActor->s();
|
||||
int nSector =pSprite->sectnum;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
|
||||
overridesect = nSector;
|
||||
short edi = nSector;
|
||||
|
@ -457,7 +457,7 @@ Collision movespritez(DExhumedActor* pActor, int z, int height, int, int clipdis
|
|||
{
|
||||
if ((SectDepth[nSector] != 0) || (edi != nSector && (SectFlag[edi] & kSectUnderwater)))
|
||||
{
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
BuildSplash(pActor, nSector);
|
||||
}
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ Collision movesprite(DExhumedActor* pActor, int dx, int dy, int dz, int ceildist
|
|||
int nClipDist = (int8_t)pSprite->clipdist << 2;
|
||||
|
||||
int nSector = pSprite->sectnum;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
|
||||
int floorZ = sector[nSector].floorz;
|
||||
|
||||
|
@ -1015,7 +1015,7 @@ void MoveSector(int nSector, int nAngle, int *nXVel, int *nYVel)
|
|||
|
||||
clipmove(&pos, &nSectorB, -xvect, -yvect, 4 * sp->clipdist, 0, 0, CLIPMASK0);
|
||||
|
||||
if (nSectorB >= 0 && nSectorB < kMaxSectors && nSectorB != nSector) {
|
||||
if (validSectorIndex(nSectorB)) {
|
||||
ChangeActorSect(pActor, nSectorB);
|
||||
}
|
||||
}
|
||||
|
@ -1041,7 +1041,7 @@ void MoveSector(int nSector, int nAngle, int *nXVel, int *nYVel)
|
|||
{
|
||||
if (nSectorB != nSector || nFloorZ >= pSprite->z)
|
||||
{
|
||||
if (nSectorB >= 0 && nSectorB < kMaxSectors) {
|
||||
if (validSectorIndex(nSectorB)) {
|
||||
ChangeActorSect(pActor, nSectorB);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -417,7 +417,7 @@ void BuildTail()
|
|||
MoveQX[i] = x;
|
||||
MoveQZ[i] = z;
|
||||
MoveQY[i] = y;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
MoveQS[i] = nSector;
|
||||
}
|
||||
|
||||
|
@ -748,7 +748,7 @@ void AIQueenHead::Tick(RunListEvent* ev)
|
|||
auto pSprite = &pActor->s();
|
||||
|
||||
int nSector = pSprite->sectnum;
|
||||
assert(nSector >= 0 && nSector < kMaxSectors);
|
||||
assert(validSectorIndex(nSector));
|
||||
|
||||
short nAction = QueenHead.nAction;
|
||||
short nHd;
|
||||
|
@ -941,7 +941,7 @@ void AIQueenHead::Tick(RunListEvent* ev)
|
|||
auto pTSprite = &pTActor->s();
|
||||
if (var_20 != pTSprite->sectnum)
|
||||
{
|
||||
assert(var_20 >= 0 && var_20 < kMaxSectors);
|
||||
assert(validSectorIndex(var_20));
|
||||
ChangeActorSect(pTActor, var_20);
|
||||
}
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
|
|||
mirror[cnt].mstate = m_viewon;
|
||||
|
||||
// Show teleport destination
|
||||
// NOTE: Adding MAXSECTORS lets you draw a room, even if
|
||||
// NOTE: Adding true lets you draw a room, even if
|
||||
// you are outside of it!
|
||||
if (mirror[cnt].mstate != m_viewon)
|
||||
{
|
||||
|
|
|
@ -611,7 +611,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, double smoothratio)
|
|||
mirror[cnt].mstate = m_viewon;
|
||||
|
||||
// Show teleport destination
|
||||
// NOTE: Adding MAXSECTORS lets you draw a room, even if
|
||||
// NOTE: Adding true lets you draw a room, even if
|
||||
// you are outside of it!
|
||||
if (mirror[cnt].mstate == m_viewon)
|
||||
{
|
||||
|
|
|
@ -3285,9 +3285,9 @@ void DoPlayerClimb(PLAYERp pp)
|
|||
|
||||
DoPlayerZrange(pp);
|
||||
|
||||
if (pp->LadderSector < 0 || pp->LadderSector > MAXSECTORS)
|
||||
if (!validSectorIndex(pp->LadderSector))
|
||||
{
|
||||
Printf("Bad ladder sector!\n");
|
||||
Printf("Bad ladder sector %d!\n", pp->LadderSector);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3175,10 +3175,8 @@ int SpawnShrap(DSWActor* parentActor, DSWActor* secondaryActor, int means, BREAK
|
|||
return 0;
|
||||
|
||||
// Don't spawn shrapnel in invalid sectors gosh dern it!
|
||||
if (parent->sectnum < 0 || parent->sectnum >= MAXSECTORS)
|
||||
if (!validSectorIndex(parent->sectnum))
|
||||
{
|
||||
//DSPRINTF(ds,"SpawnShrap: Invalid sector %d, picnum=%d\n",parent->sectnum,parent->picnum);
|
||||
MONO_PRINT(ds);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue