From 36ba43d6ea38062b17f7e63ef659962bfc51c64d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 6 Jun 2017 23:34:34 +0300 Subject: Fix clang-tidy check readability-implicit-bool-cast. --- src/render/graphics.cpp | 34 ++++++------ src/render/imagegraphics.cpp | 2 +- src/render/mobileopengl2graphics.cpp | 36 ++++++------- src/render/mobileopenglgraphics.cpp | 38 +++++++------- src/render/mockgraphics.cc | 4 +- src/render/modernopenglgraphics.cpp | 40 +++++++-------- src/render/normalopenglgraphics.cpp | 42 +++++++-------- src/render/nullopenglgraphics.cpp | 24 ++++----- src/render/safeopenglgraphics.cpp | 12 ++--- src/render/sdlgraphics.cpp | 71 +++++++++++++++++--------- src/render/shaders/shader.cpp | 2 +- src/render/shaders/shaderprogram.cpp | 6 +-- src/render/shaders/shadersmanager.cpp | 6 +-- src/render/surfacegraphics.cpp | 18 +++++-- src/render/vertexes/openglgraphicsvertexes.cpp | 2 +- 15 files changed, 185 insertions(+), 152 deletions(-) (limited to 'src/render') diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index a27325839..92a9acc36 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -193,7 +193,7 @@ void Graphics::setScale(int scale) restrict2 { if (isAllowScale()) { - if (!scale) + if (scale == 0) scale = 1; int scaleW = mActualWidth / scale; int scaleH = mActualHeight / scale; @@ -266,9 +266,9 @@ bool Graphics::setOpenGLMode() restrict2 { #ifdef USE_OPENGL SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - if (!(mWindow = graphicsManager.createWindow( + if ((mWindow = graphicsManager.createWindow( mActualWidth, mActualHeight, - mBpp, getOpenGLFlags()))) + mBpp, getOpenGLFlags())) == nullptr) { logger->log("Window/context creation failed"); mRect.w = 0; @@ -315,7 +315,7 @@ bool Graphics::setOpenGLMode() restrict2 int gotDoubleBuffer = 0; SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &gotDoubleBuffer); logger->log("Using OpenGL %s double buffering.", - (gotDoubleBuffer ? "with" : "without")); + (gotDoubleBuffer != 0 ? "with" : "without")); graphicsManager.initOpenGL(); initArrays(graphicsManager.getMaxVertices()); @@ -404,7 +404,7 @@ void Graphics::createGLContext(const bool custom A_UNUSED) restrict2 void Graphics::updateMemoryInfo() restrict2 { #ifdef USE_OPENGL - if (mStartFreeMem) + if (mStartFreeMem != 0) return; if (graphicsManager.supportExtension("GL_NVX_gpu_memory_info")) @@ -419,7 +419,7 @@ void Graphics::updateMemoryInfo() restrict2 int Graphics::getMemoryUsage() const restrict2 { #ifdef USE_OPENGL - if (!mStartFreeMem) + if (mStartFreeMem == 0) return 0; if (graphicsManager.supportExtension("GL_NVX_gpu_memory_info")) @@ -474,7 +474,7 @@ bool Graphics::videoInfo() restrict2 #else // USE_SDL2 char videoDriverName[65]; - if (SDL_VideoDriverName(videoDriverName, 64)) + if (SDL_VideoDriverName(videoDriverName, 64) != nullptr) logger->log("Using video driver: %s", videoDriverName); else logger->log1("Using video driver: unknown"); @@ -484,27 +484,27 @@ bool Graphics::videoInfo() restrict2 ImageHelper::dumpSurfaceFormat(mWindow); const SDL_VideoInfo *restrict const vi = SDL_GetVideoInfo(); - if (!vi) + if (vi == nullptr) return false; logger->log("Possible to create hardware surfaces: %s", - ((vi->hw_available) ? "yes" : "no")); + ((vi->hw_available) != 0u ? "yes" : "no")); logger->log("Window manager available: %s", - ((vi->wm_available) ? "yes" : "no")); + ((vi->wm_available) != 0u ? "yes" : "no")); logger->log("Accelerated hardware to hardware blits: %s", - ((vi->blit_hw) ? "yes" : "no")); + ((vi->blit_hw) != 0u ? "yes" : "no")); logger->log("Accelerated hardware to hardware colorkey blits: %s", - ((vi->blit_hw_CC) ? "yes" : "no")); + ((vi->blit_hw_CC) != 0u ? "yes" : "no")); logger->log("Accelerated hardware to hardware alpha blits: %s", - ((vi->blit_hw_A) ? "yes" : "no")); + ((vi->blit_hw_A) != 0u ? "yes" : "no")); logger->log("Accelerated software to hardware blits: %s", - ((vi->blit_sw) ? "yes" : "no")); + ((vi->blit_sw) != 0u ? "yes" : "no")); logger->log("Accelerated software to hardware colorkey blits: %s", - ((vi->blit_sw_CC) ? "yes" : "no")); + ((vi->blit_sw_CC) != 0u ? "yes" : "no")); logger->log("Accelerated software to hardware alpha blits: %s", - ((vi->blit_sw_A) ? "yes" : "no")); + ((vi->blit_sw_A) != 0u ? "yes" : "no")); logger->log("Accelerated color fills: %s", - ((vi->blit_fill) ? "yes" : "no")); + ((vi->blit_fill) != 0u ? "yes" : "no")); #endif // USE_SDL2 return true; diff --git a/src/render/imagegraphics.cpp b/src/render/imagegraphics.cpp index 5a425c04a..02a1f460d 100644 --- a/src/render/imagegraphics.cpp +++ b/src/render/imagegraphics.cpp @@ -47,7 +47,7 @@ void ImegeGraphics::drawImage(const Image *restrict const image A_UNUSED, void ImegeGraphics::copyImage(const Image *restrict const image, int dstX A_UNUSED, int dstY A_UNUSED) restrict2 { - if (!mTarget || !image) + if ((mTarget == nullptr) || (image == nullptr)) return; } diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp index a0cc9167b..6c0762934 100644 --- a/src/render/mobileopengl2graphics.cpp +++ b/src/render/mobileopengl2graphics.cpp @@ -128,10 +128,10 @@ MobileOpenGL2Graphics::~MobileOpenGL2Graphics() void MobileOpenGL2Graphics::deleteGLObjects() restrict2 { delete2(mProgram); - if (mVbo) + if (mVbo != 0u) mglDeleteBuffers(1, &mVbo); #ifndef __native_client__ - if (mVao) + if (mVao != 0u) mglDeleteVertexArrays(1, &mVao); #endif // __native_client__ } @@ -147,9 +147,9 @@ void MobileOpenGL2Graphics::initArrays(const int vertCount) restrict2 // need alocate small size, after if limit reached reallocate to double size const size_t sz = mMaxVertices * 4 + 30; vertexBufSize = mMaxVertices; - if (!mFloatArray) + if (mFloatArray == nullptr) mFloatArray = new GLfloat[sz]; - if (!mFloatArrayCached) + if (mFloatArrayCached == nullptr) mFloatArrayCached = new GLfloat[sz]; } @@ -165,13 +165,13 @@ void MobileOpenGL2Graphics::postInit() restrict2 logger->log("Compiling shaders"); mProgram = shaders.getGles2Program(); - if (!mProgram) + if (mProgram == nullptr) { graphicsManager.logError(); logger->safeError("Shader creation error. See manaplus.log."); } mProgramId = mProgram->getProgramId(); - if (!mProgramId) + if (mProgramId == 0u) logger->safeError("Shaders compilation error."); logger->log("Shaders compilation done."); @@ -338,7 +338,7 @@ void MobileOpenGL2Graphics::drawImageInline(const Image *restrict const image, int dstX, int dstY) restrict2 { FUNC_BLOCK("Graphics::drawImage", 1) - if (!image) + if (image == nullptr) return; #ifdef DEBUG_BIND_TEXTURE @@ -416,7 +416,7 @@ void MobileOpenGL2Graphics::drawRescaledImage(const Image * const int desiredHeight) restrict2 { - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -461,7 +461,7 @@ void MobileOpenGL2Graphics::drawPatternInline(const Image * const int w, const int h) restrict2 { - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -526,7 +526,7 @@ void MobileOpenGL2Graphics::drawRescaledPattern(const Image * const int scaledHeight) restrict2 { - if (!image) + if (image == nullptr) return; if (scaledWidth == 0 || scaledHeight == 0) @@ -637,7 +637,7 @@ void MobileOpenGL2Graphics::calcPatternInline(ImageVertexes * const int w, const int h) const restrict2 { - if (!image || !vert) + if (image == nullptr || vert == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -698,7 +698,7 @@ void MobileOpenGL2Graphics::calcTileCollection(ImageCollection * restrict const image, int x, int y) restrict2 { - if (!vertCol || !image) + if (vertCol == nullptr || image == nullptr) return; if (vertCol->currentGLImage != image->mGLImage) { @@ -744,7 +744,7 @@ void MobileOpenGL2Graphics::calcPattern(ImageCollection *restrict const const int w, const int h) const restrict2 { - if (!vertCol || !image) + if (vertCol == nullptr || image == nullptr) return; ImageVertexes *vert = nullptr; if (vertCol->currentGLImage != image->mGLImage) @@ -824,7 +824,7 @@ void MobileOpenGL2Graphics::calcTileVertexesInline(ImageVertexes * void MobileOpenGL2Graphics::drawTileVertexes(const ImageVertexes * restrict const vert) restrict2 { - if (!vert) + if (vert == nullptr) return; const Image *const image = vert->image; @@ -847,7 +847,7 @@ void MobileOpenGL2Graphics::calcWindow(ImageCollection *restrict const vertCol, { ImageVertexes *vert = nullptr; const Image *const image = imgRect.grid[4]; - if (!image) + if (image == nullptr) return; if (vertCol->currentGLImage != image->mGLImage) { @@ -1216,7 +1216,7 @@ void MobileOpenGL2Graphics::dumpSettings() test[2] = 0; test[3] = 0; mglGetIntegerv(f, &test[0]); - if (test[0] || test[1] || test[2] || test[3]) + if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0) { logger->log("\n%d = %d, %d, %d, %d", f, test[0], test[1], test[2], test[3]); @@ -1262,7 +1262,7 @@ void MobileOpenGL2Graphics::createGLContext(const bool custom) restrict2 void MobileOpenGL2Graphics::finalize(ImageCollection *restrict const col) restrict2 { - if (!col) + if (col == nullptr) return; FOR_EACH (ImageCollectionIter, it, col->draws) finalize(*it); @@ -1273,7 +1273,7 @@ void MobileOpenGL2Graphics::finalize(ImageVertexes *restrict const vert) { // in future need convert in each switchVp/continueVp - if (!vert) + if (vert == nullptr) return; OpenGLGraphicsVertexes &ogl = vert->ogl; const std::vector &vp = ogl.mVp; diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index 853757a22..cc1812107 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -121,13 +121,13 @@ void MobileOpenGLGraphics::initArrays(const int vertCount) restrict2 // need alocate small size, after if limit reached reallocate to double size const size_t sz = mMaxVertices * 4 + 30; vertexBufSize = mMaxVertices; - if (!mFloatTexArray) + if (mFloatTexArray == nullptr) mFloatTexArray = new GLfloat[sz]; - if (!mShortVertArray) + if (mShortVertArray == nullptr) mShortVertArray = new GLshort[sz]; - if (!mFloatTexArrayCached) + if (mFloatTexArrayCached == nullptr) mFloatTexArrayCached = new GLfloat[sz]; - if (!mShortVertArrayCached) + if (mShortVertArrayCached == nullptr) mShortVertArrayCached = new GLshort[sz]; } @@ -283,7 +283,7 @@ void MobileOpenGLGraphics::drawImageInline(const Image *restrict const image, int dstX, int dstY) restrict2 { FUNC_BLOCK("Graphics::drawImage", 1) - if (!image) + if (image == nullptr) return; setColorAlpha(image->mAlpha); @@ -307,7 +307,7 @@ void MobileOpenGLGraphics::copyImage(const Image *restrict const image, void MobileOpenGLGraphics::drawImageCached(const Image *restrict const image, int x, int y) restrict2 { - if (!image) + if (image == nullptr) return; if (image->mGLImage != mImageCached) @@ -364,7 +364,7 @@ void MobileOpenGLGraphics::drawPatternCached(const Image *restrict const image, const int w, const int h) restrict2 { - if (!image) + if (image == nullptr) return; if (image->mGLImage != mImageCached) @@ -419,7 +419,7 @@ void MobileOpenGLGraphics::drawPatternCached(const Image *restrict const image, void MobileOpenGLGraphics::completeCache() restrict2 { - if (!mImageCached) + if (mImageCached == 0u) return; setColorAlpha(mAlphaCached); @@ -440,7 +440,7 @@ void MobileOpenGLGraphics::drawRescaledImage(const Image *restrict const image, const int desiredHeight) restrict2 { FUNC_BLOCK("Graphics::drawRescaledImage", 1) - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -478,7 +478,7 @@ void MobileOpenGLGraphics::drawPatternInline(const Image *restrict const image, const int h) restrict2 { FUNC_BLOCK("Graphics::drawPattern", 1) - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -544,7 +544,7 @@ void MobileOpenGLGraphics::drawRescaledPattern(const Image * const int scaledHeight) restrict2 { - if (!image) + if (image == nullptr) return; if (scaledWidth == 0 || scaledHeight == 0) @@ -660,7 +660,7 @@ void MobileOpenGLGraphics::calcPatternInline(ImageVertexes * const int w, const int h) const restrict2 { - if (!image || !vert) + if (image == nullptr || vert == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -724,7 +724,7 @@ void MobileOpenGLGraphics::calcTileCollection(ImageCollection * restrict const image, int x, int y) restrict2 { - if (!vertCol || !image) + if (vertCol == nullptr || image == nullptr) return; if (vertCol->currentGLImage != image->mGLImage) { @@ -769,7 +769,7 @@ void MobileOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol, const int w, const int h) const restrict2 { - if (!vertCol || !image) + if (vertCol == nullptr || image == nullptr) return; ImageVertexes *vert = nullptr; if (vertCol->currentGLImage != image->mGLImage) @@ -851,7 +851,7 @@ void MobileOpenGLGraphics::calcTileVertexesInline(ImageVertexes * void MobileOpenGLGraphics::drawTileVertexes(const ImageVertexes * restrict const vert) restrict2 { - if (!vert) + if (vert == nullptr) return; const Image *const image = vert->image; @@ -872,7 +872,7 @@ void MobileOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol, { ImageVertexes *vert = nullptr; const Image *const image = imgRect.grid[4]; - if (!image) + if (image == nullptr) return; if (vertCol->currentGLImage != image->mGLImage) { @@ -978,7 +978,7 @@ void MobileOpenGLGraphics::pushClipArea(const Rect &restrict area) restrict2 transX += clipArea.xOffset; transY += clipArea.yOffset; - if (transX || transY) + if (transX != 0 || transY != 0) { glTranslatef(static_cast(transX), static_cast(transY), 0); @@ -1006,7 +1006,7 @@ void MobileOpenGLGraphics::popClipArea() restrict2 const ClipRect &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; - if (transX || transY) + if (transX != 0 || transY != 0) { glTranslatef(static_cast(transX), static_cast(transY), 0); @@ -1294,7 +1294,7 @@ void MobileOpenGLGraphics::dumpSettings() test[2] = 0; test[3] = 0; mglGetIntegerv(f, &test[0]); - if (test[0] || test[1] || test[2] || test[3]) + if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0) { logger->log("\n%d = %d, %d, %d, %d", f, test[0], test[1], test[2], test[3]); diff --git a/src/render/mockgraphics.cc b/src/render/mockgraphics.cc index 278ed767f..d36a6b1f5 100644 --- a/src/render/mockgraphics.cc +++ b/src/render/mockgraphics.cc @@ -267,8 +267,8 @@ bool MockGraphics::setVideoMode(const int w, const int h, { setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame); - if (!(mWindow = graphicsManager.createWindow(w, h, bpp, - getSoftwareFlags()))) + if ((mWindow = graphicsManager.createWindow(w, h, bpp, + getSoftwareFlags())) == nullptr) { mRect.w = 0; mRect.h = 0; diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp index 35deaa52c..cfd83e57f 100644 --- a/src/render/modernopenglgraphics.cpp +++ b/src/render/modernopenglgraphics.cpp @@ -125,17 +125,17 @@ ModernOpenGLGraphics::~ModernOpenGLGraphics() void ModernOpenGLGraphics::deleteGLObjects() restrict2 { delete2(mProgram); - if (mVbo) + if (mVbo != 0u) { // logger->log("delete buffer vbo: %u", mVbo); mglDeleteBuffers(1, &mVbo); } - if (mEbo) + if (mEbo != 0u) { // logger->log("delete buffer ebo: %u", mEbo); mglDeleteBuffers(1, &mEbo); } - if (mVao) + if (mVao != 0u) mglDeleteVertexArrays(1, &mVao); } @@ -150,9 +150,9 @@ void ModernOpenGLGraphics::initArrays(const int vertCount) restrict2 // need alocate small size, after if limit reached reallocate to double size const size_t sz = mMaxVertices * 4 + 30; vertexBufSize = mMaxVertices; - if (!mIntArray) + if (mIntArray == nullptr) mIntArray = new GLint[sz]; - if (!mIntArrayCached) + if (mIntArrayCached == nullptr) mIntArrayCached = new GLint[sz]; } @@ -169,13 +169,13 @@ void ModernOpenGLGraphics::postInit() restrict2 logger->log("Compiling shaders"); mProgram = shaders.getSimpleProgram(); - if (!mProgram) + if (mProgram == nullptr) { graphicsManager.logError(); logger->safeError("Shader creation error. See manaplus.log."); } mProgramId = mProgram->getProgramId(); - if (!mProgramId) + if (mProgramId == 0u) logger->error("Shaders compilation error."); logger->log("Shaders compilation done."); @@ -333,7 +333,7 @@ void ModernOpenGLGraphics::drawImageInline(const Image *restrict const image, int dstX, int dstY) restrict2 { FUNC_BLOCK("Graphics::drawImage", 1) - if (!image) + if (image == nullptr) return; #ifdef DEBUG_BIND_TEXTURE @@ -409,7 +409,7 @@ void ModernOpenGLGraphics::drawRescaledImage(const Image *restrict const image, const int desiredWidth, const int desiredHeight) restrict2 { - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -450,7 +450,7 @@ void ModernOpenGLGraphics::drawPatternInline(const Image *restrict const image, const int w, const int h) restrict2 { - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -515,7 +515,7 @@ void ModernOpenGLGraphics::drawRescaledPattern(const Image * const int scaledHeight) restrict2 { - if (!image) + if (image == nullptr) return; if (scaledWidth == 0 || scaledHeight == 0) @@ -627,7 +627,7 @@ void ModernOpenGLGraphics::calcPatternInline(ImageVertexes * const int w, const int h) const restrict2 { - if (!image || !vert) + if (image == nullptr || vert == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -683,7 +683,7 @@ void ModernOpenGLGraphics::calcTileCollection(ImageCollection * restrict const image, int x, int y) restrict2 { - if (!vertCol || !image) + if (vertCol == nullptr || image == nullptr) return; if (vertCol->currentGLImage != image->mGLImage) { @@ -736,7 +736,7 @@ void ModernOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol, const int w, const int h) const restrict2 { - if (!vertCol || !image) + if (vertCol == nullptr || image == nullptr) return; ImageVertexes *vert = nullptr; if (vertCol->currentGLImage != image->mGLImage) @@ -811,7 +811,7 @@ void ModernOpenGLGraphics::calcTileVertexesInline(ImageVertexes * void ModernOpenGLGraphics::drawTileVertexes(const ImageVertexes * restrict const vert) restrict2 { - if (!vert) + if (vert == nullptr) return; const Image *const image = vert->image; @@ -835,7 +835,7 @@ void ModernOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol, { ImageVertexes *vert = nullptr; const Image *const image = imgRect.grid[4]; - if (!image) + if (image == nullptr) return; if (vertCol->currentGLImage != image->mGLImage) { @@ -1215,7 +1215,7 @@ void ModernOpenGLGraphics::dumpSettings() test[2] = 0; test[3] = 0; mglGetIntegerv(f, &test[0]); - if (test[0] || test[1] || test[2] || test[3]) + if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0) { logger->log("\n%d = %d, %d, %d, %d", f, test[0], test[1], test[2], test[3]); @@ -1251,7 +1251,7 @@ void ModernOpenGLGraphics::createGLContext(const bool custom) restrict2 { if (custom) { - if (mGLContext) + if (mGLContext != nullptr) SDL::makeCurrentContext(mGLContext); else mGLContext = SDL::createGLContext(mWindow, 3, 3, 0x01); @@ -1265,7 +1265,7 @@ void ModernOpenGLGraphics::createGLContext(const bool custom) restrict2 void ModernOpenGLGraphics::finalize(ImageCollection *restrict const col) restrict2 { - if (!col) + if (col == nullptr) return; FOR_EACH (ImageCollectionIter, it, col->draws) finalize(*it); @@ -1276,7 +1276,7 @@ void ModernOpenGLGraphics::finalize(ImageVertexes *restrict const vert) { // in future need convert in each switchVp/continueVp - if (!vert) + if (vert == nullptr) return; OpenGLGraphicsVertexes &ogl = vert->ogl; const std::vector &vp = ogl.mVp; diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index 1ca5e851e..3ed186cdc 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -137,17 +137,17 @@ void NormalOpenGLGraphics::initArrays(const int vertCount) restrict2 // need alocate small size, after if limit reached reallocate to double size vertexBufSize = mMaxVertices; const size_t sz = mMaxVertices * 4 + 30; - if (!mFloatTexArray) + if (mFloatTexArray == nullptr) mFloatTexArray = new GLfloat[sz]; - if (!mIntTexArray) + if (mIntTexArray == nullptr) mIntTexArray = new GLint[sz]; - if (!mIntVertArray) + if (mIntVertArray == nullptr) mIntVertArray = new GLint[sz]; - if (!mFloatTexArrayCached) + if (mFloatTexArrayCached == nullptr) mFloatTexArrayCached = new GLfloat[sz]; - if (!mIntTexArrayCached) + if (mIntTexArrayCached == nullptr) mIntTexArrayCached = new GLint[sz]; - if (!mIntVertArrayCached) + if (mIntVertArrayCached == nullptr) mIntVertArrayCached = new GLint[sz]; } @@ -380,7 +380,7 @@ void NormalOpenGLGraphics::drawImageInline(const Image *restrict const image, int dstX, int dstY) restrict2 { FUNC_BLOCK("Graphics::drawImage", 1) - if (!image) + if (image == nullptr) return; setColorAlpha(image->mAlpha); @@ -465,7 +465,7 @@ void NormalOpenGLGraphics::testDraw() restrict2 void NormalOpenGLGraphics::drawImageCached(const Image *restrict const image, int x, int y) restrict2 { - if (!image) + if (image == nullptr) return; if (image->mGLImage != mImageCached) @@ -541,7 +541,7 @@ void NormalOpenGLGraphics::drawPatternCached(const Image *restrict const image, const int h) restrict2 { FUNC_BLOCK("Graphics::drawPatternCached", 1) - if (!image) + if (image == nullptr) return; if (image->mGLImage != mImageCached) @@ -623,7 +623,7 @@ void NormalOpenGLGraphics::drawPatternCached(const Image *restrict const image, void NormalOpenGLGraphics::completeCache() restrict2 { - if (!mImageCached) + if (mImageCached == 0u) return; setColorAlpha(mAlphaCached); @@ -649,7 +649,7 @@ void NormalOpenGLGraphics::drawRescaledImage(const Image *restrict const image, const int desiredHeight) restrict2 { FUNC_BLOCK("Graphics::drawRescaledImage", 1) - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -688,7 +688,7 @@ void NormalOpenGLGraphics::drawPatternInline(const Image *restrict const image, const int h) restrict2 { FUNC_BLOCK("Graphics::drawPattern", 1) - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -782,7 +782,7 @@ void NormalOpenGLGraphics::drawRescaledPattern(const Image * const int scaledHeight) restrict2 { - if (!image) + if (image == nullptr) return; if (scaledWidth == 0 || scaledHeight == 0) @@ -970,7 +970,7 @@ void NormalOpenGLGraphics::calcPatternInline(ImageVertexes * const int w, const int h) const restrict2 { - if (!image || !vert) + if (image == nullptr || vert == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -1062,7 +1062,7 @@ void NormalOpenGLGraphics::calcTileCollection(ImageCollection * restrict const image, int x, int y) restrict2 { - if (!vertCol || !image) + if (vertCol == nullptr || image == nullptr) return; if (vertCol->currentGLImage != image->mGLImage) { @@ -1108,7 +1108,7 @@ void NormalOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol, const int w, const int h) const restrict2 { - if (!vertCol || !image) + if (vertCol == nullptr || image == nullptr) return; ImageVertexes *vert = nullptr; if (vertCol->currentGLImage != image->mGLImage) @@ -1209,7 +1209,7 @@ void NormalOpenGLGraphics::calcTileVertexesInline(ImageVertexes * void NormalOpenGLGraphics::drawTileVertexes(const ImageVertexes * restrict const vert) restrict2 { - if (!vert) + if (vert == nullptr) return; const Image *const image = vert->image; @@ -1231,7 +1231,7 @@ void NormalOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol, { ImageVertexes *vert = nullptr; Image *const image = imgRect.grid[4]; - if (!image) + if (image == nullptr) return; if (vertCol->currentGLImage != image->mGLImage) { @@ -1346,7 +1346,7 @@ void NormalOpenGLGraphics::pushClipArea(const Rect &restrict area) restrict2 transX += clipArea.xOffset; transY += clipArea.yOffset; - if (transX || transY) + if (transX != 0 || transY != 0) { glTranslatef(static_cast(transX), static_cast(transY), 0); @@ -1374,7 +1374,7 @@ void NormalOpenGLGraphics::popClipArea() restrict2 const ClipRect &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; - if (transX || transY) + if (transX != 0 || transY != 0) { glTranslatef(static_cast(transX), static_cast(transY), 0); @@ -1692,7 +1692,7 @@ void NormalOpenGLGraphics::dumpSettings() test[2] = 0; test[3] = 0; glGetIntegerv(f, &test[0]); - if (test[0] || test[1] || test[2] || test[3]) + if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0) { logger->log("\n%d = %d, %d, %d, %d", f, test[0], test[1], test[2], test[3]); diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp index 2526c9feb..dac86b519 100644 --- a/src/render/nullopenglgraphics.cpp +++ b/src/render/nullopenglgraphics.cpp @@ -81,11 +81,11 @@ void NullOpenGLGraphics::initArrays(const int vertCount) restrict2 // need alocate small size, after if limit reached reallocate to double size vertexBufSize = mMaxVertices; const size_t sz = mMaxVertices * 4 + 30; - if (!mFloatTexArray) + if (mFloatTexArray == nullptr) mFloatTexArray = new GLfloat[sz]; - if (!mIntTexArray) + if (mIntTexArray == nullptr) mIntTexArray = new GLint[sz]; - if (!mIntVertArray) + if (mIntVertArray == nullptr) mIntVertArray = new GLint[sz]; } @@ -172,7 +172,7 @@ void NullOpenGLGraphics::drawImageInline(const Image *restrict const image, int dstX, int dstY) restrict2 { FUNC_BLOCK("Graphics::drawImage", 1) - if (!image) + if (image == nullptr) return; setColorAlpha(image->mAlpha); @@ -214,7 +214,7 @@ void NullOpenGLGraphics::drawRescaledImage(const Image *restrict const image, const int desiredHeight) restrict2 { FUNC_BLOCK("Graphics::drawRescaledImage", 1) - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -251,7 +251,7 @@ void NullOpenGLGraphics::drawPatternInline(const Image *restrict const image, const int w, const int h) restrict2 { FUNC_BLOCK("Graphics::drawPattern", 1) - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -385,7 +385,7 @@ void NullOpenGLGraphics::drawRescaledPattern(const Image *restrict const image, const int scaledWidth, const int scaledHeight) restrict2 { - if (!image) + if (image == nullptr) return; if (scaledWidth == 0 || scaledHeight == 0) @@ -590,7 +590,7 @@ void NullOpenGLGraphics::calcPatternInline(ImageVertexes *restrict const vert, const int w, const int h) const restrict2 { - if (!image || !vert) + if (image == nullptr || vert == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -722,7 +722,7 @@ void NullOpenGLGraphics::calcTileCollection(ImageCollection * const Image *restrict const image, int x, int y) restrict2 { - if (!vertCol || !image) + if (vertCol == nullptr || image == nullptr) return; if (vertCol->currentGLImage != image->mGLImage) { @@ -765,7 +765,7 @@ void NullOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol, const int x, const int y, const int w, const int h) const restrict2 { - if (!vertCol || !image) + if (vertCol == nullptr || image == nullptr) return; ImageVertexes *vert = nullptr; if (vertCol->currentGLImage != image->mGLImage) @@ -907,7 +907,7 @@ void NullOpenGLGraphics::calcTileVertexesInline(ImageVertexes * void NullOpenGLGraphics::drawTileVertexes(const ImageVertexes * restrict const vert) restrict2 { - if (!vert) + if (vert == nullptr) return; const Image *const image = vert->image; @@ -929,7 +929,7 @@ void NullOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol, { ImageVertexes *vert = nullptr; Image *const image = imgRect.grid[4]; - if (!image) + if (image == nullptr) return; if (vertCol->currentGLImage != image->mGLImage) { diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index c5c10ad3d..43a22bea3 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -176,7 +176,7 @@ void SafeOpenGLGraphics::drawImageInline(const Image *restrict const image, int dstX, int dstY) restrict2 { FUNC_BLOCK("Graphics::drawImage", 1) - if (!image) + if (image == nullptr) return; setColorAlpha(image->mAlpha); @@ -231,7 +231,7 @@ void SafeOpenGLGraphics::drawImageCached(const Image *restrict const image, int x, int y) restrict2 { FUNC_BLOCK("Graphics::drawImageCached", 1) - if (!image) + if (image == nullptr) return; setColorAlpha(image->mAlpha); @@ -250,7 +250,7 @@ void SafeOpenGLGraphics::drawPatternCached(const Image *restrict const image, const int w, const int h) restrict2 { FUNC_BLOCK("Graphics::drawPatternCached", 1) - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -294,7 +294,7 @@ void SafeOpenGLGraphics::drawRescaledImage(const Image *restrict const image, const int desiredHeight) restrict2 { FUNC_BLOCK("Graphics::drawRescaledImage", 1) - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -329,7 +329,7 @@ void SafeOpenGLGraphics::drawPatternInline(const Image *restrict const image, const int w, const int h) restrict2 { FUNC_BLOCK("Graphics::drawPattern", 1) - if (!image) + if (image == nullptr) return; const SDL_Rect &imageRect = image->mBounds; @@ -369,7 +369,7 @@ void SafeOpenGLGraphics::drawRescaledPattern(const Image *restrict const image, const int scaledWidth, const int scaledHeight) restrict2 { - if (!image) + if (image == nullptr) return; const int iw = scaledWidth; diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 533912760..bf4e1a258 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -68,13 +68,17 @@ void SDLGraphics::drawRescaledImage(const Image *restrict const image, { FUNC_BLOCK("Graphics::drawRescaledImage", 1) // Check that preconditions for blitting are met. - if (!mWindow || !image || !image->mSDLSurface) + if (mWindow == nullptr || + image == nullptr || + image->mSDLSurface == nullptr) + { return; + } Image *const tmpImage = image->SDLgetScaledImage( desiredWidth, desiredHeight); - if (!tmpImage || !tmpImage->mSDLSurface) + if ((tmpImage == nullptr) || (tmpImage->mSDLSurface == nullptr)) return; const ClipRect &top = mClipStack.top(); @@ -111,8 +115,12 @@ void SDLGraphics::drawImageInline(const Image *restrict const image, { FUNC_BLOCK("Graphics::drawImage", 1) // Check that preconditions for blitting are met. - if (!mWindow || !image || !image->mSDLSurface) + if (mWindow == nullptr || + image == nullptr || + image->mSDLSurface == nullptr) + { return; + } const ClipRect &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; @@ -204,8 +212,12 @@ void SDLGraphics::drawImageCached(const Image *restrict const image, { FUNC_BLOCK("Graphics::drawImageCached", 1) // Check that preconditions for blitting are met. - if (!mWindow || !image || !image->mSDLSurface) + if (mWindow == nullptr || + image == nullptr || + image->mSDLSurface == nullptr) + { return; + } const ClipRect &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; @@ -292,9 +304,9 @@ void SDLGraphics::drawPatternCached(const Image *restrict const image, { FUNC_BLOCK("Graphics::drawPatternCached", 1) // Check that preconditions for blitting are met. - if (!mWindow || !image) + if ((mWindow == nullptr) || (image == nullptr)) return; - if (!image->mSDLSurface) + if (image->mSDLSurface == nullptr) return; const SDL_Rect &bounds = image->mBounds; @@ -413,9 +425,9 @@ void SDLGraphics::drawPatternInline(const Image *restrict const image, { FUNC_BLOCK("Graphics::drawPattern", 1) // Check that preconditions for blitting are met. - if (!mWindow || !image) + if ((mWindow == nullptr) || (image == nullptr)) return; - if (!image->mSDLSurface) + if (image->mSDLSurface == nullptr) return; const SDL_Rect &bounds = image->mBounds; @@ -524,9 +536,9 @@ void SDLGraphics::drawRescaledPattern(const Image *restrict const image, const int scaledHeight) restrict2 { // Check that preconditions for blitting are met. - if (!mWindow || !image) + if ((mWindow == nullptr) || (image == nullptr)) return; - if (!image->mSDLSurface) + if (image->mSDLSurface == nullptr) return; if (scaledHeight == 0 || scaledWidth == 0) @@ -534,7 +546,7 @@ void SDLGraphics::drawRescaledPattern(const Image *restrict const image, Image *const tmpImage = image->SDLgetScaledImage( scaledWidth, scaledHeight); - if (!tmpImage) + if (tmpImage == nullptr) return; const SDL_Rect &bounds = tmpImage->mBounds; @@ -597,8 +609,13 @@ void SDLGraphics::calcPatternInline(ImageVertexes *restrict const vert, const int w, const int h) const restrict2 { // Check that preconditions for blitting are met. - if (!vert || !mWindow || !image || !image->mSDLSurface) + if (vert == nullptr || + mWindow == nullptr || + image == nullptr || + image->mSDLSurface == nullptr) + { return; + } const SDL_Rect &bounds = image->mBounds; const int iw = bounds.w; @@ -650,7 +667,7 @@ void SDLGraphics::calcPattern(ImageCollection *restrict const vertCol, const int x, const int y, const int w, const int h) const restrict2 { - if (!vertCol || !image) + if (vertCol == nullptr || image == nullptr) return; ImageVertexes *vert = nullptr; @@ -690,8 +707,12 @@ void SDLGraphics::calcTileSDL(ImageVertexes *restrict const vert, int x, int y) const restrict2 { // Check that preconditions for blitting are met. - if (!vert || !vert->image || !vert->image->mSDLSurface) + if (vert == nullptr || + vert->image == nullptr || + vert->image->mSDLSurface == nullptr) + { return; + } const Image *const image = vert->image; const ClipRect &top = mClipStack.top(); @@ -719,7 +740,7 @@ void SDLGraphics::calcTileCollection(ImageCollection *restrict const vertCol, const Image *restrict const image, int x, int y) restrict2 { - if (!vertCol) + if (vertCol == nullptr) return; if (vertCol->currentImage != image) { @@ -760,7 +781,7 @@ void SDLGraphics::drawTileCollection(const ImageCollection void SDLGraphics::drawTileVertexes(const ImageVertexes * restrict const vert) restrict2 { - if (!vert) + if (vert == nullptr) return; // vert and img must be != 0 const Image *const img = vert->image; @@ -796,7 +817,7 @@ void SDLGraphics::calcWindow(ImageCollection *restrict const vertCol, { ImageVertexes *vert = nullptr; Image *const image = imgRect.grid[4]; - if (!image) + if (image == nullptr) return; if (vertCol->currentImage != image) { @@ -821,10 +842,10 @@ int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *restrict const src, int srcx, srcy, w, h; // Make sure the surfaces aren't locked - if (!src || !dst) + if ((src == nullptr) || (dst == nullptr)) return -1; - if (!srcrect || !dstrect) + if ((srcrect == nullptr) || (dstrect == nullptr)) return -1; srcx = srcrect->x; @@ -1005,7 +1026,7 @@ void SDLGraphics::fillRectangle(const Rect &restrict rectangle) restrict2 } } #else // SDL_BYTEORDER == SDL_BIG_ENDIAN - if (!cR) + if (cR == nullptr) { cR = new unsigned int[0x100]; cG = new unsigned int[0x100]; @@ -1022,11 +1043,11 @@ void SDLGraphics::fillRectangle(const Rect &restrict rectangle) restrict2 unsigned rShift = rMask / 0xff; unsigned gShift = gMask / 0xff; unsigned bShift = bMask / 0xff; - if (!rShift) + if (rShift == 0u) rShift = 1; - if (!gShift) + if (gShift == 0u) gShift = 1; - if (!bShift) + if (bShift == 0u) bShift = 1; if (pixel != mOldPixel || mColor.a != mOldAlpha) { @@ -1457,8 +1478,8 @@ bool SDLGraphics::setVideoMode(const int w, const int h, { setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame); - if (!(mWindow = graphicsManager.createWindow(w, h, bpp, - getSoftwareFlags()))) + if ((mWindow = graphicsManager.createWindow(w, h, bpp, + getSoftwareFlags())) == nullptr) { mRect.w = 0; mRect.h = 0; diff --git a/src/render/shaders/shader.cpp b/src/render/shaders/shader.cpp index 97ede0520..f3cb54833 100644 --- a/src/render/shaders/shader.cpp +++ b/src/render/shaders/shader.cpp @@ -34,7 +34,7 @@ Shader::Shader(const unsigned int id) : Shader::~Shader() { - if (mShaderId) + if (mShaderId != 0u) mglDeleteShader(mShaderId); } diff --git a/src/render/shaders/shaderprogram.cpp b/src/render/shaders/shaderprogram.cpp index bd19230b5..52cb025d7 100644 --- a/src/render/shaders/shaderprogram.cpp +++ b/src/render/shaders/shaderprogram.cpp @@ -43,11 +43,11 @@ ShaderProgram::ShaderProgram(const unsigned int id, ShaderProgram::~ShaderProgram() { - if (mProgramId) + if (mProgramId != 0u) mglDeleteProgram(mProgramId); - if (mVertex) + if (mVertex != nullptr) mVertex->decRef(); - if (mFragment) + if (mFragment != nullptr) mFragment->decRef(); } diff --git a/src/render/shaders/shadersmanager.cpp b/src/render/shaders/shadersmanager.cpp index 1180ae880..4d4b68083 100644 --- a/src/render/shaders/shadersmanager.cpp +++ b/src/render/shaders/shadersmanager.cpp @@ -71,20 +71,20 @@ ShaderProgram *ShadersManager::createProgram(const std::string &vertex, { Shader *const vertexShader = static_cast( Loader::getShader(GL_VERTEX_SHADER, vertex)); - if (!vertexShader) + if (vertexShader == nullptr) return nullptr; Shader *const fragmentShader = static_cast( Loader::getShader(GL_FRAGMENT_SHADER, fragment)); - if (!fragmentShader) + if (fragmentShader == nullptr) { vertexShader->decRef(); return nullptr; } GLuint programId = mglCreateProgram(); - if (!programId) + if (programId == 0u) { vertexShader->decRef(); fragmentShader->decRef(); diff --git a/src/render/surfacegraphics.cpp b/src/render/surfacegraphics.cpp index 543f2add1..52d0db57f 100644 --- a/src/render/surfacegraphics.cpp +++ b/src/render/surfacegraphics.cpp @@ -48,8 +48,12 @@ void SurfaceGraphics::drawImage(const Image *restrict const image, { FUNC_BLOCK("Graphics::drawImage", 1) // Check that preconditions for blitting are met. - if (!mTarget || !image || !image->mSDLSurface) + if (mTarget == nullptr || + image == nullptr || + image->mSDLSurface == nullptr) + { return; + } const SDL_Rect &imageRect = image->mBounds; SDL_Rect dstRect; @@ -82,8 +86,12 @@ void SurfaceGraphics::copyImage(const Image *restrict const image, { FUNC_BLOCK("Graphics::drawImage", 1) // Check that preconditions for blitting are met. - if (!mTarget || !image || !image->mSDLSurface) + if (mTarget == nullptr || + image == nullptr || + image->mSDLSurface == nullptr) + { return; + } const SDL_Rect &imageRect = image->mBounds; SDL_Rect dstRect; @@ -109,8 +117,12 @@ void SurfaceGraphics::drawImageCached(const Image *restrict const image, { FUNC_BLOCK("Graphics::drawImageCached", 1) // Check that preconditions for blitting are met. - if (!mTarget || !image || !image->mSDLSurface) + if (mTarget == nullptr || + image == nullptr || + image->mSDLSurface == nullptr) + { return; + } const SDL_Rect &rect = image->mBounds; diff --git a/src/render/vertexes/openglgraphicsvertexes.cpp b/src/render/vertexes/openglgraphicsvertexes.cpp index 95f19b996..7d7600ee1 100644 --- a/src/render/vertexes/openglgraphicsvertexes.cpp +++ b/src/render/vertexes/openglgraphicsvertexes.cpp @@ -92,7 +92,7 @@ void OpenGLGraphicsVertexes::clear() restrict2 } mVp.clear(); - if (ptr) + if (ptr != 0) { ptr = 0; delete []mFloatTexArray; -- cgit v1.2.3-60-g2f50