diff --git a/Source/DiabloUI/credits.cpp b/Source/DiabloUI/credits.cpp index 62f540fdb..771f8c23e 100644 --- a/Source/DiabloUI/credits.cpp +++ b/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); diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index 5b1237b75..7e468373b 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/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(x), static_cast(y), - static_cast(w), static_cast(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); } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 48ba8244a..663695ad2 100644 --- a/Source/diablo.cpp +++ b/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 diff --git a/Source/inv.cpp b/Source/inv.cpp index 4e52edebe..423bdb411 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -8,6 +8,7 @@ #include #include +#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; diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index c6a3921dd..5142e86ef 100644 --- a/Source/loadsave.cpp +++ b/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(); + const auto automapView = static_cast(file.NextLE()); AutomapView[i][j] = automapView == MAP_EXP_OLD ? MAP_EXP_SELF : automapView; } }