Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract game mode out of init.cpp #7628

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(libdevilutionx_SRCS
diablo.cpp
diablo_msg.cpp
doom.cpp
game_mode.cpp
gamemenu.cpp
gmenu.cpp
help.cpp
Expand Down
1 change: 1 addition & 0 deletions Source/DiabloUI/hero/selhero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/DiabloUI/mainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions Source/DiabloUI/selok.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Source/engine/assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/engine/assets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions Source/game_mode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "game_mode.hpp"

namespace devilution {
bool gbIsSpawn;
bool gbIsHellfire;
bool gbVanilla;
bool forceHellfire;
} // namespace devilution
16 changes: 16 additions & 0 deletions Source/game_mode.hpp
Original file line number Diff line number Diff line change
@@ -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 changes: 1 addition & 8 deletions Source/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {

Expand Down
4 changes: 0 additions & 4 deletions Source/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
1 change: 1 addition & 0 deletions Source/levels/trigs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion Source/lighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cstdint>

#include "engine/random.hpp"
#include "game_mode.hpp"
#include "init.h"
#include "items/validation.h"
#include "loadsave.h"
Expand Down
1 change: 1 addition & 0 deletions Source/panels/spell_icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions Source/pfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/quests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/stores.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions Source/towners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions test/items_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions test/pack_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <gtest/gtest.h>

#include "cursor.h"
#include "game_mode.hpp"
#include "monstdat.h"
#include "pack.h"
#include "playerdat.hpp"
Expand Down
1 change: 1 addition & 0 deletions test/timedemo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions test/writehero_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <picosha2.h>

#include "cursor.h"
#include "game_mode.hpp"
#include "init.h"
#include "loadsave.h"
#include "pack.h"
Expand Down
Loading