Browse Source

Fix `-wnarrowing` from `SDL_Rect` construction

pull/4709/head
Gleb Mazovetskiy 4 years ago
parent
commit
ede7eab7e8
  1. 4
      Source/DiabloUI/diabloui.cpp
  2. 3
      Source/DiabloUI/selstart.cpp
  3. 5
      Source/DiabloUI/title.cpp
  4. 3
      Source/utils/display.cpp

4
Source/DiabloUI/diabloui.cpp

@ -705,13 +705,13 @@ void UiAddBackground(std::vector<std::unique_ptr<UiItemBase>> *vecDialog)
vecDialog->push_back(std::make_unique<UiImagePcx>(PcxSprite { *ArtBackgroundWidescreen }, rectw, UiFlags::AlignCenter));
}
SDL_Rect rect = { 0, uiPositionY, 0, 0 };
SDL_Rect rect = MakeSdlRect(0, uiPositionY, 0, 0);
vecDialog->push_back(std::make_unique<UiImagePcx>(PcxSpriteSheet { *ArtBackground }.sprite(0), rect, UiFlags::AlignCenter));
}
void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog, int size, int y)
{
SDL_Rect rect = { 0, (Sint16)(GetUIRectangle().position.y + y), 0, 0 };
SDL_Rect rect = MakeSdlRect(0, GetUIRectangle().position.y + y, 0, 0);
vecDialog->push_back(std::make_unique<UiImageCel>(
CelSpriteWithFrameHeight { ArtLogos[size]->sprite, ArtLogos[size]->frameHeight }, rect, UiFlags::AlignCenter, /*bAnimated=*/true));
}

3
Source/DiabloUI/selstart.cpp

@ -5,6 +5,7 @@
#include "engine/load_pcx.hpp"
#include "options.h"
#include "utils/language.h"
#include "utils/sdl_geometry.h"
namespace devilution {
namespace {
@ -39,7 +40,7 @@ void UiSelStartUpGameOption()
UiAddBackground(&vecDialog);
const Point uiPosition = GetUIRectangle().position;
SDL_Rect rect = { 0, (Sint16)(uiPosition.y), 0, 0 };
SDL_Rect rect = MakeSdlRect(0, uiPosition.y, 0, 0);
vecDialog.push_back(std::make_unique<UiImage>(&artLogo, rect, UiFlags::AlignCenter, /*bAnimated=*/true));
vecDialogItems.push_back(std::make_unique<UiListItem>(_("Enter Hellfire"), static_cast<int>(StartUpGameMode::Hellfire)));

5
Source/DiabloUI/title.cpp

@ -6,6 +6,7 @@
#include "engine/load_pcx.hpp"
#include "engine/load_pcx_as_cel.hpp"
#include "utils/language.h"
#include "utils/sdl_geometry.h"
namespace devilution {
namespace {
@ -39,7 +40,7 @@ void UiTitleDialog()
TitleLoad();
const Point uiPosition = GetUIRectangle().position;
if (gbIsHellfire) {
SDL_Rect rect = { 0, uiPosition.y, 0, 0 };
SDL_Rect rect = MakeSdlRect(0, uiPosition.y, 0, 0);
if (ArtBackgroundWidescreen)
vecTitleScreen.push_back(std::make_unique<UiImagePcx>(PcxSprite { *ArtBackgroundWidescreen }, rect, UiFlags::AlignCenter));
vecTitleScreen.push_back(std::make_unique<UiImageAnimatedPcx>(PcxSpriteSheet { *ArtBackground }, rect, UiFlags::AlignCenter));
@ -47,7 +48,7 @@ void UiTitleDialog()
UiAddBackground(&vecTitleScreen);
UiAddLogo(&vecTitleScreen, LOGO_BIG, 182);
SDL_Rect rect = { (Sint16)(uiPosition.x), (Sint16)(uiPosition.y + 410), 640, 26 };
SDL_Rect rect = MakeSdlRect(uiPosition.x, uiPosition.y + 410, 640, 26);
vecTitleScreen.push_back(std::make_unique<UiArtText>(_("Copyright © 1996-2001 Blizzard Entertainment").data(), rect, UiFlags::AlignCenter | UiFlags::FontSize24 | UiFlags::ColorUiSilver));
}

3
Source/utils/display.cpp

@ -23,6 +23,7 @@
#include "dx.h"
#include "options.h"
#include "utils/log.hpp"
#include "utils/sdl_geometry.h"
#include "utils/sdl_wrap.h"
#ifdef USE_SDL1
@ -497,7 +498,7 @@ namespace {
SDLSurfaceUniquePtr CreateScaledSurface(SDL_Surface *src)
{
SDL_Rect stretched_rect = { 0, 0, static_cast<Uint16>(src->w), static_cast<Uint16>(src->h) };
SDL_Rect stretched_rect = MakeSdlRect(0, 0, src->w, src->h);
ScaleOutputRect(&stretched_rect);
SDLSurfaceUniquePtr stretched = SDLWrap::CreateRGBSurface(
SDL_SWSURFACE, stretched_rect.w, stretched_rect.h, src->format->BitsPerPixel,

Loading…
Cancel
Save