Browse Source

Fix a few warnings

pull/4710/head
Gleb Mazovetskiy 4 years ago committed by Anders Jenbo
parent
commit
2386fd12a9
  1. 2
      Source/DiabloUI/diabloui.cpp
  2. 18
      Source/DiabloUI/selgame.cpp
  3. 13
      Source/controls/touch/renderers.cpp
  4. 2
      Source/options.cpp
  5. 4
      Source/platform/locale.cpp
  6. 2
      Source/player.cpp
  7. 3
      Source/setmaps.cpp
  8. 4
      Source/stores.cpp

2
Source/DiabloUI/diabloui.cpp

@ -701,7 +701,7 @@ void UiAddBackground(std::vector<std::unique_ptr<UiItemBase>> *vecDialog)
{
int uiPositionY = GetUIRectangle().position.y;
if (ArtBackgroundWidescreen) {
SDL_Rect rectw = { 0, uiPositionY, 0, 0 };
SDL_Rect rectw = MakeSdlRect(0, uiPositionY, 0, 0);
vecDialog->push_back(std::make_unique<UiImagePcx>(PcxSprite { *ArtBackgroundWidescreen }, rectw, UiFlags::AlignCenter));
}

18
Source/DiabloUI/selgame.cpp

@ -43,7 +43,7 @@ std::vector<std::unique_ptr<UiListItem>> vecSelGameDlgItems;
std::vector<std::unique_ptr<UiItemBase>> vecSelGameDialog;
std::vector<GameInfo> Gamelist;
uint32_t firstPublicGameInfoRequestSend = 0;
int HighlightedItem;
unsigned HighlightedItem;
void selgame_FreeVectors()
{
@ -177,7 +177,7 @@ void UiInitGameSelectionList(string_view search)
selgame_GameSelection_Select(itemValue);
};
if (search.size() > 0) {
if (!search.empty()) {
for (unsigned i = 0; i < vecSelGameDlgItems.size(); i++) {
int gameIndex = vecSelGameDlgItems[i]->m_value - 3;
if (gameIndex < 0)
@ -203,8 +203,10 @@ void selgame_GameSelection_Init()
void selgame_GameSelection_Focus(int value)
{
HighlightedItem = value;
switch (vecSelGameDlgItems[value]->m_value) {
const auto index = static_cast<unsigned>(value);
HighlightedItem = index;
const UiListItem &item = *vecSelGameDlgItems[index];
switch (item.m_value) {
case 0:
CopyUtf8(selgame_Description, _("Create a new game with a difficulty setting of your choice."), sizeof(selgame_Description));
break;
@ -219,7 +221,7 @@ void selgame_GameSelection_Focus(int value)
}
break;
default:
const auto &gameInfo = Gamelist[vecSelGameDlgItems[value]->m_value - 3];
const GameInfo &gameInfo = Gamelist[item.m_value - 3];
std::string infoString = std::string(_("Join the public game already in progress."));
infoString.append("\n\n");
if (IsGameCompatible(gameInfo.gameData)) {
@ -236,7 +238,7 @@ void selgame_GameSelection_Focus(int value)
break;
}
infoString.append(fmt::format(fmt::runtime(_(/* TRANSLATORS: {:s} means: Game Difficulty. */ "Difficulty: {:s}")), difficulty));
infoString.append("\n");
infoString += '\n';
switch (gameInfo.gameData.nTickRate) {
case 20:
AppendStrView(infoString, _("Speed: Normal"));
@ -255,11 +257,11 @@ void selgame_GameSelection_Focus(int value)
infoString.append(fmt::format("Speed: {}", gameInfo.gameData.nTickRate));
break;
}
infoString.append("\n");
infoString += '\n';
AppendStrView(infoString, _("Players: "));
for (auto &playerName : gameInfo.players) {
infoString.append(playerName);
infoString.append(" ");
infoString += ' ';
}
} else {
infoString.append(GetErrorMessageIncompatibility(gameInfo.gameData));

13
Source/controls/touch/renderers.cpp

@ -14,6 +14,7 @@
#include "stores.h"
#include "towners.h"
#include "utils/sdl_compat.h"
#include "utils/sdl_geometry.h"
#include "utils/sdl_wrap.h"
namespace devilution {
@ -116,7 +117,7 @@ void LoadPotionArt(Art *potionArt, SDL_Renderer *renderer)
ICURS_SCROLL_OF
};
int potionFrame = CURSOR_FIRSTITEM + ICURS_POTION_OF_HEALING;
int potionFrame = static_cast<int>(CURSOR_FIRSTITEM) + static_cast<int>(ICURS_POTION_OF_HEALING);
Size potionSize = GetInvItemSize(potionFrame);
auto surface = SDLWrap::CreateRGBSurfaceWithFormat(
@ -138,7 +139,7 @@ void LoadPotionArt(Art *potionArt, SDL_Renderer *renderer)
Point position { 0, 0 };
for (item_cursor_graphic graphic : potionGraphics) {
const int cursorID = CURSOR_FIRSTITEM + graphic;
const int cursorID = static_cast<int>(CURSOR_FIRSTITEM) + graphic;
const int frame = GetInvItemFrame(cursorID);
const OwnedCelSprite &potionSprite = GetInvItemSprite(cursorID);
position.y += potionSize.height;
@ -327,8 +328,8 @@ void VirtualPadButtonRenderer::Render(RenderFunction renderFunction, Art &button
int width = diameter;
int height = diameter;
SDL_Rect src { 0, offset, buttonArt.w(), buttonArt.h() };
SDL_Rect dst { x, y, width, height };
SDL_Rect src = MakeSdlRect(0, offset, buttonArt.w(), buttonArt.h());
SDL_Rect dst = MakeSdlRect(x, y, width, height);
renderFunction(buttonArt, &src, &dst);
}
@ -353,8 +354,8 @@ void PotionButtonRenderer::RenderPotion(RenderFunction renderFunction, Art &poti
int width = diameter;
int height = diameter;
SDL_Rect src { 0, offset, potionArt.w(), potionArt.h() };
SDL_Rect dst { x, y, width, height };
SDL_Rect src = MakeSdlRect(0, offset, potionArt.w(), potionArt.h());
SDL_Rect dst = MakeSdlRect(x, y, width, height);
renderFunction(potionArt, &src, &dst);
}

2
Source/options.cpp

@ -847,7 +847,7 @@ size_t OptionEntryAudioDevice::GetListSize() const
string_view OptionEntryAudioDevice::GetListDescription(size_t index) const
{
constexpr size_t MaxWidth = 500;
constexpr int MaxWidth = 500;
string_view deviceName = GetDeviceName(index);
if (deviceName.empty())

4
Source/platform/locale.cpp

@ -29,6 +29,7 @@
namespace devilution {
namespace {
#if (defined(_WIN32) && WINVER >= 0x0600) || (defined(__APPLE__) && defined(USE_COREFOUNDATION))
std::string IetfToPosix(string_view langCode)
{
/*
@ -51,6 +52,7 @@ std::string IetfToPosix(string_view langCode)
return posixLangCode;
}
#endif
} // namespace
@ -156,7 +158,7 @@ std::vector<std::string> GetLocales()
locales.push_back(std::move(locale));
}
#endif
#elif defined(__APPLE__) and defined(USE_COREFOUNDATION)
#elif defined(__APPLE__) && defined(USE_COREFOUNDATION)
// Get the user's language list (in order of preference)
CFArrayRef languages = CFLocaleCopyPreferredLanguages();
CFIndex numLanguages = CFArrayGetCount(languages);

2
Source/player.cpp

@ -2316,6 +2316,8 @@ void LoadPlrGFX(Player &player, player_graphic graphic)
case PlayerWeaponGraphic::MaceShield:
animWeaponId = PlayerWeaponGraphic::UnarmedShield;
break;
default:
break;
}
}

3
Source/setmaps.cpp

@ -167,6 +167,9 @@ void LoadSetMap()
LoadL1Dungeon(TestMapPath.c_str(), ViewPosition.x, ViewPosition.y);
AddCryptObjects(0, 0, MAXDUNX, MAXDUNY);
break;
case DTYPE_TOWN:
case DTYPE_NONE:
break;
}
LoadRndLvlPal(setlvltype);
SetMapTransparency(TestMapPath.c_str());

4
Source/stores.cpp

@ -1825,7 +1825,7 @@ void BoyBuyEnter()
else
price += boyitem._iIvalue / 2;
if (TotalPlayerGold() < price) {
if (!PlayerCanAfford(price)) {
StartStore(STORE_NOMONEY);
return;
}
@ -1953,7 +1953,7 @@ void HealerBuyEnter()
int idx = stextsval + ((stextsel - stextup) / 4);
if (TotalPlayerGold() < healitem[idx]._iIvalue) {
if (!PlayerCanAfford(healitem[idx]._iIvalue)) {
StartStore(STORE_NOMONEY);
return;
}

Loading…
Cancel
Save