diff --git a/Source/controls/devices/game_controller.cpp b/Source/controls/devices/game_controller.cpp index 55512d4eb..b1e78d84d 100644 --- a/Source/controls/devices/game_controller.cpp +++ b/Source/controls/devices/game_controller.cpp @@ -271,7 +271,10 @@ GamepadLayout GameController::getLayout(const SDL_Event &event) case SDL_CONTROLLER_TYPE_VIRTUAL: #endif case SDL_CONTROLLER_TYPE_UNKNOWN: - return GamepadLayout::Generic; +#if SDL_VERSION_ATLEAST(2, 30, 0) + case SDL_CONTROLLER_TYPE_MAX: +#endif + break; } #endif return GamepadLayout::Generic; diff --git a/Source/cursor.cpp b/Source/cursor.cpp index c2e5dd0e6..33c259002 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -470,7 +470,7 @@ void CreateHalfSizeItemSprites() { if (HalfSizeItemSprites != nullptr) return; - const int numInvItems = pCursCels->numSprites() - (static_cast(CURSOR_FIRSTITEM) - 1) + const uint32_t numInvItems = pCursCels->numSprites() - (static_cast(CURSOR_FIRSTITEM) - 1) + (gbIsHellfire ? pCursCels2->numSprites() : 0); HalfSizeItemSprites = new OptionalOwnedClxSpriteList[numInvItems]; HalfSizeItemSpritesRed = new OptionalOwnedClxSpriteList[numInvItems]; diff --git a/Source/engine/render/scrollrt.cpp b/Source/engine/render/scrollrt.cpp index f0dd77a46..aabb04503 100644 --- a/Source/engine/render/scrollrt.cpp +++ b/Source/engine/render/scrollrt.cpp @@ -45,6 +45,7 @@ #include "qol/xpbar.h" #include "stores.h" #include "towners.h" +#include "utils/attributes.h" #include "utils/bitset2d.hpp" #include "utils/display.h" #include "utils/endian.hpp" @@ -758,6 +759,8 @@ void DrawDungeon(const Surface &out, Point tilePosition, Point targetBufferPosit case Direction::SouthEast: tempTargetBufferPosition += { -TILE_WIDTH / 2, -TILE_HEIGHT / 2 }; break; + default: + DVL_UNREACHABLE(); } tempTilePosition += Opposite(player->_pdir); } else if (player->_pmode == PM_WALK_SIDEWAYS && player->_pdir == Direction::East) { @@ -793,6 +796,8 @@ void DrawDungeon(const Surface &out, Point tilePosition, Point targetBufferPosit case Direction::SouthEast: tempTargetBufferPosition += { -TILE_WIDTH / 2, -TILE_HEIGHT / 2 }; break; + default: + DVL_UNREACHABLE(); } tempTilePosition += Opposite(monster->direction); } else if (monster->mode == MonsterMode::MoveSideways && monster->direction == Direction::East) { diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 713c153c2..8f1d2cf9a 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -691,7 +691,7 @@ bool GuardianTryFireAt(Missile &missile, Point target) bool GrowWall(int id, Point position, Point target, MissileID type, int spellLevel, int damage) { - int dp = dPiece[position.x][position.y]; + [[maybe_unused]] int dp = dPiece[position.x][position.y]; assert(dp <= MAXTILES && dp >= 0); if (TileHasAny(position, TileProperties::BlockMissile) || !InDungeonBounds(target)) { @@ -719,7 +719,7 @@ void SpawnLightning(Missile &missile, int dam) MoveMissile( missile, [&](Point tile) { assert(InDungeonBounds(tile)); - int pn = dPiece[tile.x][tile.y]; + [[maybe_unused]] int pn = dPiece[tile.x][tile.y]; assert(pn >= 0 && pn <= MAXTILES); if (!missile.IsTrap() || tile != missile.position.start) { @@ -3805,7 +3805,7 @@ void ProcessFlameWaveControl(Missile &missile) Direction dira = Left(Left(sd)); Direction dirb = Right(Right(sd)); Point na = src + sd; - int pn = dPiece[na.x][na.y]; + [[maybe_unused]] int pn = dPiece[na.x][na.y]; assert(pn >= 0 && pn <= MAXTILES); if (!TileHasAny(na, TileProperties::BlockMissile)) { Direction pdir = Players[id]._pdir; diff --git a/Source/monster.cpp b/Source/monster.cpp index bc34261ae..c2bde27e1 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -41,6 +41,7 @@ #include "spelldat.h" #include "storm/storm_net.hpp" #include "towners.h" +#include "utils/attributes.h" #include "utils/cl2_to_clx.hpp" #include "utils/file_name_generator.hpp" #include "utils/language.h" @@ -734,6 +735,9 @@ void WalkInDirection(Monster &monster, Direction endDir) case Direction::SouthEast: mode = MonsterMode::MoveSouthwards; break; + case Direction::NoDirection: + DVL_UNREACHABLE(); + break; } monster.mode = mode; monster.position.old = monster.position.tile; diff --git a/Source/utils/attributes.h b/Source/utils/attributes.h index 309c8bc3f..7d2beb962 100644 --- a/Source/utils/attributes.h +++ b/Source/utils/attributes.h @@ -88,3 +88,11 @@ #ifndef DVL_ASSUME #define DVL_ASSUME(...) #endif + +#if defined(__clang__) || defined(__GNUC__) +#define DVL_UNREACHABLE() __builtin_unreachable() +#elif defined(_MSC_VER) +#define DVL_UNREACHABLE() __assume(false) +#else +#define DVL_UNREACHABLE() +#endif