Skip to content

Commit

Permalink
Make belt_item_type in to an enum class
Browse files Browse the repository at this point in the history
  • Loading branch information
AJenbo committed Mar 27, 2022
1 parent 82f53c5 commit f4ed81a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Source/controls/plrctrls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ void plrctrls_after_game_logic()
Movement(MyPlayerId);
}

void UseBeltItem(int type)
void UseBeltItem(BeltItemType type)
{
for (int i = 0; i < MAXBELTITEMS; i++) {
Item &item = Players[MyPlayerId].SpdList[i];
Expand All @@ -1517,7 +1517,7 @@ void UseBeltItem(int type)
bool isHealing = isRejuvenation || IsAnyOf(item._iMiscId, IMISC_HEAL, IMISC_FULLHEAL) || item.IsScrollOf(SPL_HEAL);
bool isMana = isRejuvenation || IsAnyOf(item._iMiscId, IMISC_MANA, IMISC_FULLMANA);

if ((type == BLT_HEALING && isHealing) || (type == BLT_MANA && isMana)) {
if ((type == BeltItemType::Healing && isHealing) || (type == BeltItemType::Mana && isMana)) {
UseInvItem(MyPlayerId, INVITEM_BELT_FIRST + i);
break;
}
Expand Down
10 changes: 5 additions & 5 deletions Source/controls/plrctrls.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

namespace devilution {

typedef enum belt_item_type : uint8_t {
BLT_HEALING,
BLT_MANA,
} belt_item_type;
enum class BeltItemType : uint8_t {
Healing,
Mana,
};

enum class ControlTypes : uint8_t {
None,
Expand Down Expand Up @@ -49,7 +49,7 @@ void DetectInputMethod(const SDL_Event &event, const ControllerButtonEvent &game
// Whether the automap is being displayed.
bool IsAutomapActive();

void UseBeltItem(int type);
void UseBeltItem(BeltItemType type);

// Talk to towners, click on inv items, attack, etc.
void PerformPrimaryAction();
Expand Down
4 changes: 2 additions & 2 deletions Source/controls/touch/renderers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ std::optional<VirtualGamepadPotionType> PotionButtonRenderer::GetPotionType()
if (myPlayer.SpdList[i].isEmpty())
continue;

if (potionType == BLT_HEALING) {
if (potionType == BeltItemType::Healing) {
if (id == IMISC_HEAL)
return GAMEPAD_HEALING;
if (id == IMISC_FULLHEAL)
Expand All @@ -376,7 +376,7 @@ std::optional<VirtualGamepadPotionType> PotionButtonRenderer::GetPotionType()
return GAMEPAD_SCROLL_OF_HEALING;
}

if (potionType == BLT_MANA) {
if (potionType == BeltItemType::Mana) {
if (id == IMISC_MANA)
return GAMEPAD_MANA;
if (id == IMISC_FULLMANA)
Expand Down
8 changes: 4 additions & 4 deletions Source/controls/touch/renderers.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class CancelButtonRenderer : public VirtualPadButtonRenderer {

class PotionButtonRenderer : public VirtualPadButtonRenderer {
public:
PotionButtonRenderer(VirtualPadButton *potionButton, belt_item_type potionType)
PotionButtonRenderer(VirtualPadButton *potionButton, BeltItemType potionType)
: VirtualPadButtonRenderer(potionButton)
, potionType(potionType)
{
Expand All @@ -174,7 +174,7 @@ class PotionButtonRenderer : public VirtualPadButtonRenderer {
void RenderPotion(RenderFunction renderFunction, Art &potionArt);

private:
belt_item_type potionType;
BeltItemType potionType;

VirtualGamepadButtonType GetButtonType();
std::optional<VirtualGamepadPotionType> GetPotionType();
Expand All @@ -190,8 +190,8 @@ class VirtualGamepadRenderer {
, secondaryActionButtonRenderer(&virtualGamepad->secondaryActionButton)
, spellActionButtonRenderer(&virtualGamepad->spellActionButton)
, cancelButtonRenderer(&virtualGamepad->cancelButton)
, healthButtonRenderer(&virtualGamepad->healthButton, BLT_HEALING)
, manaButtonRenderer(&virtualGamepad->manaButton, BLT_MANA)
, healthButtonRenderer(&virtualGamepad->healthButton, BeltItemType::Healing)
, manaButtonRenderer(&virtualGamepad->manaButton, BeltItemType::Mana)
{
}

Expand Down
4 changes: 2 additions & 2 deletions Source/miniwin/misc_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ void ProcessGamepadEvents(GameAction &action)
case GameActionType_SEND_KEY:
break;
case GameActionType_USE_HEALTH_POTION:
UseBeltItem(BLT_HEALING);
UseBeltItem(BeltItemType::Healing);
break;
case GameActionType_USE_MANA_POTION:
UseBeltItem(BLT_MANA);
UseBeltItem(BeltItemType::Mana);
break;
case GameActionType_PRIMARY_ACTION:
PerformPrimaryAction();
Expand Down

0 comments on commit f4ed81a

Please sign in to comment.