Skip to content

Commit

Permalink
Fix some compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Jun 14, 2024
1 parent aa0476b commit 5ff588d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Source/controls/devices/game_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void CreateHalfSizeItemSprites()
{
if (HalfSizeItemSprites != nullptr)
return;
const int numInvItems = pCursCels->numSprites() - (static_cast<size_t>(CURSOR_FIRSTITEM) - 1)
const uint32_t numInvItems = pCursCels->numSprites() - (static_cast<uint32_t>(CURSOR_FIRSTITEM) - 1)
+ (gbIsHellfire ? pCursCels2->numSprites() : 0);
HalfSizeItemSprites = new OptionalOwnedClxSpriteList[numInvItems];
HalfSizeItemSpritesRed = new OptionalOwnedClxSpriteList[numInvItems];
Expand Down
5 changes: 5 additions & 0 deletions Source/engine/render/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions Source/missiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Source/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions Source/utils/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5ff588d

Please sign in to comment.