summaryrefslogtreecommitdiff
path: root/src/resources/sdlimagehelper.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-06 23:34:34 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-07 19:23:40 +0300
commit36ba43d6ea38062b17f7e63ef659962bfc51c64d (patch)
tree190156cb88b13a38a6d13c69ee0742cc078065a1 /src/resources/sdlimagehelper.cpp
parentf1518dd8476c968a43fa57cfb06198e290a4f77a (diff)
downloadplus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz
plus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2
plus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz
plus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/resources/sdlimagehelper.cpp')
-rw-r--r--src/resources/sdlimagehelper.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp
index afb81d170..72afe3045 100644
--- a/src/resources/sdlimagehelper.cpp
+++ b/src/resources/sdlimagehelper.cpp
@@ -53,7 +53,7 @@ bool SDLImageHelper::mEnableAlphaCache = false;
Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
{
SDL_Surface *const tmpImage = loadPng(rw);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
reportAlways("Error, image load failed: %s",
IMG_GetError());
@@ -83,7 +83,7 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
SDL_Surface *const surf = MSDL_ConvertSurface(
tmpImage, &rgba, SDL_SWSURFACE);
MSDL_FreeSurface(tmpImage);
- if (!surf)
+ if (surf == nullptr)
return nullptr;
uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
@@ -94,14 +94,14 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
case 1:
{
const DyePalette *const pal = dye.getSPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, SColor)(pixels, surf->w * surf->h);
break;
}
case 2:
{
const DyePalette *const pal = dye.getAPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, AColor)(pixels, surf->w * surf->h);
break;
}
@@ -128,7 +128,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
const int height A_UNUSED,
const float alpha)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
bool hasAlpha = false;
@@ -138,7 +138,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
uint8_t *alphaChannel = new uint8_t[sz];
const SDL_PixelFormat *const fmt = tmpImage->format;
- if (fmt->Amask)
+ if (fmt->Amask != 0u)
{
for (size_t i = 0; i < sz; ++ i)
{
@@ -179,7 +179,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
alphaChannel = nullptr;
}
- if (!image)
+ if (image == nullptr)
{
reportAlways("Error: Image convert failed.");
delete [] alphaChannel;
@@ -193,7 +193,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
SDL_Surface* SDLImageHelper::SDLDuplicateSurface(SDL_Surface *const tmpImage)
{
- if (!tmpImage || !tmpImage->format)
+ if ((tmpImage == nullptr) || (tmpImage->format == nullptr))
return nullptr;
return MSDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE);
@@ -201,7 +201,7 @@ SDL_Surface* SDLImageHelper::SDLDuplicateSurface(SDL_Surface *const tmpImage)
Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
bool hasAlpha = false;
@@ -212,7 +212,7 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
reportAlways("Non 32 bit image detected");
tmpImage = convertTo32Bit(tmpImage);
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
converted = true;
}
@@ -223,10 +223,10 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
uint8_t *alphaChannel = new uint8_t[sz];
// Figure out whether the image uses its alpha layer
- if (!tmpImage->format->palette)
+ if (tmpImage->format->palette == nullptr)
{
const SDL_PixelFormat *const fmt = tmpImage->format;
- if (fmt->Amask)
+ if (fmt->Amask != 0u)
{
const uint32_t amask = fmt->Amask;
const uint8_t ashift = fmt->Ashift;
@@ -279,7 +279,7 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
alphaChannel = nullptr;
}
- if (!image)
+ if (image == nullptr)
{
reportAlways("Error: Image convert failed.");
delete [] alphaChannel;
@@ -308,7 +308,7 @@ void SDLImageHelper::copySurfaceToImage(const Image *const image,
const int x, const int y,
SDL_Surface *const surface) const
{
- if (!image || !surface)
+ if ((image == nullptr) || (surface == nullptr))
return;
SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE);