K_AnyPowerUpRemaining: return bit mask

This commit is contained in:
James R 2023-11-16 21:05:10 -08:00
parent 8e23d66540
commit 6aa6b8c939
3 changed files with 8 additions and 4 deletions

View file

@ -212,6 +212,8 @@ typedef enum
NUMPOWERUPS = ENDOFPOWERUPS - FIRSTPOWERUP, NUMPOWERUPS = ENDOFPOWERUPS - FIRSTPOWERUP,
} kartitems_t; } kartitems_t;
#define POWERUP_BIT(x) (1 << ((x) - FIRSTPOWERUP))
typedef enum typedef enum
{ {
KSHIELD_NONE = 0, KSHIELD_NONE = 0,

View file

@ -27,17 +27,19 @@ tic_t K_PowerUpRemaining(const player_t* player, kartitems_t powerup)
} }
} }
boolean K_AnyPowerUpRemaining(const player_t* player) UINT32 K_AnyPowerUpRemaining(const player_t* player)
{ {
UINT32 mask = 0;
for (int k = FIRSTPOWERUP; k < ENDOFPOWERUPS; ++k) for (int k = FIRSTPOWERUP; k < ENDOFPOWERUPS; ++k)
{ {
if (K_PowerUpRemaining(player, static_cast<kartitems_t>(k))) if (K_PowerUpRemaining(player, static_cast<kartitems_t>(k)))
{ {
return true; mask |= POWERUP_BIT(k);
} }
} }
return false; return mask;
} }
void K_GivePowerUp(player_t* player, kartitems_t powerup, tic_t time) void K_GivePowerUp(player_t* player, kartitems_t powerup, tic_t time)

View file

@ -9,7 +9,7 @@ extern "C" {
#endif #endif
tic_t K_PowerUpRemaining(const player_t *player, kartitems_t powerup); tic_t K_PowerUpRemaining(const player_t *player, kartitems_t powerup);
boolean K_AnyPowerUpRemaining(const player_t *player); UINT32 K_AnyPowerUpRemaining(const player_t *player); // returns POWERUP_BIT mask
void K_GivePowerUp(player_t *player, kartitems_t powerup, tic_t timer); void K_GivePowerUp(player_t *player, kartitems_t powerup, tic_t timer);
void K_DropPowerUps(player_t *player); void K_DropPowerUps(player_t *player);