SW: Fix NORM_(SPRITE|WALL|SECTOR) macros to use MAX$1 instead of ARRAY_SIZE, which would fail due to the structs not being statically allocated.

Patch prepared by Striker.

git-svn-id: https://svn.eduke32.com/eduke32@6825 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2018-04-11 03:34:03 +00:00
parent 6eeb14a12f
commit 84183c439b
2 changed files with 10 additions and 3 deletions

View file

@ -1057,6 +1057,9 @@ CONSTEXPR size_t logbasenegative(T n)
return n > static_cast<T>(-(native_t)base) ? 1 : 1 + logbase<base>(n / static_cast<T>(-(native_t)base));
}
#define isPow2OrZero(v) (((v) & ((v) - 1)) == 0)
#define isPow2(v) (isPow2OrZero(v) && (v))
#endif

View file

@ -544,9 +544,13 @@ int StdRandomRange(int range);
#define HIT_SECTOR BIT(14)
#define HIT_PLAX_WALL BIT(13)
#define NORM_SPRITE(val) ((val) & (SIZ(sprite) - 1))
#define NORM_WALL(val) ((val) & (SIZ(wall) - 1))
#define NORM_SECTOR(val) ((val) & (SIZ(sector) - 1))
#define NORM_SPRITE(val) ((val) & (MAXSPRITES - 1))
#define NORM_WALL(val) ((val) & (MAXWALLS - 1))
#define NORM_SECTOR(val) ((val) & (MAXSECTORS - 1))
EDUKE32_STATIC_ASSERT(isPow2(MAXSPRITES));
EDUKE32_STATIC_ASSERT(isPow2(MAXWALLS));
EDUKE32_STATIC_ASSERT(isPow2(MAXSECTORS));
// overwritesprite flags
#define OVER_SPRITE_MIDDLE (BIT(0))