Browse Source

Fix some compilation warnings

pull/6763/head
Gleb Mazovetskiy 2 years ago
parent
commit
17d5f05ada
  1. 2
      Source/diablo.cpp
  2. 2
      Source/engine/render/text_render.cpp
  3. 6
      Source/items.cpp
  4. 1
      Source/pack.cpp
  5. 12
      Source/panels/console.cpp

2
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<SDL_Keycode>(SDLK_F9 + i) : SDLK_UNKNOWN,
[i]() { DiabloHotkeyMsg(i); },
nullptr,
nullptr,

2
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;

6
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<size_t>(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 = {};

1
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++) {

12
Source/panels/console.cpp

@ -230,7 +230,7 @@ const ConsoleLine &GetConsoleLineFromEnd(int index)
void SetHistoryIndex(int index)
{
InputTextChanged = true;
HistoryIndex = static_cast<int>(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<bool(const ConsoleLine &line)> filter)
if (HistoryIndex == -1) {
DraftInput = ConsoleInputState.value();
}
for (int i = HistoryIndex + 1; i < ConsoleLines.size(); ++i) {
const int index = static_cast<int>(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<bool(const ConsoleLine &line)> filter)
void NextHistoryItem(tl::function_ref<bool(const ConsoleLine &line)> filter)
{
for (int i = static_cast<int>(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);
}
}

Loading…
Cancel
Save