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/gui/fonts | |
parent | f1518dd8476c968a43fa57cfb06198e290a4f77a (diff) | |
download | plus-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/gui/fonts')
-rw-r--r-- | src/gui/fonts/font.cpp | 20 | ||||
-rw-r--r-- | src/gui/fonts/textchunk.cpp | 8 | ||||
-rw-r--r-- | src/gui/fonts/textchunklist.cpp | 26 |
3 files changed, 27 insertions, 27 deletions
diff --git a/src/gui/fonts/font.cpp b/src/gui/fonts/font.cpp index fc752c2eb..78c243a70 100644 --- a/src/gui/fonts/font.cpp +++ b/src/gui/fonts/font.cpp @@ -128,7 +128,7 @@ Font::Font(std::string filename, size = 4; } - if (!fontCounter) + if (fontCounter == 0) { strBuf = new char[65535]; memset(strBuf, 0, 65535); @@ -141,13 +141,13 @@ Font::Font(std::string filename, filename.c_str()); mFont = openFont(filename.c_str(), size); - if (!mFont) + if (mFont == nullptr) { logger->log("Error normal loading font " + filename); filename = "fonts/dejavusans.ttf"; mFont = openFont(fixDirSeparators(filename).c_str(), size); - if (!mFont) + if (mFont == nullptr) { #ifdef UNITTESTS reportAlways("Font load failed %s", @@ -229,14 +229,14 @@ void Font::loadFont(std::string filename, fixDirSeparators(filename); TTF_Font *const font = openFont(filename.c_str(), size); - if (!font) + if (font == nullptr) { logger->log("Font::Font: " + std::string(TTF_GetError())); return; } - if (mFont) + if (mFont != nullptr) TTF_CloseFont(mFont); mFont = font; @@ -283,7 +283,7 @@ void Font::drawString(Graphics *const graphics, TextChunk *const chunk2 = (*i).second; cache->moveToFirst(chunk2); Image *const image = chunk2->img; - if (image) + if (image != nullptr) { image->setAlpha(alpha); graphics->drawImage(image, x, y); @@ -309,7 +309,7 @@ void Font::drawString(Graphics *const graphics, cache->insertFirst(chunk2); const Image *const image = chunk2->img; - if (image) + if (image != nullptr) graphics->drawImage(image, x, y); } BLOCK_END("Font::drawString") @@ -318,7 +318,7 @@ void Font::drawString(Graphics *const graphics, void Font::slowLogic(const int rnd) { BLOCK_START("Font::slowLogic") - if (!mCleanTime) + if (mCleanTime == 0) { mCleanTime = cur_time + CLEAN_TIME + rnd; } @@ -345,7 +345,7 @@ int Font::getWidth(const std::string &text) const TextChunk *const chunk = (*i).second; cache->moveToFirst(chunk); const Image *const image = chunk->img; - if (image) + if (image != nullptr) return image->getWidth(); else return 0; @@ -476,7 +476,7 @@ void Font::generate(TextChunk &chunk) void Font::insertChunk(TextChunk *const chunk) { - if (!chunk || chunk->text.empty() || !chunk->img) + if ((chunk == nullptr) || chunk->text.empty() || (chunk->img == nullptr)) return; // logger->log("insert chunk: text=%s, color: %d,%d,%d", // chunk->text.c_str(), chunk->color.r, chunk->color.g, chunk->color.b); diff --git a/src/gui/fonts/textchunk.cpp b/src/gui/fonts/textchunk.cpp index de2c58084..694790881 100644 --- a/src/gui/fonts/textchunk.cpp +++ b/src/gui/fonts/textchunk.cpp @@ -113,7 +113,7 @@ void TextChunk::generate(TTF_Font *restrict const font, SDL_Surface *surface = MTTF_RenderUTF8_Blended( font, strBuf, sdlCol); - if (!surface) + if (surface == nullptr) { img = nullptr; BLOCK_END("TextChunk::generate") @@ -129,7 +129,7 @@ void TextChunk::generate(TTF_Font *restrict const font, SDL_Color sdlCol2; SDL_Surface *const background = imageHelper->create32BitSurface( width, height); - if (!background) + if (background == nullptr) { img = nullptr; MSDL_FreeSurface(surface); @@ -148,7 +148,7 @@ void TextChunk::generate(TTF_Font *restrict const font, SDL_Surface *const surface2 = MTTF_RenderUTF8_Blended( font, strBuf, sdlCol2); - if (!surface2) + if (surface2 == nullptr) { img = nullptr; MSDL_FreeSurface(surface); @@ -191,7 +191,7 @@ void TextChunk::generate(TTF_Font *restrict const font, void TextChunk::deleteImage() { - if (textFont) + if (textFont != nullptr) { textFont->insertChunk(this); img = nullptr; diff --git a/src/gui/fonts/textchunklist.cpp b/src/gui/fonts/textchunklist.cpp index df791f5f9..4ce39406b 100644 --- a/src/gui/fonts/textchunklist.cpp +++ b/src/gui/fonts/textchunklist.cpp @@ -36,10 +36,10 @@ TextChunkList::TextChunkList() : void TextChunkList::insertFirst(TextChunk *restrict const item) { TextChunk *restrict const oldFirst = start; - if (start) + if (start != nullptr) start->prev = item; item->prev = nullptr; - if (oldFirst) + if (oldFirst != nullptr) item->next = oldFirst; else end = item; @@ -55,15 +55,15 @@ void TextChunkList::moveToFirst(TextChunk *restrict const item) return; TextChunk *restrict const oldPrev = item->prev; - if (oldPrev) + if (oldPrev != nullptr) oldPrev->next = item->next; TextChunk *restrict const oldNext = item->next; - if (oldNext) + if (oldNext != nullptr) oldNext->prev = item->prev; else end = oldPrev; TextChunk *restrict const oldFirst = start; - if (start) + if (start != nullptr) start->prev = item; item->prev = nullptr; item->next = oldFirst; @@ -72,16 +72,16 @@ void TextChunkList::moveToFirst(TextChunk *restrict const item) void TextChunkList::remove(const TextChunk *restrict const item) { - if (!item) + if (item == nullptr) return; TextChunk *restrict const oldPrev = item->prev; TextChunk *restrict const oldNext = item->next; - if (oldPrev) + if (oldPrev != nullptr) oldPrev->next = item->next; else start = oldNext; - if (oldNext) + if (oldNext != nullptr) oldNext->prev = item->prev; else end = oldPrev; @@ -95,10 +95,10 @@ void TextChunkList::remove(const TextChunk *restrict const item) void TextChunkList::removeBack() { TextChunk *restrict oldEnd = end; - if (oldEnd) + if (oldEnd != nullptr) { end = oldEnd->prev; - if (end) + if (end != nullptr) end->next = nullptr; else start = nullptr; @@ -113,7 +113,7 @@ void TextChunkList::removeBack() void TextChunkList::removeBack(int n) { TextChunk *restrict item = end; - while (n && item) + while ((n != 0) && (item != nullptr)) { n --; TextChunk *oldEnd = item; @@ -124,7 +124,7 @@ void TextChunkList::removeBack(int n) delete oldEnd; size --; } - if (item) + if (item != nullptr) { item->next = nullptr; end = item; @@ -141,7 +141,7 @@ void TextChunkList::clear() search.clear(); searchWidth.clear(); TextChunk *restrict item = start; - while (item) + while (item != nullptr) { TextChunk *restrict const item2 = item->next; delete item; |