|
1 | | -/** |
2 | | - * @file diablo.h |
3 | | - * |
4 | | - * Interface of the main game initialization functions. |
5 | | - */ |
6 | | -#pragma once |
7 | | - |
8 | | -#include <cstdint> |
9 | | - |
10 | | -#ifdef USE_SDL3 |
11 | | -#include <SDL3/SDL_events.h> |
12 | | -#include <SDL3/SDL_keycode.h> |
13 | | -#else |
14 | | -#include <SDL.h> |
15 | | - |
16 | | -#ifdef USE_SDL1 |
17 | | -#include "utils/sdl2_to_1_2_backports.h" |
18 | | -#endif |
19 | | -#endif |
20 | | - |
21 | | -#ifdef _DEBUG |
22 | | -#include "tables/monstdat.h" |
23 | | -#endif |
24 | | -#include "levels/gendung.h" |
25 | | -#include "utils/attributes.h" |
26 | | -#include "utils/endian_read.hpp" |
27 | | - |
28 | | -namespace devilution { |
29 | | - |
30 | | -constexpr uint32_t GameIdDiabloFull = LoadBE32("DRTL"); |
31 | | -constexpr uint32_t GameIdDiabloSpawn = LoadBE32("DSHR"); |
32 | | -constexpr uint32_t GameIdHellfireFull = LoadBE32("HRTL"); |
33 | | -constexpr uint32_t GameIdHellfireSpawn = LoadBE32("HSHR"); |
34 | | -#define GAME_ID (gbIsHellfire ? (gbIsSpawn ? GameIdHellfireSpawn : GameIdHellfireFull) : (gbIsSpawn ? GameIdDiabloSpawn : GameIdDiabloFull)) |
35 | | - |
36 | | -#define NUMLEVELS 25 |
37 | | - |
38 | | -enum clicktype : int8_t { |
39 | | - CLICK_NONE, |
40 | | - CLICK_LEFT, |
41 | | - CLICK_RIGHT, |
42 | | -}; |
43 | | - |
44 | | -/** |
45 | | - * @brief Specifies what game logic step is currently executed |
46 | | - */ |
47 | | -enum class GameLogicStep : uint8_t { |
48 | | - None, |
49 | | - ProcessPlayers, |
50 | | - ProcessMonsters, |
51 | | - ProcessObjects, |
52 | | - ProcessMissiles, |
53 | | - ProcessItems, |
54 | | - ProcessTowners, |
55 | | - ProcessItemsTown, |
56 | | - ProcessMissilesTown, |
57 | | -}; |
58 | | - |
59 | | -enum class PlayerActionType : uint8_t { |
60 | | - None, |
61 | | - Walk, |
62 | | - Spell, |
63 | | - SpellMonsterTarget, |
64 | | - SpellPlayerTarget, |
65 | | - Attack, |
66 | | - AttackMonsterTarget, |
67 | | - AttackPlayerTarget, |
68 | | - OperateObject, |
69 | | -}; |
70 | | - |
71 | | -extern uint32_t DungeonSeeds[NUMLEVELS]; |
72 | | -extern DVL_API_FOR_TEST std::optional<uint32_t> LevelSeeds[NUMLEVELS]; |
73 | | -extern DVL_API_FOR_TEST Point MousePosition; |
74 | | - |
75 | | -extern bool gbRunGameResult; |
76 | | -extern bool ReturnToMainMenu; |
77 | | -extern bool gbProcessPlayers; |
78 | | -extern DVL_API_FOR_TEST bool gbLoadGame; |
79 | | -extern bool cineflag; |
80 | | -/* These are defined in fonts.h */ |
81 | | -extern void FontsCleanup(); |
82 | | -extern DVL_API_FOR_TEST int PauseMode; |
83 | | -extern clicktype sgbMouseDown; |
84 | | -extern uint16_t gnTickDelay; |
85 | | -extern char gszProductName[64]; |
86 | | - |
87 | | -extern PlayerActionType LastPlayerAction; |
88 | | - |
89 | | -void InitKeymapActions(); |
90 | | -void SetCursorPos(Point position); |
91 | | -void FreeGameMem(); |
92 | | -bool StartGame(bool bNewGame, bool bSinglePlayer); |
93 | | -[[noreturn]] void diablo_quit(int exitStatus); |
94 | | -int DiabloMain(int argc, char **argv); |
95 | | -bool TryIconCurs(); |
96 | | -void diablo_pause_game(); |
97 | | -bool diablo_is_focused(); |
98 | | -void diablo_focus_pause(); |
99 | | -void diablo_focus_unpause(); |
100 | | -bool PressEscKey(); |
101 | | -void DisableInputEventHandler(const SDL_Event &event, uint16_t modState); |
102 | | -tl::expected<void, std::string> LoadGameLevel(bool firstflag, lvl_entry lvldir); |
103 | | -bool IsDiabloAlive(bool playSFX); |
104 | | -void PrintScreen(SDL_Keycode vkey); |
105 | | - |
106 | | -/** |
107 | | - * @param bStartup Process additional ticks before returning |
108 | | - */ |
109 | | -bool game_loop(bool bStartup); |
110 | | -void diablo_color_cyc_logic(); |
111 | | - |
112 | | -/* rdata */ |
113 | | - |
114 | | -#ifdef _DEBUG |
115 | | -extern bool DebugDisableNetworkTimeout; |
116 | | -#endif |
117 | | - |
118 | | -/** |
119 | | - * @brief Specifies what game logic step is currently executed |
120 | | - */ |
121 | | -extern GameLogicStep gGameLogicStep; |
122 | | - |
123 | | -#ifdef __UWP__ |
124 | | -void setOnInitialized(void (*)()); |
125 | | -#endif |
126 | | - |
127 | | -} // namespace devilution |
| 1 | +/** |
| 2 | + * @file diablo.h |
| 3 | + * |
| 4 | + * Interface of the main game initialization functions. |
| 5 | + */ |
| 6 | +#pragma once |
| 7 | + |
| 8 | +#include <cstdint> |
| 9 | + |
| 10 | +#ifdef USE_SDL3 |
| 11 | +#include <SDL3/SDL_events.h> |
| 12 | +#include <SDL3/SDL_keycode.h> |
| 13 | +#else |
| 14 | +#include <SDL.h> |
| 15 | + |
| 16 | +#ifdef USE_SDL1 |
| 17 | +#include "utils/sdl2_to_1_2_backports.h" |
| 18 | +#endif |
| 19 | +#endif |
| 20 | + |
| 21 | +#ifdef _DEBUG |
| 22 | +#include "tables/monstdat.h" |
| 23 | +#endif |
| 24 | +#include "levels/gendung.h" |
| 25 | +#include "utils/attributes.h" |
| 26 | +#include "utils/endian_read.hpp" |
| 27 | + |
| 28 | +namespace devilution { |
| 29 | + |
| 30 | +constexpr uint32_t GameIdDiabloFull = LoadBE32("DRTL"); |
| 31 | +constexpr uint32_t GameIdDiabloSpawn = LoadBE32("DSHR"); |
| 32 | +constexpr uint32_t GameIdHellfireFull = LoadBE32("HRTL"); |
| 33 | +constexpr uint32_t GameIdHellfireSpawn = LoadBE32("HSHR"); |
| 34 | +#define GAME_ID (gbIsHellfire ? (gbIsSpawn ? GameIdHellfireSpawn : GameIdHellfireFull) : (gbIsSpawn ? GameIdDiabloSpawn : GameIdDiabloFull)) |
| 35 | + |
| 36 | +#define NUMLEVELS 25 |
| 37 | + |
| 38 | +enum clicktype : int8_t { |
| 39 | + CLICK_NONE, |
| 40 | + CLICK_LEFT, |
| 41 | + CLICK_RIGHT, |
| 42 | +}; |
| 43 | + |
| 44 | +/** |
| 45 | + * @brief Specifies what game logic step is currently executed |
| 46 | + */ |
| 47 | +enum class GameLogicStep : uint8_t { |
| 48 | + None, |
| 49 | + ProcessPlayers, |
| 50 | + ProcessMonsters, |
| 51 | + ProcessObjects, |
| 52 | + ProcessMissiles, |
| 53 | + ProcessItems, |
| 54 | + ProcessTowners, |
| 55 | + ProcessItemsTown, |
| 56 | + ProcessMissilesTown, |
| 57 | +}; |
| 58 | + |
| 59 | +enum class PlayerActionType : uint8_t { |
| 60 | + None, |
| 61 | + Walk, |
| 62 | + Spell, |
| 63 | + SpellMonsterTarget, |
| 64 | + SpellPlayerTarget, |
| 65 | + Attack, |
| 66 | + AttackMonsterTarget, |
| 67 | + AttackPlayerTarget, |
| 68 | + OperateObject, |
| 69 | +}; |
| 70 | + |
| 71 | +extern uint32_t DungeonSeeds[NUMLEVELS]; |
| 72 | +extern DVL_API_FOR_TEST std::optional<uint32_t> LevelSeeds[NUMLEVELS]; |
| 73 | +extern DVL_API_FOR_TEST Point MousePosition; |
| 74 | + |
| 75 | +extern bool gbRunGameResult; |
| 76 | +extern bool ReturnToMainMenu; |
| 77 | +extern bool gbProcessPlayers; |
| 78 | +extern DVL_API_FOR_TEST bool gbLoadGame; |
| 79 | +extern bool cineflag; |
| 80 | +/* These are defined in fonts.h */ |
| 81 | +extern void FontsCleanup(); |
| 82 | +extern DVL_API_FOR_TEST int PauseMode; |
| 83 | +extern clicktype sgbMouseDown; |
| 84 | +extern uint16_t gnTickDelay; |
| 85 | +extern char gszProductName[64]; |
| 86 | + |
| 87 | +extern PlayerActionType LastPlayerAction; |
| 88 | + |
| 89 | +void InitKeymapActions(); |
| 90 | +void SetCursorPos(Point position); |
| 91 | +void FreeGameMem(); |
| 92 | +bool StartGame(bool bNewGame, bool bSinglePlayer); |
| 93 | +[[noreturn]] void diablo_quit(int exitStatus); |
| 94 | +int DiabloMain(int argc, char **argv); |
| 95 | +bool TryIconCurs(); |
| 96 | +void diablo_pause_game(); |
| 97 | +bool diablo_is_focused(); |
| 98 | +void diablo_focus_pause(); |
| 99 | +void diablo_focus_unpause(); |
| 100 | +bool PressEscKey(); |
| 101 | +void DisableInputEventHandler(const SDL_Event &event, uint16_t modState); |
| 102 | +tl::expected<void, std::string> LoadGameLevel(bool firstflag, lvl_entry lvldir); |
| 103 | +bool IsDiabloAlive(bool playSFX); |
| 104 | +void PrintScreen(SDL_Keycode vkey); |
| 105 | + |
| 106 | +/** |
| 107 | + * @param bStartup Process additional ticks before returning |
| 108 | + */ |
| 109 | +bool game_loop(bool bStartup); |
| 110 | +void diablo_color_cyc_logic(); |
| 111 | + |
| 112 | +/* rdata */ |
| 113 | + |
| 114 | +#ifdef _DEBUG |
| 115 | +extern bool DebugDisableNetworkTimeout; |
| 116 | +#endif |
| 117 | + |
| 118 | +/** |
| 119 | + * @brief Specifies what game logic step is currently executed |
| 120 | + */ |
| 121 | +extern GameLogicStep gGameLogicStep; |
| 122 | + |
| 123 | +#ifdef __UWP__ |
| 124 | +void setOnInitialized(void (*)()); |
| 125 | +#endif |
| 126 | + |
| 127 | +} // namespace devilution |
0 commit comments