diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d4b7dc44f..3bd75d38f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -16,6 +16,7 @@ set(libdevilutionx_SRCS game_mode.cpp gamemenu.cpp gmenu.cpp + headless_mode.cpp help.cpp hwcursor.cpp init.cpp diff --git a/Source/control.cpp b/Source/control.cpp index 392551aea..3d1f126bc 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -28,6 +28,7 @@ #include "engine/render/text_render.hpp" #include "engine/trn.hpp" #include "gamemenu.h" +#include "headless_mode.hpp" #include "init.h" #include "inv.h" #include "inv_iterators.hpp" diff --git a/Source/cursor.cpp b/Source/cursor.cpp index d05419468..91d4bd652 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -24,6 +24,7 @@ #include "engine/render/clx_render.hpp" #include "engine/render/primitive_render.hpp" #include "engine/trn.hpp" +#include "headless_mode.hpp" #include "hwcursor.hpp" #include "inv.h" #include "levels/trigs.h" diff --git a/Source/data/file.cpp b/Source/data/file.cpp index b2760d057..a6c9c6269 100644 --- a/Source/data/file.cpp +++ b/Source/data/file.cpp @@ -1,5 +1,12 @@ #include "file.hpp" +#include +#include +#include +#include +#include + +#include #include #include "engine/assets.hpp" diff --git a/Source/dead.cpp b/Source/dead.cpp index 92d9bdf40..99c41edd4 100644 --- a/Source/dead.cpp +++ b/Source/dead.cpp @@ -8,6 +8,7 @@ #include #include "diablo.h" +#include "headless_mode.hpp" #include "levels/gendung.h" #include "lighting.h" #include "misdat.h" diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 762eb605e..968bef574 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -41,6 +41,7 @@ #include "game_mode.hpp" #include "gamemenu.h" #include "gmenu.h" +#include "headless_mode.hpp" #include "help.h" #include "hwcursor.hpp" #include "init.h" @@ -125,7 +126,6 @@ bool cineflag; int PauseMode; bool gbBard; bool gbBarbarian; -bool HeadlessMode = false; clicktype sgbMouseDown; uint16_t gnTickDelay = 50; char gszProductName[64] = "DevilutionX vUnknown"; diff --git a/Source/diablo.h b/Source/diablo.h index 31793c1fe..e742e2561 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -71,10 +71,6 @@ extern void FontsCleanup(); extern DVL_API_FOR_TEST int PauseMode; extern bool gbBard; extern bool gbBarbarian; -/** - * @brief Don't load UI or show Messageboxes or other user-interaction. Needed for UnitTests. - */ -extern DVL_API_FOR_TEST bool HeadlessMode; extern clicktype sgbMouseDown; extern uint16_t gnTickDelay; extern char gszProductName[64]; diff --git a/Source/engine/assets.hpp b/Source/engine/assets.hpp index 13ea7976e..0d964cf59 100644 --- a/Source/engine/assets.hpp +++ b/Source/engine/assets.hpp @@ -13,8 +13,8 @@ #include #include "appfat.h" -#include "diablo.h" #include "game_mode.hpp" +#include "headless_mode.hpp" #include "utils/file_util.h" #include "utils/language.h" #include "utils/str_cat.hpp" diff --git a/Source/engine/demomode.cpp b/Source/engine/demomode.cpp index c0c337b44..5cfb4a903 100644 --- a/Source/engine/demomode.cpp +++ b/Source/engine/demomode.cpp @@ -14,6 +14,7 @@ #include "controls/plrctrls.h" #include "engine/events.hpp" #include "gmenu.h" +#include "headless_mode.hpp" #include "menu.h" #include "nthread.h" #include "options.h" diff --git a/Source/engine/dx.cpp b/Source/engine/dx.cpp index f88639b41..c2a3b05c2 100644 --- a/Source/engine/dx.cpp +++ b/Source/engine/dx.cpp @@ -10,6 +10,7 @@ #include "controls/plrctrls.h" #include "engine/render/primitive_render.hpp" +#include "headless_mode.hpp" #include "options.h" #include "utils/display.h" #include "utils/log.hpp" diff --git a/Source/engine/load_file.hpp b/Source/engine/load_file.hpp index 84827ff67..354e6a5d9 100644 --- a/Source/engine/load_file.hpp +++ b/Source/engine/load_file.hpp @@ -7,11 +7,10 @@ #include #include -#include #include "appfat.h" -#include "diablo.h" #include "engine/assets.hpp" +#include "headless_mode.hpp" #include "mpq/mpq_common.hpp" #include "utils/static_vector.hpp" #include "utils/str_cat.hpp" diff --git a/Source/engine/palette.cpp b/Source/engine/palette.cpp index 6ee05fd2f..a2e46f356 100644 --- a/Source/engine/palette.cpp +++ b/Source/engine/palette.cpp @@ -14,6 +14,7 @@ #include "engine/dx.h" #include "engine/load_file.hpp" #include "engine/random.hpp" +#include "headless_mode.hpp" #include "hwcursor.hpp" #include "options.h" #include "utils/display.h" diff --git a/Source/engine/render/scrollrt.cpp b/Source/engine/render/scrollrt.cpp index 34bafbc9e..7d87eade0 100644 --- a/Source/engine/render/scrollrt.cpp +++ b/Source/engine/render/scrollrt.cpp @@ -28,6 +28,7 @@ #include "engine/trn.hpp" #include "engine/world_tile.hpp" #include "gmenu.h" +#include "headless_mode.hpp" #include "help.h" #include "hwcursor.hpp" #include "init.h" diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index e2e5aa87c..9fc19a3fe 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -12,6 +12,7 @@ #include "engine/sound.h" #include "engine/sound_defs.hpp" #include "gmenu.h" +#include "headless_mode.hpp" #include "init.h" #include "loadsave.h" #include "options.h" diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 52b450459..c5fb3b2d3 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -18,6 +18,7 @@ #include "engine/render/clx_render.hpp" #include "engine/render/primitive_render.hpp" #include "engine/render/text_render.hpp" +#include "headless_mode.hpp" #include "options.h" #include "stores.h" #include "utils/language.h" diff --git a/Source/headless_mode.cpp b/Source/headless_mode.cpp new file mode 100644 index 000000000..67bbd3adc --- /dev/null +++ b/Source/headless_mode.cpp @@ -0,0 +1,7 @@ +#include "headless_mode.hpp" + +namespace devilution { + +bool HeadlessMode; + +} // namespace devilution diff --git a/Source/headless_mode.hpp b/Source/headless_mode.hpp new file mode 100644 index 000000000..f1d217bc1 --- /dev/null +++ b/Source/headless_mode.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "utils/attributes.h" + +namespace devilution { + +/** + * @brief Don't load UI or show Messageboxes or other user-interaction. Needed for unit tests. + */ +extern DVL_API_FOR_TEST bool HeadlessMode; + +} // namespace devilution diff --git a/Source/init.cpp b/Source/init.cpp index 290837aae..745c0fedb 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -22,6 +22,7 @@ #include "engine/dx.h" #include "engine/events.hpp" #include "game_mode.hpp" +#include "headless_mode.hpp" #include "hwcursor.hpp" #include "options.h" #include "pfile.h" diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 9effe977e..78c3c24f5 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -20,6 +20,7 @@ #include "engine/palette.h" #include "engine/render/clx_render.hpp" #include "engine/render/primitive_render.hpp" +#include "headless_mode.hpp" #include "hwcursor.hpp" #include "init.h" #include "loadsave.h" diff --git a/Source/items.cpp b/Source/items.cpp index 9c2e066e0..7577df4ab 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -27,6 +27,7 @@ #include "engine/render/clx_render.hpp" #include "engine/render/primitive_render.hpp" #include "engine/render/text_render.hpp" +#include "headless_mode.hpp" #include "init.h" #include "inv_iterators.hpp" #include "levels/town.h" diff --git a/Source/misdat.cpp b/Source/misdat.cpp index 62ed3f604..5dc496ac6 100644 --- a/Source/misdat.cpp +++ b/Source/misdat.cpp @@ -15,6 +15,7 @@ #include "data/file.hpp" #include "data/iterators.hpp" #include "data/record_reader.hpp" +#include "headless_mode.hpp" #include "missiles.h" #include "mpq/mpq_common.hpp" #include "utils/file_name_generator.hpp" diff --git a/Source/missiles.cpp b/Source/missiles.cpp index f757990e3..3f1838615 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -22,6 +22,7 @@ #include "engine/points_in_rectangle_range.hpp" #include "engine/random.hpp" #include "engine/render/primitive_render.hpp" +#include "headless_mode.hpp" #include "init.h" #include "inv.h" #include "levels/dun_tile.hpp" diff --git a/Source/monster.cpp b/Source/monster.cpp index 182e9520a..572d0fa46 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -31,6 +31,7 @@ #include "engine/sound_position.hpp" #include "engine/world_tile.hpp" #include "game_mode.hpp" +#include "headless_mode.hpp" #include "init.h" #include "levels/crypt.h" #include "levels/drlg_l4.h" diff --git a/Source/objects.cpp b/Source/objects.cpp index edbf690dd..60431d218 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -26,6 +26,7 @@ #include "engine/load_file.hpp" #include "engine/points_in_rectangle_range.hpp" #include "engine/random.hpp" +#include "headless_mode.hpp" #include "init.h" #include "inv.h" #include "inv_iterators.hpp" diff --git a/Source/player.cpp b/Source/player.cpp index 4cdc01c2a..cba3a5ea3 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -26,6 +26,7 @@ #include "engine/world_tile.hpp" #include "game_mode.hpp" #include "gamemenu.h" +#include "headless_mode.hpp" #include "help.h" #include "init.h" #include "inv_iterators.hpp" diff --git a/Source/qol/stash.cpp b/Source/qol/stash.cpp index fb034d955..4f447a2c7 100644 --- a/Source/qol/stash.cpp +++ b/Source/qol/stash.cpp @@ -17,6 +17,7 @@ #include "engine/render/clx_render.hpp" #include "engine/render/text_render.hpp" #include "engine/size.hpp" +#include "headless_mode.hpp" #include "hwcursor.hpp" #include "inv.h" #include "minitext.h" diff --git a/Source/storm/storm_net.cpp b/Source/storm/storm_net.cpp index 1692ca1f6..72bf4498b 100644 --- a/Source/storm/storm_net.cpp +++ b/Source/storm/storm_net.cpp @@ -13,6 +13,7 @@ #include "dvlnet/abstract_net.h" #include "engine/demomode.h" +#include "headless_mode.hpp" #include "menu.h" #include "options.h" #include "utils/stubs.h" diff --git a/Source/utils/display.cpp b/Source/utils/display.cpp index f15530c43..efd972f8d 100644 --- a/Source/utils/display.cpp +++ b/Source/utils/display.cpp @@ -28,6 +28,7 @@ #include "controls/touch/gamepad.h" #include "engine/backbuffer_state.hpp" #include "engine/dx.h" +#include "headless_mode.hpp" #include "options.h" #include "utils/log.hpp" #include "utils/sdl_geometry.h" diff --git a/test/main.cpp b/test/main.cpp index b686818d4..912e63ff9 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,6 +1,6 @@ #include -#include "diablo.h" +#include "headless_mode.hpp" #include "options.h" #include "utils/paths.h" diff --git a/test/timedemo_test.cpp b/test/timedemo_test.cpp index 9d370e3f5..b67498bbb 100644 --- a/test/timedemo_test.cpp +++ b/test/timedemo_test.cpp @@ -5,6 +5,7 @@ #include "diablo.h" #include "engine/demomode.h" #include "game_mode.hpp" +#include "headless_mode.hpp" #include "lua/lua.hpp" #include "monstdat.h" #include "options.h"