Browse Source

Set underlying type for all the enums

Reduces rg99 binary size by 3 KiB.
pull/5236/head
Gleb Mazovetskiy 4 years ago committed by Anders Jenbo
parent
commit
4cf0053ece
  1. 4
      Source/DiabloUI/settingsmenu.cpp
  2. 4
      Source/DiabloUI/ui_flags.hpp
  3. 2
      Source/DiabloUI/ui_item.h
  4. 2
      Source/control.cpp
  5. 4
      Source/controls/touch/renderers.h
  6. 4
      Source/diablo.h
  7. 2
      Source/effects.h
  8. 2
      Source/engine/actor_position.cpp
  9. 2
      Source/engine/demomode.cpp
  10. 4
      Source/engine/render/automap_render.cpp
  11. 6
      Source/engine/render/dun_render.cpp
  12. 2
      Source/engine/render/text_render.hpp
  13. 2
      Source/hwcursor.cpp
  14. 2
      Source/hwcursor.hpp
  15. 4
      Source/itemdat.h
  16. 4
      Source/misdat.h
  17. 4
      Source/missiles.h
  18. 2
      Source/monstdat.h
  19. 2
      Source/monster.h
  20. 14
      Source/options.h
  21. 2
      Source/panels/ui_panels.hpp
  22. 2
      Source/pfile.h
  23. 2
      Source/platform/switch/docking.cpp
  24. 2
      Source/platform/vita/touch.cpp

4
Source/DiabloUI/settingsmenu.cpp

@ -24,7 +24,7 @@ std::vector<std::unique_ptr<UiItemBase>> vecDialog;
std::vector<OptionEntryBase *> vecOptions; std::vector<OptionEntryBase *> vecOptions;
OptionEntryBase *selectedOption = nullptr; OptionEntryBase *selectedOption = nullptr;
enum class ShownMenuType { enum class ShownMenuType : uint8_t {
Settings, Settings,
ListOption, ListOption,
KeyInput, KeyInput,
@ -37,7 +37,7 @@ char optionDescription[512];
Rectangle rectList; Rectangle rectList;
Rectangle rectDescription; Rectangle rectDescription;
enum class SpecialMenuEntry { enum class SpecialMenuEntry : int8_t {
None = -1, None = -1,
PreviousMenu = -2, PreviousMenu = -2,
UnbindKey = -3, UnbindKey = -3,

4
Source/DiabloUI/ui_flags.hpp

@ -1,10 +1,12 @@
#pragma once #pragma once
#include <cstdint>
#include "utils/enum_traits.h" #include "utils/enum_traits.h"
namespace devilution { namespace devilution {
enum class UiFlags { enum class UiFlags : uint32_t {
// clang-format off // clang-format off
None = 0, None = 0,

2
Source/DiabloUI/ui_item.h

@ -13,7 +13,7 @@
namespace devilution { namespace devilution {
enum class UiType { enum class UiType : uint8_t {
Text, Text,
ArtText, ArtText,
ArtTextButton, ArtTextButton,

2
Source/control.cpp

@ -151,7 +151,7 @@ int sgbPlrTalkTbl;
bool WhisperList[MAX_PLRS]; bool WhisperList[MAX_PLRS];
char panelstr[4][64]; char panelstr[4][64];
enum panel_button_id { enum panel_button_id : uint8_t {
PanelButtonCharinfo, PanelButtonCharinfo,
PanelButtonQlog, PanelButtonQlog,
PanelButtonAutomap, PanelButtonAutomap,

4
Source/controls/touch/renderers.h

@ -11,7 +11,7 @@
namespace devilution { namespace devilution {
enum VirtualGamepadButtonType { enum VirtualGamepadButtonType : uint8_t {
GAMEPAD_ATTACK, GAMEPAD_ATTACK,
GAMEPAD_ATTACKDOWN, GAMEPAD_ATTACKDOWN,
GAMEPAD_TALK, GAMEPAD_TALK,
@ -40,7 +40,7 @@ enum VirtualGamepadButtonType {
GAMEPAD_POTIONDOWN, GAMEPAD_POTIONDOWN,
}; };
enum VirtualGamepadPotionType { enum VirtualGamepadPotionType : uint8_t {
GAMEPAD_HEALING, GAMEPAD_HEALING,
GAMEPAD_MANA, GAMEPAD_MANA,
GAMEPAD_REJUVENATION, GAMEPAD_REJUVENATION,

4
Source/diablo.h

@ -34,7 +34,7 @@ enum clicktype : int8_t {
/** /**
* @brief Specifices what game logic step is currently executed * @brief Specifices what game logic step is currently executed
*/ */
enum class GameLogicStep { enum class GameLogicStep : uint8_t {
None, None,
ProcessPlayers, ProcessPlayers,
ProcessMonsters, ProcessMonsters,
@ -46,7 +46,7 @@ enum class GameLogicStep {
ProcessMissilesTown, ProcessMissilesTown,
}; };
enum class MouseActionType : int { enum class MouseActionType : uint8_t {
None, None,
Walk, Walk,
Spell, Spell,

2
Source/effects.h

@ -13,7 +13,7 @@
namespace devilution { namespace devilution {
enum class HeroSpeech { enum class HeroSpeech : uint8_t {
ChamberOfBoneLore, ChamberOfBoneLore,
HorazonsSanctumLore, HorazonsSanctumLore,
GolemSpellLore, GolemSpellLore,

2
Source/engine/actor_position.cpp

@ -6,7 +6,7 @@ namespace devilution {
namespace { namespace {
enum class VelocityToUse { enum class VelocityToUse : uint8_t {
None, None,
Full, Full,
NegativeFull, NegativeFull,

2
Source/engine/demomode.cpp

@ -19,7 +19,7 @@ namespace devilution {
namespace { namespace {
enum class DemoMsgType { enum class DemoMsgType : uint8_t {
GameTick = 0, GameTick = 0,
Rendering = 1, Rendering = 1,
Message = 2, Message = 2,

4
Source/engine/render/automap_render.cpp

@ -8,12 +8,12 @@
namespace devilution { namespace devilution {
namespace { namespace {
enum class DirectionX { enum class DirectionX : int8_t {
EAST = 1, EAST = 1,
WEST = -1, WEST = -1,
}; };
enum class DirectionY { enum class DirectionY : int8_t {
SOUTH = 1, SOUTH = 1,
NORTH = -1, NORTH = -1,
}; };

6
Source/engine/render/dun_render.cpp

@ -28,7 +28,7 @@ namespace {
* Each tile type has its own encoding but they all encode data in the order * Each tile type has its own encoding but they all encode data in the order
* of bottom-to-top (bottom row first). * of bottom-to-top (bottom row first).
*/ */
enum class TileType { enum class TileType : uint8_t {
/** /**
* 🮆 A 32x32 square. Stored as an array of pixels. * 🮆 A 32x32 square. Stored as an array of pixels.
*/ */
@ -348,12 +348,12 @@ const std::uint32_t LeftFoliageMask[TILE_HEIGHT] = {
0x00000000, 0x00000000,
}; };
enum class TransparencyType { enum class TransparencyType : uint8_t {
Solid, Solid,
Blended, Blended,
}; };
enum class LightType { enum class LightType : uint8_t {
FullyDark, FullyDark,
PartiallyLit, PartiallyLit,
FullyLit, FullyLit,

2
Source/engine/render/text_render.hpp

@ -56,7 +56,7 @@ enum text_color : uint8_t {
*/ */
class DrawStringFormatArg { class DrawStringFormatArg {
public: public:
enum class Type { enum class Type : uint8_t {
StringView, StringView,
Int Int
}; };

2
Source/hwcursor.cpp

@ -27,7 +27,7 @@ CursorInfo CurrentCursorInfo;
#if SDL_VERSION_ATLEAST(2, 0, 0) #if SDL_VERSION_ATLEAST(2, 0, 0)
SDLCursorUniquePtr CurrentCursor; SDLCursorUniquePtr CurrentCursor;
enum class HotpointPosition { enum class HotpointPosition : uint8_t {
TopLeft, TopLeft,
Center, Center,
}; };

2
Source/hwcursor.hpp

@ -31,7 +31,7 @@ inline bool SetHardwareCursorVisible(bool visible)
#endif #endif
} }
enum class CursorType { enum class CursorType : uint8_t {
Unknown, Unknown,
UserInterface, UserInterface,
Game, Game,

4
Source/itemdat.h

@ -322,7 +322,7 @@ enum unique_base_item : int8_t {
UITYPE_INVALID = -1, UITYPE_INVALID = -1,
}; };
enum class ItemSpecialEffect { enum class ItemSpecialEffect : uint32_t {
// clang-format off // clang-format off
None = 0, None = 0,
RandomStealLife = 1 << 1, RandomStealLife = 1 << 1,
@ -350,7 +350,7 @@ enum class ItemSpecialEffect {
NoMana = 1 << 27, NoMana = 1 << 27,
HalfTrapDamage = 1 << 28, HalfTrapDamage = 1 << 28,
TripleDemonDamage = 1 << 30, TripleDemonDamage = 1 << 30,
ZeroResistance = 1 << 31, ZeroResistance = 1U << 31,
// clang-format on // clang-format on
}; };
use_enum_as_flags(ItemSpecialEffect); use_enum_as_flags(ItemSpecialEffect);

4
Source/misdat.h

@ -96,7 +96,7 @@ typedef enum missile_graphic_id : uint8_t {
/** /**
* @brief Specifies what if and how movement distribution is applied * @brief Specifies what if and how movement distribution is applied
*/ */
enum class MissileMovementDistrubution { enum class MissileMovementDistrubution : uint8_t {
/** /**
* @brief No movement distribution is calculated. Normally this means the missile doesn't move at all. * @brief No movement distribution is calculated. Normally this means the missile doesn't move at all.
*/ */
@ -127,7 +127,7 @@ struct MissileData {
MissileMovementDistrubution MovementDistribution; MissileMovementDistrubution MovementDistribution;
}; };
enum class MissileDataFlags { enum class MissileDataFlags : uint8_t {
// clang-format off // clang-format off
None = 0, None = 0,
MonsterOwned = 1 << 0, MonsterOwned = 1 << 0,

4
Source/missiles.h

@ -66,7 +66,7 @@ struct MissilePosition {
* | * |
* N NNE NE ENE E * N NNE NE ENE E
*/ */
enum class Direction16 { enum class Direction16 : uint8_t {
South, South,
South_SouthWest, South_SouthWest,
SouthWest, SouthWest,
@ -85,7 +85,7 @@ enum class Direction16 {
South_SouthEast, South_SouthEast,
}; };
enum class MissileSource { enum class MissileSource : uint8_t {
Player, Player,
Monster, Monster,
Trap, Trap,

2
Source/monstdat.h

@ -277,7 +277,7 @@ enum _monster_id : int16_t {
/** /**
* @brief Defines if and how a group of monsters should be spawned with the unique monster * @brief Defines if and how a group of monsters should be spawned with the unique monster
*/ */
enum class UniqueMonsterPack { enum class UniqueMonsterPack : uint8_t {
/** /**
* @brief Don't spawn a group of monsters with the unique monster * @brief Don't spawn a group of monsters with the unique monster
*/ */

2
Source/monster.h

@ -153,7 +153,7 @@ struct AnimStruct {
int8_t rate; int8_t rate;
}; };
enum class MonsterSound { enum class MonsterSound : uint8_t {
Attack, Attack,
Hit, Hit,
Death, Death,

14
Source/options.h

@ -15,21 +15,21 @@
namespace devilution { namespace devilution {
enum class StartUpGameMode { enum class StartUpGameMode : uint8_t {
/** @brief If hellfire is present, asks the user what game they want to start. */ /** @brief If hellfire is present, asks the user what game they want to start. */
Ask = 0, Ask = 0,
Hellfire = 1, Hellfire = 1,
Diablo = 2, Diablo = 2,
}; };
enum class StartUpIntro { enum class StartUpIntro : uint8_t {
Off = 0, Off = 0,
Once = 1, Once = 1,
On = 2, On = 2,
}; };
/** @brief Defines what splash screen should be shown at startup. */ /** @brief Defines what splash screen should be shown at startup. */
enum class StartUpSplash { enum class StartUpSplash : uint8_t {
/** @brief Show no splash screen. */ /** @brief Show no splash screen. */
None = 0, None = 0,
/** @brief Show only TitleDialog. */ /** @brief Show only TitleDialog. */
@ -38,13 +38,13 @@ enum class StartUpSplash {
LogoAndTitleDialog = 2, LogoAndTitleDialog = 2,
}; };
enum class ScalingQuality { enum class ScalingQuality : uint8_t {
NearestPixel, NearestPixel,
BilinearFiltering, BilinearFiltering,
AnisotropicFiltering, AnisotropicFiltering,
}; };
enum class Resampler { enum class Resampler : uint8_t {
#ifdef DEVILUTIONX_RESAMPLER_SPEEX #ifdef DEVILUTIONX_RESAMPLER_SPEEX
Speex = 0, Speex = 0,
#endif #endif
@ -56,13 +56,13 @@ enum class Resampler {
string_view ResamplerToString(Resampler resampler); string_view ResamplerToString(Resampler resampler);
std::optional<Resampler> ResamplerFromString(string_view resampler); std::optional<Resampler> ResamplerFromString(string_view resampler);
enum class OptionEntryType { enum class OptionEntryType : uint8_t {
Boolean, Boolean,
List, List,
Key, Key,
}; };
enum class OptionEntryFlags { enum class OptionEntryFlags : uint8_t {
/** @brief No special logic. */ /** @brief No special logic. */
None = 0, None = 0,
/** @brief Shouldn't be shown in settings dialog. */ /** @brief Shouldn't be shown in settings dialog. */

2
Source/panels/ui_panels.hpp

@ -2,7 +2,7 @@
namespace devilution { namespace devilution {
enum class UiPanels { enum class UiPanels : uint8_t {
Main, Main,
Quest, Quest,
Character, Character,

2
Source/pfile.h

@ -18,7 +18,7 @@ extern bool gbValidSaveFile;
* @brief Comparsion result of pfile_compare_hero_demo * @brief Comparsion result of pfile_compare_hero_demo
*/ */
struct HeroCompareResult { struct HeroCompareResult {
enum Status { enum Status : uint8_t {
ReferenceNotFound, ReferenceNotFound,
Same, Same,
Difference, Difference,

2
Source/platform/switch/docking.cpp

@ -7,7 +7,7 @@
namespace devilution { namespace devilution {
namespace { namespace {
enum class OperationMode { enum class OperationMode : int8_t {
Handheld, Handheld,
Docked, Docked,
Uninitialized = -1 Uninitialized = -1

2
Source/platform/vita/touch.cpp

@ -64,7 +64,7 @@ struct Touch {
Touch finger[TOUCH_PORT_MAX_NUM][MaxNumFingers]; // keep track of finger status Touch finger[TOUCH_PORT_MAX_NUM][MaxNumFingers]; // keep track of finger status
enum DraggingType { enum DraggingType : uint8_t {
DragNone, DragNone,
DragTwoFinger, DragTwoFinger,
DragThreeFinger, DragThreeFinger,

Loading…
Cancel
Save