diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-06-06 23:34:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-06-07 19:23:40 +0300 |
commit | 36ba43d6ea38062b17f7e63ef659962bfc51c64d (patch) | |
tree | 190156cb88b13a38a6d13c69ee0742cc078065a1 /src/resources/safeopenglimagehelper.cpp | |
parent | f1518dd8476c968a43fa57cfb06198e290a4f77a (diff) | |
download | manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2 manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip |
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/resources/safeopenglimagehelper.cpp')
-rw-r--r-- | src/resources/safeopenglimagehelper.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/resources/safeopenglimagehelper.cpp b/src/resources/safeopenglimagehelper.cpp index 676812d12..c1acea2f0 100644 --- a/src/resources/safeopenglimagehelper.cpp +++ b/src/resources/safeopenglimagehelper.cpp @@ -66,7 +66,7 @@ Image *SafeOpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye) { SDL_Surface *const tmpImage = loadPng(rw); - if (!tmpImage) + if (tmpImage == nullptr) { logger->log("Error, image load failed: %s", IMG_GetError()); return nullptr; @@ -74,7 +74,7 @@ Image *SafeOpenGLImageHelper::load(SDL_RWops *const rw, SDL_Surface *const surf = convertTo32Bit(tmpImage); MSDL_FreeSurface(tmpImage); - if (!surf) + if (surf == nullptr) return nullptr; uint32_t *pixels = static_cast<uint32_t *>(surf->pixels); @@ -85,14 +85,14 @@ Image *SafeOpenGLImageHelper::load(SDL_RWops *const rw, case 1: { const DyePalette *const pal = dye.getSPalete(); - if (pal) + if (pal != nullptr) DYEPALETTEP(pal, SOGLColor)(pixels, surf->w * surf->h); break; } case 2: { const DyePalette *const pal = dye.getAPalete(); - if (pal) + if (pal != nullptr) DYEPALETTEP(pal, AOGLColor)(pixels, surf->w * surf->h); break; } @@ -119,11 +119,11 @@ Image *SafeOpenGLImageHelper::createTextSurface(SDL_Surface *const tmpImage, const int height, const float alpha) { - if (!tmpImage) + if (tmpImage == nullptr) return nullptr; Image *const img = glLoad(tmpImage, width, height); - if (img) + if (img != nullptr) img->setAlpha(alpha); return img; } @@ -141,7 +141,7 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurfaceNormalize(SDL_Surface int width, int height) { - if (!tmpImage) + if (tmpImage == nullptr) return nullptr; int realWidth = powerOfTwo(width); @@ -190,7 +190,7 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurfaceNormalize(SDL_Surface tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight, 32, rmask, gmask, bmask, amask); - if (!tmpImage) + if (tmpImage == nullptr) { logger->log("Error, image convert failed: out of memory"); return nullptr; @@ -204,7 +204,7 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurface(SDL_Surface *tmpImage, int width, int height) { - if (!tmpImage) + if (tmpImage == nullptr) return nullptr; #ifdef USE_SDL2 @@ -243,7 +243,7 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurface(SDL_Surface *tmpImage, tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask); - if (!tmpImage) + if (tmpImage == nullptr) { logger->log("Error, image convert failed: out of memory"); return nullptr; @@ -308,21 +308,21 @@ Image *SafeOpenGLImageHelper::glLoad(SDL_Surface *tmpImage, int width, int height) { - if (!tmpImage) + if (tmpImage == nullptr) return nullptr; BLOCK_START("SafeOpenGLImageHelper::glLoad") // Flush current error flag. graphicsManager.getLastError(); - if (!width) + if (width == 0) width = tmpImage->w; - if (!height) + if (height == 0) height = tmpImage->h; SDL_Surface *oldImage = tmpImage; tmpImage = convertSurfaceNormalize(tmpImage, width, height); - if (!tmpImage) + if (tmpImage == nullptr) return nullptr; const int realWidth = tmpImage->w; @@ -389,7 +389,7 @@ Image *SafeOpenGLImageHelper::glLoad(SDL_Surface *tmpImage, MSDL_FreeSurface(tmpImage); GLenum error = graphicsManager.getLastError(); - if (error) + if (error != 0u) { std::string errmsg = GraphicsManager::errorToString(error); logger->log("Error: Image GL import failed: %s (%u)", @@ -469,17 +469,17 @@ void SafeOpenGLImageHelper::copySurfaceToImage(const Image *const image, const int y, SDL_Surface *surface) const { - if (!surface || !image) + if (surface == nullptr || image == nullptr) return; SDL_Surface *const oldSurface = surface; surface = convertSurface(surface, surface->w, surface->h); - if (!surface) + if (surface == nullptr) return; // +++ probably need combine // mglTextureSubImage2D and mglTextureSubImage2DEXT - if (mglTextureSubImage2D) + if (mglTextureSubImage2D != nullptr) { mglTextureSubImage2D(image->mGLImage, 0, |