From e7ae8ddd045aec4aa7021a0e23cc91e5b738ca12 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 10 Apr 2021 15:42:16 +0200 Subject: [PATCH] :truck: Move all enums to there respective headers --- 3rdParty/Storm/Source/storm.h | 9 +- DiabloUI/diabloui.h | 2 + Source/automap.h | 8 -- Source/capture.h | 8 -- Source/codec.h | 8 -- Source/control.cpp | 23 ++-- Source/control.h | 18 +-- Source/cursor.h | 4 +- Source/dead.h | 12 +- Source/debug.h | 8 -- Source/diablo.cpp | 2 +- Source/doom.h | 8 -- Source/drlg_l1.h | 8 -- Source/drlg_l2.h | 16 +-- Source/drlg_l3.h | 8 -- Source/drlg_l4.h | 8 -- Source/dthread.h | 9 -- Source/encrypt.h | 12 +- Source/engine.h | 3 +- Source/gamemenu.h | 8 -- Source/gendung.cpp | 2 +- Source/gendung.h | 11 +- Source/gmenu.h | 12 +- Source/help.h | 8 -- Source/init.h | 8 -- Source/interfac.h | 27 +++-- Source/inv.h | 49 +++++++- Source/itemdat.h | 18 +-- Source/items.cpp | 4 +- Source/items.h | 4 +- Source/lighting.h | 12 +- Source/loadsave.cpp | 6 +- Source/loadsave.h | 8 -- Source/mainmenu.h | 8 -- Source/minitext.h | 8 -- Source/monstdat.h | 36 +++--- Source/movie.h | 8 -- Source/mpqapi.h | 20 +--- Source/msg.cpp | 2 +- Source/multi.h | 18 +-- Source/nthread.h | 8 -- Source/objdat.h | 6 +- Source/pack.h | 17 +-- Source/palette.h | 8 -- Source/path.h | 11 +- Source/pfile.h | 8 -- Source/player.cpp | 15 ++- Source/player.h | 44 +++++--- Source/plrmsg.h | 12 +- Source/portal.cpp | 2 +- Source/portal.h | 12 +- Source/quests.cpp | 50 ++++----- Source/quests.h | 7 +- Source/render.h | 8 -- Source/restrict.h | 8 -- Source/scrollrt.h | 2 + Source/setmaps.h | 8 -- Source/sha.h | 12 +- Source/sound.h | 2 + Source/spelldat.h | 6 +- Source/stores.h | 18 +-- Source/sync.h | 8 -- Source/tmsg.h | 20 +--- Source/town.h | 8 -- Source/towners.h | 1 + Source/track.h | 8 -- Source/trigs.h | 14 +-- SourceS/console.h | 2 +- SourceS/file_util.h | 2 +- SourceS/miniwin/misc.h | 2 +- SourceS/paths.h | 2 +- SourceS/sdl2_to_1_2_backports.h | 12 +- SourceS/soundsample.h | 2 +- SourceS/storm_full.h | 5 +- SourceS/thread.h | 2 +- SourceS/ui_fwd.h | 2 +- SourceX/DiabloUI/art.h | 2 +- SourceX/DiabloUI/art_draw.h | 2 +- SourceX/DiabloUI/button.h | 2 +- SourceX/DiabloUI/credits_lines.h | 2 +- SourceX/DiabloUI/diabloui.h | 11 +- SourceX/DiabloUI/dialogs.h | 2 +- SourceX/DiabloUI/errorart.h | 2 +- SourceX/DiabloUI/fonts.h | 7 +- SourceX/DiabloUI/scrollbar.h | 6 +- SourceX/DiabloUI/selconn.h | 2 +- SourceX/DiabloUI/selgame.h | 2 +- SourceX/DiabloUI/selhero.h | 2 +- SourceX/DiabloUI/selok.h | 2 +- SourceX/DiabloUI/selyesno.h | 2 +- SourceX/DiabloUI/support_lines.h | 2 +- SourceX/DiabloUI/text.h | 2 +- SourceX/DiabloUI/text_draw.h | 2 +- SourceX/DiabloUI/ttf_render_wrapped.h | 5 +- SourceX/DiabloUI/ui_item.h | 8 +- SourceX/controls/axis_direction.h | 8 +- SourceX/controls/controller.h | 2 +- SourceX/controls/controller_buttons.h | 6 +- SourceX/controls/controller_motion.h | 2 +- SourceX/controls/devices/game_controller.h | 2 +- SourceX/controls/devices/joystick.h | 2 +- SourceX/controls/devices/kbcontroller.cpp | 2 +- SourceX/controls/devices/kbcontroller.h | 2 +- SourceX/controls/game_controls.h | 7 +- SourceX/controls/menu_controls.cpp | 2 +- SourceX/controls/menu_controls.h | 6 +- SourceX/controls/modifier_hints.h | 2 +- SourceX/controls/plrctrls.h | 6 +- SourceX/controls/remap_keyboard.h | 2 +- SourceX/controls/touch.cpp | 4 +- SourceX/controls/touch.h | 2 +- SourceX/dvlnet/packet.h | 15 ++- SourceX/platform/switch/docking.cpp | 2 +- SourceX/platform/switch/docking.h | 2 +- SourceX/storm/storm_net.cpp | 4 +- enums.h | 125 --------------------- types.h | 1 - 117 files changed, 373 insertions(+), 703 deletions(-) delete mode 100644 enums.h diff --git a/3rdParty/Storm/Source/storm.h b/3rdParty/Storm/Source/storm.h index 12a4138c7..9fd7d66f6 100644 --- a/3rdParty/Storm/Source/storm.h +++ b/3rdParty/Storm/Source/storm.h @@ -5,7 +5,12 @@ #include namespace devilution { -enum conn_type { +enum game_info : uint8_t { + GAMEINFO_NAME, + GAMEINFO_PASSWORD, +}; + +enum conn_type : uint8_t { SELCONN_ZT, SELCONN_TCP, SELCONN_LOOPBACK, @@ -134,7 +139,7 @@ bool SNetDropPlayer(int playerid, DWORD flags); * * Returns true if the function was called successfully and false otherwise. */ -bool SNetGetGameInfo(int type, void *dst, unsigned int length); +bool SNetGetGameInfo(game_info type, void *dst, unsigned int length); /* SNetGetTurnsInTransit @ 115 * diff --git a/DiabloUI/diabloui.h b/DiabloUI/diabloui.h index b1fee6341..682ca553a 100644 --- a/DiabloUI/diabloui.h +++ b/DiabloUI/diabloui.h @@ -1,6 +1,8 @@ //HEADER_GOES_HERE #pragma once +#include + namespace devilution { enum _mainmenu_selections : uint8_t { diff --git a/Source/automap.h b/Source/automap.h index edce91a32..3d0425fa2 100644 --- a/Source/automap.h +++ b/Source/automap.h @@ -9,10 +9,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - /** Specifies whether the automap is enabled. */ extern bool automapflag; /** Tracks the explored areas of the map. */ @@ -87,8 +83,4 @@ void SetAutomapView(Sint32 x, Sint32 y); */ void AutomapZoomReset(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/capture.h b/Source/capture.h index 3bb0fb6f5..fdb0444b3 100644 --- a/Source/capture.h +++ b/Source/capture.h @@ -7,14 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - void CaptureScreen(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/codec.h b/Source/codec.h index 014ae0810..0502ef91d 100644 --- a/Source/codec.h +++ b/Source/codec.h @@ -7,16 +7,8 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - int codec_decode(BYTE *pbSrcDst, DWORD size, const char *pszPassword); DWORD codec_get_encoded_len(DWORD dwSrcBytes); void codec_encode(BYTE *pbSrcDst, DWORD size, int size_64, const char *pszPassword); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/control.cpp b/Source/control.cpp index 10c103c6a..56c4d8adf 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -196,6 +196,18 @@ char SpellITbl[] = { 35, 35, }; + +enum panel_button_id { + PANBTN_CHARINFO, + PANBTN_QLOG, + PANBTN_AUTOMAP, + PANBTN_MAINMENU, + PANBTN_INVENTORY, + PANBTN_SPELLBOOK, + PANBTN_SENDMSG, + PANBTN_FRIENDLY, +}; + /** Maps from panel_button_id to the position and dimensions of a panel button. */ int PanBtnPos[8][5] = { // clang-format off @@ -1093,17 +1105,6 @@ void CheckPanelInfo() pcursinvitem = CheckInvHLight(); } -enum panel_button_id { - PANBTN_CHARINFO, - PANBTN_QLOG, - PANBTN_AUTOMAP, - PANBTN_MAINMENU, - PANBTN_INVENTORY, - PANBTN_SPELLBOOK, - PANBTN_SENDMSG, - PANBTN_FRIENDLY, -}; - /** * Check if the mouse is within a control panel button that's flagged. * Takes apropiate action if so. diff --git a/Source/control.h b/Source/control.h index 75e3400c2..299104d32 100644 --- a/Source/control.h +++ b/Source/control.h @@ -5,30 +5,28 @@ */ #pragma once +#include + #include "engine.h" #include "spelldat.h" #include "spells.h" namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum text_color { +enum text_color : uint8_t { COL_WHITE, COL_BLUE, COL_RED, COL_GOLD, COL_BLACK, -} text_color; +}; -typedef struct RECT32 { +struct RECT32 { int x; int y; int w; int h; -} RECT32; +}; extern bool drawhpflag; extern bool dropGoldFlag; @@ -153,8 +151,4 @@ extern const BYTE gbFontTransTbl[256]; extern RECT32 ChrBtnsRect[4]; -#ifdef __cplusplus -} -#endif - } diff --git a/Source/cursor.h b/Source/cursor.h index 6ed14073c..0b9b034e2 100644 --- a/Source/cursor.h +++ b/Source/cursor.h @@ -5,9 +5,11 @@ */ #pragma once +#include + namespace devilution { -enum cursor_id { +enum cursor_id : uint8_t { CURSOR_NONE, CURSOR_HAND, CURSOR_IDENTIFY, diff --git a/Source/dead.h b/Source/dead.h index 742bbb99c..231337923 100644 --- a/Source/dead.h +++ b/Source/dead.h @@ -7,17 +7,13 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct DeadStruct { +struct DeadStruct { Uint8 *_deadData[8]; int _deadFrame; int _deadWidth; int _deadWidth2; Uint8 _deadtrans; -} DeadStruct; +}; extern DeadStruct dead[MAXDEAD]; extern int stonendx; @@ -26,8 +22,4 @@ void InitDead(); void AddDead(int dx, int dy, char dv, int ddir); void SetDead(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/debug.h b/Source/debug.h index 33416e7b6..1b2f729a3 100644 --- a/Source/debug.h +++ b/Source/debug.h @@ -7,10 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern BYTE *pSquareCel; void FreeDebugGFX(); @@ -25,8 +21,4 @@ void PrintDebugQuest(); void GetDebugMonster(); void NextDebugMonster(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 68972d155..ec8fbc402 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -188,7 +188,7 @@ static void diablo_parse_flags(int argc, char **argv) } else if (strcasecmp("-t", argv[i]) == 0) { leveldebug = true; setlevel = true; - setlvlnum = SDL_atoi(argv[++i]); + setlvlnum = (_setlevels)SDL_atoi(argv[++i]); } else if (strcasecmp("-v", argv[i]) == 0) { visiondebug = true; } else if (strcasecmp("-w", argv[i]) == 0) { diff --git a/Source/doom.h b/Source/doom.h index f58d30186..1df25858f 100644 --- a/Source/doom.h +++ b/Source/doom.h @@ -9,10 +9,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern bool doomflag; extern int DoomQuestState; @@ -21,8 +17,4 @@ void doom_init(); void doom_close(); void doom_draw(CelOutputBuffer out); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/drlg_l1.h b/Source/drlg_l1.h index 9c17081cc..12e96316d 100644 --- a/Source/drlg_l1.h +++ b/Source/drlg_l1.h @@ -7,10 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern int UberRow; extern int UberCol; extern bool IsUberRoomOpened; @@ -33,8 +29,4 @@ void drlg_l1_crypt_pattern5(int rndper); void drlg_l1_crypt_pattern6(int rndper); void drlg_l1_crypt_pattern7(int rndper); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/drlg_l2.h b/Source/drlg_l2.h index 98d09b13c..4c953dccb 100644 --- a/Source/drlg_l2.h +++ b/Source/drlg_l2.h @@ -7,26 +7,22 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct HALLNODE { +struct HALLNODE { Sint32 nHallx1; Sint32 nHally1; Sint32 nHallx2; Sint32 nHally2; Sint32 nHalldir; struct HALLNODE *pNext; -} HALLNODE; +}; -typedef struct ROOMNODE { +struct ROOMNODE { Sint32 nRoomx1; Sint32 nRoomy1; Sint32 nRoomx2; Sint32 nRoomy2; Sint32 nRoomDest; -} ROOMNODE; +}; extern BYTE predungeon[DMAXX][DMAXY]; @@ -35,8 +31,4 @@ void LoadL2Dungeon(const char *sFileName, int vx, int vy); void LoadPreL2Dungeon(const char *sFileName, int vx, int vy); void CreateL2Dungeon(DWORD rseed, lvl_entry entry); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/drlg_l3.h b/Source/drlg_l3.h index dc36d2fe9..b4ff044b6 100644 --- a/Source/drlg_l3.h +++ b/Source/drlg_l3.h @@ -7,17 +7,9 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - void AddFenceDoors(); void CreateL3Dungeon(DWORD rseed, lvl_entry entry); void LoadL3Dungeon(const char *sFileName, int vx, int vy); void LoadPreL3Dungeon(const char *sFileName, int vx, int vy); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/drlg_l4.h b/Source/drlg_l4.h index 914e1a5b3..375ea9659 100644 --- a/Source/drlg_l4.h +++ b/Source/drlg_l4.h @@ -7,10 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern int diabquad1x; extern int diabquad1y; extern int diabquad2x; @@ -23,8 +19,4 @@ bool IsDURWall(char d); bool IsDLLWall(char dd); void CreateL4Dungeon(DWORD rseed, lvl_entry entry); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/dthread.h b/Source/dthread.h index 0286d6398..a23ead056 100644 --- a/Source/dthread.h +++ b/Source/dthread.h @@ -7,18 +7,9 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - void dthread_remove_player(int pnum); void dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen); void dthread_start(); void dthread_cleanup(); -/* data */ -#ifdef __cplusplus -} -#endif - } diff --git a/Source/encrypt.h b/Source/encrypt.h index 34e27e4b7..09c55a5f8 100644 --- a/Source/encrypt.h +++ b/Source/encrypt.h @@ -7,17 +7,13 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct TDataInfo { +struct TDataInfo { Uint8 *srcData; Uint32 srcOffset; Uint8 *destData; Uint32 destOffset; Uint32 size; -} TDataInfo; +}; void Decrypt(DWORD *castBlock, DWORD size, DWORD key); void Encrypt(DWORD *castBlock, DWORD size, DWORD key); @@ -26,8 +22,4 @@ void InitHash(); DWORD PkwareCompress(BYTE *srcData, DWORD size); void PkwareDecompress(BYTE *pbInBuff, int recv_size, int dwMaxBytes); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/engine.h b/Source/engine.h index ae8f320a7..eace519f3 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -26,7 +27,7 @@ namespace devilution { -enum direction { +enum direction : uint8_t { DIR_S, DIR_SW, DIR_W, diff --git a/Source/gamemenu.h b/Source/gamemenu.h index 7a6bbb198..a0e990eff 100644 --- a/Source/gamemenu.h +++ b/Source/gamemenu.h @@ -7,10 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - void gamemenu_on(); void gamemenu_off(); void gamemenu_handle_previous(); @@ -28,8 +24,4 @@ void gamemenu_gamma(bool bActivate); void gamemenu_speed(bool bActivate); void gamemenu_color_cycling(bool bActivate); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 4edd296bd..aef2e4e36 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -65,7 +65,7 @@ dungeon_type leveltype; BYTE currlevel; bool setlevel; /** Specifies the active quest level of the current game. */ -BYTE setlvlnum; +_setlevels setlvlnum; /** Level type of the active quest level */ dungeon_type setlvltype; /** Specifies the player viewpoint X-coordinate of the map. */ diff --git a/Source/gendung.h b/Source/gendung.h index efe695dc3..9c5320bd7 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -11,6 +11,15 @@ namespace devilution { +enum _setlevels : int8_t { + SL_NONE, + SL_SKELKING, + SL_BONECHAMB, + SL_MAZE, + SL_POISONWATER, + SL_VILEBETRAYER, +}; + enum dungeon_type : int8_t { DTYPE_TOWN, DTYPE_CATHEDRAL, @@ -120,7 +129,7 @@ extern int dmaxy; extern dungeon_type leveltype; extern BYTE currlevel; extern bool setlevel; -extern BYTE setlvlnum; +extern _setlevels setlvlnum; extern dungeon_type setlvltype; extern int ViewX; extern int ViewY; diff --git a/Source/gmenu.h b/Source/gmenu.h index 3924baf62..1e2bd7f0b 100644 --- a/Source/gmenu.h +++ b/Source/gmenu.h @@ -9,15 +9,11 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct TMenuItem { +struct TMenuItem { Uint32 dwFlags; const char *pszStr; void (*fnMenu)(bool); -} TMenuItem; +}; extern TMenuItem *sgpCurrentMenu; @@ -35,8 +31,4 @@ void gmenu_slider_set(TMenuItem *pItem, int min, int max, int gamma); int gmenu_slider_get(TMenuItem *pItem, int min, int max); void gmenu_slider_steps(TMenuItem *pItem, int dwTicks); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/help.h b/Source/help.h index 92503bfd7..19822ab57 100644 --- a/Source/help.h +++ b/Source/help.h @@ -7,10 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern bool helpflag; void InitHelp(); @@ -19,8 +15,4 @@ void DisplayHelp(); void HelpScrollUp(); void HelpScrollDown(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/init.h b/Source/init.h index ad58e6f6d..e3d3d0192 100644 --- a/Source/init.h +++ b/Source/init.h @@ -7,10 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern int gbActive; extern HANDLE hellfire_mpq; extern WNDPROC CurrentProc; @@ -40,8 +36,4 @@ WNDPROC SetWindowProc(WNDPROC NewProc); extern char gszVersionNumber[64]; extern char gszProductName[64]; -#ifdef __cplusplus -} -#endif - } diff --git a/Source/interfac.h b/Source/interfac.h index 6d31006fd..7e9ee0b7d 100644 --- a/Source/interfac.h +++ b/Source/interfac.h @@ -5,13 +5,26 @@ */ #pragma once +#include + namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif +enum interface_mode : uint16_t { + // clang-format off + WM_DIABNEXTLVL = 0x402, // WM_USER+2 + WM_DIABPREVLVL = 0x403, + WM_DIABRTNLVL = 0x404, + WM_DIABSETLVL = 0x405, + WM_DIABWARPLVL = 0x406, + WM_DIABTOWNWARP = 0x407, + WM_DIABTWARPUP = 0x408, + WM_DIABRETOWN = 0x409, + WM_DIABNEWGAME = 0x40A, + WM_DIABLOADGAME = 0x40B + // clang-format on +}; -typedef enum Cutscenes { +enum Cutscenes : uint8_t { CutStart, CutTown, CutLevel1, @@ -23,14 +36,10 @@ typedef enum Cutscenes { CutPortal, CutPortalRed, CutGate, -} Cutscenes; +}; void interface_msg_pump(); bool IncProgress(); void ShowProgress(interface_mode uMsg); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/inv.h b/Source/inv.h index 90ef7b22c..c749010d8 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -5,12 +5,59 @@ */ #pragma once +#include + #include "items.h" #include "player.h" namespace devilution { -enum item_color { +enum inv_item : int8_t { + // clang-format off + INVITEM_HEAD = 0, + INVITEM_RING_LEFT = 1, + INVITEM_RING_RIGHT = 2, + INVITEM_AMULET = 3, + INVITEM_HAND_LEFT = 4, + INVITEM_HAND_RIGHT = 5, + INVITEM_CHEST = 6, + INVITEM_INV_FIRST = 7, + INVITEM_INV_LAST = 46, + INVITEM_BELT_FIRST = 47, + INVITEM_BELT_LAST = 54, + // clang-format on + NUM_INVELEM, + INVITEM_INVALID = -1, +}; + +// identifiers for each of the inventory squares +// see https://github.com/sanctuary/graphics/blob/master/inventory.png +enum inv_xy_slot : uint8_t { + // clang-format off + SLOTXY_HEAD_FIRST = 0, + SLOTXY_HEAD_LAST = 3, + SLOTXY_RING_LEFT = 4, + SLOTXY_RING_RIGHT = 5, + SLOTXY_AMULET = 6, + SLOTXY_HAND_LEFT_FIRST = 7, + SLOTXY_HAND_LEFT_LAST = 12, + SLOTXY_HAND_RIGHT_FIRST = 13, + SLOTXY_HAND_RIGHT_LAST = 18, + SLOTXY_CHEST_FIRST = 19, + SLOTXY_CHEST_LAST = 24, + + // regular inventory + SLOTXY_INV_FIRST = 25, + SLOTXY_INV_LAST = 64, + + // belt items + SLOTXY_BELT_FIRST = 65, + SLOTXY_BELT_LAST = 72, + NUM_XY_SLOTS = 73 + // clang-format on +}; + +enum item_color : uint8_t { // clang-format off ICOL_WHITE = PAL16_YELLOW + 5, ICOL_BLUE = PAL16_BLUE + 5, diff --git a/Source/itemdat.h b/Source/itemdat.h index 4c5b19b11..5743c3007 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -434,7 +434,7 @@ struct ItemDataStruct { Uint16 iMaxValue; }; -enum item_effect_type { +enum item_effect_type : int8_t { IPL_TOHIT, IPL_TOHIT_CURSE, IPL_DAMP, @@ -533,20 +533,20 @@ enum item_effect_type { IPL_INVALID = -1, }; -enum goodorevil { +enum goodorevil : uint8_t { GOE_ANY, GOE_EVIL, GOE_GOOD, }; -enum affix_item_type { +enum affix_item_type : uint8_t { // clang-format off - PLT_MISC = 0x000001, - PLT_BOW = 0x000010, - PLT_STAFF = 0x000100, - PLT_WEAP = 0x001000, - PLT_SHLD = 0x010000, - PLT_ARMO = 0x100000, + PLT_MISC = 1 << 0, + PLT_BOW = 1 << 1, + PLT_STAFF = 1 << 2, + PLT_WEAP = 1 << 3, + PLT_SHLD = 1 << 4, + PLT_ARMO = 1 << 5, // clang-format on }; diff --git a/Source/items.cpp b/Source/items.cpp index 85a0137fb..f23db58ac 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -37,7 +37,7 @@ int gnNumGetRecords; int OilLevels[] = { 1, 10, 1, 10, 4, 1, 5, 17, 1, 10 }; int OilValues[] = { 500, 2500, 500, 2500, 1500, 100, 2500, 15000, 500, 2500 }; -enum item_misc_id OilMagic[] = { +item_misc_id OilMagic[] = { IMISC_OILACC, IMISC_OILMAST, IMISC_OILSHARP, @@ -2338,7 +2338,7 @@ static void SaveItemSuffix(int i, int sufidx) PL_Suffix[sufidx].PLMultVal); } -void GetItemPower(int i, int minlvl, int maxlvl, int flgs, bool onlygood) +void GetItemPower(int i, int minlvl, int maxlvl, affix_item_type flgs, bool onlygood) { int pre, post, nt, nl, j, preidx, sufidx; int l[256]; diff --git a/Source/items.h b/Source/items.h index d639bf961..d97c68632 100644 --- a/Source/items.h +++ b/Source/items.h @@ -11,7 +11,7 @@ namespace devilution { -enum item_quality { +enum item_quality : uint8_t { ITEM_QUALITY_NORMAL, ITEM_QUALITY_MAGIC, ITEM_QUALITY_UNIQUE, @@ -380,7 +380,7 @@ int AllocateItem(); void GetSuperItemLoc(int x, int y, int *xx, int *yy); void GetItemAttrs(int i, int idata, int lvl); void SaveItemPower(int i, item_effect_type power, int param1, int param2, int minval, int maxval, int multval); -void GetItemPower(int i, int minlvl, int maxlvl, int flgs, bool onlygood); +void GetItemPower(int i, int minlvl, int maxlvl, affix_item_type flgs, bool onlygood); void SetupItem(int i); int RndItem(int m); void SpawnUnique(_unique_items uid, int x, int y); diff --git a/Source/lighting.h b/Source/lighting.h index 04f66be82..b6079d979 100644 --- a/Source/lighting.h +++ b/Source/lighting.h @@ -7,11 +7,7 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct LightListStruct { +struct LightListStruct { int _lx; int _ly; int _lradius; @@ -24,7 +20,7 @@ typedef struct LightListStruct { int _xoff; int _yoff; bool _lflags; -} LightListStruct; +}; extern LightListStruct VisionList[MAXVISION]; extern BYTE lightactive[MAXLIGHTS]; @@ -68,8 +64,4 @@ void lighting_color_cycling(); extern const char CrawlTable[2749]; extern const BYTE vCrawlTable[23][30]; -#ifdef __cplusplus -} -#endif - } diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index b2965c01f..74f9bbc41 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -733,7 +733,7 @@ static void LoadQuest(LoadHelper *file, int i) pQuest->_qlvltype = (dungeon_type)file->nextLE(); pQuest->_qtx = file->nextLE(); pQuest->_qty = file->nextLE(); - pQuest->_qslvl = file->nextLE(); + pQuest->_qslvl = (_setlevels)file->nextLE(); pQuest->_qidx = file->nextLE(); if (gbIsHellfireSaveGame) { file->skip(2); // Alignment @@ -842,7 +842,7 @@ static void ConvertLevels() { // Backup current level state bool _setlevel = setlevel; - int _setlvlnum = setlvlnum; + _setlevels _setlvlnum = setlvlnum; int _currlevel = currlevel; dungeon_type _leveltype = leveltype; @@ -1002,7 +1002,7 @@ void LoadGame(bool firstflag) } setlevel = file.nextBool8(); - setlvlnum = file.nextBE(); + setlvlnum = (_setlevels)file.nextBE(); currlevel = file.nextBE(); leveltype = (dungeon_type)file.nextBE(); if (!setlevel) diff --git a/Source/loadsave.h b/Source/loadsave.h index 117b5e617..7da1ab34a 100644 --- a/Source/loadsave.h +++ b/Source/loadsave.h @@ -9,10 +9,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern bool gbIsHellfireSaveGame; extern int giNumberOfLevels; @@ -34,8 +30,4 @@ void SaveGame(); void SaveLevel(); void LoadLevel(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/mainmenu.h b/Source/mainmenu.h index b474dd095..4e627a4d7 100644 --- a/Source/mainmenu.h +++ b/Source/mainmenu.h @@ -9,17 +9,9 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern char gszHero[16]; bool mainmenu_select_hero_dialog(GameData *gameData); void mainmenu_loop(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/minitext.h b/Source/minitext.h index 8f9e3377c..c8e0b9bc1 100644 --- a/Source/minitext.h +++ b/Source/minitext.h @@ -7,10 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern bool qtextflag; void FreeQuestText(); @@ -27,8 +23,4 @@ void DrawQTextBack(CelOutputBuffer out); */ void DrawQText(CelOutputBuffer out); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/monstdat.h b/Source/monstdat.h index 000e6c9c7..6b4c9c3ef 100644 --- a/Source/monstdat.h +++ b/Source/monstdat.h @@ -9,11 +9,7 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum _mai_id : int8_t { +enum _mai_id : int8_t { AI_ZOMBIE, AI_FAT, AI_SKELSD, @@ -55,15 +51,15 @@ typedef enum _mai_id : int8_t { AI_NECROMORB, AI_BONEDEMON, AI_INVALID = -1, -} _mai_id; +}; -typedef enum _mc_id : uint8_t { +enum _mc_id : uint8_t { MC_UNDEAD, MC_DEMON, MC_ANIMAL, -} _mc_id; +}; -typedef enum monster_resistance : uint8_t { +enum monster_resistance : uint8_t { // clang-format off RESIST_MAGIC = 0x01, RESIST_FIRE = 0x02, @@ -74,9 +70,9 @@ typedef enum monster_resistance : uint8_t { IMMUNE_NULL_40 = 0x40, IMMUNE_ACID = 0x80, // clang-format on -} monster_resistance; +}; -typedef struct MonsterData { +struct MonsterData { const char *mName; const char *GraphicType; const char *sndfile; @@ -114,9 +110,9 @@ typedef struct MonsterData { Sint8 mSelFlag; // TODO Create enum Uint16 mTreasure; // TODO Create enum Uint16 mExp; -} MonsterData; +}; -typedef enum _monster_id { +enum _monster_id : int16_t { MT_NZOMBIE, MT_BZOMBIE, MT_GZOMBIE, @@ -257,15 +253,15 @@ typedef enum _monster_id { MT_NAKRUL, NUM_MTYPES, MT_INVALID = -1, -} _monster_id; +}; -typedef enum _monster_availability { +enum _monster_availability : uint8_t { MAT_NEVER, MAT_ALWAYS, MAT_RETAIL, -} _monster_availability; +}; -typedef struct UniqMonstStruct { +struct UniqMonstStruct { _monster_id mtype; const char *mName; const char *mTrnName; @@ -281,15 +277,11 @@ typedef struct UniqMonstStruct { Uint8 mUnqVar1; Uint8 mUnqVar2; Sint32 mtalkmsg; -} UniqMonstStruct; +}; extern const MonsterData monsterdata[]; extern const _monster_id MonstConvTbl[]; extern const char MonstAvailTbl[]; extern const UniqMonstStruct UniqMonst[]; -#ifdef __cplusplus -} -#endif - } diff --git a/Source/movie.h b/Source/movie.h index 917d5e83c..9f7934ef2 100644 --- a/Source/movie.h +++ b/Source/movie.h @@ -7,17 +7,9 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern BYTE movie_playing; extern bool loop_movie; void play_movie(const char *pszMovie, bool user_can_close); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/mpqapi.h b/Source/mpqapi.h index 673d001a1..a8dd3e1dc 100644 --- a/Source/mpqapi.h +++ b/Source/mpqapi.h @@ -9,11 +9,7 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _FILEHEADER { +struct _FILEHEADER { int signature; int headersize; int filesize; @@ -24,20 +20,20 @@ typedef struct _FILEHEADER { int hashcount; int blockcount; Uint8 pad[72]; -} _FILEHEADER; +}; -typedef struct _HASHENTRY { +struct _HASHENTRY { Uint32 hashcheck[2]; Uint32 lcid; Uint32 block; -} _HASHENTRY; +}; -typedef struct _BLOCKENTRY { +struct _BLOCKENTRY { Uint32 offset; Uint32 sizealloc; Uint32 sizefile; Uint32 flags; -} _BLOCKENTRY; +}; void mpqapi_remove_hash_entry(const char *pszName); void mpqapi_remove_hash_entries(bool (*fnGetName)(DWORD, char *)); @@ -47,8 +43,4 @@ bool mpqapi_has_file(const char *pszName); bool OpenMPQ(const char *pszArchive, DWORD dwChar); bool mpqapi_flush_and_close(const char *pszArchive, bool bFree, DWORD dwChar); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/msg.cpp b/Source/msg.cpp index c209df9e2..f73b5afa5 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1931,7 +1931,7 @@ static DWORD On_NEWLVL(TCmd *pCmd, int pnum) if (gbBufferMsgs == 1) msg_send_packet(pnum, p, sizeof(*p)); else if (pnum != myplr) - StartNewLvl(pnum, p->wParam1, p->wParam2); + StartNewLvl(pnum, (interface_mode)p->wParam1, p->wParam2); return sizeof(*p); } diff --git a/Source/multi.h b/Source/multi.h index bbd80080a..85bf9a1a2 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -5,15 +5,19 @@ */ #pragma once +#include + #include "msg.h" namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif +enum event_type : uint8_t { + EVENT_TYPE_PLAYER_CREATE_GAME, + EVENT_TYPE_PLAYER_LEAVE_GAME, + EVENT_TYPE_PLAYER_MESSAGE, +}; -typedef struct GameData { +struct GameData { Sint32 size; Sint32 dwSeed; Uint32 programid; @@ -26,7 +30,7 @@ typedef struct GameData { Uint8 bTheoQuest; Uint8 bCowQuest; Uint8 bFriendlyFire; -} GameData; +}; extern bool gbSomebodyWonGameKludge; extern char szPlayerDescript[128]; @@ -56,8 +60,4 @@ bool multi_init_single(GameData *gameData); bool multi_init_multi(GameData *gameData, bool *pfExitProgram); void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, bool recv); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/nthread.h b/Source/nthread.h index 7272ecd22..326dd7f91 100644 --- a/Source/nthread.h +++ b/Source/nthread.h @@ -7,10 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern BYTE sgbNetUpdateRate; extern DWORD gdwMsgLenTbl[MAX_PLRS]; extern DWORD gdwDeltaBytesSec; @@ -28,8 +24,4 @@ void nthread_cleanup(); void nthread_ignore_mutex(bool bStart); bool nthread_has_500ms_passed(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/objdat.h b/Source/objdat.h index db746d8fa..1c76d0f99 100644 --- a/Source/objdat.h +++ b/Source/objdat.h @@ -5,6 +5,8 @@ */ #pragma once +#include + namespace devilution { enum theme_id : int8_t { @@ -28,7 +30,7 @@ enum theme_id : int8_t { THEME_NONE = -1, }; -enum object_graphic_id { +enum object_graphic_id : int8_t { OFILE_L1BRAZ, OFILE_L1DOORS, OFILE_LEVER, @@ -88,7 +90,7 @@ enum object_graphic_id { OFILE_NULL = -1, }; -enum _object_id { +enum _object_id : int8_t { OBJ_L1LIGHT, OBJ_L1LDOOR, OBJ_L1RDOOR, diff --git a/Source/pack.h b/Source/pack.h index 0f4f4737a..bc3b37ecb 100644 --- a/Source/pack.h +++ b/Source/pack.h @@ -10,12 +10,8 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - #pragma pack(push, 1) -typedef struct PkItemStruct { +struct PkItemStruct { Uint32 iSeed; Uint16 iCreateInfo; Uint16 idx; @@ -26,9 +22,9 @@ typedef struct PkItemStruct { Uint8 bMCh; Uint16 wValue; Uint32 dwBuff; -} PkItemStruct; +}; -typedef struct PkPlayerStruct { +struct PkPlayerStruct { Uint32 dwLowDateTime; Uint32 dwHighDateTime; Sint8 destAction; @@ -76,7 +72,7 @@ typedef struct PkPlayerStruct { Uint32 pDifficulty; Sint32 pDamAcFlags; Sint32 dwReserved[5]; // For future use -} PkPlayerStruct; +}; #pragma pack(pop) void PackPlayer(PkPlayerStruct *pPack, int pnum, bool manashield); @@ -84,9 +80,4 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool netSync); void PackItem(PkItemStruct *id, const ItemStruct *is); void UnPackItem(const PkItemStruct *is, ItemStruct *id, bool isHellfire); -/* rdata */ -#ifdef __cplusplus -} -#endif - } diff --git a/Source/palette.h b/Source/palette.h index c56dfc82f..55571ac19 100644 --- a/Source/palette.h +++ b/Source/palette.h @@ -7,10 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern SDL_Color logical_palette[256]; extern SDL_Color system_palette[256]; extern SDL_Color orig_palette[256]; @@ -34,8 +30,4 @@ void palette_update_crypt(); void palette_update_hive(); void palette_update_quest_palette(int n); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/path.h b/Source/path.h index b19265cce..045b22381 100644 --- a/Source/path.h +++ b/Source/path.h @@ -7,11 +7,7 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct PATHNODE { +struct PATHNODE { Uint8 f; Uint8 h; Uint8 g; @@ -20,7 +16,7 @@ typedef struct PATHNODE { struct PATHNODE *Parent; struct PATHNODE *Child[8]; struct PATHNODE *NextNode; -} PATHNODE; +}; int FindPath(bool (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, Sint8 path[MAX_PATH_LENGTH]); int path_get_h_cost(int sx, int sy, int dx, int dy); @@ -40,8 +36,5 @@ PATHNODE *path_new_step(); extern const char pathxdir[8]; extern const char pathydir[8]; -#ifdef __cplusplus -} -#endif } diff --git a/Source/pfile.h b/Source/pfile.h index b58283c14..43221b984 100644 --- a/Source/pfile.h +++ b/Source/pfile.h @@ -10,10 +10,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - extern bool gbValidSaveFile; const char *pfile_get_password(); @@ -36,8 +32,4 @@ void pfile_write_save_file(const char *pszName, BYTE *pbData, DWORD dwLen, DWORD BYTE *pfile_read(const char *pszName, DWORD *pdwLen); void pfile_update(bool force_save); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/player.cpp b/Source/player.cpp index 6fe4e0fb9..24ea62f38 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -2034,7 +2034,7 @@ void InitLevelChange(int pnum) __attribute__((no_sanitize("shift-base"))) #endif void -StartNewLvl(int pnum, int fom, int lvl) +StartNewLvl(int pnum, interface_mode fom, int lvl) { InitLevelChange(pnum); @@ -2052,7 +2052,7 @@ StartNewLvl(int pnum, int fom, int lvl) plr[pnum].plrlevel = lvl; break; case WM_DIABSETLVL: - setlvlnum = lvl; + setlvlnum = (_setlevels)lvl; break; case WM_DIABTWARPUP: plr[myplr].pTownWarps |= 1 << (leveltype - 2); @@ -2073,6 +2073,7 @@ StartNewLvl(int pnum, int fom, int lvl) } } } + void RestartTownLvl(int pnum) { InitLevelChange(pnum); @@ -4230,6 +4231,16 @@ void InitDungMsgs(int pnum) plr[pnum].pDungMsgs2 = 0; } +enum { + // clang-format off + DMSG_CATHEDRAL = 1 << 0, + DMSG_CATACOMBS = 1 << 1, + DMSG_CAVES = 1 << 2, + DMSG_HELL = 1 << 3, + DMSG_DIABLO = 1 << 4, + // clang-format on +}; + void PlayDungMsgs() { if ((DWORD)myplr >= MAX_PLRS) { diff --git a/Source/player.h b/Source/player.h index 0a1d24384..f1bc96fda 100644 --- a/Source/player.h +++ b/Source/player.h @@ -10,6 +10,7 @@ #include "gendung.h" #include "items.h" #include "spelldat.h" +#include "interfac.h" namespace devilution { @@ -57,6 +58,23 @@ enum inv_body_loc : uint8_t { NUM_INVLOC, }; +enum player_graphic : uint16_t { + // clang-format off + PFILE_STAND = 1 << 0, + PFILE_WALK = 1 << 1, + PFILE_ATTACK = 1 << 2, + PFILE_HIT = 1 << 3, + PFILE_LIGHTNING = 1 << 4, + PFILE_FIRE = 1 << 5, + PFILE_MAGIC = 1 << 6, + PFILE_DEATH = 1 << 7, + PFILE_BLOCK = 1 << 8, + // everything except PFILE_DEATH + // 0b1_0111_1111 + PFILE_NONDEATH = 0x17F + // clang-format on +}; + enum anim_weapon_id : uint8_t { ANIM_ID_UNARMED, ANIM_ID_UNARMED_SHIELD, @@ -69,7 +87,7 @@ enum anim_weapon_id : uint8_t { ANIM_ID_STAFF, }; -typedef enum PLR_MODE { +enum PLR_MODE : uint8_t { PM_STAND, PM_WALK, //Movement towards N, NW, or NE PM_WALK2, //Movement towards S, SW, or SE @@ -82,9 +100,9 @@ typedef enum PLR_MODE { PM_SPELL, PM_NEWLVL, PM_QUIT, -} PLR_MODE; +}; -typedef enum action_id { +enum action_id : int8_t { // clang-format off ACTION_WALK = -2, // Automatic walk when using gamepad ACTION_NONE = -1, @@ -105,14 +123,14 @@ typedef enum action_id { ACTION_SPELLPLR = 25, ACTION_SPELLWALL = 26, // clang-format on -} action_id; +}; -typedef enum player_weapon_type { +enum player_weapon_type : uint8_t { WT_MELEE, WT_RANGED, -} player_weapon_type; +}; -typedef struct PlayerStruct { +struct PlayerStruct { PLR_MODE _pmode; Sint8 walkpath[MAX_PATH_LENGTH]; bool plractive; @@ -300,11 +318,7 @@ typedef struct PlayerStruct { * @return The maximum value for the requested attribute. */ Sint32 GetMaximumAttributeValue(attribute_id attribute) const; -} PlayerStruct; - -#ifdef __cplusplus -extern "C" { -#endif +}; extern int myplr; extern PlayerStruct plr[MAX_PLRS]; @@ -342,7 +356,7 @@ void DropHalfPlayersGold(int pnum); void StripTopGold(int pnum); void SyncPlrKill(int pnum, int earflag); void RemovePlrMissiles(int pnum); -void StartNewLvl(int pnum, int fom, int lvl); +void StartNewLvl(int pnum, interface_mode fom, int lvl); void RestartTownLvl(int pnum); void StartWarpLvl(int pnum, int pidx); void ProcessPlayers(); @@ -378,8 +392,4 @@ extern int DexterityTbl[NUM_CLASSES]; extern int VitalityTbl[NUM_CLASSES]; extern int ExpLvlsTbl[MAXCHARLEVEL]; -#ifdef __cplusplus -} -#endif - } diff --git a/Source/plrmsg.h b/Source/plrmsg.h index 4236ddea2..404f26068 100644 --- a/Source/plrmsg.h +++ b/Source/plrmsg.h @@ -9,15 +9,11 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _plrmsg { +struct _plrmsg { Uint32 time; Uint8 player; char str[144]; -} _plrmsg; +}; void plrmsg_delay(bool delay); void ErrorPlrMsg(const char *pszMsg); @@ -27,8 +23,4 @@ void ClearPlrMsg(); void InitPlrMsg(); void DrawPlrMsg(CelOutputBuffer out); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/portal.cpp b/Source/portal.cpp index d52ddd6ea..29b4b351c 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -139,7 +139,7 @@ void GetPortalLevel() } else { if (portal[portalindex].setlvl) { setlevel = true; - setlvlnum = portal[portalindex].level; + setlvlnum = (_setlevels)portal[portalindex].level; currlevel = portal[portalindex].level; plr[myplr].plrlevel = setlvlnum; leveltype = portal[portalindex].ltype; diff --git a/Source/portal.h b/Source/portal.h index b8adc64e0..3a90910fb 100644 --- a/Source/portal.h +++ b/Source/portal.h @@ -7,18 +7,14 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct PortalStruct { +struct PortalStruct { bool open; Sint32 x; Sint32 y; Sint32 level; dungeon_type ltype; bool setlvl; -} PortalStruct; +}; extern PortalStruct portal[MAXPORTAL]; @@ -36,8 +32,4 @@ void GetPortalLevel(); void GetPortalLvlPos(); bool PosOkPortal(int lvl, int x, int y); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/quests.cpp b/Source/quests.cpp index a39277716..73a6a7f6f 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -25,31 +25,31 @@ int ReturnLvl; /** Contains the data related to each quest_id. */ QuestData questlist[] = { // clang-format off - // _qdlvl, _qdmultlvl, _qlvlt, _qdtype, _qdrnd, _qslvl, isSinglePlayerOnly, _qdmsg, _qlstr - { 5, -1, DTYPE_NONE, Q_ROCK, 100, 0, true, TEXT_INFRA5, "The Magic Rock" }, - { 9, -1, DTYPE_NONE, Q_MUSHROOM, 100, 0, true, TEXT_MUSH8, "Black Mushroom" }, - { 4, -1, DTYPE_NONE, Q_GARBUD, 100, 0, true, TEXT_GARBUD1, "Gharbad The Weak" }, - { 8, -1, DTYPE_NONE, Q_ZHAR, 100, 0, true, TEXT_ZHAR1, "Zhar the Mad" }, - { 14, -1, DTYPE_NONE, Q_VEIL, 100, 0, true, TEXT_VEIL9, "Lachdanan" }, - { 15, -1, DTYPE_NONE, Q_DIABLO, 100, 0, false, TEXT_VILE3, "Diablo" }, - { 2, 2, DTYPE_NONE, Q_BUTCHER, 100, 0, false, TEXT_BUTCH9, "The Butcher" }, - { 4, -1, DTYPE_NONE, Q_LTBANNER, 100, 0, true, TEXT_BANNER2, "Ogden's Sign" }, - { 7, -1, DTYPE_NONE, Q_BLIND, 100, 0, true, TEXT_BLINDING, "Halls of the Blind" }, - { 5, -1, DTYPE_NONE, Q_BLOOD, 100, 0, true, TEXT_BLOODY, "Valor" }, - { 10, -1, DTYPE_NONE, Q_ANVIL, 100, 0, true, TEXT_ANVIL5, "Anvil of Fury" }, - { 13, -1, DTYPE_NONE, Q_WARLORD, 100, 0, true, TEXT_BLOODWAR, "Warlord of Blood" }, - { 3, 3, DTYPE_CATHEDRAL, Q_SKELKING, 100, 1, false, TEXT_KING2, "The Curse of King Leoric" }, - { 2, -1, DTYPE_CAVES, Q_PWATER, 100, 4, true, TEXT_POISON3, "Poisoned Water Supply" }, - { 6, -1, DTYPE_CATACOMBS, Q_SCHAMB, 100, 2, true, TEXT_BONER, "The Chamber of Bone" }, - { 15, 15, DTYPE_CATHEDRAL, Q_BETRAYER, 100, 5, false, TEXT_VILE1, "Archbishop Lazarus" }, - { 17, 17, DTYPE_NONE, Q_GRAVE, 100, 0, false, TEXT_GRAVE7, "Grave Matters" }, - { 9, 9, DTYPE_NONE, Q_FARMER, 100, 0, false, TEXT_FARMER1, "Farmer's Orchard" }, - { 17, -1, DTYPE_NONE, Q_GIRL, 100, 0, true, TEXT_GIRL2, "Little Girl" }, - { 19, -1, DTYPE_NONE, Q_TRADER, 100, 0, true, TEXT_TRADER, "Wandering Trader" }, - { 17, 17, DTYPE_NONE, Q_DEFILER, 100, 0, false, TEXT_DEFILER1, "The Defiler" }, - { 21, 21, DTYPE_NONE, Q_NAKRUL, 100, 0, false, TEXT_NAKRUL1, "Na-Krul" }, - { 21, -1, DTYPE_NONE, Q_CORNSTN, 100, 0, true, TEXT_CORNSTN, "Cornerstone of the World" }, - { 9, 9, DTYPE_NONE, Q_JERSEY, 100, 0, false, TEXT_JERSEY4, "The Jersey's Jersey" }, + // _qdlvl, _qdmultlvl, _qlvlt, _qdtype, _qdrnd, _qslvl, isSinglePlayerOnly, _qdmsg, _qlstr + { 5, -1, DTYPE_NONE, Q_ROCK, 100, SL_NONE, true, TEXT_INFRA5, "The Magic Rock" }, + { 9, -1, DTYPE_NONE, Q_MUSHROOM, 100, SL_NONE, true, TEXT_MUSH8, "Black Mushroom" }, + { 4, -1, DTYPE_NONE, Q_GARBUD, 100, SL_NONE, true, TEXT_GARBUD1, "Gharbad The Weak" }, + { 8, -1, DTYPE_NONE, Q_ZHAR, 100, SL_NONE, true, TEXT_ZHAR1, "Zhar the Mad" }, + { 14, -1, DTYPE_NONE, Q_VEIL, 100, SL_NONE, true, TEXT_VEIL9, "Lachdanan" }, + { 15, -1, DTYPE_NONE, Q_DIABLO, 100, SL_NONE, false, TEXT_VILE3, "Diablo" }, + { 2, 2, DTYPE_NONE, Q_BUTCHER, 100, SL_NONE, false, TEXT_BUTCH9, "The Butcher" }, + { 4, -1, DTYPE_NONE, Q_LTBANNER, 100, SL_NONE, true, TEXT_BANNER2, "Ogden's Sign" }, + { 7, -1, DTYPE_NONE, Q_BLIND, 100, SL_NONE, true, TEXT_BLINDING, "Halls of the Blind" }, + { 5, -1, DTYPE_NONE, Q_BLOOD, 100, SL_NONE, true, TEXT_BLOODY, "Valor" }, + { 10, -1, DTYPE_NONE, Q_ANVIL, 100, SL_NONE, true, TEXT_ANVIL5, "Anvil of Fury" }, + { 13, -1, DTYPE_NONE, Q_WARLORD, 100, SL_NONE, true, TEXT_BLOODWAR, "Warlord of Blood" }, + { 3, 3, DTYPE_CATHEDRAL, Q_SKELKING, 100, SL_SKELKING, false, TEXT_KING2, "The Curse of King Leoric" }, + { 2, -1, DTYPE_CAVES, Q_PWATER, 100, SL_POISONWATER, true, TEXT_POISON3, "Poisoned Water Supply" }, + { 6, -1, DTYPE_CATACOMBS, Q_SCHAMB, 100, SL_BONECHAMB, true, TEXT_BONER, "The Chamber of Bone" }, + { 15, 15, DTYPE_CATHEDRAL, Q_BETRAYER, 100, SL_VILEBETRAYER, false, TEXT_VILE1, "Archbishop Lazarus" }, + { 17, 17, DTYPE_NONE, Q_GRAVE, 100, SL_NONE, false, TEXT_GRAVE7, "Grave Matters" }, + { 9, 9, DTYPE_NONE, Q_FARMER, 100, SL_NONE, false, TEXT_FARMER1, "Farmer's Orchard" }, + { 17, -1, DTYPE_NONE, Q_GIRL, 100, SL_NONE, true, TEXT_GIRL2, "Little Girl" }, + { 19, -1, DTYPE_NONE, Q_TRADER, 100, SL_NONE, true, TEXT_TRADER, "Wandering Trader" }, + { 17, 17, DTYPE_NONE, Q_DEFILER, 100, SL_NONE, false, TEXT_DEFILER1, "The Defiler" }, + { 21, 21, DTYPE_NONE, Q_NAKRUL, 100, SL_NONE, false, TEXT_NAKRUL1, "Na-Krul" }, + { 21, -1, DTYPE_NONE, Q_CORNSTN, 100, SL_NONE, true, TEXT_CORNSTN, "Cornerstone of the World" }, + { 9, 9, DTYPE_NONE, Q_JERSEY, 100, SL_NONE, false, TEXT_JERSEY4, "The Jersey's Jersey" }, // clang-format on }; /** diff --git a/Source/quests.h b/Source/quests.h index 63b185722..c6845a224 100644 --- a/Source/quests.h +++ b/Source/quests.h @@ -5,7 +5,10 @@ */ #pragma once +#include + #include "engine.h" +#include "gendung.h" namespace devilution { @@ -40,7 +43,7 @@ struct QuestStruct { dungeon_type _qlvltype; Sint32 _qtx; Sint32 _qty; - Uint8 _qslvl; + _setlevels _qslvl; Uint8 _qidx; Sint32 _qmsg; Uint8 _qvar1; @@ -54,7 +57,7 @@ struct QuestData { dungeon_type _qlvlt; Uint8 _qdtype; Uint8 _qdrnd; - Uint8 _qslvl; + _setlevels _qslvl; bool isSinglePlayerOnly; Sint32 _qdmsg; const char *_qlstr; diff --git a/Source/render.h b/Source/render.h index 4faf28ea4..bb6894f0d 100644 --- a/Source/render.h +++ b/Source/render.h @@ -7,10 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - /** * @brief Blit current world CEL to the given buffer * @param out Target buffer @@ -27,8 +23,4 @@ void RenderTile(CelOutputBuffer out, int x, int y); */ void world_draw_black_tile(CelOutputBuffer out, int sx, int sy); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/restrict.h b/Source/restrict.h index 21ff39a8f..a9e30de70 100644 --- a/Source/restrict.h +++ b/Source/restrict.h @@ -7,14 +7,6 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - void ReadOnlyTest(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/scrollrt.h b/Source/scrollrt.h index 26e52ba17..8bc9dd8f2 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -5,6 +5,8 @@ */ #pragma once +#include + namespace devilution { enum _scroll_direction : uint8_t { diff --git a/Source/setmaps.h b/Source/setmaps.h index 73a58eb29..123826220 100644 --- a/Source/setmaps.h +++ b/Source/setmaps.h @@ -7,18 +7,10 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - int ObjIndex(int x, int y); void LoadSetMap(); /* rdata */ extern const char *const quest_level_names[]; -#ifdef __cplusplus -} -#endif - } diff --git a/Source/sha.h b/Source/sha.h index 88b8d8064..d3026d4bf 100644 --- a/Source/sha.h +++ b/Source/sha.h @@ -7,25 +7,17 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - #define SHA1HashSize 20 -typedef struct SHA1Context { +struct SHA1Context { Uint32 state[5]; Uint32 count[2]; char buffer[64]; -} SHA1Context; +}; void SHA1Clear(); void SHA1Result(int n, char Message_Digest[SHA1HashSize]); void SHA1Calculate(int n, const char *data, char Message_Digest[SHA1HashSize]); void SHA1Reset(int n); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/sound.h b/Source/sound.h index c7cb275ab..33b2c2343 100644 --- a/Source/sound.h +++ b/Source/sound.h @@ -5,6 +5,8 @@ */ #pragma once +#include + namespace devilution { enum _music_id : uint8_t { diff --git a/Source/spelldat.h b/Source/spelldat.h index b754e4476..725536f01 100644 --- a/Source/spelldat.h +++ b/Source/spelldat.h @@ -5,6 +5,8 @@ */ #pragma once +#include + #include "effects.h" namespace devilution { @@ -74,13 +76,13 @@ enum spell_id : int8_t { SPL_INVALID = -1, }; -enum magic_type { +enum magic_type : uint8_t { STYPE_FIRE, STYPE_LIGHTNING, STYPE_MAGIC, }; -enum missile_id { +enum missile_id : int8_t { MIS_ARROW, MIS_FIREBOLT, MIS_GUARDIAN, diff --git a/Source/stores.h b/Source/stores.h index 1ef9adddd..326bee374 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -9,11 +9,7 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum talk_id { +enum talk_id : uint8_t { STORE_NONE, STORE_SMITH, STORE_SBUY, @@ -38,9 +34,9 @@ typedef enum talk_id { STORE_TAVERN, STORE_DRUNK, STORE_BARMAID, -} talk_id; +}; -typedef struct STextStruct { +struct STextStruct { int _sx; int _syoff; char _sstr[128]; @@ -49,7 +45,7 @@ typedef struct STextStruct { int _sline; bool _ssel; int _sval; -} STextStruct; +}; /** Shop frame graphics */ extern BYTE *pSTextBoxCels; @@ -114,10 +110,4 @@ void STextEnter(); void CheckStoreBtn(); void ReleaseStoreBtn(); -/* rdata */ - -#ifdef __cplusplus -} -#endif - } diff --git a/Source/sync.h b/Source/sync.h index 380d4233e..d6f093069 100644 --- a/Source/sync.h +++ b/Source/sync.h @@ -7,16 +7,8 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - Uint32 sync_all_monsters(const Uint8 *pbBuf, Uint32 dwMaxLen); Uint32 sync_update(int pnum, const Uint8 *pbBuf); void sync_init(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/tmsg.h b/Source/tmsg.h index d4670c153..7def37edc 100644 --- a/Source/tmsg.h +++ b/Source/tmsg.h @@ -7,25 +7,19 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - #pragma pack(push, 1) -typedef struct TMsg TMsg; - -typedef struct TMsgHdr { - TMsg *pNext; +struct TMsgHdr { + struct TMsg *pNext; Sint32 dwTime; Uint8 bLen; -} TMsgHdr; +}; -typedef struct TMsg { +struct TMsg { TMsgHdr hdr; // this is actually alignment padding, but the message body is appended to the struct // so it's convenient to use byte-alignment and name it "body" Uint8 body[3]; -} TMsg; +}; #pragma pack(pop) int tmsg_get(Uint8 *pbMsg, Uint32 dwMaxLen); @@ -33,8 +27,4 @@ void tmsg_add(Uint8 *pbMsg, Uint8 bLen); void tmsg_start(); void tmsg_cleanup(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/town.h b/Source/town.h index 4074a4926..8b86af7f8 100644 --- a/Source/town.h +++ b/Source/town.h @@ -7,16 +7,8 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - void TownOpenHive(); void TownOpenGrave(); void CreateTown(lvl_entry entry); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/towners.h b/Source/towners.h index 20116189a..09d4b9387 100644 --- a/Source/towners.h +++ b/Source/towners.h @@ -8,6 +8,7 @@ #include namespace devilution { + enum _talker_id : uint8_t { TOWN_SMITH, TOWN_HEALER, diff --git a/Source/track.h b/Source/track.h index 28fc73dc7..57220c673 100644 --- a/Source/track.h +++ b/Source/track.h @@ -7,16 +7,8 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - void track_process(); void track_repeat_walk(bool rep); bool track_isscrolling(); -#ifdef __cplusplus -} -#endif - } diff --git a/Source/trigs.h b/Source/trigs.h index ac6a82bb9..90bf3227a 100644 --- a/Source/trigs.h +++ b/Source/trigs.h @@ -7,16 +7,12 @@ namespace devilution { -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct TriggerStruct { +struct TriggerStruct { int _tx; int _ty; - int _tmsg; + interface_mode _tmsg; int _tlvl; -} TriggerStruct; +}; extern bool trigflag; extern int numtrigs; @@ -37,8 +33,4 @@ void Freeupstairs(); void CheckTrigForce(); void CheckTriggers(); -#ifdef __cplusplus -} -#endif - } diff --git a/SourceS/console.h b/SourceS/console.h index 61ef7053c..ec0ce2bb3 100644 --- a/SourceS/console.h +++ b/SourceS/console.h @@ -29,7 +29,7 @@ void printInConsole(const char *fmt, ...) WriteConsole(stderrHandle, message, strlen(message), NULL, NULL); } -} // namespace dvl +} // namespace devilution #else #define printInConsole printf #endif diff --git a/SourceS/file_util.h b/SourceS/file_util.h index 9a5b318a0..38bace787 100644 --- a/SourceS/file_util.h +++ b/SourceS/file_util.h @@ -111,4 +111,4 @@ inline void RemoveFile(const char *lpFileName) } } -} // namespace dvl +} // namespace devilution diff --git a/SourceS/miniwin/misc.h b/SourceS/miniwin/misc.h index 3965de30b..4d01e9a88 100644 --- a/SourceS/miniwin/misc.h +++ b/SourceS/miniwin/misc.h @@ -163,4 +163,4 @@ bool PostMessage(UINT Msg, WPARAM wParam, LPARAM lParam); #define DVL_MK_LBUTTON 0x0001 #define DVL_MK_RBUTTON 0x0002 -} // namespace dvl +} // namespace devilution diff --git a/SourceS/paths.h b/SourceS/paths.h index ac4e697eb..b09658327 100644 --- a/SourceS/paths.h +++ b/SourceS/paths.h @@ -16,4 +16,4 @@ void SetConfigPath(const char *path); void SetTtfPath(const char *path); void SetTtfName(const char *path); -} // namespace dvl +} // namespace devilution diff --git a/SourceS/sdl2_to_1_2_backports.h b/SourceS/sdl2_to_1_2_backports.h index 25e368fe9..d402cca4c 100644 --- a/SourceS/sdl2_to_1_2_backports.h +++ b/SourceS/sdl2_to_1_2_backports.h @@ -96,11 +96,13 @@ inline void SDL_DisableScreenSaver() //= Messagebox (simply logged to stderr for now) -typedef enum { - SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */ - SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */ - SDL_MESSAGEBOX_INFORMATION = 0x00000040 /**< informational dialog */ -} SDL_MessageBoxFlags; +enum { + // clang-format off + SDL_MESSAGEBOX_ERROR = 0x10, /**< error dialog */ + SDL_MESSAGEBOX_WARNING = 0x20, /**< warning dialog */ + SDL_MESSAGEBOX_INFORMATION = 0x40, /**< informational dialog */ + // clang-format on +}; inline int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, diff --git a/SourceS/soundsample.h b/SourceS/soundsample.h index 9ef3aa336..93a550cbd 100644 --- a/SourceS/soundsample.h +++ b/SourceS/soundsample.h @@ -17,4 +17,4 @@ private: Mix_Chunk *chunk; }; -} // namespace dvl +} // namespace devilution diff --git a/SourceS/storm_full.h b/SourceS/storm_full.h index 351e59cb2..e9b7d2e96 100644 --- a/SourceS/storm_full.h +++ b/SourceS/storm_full.h @@ -1,8 +1,7 @@ #pragma once namespace devilution { -extern "C" { extern DWORD nLastError; -} -} // namespace dvl + +} // namespace devilution diff --git a/SourceS/thread.h b/SourceS/thread.h index 179e6e16c..ad7428107 100644 --- a/SourceS/thread.h +++ b/SourceS/thread.h @@ -20,4 +20,4 @@ void ResetEvent(event_emul *e); int WaitForEvent(event_emul *e); SDL_Thread *CreateThread(unsigned int (*handler)(void *), SDL_threadID *ThreadID); -} // namespace dvl +} // namespace devilution diff --git a/SourceS/ui_fwd.h b/SourceS/ui_fwd.h index b6ddafbfa..bce5df000 100644 --- a/SourceS/ui_fwd.h +++ b/SourceS/ui_fwd.h @@ -10,4 +10,4 @@ extern Uint16 borderRight; bool SpawnWindow(const char *lpWindowName); void UiErrorOkDialog(const char *text, const char *caption, bool error = true); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/art.h b/SourceX/DiabloUI/art.h index 98193b316..67cdb0330 100644 --- a/SourceX/DiabloUI/art.h +++ b/SourceX/DiabloUI/art.h @@ -42,4 +42,4 @@ void LoadArt(const char *pszFile, Art *art, int frames = 1, SDL_Color *pPalette void LoadMaskedArt(const char *pszFile, Art *art, int frames = 1, int mask = 250); void LoadArt(Art *art, const BYTE *artData, int w, int h, int frames = 1); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/art_draw.h b/SourceX/DiabloUI/art_draw.h index 3e22fca3a..4013bda0d 100644 --- a/SourceX/DiabloUI/art_draw.h +++ b/SourceX/DiabloUI/art_draw.h @@ -14,4 +14,4 @@ void DrawAnimatedArt(Art *art, int screenX, int screenY); int GetAnimationFrame(int frames, int fps = 60); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/button.h b/SourceX/DiabloUI/button.h index 35b00dbf2..e09f1d4e6 100644 --- a/SourceX/DiabloUI/button.h +++ b/SourceX/DiabloUI/button.h @@ -18,4 +18,4 @@ void RenderButton(UiButton *button); bool HandleMouseEventButton(const SDL_Event &event, UiButton *button); void HandleGlobalMouseUpButton(UiButton *button); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/credits_lines.h b/SourceX/DiabloUI/credits_lines.h index a59fb807f..fcdd71732 100644 --- a/SourceX/DiabloUI/credits_lines.h +++ b/SourceX/DiabloUI/credits_lines.h @@ -5,4 +5,4 @@ namespace devilution { extern const char *const CREDITS_LINES[]; extern const std::size_t CREDITS_LINES_SIZE; -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/diabloui.h b/SourceX/DiabloUI/diabloui.h index 7fd46eb5f..5c226dd37 100644 --- a/SourceX/DiabloUI/diabloui.h +++ b/SourceX/DiabloUI/diabloui.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -13,17 +14,17 @@ namespace devilution { extern std::size_t SelectedItem; extern bool textInputActive; -typedef enum _artFocus { +enum _artFocus : uint8_t { FOCUS_SMALL, FOCUS_MED, FOCUS_BIG, -} _artFocus; +}; -typedef enum _artLogo { +enum _artLogo : uint8_t { LOGO_SMALL, LOGO_MED, LOGO_BIG, -} _artLogo; +}; extern std::array ArtLogos; extern std::array ArtFocus; @@ -61,4 +62,4 @@ void UiRenderItems(std::vector items); void UiInitList_clear(); void mainmenu_restart_repintro(); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/dialogs.h b/SourceX/DiabloUI/dialogs.h index b8d32f20a..b0400decd 100644 --- a/SourceX/DiabloUI/dialogs.h +++ b/SourceX/DiabloUI/dialogs.h @@ -10,4 +10,4 @@ void UiErrorOkDialog(const char *text, std::vector renderBehind); void UiErrorOkDialog(const char *text, const char *caption, std::vector renderBehind); void UiOkDialog(const char *text, const char *caption, bool error, std::vector renderBehind); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/errorart.h b/SourceX/DiabloUI/errorart.h index efa7b2ba6..60774647a 100644 --- a/SourceX/DiabloUI/errorart.h +++ b/SourceX/DiabloUI/errorart.h @@ -5,4 +5,4 @@ namespace devilution { extern const unsigned char btnData[]; extern const unsigned char popupData[]; -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/fonts.h b/SourceX/DiabloUI/fonts.h index fde0a0995..ed1ef91de 100644 --- a/SourceX/DiabloUI/fonts.h +++ b/SourceX/DiabloUI/fonts.h @@ -2,20 +2,21 @@ #include "all.h" +#include #include #include "DiabloUI/art.h" namespace devilution { -enum _artFontTables { +enum _artFontTables : uint8_t { AFT_SMALL, AFT_MED, AFT_BIG, AFT_HUGE, }; -enum _artFontColors { +enum _artFontColors : uint8_t { AFC_SILVER, AFC_GOLD, }; @@ -31,4 +32,4 @@ void LoadTtfFont(); void UnloadTtfFont(); void FontsCleanup(); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/scrollbar.h b/SourceX/DiabloUI/scrollbar.h index 29f5b9742..3bab0ab9d 100644 --- a/SourceX/DiabloUI/scrollbar.h +++ b/SourceX/DiabloUI/scrollbar.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "DiabloUI/art.h" #include "DiabloUI/ui_item.h" @@ -11,7 +13,7 @@ extern Art ArtScrollBarArrow; const Uint16 SCROLLBAR_BG_WIDTH = 25; extern Art ArtScrollBarArrow; -enum ScrollBarArrowFrame { +enum ScrollBarArrowFrame : uint8_t { ScrollBarArrowFrame_UP_ACTIVE = 0, ScrollBarArrowFrame_UP, ScrollBarArrowFrame_DOWN_ACTIVE, @@ -77,4 +79,4 @@ inline SDL_Rect ThumbRect(const UiScrollBar *sb, std::size_t selected_index, std void LoadScrollBar(); void UnloadScrollBar(); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/selconn.h b/SourceX/DiabloUI/selconn.h index 01eaeb8dc..3b6c46c8c 100644 --- a/SourceX/DiabloUI/selconn.h +++ b/SourceX/DiabloUI/selconn.h @@ -4,4 +4,4 @@ void selconn_Esc(); void selconn_Focus(int value); void selconn_Select(int value); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/selgame.h b/SourceX/DiabloUI/selgame.h index eed1b07ff..e0164fb3e 100644 --- a/SourceX/DiabloUI/selgame.h +++ b/SourceX/DiabloUI/selgame.h @@ -20,4 +20,4 @@ void selgame_Password_Init(int value); void selgame_Password_Select(int value); void selgame_Password_Esc(); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/selhero.h b/SourceX/DiabloUI/selhero.h index 0d363950c..089ab3621 100644 --- a/SourceX/DiabloUI/selhero.h +++ b/SourceX/DiabloUI/selhero.h @@ -22,4 +22,4 @@ void selhero_Name_Esc(); void selhero_Load_Focus(int value); void selhero_Load_Select(int value); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/selok.h b/SourceX/DiabloUI/selok.h index c7a424693..44078abb4 100644 --- a/SourceX/DiabloUI/selok.h +++ b/SourceX/DiabloUI/selok.h @@ -8,4 +8,4 @@ void selok_Free(); void selok_Select(int value); void selok_Esc(); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/selyesno.h b/SourceX/DiabloUI/selyesno.h index defbdb904..d526c7f94 100644 --- a/SourceX/DiabloUI/selyesno.h +++ b/SourceX/DiabloUI/selyesno.h @@ -8,4 +8,4 @@ void selyesno_Free(); void selyesno_Select(int value); void selyesno_Esc(); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/support_lines.h b/SourceX/DiabloUI/support_lines.h index 6fdd2ec95..dc35b4806 100644 --- a/SourceX/DiabloUI/support_lines.h +++ b/SourceX/DiabloUI/support_lines.h @@ -5,4 +5,4 @@ namespace devilution { extern const char *const SUPPORT_LINES[]; extern const std::size_t SUPPORT_LINES_SIZE; -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/text.h b/SourceX/DiabloUI/text.h index 38030890a..a45a44dac 100644 --- a/SourceX/DiabloUI/text.h +++ b/SourceX/DiabloUI/text.h @@ -9,4 +9,4 @@ namespace devilution { std::size_t GetArtStrWidth(const char *str, std::size_t size); void WordWrapArtStr(char *text, std::size_t width); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/text_draw.h b/SourceX/DiabloUI/text_draw.h index ceb57607b..b97ca22fd 100644 --- a/SourceX/DiabloUI/text_draw.h +++ b/SourceX/DiabloUI/text_draw.h @@ -17,4 +17,4 @@ void DrawTTF(const char *text, const SDL_Rect &rect, int flags, void DrawArtStr(const char *text, const SDL_Rect &rect, int flags, bool drawTextCursor = false); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/ttf_render_wrapped.h b/SourceX/DiabloUI/ttf_render_wrapped.h index 3845d9f18..63f9455ea 100644 --- a/SourceX/DiabloUI/ttf_render_wrapped.h +++ b/SourceX/DiabloUI/ttf_render_wrapped.h @@ -2,11 +2,12 @@ #include "all.h" +#include #include namespace devilution { -enum TextAlignment { +enum TextAlignment : uint8_t { TextAlignment_BEGIN = 0, TextAlignment_CENTER, TextAlignment_END, @@ -21,4 +22,4 @@ enum TextAlignment { SDL_Surface *RenderUTF8_Solid_Wrapped( TTF_Font *font, const char *text, SDL_Color fg, Uint32 wrapLength, const int x_align = TextAlignment_BEGIN); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/DiabloUI/ui_item.h b/SourceX/DiabloUI/ui_item.h index 40cb27295..8bd0594df 100644 --- a/SourceX/DiabloUI/ui_item.h +++ b/SourceX/DiabloUI/ui_item.h @@ -13,7 +13,7 @@ namespace devilution { -enum UiType { +enum UiType : uint8_t { UI_TEXT, UI_ART_TEXT, UI_ART_TEXT_BUTTON, @@ -24,7 +24,7 @@ enum UiType { UI_EDIT, }; -enum UiFlags { +enum UiFlags : uint16_t { UIS_SMALL = 1 << 0, UIS_MED = 1 << 1, UIS_BIG = 1 << 2, @@ -260,7 +260,7 @@ public: m_render_cache = NULL; } - enum FrameKey { + enum FrameKey : uint8_t { DEFAULT = 0, PRESSED, DISABLED @@ -348,4 +348,4 @@ public: Uint16 m_width, m_height; std::vector m_vecItems; }; -} // namespace dvl +} // namespace devilution diff --git a/SourceX/controls/axis_direction.h b/SourceX/controls/axis_direction.h index 398e3a37d..681d2b3cf 100644 --- a/SourceX/controls/axis_direction.h +++ b/SourceX/controls/axis_direction.h @@ -1,13 +1,15 @@ #pragma once +#include + namespace devilution { -enum AxisDirectionX { +enum AxisDirectionX : uint8_t { AxisDirectionX_NONE = 0, AxisDirectionX_LEFT, AxisDirectionX_RIGHT }; -enum AxisDirectionY { +enum AxisDirectionY : uint8_t { AxisDirectionY_NONE = 0, AxisDirectionY_UP, AxisDirectionY_DOWN @@ -45,4 +47,4 @@ private: int min_interval_ms_; }; -} // namespace dvl +} // namespace devilution diff --git a/SourceX/controls/controller.h b/SourceX/controls/controller.h index b56d67314..46e2c8bd9 100644 --- a/SourceX/controls/controller.h +++ b/SourceX/controls/controller.h @@ -20,4 +20,4 @@ bool IsControllerButtonPressed(ControllerButton button); bool HandleControllerAddedOrRemovedEvent(const SDL_Event &event); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/controls/controller_buttons.h b/SourceX/controls/controller_buttons.h index 859645a96..f25b0481e 100644 --- a/SourceX/controls/controller_buttons.h +++ b/SourceX/controls/controller_buttons.h @@ -1,11 +1,13 @@ #pragma once // Unifies joystick, gamepad, and keyboard controller APIs. +#include + namespace devilution { // NOTE: A, B, X, Y refer to physical positions on an XBox 360 controller. // A<->B and X<->Y are reversed on a Nintendo controller. -enum ControllerButton { +enum ControllerButton : uint8_t { ControllerButton_NONE = 0, ControllerButton_IGNORE, ControllerButton_AXIS_TRIGGERLEFT, // ZL (aka L2) @@ -34,4 +36,4 @@ inline bool IsDPadButton(ControllerButton button) || button == ControllerButton_BUTTON_DPAD_RIGHT; } -} // namespace dvl +} // namespace devilution diff --git a/SourceX/controls/controller_motion.h b/SourceX/controls/controller_motion.h index a046c0773..e4ff82410 100644 --- a/SourceX/controls/controller_motion.h +++ b/SourceX/controls/controller_motion.h @@ -24,4 +24,4 @@ bool ProcessControllerMotion(const SDL_Event &event, ControllerButtonEvent ctrl_ // Returns direction of the left thumb stick or DPad (if allow_dpad = true). AxisDirection GetLeftStickOrDpadDirection(bool allow_dpad = true); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/controls/devices/game_controller.h b/SourceX/controls/devices/game_controller.h index 7c9b21802..1d60a542f 100644 --- a/SourceX/controls/devices/game_controller.h +++ b/SourceX/controls/devices/game_controller.h @@ -38,5 +38,5 @@ private: bool trigger_right_is_down_ = false; }; -} // namespace dvl +} // namespace devilution #endif diff --git a/SourceX/controls/devices/joystick.h b/SourceX/controls/devices/joystick.h index b466e5737..9b64ae8ca 100644 --- a/SourceX/controls/devices/joystick.h +++ b/SourceX/controls/devices/joystick.h @@ -42,4 +42,4 @@ private: SDL_JoystickID instance_id_ = -1; }; -} // namespace dvl +} // namespace devilution diff --git a/SourceX/controls/devices/kbcontroller.cpp b/SourceX/controls/devices/kbcontroller.cpp index 28dbd1f95..433f68065 100644 --- a/SourceX/controls/devices/kbcontroller.cpp +++ b/SourceX/controls/devices/kbcontroller.cpp @@ -170,5 +170,5 @@ bool ProcessKbCtrlAxisMotion(const SDL_Event &event) return false; } -} // namespace dvl +} // namespace devilution #endif diff --git a/SourceX/controls/devices/kbcontroller.h b/SourceX/controls/devices/kbcontroller.h index 5949d4874..622bf0845 100644 --- a/SourceX/controls/devices/kbcontroller.h +++ b/SourceX/controls/devices/kbcontroller.h @@ -17,5 +17,5 @@ bool IsKbCtrlButtonPressed(ControllerButton button); bool ProcessKbCtrlAxisMotion(const SDL_Event &event); -} // namespace dvl +} // namespace devilution #endif diff --git a/SourceX/controls/game_controls.h b/SourceX/controls/game_controls.h index 0e15870ca..cceb7f10e 100644 --- a/SourceX/controls/game_controls.h +++ b/SourceX/controls/game_controls.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -8,7 +9,7 @@ namespace devilution { -enum GameActionType { +enum GameActionType : uint8_t { GameActionType_NONE = 0, GameActionType_USE_HEALTH_POTION, GameActionType_USE_MANA_POTION, @@ -30,7 +31,7 @@ struct GameActionSendKey { }; struct GameActionSendMouseClick { - enum Button { + enum Button : uint8_t { LEFT = 0, RIGHT, }; @@ -76,4 +77,4 @@ AxisDirection GetMoveDirection(); extern bool start_modifier_active; extern bool select_modifier_active; -} // namespace dvl +} // namespace devilution diff --git a/SourceX/controls/menu_controls.cpp b/SourceX/controls/menu_controls.cpp index 3134e6ed4..08e4f0605 100644 --- a/SourceX/controls/menu_controls.cpp +++ b/SourceX/controls/menu_controls.cpp @@ -112,6 +112,6 @@ MenuAction GetMenuAction(const SDL_Event &event) #endif return MenuAction_NONE; -} // namespace dvl +} // namespace devilution } // namespace devilution diff --git a/SourceX/controls/menu_controls.h b/SourceX/controls/menu_controls.h index 1676a4261..2a2dc4c53 100644 --- a/SourceX/controls/menu_controls.h +++ b/SourceX/controls/menu_controls.h @@ -1,10 +1,12 @@ #pragma once +#include + #include "all.h" namespace devilution { -enum MenuAction { +enum MenuAction : uint8_t { MenuAction_NONE = 0, MenuAction_SELECT, MenuAction_BACK, @@ -24,4 +26,4 @@ MenuAction GetMenuAction(const SDL_Event &event); /** Menu action from holding the left stick or DPad. */ MenuAction GetMenuHeldUpDownAction(); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/controls/modifier_hints.h b/SourceX/controls/modifier_hints.h index f496b08d6..a5815f5cd 100644 --- a/SourceX/controls/modifier_hints.h +++ b/SourceX/controls/modifier_hints.h @@ -6,4 +6,4 @@ namespace devilution { void DrawControllerModifierHints(CelOutputBuffer out); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/controls/plrctrls.h b/SourceX/controls/plrctrls.h index 68baf2d9f..5bb9bd8ee 100644 --- a/SourceX/controls/plrctrls.h +++ b/SourceX/controls/plrctrls.h @@ -1,11 +1,13 @@ #pragma once // Controller actions implementation +#include + #include "all.h" namespace devilution { -typedef enum belt_item_type { +typedef enum belt_item_type : uint8_t { BLT_HEALING, BLT_MANA, } belt_item_type; @@ -52,4 +54,4 @@ typedef struct coords { } coords; extern int speedspellcount; -} // namespace dvl +} // namespace devilution diff --git a/SourceX/controls/remap_keyboard.h b/SourceX/controls/remap_keyboard.h index 6fe528379..2b3418f36 100644 --- a/SourceX/controls/remap_keyboard.h +++ b/SourceX/controls/remap_keyboard.h @@ -29,4 +29,4 @@ inline void remap_keyboard_key(SDL_Keycode *sym) #endif } -} // namespace dvl +} // namespace devilution diff --git a/SourceX/controls/touch.cpp b/SourceX/controls/touch.cpp index b98a50790..0befcc398 100644 --- a/SourceX/controls/touch.cpp +++ b/SourceX/controls/touch.cpp @@ -47,7 +47,7 @@ enum { MAX_TAP_TIME = 250, // taps longer than this will not result in mouse click events MAX_TAP_MOTION_DISTANCE = 10, // max distance finger motion in Vita screen pixels to be considered a tap SIMULATED_CLICK_DURATION = 50, // time in ms how long simulated mouse clicks should be -}; // track three fingers per panel +}; // track three fingers per panel typedef struct { int id; // -1: not touching @@ -61,7 +61,7 @@ typedef struct { static Touch finger[TOUCH_PORT_MAX_NUM][MAX_NUM_FINGERS]; // keep track of finger status typedef enum { - DRAG_NONE = 0, + DRAG_NONE, DRAG_TWO_FINGER, DRAG_THREE_FINGER, } DraggingType; diff --git a/SourceX/controls/touch.h b/SourceX/controls/touch.h index c608a9c17..1fe090e72 100644 --- a/SourceX/controls/touch.h +++ b/SourceX/controls/touch.h @@ -8,4 +8,4 @@ namespace devilution { void handle_touch(SDL_Event *event, int current_mouse_x, int current_mouse_y); #endif -} // namespace dvl +} // namespace devilution diff --git a/SourceX/dvlnet/packet.h b/SourceX/dvlnet/packet.h index 926ee1fef..4b856a454 100644 --- a/SourceX/dvlnet/packet.h +++ b/SourceX/dvlnet/packet.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -15,14 +16,16 @@ namespace devilution { namespace net { enum packet_type : uint8_t { - PT_MESSAGE = 0x01, - PT_TURN = 0x02, + // clang-format off + PT_MESSAGE = 0x01, + PT_TURN = 0x02, PT_JOIN_REQUEST = 0x11, - PT_JOIN_ACCEPT = 0x12, - PT_CONNECT = 0x13, - PT_DISCONNECT = 0x14, + PT_JOIN_ACCEPT = 0x12, + PT_CONNECT = 0x13, + PT_DISCONNECT = 0x14, PT_INFO_REQUEST = 0x21, - PT_INFO_REPLY = 0x22 + PT_INFO_REPLY = 0x22, + // clang-format on }; // Returns NULL for an invalid packet type. diff --git a/SourceX/platform/switch/docking.cpp b/SourceX/platform/switch/docking.cpp index a8dec1a6c..bfafaab2b 100644 --- a/SourceX/platform/switch/docking.cpp +++ b/SourceX/platform/switch/docking.cpp @@ -46,4 +46,4 @@ void HandleDocking() } } -} // namespace dvl +} // namespace devilution diff --git a/SourceX/platform/switch/docking.h b/SourceX/platform/switch/docking.h index 4a0da4ac4..0843aa224 100644 --- a/SourceX/platform/switch/docking.h +++ b/SourceX/platform/switch/docking.h @@ -4,4 +4,4 @@ namespace devilution { void HandleDocking(); -} // namespace dvl +} // namespace devilution diff --git a/SourceX/storm/storm_net.cpp b/SourceX/storm/storm_net.cpp index 082b00c97..5e824ec21 100644 --- a/SourceX/storm/storm_net.cpp +++ b/SourceX/storm/storm_net.cpp @@ -105,7 +105,7 @@ bool SNetDropPlayer(int playerid, DWORD flags) return dvlnet_inst->SNetDropPlayer(playerid, flags); } -bool SNetGetGameInfo(int type, void *dst, unsigned int length) +bool SNetGetGameInfo(game_info type, void *dst, unsigned int length) { #ifndef NONET std::lock_guard lg(storm_net_mutex); @@ -161,7 +161,7 @@ bool SNetCreateGame(const char *pszGameName, const char *pszGamePassword, const dvlnet_inst->setup_gameinfo(std::move(game_init_info)); std::string default_name; - if(!pszGameName) { + if (!pszGameName) { default_name = dvlnet_inst->make_default_gamename(); pszGameName = default_name.c_str(); } diff --git a/enums.h b/enums.h deleted file mode 100644 index 4c84764df..000000000 --- a/enums.h +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @file enums.h - * - * Various global enumerators. - */ - -#include - -namespace devilution { - -typedef enum dungeon_message { - DMSG_CATHEDRAL = 1 << 0, - DMSG_CATACOMBS = 1 << 1, - DMSG_CAVES = 1 << 2, - DMSG_HELL = 1 << 3, - DMSG_DIABLO = 1 << 4, -} dungeon_message; - -typedef enum event_type { - EVENT_TYPE_PLAYER_CREATE_GAME = 1, - EVENT_TYPE_2 = 2, - EVENT_TYPE_PLAYER_LEAVE_GAME = 3, - EVENT_TYPE_PLAYER_MESSAGE = 4, - EVENT_TYPE_5 = 5, - EVENT_TYPE_6 = 6, - EVENT_TYPE_7 = 7, - EVENT_TYPE_8 = 8, - EVENT_TYPE_9 = 9, - EVENT_TYPE_10 = 10, - EVENT_TYPE_11 = 11, - EVENT_TYPE_12 = 12, - EVENT_TYPE_13 = 13, - EVENT_TYPE_14 = 14, - EVENT_TYPE_15 = 15, -} event_type; - -typedef enum interface_mode { - WM_DIABNEXTLVL = 0x402, // WM_USER+2 - WM_DIABPREVLVL = 0x403, - WM_DIABRTNLVL = 0x404, - WM_DIABSETLVL = 0x405, - WM_DIABWARPLVL = 0x406, - WM_DIABTOWNWARP = 0x407, - WM_DIABTWARPUP = 0x408, - WM_DIABRETOWN = 0x409, - WM_DIABNEWGAME = 0x40A, - WM_DIABLOADGAME = 0x40B - // WM_LEIGHSKIP = 0x40C, // psx only - // WM_DIAVNEWLVL = 0x40D, // psx only -} interface_mode; - -typedef enum game_info { - GAMEINFO_NAME = 1, - GAMEINFO_PASSWORD = 2, - GAMEINFO_STATS = 3, - GAMEINFO_MODEFLAG = 4, - GAMEINFO_GAMETEMPLATE = 5, - GAMEINFO_PLAYERS = 6, -} game_info; - -typedef enum _setlevels { - //SL_BUTCHCHAMB = 0x0, - SL_SKELKING = 0x1, - SL_BONECHAMB = 0x2, - SL_MAZE = 0x3, - SL_POISONWATER = 0x4, - SL_VILEBETRAYER = 0x5, -} _setlevels; - -typedef enum inv_item { - INVITEM_HEAD = 0, - INVITEM_RING_LEFT = 1, - INVITEM_RING_RIGHT = 2, - INVITEM_AMULET = 3, - INVITEM_HAND_LEFT = 4, - INVITEM_HAND_RIGHT = 5, - INVITEM_CHEST = 6, - INVITEM_INV_FIRST = 7, - INVITEM_INV_LAST = 46, - INVITEM_BELT_FIRST = 47, - INVITEM_BELT_LAST = 54, - NUM_INVELEM -} inv_item; - -// identifiers for each of the inventory squares -// see https://github.com/sanctuary/graphics/blob/master/inventory.png -typedef enum inv_xy_slot { - SLOTXY_HEAD_FIRST = 0, - SLOTXY_HEAD_LAST = 3, - SLOTXY_RING_LEFT = 4, - SLOTXY_RING_RIGHT = 5, - SLOTXY_AMULET = 6, - SLOTXY_HAND_LEFT_FIRST = 7, - SLOTXY_HAND_LEFT_LAST = 12, - SLOTXY_HAND_RIGHT_FIRST = 13, - SLOTXY_HAND_RIGHT_LAST = 18, - SLOTXY_CHEST_FIRST = 19, - SLOTXY_CHEST_LAST = 24, - - // regular inventory - SLOTXY_INV_FIRST = 25, - SLOTXY_INV_LAST = 64, - - // belt items - SLOTXY_BELT_FIRST = 65, - SLOTXY_BELT_LAST = 72, - NUM_XY_SLOTS = 73 -} inv_xy_slot; - -typedef enum player_graphic { - PFILE_STAND = 1 << 0, - PFILE_WALK = 1 << 1, - PFILE_ATTACK = 1 << 2, - PFILE_HIT = 1 << 3, - PFILE_LIGHTNING = 1 << 4, - PFILE_FIRE = 1 << 5, - PFILE_MAGIC = 1 << 6, - PFILE_DEATH = 1 << 7, - PFILE_BLOCK = 1 << 8, - // everything except PFILE_DEATH - // 0b1_0111_1111 - PFILE_NONDEATH = 0x17F -} player_graphic; - -} // namespace devilution diff --git a/types.h b/types.h index 7e3dfbbbc..0cc3c56a3 100644 --- a/types.h +++ b/types.h @@ -13,6 +13,5 @@ #include #include "defs.h" -#include "enums.h" #endif