diff --git a/Source/diablo.cpp b/Source/diablo.cpp index d69c3233b..0ea4aa9f4 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1764,7 +1764,7 @@ void InitKeymapActions() "QuickMessage{}", N_("Quick Message {}"), N_("Use Quick Message in chat."), - (i < 4) ? SDLK_F9 + i : SDLK_UNKNOWN, + (i < 4) ? static_cast(SDLK_F9 + i) : SDLK_UNKNOWN, [i]() { DiabloHotkeyMsg(i); }, nullptr, nullptr, diff --git a/Source/engine/render/text_render.cpp b/Source/engine/render/text_render.cpp index d810a2ba3..5af788f7b 100644 --- a/Source/engine/render/text_render.cpp +++ b/Source/engine/render/text_render.cpp @@ -596,7 +596,7 @@ std::string WordWrapString(std::string_view text, unsigned width, GameFontTables const char *begin = text.data(); const char *processedEnd = text.data(); std::string_view::size_type lastBreakablePos = std::string_view::npos; - std::size_t lastBreakableLen; + std::size_t lastBreakableLen = 0; unsigned lineWidth = 0; CurrentFont currentFont; diff --git a/Source/items.cpp b/Source/items.cpp index 3cc9b7118..5ee4a8635 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -4421,11 +4421,11 @@ void SpawnBoy(int lvl) void SpawnHealer(int lvl) { - constexpr int PinnedItemCount = 2; + constexpr size_t PinnedItemCount = 2; constexpr std::array<_item_indexes, PinnedItemCount + 1> PinnedItemTypes = { IDI_HEAL, IDI_FULLHEAL, IDI_RESURRECT }; - const int itemCount = RandomIntBetween(10, gbIsHellfire ? 19 : 17); + const auto itemCount = static_cast(RandomIntBetween(10, gbIsHellfire ? 19 : 17)); - for (int i = 0; i < sizeof(healitem) / sizeof(healitem[0]); i++) { + for (size_t i = 0; i < sizeof(healitem) / sizeof(healitem[0]); ++i) { Item &item = healitem[i]; item = {}; diff --git a/Source/pack.cpp b/Source/pack.cpp index a7ee39d3c..1bde01ccf 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -116,7 +116,6 @@ bool IsTownItemValid(uint16_t iCreateInfo, const Player &player) bool IsUniqueMonsterItemValid(uint16_t iCreateInfo, uint32_t dwBuff) { const uint8_t level = iCreateInfo & CF_LEVEL; - const bool isHellfireItem = (dwBuff & CF_HELLFIRE) != 0; // Check all unique monster levels to see if they match the item level for (int i = 0; UniqueMonstersData[i].mName != nullptr; i++) { diff --git a/Source/panels/console.cpp b/Source/panels/console.cpp index d5a838cac..2dcd8bd1a 100644 --- a/Source/panels/console.cpp +++ b/Source/panels/console.cpp @@ -230,7 +230,7 @@ const ConsoleLine &GetConsoleLineFromEnd(int index) void SetHistoryIndex(int index) { InputTextChanged = true; - HistoryIndex = static_cast(ConsoleLines.size()) - (index + 1); + HistoryIndex = std::ssize(ConsoleLines) - (index + 1); if (HistoryIndex == -1) { ConsoleInputState.assign(DraftInput); return; @@ -244,8 +244,9 @@ void PrevHistoryItem(tl::function_ref filter) if (HistoryIndex == -1) { DraftInput = ConsoleInputState.value(); } - for (int i = HistoryIndex + 1; i < ConsoleLines.size(); ++i) { - const int index = static_cast(ConsoleLines.size()) - (i + 1); + const int n = std::ssize(ConsoleLines); + for (int i = HistoryIndex + 1; i < n; ++i) { + const int index = n - (i + 1); if (filter(ConsoleLines[index])) { SetHistoryIndex(index); return; @@ -255,14 +256,15 @@ void PrevHistoryItem(tl::function_ref filter) void NextHistoryItem(tl::function_ref filter) { - for (int i = static_cast(ConsoleLines.size()) - HistoryIndex; i < ConsoleLines.size(); ++i) { + const int n = std::ssize(ConsoleLines); + for (int i = n - HistoryIndex; i < n; ++i) { if (filter(ConsoleLines[i])) { SetHistoryIndex(i); return; } } if (HistoryIndex != -1) { - SetHistoryIndex(ConsoleLines.size()); + SetHistoryIndex(n); } }