Browse Source

Extract game mode out of init.cpp

Untangles some dependencies
pull/7623/head
Gleb Mazovetskiy 1 year ago
parent
commit
b76feb2be3
  1. 1
      Source/CMakeLists.txt
  2. 1
      Source/DiabloUI/hero/selhero.cpp
  3. 1
      Source/DiabloUI/mainmenu.cpp
  4. 1
      Source/DiabloUI/selok.cpp
  5. 1
      Source/diablo.cpp
  6. 2
      Source/engine/assets.cpp
  7. 1
      Source/engine/assets.hpp
  8. 8
      Source/game_mode.cpp
  9. 16
      Source/game_mode.hpp
  10. 9
      Source/init.cpp
  11. 4
      Source/init.h
  12. 1
      Source/levels/trigs.cpp
  13. 1
      Source/lighting.cpp
  14. 1
      Source/menu.cpp
  15. 1
      Source/monster.cpp
  16. 1
      Source/monster.h
  17. 1
      Source/options.cpp
  18. 1
      Source/pack.cpp
  19. 1
      Source/panels/spell_icons.cpp
  20. 1
      Source/pfile.cpp
  21. 1
      Source/player.cpp
  22. 1
      Source/player.h
  23. 1
      Source/quests.cpp
  24. 1
      Source/spells.cpp
  25. 1
      Source/stores.h
  26. 1
      Source/towners.cpp
  27. 1
      test/items_test.cpp
  28. 1
      test/pack_test.cpp
  29. 1
      test/timedemo_test.cpp
  30. 1
      test/writehero_test.cpp

1
Source/CMakeLists.txt

@ -13,6 +13,7 @@ set(libdevilutionx_SRCS
diablo.cpp
diablo_msg.cpp
doom.cpp
game_mode.cpp
gamemenu.cpp
gmenu.cpp
help.cpp

1
Source/DiabloUI/hero/selhero.cpp

@ -15,6 +15,7 @@
#include "DiabloUI/selyesno.h"
#include "control.h"
#include "controls/plrctrls.h"
#include "game_mode.hpp"
#include "menu.h"
#include "options.h"
#include "pfile.h"

1
Source/DiabloUI/mainmenu.cpp

@ -4,6 +4,7 @@
#include "DiabloUI/selok.h"
#include "control.h"
#include "engine/load_clx.hpp"
#include "game_mode.hpp"
#include "utils/language.h"
namespace devilution {

1
Source/DiabloUI/selok.cpp

@ -3,6 +3,7 @@
#include "DiabloUI/diabloui.h"
#include "control.h"
#include "engine/render/text_render.hpp"
#include "game_mode.hpp"
#include "utils/language.h"
#include "utils/utf8.hpp"

1
Source/diablo.cpp

@ -38,6 +38,7 @@
#include "engine/random.hpp"
#include "engine/render/clx_render.hpp"
#include "engine/sound.h"
#include "game_mode.hpp"
#include "gamemenu.h"
#include "gmenu.h"
#include "help.h"

2
Source/engine/assets.cpp

@ -5,7 +5,7 @@
#include <cstring>
#include <string_view>
#include "init.h"
#include "game_mode.hpp"
#include "utils/file_util.h"
#include "utils/log.hpp"
#include "utils/paths.h"

1
Source/engine/assets.hpp

@ -14,6 +14,7 @@
#include "appfat.h"
#include "diablo.h"
#include "game_mode.hpp"
#include "utils/file_util.h"
#include "utils/language.h"
#include "utils/str_cat.hpp"

8
Source/game_mode.cpp

@ -0,0 +1,8 @@
#include "game_mode.hpp"
namespace devilution {
bool gbIsSpawn;
bool gbIsHellfire;
bool gbVanilla;
bool forceHellfire;
} // namespace devilution

16
Source/game_mode.hpp

@ -0,0 +1,16 @@
#pragma once
#include "utils/attributes.h"
namespace devilution {
/** Indicate if we only have access to demo data */
extern DVL_API_FOR_TEST bool gbIsSpawn;
/** Indicate if we have loaded the Hellfire expansion data */
extern DVL_API_FOR_TEST bool gbIsHellfire;
/** Indicate if we want vanilla savefiles */
extern DVL_API_FOR_TEST bool gbVanilla;
/** Whether the Hellfire mode is required (forced). */
extern bool forceHellfire;
} // namespace devilution

9
Source/init.cpp

@ -21,6 +21,7 @@
#include "engine/backbuffer_state.hpp"
#include "engine/dx.h"
#include "engine/events.hpp"
#include "game_mode.hpp"
#include "hwcursor.hpp"
#include "options.h"
#include "pfile.h"
@ -46,14 +47,6 @@ namespace devilution {
/** True if the game is the current active window */
bool gbActive;
/** Indicate if we only have access to demo data */
bool gbIsSpawn;
/** Indicate if we have loaded the Hellfire expansion data */
bool gbIsHellfire;
/** Indicate if we want vanilla savefiles */
bool gbVanilla;
/** Whether the Hellfire mode is required (forced). */
bool forceHellfire;
namespace {

4
Source/init.h

@ -20,10 +20,6 @@ namespace devilution {
/** True if the game is the current active window */
extern bool gbActive;
extern DVL_API_FOR_TEST bool gbIsSpawn;
extern DVL_API_FOR_TEST bool gbIsHellfire;
extern DVL_API_FOR_TEST bool gbVanilla;
extern bool forceHellfire;
inline bool HaveSpawn()
{

1
Source/levels/trigs.cpp

@ -14,6 +14,7 @@
#include "controls/plrctrls.h"
#include "cursor.h"
#include "diablo_msg.hpp"
#include "game_mode.hpp"
#include "init.h"
#include "utils/algorithm/container.hpp"
#include "utils/is_of.hpp"

1
Source/lighting.cpp

@ -13,7 +13,6 @@
#include <expected.hpp>
#include "automap.h"
#include "diablo.h"
#include "engine/load_file.hpp"
#include "engine/points_in_rectangle_range.hpp"
#include "player.h"

1
Source/menu.cpp

@ -9,6 +9,7 @@
#include "DiabloUI/diabloui.h"
#include "DiabloUI/settingsmenu.h"
#include "engine/demomode.h"
#include "game_mode.hpp"
#include "init.h"
#include "movie.h"
#include "options.h"

1
Source/monster.cpp

@ -30,6 +30,7 @@
#include "engine/render/clx_render.hpp"
#include "engine/sound_position.hpp"
#include "engine/world_tile.hpp"
#include "game_mode.hpp"
#include "init.h"
#include "levels/crypt.h"
#include "levels/drlg_l4.h"

1
Source/monster.h

@ -21,6 +21,7 @@
#include "engine/point.hpp"
#include "engine/sound.h"
#include "engine/world_tile.hpp"
#include "game_mode.hpp"
#include "init.h"
#include "levels/dun_tile.hpp"
#include "misdat.h"

1
Source/options.cpp

@ -21,6 +21,7 @@
#include "discord/discord.h"
#include "engine/demomode.h"
#include "engine/sound_defs.hpp"
#include "game_mode.hpp"
#include "hwcursor.hpp"
#include "options.h"
#include "platform/locale.hpp"

1
Source/pack.cpp

@ -8,6 +8,7 @@
#include <cstdint>
#include "engine/random.hpp"
#include "game_mode.hpp"
#include "init.h"
#include "items/validation.h"
#include "loadsave.h"

1
Source/panels/spell_icons.cpp

@ -8,6 +8,7 @@
#include "engine/palette.h"
#include "engine/render/clx_render.hpp"
#include "engine/render/primitive_render.hpp"
#include "game_mode.hpp"
#include "init.h"
namespace devilution {

1
Source/pfile.cpp

@ -16,6 +16,7 @@
#include "codec.h"
#include "engine/load_file.hpp"
#include "engine/render/primitive_render.hpp"
#include "game_mode.hpp"
#include "init.h"
#include "loadsave.h"
#include "menu.h"

1
Source/player.cpp

@ -24,6 +24,7 @@
#include "engine/render/clx_render.hpp"
#include "engine/trn.hpp"
#include "engine/world_tile.hpp"
#include "game_mode.hpp"
#include "gamemenu.h"
#include "help.h"
#include "init.h"

1
Source/player.h

@ -18,6 +18,7 @@
#include "engine/displacement.hpp"
#include "engine/path.h"
#include "engine/point.hpp"
#include "game_mode.hpp"
#include "interfac.h"
#include "items.h"
#include "items/validation.h"

1
Source/quests.cpp

@ -17,6 +17,7 @@
#include "engine/render/clx_render.hpp"
#include "engine/render/text_render.hpp"
#include "engine/world_tile.hpp"
#include "game_mode.hpp"
#include "init.h"
#include "levels/gendung.h"
#include "levels/town.h"

1
Source/spells.cpp

@ -14,6 +14,7 @@
#include "engine/point.hpp"
#include "engine/random.hpp"
#include "engine/world_tile.hpp"
#include "game_mode.hpp"
#include "gamemenu.h"
#include "inv.h"
#include "missiles.h"

1
Source/stores.h

@ -12,6 +12,7 @@
#include "control.h"
#include "engine/clx_sprite.hpp"
#include "engine/surface.hpp"
#include "game_mode.hpp"
#include "utils/attributes.h"
namespace devilution {

1
Source/towners.cpp

@ -7,6 +7,7 @@
#include "engine/load_cel.hpp"
#include "engine/load_file.hpp"
#include "engine/random.hpp"
#include "game_mode.hpp"
#include "inv.h"
#include "minitext.h"
#include "stores.h"

1
test/items_test.cpp

@ -4,6 +4,7 @@
#include <gtest/gtest.h>
#include "engine/random.hpp"
#include "game_mode.hpp"
#include "items.h"
#include "player.h"
#include "spells.h"

1
test/pack_test.cpp

@ -3,6 +3,7 @@
#include <gtest/gtest.h>
#include "cursor.h"
#include "game_mode.hpp"
#include "monstdat.h"
#include "pack.h"
#include "playerdat.hpp"

1
test/timedemo_test.cpp

@ -4,6 +4,7 @@
#include "diablo.h"
#include "engine/demomode.h"
#include "game_mode.hpp"
#include "lua/lua.hpp"
#include "monstdat.h"
#include "options.h"

1
test/writehero_test.cpp

@ -9,6 +9,7 @@
#include <picosha2.h>
#include "cursor.h"
#include "game_mode.hpp"
#include "init.h"
#include "loadsave.h"
#include "pack.h"

Loading…
Cancel
Save