diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index 3bfac9b38..683d499cc 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/Source/DiabloUI/diabloui.cpp @@ -701,7 +701,7 @@ void UiAddBackground(std::vector> *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(PcxSprite { *ArtBackgroundWidescreen }, rectw, UiFlags::AlignCenter)); } diff --git a/Source/DiabloUI/selgame.cpp b/Source/DiabloUI/selgame.cpp index e7dc26417..01457b056 100644 --- a/Source/DiabloUI/selgame.cpp +++ b/Source/DiabloUI/selgame.cpp @@ -43,7 +43,7 @@ std::vector> vecSelGameDlgItems; std::vector> vecSelGameDialog; std::vector 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(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)); diff --git a/Source/controls/touch/renderers.cpp b/Source/controls/touch/renderers.cpp index 8592090c6..26b7244a7 100644 --- a/Source/controls/touch/renderers.cpp +++ b/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(CURSOR_FIRSTITEM) + static_cast(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(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); } diff --git a/Source/options.cpp b/Source/options.cpp index 76d06d03b..5210838de 100644 --- a/Source/options.cpp +++ b/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()) diff --git a/Source/platform/locale.cpp b/Source/platform/locale.cpp index 20a6e6eaf..d8e0b2a57 100644 --- a/Source/platform/locale.cpp +++ b/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 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); diff --git a/Source/player.cpp b/Source/player.cpp index 656206d4d..b9a3dbb2d 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -2316,6 +2316,8 @@ void LoadPlrGFX(Player &player, player_graphic graphic) case PlayerWeaponGraphic::MaceShield: animWeaponId = PlayerWeaponGraphic::UnarmedShield; break; + default: + break; } } diff --git a/Source/setmaps.cpp b/Source/setmaps.cpp index 81b0eb224..d02d79cc9 100644 --- a/Source/setmaps.cpp +++ b/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()); diff --git a/Source/stores.cpp b/Source/stores.cpp index 467e5177a..950bf6538 100644 --- a/Source/stores.cpp +++ b/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; }