const correctness for parameters passed to the updatesector family of functions

git-svn-id: https://svn.eduke32.com/eduke32@7478 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-04-06 06:37:42 +00:00 committed by Christoph Oelckers
parent f50ad3d424
commit 631863ab67
2 changed files with 21 additions and 21 deletions

View file

@ -1154,11 +1154,11 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange
int32_t (*blacklist_sprite_func)(int32_t)) ATTRIBUTE((nonnull(6,7,8))); int32_t (*blacklist_sprite_func)(int32_t)) ATTRIBUTE((nonnull(6,7,8)));
int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1,
int32_t x2, int32_t y2, int32_t z2, int16_t sect2); int32_t x2, int32_t y2, int32_t z2, int16_t sect2);
void updatesector(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3))); void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum) ATTRIBUTE((nonnull(3)));
void updatesectorbreadth(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3))); void updatesectorbreadth(int32_t const x, int32_t const y, int16_t * const sectnum) ATTRIBUTE((nonnull(3)));
void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, void updatesectorexclude(int32_t const x, int32_t const y, int16_t * const sectnum,
const uint8_t *excludesectbitmap) ATTRIBUTE((nonnull(3,4))); const uint8_t * const excludesectbitmap) ATTRIBUTE((nonnull(3,4)));
void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum) ATTRIBUTE((nonnull(4))); void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum) ATTRIBUTE((nonnull(4)));
int32_t inside(int32_t x, int32_t y, int16_t sectnum); int32_t inside(int32_t x, int32_t y, int16_t sectnum);
void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags); void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags);
void setfirstwall(int16_t sectnum, int16_t newfirstwall); void setfirstwall(int16_t sectnum, int16_t newfirstwall);

View file

@ -10964,35 +10964,35 @@ void bfirst_search_try(int16_t * const list, uint8_t * const bitmap, int32_t * c
/* Different "is inside" predicates. /* Different "is inside" predicates.
* NOTE: The redundant bound checks are expected to be optimized away in the * NOTE: The redundant bound checks are expected to be optimized away in the
* inlined code. */ * inlined code. */
static inline int32_t inside_p(int32_t x, int32_t y, int16_t sectnum) static inline bool inside_p(int32_t const x, int32_t const y, int const sectnum)
{ {
return (sectnum>=0 && inside(x, y, sectnum) == 1); return (sectnum>=0 && inside(x, y, sectnum) == 1);
} }
static inline int32_t inside_exclude_p(int32_t x, int32_t y, int16_t i, const uint8_t *excludesectbitmap) static inline bool inside_exclude_p(int32_t const x, int32_t const y, int const sectnum, const uint8_t *excludesectbitmap)
{ {
return (i>=0 && !(excludesectbitmap[i>>3]&(1<<(i&7))) && inside_p(x, y, i)); return (sectnum>=0 && !bitmap_test(excludesectbitmap, sectnum) && inside_p(x, y, sectnum));
} }
/* NOTE: no bound check */ /* NOTE: no bound check */
static inline int32_t inside_z_p(int32_t x, int32_t y, int32_t z, int16_t i) static inline bool inside_z_p(int32_t const x, int32_t const y, int32_t const z, int const sectnum)
{ {
int32_t cz, fz; int32_t cz, fz;
getzsofslope(i, x, y, &cz, &fz); getzsofslope(sectnum, x, y, &cz, &fz);
return (z >= cz && z <= fz && inside_p(x, y, i)); return (z >= cz && z <= fz && inside_p(x, y, sectnum));
} }
#define SET_AND_RETURN(Lval, Rval) do \ #define SET_AND_RETURN(Lval, Rval) \
do \
{ \ { \
(Lval) = (Rval); \ (Lval) = (Rval); \
return; \ return; \
} while (0) } while (0)
// //
// updatesector[z] // updatesector[z]
// //
void updatesector(int32_t x, int32_t y, int16_t *sectnum) void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum)
{ {
if (inside_p(x,y,*sectnum)) if (inside_p(x,y,*sectnum))
return; return;
@ -11019,7 +11019,7 @@ void updatesector(int32_t x, int32_t y, int16_t *sectnum)
*sectnum = -1; *sectnum = -1;
} }
void updatesectorbreadth(int32_t x, int32_t y, int16_t *sectnum) void updatesectorbreadth(int32_t const x, int32_t const y, int16_t * const sectnum)
{ {
static int16_t sectlist[MAXSECTORS]; static int16_t sectlist[MAXSECTORS];
static uint8_t sectbitmap[MAXSECTORS>>3]; static uint8_t sectbitmap[MAXSECTORS>>3];
@ -11049,7 +11049,7 @@ void updatesectorbreadth(int32_t x, int32_t y, int16_t *sectnum)
*sectnum = -1; *sectnum = -1;
} }
void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, const uint8_t *excludesectbitmap) void updatesectorexclude(int32_t const x, int32_t const y, int16_t * const sectnum, const uint8_t * const excludesectbitmap)
{ {
if (inside_exclude_p(x, y, *sectnum, excludesectbitmap)) if (inside_exclude_p(x, y, *sectnum, excludesectbitmap))
return; return;
@ -11079,7 +11079,7 @@ void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, const uint8_t *
// new: if *sectnum >= MAXSECTORS, *sectnum-=MAXSECTORS is considered instead // new: if *sectnum >= MAXSECTORS, *sectnum-=MAXSECTORS is considered instead
// as starting sector and the 'initial' z check is skipped // as starting sector and the 'initial' z check is skipped
// (not initial anymore because it follows the sector updating due to TROR) // (not initial anymore because it follows the sector updating due to TROR)
void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum) void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum)
{ {
if ((uint32_t)(*sectnum) < 2*MAXSECTORS) if ((uint32_t)(*sectnum) < 2*MAXSECTORS)
{ {