mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-19 15:40:58 +00:00
- inlines for validating sector and wall indices.
This commit is contained in:
parent
2840b5f25d
commit
eeaa7f98f0
4 changed files with 17 additions and 7 deletions
|
@ -211,6 +211,16 @@ EXTERN int32_t Numsprites;
|
|||
EXTERN int16_t numsectors, numwalls;
|
||||
EXTERN int32_t display_mirror;
|
||||
|
||||
inline bool validSectorIndex(int sectnum)
|
||||
{
|
||||
return sectnum >= 0 && sectnum < numsectors;
|
||||
}
|
||||
|
||||
inline bool validWallIndex(int wallnum)
|
||||
{
|
||||
return wallnum >= 0 && wallnum < numwalls;
|
||||
}
|
||||
|
||||
EXTERN int32_t randomseed;
|
||||
|
||||
EXTERN uint8_t paletteloaded;
|
||||
|
|
|
@ -217,7 +217,7 @@ inline void clipmove_tweak_pos(const vec3_t *pos, int32_t gx, int32_t gy, int32_
|
|||
// Returns: should clip?
|
||||
static int cliptestsector(int const dasect, int const nextsect, int32_t const flordist, int32_t const ceildist, vec2_t const pos, int32_t const posz)
|
||||
{
|
||||
assert((unsigned)dasect < (unsigned)numsectors && (unsigned)nextsect < (unsigned)numsectors);
|
||||
assert(validSectorIndex(dasect) && validSectorIndex(nextsect));
|
||||
|
||||
auto const sec2 = (usectorptr_t)§or[nextsect];
|
||||
|
||||
|
|
|
@ -704,7 +704,7 @@ void initspritelists(void)
|
|||
// "Inside details" for the idea behind the algorithm.
|
||||
int32_t inside_ps(int32_t x, int32_t y, int16_t sectnum)
|
||||
{
|
||||
if (sectnum >= 0 && sectnum < numsectors)
|
||||
if (validSectorIndex(sectnum))
|
||||
{
|
||||
int32_t cnt = 0;
|
||||
auto wal = (uwallptr_t)&wall[sector[sectnum].wallptr];
|
||||
|
@ -730,7 +730,7 @@ int32_t inside_ps(int32_t x, int32_t y, int16_t sectnum)
|
|||
}
|
||||
int32_t inside_old(int32_t x, int32_t y, int16_t sectnum)
|
||||
{
|
||||
if (sectnum >= 0 && sectnum < numsectors)
|
||||
if (validSectorIndex(sectnum))
|
||||
{
|
||||
uint32_t cnt = 0;
|
||||
auto wal = (uwallptr_t)&wall[sector[sectnum].wallptr];
|
||||
|
@ -774,7 +774,7 @@ int32_t inside(int32_t x, int32_t y, int sectnum)
|
|||
default:
|
||||
return inside_old(x, y, sectnum);
|
||||
}
|
||||
if ((unsigned)sectnum < (unsigned)numsectors)
|
||||
if (validSectorIndex(sectnum))
|
||||
{
|
||||
uint32_t cnt1 = 0, cnt2 = 0;
|
||||
|
||||
|
@ -1433,7 +1433,7 @@ void updatesectorneighbor(int32_t const x, int32_t const y, int * const sectnum,
|
|||
{
|
||||
int const initialsectnum = *sectnum;
|
||||
|
||||
if ((unsigned)initialsectnum < (unsigned)numsectors && getsectordist({x, y}, initialsectnum) <= initialMaxDistance)
|
||||
if (validSectorIndex(initialsectnum) && getsectordist({x, y}, initialsectnum) <= initialMaxDistance)
|
||||
{
|
||||
if (inside_p(x, y, initialsectnum))
|
||||
return;
|
||||
|
@ -1477,7 +1477,7 @@ void updatesectorneighborz(int32_t const x, int32_t const y, int32_t const z, in
|
|||
|
||||
uint32_t const correctedsectnum = (unsigned)*sectnum;
|
||||
|
||||
if (correctedsectnum < (unsigned)numsectors && getsectordist({x, y}, correctedsectnum) <= initialMaxDistance)
|
||||
if (validSectorIndex(correctedsectnum) && getsectordist({x, y}, correctedsectnum) <= initialMaxDistance)
|
||||
{
|
||||
int32_t cz, fz;
|
||||
getzsofslope(correctedsectnum, x, y, &cz, &fz);
|
||||
|
|
|
@ -507,4 +507,4 @@ void setWallSectors()
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue