Fix: Ensure 31-bit shifts are unsigned. (#10128)

Shifting a signed 32-bit integer by 31 bits is undefined behaviour.
A few more than necessary are switched to unsigned for consistentency.
This commit is contained in:
PeterN
2022-11-04 07:15:59 +00:00
committed by GitHub
parent accbfd502e
commit f24286a1ae
6 changed files with 92 additions and 92 deletions

View File

@@ -1542,18 +1542,18 @@ enum Modifiers {
* @see SpriteSetup
*/
enum SpriteMasks {
MAX_SPRITES = 1 << SPRITE_WIDTH, ///< Maximum number of sprites that can be loaded at a given time
MAX_SPRITES = 1U << SPRITE_WIDTH, ///< Maximum number of sprites that can be loaded at a given time
SPRITE_MASK = MAX_SPRITES - 1, ///< The mask to for the main sprite
MAX_PALETTES = 1 << PALETTE_WIDTH,
MAX_PALETTES = 1U << PALETTE_WIDTH,
PALETTE_MASK = MAX_PALETTES - 1, ///< The mask for the auxiliary sprite (the one that takes care of recolouring)
};
static_assert( (1 << TRANSPARENT_BIT & SPRITE_MASK) == 0 );
static_assert( (1 << RECOLOUR_BIT & SPRITE_MASK) == 0 );
static_assert( (1U << TRANSPARENT_BIT & SPRITE_MASK) == 0 );
static_assert( (1U << RECOLOUR_BIT & SPRITE_MASK) == 0 );
static_assert( TRANSPARENT_BIT != RECOLOUR_BIT );
static_assert( (1 << TRANSPARENT_BIT & PALETTE_MASK) == 0);
static_assert( (1 << RECOLOUR_BIT & PALETTE_MASK) == 0 );
static_assert( (1U << TRANSPARENT_BIT & PALETTE_MASK) == 0 );
static_assert( (1U << RECOLOUR_BIT & PALETTE_MASK) == 0 );
static const PaletteID PAL_NONE = 0;