summaryrefslogtreecommitdiff
path: root/src/render/sdlgraphics.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/render/sdlgraphics.cpp
parentf1518dd8476c968a43fa57cfb06198e290a4f77a (diff)
downloadmanaverse-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/render/sdlgraphics.cpp')
-rw-r--r--src/render/sdlgraphics.cpp71
1 files changed, 46 insertions, 25 deletions
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;