diff --git a/Source/DiabloUI/credits.cpp b/Source/DiabloUI/credits.cpp index 17c343a32e8..41b765b0e84 100644 --- a/Source/DiabloUI/credits.cpp +++ b/Source/DiabloUI/credits.cpp @@ -14,6 +14,7 @@ #include "engine/render/text_render.hpp" #include "hwcursor.hpp" #include "utils/display.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/log.hpp" #include "utils/sdl_compat.h" diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index 680d1b3ca21..c1289f7b560 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/Source/DiabloUI/diabloui.cpp @@ -24,6 +24,7 @@ #include "hwcursor.hpp" #include "utils/algorithm/container.hpp" #include "utils/display.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/log.hpp" #include "utils/pcx_to_clx.hpp" diff --git a/Source/DiabloUI/dialogs.cpp b/Source/DiabloUI/dialogs.cpp index 8b125b76be0..4b60e8a27af 100644 --- a/Source/DiabloUI/dialogs.cpp +++ b/Source/DiabloUI/dialogs.cpp @@ -16,6 +16,7 @@ #include "engine/palette.h" #include "hwcursor.hpp" #include "utils/display.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/log.hpp" diff --git a/Source/DiabloUI/progress.cpp b/Source/DiabloUI/progress.cpp index bc627e38e24..2a15b61b2eb 100644 --- a/Source/DiabloUI/progress.cpp +++ b/Source/DiabloUI/progress.cpp @@ -12,6 +12,7 @@ #include "engine/render/clx_render.hpp" #include "hwcursor.hpp" #include "utils/display.h" +#include "utils/is_of.hpp" #include "utils/language.h" namespace devilution { diff --git a/Source/DiabloUI/settingsmenu.cpp b/Source/DiabloUI/settingsmenu.cpp index 3e6be08b1a5..37ae4142656 100644 --- a/Source/DiabloUI/settingsmenu.cpp +++ b/Source/DiabloUI/settingsmenu.cpp @@ -14,6 +14,7 @@ #include "engine/render/text_render.hpp" #include "hwcursor.hpp" #include "options.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/utf8.hpp" diff --git a/Source/automap.cpp b/Source/automap.cpp index 491a7846abf..23a6c93a670 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -19,6 +19,7 @@ #include "player.h" #include "utils/attributes.h" #include "utils/enum_traits.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/ui_fwd.h" #include "utils/utf8.hpp" diff --git a/Source/automap.h b/Source/automap.h index dee4cd2736b..e12d752ed4c 100644 --- a/Source/automap.h +++ b/Source/automap.h @@ -7,9 +7,9 @@ #include -#include "engine.h" #include "engine/displacement.hpp" #include "engine/point.hpp" +#include "engine/surface.hpp" #include "levels/gendung.h" #include "utils/attributes.h" diff --git a/Source/controls/controller_motion.cpp b/Source/controls/controller_motion.cpp index 23363413c0b..568a04f7493 100644 --- a/Source/controls/controller_motion.cpp +++ b/Source/controls/controller_motion.cpp @@ -13,6 +13,7 @@ #include "controls/touch/gamepad.h" #include "engine/demomode.h" #include "options.h" +#include "utils/is_of.hpp" #include "utils/log.hpp" namespace devilution { diff --git a/Source/controls/game_controls.cpp b/Source/controls/game_controls.cpp index 9c6cfd3bb56..58e74f709a3 100644 --- a/Source/controls/game_controls.cpp +++ b/Source/controls/game_controls.cpp @@ -16,6 +16,7 @@ #include "panels/spell_list.hpp" #include "qol/stash.h" #include "stores.h" +#include "utils/is_of.hpp" namespace devilution { diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 01bdbf50a3b..9045df2bc88 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -38,6 +38,7 @@ #include "stores.h" #include "towners.h" #include "track.h" +#include "utils/is_of.hpp" #include "utils/log.hpp" #include "utils/str_cat.hpp" diff --git a/Source/controls/touch/event_handlers.cpp b/Source/controls/touch/event_handlers.cpp index 5e2b3906790..e5ecbb82677 100644 --- a/Source/controls/touch/event_handlers.cpp +++ b/Source/controls/touch/event_handlers.cpp @@ -12,6 +12,7 @@ #include "panels/spell_list.hpp" #include "qol/stash.h" #include "stores.h" +#include "utils/is_of.hpp" #include "utils/ui_fwd.h" namespace devilution { diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 08f8ae84590..54174b1209c 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -34,6 +34,7 @@ #include "towners.h" #include "track.h" #include "utils/attributes.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/sdl_bilinear_scale.hpp" #include "utils/surface_to_clx.hpp" diff --git a/Source/data/file.hpp b/Source/data/file.hpp index 39a759cf0f5..4bbad2689a1 100644 --- a/Source/data/file.hpp +++ b/Source/data/file.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/Source/data/parser.hpp b/Source/data/parser.hpp index 90ce4d9ef6e..b6fd6230670 100644 --- a/Source/data/parser.hpp +++ b/Source/data/parser.hpp @@ -3,7 +3,7 @@ #include #include -#include "engine.h" // For IsAnyOf +#include "utils/is_of.hpp" namespace devilution { diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 8937e9cc836..0d55ce46673 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -86,6 +86,7 @@ #include "track.h" #include "utils/console.h" #include "utils/display.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/parse_int.hpp" #include "utils/paths.h" diff --git a/Source/dvlnet/base_protocol.h b/Source/dvlnet/base_protocol.h index c296da00b6d..6e4f205c831 100644 --- a/Source/dvlnet/base_protocol.h +++ b/Source/dvlnet/base_protocol.h @@ -11,6 +11,7 @@ #include "dvlnet/packet.h" #include "player.h" #include "utils/algorithm/container.hpp" +#include "utils/is_of.hpp" #include "utils/log.hpp" namespace devilution::net { diff --git a/Source/effects.cpp b/Source/effects.cpp index 1df897a0916..24cadcd75e1 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -19,6 +19,7 @@ #include "engine/sound_position.hpp" #include "init.h" #include "player.h" +#include "utils/is_of.hpp" namespace devilution { diff --git a/Source/engine.h b/Source/engine.h index a1ce99bf2d4..1ed3cd7aed7 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -40,18 +40,6 @@ namespace devilution { -template -DVL_ALWAYS_INLINE constexpr bool IsAnyOf(const V &v, X x, Xs... xs) -{ - return v == x || ((v == xs) || ...); -} - -template -DVL_ALWAYS_INLINE constexpr bool IsNoneOf(const V &v, X x, Xs... xs) -{ - return v != x && ((v != xs) && ...); -} - /** * @brief Fill a rectangle with the given color. */ diff --git a/Source/engine/demomode.cpp b/Source/engine/demomode.cpp index ca9d34ab62d..c0c337b4472 100644 --- a/Source/engine/demomode.cpp +++ b/Source/engine/demomode.cpp @@ -21,6 +21,7 @@ #include "utils/console.h" #include "utils/display.h" #include "utils/endian_stream.hpp" +#include "utils/is_of.hpp" #include "utils/paths.h" #include "utils/str_cat.hpp" diff --git a/Source/engine/displacement.hpp b/Source/engine/displacement.hpp index 4056335dcbe..341838b562e 100644 --- a/Source/engine/displacement.hpp +++ b/Source/engine/displacement.hpp @@ -1,6 +1,8 @@ #pragma once #include +#include + #ifdef BUILD_TESTING #include #endif diff --git a/Source/engine/events.cpp b/Source/engine/events.cpp index 7bf6051485b..ae791d6651a 100644 --- a/Source/engine/events.cpp +++ b/Source/engine/events.cpp @@ -9,6 +9,7 @@ #include "movie.h" #include "options.h" #include "panels/console.hpp" +#include "utils/is_of.hpp" #include "utils/log.hpp" #ifdef USE_SDL1 diff --git a/Source/engine/render/scrollrt.cpp b/Source/engine/render/scrollrt.cpp index 0e656c13888..d160b269aab 100644 --- a/Source/engine/render/scrollrt.cpp +++ b/Source/engine/render/scrollrt.cpp @@ -54,6 +54,7 @@ #include "towners.h" #include "utils/attributes.h" #include "utils/display.h" +#include "utils/is_of.hpp" #include "utils/log.hpp" #include "utils/str_cat.hpp" diff --git a/Source/engine/render/text_render.cpp b/Source/engine/render/text_render.cpp index a248945af12..da2e5d0ce9f 100644 --- a/Source/engine/render/text_render.cpp +++ b/Source/engine/render/text_render.cpp @@ -27,6 +27,7 @@ #include "engine/render/clx_render.hpp" #include "utils/algorithm/container.hpp" #include "utils/display.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/sdl_compat.h" #include "utils/utf8.hpp" diff --git a/Source/inv.cpp b/Source/inv.cpp index 6a88617c86a..8d20a13d127 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -33,6 +33,7 @@ #include "stores.h" #include "towners.h" #include "utils/format_int.hpp" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/sdl_geometry.h" #include "utils/str_cat.hpp" diff --git a/Source/items.cpp b/Source/items.cpp index 80fb9c98fbf..f05dbf25e85 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -41,6 +41,7 @@ #include "spells.h" #include "stores.h" #include "utils/format_int.hpp" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/log.hpp" #include "utils/math.h" diff --git a/Source/items.h b/Source/items.h index 1bb0805f4f5..db4528e1f6d 100644 --- a/Source/items.h +++ b/Source/items.h @@ -15,6 +15,7 @@ #include "engine/point.hpp" #include "itemdat.h" #include "monster.h" +#include "utils/is_of.hpp" #include "utils/string_or_view.hpp" namespace devilution { diff --git a/Source/items/validation.cpp b/Source/items/validation.cpp index b5d71a95fe9..608be7bd7b0 100644 --- a/Source/items/validation.cpp +++ b/Source/items/validation.cpp @@ -12,6 +12,7 @@ #include "monstdat.h" #include "player.h" #include "spells.h" +#include "utils/is_of.hpp" namespace devilution { diff --git a/Source/levels/drlg_l1.cpp b/Source/levels/drlg_l1.cpp index 564153ded20..bffa03ee3a5 100644 --- a/Source/levels/drlg_l1.cpp +++ b/Source/levels/drlg_l1.cpp @@ -11,6 +11,7 @@ #include "player.h" #include "quests.h" #include "utils/bitset2d.hpp" +#include "utils/is_of.hpp" namespace devilution { diff --git a/Source/levels/drlg_l2.cpp b/Source/levels/drlg_l2.cpp index b01f9659337..1e83c202b8a 100644 --- a/Source/levels/drlg_l2.cpp +++ b/Source/levels/drlg_l2.cpp @@ -19,6 +19,7 @@ #include "levels/setmaps.h" #include "player.h" #include "quests.h" +#include "utils/is_of.hpp" namespace devilution { diff --git a/Source/levels/drlg_l3.cpp b/Source/levels/drlg_l3.cpp index cf64377f1b4..9d729f27056 100644 --- a/Source/levels/drlg_l3.cpp +++ b/Source/levels/drlg_l3.cpp @@ -14,6 +14,7 @@ #include "objects.h" #include "player.h" #include "quests.h" +#include "utils/is_of.hpp" namespace devilution { diff --git a/Source/levels/drlg_l4.cpp b/Source/levels/drlg_l4.cpp index d7260aa1c58..8e2737d3610 100644 --- a/Source/levels/drlg_l4.cpp +++ b/Source/levels/drlg_l4.cpp @@ -14,6 +14,7 @@ #include "multi.h" #include "objdat.h" #include "player.h" +#include "utils/is_of.hpp" namespace devilution { diff --git a/Source/levels/gendung.cpp b/Source/levels/gendung.cpp index f625f7bd9dd..03d8e331082 100644 --- a/Source/levels/gendung.cpp +++ b/Source/levels/gendung.cpp @@ -25,6 +25,7 @@ #include "lighting.h" #include "options.h" #include "utils/bitset2d.hpp" +#include "utils/is_of.hpp" #include "utils/log.hpp" #include "utils/status_macros.hpp" diff --git a/Source/levels/themes.cpp b/Source/levels/themes.cpp index f3be95d005c..2c266dd16f3 100644 --- a/Source/levels/themes.cpp +++ b/Source/levels/themes.cpp @@ -18,6 +18,7 @@ #include "objects.h" #include "quests.h" #include "utils/algorithm/container.hpp" +#include "utils/is_of.hpp" #include "utils/str_cat.hpp" namespace devilution { diff --git a/Source/levels/trigs.cpp b/Source/levels/trigs.cpp index e91f90b1c17..3b1374dc37f 100644 --- a/Source/levels/trigs.cpp +++ b/Source/levels/trigs.cpp @@ -16,6 +16,7 @@ #include "diablo_msg.hpp" #include "init.h" #include "utils/algorithm/container.hpp" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/utf8.hpp" diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 32429c46855..e09b1e3d97e 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -18,6 +18,7 @@ #include "engine/points_in_rectangle_range.hpp" #include "player.h" #include "utils/attributes.h" +#include "utils/is_of.hpp" #include "utils/status_macros.hpp" namespace devilution { diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index ad0dc45c4b2..fe508a34813 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -38,6 +38,7 @@ #include "stores.h" #include "utils/algorithm/container.hpp" #include "utils/endian.hpp" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/status_macros.hpp" diff --git a/Source/lua/modules/dev/items.cpp b/Source/lua/modules/dev/items.cpp index bc4871e6ec3..ca329ee31bd 100644 --- a/Source/lua/modules/dev/items.cpp +++ b/Source/lua/modules/dev/items.cpp @@ -12,6 +12,7 @@ #include "lua/metadoc.hpp" #include "pack.h" #include "player.h" +#include "utils/is_of.hpp" #include "utils/str_case.hpp" #include "utils/str_cat.hpp" diff --git a/Source/lua/modules/dev/quests.cpp b/Source/lua/modules/dev/quests.cpp index a3329e82d86..138bd00f195 100644 --- a/Source/lua/modules/dev/quests.cpp +++ b/Source/lua/modules/dev/quests.cpp @@ -9,6 +9,7 @@ #include "engine.h" #include "lua/metadoc.hpp" #include "quests.h" +#include "utils/is_of.hpp" #include "utils/str_cat.hpp" namespace devilution { diff --git a/Source/missiles.cpp b/Source/missiles.cpp index f2cd1a15832..7fb7d99b8bc 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -27,6 +27,7 @@ #include "lighting.h" #include "monster.h" #include "spells.h" +#include "utils/is_of.hpp" #include "utils/str_cat.hpp" namespace devilution { diff --git a/Source/missiles.h b/Source/missiles.h index f78d6d64cc0..0411633b0bf 100644 --- a/Source/missiles.h +++ b/Source/missiles.h @@ -16,6 +16,7 @@ #include "monster.h" #include "player.h" #include "spelldat.h" +#include "utils/is_of.hpp" namespace devilution { diff --git a/Source/monster.cpp b/Source/monster.cpp index 34b734394f6..892f8fa2157 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -47,6 +47,7 @@ #include "utils/attributes.h" #include "utils/cl2_to_clx.hpp" #include "utils/file_name_generator.hpp" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/log.hpp" #include "utils/static_vector.hpp" diff --git a/Source/msg.cpp b/Source/msg.cpp index cbcfd6bcb31..2c655de82ee 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -42,6 +42,7 @@ #include "sync.h" #include "tmsg.h" #include "towners.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/str_cat.hpp" #include "utils/utf8.hpp" diff --git a/Source/multi.cpp b/Source/multi.cpp index c5d75334262..1530360c58e 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -29,6 +29,7 @@ #include "sync.h" #include "tmsg.h" #include "utils/endian.hpp" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/str_cat.hpp" diff --git a/Source/objects.cpp b/Source/objects.cpp index a326d2539c9..edbf690ddf5 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -44,6 +44,7 @@ #include "towners.h" #include "track.h" #include "utils/algorithm/container.hpp" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/log.hpp" #include "utils/str_cat.hpp" diff --git a/Source/objects.h b/Source/objects.h index 576787d15c2..7cafbaa9ebe 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -21,6 +21,7 @@ #include "objdat.h" #include "textdat.h" #include "utils/attributes.h" +#include "utils/is_of.hpp" #include "utils/string_or_view.hpp" namespace devilution { diff --git a/Source/options.cpp b/Source/options.cpp index c1a095e07fa..d6fcfd4657b 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -30,6 +30,7 @@ #include "utils/display.h" #include "utils/file_util.h" #include "utils/ini.hpp" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/log.hpp" #include "utils/logged_fstream.hpp" diff --git a/Source/pack.cpp b/Source/pack.cpp index ead5c464d87..6f0970edf30 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -15,6 +15,7 @@ #include "plrmsg.h" #include "stores.h" #include "utils/endian.hpp" +#include "utils/is_of.hpp" #include "utils/log.hpp" #include "utils/utf8.hpp" diff --git a/Source/player.cpp b/Source/player.cpp index f4b144127f0..4e771bc59dd 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -43,6 +43,7 @@ #include "spells.h" #include "stores.h" #include "towners.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/log.hpp" #include "utils/str_cat.hpp" diff --git a/Source/player.h b/Source/player.h index c703a0fec24..73860095ef3 100644 --- a/Source/player.h +++ b/Source/player.h @@ -27,6 +27,7 @@ #include "spelldat.h" #include "utils/attributes.h" #include "utils/enum_traits.h" +#include "utils/is_of.hpp" namespace devilution { diff --git a/Source/quests.cpp b/Source/quests.cpp index 984bdc8a5de..ecf573f32f6 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -28,6 +28,7 @@ #include "panels/ui_panels.hpp" #include "stores.h" #include "towners.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/utf8.hpp" diff --git a/Source/sync.cpp b/Source/sync.cpp index d758212d667..abd510ffceb 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -11,6 +11,7 @@ #include "lighting.h" #include "monster.h" #include "player.h" +#include "utils/is_of.hpp" namespace devilution { diff --git a/Source/towners.cpp b/Source/towners.cpp index b89786a185e..0894c5be5f4 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -10,6 +10,7 @@ #include "inv.h" #include "minitext.h" #include "stores.h" +#include "utils/is_of.hpp" #include "utils/language.h" #include "utils/str_case.hpp" diff --git a/Source/utils/is_of.hpp b/Source/utils/is_of.hpp new file mode 100644 index 00000000000..fff5f6c37a8 --- /dev/null +++ b/Source/utils/is_of.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "utils/attributes.h" + +namespace devilution { + +template +DVL_ALWAYS_INLINE constexpr bool IsAnyOf(const V &v, X x, Xs... xs) +{ + return v == x || ((v == xs) || ...); +} + +template +DVL_ALWAYS_INLINE constexpr bool IsNoneOf(const V &v, X x, Xs... xs) +{ + return v != x && ((v != xs) && ...); +} + +} // namespace devilution diff --git a/test/pack_test.cpp b/test/pack_test.cpp index d72d0f5cc6f..9a436ea098a 100644 --- a/test/pack_test.cpp +++ b/test/pack_test.cpp @@ -6,6 +6,7 @@ #include "monstdat.h" #include "pack.h" #include "playerdat.hpp" +#include "utils/is_of.hpp" #include "utils/paths.h" namespace devilution {