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;
OptionEntryBase *selectedOption = nullptr;
enum class ShownMenuType {
enum class ShownMenuType : uint8_t {
Settings,
ListOption,
KeyInput,
@ -37,7 +37,7 @@ char optionDescription[512];
Rectangle rectList;
Rectangle rectDescription;
enum class SpecialMenuEntry {
enum class SpecialMenuEntry : int8_t {
None = -1,
PreviousMenu = -2,
UnbindKey = -3,

4
Source/DiabloUI/ui_flags.hpp

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

2
Source/DiabloUI/ui_item.h

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

2
Source/control.cpp

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

4
Source/controls/touch/renderers.h

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

4
Source/diablo.h

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

2
Source/effects.h

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

2
Source/engine/actor_position.cpp

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

2
Source/engine/demomode.cpp

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

4
Source/engine/render/automap_render.cpp

@ -8,12 +8,12 @@
namespace devilution {
namespace {
enum class DirectionX {
enum class DirectionX : int8_t {
EAST = 1,
WEST = -1,
};
enum class DirectionY {
enum class DirectionY : int8_t {
SOUTH = 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
* of bottom-to-top (bottom row first).
*/
enum class TileType {
enum class TileType : uint8_t {
/**
* 🮆 A 32x32 square. Stored as an array of pixels.
*/
@ -348,12 +348,12 @@ const std::uint32_t LeftFoliageMask[TILE_HEIGHT] = {
0x00000000,
};
enum class TransparencyType {
enum class TransparencyType : uint8_t {
Solid,
Blended,
};
enum class LightType {
enum class LightType : uint8_t {
FullyDark,
PartiallyLit,
FullyLit,

2
Source/engine/render/text_render.hpp

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

2
Source/hwcursor.cpp

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

2
Source/hwcursor.hpp

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

4
Source/itemdat.h

@ -322,7 +322,7 @@ enum unique_base_item : int8_t {
UITYPE_INVALID = -1,
};
enum class ItemSpecialEffect {
enum class ItemSpecialEffect : uint32_t {
// clang-format off
None = 0,
RandomStealLife = 1 << 1,
@ -350,7 +350,7 @@ enum class ItemSpecialEffect {
NoMana = 1 << 27,
HalfTrapDamage = 1 << 28,
TripleDemonDamage = 1 << 30,
ZeroResistance = 1 << 31,
ZeroResistance = 1U << 31,
// clang-format on
};
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
*/
enum class MissileMovementDistrubution {
enum class MissileMovementDistrubution : uint8_t {
/**
* @brief No movement distribution is calculated. Normally this means the missile doesn't move at all.
*/
@ -127,7 +127,7 @@ struct MissileData {
MissileMovementDistrubution MovementDistribution;
};
enum class MissileDataFlags {
enum class MissileDataFlags : uint8_t {
// clang-format off
None = 0,
MonsterOwned = 1 << 0,

4
Source/missiles.h

@ -66,7 +66,7 @@ struct MissilePosition {
* |
* N NNE NE ENE E
*/
enum class Direction16 {
enum class Direction16 : uint8_t {
South,
South_SouthWest,
SouthWest,
@ -85,7 +85,7 @@ enum class Direction16 {
South_SouthEast,
};
enum class MissileSource {
enum class MissileSource : uint8_t {
Player,
Monster,
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
*/
enum class UniqueMonsterPack {
enum class UniqueMonsterPack : uint8_t {
/**
* @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;
};
enum class MonsterSound {
enum class MonsterSound : uint8_t {
Attack,
Hit,
Death,

14
Source/options.h

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

2
Source/panels/ui_panels.hpp

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

2
Source/pfile.h

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

2
Source/platform/switch/docking.cpp

@ -7,7 +7,7 @@
namespace devilution {
namespace {
enum class OperationMode {
enum class OperationMode : int8_t {
Handheld,
Docked,
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
enum DraggingType {
enum DraggingType : uint8_t {
DragNone,
DragTwoFinger,
DragThreeFinger,

Loading…
Cancel
Save