Browse Source

Fix a few build warnings

pull/3452/head
Gleb Mazovetskiy 4 years ago committed by Anders Jenbo
parent
commit
b8affd5fe5
  1. 2
      Source/DiabloUI/credits.cpp
  2. 18
      Source/DiabloUI/diabloui.cpp
  3. 6
      Source/diablo.cpp
  4. 4
      Source/inv.cpp
  5. 2
      Source/loadsave.cpp

2
Source/DiabloUI/credits.cpp

@ -118,7 +118,7 @@ void CreditsRenderer::Render()
auto &lineContent = linesToRender[i];
SDL_Rect dstRect { destX + lineContent.offset, destY, 0, 0 };
SDL_Rect dstRect = MakeSdlRect(destX + lineContent.offset, destY, 0, 0);
ScaleOutputRect(&dstRect);
const Surface &out = Surface(DiabloUiSurface());
DrawString(out, lineContent.text, Point { dstRect.x, dstRect.y }, UiFlags::FontSizeDialog | UiFlags::ColorDialogWhite);

18
Source/DiabloUI/diabloui.cpp

@ -19,11 +19,12 @@
#include "hwcursor.hpp"
#include "palette.h"
#include "utils/display.h"
#include "utils/language.h"
#include "utils/log.hpp"
#include "utils/sdl_compat.h"
#include "utils/sdl_geometry.h"
#include "utils/sdl_wrap.h"
#include "utils/stubs.h"
#include "utils/language.h"
#include "utils/utf8.hpp"
#ifdef __SWITCH__
@ -470,15 +471,6 @@ bool IsInsideRect(const SDL_Event &event, const SDL_Rect &rect)
return SDL_PointInRect(&point, &rect) == SDL_TRUE;
}
// Equivalent to SDL_Rect { ... } but avoids -Wnarrowing.
inline SDL_Rect MakeRect(int x, int y, int w, int h)
{
using Pos = decltype(SDL_Rect {}.x);
using Len = decltype(SDL_Rect {}.w);
return SDL_Rect { static_cast<Pos>(x), static_cast<Pos>(y),
static_cast<Len>(w), static_cast<Len>(h) };
}
void LoadHeros()
{
LoadArt("ui_art\\heros.pcx", &ArtHero);
@ -501,8 +493,8 @@ void LoadHeros()
if (offset + portraitHeight > ArtHero.h()) {
offset = 0;
}
SDL_Rect srcRect = MakeRect(0, offset, ArtHero.w(), portraitHeight);
SDL_Rect dstRect = MakeRect(0, i * portraitHeight, ArtHero.w(), portraitHeight);
SDL_Rect srcRect = MakeSdlRect(0, offset, ArtHero.w(), portraitHeight);
SDL_Rect dstRect = MakeSdlRect(0, i * portraitHeight, ArtHero.w(), portraitHeight);
SDL_BlitSurface(ArtHero.surface.get(), &srcRect, heros.get(), &dstRect);
}
@ -514,7 +506,7 @@ void LoadHeros()
if (portrait.surface == nullptr)
continue;
SDL_Rect dstRect = MakeRect(0, i * portraitHeight, portrait.w(), portraitHeight);
SDL_Rect dstRect = MakeSdlRect(0, i * portraitHeight, portrait.w(), portraitHeight);
SDL_BlitSurface(portrait.surface.get(), nullptr, heros.get(), &dstRect);
}

6
Source/diablo.cpp

@ -1903,16 +1903,16 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir)
if (leveltype != DTYPE_TOWN) {
if (firstflag || lvldir == ENTRY_LOAD || !myPlayer._pLvlVisited[currlevel] || gbIsMultiplayer) {
HoldThemeRooms();
uint32_t mid1Seed = GetLCGEngineState();
[[maybe_unused]] uint32_t mid1Seed = GetLCGEngineState();
InitMonsters();
uint32_t mid2Seed = GetLCGEngineState();
[[maybe_unused]] uint32_t mid2Seed = GetLCGEngineState();
IncProgress();
InitObjects();
InitItems();
if (currlevel < 17)
CreateThemeRooms();
IncProgress();
uint32_t mid3Seed = GetLCGEngineState();
[[maybe_unused]] uint32_t mid3Seed = GetLCGEngineState();
InitMissiles();
InitCorpses();
#if _DEBUG

4
Source/inv.cpp

@ -8,6 +8,7 @@
#include <algorithm>
#include <fmt/format.h>
#include "controls/plrctrls.h"
#include "cursor.h"
#include "engine/cel_sprite.hpp"
#include "engine/load_cel.hpp"
@ -22,7 +23,6 @@
#include "stores.h"
#include "town.h"
#include "towners.h"
#include "controls/plrctrls.h"
#include "utils/language.h"
#include "utils/sdl_geometry.h"
#include "utils/stdcompat/optional.hpp"
@ -1163,7 +1163,7 @@ void StartGoldDrop()
control_reset_talk();
Point start = GetPanelPosition(UiPanels::Inventory, { 67, 128 });
SDL_Rect rect = { start.x, start.y, 180, 20 };
SDL_Rect rect = MakeSdlRect(start.x, start.y, 180, 20);
SDL_SetTextInputRect(&rect);
dropGoldFlag = true;

2
Source/loadsave.cpp

@ -2212,7 +2212,7 @@ void LoadLevel()
}
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) { // NOLINT(modernize-loop-convert)
uint8_t automapView = file.NextLE<uint8_t>();
const auto automapView = static_cast<MapExplorationType>(file.NextLE<uint8_t>());
AutomapView[i][j] = automapView == MAP_EXP_OLD ? MAP_EXP_SELF : automapView;
}
}

Loading…
Cancel
Save