summaryrefslogtreecommitdiff
path: root/src/gui
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/gui
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/gui')
-rw-r--r--src/gui/dialogsmanager.cpp8
-rw-r--r--src/gui/focushandler.cpp32
-rw-r--r--src/gui/fonts/font.cpp20
-rw-r--r--src/gui/fonts/textchunk.cpp8
-rw-r--r--src/gui/fonts/textchunklist.cpp26
-rw-r--r--src/gui/gui.cpp176
-rw-r--r--src/gui/models/colormodel.cpp2
-rw-r--r--src/gui/models/extendednamesmodel.cpp2
-rw-r--r--src/gui/models/langlistmodel.h2
-rw-r--r--src/gui/models/modelistmodel.cpp4
-rw-r--r--src/gui/models/namesmodel.cpp2
-rw-r--r--src/gui/models/playertablemodel.cpp6
-rw-r--r--src/gui/models/serverslistmodel.h4
-rw-r--r--src/gui/models/shopitems.cpp8
-rw-r--r--src/gui/models/skillmodel.cpp4
-rw-r--r--src/gui/models/tablemodel.cpp8
-rw-r--r--src/gui/models/touchactionmodel.cpp2
-rw-r--r--src/gui/models/worldlistmodel.h2
-rw-r--r--src/gui/palette.cpp16
-rw-r--r--src/gui/popupmanager.cpp16
-rw-r--r--src/gui/popups/beingpopup.cpp12
-rw-r--r--src/gui/popups/itempopup.cpp18
-rw-r--r--src/gui/popups/popupmenu.cpp241
-rw-r--r--src/gui/popups/skillpopup.cpp4
-rw-r--r--src/gui/popups/speechbubble.cpp2
-rw-r--r--src/gui/popups/spellpopup.cpp2
-rw-r--r--src/gui/sdlinput.cpp10
-rw-r--r--src/gui/sdlinput.h2
-rw-r--r--src/gui/shortcut/dropshortcut.cpp12
-rw-r--r--src/gui/shortcut/emoteshortcut.cpp8
-rw-r--r--src/gui/shortcut/emoteshortcut.h2
-rw-r--r--src/gui/shortcut/itemshortcut.cpp28
-rw-r--r--src/gui/shortcut/shortcutbase.cpp4
-rw-r--r--src/gui/shortcut/spellshortcut.cpp2
-rw-r--r--src/gui/skin.cpp46
-rw-r--r--src/gui/theme.cpp70
-rw-r--r--src/gui/viewport.cpp108
-rw-r--r--src/gui/widgets/attrs/attrdisplay.cpp2
-rw-r--r--src/gui/widgets/attrs/attrdisplay.h2
-rw-r--r--src/gui/widgets/avatarlistbox.cpp56
-rw-r--r--src/gui/widgets/basiccontainer.cpp12
-rw-r--r--src/gui/widgets/basiccontainer2.cpp2
-rw-r--r--src/gui/widgets/browserbox.cpp38
-rw-r--r--src/gui/widgets/button.cpp68
-rw-r--r--src/gui/widgets/characterdisplay.cpp14
-rw-r--r--src/gui/widgets/characterviewnormal.cpp4
-rw-r--r--src/gui/widgets/characterviewsmall.cpp4
-rw-r--r--src/gui/widgets/chatinput.h6
-rw-r--r--src/gui/widgets/checkbox.cpp28
-rw-r--r--src/gui/widgets/colorpage.cpp6
-rw-r--r--src/gui/widgets/container.cpp2
-rw-r--r--src/gui/widgets/containerplacer.cpp7
-rw-r--r--src/gui/widgets/desktop.cpp20
-rw-r--r--src/gui/widgets/dropdown.cpp44
-rw-r--r--src/gui/widgets/emotepage.cpp10
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp40
-rw-r--r--src/gui/widgets/extendedlistbox.cpp20
-rw-r--r--src/gui/widgets/flowcontainer.cpp8
-rw-r--r--src/gui/widgets/guitable.cpp41
-rw-r--r--src/gui/widgets/horizontcontainer.cpp2
-rw-r--r--src/gui/widgets/icon.cpp14
-rw-r--r--src/gui/widgets/itemcontainer.cpp134
-rw-r--r--src/gui/widgets/itemcontainer.h2
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp14
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp100
-rw-r--r--src/gui/widgets/label.cpp16
-rw-r--r--src/gui/widgets/layoutarray.cpp14
-rw-r--r--src/gui/widgets/layoutcell.cpp4
-rw-r--r--src/gui/widgets/layouthelper.cpp10
-rw-r--r--src/gui/widgets/linepart.cpp2
-rw-r--r--src/gui/widgets/listbox.cpp30
-rw-r--r--src/gui/widgets/passwordfield.cpp4
-rw-r--r--src/gui/widgets/playerbox.cpp10
-rw-r--r--src/gui/widgets/popup.cpp22
-rw-r--r--src/gui/widgets/popuplist.cpp18
-rw-r--r--src/gui/widgets/progressbar.cpp18
-rw-r--r--src/gui/widgets/progressindicator.cpp10
-rw-r--r--src/gui/widgets/radiobutton.cpp26
-rw-r--r--src/gui/widgets/scrollarea.cpp86
-rw-r--r--src/gui/widgets/selldialog.cpp39
-rw-r--r--src/gui/widgets/serverslistbox.h2
-rw-r--r--src/gui/widgets/setupitem.cpp52
-rw-r--r--src/gui/widgets/setuptouchitem.cpp6
-rw-r--r--src/gui/widgets/shoplistbox.cpp22
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp10
-rw-r--r--src/gui/widgets/skilllistbox.h29
-rw-r--r--src/gui/widgets/skillrectanglelistbox.h34
-rw-r--r--src/gui/widgets/slider.cpp44
-rw-r--r--src/gui/widgets/sliderlist.cpp14
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp48
-rw-r--r--src/gui/widgets/statspage.cpp4
-rw-r--r--src/gui/widgets/statspagebasic.cpp12
-rw-r--r--src/gui/widgets/tabbedarea.cpp60
-rw-r--r--src/gui/widgets/tabs/chat/channeltab.cpp6
-rw-r--r--src/gui/widgets/tabs/chat/chattab.cpp36
-rw-r--r--src/gui/widgets/tabs/chat/emulateguildtab.cpp14
-rw-r--r--src/gui/widgets/tabs/chat/guildtab.cpp12
-rw-r--r--src/gui/widgets/tabs/chat/partytab.cpp4
-rw-r--r--src/gui/widgets/tabs/chat/whispertab.cpp10
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.cpp12
-rw-r--r--src/gui/widgets/tabs/setup_audio.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_chat.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_colors.cpp18
-rw-r--r--src/gui/widgets/tabs/setup_input.cpp8
-rw-r--r--src/gui/widgets/tabs/setup_joystick.cpp14
-rw-r--r--src/gui/widgets/tabs/setup_mods.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_players.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_relations.cpp22
-rw-r--r--src/gui/widgets/tabs/setup_theme.cpp8
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp6
-rw-r--r--src/gui/widgets/tabs/setuptabscroll.cpp12
-rw-r--r--src/gui/widgets/tabs/skilltab.h6
-rw-r--r--src/gui/widgets/tabs/socialfriendsfunctor.h7
-rw-r--r--src/gui/widgets/tabs/socialfriendstab.h8
-rw-r--r--src/gui/widgets/tabs/socialguildtab.h10
-rw-r--r--src/gui/widgets/tabs/socialguildtab2.h4
-rw-r--r--src/gui/widgets/tabs/socialnavigationtab.h50
-rw-r--r--src/gui/widgets/tabs/socialpartytab.h8
-rw-r--r--src/gui/widgets/tabs/socialplayerstab.h22
-rw-r--r--src/gui/widgets/tabs/socialtab.h8
-rw-r--r--src/gui/widgets/tabs/tab.cpp44
-rw-r--r--src/gui/widgets/tabstrip.cpp6
-rw-r--r--src/gui/widgets/textbox.cpp10
-rw-r--r--src/gui/widgets/textfield.cpp33
-rw-r--r--src/gui/widgets/textpreview.cpp12
-rw-r--r--src/gui/widgets/vertcontainer.cpp2
-rw-r--r--src/gui/widgets/virtshortcutcontainer.cpp46
-rw-r--r--src/gui/widgets/widget.cpp42
-rw-r--r--src/gui/widgets/widget.h2
-rw-r--r--src/gui/widgets/widget2.h8
-rw-r--r--src/gui/widgets/widgetgroup.cpp4
-rw-r--r--src/gui/widgets/window.cpp152
-rw-r--r--src/gui/widgets/windowcontainer.cpp2
-rw-r--r--src/gui/windowmanager.cpp16
-rw-r--r--src/gui/windowmenu.cpp60
-rw-r--r--src/gui/windows/bankwindow.cpp2
-rw-r--r--src/gui/windows/buydialog.cpp48
-rw-r--r--src/gui/windows/buyingstoreselldialog.cpp6
-rw-r--r--src/gui/windows/buyselldialog.cpp16
-rw-r--r--src/gui/windows/charcreatedialog.cpp52
-rw-r--r--src/gui/windows/chardeleteconfirm.h2
-rw-r--r--src/gui/windows/charselectdialog.cpp58
-rw-r--r--src/gui/windows/chatwindow.cpp208
-rw-r--r--src/gui/windows/confirmdialog.cpp8
-rw-r--r--src/gui/windows/cutinwindow.cpp6
-rw-r--r--src/gui/windows/debugwindow.cpp14
-rw-r--r--src/gui/windows/didyouknowwindow.cpp6
-rw-r--r--src/gui/windows/editserverdialog.cpp2
-rw-r--r--src/gui/windows/eggselectiondialog.cpp2
-rw-r--r--src/gui/windows/emotewindow.cpp10
-rw-r--r--src/gui/windows/equipmentwindow.cpp100
-rw-r--r--src/gui/windows/equipmentwindow.h5
-rw-r--r--src/gui/windows/helpwindow.cpp6
-rw-r--r--src/gui/windows/insertcarddialog.cpp4
-rw-r--r--src/gui/windows/inventorywindow.cpp123
-rw-r--r--src/gui/windows/inventorywindow.h7
-rw-r--r--src/gui/windows/itemamountwindow.cpp36
-rw-r--r--src/gui/windows/killstats.cpp10
-rw-r--r--src/gui/windows/logindialog.cpp17
-rw-r--r--src/gui/windows/maileditwindow.cpp12
-rw-r--r--src/gui/windows/mailviewwindow.cpp20
-rw-r--r--src/gui/windows/mailwindow.cpp18
-rw-r--r--src/gui/windows/minimap.cpp44
-rw-r--r--src/gui/windows/ministatuswindow.cpp56
-rw-r--r--src/gui/windows/npcdialog.cpp78
-rw-r--r--src/gui/windows/npcdialog.h2
-rw-r--r--src/gui/windows/npcselldialog.cpp6
-rw-r--r--src/gui/windows/outfitwindow.cpp44
-rw-r--r--src/gui/windows/questswindow.cpp30
-rw-r--r--src/gui/windows/quitdialog.cpp10
-rw-r--r--src/gui/windows/registerdialog.cpp11
-rw-r--r--src/gui/windows/serverdialog.cpp22
-rw-r--r--src/gui/windows/setupwindow.cpp28
-rw-r--r--src/gui/windows/shopselldialog.cpp4
-rw-r--r--src/gui/windows/shopwindow.cpp134
-rw-r--r--src/gui/windows/shortcutwindow.cpp30
-rw-r--r--src/gui/windows/skilldialog.cpp108
-rw-r--r--src/gui/windows/socialwindow.cpp64
-rw-r--r--src/gui/windows/statuswindow.cpp50
-rw-r--r--src/gui/windows/textcommandeditor.cpp14
-rw-r--r--src/gui/windows/textdialog.cpp14
-rw-r--r--src/gui/windows/textdialog.h2
-rw-r--r--src/gui/windows/textselectdialog.cpp6
-rw-r--r--src/gui/windows/tradewindow.cpp38
-rw-r--r--src/gui/windows/updaterwindow.cpp52
-rw-r--r--src/gui/windows/whoisonline.cpp94
186 files changed, 2442 insertions, 2320 deletions
diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp
index b4a3cc6ea..9b2335736 100644
--- a/src/gui/dialogsmanager.cpp
+++ b/src/gui/dialogsmanager.cpp
@@ -82,11 +82,11 @@ void DialogsManager::closeDialogs()
BuySellDialog::closeAll();
NpcDialog::closeAll();
SellDialog::closeAll();
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->destroyStorage();
#endif // DYECMD
- if (deathNotice)
+ if (deathNotice != nullptr)
{
deathNotice->scheduleDelete();
deathNotice = nullptr;
@@ -139,7 +139,7 @@ Window *DialogsManager::openErrorDialog(const std::string &header,
void DialogsManager::playerDeath()
{
#ifndef DYECMD
- if (!deathNotice)
+ if (deathNotice == nullptr)
{
CREATEWIDGETV(deathNotice, OkDialog,
// TRANSLATORS: message header
@@ -164,7 +164,7 @@ void DialogsManager::attributeChanged(const AttributesT id,
{
if (id == Attributes::TOTAL_WEIGHT)
{
- if (!weightNotice && config.getBoolValue("weightMsg"))
+ if ((weightNotice == nullptr) && config.getBoolValue("weightMsg"))
{
int percent = settings.overweightPercent;
if (percent < 1)
diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp
index 1c6b86954..21b80d9bf 100644
--- a/src/gui/focushandler.cpp
+++ b/src/gui/focushandler.cpp
@@ -92,14 +92,14 @@ void FocusHandler::requestModalFocus(Widget *const widget)
/* If there is another widget with modal focus, remove its modal focus
* and put it on the modal widget stack.
*/
- if (mModalFocusedWidget && mModalFocusedWidget != widget)
+ if ((mModalFocusedWidget != nullptr) && mModalFocusedWidget != widget)
{
mModalStack.push_front(mModalFocusedWidget);
mModalFocusedWidget = nullptr;
}
mModalFocusedWidget = widget;
- if (mFocusedWidget && !mFocusedWidget->isModalFocused())
+ if ((mFocusedWidget != nullptr) && !mFocusedWidget->isModalFocused())
focusNone();
}
@@ -171,7 +171,7 @@ void FocusHandler::remove(Widget *const widget)
void FocusHandler::tabNext()
{
- if (mFocusedWidget)
+ if (mFocusedWidget != nullptr)
{
if (!mFocusedWidget->isTabOutEnabled())
return;
@@ -217,7 +217,7 @@ void FocusHandler::tabNext()
const Widget *const widget = mWidgets.at(focusedWidget);
if (widget->isFocusable() && widget->isTabInEnabled() &&
- (!mModalFocusedWidget || widget->isModalFocused()))
+ ((mModalFocusedWidget == nullptr) || widget->isModalFocused()))
{
done = true;
}
@@ -242,7 +242,7 @@ void FocusHandler::tabNext()
void FocusHandler::tabPrevious()
{
- if (mFocusedWidget)
+ if (mFocusedWidget != nullptr)
{
if (!mFocusedWidget->isTabOutEnabled())
return;
@@ -288,7 +288,7 @@ void FocusHandler::tabPrevious()
const Widget *const widget = mWidgets.at(focusedWidget);
if (widget->isFocusable() && widget->isTabInEnabled() &&
- (!mModalFocusedWidget || widget->isModalFocused()))
+ ((mModalFocusedWidget == nullptr) || widget->isModalFocused()))
{
done = true;
}
@@ -313,15 +313,15 @@ void FocusHandler::tabPrevious()
void FocusHandler::checkForWindow() const
{
- if (mFocusedWidget)
+ if (mFocusedWidget != nullptr)
{
Widget *widget = mFocusedWidget->getParent();
- while (widget)
+ while (widget != nullptr)
{
Window *const window = dynamic_cast<Window*>(widget);
- if (window)
+ if (window != nullptr)
{
window->requestMoveToTop();
break;
@@ -334,12 +334,12 @@ void FocusHandler::checkForWindow() const
void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent)
{
- if (gui)
+ if (gui != nullptr)
gui->distributeGlobalFocusGainedEvent(focusEvent);
const Widget *const sourceWidget = focusEvent.getSource();
- if (!sourceWidget)
+ if (sourceWidget == nullptr)
return;
std::list<FocusListener*> focusListeners
= sourceWidget->getFocusListeners();
@@ -356,7 +356,7 @@ void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent)
void FocusHandler::requestFocus(const Widget *const widget)
{
- if (!widget || widget == mFocusedWidget)
+ if ((widget == nullptr) || widget == mFocusedWidget)
return;
int toBeFocusedIndex = -1;
@@ -379,7 +379,7 @@ void FocusHandler::requestFocus(const Widget *const widget)
{
mFocusedWidget = mWidgets.at(toBeFocusedIndex);
- if (oldFocused)
+ if (oldFocused != nullptr)
{
Event focusEvent(oldFocused);
distributeFocusLostEvent(focusEvent);
@@ -392,7 +392,7 @@ void FocusHandler::requestFocus(const Widget *const widget)
void FocusHandler::requestModalMouseInputFocus(Widget *const widget)
{
- if (mModalMouseInputFocusedWidget
+ if ((mModalMouseInputFocusedWidget != nullptr)
&& mModalMouseInputFocusedWidget != widget)
{
return;
@@ -539,7 +539,7 @@ void FocusHandler::add(Widget *const widget)
void FocusHandler::focusNone()
{
- if (mFocusedWidget)
+ if (mFocusedWidget != nullptr)
{
Widget *const focused = mFocusedWidget;
mFocusedWidget = nullptr;
@@ -552,7 +552,7 @@ void FocusHandler::focusNone()
void FocusHandler::distributeFocusLostEvent(const Event& focusEvent)
{
const Widget *const sourceWidget = focusEvent.getSource();
- if (!sourceWidget)
+ if (sourceWidget == nullptr)
return;
std::list<FocusListener*> focusListeners
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;
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 04c9e3ada..8063207c6 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -269,13 +269,13 @@ Gui::~Gui()
config.removeListeners(mConfigListener);
delete2(mConfigListener);
- if (mMouseCursors)
+ if (mMouseCursors != nullptr)
{
mMouseCursors->decRef();
mMouseCursors = nullptr;
}
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->slowLogic();
Widget *top = mTop;
if (Widget::widgetExists(mTop))
@@ -303,7 +303,7 @@ void Gui::logic()
BLOCK_START("Gui::logic")
ResourceManager::clearScheduled();
- if (!mTop)
+ if (mTop == nullptr)
{
BLOCK_END("Gui::logic")
return;
@@ -312,7 +312,7 @@ void Gui::logic()
handleModalFocus();
handleModalMouseInputFocus();
- if (guiInput)
+ if (guiInput != nullptr)
handleMouseInput();
mTop->logic();
@@ -334,26 +334,26 @@ void Gui::slowLogic()
{
mMouseCursorAlpha = std::max(0.0F, mMouseCursorAlpha - 0.005F);
}
- if (mGuiFont)
+ if (mGuiFont != nullptr)
mGuiFont->slowLogic(0);
- if (mInfoParticleFont)
+ if (mInfoParticleFont != nullptr)
mInfoParticleFont->slowLogic(1);
- if (mHelpFont)
+ if (mHelpFont != nullptr)
mHelpFont->slowLogic(2);
- if (mSecureFont)
+ if (mSecureFont != nullptr)
mSecureFont->slowLogic(3);
- if (boldFont)
+ if (boldFont != nullptr)
boldFont->slowLogic(4);
- if (mNpcFont)
+ if (mNpcFont != nullptr)
mNpcFont->slowLogic(5);
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->slowLogic();
const time_t time = cur_time;
if (mTime != time)
{
logger->flush();
- if (ipc)
+ if (ipc != nullptr)
ipc->flush();
mTime = time;
@@ -369,23 +369,23 @@ void Gui::slowLogic()
void Gui::clearFonts()
{
- if (mGuiFont)
+ if (mGuiFont != nullptr)
mGuiFont->clear();
- if (mInfoParticleFont)
+ if (mInfoParticleFont != nullptr)
mInfoParticleFont->clear();
- if (mHelpFont)
+ if (mHelpFont != nullptr)
mHelpFont->clear();
- if (mSecureFont)
+ if (mSecureFont != nullptr)
mSecureFont->clear();
- if (boldFont)
+ if (boldFont != nullptr)
boldFont->clear();
- if (mNpcFont)
+ if (mNpcFont != nullptr)
mNpcFont->clear();
}
bool Gui::handleInput()
{
- if (mInput)
+ if (mInput != nullptr)
return handleKeyInput();
else
return false;
@@ -393,7 +393,7 @@ bool Gui::handleInput()
bool Gui::handleKeyInput()
{
- if (!guiInput)
+ if (guiInput == nullptr)
return false;
BLOCK_START("Gui::handleKeyInput")
@@ -423,12 +423,12 @@ bool Gui::handleKeyInput()
continue;
}
- if (mFocusHandler)
+ if (mFocusHandler != nullptr)
{
bool eventConsumed = false;
// Send key inputs to the focused widgets
- if (mFocusHandler->getFocused())
+ if (mFocusHandler->getFocused() != nullptr)
{
KeyEvent event(getKeyEventSource(),
keyInput.getType(),
@@ -470,7 +470,7 @@ void Gui::draw()
{
BLOCK_START("Gui::draw 1")
Widget *const top = getTop();
- if (!top)
+ if (top == nullptr)
return;
mGraphics->pushClipArea(top->getDimension());
@@ -489,25 +489,29 @@ void Gui::draw()
int mouseY;
const MouseStateType button = getMouseState(mouseX, mouseY);
- if ((settings.mouseFocused || button & SDL_BUTTON(1))
- && mMouseCursors && mCustomCursor && mMouseCursorAlpha > 0.0F)
+ if ((settings.mouseFocused ||
+ ((button & SDL_BUTTON(1)) != 0)) &&
+ mMouseCursors != nullptr &&
+ mCustomCursor &&
+ mMouseCursorAlpha > 0.0F)
{
#ifndef DYECMD
const Image *const image = dragDrop.getItemImage();
- if (mGuiFont)
+ if (mGuiFont != nullptr)
{
const std::string &str = dragDrop.getText();
if (!str.empty())
{
const int posX = mouseX - mGuiFont->getWidth(str) / 2;
- const int posY = mouseY + (image ? image->mBounds.h / 2 : 0);
+ const int posY = mouseY +
+ (image != nullptr ? image->mBounds.h / 2 : 0);
mGuiFont->drawString(mGraphics,
mForegroundColor, mForegroundColor2,
str,
posX, posY);
}
}
- if (image)
+ if (image != nullptr)
{
const int posX = mouseX - (image->mBounds.w / 2);
const int posY = mouseY - (image->mBounds.h / 2);
@@ -517,7 +521,7 @@ void Gui::draw()
Image *const mouseCursor = mMouseCursors->get(
CAST_SIZE(mCursorType));
- if (mouseCursor)
+ if (mouseCursor != nullptr)
{
mouseCursor->setAlpha(mMouseCursorAlpha);
mGraphics->drawImage(mouseCursor, mouseX - 15, mouseY - 17);
@@ -532,7 +536,7 @@ void Gui::videoResized() const
{
WindowContainer *const top = static_cast<WindowContainer *>(getTop());
- if (top)
+ if (top != nullptr)
{
const int oldWidth = top->getWidth();
const int oldHeight = top->getHeight();
@@ -541,7 +545,7 @@ void Gui::videoResized() const
top->adjustAfterResize(oldWidth, oldHeight);
}
- if (viewport)
+ if (viewport != nullptr)
viewport->videoResized();
Widget::distributeWindowResizeEvent();
}
@@ -558,11 +562,11 @@ void Gui::setUseCustomCursor(const bool customCursor)
SDL::showCursor(false);
// Load the mouse cursor
- if (mMouseCursors)
+ if (mMouseCursors != nullptr)
mMouseCursors->decRef();
mMouseCursors = Theme::getImageSetFromTheme("mouse.png", 40, 40);
- if (!mMouseCursors)
+ if (mMouseCursors == nullptr)
logger->log("Error: Unable to load mouse cursors.");
}
else
@@ -571,7 +575,7 @@ void Gui::setUseCustomCursor(const bool customCursor)
SDL::showCursor(true);
// Unload the mouse cursor
- if (mMouseCursors)
+ if (mMouseCursors != nullptr)
{
mMouseCursors->decRef();
mMouseCursors = nullptr;
@@ -583,9 +587,12 @@ void Gui::setUseCustomCursor(const bool customCursor)
void Gui::handleMouseMoved(const MouseInput &mouseInput)
{
// Check if the mouse leaves the application window.
- if (mTop && !mWidgetWithMouseQueue.empty() && (mouseInput.getX() < 0
- || mouseInput.getY() < 0 || !mTop->getDimension().isPointInRect(
- mouseInput.getX(), mouseInput.getY())))
+ if (mTop != nullptr &&
+ !mWidgetWithMouseQueue.empty() &&
+ (mouseInput.getX() < 0 ||
+ mouseInput.getY() < 0 ||
+ !mTop->getDimension().isPointInRect(mouseInput.getX(),
+ mouseInput.getY())))
{
// Distribute an event to all widgets in the
// "widget with mouse" queue.
@@ -681,10 +688,10 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput)
// widget with modal mouse input focus, hence we need to check if
// that's the case. If it's not we should simply ignore to send any
// mouse entered events.
- if (mFocusHandler->getModalMouseInputFocused()
+ if ((mFocusHandler->getModalMouseInputFocused() != nullptr)
&& widget == mFocusHandler->getModalMouseInputFocused()
&& Widget::widgetExists(widget) &&
- widget)
+ (widget != nullptr))
{
int x, y;
widget->getAbsolutePosition(x, y);
@@ -697,7 +704,7 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput)
}
}
- while (parent)
+ while (parent != nullptr)
{
parent = widget->getParent();
@@ -733,7 +740,7 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput)
parent = swap->getParent();
}
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
{
distributeMouseEvent(mFocusHandler->getDraggedWidget(),
MouseEventType::DRAGGED,
@@ -762,18 +769,18 @@ void Gui::handleMousePressed(const MouseInput &mouseInput)
Widget *sourceWidget = getMouseEventSource(x, y);
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
sourceWidget = mFocusHandler->getDraggedWidget();
- if (!sourceWidget)
+ if (sourceWidget == nullptr)
return;
int sourceWidgetX;
int sourceWidgetY;
sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
- if ((mFocusHandler->getModalFocused()
+ if (((mFocusHandler->getModalFocused() != nullptr)
&& sourceWidget->isModalFocused())
- || !mFocusHandler->getModalFocused())
+ || (mFocusHandler->getModalFocused() == nullptr))
{
sourceWidget->requestFocus();
}
@@ -834,7 +841,7 @@ void Gui::distributeMouseEvent(Widget *const source,
const bool force,
const bool toSourceOnly)
{
- if (!source || !mFocusHandler)
+ if ((source == nullptr) || (mFocusHandler == nullptr))
return;
Widget *widget = source;
@@ -858,7 +865,7 @@ void Gui::distributeMouseEvent(Widget *const source,
x, y, mClickCount);
Widget* parent = source;
- while (parent)
+ while (parent != nullptr)
{
// If the widget has been removed due to input
// cancel the distribution.
@@ -932,12 +939,12 @@ void Gui::distributeMouseEvent(Widget *const source,
dragDrop.clear();
#endif // DYECMD
- if (!widget || event.isConsumed())
+ if ((widget == nullptr) || event.isConsumed())
break;
// If a non modal focused widget has been reach
// and we have modal focus cancel the distribution.
- if (mFocusHandler->getModalFocused()
+ if ((mFocusHandler->getModalFocused() != nullptr)
&& !widget->isModalFocused())
{
break;
@@ -945,7 +952,7 @@ void Gui::distributeMouseEvent(Widget *const source,
// If a non modal mouse input focused widget has been reach
// and we have modal mouse input focus cancel the distribution.
- if (mFocusHandler->getModalMouseInputFocused()
+ if ((mFocusHandler->getModalMouseInputFocused() != nullptr)
&& !widget->isModalMouseInputFocused())
{
break;
@@ -961,7 +968,7 @@ void Gui::resetClickCount()
MouseEvent *Gui::createMouseEvent(Window *const widget)
{
- if (!viewport || !widget)
+ if ((viewport == nullptr) || (widget == nullptr))
return nullptr;
int x = 0;
@@ -984,11 +991,11 @@ void Gui::getAbsolutePosition(Widget *restrict widget,
int &restrict x,
int &restrict y)
{
- if (!widget)
+ if (widget == nullptr)
return;
x = 0;
y = 0;
- while (widget->getParent())
+ while (widget->getParent() != nullptr)
{
x += widget->getX();
y += widget->getY();
@@ -1061,14 +1068,14 @@ void Gui::handleMouseReleased(const MouseInput &mouseInput)
int sourceWidgetX;
int sourceWidgetY;
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
{
if (sourceWidget != mFocusHandler->getLastWidgetPressed())
mFocusHandler->setLastWidgetPressed(nullptr);
Widget *const oldWidget = sourceWidget;
sourceWidget = mFocusHandler->getDraggedWidget();
- if (oldWidget && oldWidget != sourceWidget)
+ if ((oldWidget != nullptr) && oldWidget != sourceWidget)
{
oldWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
distributeMouseEvent(oldWidget,
@@ -1079,7 +1086,7 @@ void Gui::handleMouseReleased(const MouseInput &mouseInput)
}
}
- if (!sourceWidget)
+ if (sourceWidget == nullptr)
return;
sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
distributeMouseEvent(sourceWidget,
@@ -1105,7 +1112,7 @@ void Gui::handleMouseReleased(const MouseInput &mouseInput)
mClickCount = 0;
}
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
mFocusHandler->setDraggedWidget(nullptr);
}
@@ -1131,7 +1138,7 @@ void Gui::distributeGlobalFocusGainedEvent(const Event &focusEvent)
void Gui::removeDragged(const Widget *const widget)
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
if (mFocusHandler->getDraggedWidget() == widget)
@@ -1149,9 +1156,9 @@ MouseStateType Gui::getMouseState(int &x, int &y)
void Gui::setTop(Widget *const top)
{
- if (mTop)
+ if (mTop != nullptr)
mTop->setFocusHandler(nullptr);
- if (top)
+ if (top != nullptr)
top->setFocusHandler(mFocusHandler);
mTop = top;
@@ -1192,10 +1199,10 @@ void Gui::handleMouseWheelMovedDown(const MouseInput& mouseInput)
Widget* sourceWidget = getMouseEventSource(
mouseInput.getX(), mouseInput.getY());
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
sourceWidget = mFocusHandler->getDraggedWidget();
- if (sourceWidget)
+ if (sourceWidget != nullptr)
{
int sourceWidgetX = 0;
int sourceWidgetY = 0;
@@ -1214,10 +1221,10 @@ void Gui::handleMouseWheelMovedUp(const MouseInput& mouseInput)
Widget* sourceWidget = getMouseEventSource(
mouseInput.getX(), mouseInput.getY());
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
sourceWidget = mFocusHandler->getDraggedWidget();
- if (sourceWidget)
+ if (sourceWidget != nullptr)
{
int sourceWidgetX;
int sourceWidgetY;
@@ -1238,14 +1245,14 @@ Widget* Gui::getWidgetAt(const int x, const int y) const
Widget* child = mTop;
Widget* selectable = mTop;
- while (child)
+ while (child != nullptr)
{
Widget *const swap = child;
int parentX, parentY;
parent->getAbsolutePosition(parentX, parentY);
child = parent->getWidgetAt(x - parentX, y - parentY);
parent = swap;
- if (parent && parent->isSelectable())
+ if ((parent != nullptr) && parent->isSelectable())
selectable = parent;
}
@@ -1255,11 +1262,12 @@ Widget* Gui::getWidgetAt(const int x, const int y) const
Widget* Gui::getMouseEventSource(const int x, const int y) const
{
Widget *const widget = getWidgetAt(x, y);
- if (!widget)
+ if (widget == nullptr)
return nullptr;
- if (mFocusHandler && mFocusHandler->getModalMouseInputFocused()
- && !widget->isModalMouseInputFocused())
+ if (mFocusHandler != nullptr &&
+ mFocusHandler->getModalMouseInputFocused() != nullptr &&
+ !widget->isModalMouseInputFocused())
{
return mFocusHandler->getModalMouseInputFocused();
}
@@ -1271,8 +1279,9 @@ Widget* Gui::getKeyEventSource() const
{
Widget* widget = mFocusHandler->getFocused();
- while (widget && widget->getInternalFocusHandler()
- && widget->getInternalFocusHandler()->getFocused())
+ while (widget != nullptr &&
+ widget->getInternalFocusHandler() != nullptr &&
+ widget->getInternalFocusHandler()->getFocused() != nullptr)
{
widget = widget->getInternalFocusHandler()->getFocused();
}
@@ -1285,17 +1294,20 @@ void Gui::distributeKeyEvent(KeyEvent &event) const
Widget* parent = event.getSource();
Widget* widget = parent;
- if (!parent)
+ if (parent == nullptr)
return;
- if (mFocusHandler->getModalFocused() && !widget->isModalFocused())
+ if (mFocusHandler->getModalFocused() != nullptr &&
+ !widget->isModalFocused())
+ {
return;
- if (mFocusHandler->getModalMouseInputFocused()
- && !widget->isModalMouseInputFocused())
+ }
+ if (mFocusHandler->getModalMouseInputFocused() != nullptr &&
+ !widget->isModalMouseInputFocused())
{
return;
}
- while (parent)
+ while (parent != nullptr)
{
// If the widget has been removed due to input
// cancel the distribution.
@@ -1334,8 +1346,8 @@ void Gui::distributeKeyEvent(KeyEvent &event) const
// If a non modal focused widget has been reach
// and we have modal focus cancel the distribution.
- if (widget &&
- mFocusHandler->getModalFocused() &&
+ if ((widget != nullptr) &&
+ (mFocusHandler->getModalFocused() != nullptr) &&
!widget->isModalFocused())
{
break;
@@ -1376,7 +1388,7 @@ void Gui::handleModalMouseInputFocus()
if (lastModalWidget != modalWidget)
{
// Check if modal mouse input focus has been gained by a widget.
- if (!lastModalWidget)
+ if (lastModalWidget == nullptr)
{
handleModalFocusGained();
mFocusHandler->setLastWidgetWithModalMouseInputFocus(modalWidget);
@@ -1401,7 +1413,7 @@ void Gui::handleModalFocus()
if (lastModalWidget != modalWidget)
{
// Check if modal focus has been gained by a widget.
- if (!lastModalWidget)
+ if (lastModalWidget == nullptr)
{
handleModalFocusGained();
mFocusHandler->setLastWidgetWithModalFocus(modalWidget);
@@ -1450,7 +1462,7 @@ void Gui::handleModalFocusReleased()
Widget* widget = getMouseEventSource(mLastMouseX, mLastMouseY);
Widget* parent = widget;
- while (parent)
+ while (parent != nullptr)
{
parent = widget->getParent();
@@ -1488,7 +1500,7 @@ void Gui::handleModalFocusReleased()
int Gui::getMousePressLength() const
{
- if (!mLastMousePressTimeStamp)
+ if (mLastMousePressTimeStamp == 0u)
return 0;
unsigned int ticks = SDL_GetTicks();
if (ticks > mLastMousePressTimeStamp)
diff --git a/src/gui/models/colormodel.cpp b/src/gui/models/colormodel.cpp
index 76a7da8fa..3bbded2e2 100644
--- a/src/gui/models/colormodel.cpp
+++ b/src/gui/models/colormodel.cpp
@@ -71,7 +71,7 @@ void ColorModel::add(const std::string &name, const Color *const color1,
ColorModel *ColorModel::createDefault(const Widget2 *const widget)
{
ColorModel *const model = new ColorModel;
- if (!widget)
+ if (widget == nullptr)
return model;
// TRANSLATORS: color name
addColor(_("black"), BLACK);
diff --git a/src/gui/models/extendednamesmodel.cpp b/src/gui/models/extendednamesmodel.cpp
index 2b185d9b3..2c8d7167a 100644
--- a/src/gui/models/extendednamesmodel.cpp
+++ b/src/gui/models/extendednamesmodel.cpp
@@ -58,7 +58,7 @@ void ExtendedNamesModel::clear()
mNames.clear();
FOR_EACH (std::vector<Image*>::iterator, it, mImages)
{
- if (*it)
+ if (*it != nullptr)
(*it)->decRef();
}
mImages.clear();
diff --git a/src/gui/models/langlistmodel.h b/src/gui/models/langlistmodel.h
index 839a836e7..f8c67ad30 100644
--- a/src/gui/models/langlistmodel.h
+++ b/src/gui/models/langlistmodel.h
@@ -116,7 +116,7 @@ class LangListModel final : public ExtendedListModel
for (int f = 0; f < langs_count; f ++)
{
Image *const img = mIcons[f];
- if (img)
+ if (img != nullptr)
img->decRef();
}
}
diff --git a/src/gui/models/modelistmodel.cpp b/src/gui/models/modelistmodel.cpp
index 60974bb7e..3c39921ad 100644
--- a/src/gui/models/modelistmodel.cpp
+++ b/src/gui/models/modelistmodel.cpp
@@ -36,12 +36,12 @@ static bool modeSorter(const std::string &mode1, const std::string &mode2)
{
const int width1 = atoi(mode1.substr(0, mode1.find('x')).c_str());
const int height1 = atoi(mode1.substr(mode1.find('x') + 1).c_str());
- if (!width1 || !height1)
+ if ((width1 == 0) || (height1 == 0))
return false;
const int width2 = atoi(mode2.substr(0, mode2.find('x')).c_str());
const int height2 = atoi(mode2.substr(mode2.find('x') + 1).c_str());
- if (!width2 || !height2)
+ if ((width2 == 0) || (height2 == 0))
return false;
if (width1 != width2)
return width1 < width2;
diff --git a/src/gui/models/namesmodel.cpp b/src/gui/models/namesmodel.cpp
index 9c90ff4c0..5a351f471 100644
--- a/src/gui/models/namesmodel.cpp
+++ b/src/gui/models/namesmodel.cpp
@@ -49,7 +49,7 @@ std::string NamesModel::getElementAt(int i)
void NamesModel::fillFromArray(const char *const *const arr,
const std::size_t sz)
{
- if (!arr)
+ if (arr == nullptr)
return;
for (size_t f = 0; f < sz; f ++)
mNames.push_back(gettext(arr[f]));
diff --git a/src/gui/models/playertablemodel.cpp b/src/gui/models/playertablemodel.cpp
index 29e08578d..9c8526e0d 100644
--- a/src/gui/models/playertablemodel.cpp
+++ b/src/gui/models/playertablemodel.cpp
@@ -66,7 +66,7 @@ PlayerTableModel::~PlayerTableModel()
int PlayerTableModel::getRows() const
{
- if (mPlayers)
+ if (mPlayers != nullptr)
return CAST_S32(mPlayers->size());
else
return 0;
@@ -120,7 +120,7 @@ void PlayerTableModel::updateModelInRow(const int row) const
{
const DropDown *const choicebox = static_cast<DropDown *>(
getElementAt(row, RELATION_CHOICE_COLUMN));
- if (!choicebox)
+ if (choicebox == nullptr)
return;
player_relations.setRelation(getPlayerAt(row),
static_cast<RelationT>(
@@ -141,7 +141,7 @@ void PlayerTableModel::freeWidgets()
std::string PlayerTableModel::getPlayerAt(const int index) const
{
- if (!mPlayers || index < 0
+ if ((mPlayers == nullptr) || index < 0
|| index >= CAST_S32(mPlayers->size()))
{
return std::string();
diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h
index 453c1fa09..935fd3422 100644
--- a/src/gui/models/serverslistmodel.h
+++ b/src/gui/models/serverslistmodel.h
@@ -42,7 +42,7 @@ class ServersListModel final : public ListModel
ServersListModel(ServerInfos *const servers,
ServerDialog *const parent) :
mServers(servers),
- mVersionStrings(servers ? servers->size() : 0,
+ mVersionStrings(servers != nullptr ? servers->size() : 0,
VersionString(0, "")),
mParent(parent)
{
@@ -83,7 +83,7 @@ class ServersListModel final : public ListModel
if (index < 0 || index >= CAST_S32(mVersionStrings.size()))
return;
- if (version.empty() || !gui)
+ if (version.empty() || (gui == nullptr))
{
mVersionStrings[index] = VersionString(0, "");
}
diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp
index 94bba3be4..a5c05388b 100644
--- a/src/gui/models/shopitems.cpp
+++ b/src/gui/models/shopitems.cpp
@@ -46,7 +46,7 @@ ShopItems::~ShopItems()
std::string ShopItems::getElementAt(int i)
{
if (i < 0 || CAST_U32(i)
- >= CAST_U32(mShopItems.size()) || !mShopItems.at(i))
+ >= CAST_U32(mShopItems.size()) || (mShopItems.at(i) == nullptr))
{
return "";
}
@@ -79,7 +79,7 @@ ShopItem *ShopItems::addItemNoDup(const int id,
const int price)
{
ShopItem *item = findItem(id, color);
- if (!item)
+ if (item == nullptr)
{
item = new ShopItem(-1,
id,
@@ -105,7 +105,7 @@ ShopItem *ShopItems::addItem2(const int inventoryIndex,
if (mMergeDuplicates)
item = findItem(id, color);
- if (item)
+ if (item != nullptr)
{
item->addDuplicate(inventoryIndex, quantity);
}
@@ -199,7 +199,7 @@ void ShopItems::updateList()
FOR_EACH (std::vector<ShopItem*>::iterator, it, mAllShopItems)
{
ShopItem *const item = *it;
- if (item && item->isVisible())
+ if ((item != nullptr) && item->isVisible())
mShopItems.push_back(item);
}
}
diff --git a/src/gui/models/skillmodel.cpp b/src/gui/models/skillmodel.cpp
index 13d2bb547..102956897 100644
--- a/src/gui/models/skillmodel.cpp
+++ b/src/gui/models/skillmodel.cpp
@@ -43,7 +43,7 @@ SkillInfo *SkillModel::getSkillAt(const int i) const
std::string SkillModel::getElementAt(int i)
{
const SkillInfo *const info = getSkillAt(i);
- if (info)
+ if (info != nullptr)
return info->data->name;
else
return std::string();
@@ -55,7 +55,7 @@ void SkillModel::updateVisibilities()
FOR_EACH (SkillList::const_iterator, it, mSkills)
{
- if ((*it) && (*it)->visible == Visible_true)
+ if (((*it) != nullptr) && (*it)->visible == Visible_true)
mVisibleSkills.push_back((*it));
}
}
diff --git a/src/gui/models/tablemodel.cpp b/src/gui/models/tablemodel.cpp
index fe60ccc95..08cfb6d83 100644
--- a/src/gui/models/tablemodel.cpp
+++ b/src/gui/models/tablemodel.cpp
@@ -32,13 +32,13 @@
void TableModel::installListener(TableModelListener *const listener)
{
- if (listener)
+ if (listener != nullptr)
listeners.insert(listener);
}
void TableModel::removeListener(TableModelListener *const listener)
{
- if (listener)
+ if (listener != nullptr)
listeners.erase(listener);
}
@@ -56,7 +56,7 @@ void TableModel::signalAfterUpdate()
for (std::set<TableModelListener *>::const_iterator it = listeners.begin();
it != listeners.end(); ++it)
{
- if (*it)
+ if (*it != nullptr)
(*it)->modelUpdated(true);
}
}
@@ -93,7 +93,7 @@ void StaticTableModel::resize()
void StaticTableModel::set(const int row, const int column,
Widget *const widget)
{
- if (!widget || row >= mRows || row < 0
+ if ((widget == nullptr) || row >= mRows || row < 0
|| column >= mColumns || column < 0)
{
// raise exn?
diff --git a/src/gui/models/touchactionmodel.cpp b/src/gui/models/touchactionmodel.cpp
index 6238797e6..983fc7065 100644
--- a/src/gui/models/touchactionmodel.cpp
+++ b/src/gui/models/touchactionmodel.cpp
@@ -37,7 +37,7 @@ static class SortTouchActionFunctor final
bool operator() (const SetupActionData *const data1,
const SetupActionData *const data2) const
{
- if (!data1 || !data2)
+ if ((data1 == nullptr) || (data2 == nullptr))
return false;
return data1->name < data2->name;
}
diff --git a/src/gui/models/worldlistmodel.h b/src/gui/models/worldlistmodel.h
index 4fe0a812e..4436f848c 100644
--- a/src/gui/models/worldlistmodel.h
+++ b/src/gui/models/worldlistmodel.h
@@ -53,7 +53,7 @@ class WorldListModel final : public ListModel
std::string getElementAt(int i) override final
{
const WorldInfo *const si = mWorlds[i];
- if (si)
+ if (si != nullptr)
{
return std::string(si->name).append(" (").append(
toString(si->online_users)).append(")");
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index c3e3a6fa8..25f8084e9 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -93,7 +93,7 @@ void Palette::advanceGradient()
for (size_t i = 0, sz = mGradVector.size(); i < sz; i++)
{
ColorElem *const elem A_NONNULLPOINTER = mGradVector[i];
- if (!elem)
+ if (elem == nullptr)
continue;
int delay = elem->delay;
@@ -110,9 +110,9 @@ void Palette::advanceGradient()
% (delay * numOfColors);
const int gradIndex = elem->gradientIndex;
- const int pos = delay ? (gradIndex % delay) : gradIndex;
+ const int pos = delay != 0 ? (gradIndex % delay) : gradIndex;
int colIndex;
- if (delay)
+ if (delay != 0)
colIndex = gradIndex / delay;
else
colIndex = gradIndex;
@@ -133,9 +133,9 @@ void Palette::advanceGradient()
}
else if (grad == GradientType::SPECTRUM)
{
- if (colIndex % 2)
+ if ((colIndex % 2) != 0)
{ // falling curve
- if (delay)
+ if (delay != 0)
{
colVal = CAST_S32(255.0 *
(cos(M_PI * pos / delay) + 1) / 2);
@@ -148,7 +148,7 @@ void Palette::advanceGradient()
}
else
{ // ascending curve
- if (delay)
+ if (delay != 0)
{
colVal = CAST_S32(255.0 * (cos(M_PI *
(delay - pos) / delay) + 1) / 2);
@@ -175,7 +175,7 @@ void Palette::advanceGradient()
double startColVal;
double destColVal;
- if (delay)
+ if (delay != 0)
startColVal = (cos(M_PI * pos / delay) + 1) / 2;
else
startColVal = 0;
@@ -193,7 +193,7 @@ void Palette::advanceGradient()
}
}
- if (advance)
+ if (advance != 0)
mRainbowTime = tick_time;
}
}
diff --git a/src/gui/popupmanager.cpp b/src/gui/popupmanager.cpp
index 5a9c2809b..c415956ce 100644
--- a/src/gui/popupmanager.cpp
+++ b/src/gui/popupmanager.cpp
@@ -43,7 +43,7 @@ PopupManager::~PopupManager()
void PopupManager::closePopupMenu()
{
#ifndef DYECMD
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->handleLink("cancel", nullptr);
#endif // DYECMD
}
@@ -51,21 +51,21 @@ void PopupManager::closePopupMenu()
void PopupManager::hideBeingPopup()
{
#ifndef DYECMD
- if (beingPopup)
+ if (beingPopup != nullptr)
beingPopup->setVisible(Visible_false);
#endif // DYECMD
}
void PopupManager::hideTextPopup()
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
void PopupManager::hidePopupMenu()
{
#ifndef DYECMD
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->setVisible(Visible_false);
#endif // DYECMD
}
@@ -73,7 +73,7 @@ void PopupManager::hidePopupMenu()
bool PopupManager::isPopupMenuVisible()
{
#ifndef DYECMD
- return popupMenu ? popupMenu->isPopupVisible() : false;
+ return popupMenu != nullptr ? popupMenu->isPopupVisible() : false;
#else
return false;
#endif // DYECMD
@@ -82,20 +82,20 @@ bool PopupManager::isPopupMenuVisible()
void PopupManager::clearPopup()
{
#ifndef DYECMD
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->clear();
#endif // DYECMD
}
bool PopupManager::isTextPopupVisible()
{
- return textPopup ? textPopup->isPopupVisible() : false;
+ return textPopup != nullptr ? textPopup->isPopupVisible() : false;
}
bool PopupManager::isBeingPopupVisible()
{
#ifndef DYECMD
- return beingPopup ? beingPopup->isPopupVisible() : false;
+ return beingPopup != nullptr ? beingPopup->isPopupVisible() : false;
#else // DYECMD
return false;
#endif // DYECMD
diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp
index 5a800871b..c18ac3871 100644
--- a/src/gui/popups/beingpopup.cpp
+++ b/src/gui/popups/beingpopup.cpp
@@ -84,7 +84,7 @@ void BeingPopup::addLabels(const int fontHeight)
void BeingPopup::show(const int x, const int y, Being *const b)
{
- if (!b)
+ if (b == nullptr)
{
setVisible(Visible_false);
return;
@@ -101,7 +101,7 @@ void BeingPopup::show(const int x, const int y, Being *const b)
}
mBeingName->setCaption(b->getName() + b->getGenderSignWithSpace());
- if (gui)
+ if (gui != nullptr)
{
if (player_relations.isGoodName(b))
mBeingName->setFont(boldFont);
@@ -130,7 +130,7 @@ void BeingPopup::show(const int x, const int y, Being *const b)
if (type == ActorType::Pet)
{
const PetInfo *const info = PlayerInfo::getPet();
- if (info && info->id == b->getId())
+ if ((info != nullptr) && info->id == b->getId())
{
ptr = mLabels[num];
// TRANSLATORS: being popup label
@@ -149,7 +149,7 @@ void BeingPopup::show(const int x, const int y, Being *const b)
else if (type == ActorType::Homunculus)
{
const HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (info && info->id == b->getId())
+ if ((info != nullptr) && info->id == b->getId())
{
ptr = mLabels[num];
// TRANSLATORS: being popup label
@@ -239,7 +239,7 @@ void BeingPopup::show(const int x, const int y, Being *const b)
}
const ChatObject *const chat = b->getChat();
- if (chat)
+ if (chat != nullptr)
{
ptr = mLabels[num];
// TRANSLATORS: being popup label
@@ -298,7 +298,7 @@ void BeingPopup::show(const int x, const int y, Being *const b)
FOR_EACH (std::vector<Label*>::iterator, it, mLabels)
{
const Label *const label = *it;
- if (label)
+ if (label != nullptr)
{
if (label->getWidth() > minWidth)
minWidth = label->getWidth();
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
index 17f955da0..3fc546cf0 100644
--- a/src/gui/popups/itempopup.cpp
+++ b/src/gui/popups/itempopup.cpp
@@ -125,10 +125,10 @@ void ItemPopup::postInit()
ItemPopup::~ItemPopup()
{
- if (mIcon)
+ if (mIcon != nullptr)
{
Image *const image = mIcon->getImage();
- if (image)
+ if (image != nullptr)
image->decRef();
}
}
@@ -136,7 +136,7 @@ ItemPopup::~ItemPopup()
void ItemPopup::setItem(const Item *const item,
const bool showImage)
{
- if (!item)
+ if (item == nullptr)
return;
const ItemInfo &ii = item->getInfo();
@@ -181,8 +181,8 @@ void ItemPopup::setItem(const ItemInfo &item,
const int *const cards,
const ItemOptionsList *const options)
{
- if (!mIcon || (item.getName() == mLastName && color == mLastColor
- && id == mLastId))
+ if (mIcon == nullptr ||
+ (item.getName() == mLastName && color == mLastColor && id == mLastId))
{
return;
}
@@ -193,7 +193,7 @@ void ItemPopup::setItem(const ItemInfo &item,
int space = 0;
Image *const oldImage = mIcon->getImage();
- if (oldImage)
+ if (oldImage != nullptr)
oldImage->decRef();
if (showImage)
@@ -204,7 +204,7 @@ void ItemPopup::setItem(const ItemInfo &item,
item.getDyeIconColorsString(color)));
mIcon->setImage(image);
- if (image)
+ if (image != nullptr)
{
mIcon->setPosition(0, 0);
space = mIcon->getWidth();
@@ -297,7 +297,7 @@ void ItemPopup::setItem(const ItemInfo &item,
std::string ItemPopup::getCardsString(const int *const cards)
{
- if (!cards)
+ if (cards == nullptr)
return std::string();
std::string label;
@@ -331,7 +331,7 @@ std::string ItemPopup::getCardsString(const int *const cards)
for (int f = 0; f < maxCards; f ++)
{
const int id = cards[f];
- if (id)
+ if (id != 0)
{
if (!label.empty())
label.append(" / ");
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 69fd7d879..b5a337b1c 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -145,7 +145,7 @@ void PopupMenu::postInit()
void PopupMenu::showPopup(const int x, const int y, const Being *const being)
{
- if (!being || !localPlayer || !actorManager)
+ if ((being == nullptr) || (localPlayer == nullptr) || (actorManager == nullptr))
return;
mBeingId = being->getId();
@@ -193,9 +193,9 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
const Guild *const guild1 = being->getGuild();
const Guild *const guild2 = localPlayer->getGuild();
- if (guild2)
+ if (guild2 != nullptr)
{
- if (guild1)
+ if (guild1 != nullptr)
{
if (guild1->getId() == guild2->getId())
{
@@ -213,7 +213,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
}
}
}
- else if (guild2->getMember(mName))
+ else if (guild2->getMember(mName) != nullptr)
{
mBrowserBox->addRow("/kickguild 'NAME'",
// TRANSLATORS: popup menu item
@@ -231,8 +231,8 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
else
{
#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild()
- || (guildManager && guildManager->havePower()))
+ if (guild2->getServerGuild() ||
+ (guildManager != nullptr && guildManager->havePower()))
#endif // TMWA_SUPPORT
{
mBrowserBox->addRow("/guild 'NAME'",
@@ -345,7 +345,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
case ActorType::Homunculus:
{
const HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (info)
+ if (info != nullptr)
{
mBrowserBox->addRow("homunculus to master",
// TRANSLATORS: popup menu item
@@ -387,7 +387,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
mBrowserBox->addRow("##3---");
const BeingInfo *const info = being->getInfo();
std::string msg;
- if (info)
+ if (info != nullptr)
msg = info->getString(0);
if (!msg.empty())
{
@@ -411,7 +411,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
const BeingId id = being->getCreatorId();
std::string creatorName;
Being *const creator = actorManager->findBeing(id);
- if (creator)
+ if (creator != nullptr)
creatorName = creator->getName();
else
creatorName = actorManager->getSeenPlayerById(id);
@@ -448,12 +448,12 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
bool PopupMenu::addBeingMenu()
{
Being *being = actorManager->findBeing(mBeingId);
- if (!being)
+ if (being == nullptr)
return false;
BeingInfo *const info = NPCDB::get(fromInt(
being->getSubType(), BeingTypeId));
- if (!info)
+ if (info == nullptr)
return false;
const std::vector<BeingMenuItem> &menu = info->getMenu();
@@ -467,7 +467,7 @@ bool PopupMenu::addBeingMenu()
void PopupMenu::setMousePos()
{
- if (viewport)
+ if (viewport != nullptr)
{
mX = viewport->mMouseX;
mY = viewport->mMouseY;
@@ -482,7 +482,7 @@ void PopupMenu::setMousePos2()
{
if (mX == 0 && mY == 0)
{
- if (viewport)
+ if (viewport != nullptr)
{
mX = viewport->mMouseX;
mY = viewport->mMouseY;
@@ -506,7 +506,7 @@ void PopupMenu::showPopup(const int x, const int y,
{
const Being *const being = dynamic_cast<const Being*>(*it);
const ActorSprite *const actor = *it;
- if (being && !being->getName().empty())
+ if ((being != nullptr) && !being->getName().empty())
{
mBrowserBox->addRow(strprintf("@@player_%u|%s >@@",
CAST_U32(being->getId()), (being->getName()
@@ -530,7 +530,7 @@ void PopupMenu::showPopup(const int x, const int y,
void PopupMenu::showPlayerPopup(const std::string &nick)
{
- if (nick.empty() || !localPlayer)
+ if (nick.empty() || (localPlayer == nullptr))
return;
setMousePos();
@@ -563,10 +563,10 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
if (localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
const PartyMember *const member = party->getMember(mName);
- if (member)
+ if (member != nullptr)
{
// TRANSLATORS: popup menu item
// TRANSLATORS: kick player from party
@@ -575,7 +575,7 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
const PartyMember *const o = party->getMember(
localPlayer->getName());
showAdoptCommands();
- if (o && member->getMap() == o->getMap())
+ if ((o != nullptr) && member->getMap() == o->getMap())
{
// TRANSLATORS: popup menu item
// TRANSLATORS: move to player position
@@ -586,12 +586,12 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
}
const Guild *const guild2 = localPlayer->getGuild();
- if (guild2)
+ if (guild2 != nullptr)
{
- if (guild2->getMember(mName))
+ if (guild2->getMember(mName) != nullptr)
{
#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() || (guildManager
+ if (guild2->getServerGuild() || (guildManager != nullptr
&& guildManager->havePower()))
#endif // TMWA_SUPPORT
{
@@ -611,7 +611,7 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
else
{
#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() || (guildManager
+ if (guild2->getServerGuild() || (guildManager != nullptr
&& guildManager->havePower()))
#endif // TMWA_SUPPORT
{
@@ -637,7 +637,7 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
void PopupMenu::showPopup(const int x, const int y,
const FloorItem *const floorItem)
{
- if (!floorItem)
+ if (floorItem == nullptr)
return;
mX = x;
@@ -690,7 +690,7 @@ void PopupMenu::showPopup(const int x, const int y,
void PopupMenu::showPopup(const int x, const int y, MapItem *const mapItem)
{
- if (!mapItem)
+ if (mapItem == nullptr)
return;
mMapItem = mapItem;
@@ -708,7 +708,7 @@ void PopupMenu::showPopup(const int x, const int y, MapItem *const mapItem)
// TRANSLATORS: remove map item
mBrowserBox->addRow("remove map", _("Remove"));
- if (localPlayer && localPlayer->isGM())
+ if ((localPlayer != nullptr) && localPlayer->isGM())
{
mBrowserBox->addRow("##3---");
// TRANSLATORS: popup menu item
@@ -738,7 +738,7 @@ void PopupMenu::showMapPopup(const int x, const int y,
// TRANSLATORS: popup menu header
mBrowserBox->addRow(_("Map Item"));
- if (localPlayer && localPlayer->isGM())
+ if ((localPlayer != nullptr) && localPlayer->isGM())
{
// TRANSLATORS: popup menu item
// TRANSLATORS: warp to map item
@@ -806,7 +806,7 @@ void PopupMenu::showOutfitsWindowPopup(const int x, const int y)
void PopupMenu::showSpellPopup(const int x, const int y,
TextCommand *const cmd)
{
- if (!cmd)
+ if (cmd == nullptr)
return;
mBrowserBox->clearRows();
@@ -830,7 +830,7 @@ void PopupMenu::showSpellPopup(const int x, const int y,
void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
{
- if (!tab || !actorManager || !localPlayer)
+ if ((tab == nullptr) || (actorManager == nullptr) || (localPlayer == nullptr))
return;
mTab = tab;
@@ -911,7 +911,7 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
name, ActorType::Player);
addGmCommands();
- if (being)
+ if (being != nullptr)
{
mBeingId = being->getId();
mName = being->getName();
@@ -943,15 +943,16 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
addParty(wTab->getNick());
const Guild *const guild1 = being->getGuild();
const Guild *const guild2 = localPlayer->getGuild();
- if (guild2)
+ if (guild2 != nullptr)
{
- if (guild1)
+ if (guild1 != nullptr)
{
if (guild1->getId() == guild2->getId())
{
#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() || (guildManager
- && guildManager->havePower()))
+ if (guild2->getServerGuild() ||
+ (guildManager != nullptr &&
+ guildManager->havePower()))
#endif // TMWA_SUPPORT
{
mBrowserBox->addRow("/kickguild 'NAME'",
@@ -971,7 +972,7 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
else
{
#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() || (guildManager
+ if (guild2->getServerGuild() || (guildManager != nullptr
&& guildManager->havePower()))
#endif // TMWA_SUPPORT
{
@@ -998,10 +999,10 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
if (localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
const PartyMember *const m = party->getMember(mName);
- if (m)
+ if (m != nullptr)
{
// TRANSLATORS: popup menu item
// TRANSLATORS: move to player location
@@ -1031,13 +1032,13 @@ void PopupMenu::showChangePos(const int x, const int y)
// TRANSLATORS: popup menu header
mBrowserBox->addRow(_("Change guild position"));
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
mX = x;
mY = y;
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
const PositionsMap &map = guild->getPositions();
FOR_EACH (PositionsMap::const_iterator, itr, map)
@@ -1072,7 +1073,7 @@ void PopupMenu::showChangePos(const int x, const int y)
void PopupMenu::showWindowPopup(Window *const window)
{
- if (!window)
+ if (window == nullptr)
return;
setMousePos();
@@ -1092,7 +1093,7 @@ void PopupMenu::showWindowPopup(Window *const window)
void PopupMenu::addWindowMenu(const Window *const window)
{
- if (!window)
+ if (window == nullptr)
return;
if (window->getAlowClose())
@@ -1158,20 +1159,20 @@ void PopupMenu::handleLink(const std::string &link,
MouseEvent *event A_UNUSED)
{
Being *being = nullptr;
- if (actorManager)
+ if (actorManager != nullptr)
being = actorManager->findBeing(mBeingId);
mAllowCleanMenu = true;
- if (link == "remove map" && mMapItem)
+ if (link == "remove map" && (mMapItem != nullptr))
{
- if (viewport)
+ if (viewport != nullptr)
{
const Map *const map = viewport->getMap();
- if (map)
+ if (map != nullptr)
{
SpecialLayer *const specialLayer = map->getSpecialLayer();
- if (specialLayer)
+ if (specialLayer != nullptr)
{
const bool isHome = (mMapItem->getType()
== CAST_S32(MapItemType::HOME));
@@ -1180,9 +1181,9 @@ void PopupMenu::handleLink(const std::string &link,
specialLayer->setTile(x, y,
CAST_S32(MapItemType::EMPTY));
specialLayer->updateCache();
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->removePortal(x, y);
- if (isHome && localPlayer)
+ if (isHome && (localPlayer != nullptr))
{
localPlayer->removeHome();
localPlayer->saveHomes();
@@ -1191,7 +1192,7 @@ void PopupMenu::handleLink(const std::string &link,
}
}
}
- else if (link == "rename map" && mMapItem)
+ else if (link == "rename map" && (mMapItem != nullptr))
{
mRenameListener.setMapItem(mMapItem);
CREATEWIDGETV(mDialog, TextDialog,
@@ -1206,7 +1207,7 @@ void PopupMenu::handleLink(const std::string &link,
mDialog->setActionEventId("ok");
mDialog->addActionListener(&mRenameListener);
}
- else if (link == "edit spell" && mSpell)
+ else if (link == "edit spell" && (mSpell != nullptr))
{
CREATEWIDGET(TextCommandEditor, mSpell);
}
@@ -1223,7 +1224,7 @@ void PopupMenu::handleLink(const std::string &link,
mPlayerListener.setNick(mName);
mPlayerListener.setType(mType);
- if (being)
+ if (being != nullptr)
{
being->updateComment();
dialog->setText(being->getComment());
@@ -1243,12 +1244,12 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (link == "clipboard copy")
{
- if (mTextField)
+ if (mTextField != nullptr)
mTextField->handleCopy();
}
else if (link == "clipboard paste")
{
- if (mTextField)
+ if (mTextField != nullptr)
mTextField->handlePaste();
}
else if (link == "gm" && !mName.empty())
@@ -1266,25 +1267,25 @@ void PopupMenu::handleLink(const std::string &link,
showPlayerMenu();
return;
}
- else if (link == "window close" && mCallerWindow)
+ else if (link == "window close" && (mCallerWindow != nullptr))
{
if (Widget::widgetExists(mCallerWindow))
mCallerWindow->close();
}
- else if (link == "window unlock" && mCallerWindow)
+ else if (link == "window unlock" && (mCallerWindow != nullptr))
{
if (Widget::widgetExists(mCallerWindow))
mCallerWindow->setSticky(false);
}
- else if (link == "window lock" && mCallerWindow)
+ else if (link == "window lock" && (mCallerWindow != nullptr))
{
if (Widget::widgetExists(mCallerWindow))
mCallerWindow->setSticky(true);
}
- else if (link == "join chat" && being)
+ else if (link == "join chat" && (being != nullptr))
{
const ChatObject *const chat = being->getChat();
- if (chat)
+ if (chat != nullptr)
chatHandler->joinChat(chat, "");
}
else if (link == "fire mercenary")
@@ -1328,42 +1329,42 @@ void PopupMenu::handleLink(const std::string &link,
{
petHandler->unequip();
}
- else if (!link.compare(0, 10, "guild-pos-"))
+ else if (link.compare(0, 10, "guild-pos-") == 0)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
const int num = atoi(link.substr(10).c_str());
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
guildHandler->changeMemberPostion(
guild->getMember(mName), num);
}
}
}
- else if (!link.compare(0, 7, "player_"))
+ else if (link.compare(0, 7, "player_") == 0)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
mBeingId = fromInt(atoi(link.substr(7).c_str()), BeingId);
being = actorManager->findBeing(mBeingId);
- if (being)
+ if (being != nullptr)
{
showPopup(getX(), getY(), being);
return;
}
}
}
- else if (!link.compare(0, 10, "flooritem_"))
+ else if (link.compare(0, 10, "flooritem_") == 0)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
const BeingId id = fromInt(atoi(
link.substr(10).c_str()), BeingId);
if (id != BeingId_zero)
{
const FloorItem *const item = actorManager->findItem(id);
- if (item)
+ if (item != nullptr)
{
mFloorItemId = item->getId();
mItemId = item->getItemId();
@@ -1375,43 +1376,43 @@ void PopupMenu::handleLink(const std::string &link,
}
}
}
- else if (!link.compare(0, 12, "hide button_"))
+ else if (link.compare(0, 12, "hide button_") == 0)
{
- if (windowMenu)
+ if (windowMenu != nullptr)
windowMenu->showButton(link.substr(12), Visible_false);
}
- else if (!link.compare(0, 12, "show button_"))
+ else if (link.compare(0, 12, "show button_") == 0)
{
- if (windowMenu)
+ if (windowMenu != nullptr)
windowMenu->showButton(link.substr(12), Visible_true);
}
- else if (!link.compare(0, 9, "hide bar_"))
+ else if (link.compare(0, 9, "hide bar_") == 0)
{
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->showBar(link.substr(9), Visible_false);
}
- else if (!link.compare(0, 9, "show bar_"))
+ else if (link.compare(0, 9, "show bar_") == 0)
{
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->showBar(link.substr(9), Visible_true);
}
- else if (!link.compare(0, 12, "show window_"))
+ else if (link.compare(0, 12, "show window_") == 0)
{
const int id = atoi(link.substr(12).c_str());
if (id >= 0)
inputManager.executeAction(static_cast<InputActionT>(id));
}
- else if (!link.compare(0, 6, "mute_+"))
+ else if (link.compare(0, 6, "mute_+") == 0)
{
- if (being)
+ if (being != nullptr)
{
const int time = atoi(link.substr(6).c_str());
adminHandler->mute(being, 1, time);
}
}
- else if (!link.compare(0, 6, "mute_-"))
+ else if (link.compare(0, 6, "mute_-") == 0)
{
- if (being)
+ if (being != nullptr)
{
const int time = atoi(link.substr(6).c_str());
adminHandler->mute(being, 0, time);
@@ -1440,7 +1441,7 @@ void PopupMenu::handleLink(const std::string &link,
replaceAll(cmd, "'INVINDEX'", toString(mItemIndex));
else
replaceAll(cmd, "'INVINDEX'", "0");
- if (mMapItem)
+ if (mMapItem != nullptr)
{
replaceAll(cmd, "'MAPX'", toString(mMapItem->getX()));
replaceAll(cmd, "'MAPY'", toString(mMapItem->getY()));
@@ -1455,7 +1456,7 @@ void PopupMenu::handleLink(const std::string &link,
for (int f = 0; f < maxCards; f ++)
{
const int id = mItemCards[f];
- if (id)
+ if (id != 0)
{
cards.append(",");
cards.append(toString(id));
@@ -1463,15 +1464,15 @@ void PopupMenu::handleLink(const std::string &link,
}
replaceAll(cmd, "'CARDS'", cards);
replaceAll(cmd, "'ECARDS'", escapeString(cards));
- if (actorManager)
+ if (actorManager != nullptr)
{
- if (!being)
+ if (being == nullptr)
{
being = actorManager->findBeingByName(mName,
ActorType::Player);
}
}
- if (being)
+ if (being != nullptr)
replaceAll(cmd, "'PARTY'", being->getPartyName());
else
replaceAll(cmd, "'PARTY'", "");
@@ -1520,7 +1521,7 @@ void PopupMenu::showPopup(Window *const parent,
const Item *const item,
const InventoryTypeT type)
{
- if (!item)
+ if (item == nullptr)
return;
mItemId = item->getId();
@@ -1541,7 +1542,9 @@ void PopupMenu::showPopup(Window *const parent,
switch (type)
{
case InventoryType::Inventory:
- if (tradeWindow && tradeWindow->isWindowVisible() && !isProtected)
+ if (tradeWindow != nullptr &&
+ tradeWindow->isWindowVisible() &&
+ !isProtected)
{
// TRANSLATORS: popup menu item
// TRANSLATORS: add item to trade
@@ -1599,10 +1602,10 @@ void PopupMenu::showPopup(Window *const parent,
}
mBrowserBox->addRow("##3---");
}
- if (npcHandler)
+ if (npcHandler != nullptr)
{
NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
- if (dialog &&
+ if ((dialog != nullptr) &&
dialog->getInputState() == NpcInputState::ITEM_CRAFT)
{
mBrowserBox->addRow("craftmenu",
@@ -1679,11 +1682,11 @@ void PopupMenu::showItemPopup(const int x, const int y,
const ItemColor color)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
Item *const item = inv->findItem(itemId, color);
- if (item)
+ if (item != nullptr)
{
showItemPopup(x, y, item);
}
@@ -1720,7 +1723,7 @@ void PopupMenu::showItemPopup(const int x, const int y,
{
mX = x;
mY = y;
- if (item)
+ if (item != nullptr)
{
mItemId = item->getId();
mItemColor = item->getColor();
@@ -1740,7 +1743,7 @@ void PopupMenu::showItemPopup(const int x, const int y,
mExtName.clear();
mBrowserBox->clearRows();
- if (item)
+ if (item != nullptr)
{
const bool isProtected = PlayerInfo::isItemProtected(mItemId);
addUseDrop(item, isProtected);
@@ -1782,7 +1785,7 @@ void PopupMenu::showDropPopup(const int x,
mExtName.clear();
mBrowserBox->clearRows();
- if (item)
+ if (item != nullptr)
{
mItemId = item->getId();
mItemColor = item->getColor();
@@ -1823,7 +1826,7 @@ void PopupMenu::showDropPopup(const int x,
void PopupMenu::showPopup(const int x, const int y, Button *const button)
{
- if (!button || !windowMenu)
+ if ((button == nullptr) || (windowMenu == nullptr))
return;
mButton = button;
@@ -1836,7 +1839,7 @@ void PopupMenu::showPopup(const int x, const int y, Button *const button)
it_end = names.end(); it != it_end; ++ it)
{
const Button *const btn = *it;
- if (!btn || btn->getActionEventId() == "SET")
+ if ((btn == nullptr) || btn->getActionEventId() == "SET")
continue;
if (btn->mVisible == Visible_true)
@@ -1864,7 +1867,7 @@ void PopupMenu::showPopup(const int x, const int y, Button *const button)
void PopupMenu::showPopup(const int x, const int y, const ProgressBar *const b)
{
- if (!b || !miniStatusWindow)
+ if ((b == nullptr) || (miniStatusWindow == nullptr))
return;
mName = b->text();
@@ -1882,7 +1885,7 @@ void PopupMenu::showPopup(const int x, const int y, const ProgressBar *const b)
it_end = bars.end(); it != it_end; ++it)
{
ProgressBar *const bar = *it;
- if (!bar)
+ if (bar == nullptr)
continue;
if (bar->mVisible == Visible_true)
@@ -1898,7 +1901,7 @@ void PopupMenu::showPopup(const int x, const int y, const ProgressBar *const b)
it_end = bars.end(); it != it_end; ++it)
{
ProgressBar *const bar = *it;
- if (!bar || bar == onlyBar)
+ if ((bar == nullptr) || bar == onlyBar)
continue;
if (bar->mVisible == Visible_true)
@@ -1937,7 +1940,7 @@ void PopupMenu::showAttackMonsterPopup(const int x, const int y,
const std::string &name,
const int type)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return;
mName = name;
@@ -2019,7 +2022,7 @@ void PopupMenu::showAttackMonsterPopup(const int x, const int y,
void PopupMenu::showPickupItemPopup(const int x, const int y,
const std::string &name)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return;
mName = name;
@@ -2056,7 +2059,7 @@ void PopupMenu::showUndressPopup(const int x, const int y,
const Being *const being,
const Item *const item)
{
- if (!being || !item)
+ if ((being == nullptr) || (item == nullptr))
return;
mBeingId = being->getId();
@@ -2139,7 +2142,7 @@ void PopupMenu::showWindowsPopup()
FOR_EACH (std::vector<ButtonText*>::const_iterator, it, names)
{
const ButtonText *const btn = *it;
- if (!btn)
+ if (btn == nullptr)
continue;
mBrowserBox->addRow(strprintf("show window_%d",
@@ -2174,7 +2177,7 @@ void PopupMenu::showNpcDialogPopup(const BeingId npcId,
void PopupMenu::showSkillPopup(const SkillInfo *const info)
{
- if (!info)
+ if (info == nullptr)
return;
setMousePos();
@@ -2212,7 +2215,7 @@ void PopupMenu::showSkillPopup(const SkillInfo *const info)
void PopupMenu::showSkillOffsetPopup(const SkillInfo *const info,
const bool isOffsetX)
{
- if (!info)
+ if (info == nullptr)
return;
setMousePos2();
@@ -2258,7 +2261,7 @@ void PopupMenu::showSkillOffsetPopup(const SkillInfo *const info,
void PopupMenu::showSkillLevelPopup(const SkillInfo *const info)
{
- if (!info)
+ if (info == nullptr)
return;
setMousePos2();
@@ -2294,7 +2297,7 @@ void PopupMenu::showSkillLevelPopup(const SkillInfo *const info)
void PopupMenu::showSkillTypePopup(const SkillInfo *const info)
{
- if (!info)
+ if (info == nullptr)
return;
setMousePos2();
@@ -2490,7 +2493,7 @@ void PopupMenu::addFollow()
void PopupMenu::addBuySell(const Being *const being)
{
- if (player_relations.getDefault() & PlayerRelation::TRADE)
+ if ((player_relations.getDefault() & PlayerRelation::TRADE) != 0u)
{
mBrowserBox->addRow("##3---");
const bool haveVending =
@@ -2524,7 +2527,7 @@ void PopupMenu::addBuySell(const Being *const being)
void PopupMenu::addBuySellDefault()
{
- if (player_relations.getDefault() & PlayerRelation::TRADE)
+ if ((player_relations.getDefault() & PlayerRelation::TRADE) != 0u)
{
mBrowserBox->addRow("##3---");
// TRANSLATORS: popup menu item
@@ -2540,7 +2543,7 @@ void PopupMenu::addPartyName(const std::string &partyName)
{
if (localPlayer->isInParty())
{
- if (localPlayer->getParty())
+ if (localPlayer->getParty() != nullptr)
{
if (localPlayer->getParty()->getName() != partyName)
{
@@ -2565,7 +2568,7 @@ void PopupMenu::addParty(const std::string &nick)
if (localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
if (!party->isMember(nick))
{
@@ -2587,10 +2590,10 @@ void PopupMenu::addParty(const std::string &nick)
void PopupMenu::addChat(const Being *const being)
{
- if (!being)
+ if (being == nullptr)
return;
const ChatObject *const chat = being->getChat();
- if (chat)
+ if (chat != nullptr)
{
mBrowserBox->addRow("join chat",
// TRANSLATORS: popup menu item
@@ -2638,7 +2641,7 @@ void PopupMenu::addPickupFilter(const std::string &name)
void PopupMenu::showPopup(const int x, const int y,
ListModel *const model)
{
- if (!model)
+ if (model == nullptr)
return;
mBrowserBox->clearRows();
@@ -2655,7 +2658,7 @@ void PopupMenu::showPopup(const int x, const int y,
void PopupMenu::clear()
{
- if (mDialog)
+ if (mDialog != nullptr)
{
mDialog->close();
mDialog = nullptr;
@@ -2809,7 +2812,7 @@ void PopupMenu::showPlayerGMCommands(const std::string &name)
{
Being *const being = actorManager->findBeingByName(name,
ActorType::Player);
- if (being)
+ if (being != nullptr)
{
if (!being->getPartyName().empty())
{
@@ -2826,10 +2829,10 @@ void PopupMenu::showPlayerGMCommands(const std::string &name)
_("Recall guild"));
}
}
- if (localPlayer && localPlayer->isInParty())
+ if ((localPlayer != nullptr) && localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party && party->isMember(name))
+ if ((party != nullptr) && party->isMember(name))
{
mBrowserBox->addRow("/gmpartyleader 'NAME'",
// TRANSLATORS: popup menu item
@@ -3208,7 +3211,7 @@ void PopupMenu::addSocialMenu()
mBrowserBox->clearRows();
setMousePos();
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
// TRANSLATORS: popup menu item
// TRANSLATORS: leave party
@@ -3224,7 +3227,7 @@ void PopupMenu::addSocialMenu()
if (Net::getNetworkType() != ServerType::TMWATHENA)
{
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
// TRANSLATORS: popup menu item
// TRANSLATORS: leave guild
diff --git a/src/gui/popups/skillpopup.cpp b/src/gui/popups/skillpopup.cpp
index ab66dba81..91ea03feb 100644
--- a/src/gui/popups/skillpopup.cpp
+++ b/src/gui/popups/skillpopup.cpp
@@ -101,8 +101,8 @@ void SkillPopup::show(const SkillInfo *const skill,
const int offsetX,
const int offsetY)
{
- if (!skill ||
- !skill->data ||
+ if ((skill == nullptr) ||
+ (skill->data == nullptr) ||
(skill->id == mLastId &&
level == mLastLevel &&
castType == mCastType &&
diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp
index a76f8694c..50d54e692 100644
--- a/src/gui/popups/speechbubble.cpp
+++ b/src/gui/popups/speechbubble.cpp
@@ -37,7 +37,7 @@
SpeechBubble::SpeechBubble() :
Popup("Speech", "speechbubble.xml"),
mText(),
- mSpacing(mSkin ? mSkin->getOption("spacing") : 2),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing") : 2),
mCaption(new Label(this)),
mSpeechBox(new BrowserBox(this, BrowserBoxMode::AUTO_SIZE, Opaque_true,
"speechbrowserbox.xml"))
diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp
index fcfe837d5..16169d81e 100644
--- a/src/gui/popups/spellpopup.cpp
+++ b/src/gui/popups/spellpopup.cpp
@@ -60,7 +60,7 @@ SpellPopup::~SpellPopup()
void SpellPopup::setItem(const TextCommand *const spell)
{
- if (spell)
+ if (spell != nullptr)
{
mItemName->setCaption(spell->getName());
mItemComment->setCaption(spell->getComment());
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index ead88bf6a..a6a3b831c 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -270,7 +270,8 @@ void SDLInput::pushInput(const SDL_Event &event)
* This occurs when the mouse leaves the window and the Gui-chan
* application loses its mousefocus.
*/
- if ((event.active.state & SDL_APPMOUSEFOCUS) && !event.active.gain)
+ if ((event.active.state & SDL_APPMOUSEFOCUS) != 0 &&
+ event.active.gain == 0u)
{
mMouseInWindow = false;
@@ -284,8 +285,11 @@ void SDLInput::pushInput(const SDL_Event &event)
}
}
- if ((event.active.state & SDL_APPMOUSEFOCUS) && event.active.gain)
+ if ((event.active.state & SDL_APPMOUSEFOCUS) != 0 &&
+ event.active.gain != 0u)
+ {
mMouseInWindow = true;
+ }
break;
#endif // USE_SDL2
@@ -344,7 +348,7 @@ void SDLInput::simulateMouseClick(const int x, const int y,
void SDLInput::simulateMouseMove()
{
- if (!gui)
+ if (gui == nullptr)
return;
int x, y;
diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h
index 142a942aa..573dc3fd2 100644
--- a/src/gui/sdlinput.h
+++ b/src/gui/sdlinput.h
@@ -326,7 +326,7 @@ class SDLInput final
}
PRAGMA45(GCC diagnostic pop)
- if (!(CAST_U32(keysym.mod) & KMOD_NUM))
+ if ((CAST_U32(keysym.mod) & KMOD_NUM) == 0u)
{
PRAGMA45(GCC diagnostic push)
PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
diff --git a/src/gui/shortcut/dropshortcut.cpp b/src/gui/shortcut/dropshortcut.cpp
index 1afea70ec..f9876ebee 100644
--- a/src/gui/shortcut/dropshortcut.cpp
+++ b/src/gui/shortcut/dropshortcut.cpp
@@ -53,7 +53,7 @@ DropShortcut::~DropShortcut()
void DropShortcut::dropFirst() const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (!PacketLimiter::limitPackets(PacketType::PACKET_DROP))
@@ -68,7 +68,7 @@ void DropShortcut::dropFirst() const
{
const Item *const item = PlayerInfo::getInventory()
->findItem(itemId, itemColor);
- if (item && item->getQuantity())
+ if ((item != nullptr) && (item->getQuantity() != 0))
{
const int cnt = settings.quickDropCounter;
if (localPlayer->isServerBuggy())
@@ -86,7 +86,7 @@ void DropShortcut::dropFirst() const
void DropShortcut::dropItems(const int cnt)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (localPlayer->isServerBuggy())
@@ -114,7 +114,7 @@ void DropShortcut::dropItems(const int cnt)
bool DropShortcut::dropItem(const int cnt)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return false;
int itemId = 0;
@@ -133,7 +133,7 @@ bool DropShortcut::dropItem(const int cnt)
if (itemId > 0)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item &&
+ if ((item != nullptr) &&
item->getQuantity() > 0)
{
PlayerInfo::dropItem(item, cnt, Sfx_true);
@@ -158,7 +158,7 @@ bool DropShortcut::dropItem(const int cnt)
if (itemId > 0)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item && item->getQuantity() > 0)
+ if ((item != nullptr) && item->getQuantity() > 0)
{
PlayerInfo::dropItem(item, cnt, Sfx_true);
return true;
diff --git a/src/gui/shortcut/emoteshortcut.cpp b/src/gui/shortcut/emoteshortcut.cpp
index ac9581fa3..0fcf4abaf 100644
--- a/src/gui/shortcut/emoteshortcut.cpp
+++ b/src/gui/shortcut/emoteshortcut.cpp
@@ -56,7 +56,7 @@ void EmoteShortcut::load()
i++)
{
const EmoteSprite *const sprite = EmoteDB::getSprite(i, true);
- if (sprite)
+ if (sprite != nullptr)
{
mEmotes[j] = CAST_U8(i + 1);
j ++;
@@ -68,7 +68,7 @@ void EmoteShortcut::save() const
{
for (int i = 0; i < SHORTCUT_EMOTES; i++)
{
- const unsigned char emoteId = mEmotes[i] ? mEmotes[i]
+ const unsigned char emoteId = mEmotes[i] != 0u ? mEmotes[i]
: CAST_U8(0);
serverConfig.setValue("emoteshortcut" + toString(i),
CAST_U32(emoteId));
@@ -77,7 +77,7 @@ void EmoteShortcut::save() const
void EmoteShortcut::useEmotePlayer(const int index) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (index > 0 &&
@@ -90,7 +90,7 @@ void EmoteShortcut::useEmotePlayer(const int index) const
void EmoteShortcut::useEmote(const int index) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (index > 0 &&
diff --git a/src/gui/shortcut/emoteshortcut.h b/src/gui/shortcut/emoteshortcut.h
index b9bbb920e..14d68fbc6 100644
--- a/src/gui/shortcut/emoteshortcut.h
+++ b/src/gui/shortcut/emoteshortcut.h
@@ -98,7 +98,7 @@ class EmoteShortcut final
* A flag to check if the Emote is selected.
*/
bool isEmoteSelected() const noexcept2 A_WARN_UNUSED
- { return mEmoteSelected; }
+ { return mEmoteSelected != 0u; }
/**
* Remove a Emote from the shortcut.
diff --git a/src/gui/shortcut/itemshortcut.cpp b/src/gui/shortcut/itemshortcut.cpp
index 9f1c0705c..5828ae4e7 100644
--- a/src/gui/shortcut/itemshortcut.cpp
+++ b/src/gui/shortcut/itemshortcut.cpp
@@ -64,7 +64,7 @@ void ItemShortcut::load()
std::string data;
const Configuration *cfg = &serverConfig;
- if (mNumber)
+ if (mNumber != 0)
{
name = std::string("shortcut").append(toString(mNumber)).append("_");
color = std::string("shortcutColor").append(
@@ -96,7 +96,7 @@ void ItemShortcut::save() const
std::string name;
std::string color;
std::string data;
- if (mNumber)
+ if (mNumber != 0)
{
name = std::string("shortcut").append(toString(mNumber)).append("_");
color = std::string("shortcutColor").append(
@@ -113,7 +113,7 @@ void ItemShortcut::save() const
for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
{
- const int itemId = mItems[i] ? mItems[i] : -1;
+ const int itemId = mItems[i] != 0 ? mItems[i] : -1;
const int itemColor = toInt(mItemColors[i], int);
const std::string itemData = mItemData[i];
if (itemId != -1)
@@ -134,7 +134,7 @@ void ItemShortcut::save() const
void ItemShortcut::useItem(const int index) const
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const int itemId = mItems[index];
@@ -144,14 +144,14 @@ void ItemShortcut::useItem(const int index) const
if (itemId < SPELL_MIN_ID)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item && item->getQuantity())
+ if ((item != nullptr) && (item->getQuantity() != 0))
PlayerInfo::useEquipItem(item, Sfx_true);
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{
spellManager->useItem(itemId);
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
skillDialog->useItem(itemId,
fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
@@ -164,14 +164,14 @@ void ItemShortcut::useItem(const int index) const
void ItemShortcut::equipItem(const int index) const
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const int itemId = mItems[index];
- if (itemId)
+ if (itemId != 0)
{
const Item *const item = inv->findItem(itemId, mItemColors[index]);
- if (item && item->getQuantity())
+ if ((item != nullptr) && (item->getQuantity() != 0))
{
if (item->isEquipment() == Equipm_true)
{
@@ -184,14 +184,14 @@ void ItemShortcut::equipItem(const int index) const
void ItemShortcut::unequipItem(const int index) const
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const int itemId = mItems[index];
- if (itemId)
+ if (itemId != 0)
{
const Item *const item = inv->findItem(itemId, mItemColors[index]);
- if (item && item->getQuantity())
+ if ((item != nullptr) && (item->getQuantity() != 0))
{
if (item->isEquipment() == Equipm_true)
{
@@ -204,7 +204,7 @@ void ItemShortcut::unequipItem(const int index) const
void ItemShortcut::setItemSelected(const Item *const item)
{
- if (item)
+ if (item != nullptr)
{
mItemSelected = item->getId();
mItemColorSelected = item->getColor();
diff --git a/src/gui/shortcut/shortcutbase.cpp b/src/gui/shortcut/shortcutbase.cpp
index 0b3121ee0..8b7bf80c3 100644
--- a/src/gui/shortcut/shortcutbase.cpp
+++ b/src/gui/shortcut/shortcutbase.cpp
@@ -74,7 +74,7 @@ void ShortcutBase::save() const
{
for (int i = 0; i < mMaxSize; i++)
{
- const int itemId = mItems[i] ? mItems[i] : -1;
+ const int itemId = mItems[i] != 0 ? mItems[i] : -1;
const int itemColor = (mItemColors[i] != ItemColor_zero)
? toInt(mItemColors[i], int) : 1;
if (itemId != -1)
@@ -92,7 +92,7 @@ void ShortcutBase::save() const
void ShortcutBase::setItemSelected(const Item *const item)
{
- if (item)
+ if (item != nullptr)
{
mItemSelected = item->getId();
mItemColorSelected = item->getColor();
diff --git a/src/gui/shortcut/spellshortcut.cpp b/src/gui/shortcut/spellshortcut.cpp
index 9cec4cd9a..ef6815a2c 100644
--- a/src/gui/shortcut/spellshortcut.cpp
+++ b/src/gui/shortcut/spellshortcut.cpp
@@ -44,7 +44,7 @@ void SpellShortcut::load()
for (unsigned f = 0; f < SPELLS_SIZE; f ++)
mItems[f] = -1;
- if (!spellManager)
+ if (spellManager == nullptr)
return;
const std::vector<TextCommand*> &spells = spellManager->getAll();
diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp
index d3c2a048e..45317fa0d 100644
--- a/src/gui/skin.cpp
+++ b/src/gui/skin.cpp
@@ -45,18 +45,18 @@ Skin::Skin(ImageRect *const restrict skin,
mFilePath(filePath),
mName(name),
mBorder(skin),
- mCloseImage(images ? images->grid[0] : nullptr),
- mCloseImageHighlighted(images ? images->grid[1] : nullptr),
- mStickyImageUp(images ? images->grid[2] : nullptr),
- mStickyImageDown(images ? images->grid[3] : nullptr),
+ mCloseImage(images != nullptr ? images->grid[0] : nullptr),
+ mCloseImageHighlighted(images != nullptr ? images->grid[1] : nullptr),
+ mStickyImageUp(images != nullptr ? images->grid[2] : nullptr),
+ mStickyImageDown(images != nullptr ? images->grid[3] : nullptr),
mPadding(padding),
mTitlePadding(titlePadding),
mOptions(options)
{
- if (!mCloseImageHighlighted)
+ if (mCloseImageHighlighted == nullptr)
{
mCloseImageHighlighted = mCloseImage;
- if (mCloseImageHighlighted)
+ if (mCloseImageHighlighted != nullptr)
mCloseImageHighlighted->incRef();
}
}
@@ -65,32 +65,32 @@ Skin::~Skin()
{
for (int i = 0; i < 9; i++)
{
- if (mBorder && mBorder->grid[i])
+ if ((mBorder != nullptr) && (mBorder->grid[i] != nullptr))
{
mBorder->grid[i]->decRef();
mBorder->grid[i] = nullptr;
}
}
- if (mCloseImage)
+ if (mCloseImage != nullptr)
{
mCloseImage->decRef();
mCloseImage = nullptr;
}
- if (mCloseImageHighlighted)
+ if (mCloseImageHighlighted != nullptr)
{
mCloseImageHighlighted->decRef();
mCloseImageHighlighted = nullptr;
}
- if (mStickyImageUp)
+ if (mStickyImageUp != nullptr)
{
mStickyImageUp->decRef();
mStickyImageUp = nullptr;
}
- if (mStickyImageDown)
+ if (mStickyImageDown != nullptr)
{
mStickyImageDown->decRef();
mStickyImageDown = nullptr;
@@ -106,30 +106,30 @@ void Skin::updateAlpha(const float minimumOpacityAllowed)
std::max(static_cast<double>(minimumOpacityAllowed),
static_cast<double>(settings.guiAlpha)));
- if (mBorder)
+ if (mBorder != nullptr)
{
for (int i = 0; i < 9; i++)
{
- if (mBorder->grid[i])
+ if (mBorder->grid[i] != nullptr)
mBorder->grid[i]->setAlpha(alpha);
}
}
- if (mCloseImage)
+ if (mCloseImage != nullptr)
mCloseImage->setAlpha(alpha);
- if (mCloseImageHighlighted)
+ if (mCloseImageHighlighted != nullptr)
mCloseImageHighlighted->setAlpha(alpha);
- if (mStickyImageUp)
+ if (mStickyImageUp != nullptr)
mStickyImageUp->setAlpha(alpha);
- if (mStickyImageDown)
+ if (mStickyImageDown != nullptr)
mStickyImageDown->setAlpha(alpha);
}
int Skin::getMinWidth() const
{
- if (!mBorder ||
- !mBorder->grid[ImagePosition::UPPER_LEFT] ||
- !mBorder->grid[ImagePosition::UPPER_RIGHT])
+ if ((mBorder == nullptr) ||
+ (mBorder->grid[ImagePosition::UPPER_LEFT] == nullptr) ||
+ (mBorder->grid[ImagePosition::UPPER_RIGHT] == nullptr))
{
return 1;
}
@@ -140,9 +140,9 @@ int Skin::getMinWidth() const
int Skin::getMinHeight() const
{
- if (!mBorder ||
- !mBorder->grid[ImagePosition::UPPER_LEFT] ||
- !mBorder->grid[ImagePosition::LOWER_LEFT])
+ if ((mBorder == nullptr) ||
+ (mBorder->grid[ImagePosition::UPPER_LEFT] == nullptr) ||
+ (mBorder->grid[ImagePosition::LOWER_LEFT] == nullptr))
{
return 1;
}
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 5eda09a36..6d16dfd4e 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -158,12 +158,12 @@ Color Theme::getProgressColor(const ProgressColorIdT type,
{
int color[3] = {0, 0, 0};
- if (theme)
+ if (theme != nullptr)
{
const DyePalette *const dye
= theme->mProgressColors[CAST_SIZE(type)];
- if (dye)
+ if (dye != nullptr)
{
dye->getColor(progress, color);
}
@@ -187,7 +187,7 @@ Skin *Theme::load(const std::string &filename,
const SkinIterator skinIterator = mSkins.find(filename);
if (mSkins.end() != skinIterator)
{
- if (skinIterator->second)
+ if (skinIterator->second != nullptr)
skinIterator->second->instances++;
return skinIterator->second;
}
@@ -196,9 +196,9 @@ Skin *Theme::load(const std::string &filename,
if (mScreenDensity.empty())
{ // if no density detected
skin = readSkin(filename, full);
- if (!skin && !filename2.empty() && filename2 != filename)
+ if ((skin == nullptr) && !filename2.empty() && filename2 != filename)
skin = readSkin(filename2, full);
- if (!skin && filename2 != "window.xml")
+ if ((skin == nullptr) && filename2 != "window.xml")
skin = readSkin("window.xml", full);
}
else
@@ -207,25 +207,25 @@ Skin *Theme::load(const std::string &filename,
std::string name = filename;
if (findCutLast(name, ".xml"))
skin = readSkin(name + endStr, full);
- if (!skin)
+ if (skin == nullptr)
skin = readSkin(filename, full);
- if (!skin && !filename2.empty() && filename2 != filename)
+ if ((skin == nullptr) && !filename2.empty() && filename2 != filename)
{
name = filename2;
if (findCutLast(name, ".xml"))
skin = readSkin(name + endStr, full);
- if (!skin)
+ if (skin == nullptr)
skin = readSkin(filename2, full);
}
- if (!skin && filename2 != "window.xml")
+ if ((skin == nullptr) && filename2 != "window.xml")
{
skin = readSkin("window" + endStr, full);
- if (!skin)
+ if (skin == nullptr)
skin = readSkin("window.xml", full);
}
}
- if (!skin)
+ if (skin == nullptr)
{
// Try falling back on the defaultPath if this makes sense
if (filename != defaultPath)
@@ -236,7 +236,7 @@ Skin *Theme::load(const std::string &filename,
skin = readSkin(defaultPath, full);
}
- if (!skin)
+ if (skin == nullptr)
{
logger->log(strprintf("Error: Loading default skin '%s' failed. "
"Make sure the skin file is valid.",
@@ -250,10 +250,10 @@ Skin *Theme::load(const std::string &filename,
void Theme::unload(Skin *const skin)
{
- if (!skin)
+ if (skin == nullptr)
return;
skin->instances --;
- if (!skin->instances)
+ if (skin->instances == 0)
{
SkinIterator it = mSkins.begin();
const SkinIterator it_end = mSkins.end();
@@ -284,7 +284,7 @@ void Theme::updateAlpha()
FOR_EACH (SkinIterator, iter, mSkins)
{
Skin *const skin = iter->second;
- if (skin)
+ if (skin != nullptr)
skin->updateAlpha(mMinimumOpacity);
}
}
@@ -403,10 +403,10 @@ Skin *Theme::readSkin(const std::string &filename, const bool full)
XML::Document *const doc = Loader::getXml(path,
UseVirtFs_true,
SkipError_true);
- if (!doc)
+ if (doc == nullptr)
return nullptr;
XmlNodeConstPtr rootNode = doc->rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "skinset"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "skinset"))
{
doc->decRef();
return nullptr;
@@ -461,7 +461,7 @@ Skin *Theme::readSkin(const std::string &filename, const bool full)
partNode, "ypos", 0) + globalYPos;
helper.width = XML::getProperty(partNode, "width", 0);
helper.height = XML::getProperty(partNode, "height", 0);
- if (!helper.width || !helper.height)
+ if ((helper.width == 0) || (helper.height == 0))
continue;
helper.image = dBorders;
@@ -528,7 +528,7 @@ Skin *Theme::readSkin(const std::string &filename, const bool full)
}
}
- if (dBorders)
+ if (dBorders != nullptr)
dBorders->decRef();
(*mOptions)["closePadding"] = closePadding;
@@ -555,7 +555,7 @@ bool Theme::tryThemePath(const std::string &themeName)
{
mThemePath = path;
mThemeName = themeName;
- if (theme)
+ if (theme != nullptr)
theme->loadColors("");
return true;
}
@@ -960,7 +960,7 @@ static GradientTypeT readColorGradient(const std::string &grad)
for (int i = 0; i < 4; i++)
{
- if (compareStrI(grad, grads[i]))
+ if (compareStrI(grad, grads[i]) != 0)
return static_cast<GradientTypeT>(i);
}
@@ -1008,11 +1008,11 @@ void Theme::loadColors(std::string file)
XML::Document *const doc = Loader::getXml(resolveThemePath(file),
UseVirtFs_true,
SkipError_false);
- if (!doc)
+ if (doc == nullptr)
return;
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root || !xmlNameEqual(root, "colors"))
+ if ((root == nullptr) || !xmlNameEqual(root, "colors"))
{
logger->log("Error loading colors file: %s", file.c_str());
doc->decRef();
@@ -1097,7 +1097,7 @@ void Theme::loadRect(ImageRect &image,
const int end)
{
Skin *const skin = load(name, name2, false);
- if (skin)
+ if (skin != nullptr)
{
loadGrid();
unload(skin);
@@ -1111,7 +1111,7 @@ Skin *Theme::loadSkinRect(ImageRect &image,
const int end)
{
Skin *const skin = load(name, name2);
- if (skin)
+ if (skin != nullptr)
loadGrid();
return skin;
}
@@ -1122,7 +1122,7 @@ void Theme::unloadRect(const ImageRect &rect,
{
for (int f = start; f <= end; f ++)
{
- if (rect.grid[f])
+ if (rect.grid[f] != nullptr)
rect.grid[f]->decRef();
}
}
@@ -1130,14 +1130,14 @@ void Theme::unloadRect(const ImageRect &rect,
Image *Theme::getImageFromThemeXml(const std::string &name,
const std::string &name2)
{
- if (!theme)
+ if (theme == nullptr)
return nullptr;
Skin *const skin = theme->load(name, name2, false);
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
- if (rect.grid[0])
+ if (rect.grid[0] != nullptr)
{
Image *const image = rect.grid[0];
image->incRef();
@@ -1153,18 +1153,18 @@ ImageSet *Theme::getImageSetFromThemeXml(const std::string &name,
const std::string &name2,
const int w, const int h)
{
- if (!theme)
+ if (theme == nullptr)
return nullptr;
Skin *const skin = theme->load(name, name2, false);
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
- if (rect.grid[0])
+ if (rect.grid[0] != nullptr)
{
Image *const image = rect.grid[0];
const SDL_Rect &rect2 = image->mBounds;
- if (rect2.w && rect2.h)
+ if ((rect2.w != 0u) && (rect2.h != 0u))
{
ImageSet *const imageSet = Loader::getSubImageSet(
image, w, h);
@@ -1218,11 +1218,11 @@ ThemeInfo *Theme::loadInfo(const std::string &themeName)
XML::Document *const doc = Loader::getXml(path,
UseVirtFs_true,
SkipError_false);
- if (!doc)
+ if (doc == nullptr)
return nullptr;
XmlNodeConstPtrConst rootNode = doc->rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "info"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "info"))
{
doc->decRef();
return nullptr;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index df9b9ae9b..3fb80fd33 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -121,7 +121,7 @@ Viewport::~Viewport()
void Viewport::setMap(Map *const map)
{
- if (mMap && map)
+ if ((mMap != nullptr) && (map != nullptr))
map->setDrawLayersFlags(mMap->getDrawLayersFlags());
mMap = map;
updateMaxVars();
@@ -132,7 +132,7 @@ void Viewport::draw(Graphics *const graphics)
BLOCK_START("Viewport::draw 1")
static int lastTick = tick_time;
- if (!mMap || !localPlayer)
+ if ((mMap == nullptr) || (localPlayer == nullptr))
{
graphics->setColor(Color(64, 64, 64));
graphics->fillRectangle(
@@ -247,7 +247,7 @@ void Viewport::draw(Graphics *const graphics)
}
// Draw text
- if (textManager)
+ if (textManager != nullptr)
textManager->draw(graphics, mPixelViewX, mPixelViewY);
// Draw player names, speech, and emotion sprite as needed
@@ -261,7 +261,7 @@ void Viewport::draw(Graphics *const graphics)
b->drawEmotion(graphics, mPixelViewX, mPixelViewY);
}
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->drawIcons(graphics);
// Draw contained widgets
@@ -285,11 +285,11 @@ void Viewport::logic()
void Viewport::followMouse()
{
- if (!gui)
+ if (gui == nullptr)
return;
const MouseStateType button = Gui::getMouseState(mMouseX, mMouseY);
// If the left button is dragged
- if (mPlayerFollowMouse && (button & SDL_BUTTON(1)))
+ if (mPlayerFollowMouse && ((button & SDL_BUTTON(1)) != 0))
{
// We create a mouse event and send it to mouseDragged.
const MouseEvent event(nullptr,
@@ -305,8 +305,14 @@ void Viewport::followMouse()
void Viewport::drawDebugPath(Graphics *const graphics)
{
- if (!localPlayer || !userPalette || !actorManager || !mMap || !gui)
+ if (localPlayer == nullptr ||
+ userPalette == nullptr ||
+ actorManager == nullptr ||
+ mMap == nullptr ||
+ gui == nullptr)
+ {
return;
+ }
Gui::getMouseState(mMouseX, mMouseY);
@@ -335,7 +341,7 @@ void Viewport::drawDebugPath(Graphics *const graphics)
FOR_EACH (ActorSpritesConstIterator, it, actors)
{
const Being *const being = dynamic_cast<const Being*>(*it);
- if (being && being != localPlayer)
+ if ((being != nullptr) && being != localPlayer)
{
const Path &beingPath = being->getPath();
drawPath(graphics, beingPath, userPalette->getColorWithAlpha(
@@ -358,7 +364,7 @@ void Viewport::drawPath(Graphics *const graphics,
const int squareY = i->y * mapTileSize - mPixelViewY + 12;
graphics->fillRectangle(Rect(squareX, squareY, 8, 8));
- if (mMap)
+ if (mMap != nullptr)
{
const std::string str = toString(cnt);
font->drawString(graphics,
@@ -376,12 +382,12 @@ bool Viewport::openContextMenu(const MouseEvent &event)
mPlayerFollowMouse = false;
const int eventX = event.getX();
const int eventY = event.getY();
- if (!popupMenu)
+ if (popupMenu == nullptr)
return false;
- if (mHoverBeing)
+ if (mHoverBeing != nullptr)
{
validateSpeed();
- if (actorManager)
+ if (actorManager != nullptr)
{
std::vector<ActorSprite*> beings;
const int x = mMouseX + mPixelViewX;
@@ -394,21 +400,21 @@ bool Viewport::openContextMenu(const MouseEvent &event)
return true;
}
}
- else if (mHoverItem)
+ else if (mHoverItem != nullptr)
{
validateSpeed();
popupMenu->showPopup(eventX, eventY, mHoverItem);
return true;
}
- else if (mHoverSign)
+ else if (mHoverSign != nullptr)
{
validateSpeed();
popupMenu->showPopup(eventX, eventY, mHoverSign);
return true;
}
- else if (settings.cameraMode)
+ else if (settings.cameraMode != 0u)
{
- if (!mMap)
+ if (mMap == nullptr)
return false;
popupMenu->showMapPopup(eventX, eventY,
(mMouseX + mPixelViewX) / mMap->getTileWidth(),
@@ -424,7 +430,7 @@ bool Viewport::leftMouseAction()
const bool stopAttack = inputManager.isActionActive(
InputAction::STOP_ATTACK);
// Interact with some being
- if (mHoverBeing)
+ if (mHoverBeing != nullptr)
{
if (!mHoverBeing->isAlive())
return true;
@@ -442,14 +448,14 @@ bool Viewport::leftMouseAction()
{
case ActorType::Player:
validateSpeed();
- if (actorManager)
+ if (actorManager != nullptr)
{
#ifdef TMWA_SUPPORT
if (localPlayer != mHoverBeing || mSelfMouseHeal)
actorManager->heal(mHoverBeing);
#endif // TMWA_SUPPORT
- if (localPlayer == mHoverBeing && mHoverItem)
+ if (localPlayer == mHoverBeing && (mHoverItem != nullptr))
localPlayer->pickUp(mHoverItem);
return true;
}
@@ -500,14 +506,14 @@ bool Viewport::leftMouseAction()
}
}
// Picks up a item if we clicked on one
- if (mHoverItem)
+ if (mHoverItem != nullptr)
{
validateSpeed();
localPlayer->pickUp(mHoverItem);
}
else if (stopAttack)
{
- if (mMap)
+ if (mMap != nullptr)
{
const int mouseTileX = (mMouseX + mPixelViewX)
/ mMap->getTileWidth();
@@ -542,7 +548,7 @@ void Viewport::mousePressed(MouseEvent &event)
return;
// Check if we are alive and kickin'
- if (!mMap || !localPlayer)
+ if ((mMap == nullptr) || (localPlayer == nullptr))
return;
// Check if we are busy
@@ -590,12 +596,12 @@ void Viewport::mousePressed(MouseEvent &event)
mPlayerFollowMouse = false;
validateSpeed();
// Find the being nearest to the clicked position
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const target = actorManager->findNearestLivingBeing(
pixelX, pixelY, 20, ActorType::Monster, nullptr);
- if (target)
+ if (target != nullptr)
localPlayer->setTarget(target);
}
}
@@ -609,7 +615,7 @@ void Viewport::getMouseTile(int &destX, int &destY) const
void Viewport::getMouseTile(const int x, const int y,
int &destX, int &destY) const
{
- if (!mMap)
+ if (mMap == nullptr)
return;
const int tw = mMap->getTileWidth();
const int th = mMap->getTileHeight();
@@ -656,7 +662,7 @@ void Viewport::getMouseTile(const int x, const int y,
void Viewport::walkByMouse(const MouseEvent &event)
{
- if (!mMap || !localPlayer)
+ if ((mMap == nullptr) || (localPlayer == nullptr))
return;
if (mPlayerFollowMouse
&& !inputManager.isActionActive(InputAction::STOP_ATTACK)
@@ -678,7 +684,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
/ static_cast<float>(height);
int x = event.getX() - width;
int y = event.getY() - height;
- if (!x && !y)
+ if ((x == 0) && (y == 0))
return;
const int x2 = abs(x);
const int y2 = abs(y);
@@ -687,7 +693,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
int dy = 0;
if (x2 > y2)
{
- if (y2 && static_cast<float>(x2) / static_cast<float>(y2)
+ if ((y2 != 0) && static_cast<float>(x2) / static_cast<float>(y2)
/ wh > diff)
{
y = 0;
@@ -695,7 +701,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
}
else
{
- if (x2 && y2 * wh / x2 > diff)
+ if ((x2 != 0) && y2 * wh / x2 > diff)
x = 0;
}
if (x > 0)
@@ -718,7 +724,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
}
else
{
- if (dx && dy)
+ if ((dx != 0) && (dy != 0))
{
// try avoid diagonal collision
if (x2 > y2)
@@ -757,7 +763,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
else
{
// try avoid vertical or horisontal collision
- if (!dx)
+ if (dx == 0)
{
if (mMap->getWalk(playerX + 1,
playerY + dy,
@@ -778,7 +784,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
dx = -1;
}
}
- if (!dy)
+ if (dy == 0)
{
if (mMap->getWalk(playerX + dx,
playerY + 1,
@@ -839,7 +845,7 @@ void Viewport::mouseDragged(MouseEvent &event)
}
if (mAllowMoveByMouse &&
mMouseClicked &&
- localPlayer &&
+ (localPlayer != nullptr) &&
localPlayer->canMove())
{
if (abs(event.getX() - mMousePressX) > 32
@@ -865,7 +871,7 @@ void Viewport::mouseReleased(MouseEvent &event)
if (eventButton == MouseButton::LEFT)
{
// long button press
- if (gui && gui->isLongPress())
+ if ((gui != nullptr) && gui->isLongPress())
{
if (openContextMenu(event))
{
@@ -906,7 +912,7 @@ void Viewport::optionChanged(const std::string &name)
void Viewport::mouseMoved(MouseEvent &event)
{
// Check if we are on the map
- if (!mMap || !localPlayer || !actorManager)
+ if ((mMap == nullptr) || (localPlayer == nullptr) || (actorManager == nullptr))
return;
if (mMouseDirectionMove)
@@ -917,9 +923,9 @@ void Viewport::mouseMoved(MouseEvent &event)
ActorTypeT type = ActorType::Unknown;
mHoverBeing = actorManager->findBeingByPixel(x, y, AllPlayers_true);
- if (mHoverBeing)
+ if (mHoverBeing != nullptr)
type = mHoverBeing->getType();
- if (mHoverBeing
+ if ((mHoverBeing != nullptr)
&& (type == ActorType::Player
|| type == ActorType::Npc
|| type == ActorType::Homunculus
@@ -927,7 +933,7 @@ void Viewport::mouseMoved(MouseEvent &event)
|| type == ActorType::Pet))
{
popupManager->hideTextPopup();
- if (mShowBeingPopup && beingPopup)
+ if (mShowBeingPopup && (beingPopup != nullptr))
beingPopup->show(mMouseX, mMouseY, mHoverBeing);
}
else
@@ -938,10 +944,10 @@ void Viewport::mouseMoved(MouseEvent &event)
mHoverItem = actorManager->findItem(x / mMap->getTileWidth(),
y / mMap->getTileHeight());
- if (!mHoverBeing && !mHoverItem)
+ if ((mHoverBeing == nullptr) && (mHoverItem == nullptr))
{
const SpecialLayer *const specialLayer = mMap->getSpecialLayer();
- if (specialLayer)
+ if (specialLayer != nullptr)
{
const int mouseTileX = (mMouseX + mPixelViewX)
/ mMap->getTileWidth();
@@ -949,12 +955,12 @@ void Viewport::mouseMoved(MouseEvent &event)
/ mMap->getTileHeight();
mHoverSign = specialLayer->getTile(mouseTileX, mouseTileY);
- if (mHoverSign && mHoverSign->getType() != MapItemType::EMPTY)
+ if ((mHoverSign != nullptr) && mHoverSign->getType() != MapItemType::EMPTY)
{
if (!mHoverSign->getComment().empty())
{
popupManager->hideBeingPopup();
- if (textPopup)
+ if (textPopup != nullptr)
{
textPopup->show(mMouseX, mMouseY,
mHoverSign->getComment());
@@ -973,7 +979,7 @@ void Viewport::mouseMoved(MouseEvent &event)
if (!event.isConsumed() && popupManager->isTextPopupVisible())
popupManager->hideTextPopup();
- if (mHoverBeing)
+ if (mHoverBeing != nullptr)
{
switch (type)
{
@@ -998,7 +1004,7 @@ void Viewport::mouseMoved(MouseEvent &event)
}
}
// Item mouseover
- else if (mHoverItem)
+ else if (mHoverItem != nullptr)
{
gui->setCursorType(mHoverItem->getHoverCursor());
}
@@ -1014,7 +1020,7 @@ void Viewport::toggleMapDrawType()
CAST_S32(settings.mapDrawType) + 1);
if (settings.mapDrawType > MapType::BLACKWHITE)
settings.mapDrawType = MapType::NORMAL;
- if (mMap)
+ if (mMap != nullptr)
mMap->setDrawLayersFlags(settings.mapDrawType);
}
@@ -1023,7 +1029,7 @@ void Viewport::toggleCameraMode()
settings.cameraMode ++;
if (settings.cameraMode > 1)
settings.cameraMode = 0;
- if (!settings.cameraMode)
+ if (settings.cameraMode == 0u)
{
mCameraRelativeX = 0;
mCameraRelativeY = 0;
@@ -1058,11 +1064,11 @@ void Viewport::moveCamera(const int dx, const int dy)
void Viewport::moveCameraToActor(const BeingId actorId,
const int x, const int y)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return;
const Actor *const actor = actorManager->findBeing(actorId);
- if (!actor)
+ if (actor == nullptr)
return;
settings.cameraMode = 1;
mCameraRelativeX = actor->mPixelX - localPlayer->mPixelX + x;
@@ -1072,7 +1078,7 @@ void Viewport::moveCameraToActor(const BeingId actorId,
void Viewport::moveCameraToPosition(const int x, const int y)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
settings.cameraMode = 1;
@@ -1102,7 +1108,7 @@ void Viewport::validateSpeed()
if (!inputManager.isActionActive(InputAction::TARGET_ATTACK) &&
!inputManager.isActionActive(InputAction::ATTACK))
{
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
}
}
@@ -1117,7 +1123,7 @@ void Viewport::updateMidVars()
void Viewport::updateMaxVars()
{
- if (!mMap)
+ if (mMap == nullptr)
return;
mViewXmax = mMap->getWidth() * mMap->getTileWidth()
- mainGraphics->mWidth;
diff --git a/src/gui/widgets/attrs/attrdisplay.cpp b/src/gui/widgets/attrs/attrdisplay.cpp
index 503444e7f..3b91fef9d 100644
--- a/src/gui/widgets/attrs/attrdisplay.cpp
+++ b/src/gui/widgets/attrs/attrdisplay.cpp
@@ -60,7 +60,7 @@ std::string AttrDisplay::update()
const int base = PlayerInfo::getStatBase(mId);
const int bonus = PlayerInfo::getStatMod(mId);
std::string value = toString(base + bonus);
- if (bonus)
+ if (bonus != 0)
value.append(strprintf("=%d%+d", base, bonus));
mValue->setCaption(value);
return mName;
diff --git a/src/gui/widgets/attrs/attrdisplay.h b/src/gui/widgets/attrs/attrdisplay.h
index c4f23339f..1641bac9f 100644
--- a/src/gui/widgets/attrs/attrdisplay.h
+++ b/src/gui/widgets/attrs/attrdisplay.h
@@ -54,7 +54,7 @@ class AttrDisplay notfinal : public Container
std::string getValue() const
{
- if (!mValue)
+ if (mValue == nullptr)
return "-";
else
return mValue->getCaption();
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index c81798e29..383efb397 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -56,7 +56,7 @@ Image *AvatarListBox::offlineIcon = nullptr;
AvatarListBox::AvatarListBox(const Widget2 *const widget,
AvatarListModel *const model) :
ListBox(widget, model, "avatarlistbox.xml"),
- mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0),
+ mImagePadding(mSkin != nullptr ? mSkin->getOption("imagePadding") : 0),
mShowGender(config.getBoolValue("showgender")),
mShowLevel(config.getBoolValue("showlevel"))
{
@@ -86,12 +86,12 @@ AvatarListBox::~AvatarListBox()
if (instances == 0)
{
- if (onlineIcon)
+ if (onlineIcon != nullptr)
{
onlineIcon->decRef();
onlineIcon = nullptr;
}
- if (offlineIcon)
+ if (offlineIcon != nullptr)
{
offlineIcon->decRef();
offlineIcon = nullptr;
@@ -102,14 +102,14 @@ AvatarListBox::~AvatarListBox()
void AvatarListBox::draw(Graphics *const graphics)
{
BLOCK_START("AvatarListBox::draw")
- if (!mListModel || !localPlayer)
+ if ((mListModel == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("AvatarListBox::draw")
return;
}
const Widget *const parent = mParent;
- if (!parent)
+ if (parent == nullptr)
return;
AvatarListModel *const model = static_cast<AvatarListModel *>(
@@ -129,7 +129,7 @@ void AvatarListBox::draw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -139,7 +139,7 @@ void AvatarListBox::draw(Graphics *const graphics)
// Draw online status
const Image *const icon = a->getOnline()
? onlineIcon : offlineIcon;
- if (icon)
+ if (icon != nullptr)
{
graphics->calcTileCollection(&vertexes, icon,
mImagePadding, y + mPadding);
@@ -155,7 +155,7 @@ void AvatarListBox::draw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -175,7 +175,7 @@ void AvatarListBox::draw(Graphics *const graphics)
a->getHp(), a->getMaxHp());
}
const bool isPoison = a->getPoison();
- if (a->getMaxHp())
+ if (a->getMaxHp() != 0)
{
const ProgressColorIdT themeColor = (isPoison
? ProgressColorId::PROG_HP_POISON
@@ -347,14 +347,14 @@ void AvatarListBox::draw(Graphics *const graphics)
void AvatarListBox::safeDraw(Graphics *const graphics)
{
BLOCK_START("AvatarListBox::draw")
- if (!mListModel || !localPlayer)
+ if ((mListModel == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("AvatarListBox::draw")
return;
}
const Widget *const parent = mParent;
- if (!parent)
+ if (parent == nullptr)
return;
AvatarListModel *const model = static_cast<AvatarListModel *>(
@@ -373,7 +373,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -383,7 +383,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
// Draw online status
const Image *const icon = a->getOnline()
? onlineIcon : offlineIcon;
- if (icon)
+ if (icon != nullptr)
graphics->drawImage(icon, mImagePadding, y + mPadding);
}
}
@@ -393,7 +393,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -413,7 +413,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
a->getHp(), a->getMaxHp());
}
const bool isPoison = a->getPoison();
- if (a->getMaxHp())
+ if (a->getMaxHp() != 0)
{
const ProgressColorIdT themeColor = (isPoison
? ProgressColorId::PROG_HP_POISON
@@ -584,15 +584,19 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
void AvatarListBox::mousePressed(MouseEvent &event)
{
- if (!actorManager || !localPlayer || !popupManager)
+ if (actorManager == nullptr ||
+ localPlayer == nullptr ||
+ popupManager == nullptr)
+ {
return;
+ }
const int height = getFont()->getHeight();
- if (!height)
+ if (height == 0)
return;
const int y = (event.getY() - mPadding) / height;
- if (!mListModel || y > mListModel->getNumberOfElements())
+ if ((mListModel == nullptr) || y > mListModel->getNumberOfElements())
return;
setSelected(y);
@@ -600,10 +604,10 @@ void AvatarListBox::mousePressed(MouseEvent &event)
const int selected = getSelected();
AvatarListModel *const model = static_cast<AvatarListModel *>(
mListModel);
- if (!model)
+ if (model == nullptr)
return;
const Avatar *ava = model->getAvatarAt(selected);
- if (!ava)
+ if (ava == nullptr)
return;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -618,7 +622,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
{
const Being *const being = actorManager->findBeingByName(
ava->getName(), ActorType::Player);
- if (being)
+ if (being != nullptr)
actorManager->heal(being);
}
else
@@ -634,11 +638,11 @@ void AvatarListBox::mousePressed(MouseEvent &event)
case MapItemType::EMPTY:
{
const Avatar *const avatar = model->getAvatarAt(selected);
- if (avatar)
+ if (avatar != nullptr)
{
const Being *const being = actorManager->findBeingByName(
avatar->getName(), ActorType::Player);
- if (being)
+ if (being != nullptr)
{
popupMenu->showPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -698,7 +702,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
{
const Map *const map = viewport->getMap();
ava = model->getAvatarAt(selected);
- if (map && ava)
+ if ((map != nullptr) && (ava != nullptr))
{
MapItem *const mapItem = map->findPortalXY(
ava->getX(), ava->getY());
@@ -712,12 +716,12 @@ void AvatarListBox::mousePressed(MouseEvent &event)
}
else if (eventButton == MouseButton::MIDDLE)
{
- if (type == MapItemType::EMPTY && chatWindow)
+ if (type == MapItemType::EMPTY && (chatWindow != nullptr))
{
const std::string &name = model->getAvatarAt(selected)->getName();
const WhisperTab *const tab = chatWindow->addWhisperTab(
name, name, true);
- if (tab)
+ if (tab != nullptr)
chatWindow->saveState();
}
}
diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp
index 68f440fcf..771ba83f4 100644
--- a/src/gui/widgets/basiccontainer.cpp
+++ b/src/gui/widgets/basiccontainer.cpp
@@ -234,7 +234,7 @@ void BasicContainer::setFocusHandler(FocusHandler *restrict2 const
{
Widget::setFocusHandler(focusHandler);
- if (mInternalFocusHandler)
+ if (mInternalFocusHandler != nullptr)
return;
FOR_EACH (WidgetListConstIterator, iter, mWidgets)
@@ -243,13 +243,13 @@ void BasicContainer::setFocusHandler(FocusHandler *restrict2 const
void BasicContainer::add(Widget *const widget) restrict2
{
- if (!widget)
+ if (widget == nullptr)
return;
mWidgets.push_back(widget);
if (widget->isAllowLogic())
mLogicWidgets.push_back(widget);
- if (!mInternalFocusHandler)
+ if (mInternalFocusHandler == nullptr)
widget->setFocusHandler(getFocusHandler());
else
widget->setFocusHandler(mInternalFocusHandler);
@@ -260,7 +260,7 @@ void BasicContainer::add(Widget *const widget) restrict2
void BasicContainer::remove(Widget *const restrict widget) restrict2
{
- if (!widget)
+ if (widget == nullptr)
return;
FOR_EACH (WidgetListIterator, iter, mWidgets)
{
@@ -391,7 +391,7 @@ void BasicContainer::logicChildren() restrict2
void BasicContainer::showWidgetPart(Widget *restrict const widget,
const Rect &restrict area) restrict2
{
- if (!widget)
+ if (widget == nullptr)
return;
const Rect widgetArea = getChildrenArea();
@@ -417,7 +417,7 @@ void BasicContainer::setInternalFocusHandler(FocusHandler *const restrict
{
Widget::setInternalFocusHandler(focusHandler);
- FocusHandler *const restrict handler = mInternalFocusHandler ?
+ FocusHandler *const restrict handler = mInternalFocusHandler != nullptr ?
mInternalFocusHandler : getFocusHandler();
FOR_EACH (WidgetListConstIterator, iter, mWidgets)
{
diff --git a/src/gui/widgets/basiccontainer2.cpp b/src/gui/widgets/basiccontainer2.cpp
index c89cf1962..ad143010d 100644
--- a/src/gui/widgets/basiccontainer2.cpp
+++ b/src/gui/widgets/basiccontainer2.cpp
@@ -121,7 +121,7 @@ void BasicContainer2::addXY(Widget *const widget,
const int x,
const int y)
{
- if (!widget)
+ if (widget == nullptr)
return;
widget->setPosition(x, y);
BasicContainer::add(widget);
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 0c35b63d4..22a6cec9d 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -123,7 +123,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND);
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load(skin, "browserbox.xml");
if (mInstances == 0)
{
@@ -132,15 +132,15 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
}
mInstances ++;
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mNewLinePadding = CAST_U32(
mSkin->getOption("newLinePadding", 15));
mItemPadding = mSkin->getOption("itemPadding");
- if (mSkin->getOption("highlightBackground"))
+ if (mSkin->getOption("highlightBackground") != 0)
mHighlightMode |= LinkHighlightMode::BACKGROUND;
- if (mSkin->getOption("highlightUnderline"))
+ if (mSkin->getOption("highlightUnderline") != 0)
mHighlightMode |= LinkHighlightMode::UNDERLINE;
}
@@ -161,10 +161,10 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
BrowserBox::~BrowserBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (theme)
+ if (theme != nullptr)
{
theme->unload(mSkin);
mSkin = nullptr;
@@ -173,7 +173,7 @@ BrowserBox::~BrowserBox()
mInstances --;
if (mInstances == 0)
{
- if (mEmotes)
+ if (mEmotes != nullptr)
{
mEmotes->decRef();
mEmotes = nullptr;
@@ -231,7 +231,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
{
bLink.caption = BrowserBoxTools::replaceLinkCommands(
bLink.link);
- if (translator)
+ if (translator != nullptr)
bLink.caption = translator->getStr(bLink.caption);
}
@@ -295,7 +295,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
int cnt = mTextRowLinksCount.front();
mTextRowLinksCount.pop_front();
- while (cnt && !mLinks.empty())
+ while ((cnt != 0) && !mLinks.empty())
{
mLinks.erase(mLinks.begin());
cnt --;
@@ -413,7 +413,7 @@ void BrowserBox::clearRows()
void BrowserBox::mousePressed(MouseEvent &event)
{
- if (!mLinkHandler)
+ if (mLinkHandler == nullptr)
return;
const LinkIterator i = std::find_if(mLinks.begin(), mLinks.end(),
@@ -462,7 +462,7 @@ void BrowserBox::draw(Graphics *const graphics)
if (mSelectedLink >= 0 &&
mSelectedLink < CAST_S32(mLinks.size()))
{
- if ((mHighlightMode & LinkHighlightMode::BACKGROUND))
+ if ((mHighlightMode & LinkHighlightMode::BACKGROUND) != 0u)
{
BrowserLink &link = mLinks[CAST_SIZE(mSelectedLink)];
graphics->setColor(mHighlightColor);
@@ -473,7 +473,7 @@ void BrowserBox::draw(Graphics *const graphics)
link.y2 - link.y1));
}
- if ((mHighlightMode & LinkHighlightMode::UNDERLINE))
+ if ((mHighlightMode & LinkHighlightMode::UNDERLINE) != 0u)
{
BrowserLink &link = mLinks[CAST_SIZE(mSelectedLink)];
graphics->setColor(mHyperLinkColor);
@@ -494,7 +494,7 @@ void BrowserBox::draw(Graphics *const graphics)
continue;
if (part.mY > yEnd)
break;
- if (!part.mType)
+ if (part.mType == 0u)
{
if (part.mBold)
{
@@ -513,7 +513,7 @@ void BrowserBox::draw(Graphics *const graphics)
part.mX, part.mY);
}
}
- else if (part.mImage)
+ else if (part.mImage != nullptr)
{
graphics->drawImage(part.mImage, part.mX, part.mY);
}
@@ -580,7 +580,7 @@ int BrowserBox::calcHeight()
if (sz > 2 && str.substr(sz - 1) == "~")
str = str.substr(0, sz - 1);
Image *const img = Loader::getImage(str);
- if (img)
+ if (img != nullptr)
{
img->incRef();
mLineParts.push_back(LinePart(CAST_S32(x),
@@ -757,14 +757,14 @@ int BrowserBox::calcHeight()
const int cid = row.at(start + 2) - '0';
if (cid >= 0)
{
- if (mEmotes)
+ if (mEmotes != nullptr)
{
const size_t sz = mEmotes->size();
if (CAST_SIZE(cid) < sz)
{
Image *const img = mEmotes->get(
CAST_SIZE(cid));
- if (img)
+ if (img != nullptr)
{
mLineParts.push_back(LinePart(
CAST_S32(x),
@@ -890,7 +890,7 @@ int BrowserBox::calcHeight()
void BrowserBox::updateHeight()
{
if (mAlwaysUpdate || mUpdateTime != cur_time
- || mTextRows.size() < 3 || !mUpdateTime)
+ || mTextRows.size() < 3 || (mUpdateTime == 0))
{
mWidth = mDimension.width;
mHeight = calcHeight();
@@ -958,7 +958,7 @@ void BrowserBox::moveSelectionDown()
void BrowserBox::selectSelection()
{
- if (!mLinkHandler ||
+ if ((mLinkHandler == nullptr) ||
mSelectedLink < 0 ||
mSelectedLink >= static_cast<signed int>(mLinks.size()))
{
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index f24d5c9a0..3509b927c 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -183,7 +183,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -234,7 +234,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -284,7 +284,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -334,7 +334,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -351,12 +351,12 @@ void Button::init()
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
{
Skin *const skin = theme->load(data[mode], "button.xml");
- if (skin)
+ if (skin != nullptr)
{
button[mode] = skin;
mSpacing[mode] = skin->getOption("spacing");
@@ -372,26 +372,26 @@ void Button::init()
Button::~Button()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances--;
- if (mInstances == 0 && theme)
+ if (mInstances == 0 && (theme != nullptr))
{
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
theme->unload(button[mode]);
}
delete2(mVertexes2);
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
}
- if (mImages)
+ if (mImages != nullptr)
{
for (int f = 0; f < BUTTON_COUNT; f ++)
mImages[f] = nullptr;
@@ -403,7 +403,7 @@ Button::~Button()
void Button::loadImage(const std::string &imageName)
{
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
@@ -416,21 +416,21 @@ void Button::loadImage(const std::string &imageName)
void Button::loadImageSet(const std::string &imageName)
{
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
}
mImageSet = Theme::getImageSetFromTheme(imageName,
mImageWidth, mImageHeight);
- if (!mImageSet)
+ if (mImageSet == nullptr)
return;
mImages = new Image*[BUTTON_COUNT];
mImages[0] = nullptr;
for (size_t f = 0; f < BUTTON_COUNT; f ++)
{
Image *const img = mImageSet->get(f);
- if (img)
+ if (img != nullptr)
mImages[f] = img;
else
mImages[f] = mImages[0];
@@ -450,11 +450,11 @@ void Button::updateAlpha()
for (int a = 0; a < 9; a ++)
{
Skin *const skin = button[mode];
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -477,7 +477,7 @@ void Button::draw(Graphics *const graphics)
mode = BUTTON_STANDARD;
const Skin *const skin = button[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Button::draw")
return;
@@ -526,7 +526,7 @@ void Button::draw(Graphics *const graphics)
const int height = rect.height;
Font *const font = getFont();
int textY = height / 2 - font->getHeight() / 2;
- if (mImages)
+ if (mImages != nullptr)
imageY = height / 2 - mImageHeight / 2;
// need move calculation from draw!!!
@@ -536,7 +536,7 @@ void Button::draw(Graphics *const graphics)
default:
case Graphics::LEFT:
{
- if (mImages)
+ if (mImages != nullptr)
{
imageX = padding;
textX = padding + mImageWidth + spacing;
@@ -550,7 +550,7 @@ void Button::draw(Graphics *const graphics)
case Graphics::CENTER:
{
const int width1 = font->getWidth(mCaption);
- if (mImages)
+ if (mImages != nullptr)
{
const int w = width1 + mImageWidth + spacing;
imageX = (width - w) / 2;
@@ -581,7 +581,7 @@ void Button::draw(Graphics *const graphics)
width, height,
skin->getBorder());
- if (mImages)
+ if (mImages != nullptr)
{
if (isPressed())
{
@@ -635,7 +635,7 @@ void Button::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, textX, textY);
BLOCK_END("Button::draw")
@@ -656,7 +656,7 @@ void Button::safeDraw(Graphics *const graphics)
mode = BUTTON_STANDARD;
const Skin *const skin = button[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Button::safeDraw")
return;
@@ -681,7 +681,7 @@ void Button::safeDraw(Graphics *const graphics)
const int height = rect.height;
Font *const font = getFont();
int textY = height / 2 - font->getHeight() / 2;
- if (mImages)
+ if (mImages != nullptr)
imageY = height / 2 - mImageHeight / 2;
// need move calculation from draw!!!
@@ -691,7 +691,7 @@ void Button::safeDraw(Graphics *const graphics)
default:
case Graphics::LEFT:
{
- if (mImages)
+ if (mImages != nullptr)
{
imageX = padding;
textX = padding + mImageWidth + spacing;
@@ -705,7 +705,7 @@ void Button::safeDraw(Graphics *const graphics)
case Graphics::CENTER:
{
const int width1 = font->getWidth(mCaption);
- if (mImages)
+ if (mImages != nullptr)
{
const int w = width1 + mImageWidth + spacing;
imageX = (width - w) / 2;
@@ -728,7 +728,7 @@ void Button::safeDraw(Graphics *const graphics)
graphics->drawImageRect(0, 0, width, height, skin->getBorder());
- if (mImages)
+ if (mImages != nullptr)
{
if (isPressed())
graphics->drawImage(mImages[mode], imageX + 1, imageY + 1);
@@ -771,7 +771,7 @@ void Button::safeDraw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, textX, textY);
BLOCK_END("Button::safeDraw")
@@ -822,15 +822,15 @@ void Button::adjustSize()
{
const Font *const font = getFont();
const Skin *const skin = button[BUTTON_STANDARD];
- if (!skin)
+ if (skin == nullptr)
return;
const int padding = skin->getPadding();
- if (mImages)
+ if (mImages != nullptr)
{
const int spacing = mSpacing[BUTTON_STANDARD];
const int width = font->getWidth(mCaption);
- if (width)
+ if (width != 0)
setWidth(width + mImageWidth + spacing + 2 * padding);
else
setWidth(mImageWidth + 2 * padding);
@@ -916,14 +916,14 @@ void Button::mouseDragged(MouseEvent& event)
void Button::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
void Button::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index 696b8c2bf..c3b5ea064 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -85,7 +85,7 @@ void CharacterDisplay::setCharacter(Net::Character *const character)
return;
mCharacter = character;
- mPlayerBox->setPlayer(character ? character->dummy : nullptr);
+ mPlayerBox->setPlayer(character != nullptr ? character->dummy : nullptr);
update();
}
@@ -99,7 +99,7 @@ void CharacterDisplay::setActive(const bool active A_UNUSED)
void CharacterDisplay::update()
{
- if (mCharacter)
+ if (mCharacter != nullptr)
mName->setCaption(mCharacter->dummy->getName());
else
mName->setCaption("");
@@ -111,20 +111,24 @@ void CharacterDisplay::update()
void CharacterDisplay::widgetHidden(const Event &event A_UNUSED)
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
void CharacterDisplay::mouseExited(MouseEvent &event A_UNUSED)
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED)
{
- if (!gui || !textPopup || !mCharacter)
+ if (gui == nullptr ||
+ textPopup == nullptr ||
+ mCharacter == nullptr)
+ {
return;
+ }
int mouseX = 0;
int mouseY = 0;
diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp
index c4bf0d5ef..c92ad7477 100644
--- a/src/gui/widgets/characterviewnormal.cpp
+++ b/src/gui/widgets/characterviewnormal.cpp
@@ -34,7 +34,7 @@ CharacterViewNormal::CharacterViewNormal(CharSelectDialog *const widget,
mCharacterEntries(entries)
{
addKeyListener(widget);
- if (entries)
+ if (entries != nullptr)
{
FOR_EACHP (std::vector<CharacterDisplay*>::iterator,
it, entries)
@@ -47,7 +47,7 @@ CharacterViewNormal::CharacterViewNormal(CharSelectDialog *const widget,
if (mSelected >= 0 && mSelected < CAST_S32(sz))
{
CharacterDisplay *const display = (*mCharacterEntries)[mSelected];
- if (display)
+ if (display != nullptr)
display->setSelect(false);
}
if (sz > 0)
diff --git a/src/gui/widgets/characterviewsmall.cpp b/src/gui/widgets/characterviewsmall.cpp
index dbb04064f..a861e5033 100644
--- a/src/gui/widgets/characterviewsmall.cpp
+++ b/src/gui/widgets/characterviewsmall.cpp
@@ -40,7 +40,7 @@ CharacterViewSmall::CharacterViewSmall(CharSelectDialog *const widget,
mCharacterEntries(entries)
{
addKeyListener(widget);
- if (entries)
+ if (entries != nullptr)
{
FOR_EACHP (std::vector<CharacterDisplay*>::iterator,
it, entries)
@@ -81,7 +81,7 @@ void CharacterViewSmall::show(const int i)
const int sz = CAST_S32(mCharacterEntries->size());
if (sz <= 0)
return;
- if (mSelectedEntry)
+ if (mSelectedEntry != nullptr)
mSelectedEntry->setVisible(Visible_false);
if (i >= sz)
mSelected = 0;
diff --git a/src/gui/widgets/chatinput.h b/src/gui/widgets/chatinput.h
index 2a6a23a80..92c7dc341 100644
--- a/src/gui/widgets/chatinput.h
+++ b/src/gui/widgets/chatinput.h
@@ -60,7 +60,7 @@ class ChatInput final : public TextField
if (mFocusGaining || !config.getBoolValue("protectChatFocus"))
{
processVisible(Visible_false);
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->updateVisibility();
mFocusGaining = false;
return;
@@ -72,7 +72,7 @@ class ChatInput final : public TextField
void processVisible(const Visible n)
{
- if (!mWindow || isVisible() == (n == Visible_true))
+ if (mWindow == nullptr || isVisible() == (n == Visible_true))
return;
if (n == Visible_false)
@@ -83,7 +83,7 @@ class ChatInput final : public TextField
{
mWindow->adjustTabSize();
}
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
emoteWindow->hide();
}
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 03da61a7b..ab1227b08 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -115,7 +115,7 @@ CheckBox::CheckBox(const Widget2 *const widget,
mForegroundColor2 = getThemeColor(ThemeColorId::CHECKBOX_OUTLINE);
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load("checkbox.xml", "");
updateAlpha();
@@ -127,17 +127,17 @@ CheckBox::CheckBox(const Widget2 *const widget,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
mForegroundColor = getThemeColor(ThemeColorId::CHECKBOX);
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mImagePadding = mSkin->getOption("imagePadding");
mImageSize = mSkin->getOption("imageSize");
mSpacing = mSkin->getOption("spacing");
- mDrawBox = mSkin->getOption("drawBox", 1);
+ mDrawBox = (mSkin->getOption("drawBox", 1) != 0);
mTextX = mPadding + mImageSize + mSpacing;
}
adjustSize();
@@ -145,17 +145,17 @@ CheckBox::CheckBox(const Widget2 *const widget,
CheckBox::~CheckBox()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
}
@@ -179,7 +179,7 @@ void CheckBox::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, mTextX, mPadding);
BLOCK_END("CheckBox::draw")
@@ -198,13 +198,13 @@ void CheckBox::updateAlpha()
if (mAlpha != alpha)
{
mAlpha = alpha;
- if (mSkin)
+ if (mSkin != nullptr)
{
const ImageRect &rect = mSkin->getBorder();
for (int a = 0; a < 6; a ++)
{
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -213,7 +213,7 @@ void CheckBox::updateAlpha()
void CheckBox::drawBox(Graphics *const graphics)
{
- if (!mSkin || !mDrawBox)
+ if ((mSkin == nullptr) || !mDrawBox)
return;
const ImageRect &rect = mSkin->getBorder();
@@ -247,7 +247,7 @@ void CheckBox::drawBox(Graphics *const graphics)
updateAlpha();
- if (box)
+ if (box != nullptr)
{
graphics->drawImage(box,
mImagePadding,
@@ -313,7 +313,7 @@ void CheckBox::setCaption(const std::string& caption)
void CheckBox::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
@@ -326,7 +326,7 @@ void CheckBox::widgetHidden(const Event &event A_UNUSED)
void CheckBox::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp
index f29540c0f..fa3099c2c 100644
--- a/src/gui/widgets/colorpage.cpp
+++ b/src/gui/widgets/colorpage.cpp
@@ -35,11 +35,11 @@ ColorPage::ColorPage(const Widget2 *const widget,
const std::string &skin) :
ListBox(widget, listModel, skin)
{
- mItemPadding = mSkin ? mSkin->getOption("itemPadding") : 1;
+ mItemPadding = mSkin != nullptr ? mSkin->getOption("itemPadding") : 1;
const Font *const font = getFont();
mRowHeight = CAST_U32(font->getHeight() +
2 * mItemPadding);
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(CAST_S32(getRowHeight()) *
mListModel->getNumberOfElements()
@@ -114,7 +114,7 @@ void ColorPage::resetAction()
void ColorPage::adjustSize()
{
BLOCK_START("ColorPage::adjustSize")
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(CAST_S32(getRowHeight()) *
mListModel->getNumberOfElements() +
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index e6f8ad4f4..2da444728 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -34,7 +34,7 @@ Container::Container(const Widget2 *const widget) :
Container::~Container()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
removeControls();
}
diff --git a/src/gui/widgets/containerplacer.cpp b/src/gui/widgets/containerplacer.cpp
index 8db3a0e25..634a87fcd 100644
--- a/src/gui/widgets/containerplacer.cpp
+++ b/src/gui/widgets/containerplacer.cpp
@@ -29,15 +29,16 @@
ContainerPlacer ContainerPlacer::at(const int x, const int y)
{
- return ContainerPlacer(mContainer, mCell ? &mCell->at(x, y) : nullptr);
+ return ContainerPlacer(mContainer,
+ mCell != nullptr ? &mCell->at(x, y) : nullptr);
}
LayoutCell &ContainerPlacer::operator()
(const int x, const int y, Widget *const wg, const int w, const int h)
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->add(wg);
- if (mCell)
+ if (mCell != nullptr)
return mCell->place(wg, x, y, w, h);
return LayoutCell::emptyCell;
}
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 83d5bd58e..43248ebe8 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -64,11 +64,11 @@ Desktop::Desktop(const Widget2 *const widget) :
Wallpaper::loadWallpapers();
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load("desktop.xml", "");
- if (mSkin)
- mShowBackground = mSkin->getOption("showBackground");
+ if (mSkin != nullptr)
+ mShowBackground = (mSkin->getOption("showBackground") != 0);
const std::string appName = branding.getValue("appName", std::string());
if (appName.empty())
@@ -87,18 +87,18 @@ Desktop::Desktop(const Widget2 *const widget) :
Desktop::~Desktop()
{
- if (mWallpaper)
+ if (mWallpaper != nullptr)
{
mWallpaper->decRef();
mWallpaper = nullptr;
}
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
void Desktop::postInit()
{
- if (mSkin)
+ if (mSkin != nullptr)
{
addXY(mVersionLabel,
mSkin->getOption("versionX", 25),
@@ -130,7 +130,7 @@ void Desktop::draw(Graphics *const graphics)
const Rect &rect = mDimension;
const int width = rect.width;
const int height = rect.height;
- if (mWallpaper)
+ if (mWallpaper != nullptr)
{
const int wallpWidth = mWallpaper->getWidth();
const int wallpHeight = mWallpaper->getHeight();
@@ -178,9 +178,9 @@ void Desktop::setBestFittingWallpaper()
Image *const nWallPaper = Theme::getImageFromTheme(wallpaperName);
- if (nWallPaper)
+ if (nWallPaper != nullptr)
{
- if (mWallpaper)
+ if (mWallpaper != nullptr)
{
ResourceManager::decRefDelete(mWallpaper);
mWallpaper = nullptr;
@@ -198,7 +198,7 @@ void Desktop::setBestFittingWallpaper()
Image *const newRsclWlPpr = Loader::getRescaled(
nWallPaper, width, height);
- if (newRsclWlPpr)
+ if (newRsclWlPpr != nullptr)
{
ResourceManager::decRefDelete(nWallPaper);
// We replace the resource in the resource manager
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index eb848f4d6..cb9eef73d 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -84,20 +84,20 @@ DropDown::DropDown(const Widget2 *const widget,
mPopup->setHeight(100);
// Initialize graphics
- if (instances == 0 && theme)
+ if (instances == 0 && (theme != nullptr))
{
// Load the background skin
for (int i = 0; i < 2; i ++)
{
Skin *const skin = theme->load(dropdownFiles[i], "dropdown.xml");
- if (skin)
+ if (skin != nullptr)
{
- if (!i)
+ if (i == 0)
mSkin = skin;
const ImageRect &rect = skin->getBorder();
for (int f = 0; f < 2; f ++)
{
- if (rect.grid[f])
+ if (rect.grid[f] != nullptr)
{
rect.grid[f]->incRef();
buttons[f][i] = rect.grid[f];
@@ -108,7 +108,7 @@ DropDown::DropDown(const Widget2 *const widget,
buttons[f][i] = nullptr;
}
}
- if (i)
+ if (i != 0)
theme->unload(skin);
}
else
@@ -144,12 +144,12 @@ DropDown::DropDown(const Widget2 *const widget,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
mPopup->adjustSize();
- if (mSkin)
+ if (mSkin != nullptr)
{
mSpacing = mSkin->getOption("spacing");
mFrameSize = CAST_U32(mSkin->getOption("frameSize"));
@@ -161,7 +161,7 @@ DropDown::DropDown(const Widget2 *const widget,
DropDown::~DropDown()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
@@ -171,11 +171,11 @@ DropDown::~DropDown()
{
for (int i = 0; i < 2; i ++)
{
- if (buttons[f][i])
+ if (buttons[f][i] != nullptr)
buttons[f][i]->decRef();
}
}
- if (theme)
+ if (theme != nullptr)
{
theme->unload(mSkin);
Theme::unloadRect(skinRect);
@@ -192,18 +192,18 @@ void DropDown::updateAlpha()
{
mAlpha = alpha;
- if (buttons[0][0])
+ if (buttons[0][0] != nullptr)
buttons[0][0]->setAlpha(mAlpha);
- if (buttons[0][1])
+ if (buttons[0][1] != nullptr)
buttons[0][1]->setAlpha(mAlpha);
- if (buttons[1][0])
+ if (buttons[1][0] != nullptr)
buttons[1][0]->setAlpha(mAlpha);
- if (buttons[1][1])
+ if (buttons[1][1] != nullptr)
buttons[1][1]->setAlpha(mAlpha);
for (int a = 0; a < 9; a++)
{
- if (skinRect.grid[a])
+ if (skinRect.grid[a] != nullptr)
skinRect.grid[a]->setAlpha(mAlpha);
}
}
@@ -227,7 +227,7 @@ void DropDown::draw(Graphics *const graphics)
mShadowColor.a = alpha;
ListModel *const model = mPopup->getListModel();
- if (model && mPopup->getSelected() >= 0)
+ if ((model != nullptr) && mPopup->getSelected() >= 0)
{
Font *const font = getFont();
if (mExtended)
@@ -236,7 +236,7 @@ void DropDown::draw(Graphics *const graphics)
ExtendedListModel *const model2
= static_cast<ExtendedListModel *>(model);
const Image *const image = model2->getImageAt(sel);
- if (!image)
+ if (image == nullptr)
{
font->drawString(graphics,
mForegroundColor,
@@ -320,7 +320,7 @@ void DropDown::drawButton(Graphics *const graphics)
const int height = mDroppedDown ? mFoldedUpHeight : mDimension.height;
Image *image = buttons[mDroppedDown][mPushed];
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image,
mDimension.width - image->getWidth() - mImagePadding,
@@ -356,7 +356,7 @@ void DropDown::keyPressed(KeyEvent& event)
break;
case InputAction::GUI_END:
- if (mPopup->getListModel())
+ if (mPopup->getListModel() != nullptr)
{
setSelected(mPopup->getListModel()->
getNumberOfElements() - 1);
@@ -441,7 +441,7 @@ void DropDown::mouseWheelMovedDown(MouseEvent& event)
void DropDown::setSelectedString(const std::string &str)
{
ListModel *const listModel = mPopup->getListModel();
- if (!listModel)
+ if (listModel == nullptr)
return;
for (int f = 0; f < listModel->getNumberOfElements(); f ++)
@@ -457,7 +457,7 @@ void DropDown::setSelectedString(const std::string &str)
std::string DropDown::getSelectedString() const
{
ListModel *const listModel = mPopup->getListModel();
- if (!listModel)
+ if (listModel == nullptr)
return "";
return listModel->getElementAt(getSelected());
@@ -472,7 +472,7 @@ void DropDown::dropDown()
{
if (!mDroppedDown)
{
- if (!mParent)
+ if (mParent == nullptr)
return;
mDroppedDown = true;
mFoldedUpHeight = getHeight();
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index 771813d1b..459e386a4 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -54,7 +54,7 @@ EmotePage::EmotePage(const Widget2 *const widget) :
EmotePage::~EmotePage()
{
- if (mEmotes)
+ if (mEmotes != nullptr)
{
mEmotes->decRef();
mEmotes = nullptr;
@@ -68,7 +68,7 @@ void EmotePage::draw(Graphics *const graphics)
if (mRedraw)
{
- if (!mEmotes)
+ if (mEmotes == nullptr)
return;
const std::vector<Image*> &images = mEmotes->getImages();
@@ -82,7 +82,7 @@ void EmotePage::draw(Graphics *const graphics)
FOR_EACH (std::vector<Image*>::const_iterator, it, images)
{
const Image *const image = *it;
- if (image)
+ if (image != nullptr)
{
graphics->calcTileCollection(mVertexes, image, x, y);
x += emoteWidth;
@@ -104,7 +104,7 @@ void EmotePage::safeDraw(Graphics *const graphics)
{
BLOCK_START("EmotePage::safeDraw")
- if (!mEmotes)
+ if (mEmotes == nullptr)
return;
const std::vector<Image*> &images = mEmotes->getImages();
@@ -116,7 +116,7 @@ void EmotePage::safeDraw(Graphics *const graphics)
FOR_EACH (std::vector<Image*>::const_iterator, it, images)
{
const Image *const image = *it;
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image, x, y);
x += emoteWidth;
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 0d75051eb..37acf7263 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -57,14 +57,14 @@ EmoteShortcutContainer::EmoteShortcutContainer(Widget2 *restrict const
mEmoteClicked(false),
mEmoteMoved(0)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(settings.guiAlpha);
// Setup emote sprites
for (int i = 0; i <= EmoteDB::getLast(); i++)
{
const EmoteSprite *const sprite = EmoteDB::getSprite(i, true);
- if (sprite && sprite->sprite)
+ if ((sprite != nullptr) && (sprite->sprite != nullptr))
mEmoteImg.push_back(sprite);
}
@@ -85,13 +85,13 @@ void EmoteShortcutContainer::setWidget2(const Widget2 *restrict const widget)
void EmoteShortcutContainer::draw(Graphics *restrict graphics) restrict2
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
BLOCK_START("EmoteShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -105,10 +105,10 @@ void EmoteShortcutContainer::draw(Graphics *restrict graphics) restrict2
for (unsigned i = 0; i < sz; i++)
{
const EmoteSprite *restrict const emoteImg = mEmoteImg[i];
- if (emoteImg)
+ if (emoteImg != nullptr)
{
const AnimatedSprite *restrict const sprite = emoteImg->sprite;
- if (sprite)
+ if (sprite != nullptr)
{
sprite->draw(graphics,
(i % mGridWidth) * mBoxWidth + 2,
@@ -137,13 +137,13 @@ void EmoteShortcutContainer::draw(Graphics *restrict graphics) restrict2
void EmoteShortcutContainer::safeDraw(Graphics *restrict graphics) restrict2
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
BLOCK_START("EmoteShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -157,10 +157,10 @@ void EmoteShortcutContainer::safeDraw(Graphics *restrict graphics) restrict2
for (unsigned i = 0; i < sz; i++)
{
const EmoteSprite *restrict const emoteImg = mEmoteImg[i];
- if (emoteImg)
+ if (emoteImg != nullptr)
{
const AnimatedSprite *restrict const sprite = emoteImg->sprite;
- if (sprite)
+ if (sprite != nullptr)
{
sprite->draw(graphics,
(i % mGridWidth) * mBoxWidth + 2,
@@ -199,7 +199,7 @@ void EmoteShortcutContainer::mousePressed(MouseEvent &restrict event) restrict2
if (event.getButton() == MouseButton::LEFT)
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -214,14 +214,14 @@ void EmoteShortcutContainer::mousePressed(MouseEvent &restrict event) restrict2
emoteShortcut->setEmote(index);
emoteShortcut->setEmoteSelected(0);
}
- else if (emoteShortcut->getEmote(index))
+ else if (emoteShortcut->getEmote(index) != 0u)
{
mEmoteClicked = true;
}
}
else if (event.getButton() == MouseButton::RIGHT)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
{
event.consume();
popupMenu->showEmoteType();
@@ -232,7 +232,7 @@ void EmoteShortcutContainer::mousePressed(MouseEvent &restrict event) restrict2
void EmoteShortcutContainer::mouseReleased(MouseEvent &restrict event)
restrict2
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -248,12 +248,12 @@ void EmoteShortcutContainer::mouseReleased(MouseEvent &restrict event)
return;
}
- if (mEmoteMoved)
+ if (mEmoteMoved != 0u)
{
emoteShortcut->setEmotes(index, mEmoteMoved);
mEmoteMoved = 0;
}
- else if (emoteShortcut->getEmote(index) && mEmoteClicked)
+ else if ((emoteShortcut->getEmote(index) != 0u) && mEmoteClicked)
{
emoteShortcut->useEmote(index + 1);
}
@@ -264,7 +264,7 @@ void EmoteShortcutContainer::mouseReleased(MouseEvent &restrict event)
void EmoteShortcutContainer::mouseMoved(MouseEvent &restrict event) restrict2
{
- if (!emoteShortcut || !textPopup)
+ if ((emoteShortcut == nullptr) || (textPopup == nullptr))
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -274,7 +274,7 @@ void EmoteShortcutContainer::mouseMoved(MouseEvent &restrict event) restrict2
textPopup->setVisible(Visible_false);
- if (CAST_SIZE(index) < mEmoteImg.size() && mEmoteImg[index])
+ if (CAST_SIZE(index) < mEmoteImg.size() && (mEmoteImg[index] != nullptr))
{
const EmoteSprite *restrict const sprite = mEmoteImg[index];
textPopup->show(viewport->mMouseX, viewport->mMouseY,
@@ -285,13 +285,13 @@ void EmoteShortcutContainer::mouseMoved(MouseEvent &restrict event) restrict2
void EmoteShortcutContainer::mouseExited(MouseEvent &restrict event A_UNUSED)
restrict2
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
void EmoteShortcutContainer::widgetHidden(const Event &restrict event A_UNUSED)
restrict2
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
index 921dfee7f..ebbb07bf3 100644
--- a/src/gui/widgets/extendedlistbox.cpp
+++ b/src/gui/widgets/extendedlistbox.cpp
@@ -35,13 +35,13 @@ ExtendedListBox::ExtendedListBox(const Widget2 *const widget,
const std::string &skin,
const unsigned int rowHeight) :
ListBox(widget, listModel, skin),
- mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0),
- mSpacing(mSkin ? mSkin->getOption("spacing") : 0),
+ mImagePadding(mSkin != nullptr ? mSkin->getOption("imagePadding") : 0),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing") : 0),
mHeight(0),
mListItems(),
mSelectedItems()
{
- if (rowHeight)
+ if (rowHeight != 0u)
mRowHeight = rowHeight;
}
@@ -51,7 +51,7 @@ ExtendedListBox::~ExtendedListBox()
void ExtendedListBox::draw(Graphics *const graphics)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
BLOCK_START("ExtendedListBox::draw")
@@ -81,7 +81,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
int strWidth = font->getWidth(str) + 8;
const Image *const image = model->getImageAt(row);
- if (image)
+ if (image != nullptr)
strWidth += image->getWidth() + mImagePadding;
std::vector<ExtendedListBoxItem> &list =
@@ -145,7 +145,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
if (item.image)
{
const Image *const image = model->getImageAt(row1);
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image,
mImagePadding,
@@ -160,7 +160,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
const int row1 = item.row;
const int y1 = item.y;
const Image *const image = model->getImageAt(row1);
- if (!image || !item.image)
+ if ((image == nullptr) || !item.image)
{
font->drawString(graphics,
mForegroundColor, mForegroundColor2,
@@ -182,7 +182,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
const int row1 = item.row;
const int y1 = item.y;
const Image *const image = model->getImageAt(row1);
- if (!image || !item.image)
+ if ((image == nullptr) || !item.image)
{
font->drawString(graphics,
mForegroundSelectedColor, mForegroundSelectedColor2,
@@ -205,7 +205,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
if (item.image)
{
const Image *const image = model->getImageAt(row1);
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image,
mImagePadding,
@@ -224,7 +224,7 @@ void ExtendedListBox::safeDraw(Graphics *const graphics)
void ExtendedListBox::adjustSize()
{
- if (mHeight)
+ if (mHeight != 0)
setHeight(mHeight + 2 * mPadding);
else
ListBox::adjustSize();
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
index 7f33208c2..ee3181636 100644
--- a/src/gui/widgets/flowcontainer.cpp
+++ b/src/gui/widgets/flowcontainer.cpp
@@ -34,9 +34,9 @@ FlowContainer::FlowContainer(const Widget2 *const widget,
mGridHeight(1)
{
addWidgetListener(this);
- if (!mBoxWidth)
+ if (mBoxWidth == 0)
mBoxWidth = 1;
- if (!mBoxHeight)
+ if (mBoxHeight == 0)
mBoxHeight = 1;
}
@@ -50,7 +50,7 @@ void FlowContainer::widgetResized(const Event &event A_UNUSED)
const int itemCount = CAST_S32(mWidgets.size());
- if (!mBoxWidth)
+ if (mBoxWidth == 0)
mGridWidth = getWidth();
else
mGridWidth = getWidth() / mBoxWidth;
@@ -88,7 +88,7 @@ void FlowContainer::widgetResized(const Event &event A_UNUSED)
void FlowContainer::add(Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index 3c22dd4b1..392755a20 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -69,7 +69,7 @@ GuiTable::GuiTable(const Widget2 *const widget,
GuiTable::~GuiTable()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
uninstallActionListeners();
@@ -83,7 +83,7 @@ const TableModel *GuiTable::getModel() const
void GuiTable::setModel(TableModel *const new_model)
{
- if (mModel)
+ if (mModel != nullptr)
{
uninstallActionListeners();
mModel->removeListener(this);
@@ -98,7 +98,7 @@ void GuiTable::setModel(TableModel *const new_model)
void GuiTable::recomputeDimensions()
{
- if (!mModel)
+ if (mModel == nullptr)
return;
const int rows_nr = mModel->getRows();
@@ -211,7 +211,7 @@ void GuiTable::installActionListeners()
for (int column = 0; column < columns; ++column)
{
Widget *const widget = mModel->getElementAt(row, column);
- if (widget)
+ if (widget != nullptr)
{
mActionListeners2.push_back(new GuiTableActionListener(
this, widget, row, column));
@@ -225,7 +225,7 @@ void GuiTable::installActionListeners()
// -- widget ops
void GuiTable::draw(Graphics *const graphics)
{
- if (!getRowHeight())
+ if (getRowHeight() == 0)
return;
BLOCK_START("GuiTable::draw")
@@ -246,7 +246,7 @@ void GuiTable::draw(Graphics *const graphics)
// First, determine how many rows we need to draw,
// and where we should start.
int rHeight = getRowHeight();
- if (!rHeight)
+ if (rHeight == 0)
rHeight = 1;
int first_row = -(y / rHeight);
@@ -288,7 +288,7 @@ void GuiTable::draw(Graphics *const graphics)
CAST_S32(c));
const int cWidth = CAST_S32(getColumnWidth(
CAST_S32(c)));
- if (widget)
+ if (widget != nullptr)
{
Rect bounds(x_offset, y_offset, cWidth, rHeight);
@@ -331,7 +331,7 @@ void GuiTable::draw(Graphics *const graphics)
y_offset += rHeight;
}
- if (mTopWidget)
+ if (mTopWidget != nullptr)
{
const Rect &bounds = mTopWidget->getDimension();
graphics->pushClipArea(bounds);
@@ -343,7 +343,7 @@ void GuiTable::draw(Graphics *const graphics)
void GuiTable::safeDraw(Graphics *const graphics)
{
- if (!getRowHeight())
+ if (getRowHeight() == 0)
return;
BLOCK_START("GuiTable::draw")
@@ -364,7 +364,7 @@ void GuiTable::safeDraw(Graphics *const graphics)
// First, determine how many rows we need to draw,
// and where we should start.
int rHeight = getRowHeight();
- if (!rHeight)
+ if (rHeight == 0)
rHeight = 1;
int first_row = -(y / rHeight);
@@ -406,7 +406,7 @@ void GuiTable::safeDraw(Graphics *const graphics)
CAST_S32(c));
const int cWidth = CAST_S32(getColumnWidth(
CAST_S32(c)));
- if (widget)
+ if (widget != nullptr)
{
Rect bounds(x_offset, y_offset, cWidth, rHeight);
@@ -449,7 +449,7 @@ void GuiTable::safeDraw(Graphics *const graphics)
y_offset += rHeight;
}
- if (mTopWidget)
+ if (mTopWidget != nullptr)
{
const Rect &bounds = mTopWidget->getDimension();
graphics->pushClipArea(bounds);
@@ -513,7 +513,7 @@ void GuiTable::keyPressed(KeyEvent& event)
setSelectedColumn(0);
event.consume();
}
- else if (action == InputAction::GUI_END && mModel)
+ else if (action == InputAction::GUI_END && (mModel != nullptr))
{
setSelectedRow(mModel->getRows() - 1);
setSelectedColumn(mModel->getColumns() - 1);
@@ -596,13 +596,16 @@ Widget *GuiTable::getWidgetAt(int x, int y)
const int row = getRowForY(y);
const int column = getColumnForX(x);
- if (mTopWidget && mTopWidget->getDimension().isPointInRect(x, y))
+ if (mTopWidget != nullptr &&
+ mTopWidget->getDimension().isPointInRect(x, y))
+ {
return mTopWidget;
+ }
- if (mModel && row > -1 && column > -1)
+ if ((mModel != nullptr) && row > -1 && column > -1)
{
Widget *const w = mModel->getElementAt(row, column);
- if (w && w->isFocusable())
+ if ((w != nullptr) && w->isFocusable())
return w;
else
return nullptr; // Grab the event locally
@@ -648,7 +651,7 @@ void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
{
// add check for focusHandler. may be need remove it?
- if (!focusHandler)
+ if (focusHandler == nullptr)
return;
Widget::setFocusHandler(focusHandler);
@@ -660,7 +663,7 @@ void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
for (int c = 0; c < cols ; ++c)
{
Widget *const w = mModel->getElementAt(r, c);
- if (w)
+ if (w != nullptr)
w->setFocusHandler(focusHandler);
}
}
@@ -668,7 +671,7 @@ void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
void GuiTable::requestFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
Widget::requestFocus();
}
diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp
index 5b3b08d16..8a026329a 100644
--- a/src/gui/widgets/horizontcontainer.cpp
+++ b/src/gui/widgets/horizontcontainer.cpp
@@ -45,7 +45,7 @@ void HorizontContainer::add(Widget *const widget)
void HorizontContainer::add(Widget *const widget, const int spacing)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 8cb43db6d..dbe46a21a 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -39,7 +39,7 @@ Icon::Icon(const Widget2 *const widget,
mImage(Loader::getImage(file)),
mAutoRelease(autoRelease)
{
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &bounds = mImage->mBounds;
setSize(bounds.w, bounds.h);
@@ -54,7 +54,7 @@ Icon::Icon(const Widget2 *const widget,
mImage(image),
mAutoRelease(autoRelease)
{
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &bounds = mImage->mBounds;
setSize(bounds.w, bounds.h);
@@ -64,16 +64,16 @@ Icon::Icon(const Widget2 *const widget,
Icon::~Icon()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (mImage && mAutoRelease == AutoRelease_true)
+ if ((mImage != nullptr) && mAutoRelease == AutoRelease_true)
mImage->decRef();
}
void Icon::setImage(Image *const image)
{
mImage = image;
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &bounds = mImage->mBounds;
setSize(bounds.w, bounds.h);
@@ -83,7 +83,7 @@ void Icon::setImage(Image *const image)
void Icon::draw(Graphics *const graphics)
{
BLOCK_START("Icon::draw")
- if (mImage)
+ if (mImage != nullptr)
{
graphics->drawImage(mImage,
(mDimension.width - mImage->mBounds.w) / 2,
@@ -95,7 +95,7 @@ void Icon::draw(Graphics *const graphics)
void Icon::safeDraw(Graphics *const graphics)
{
BLOCK_START("Icon::draw")
- if (mImage)
+ if (mImage != nullptr)
{
graphics->drawImage(mImage,
(mDimension.width - mImage->mBounds.w) / 2,
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 857467f63..15e2df093 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -88,7 +88,7 @@ namespace
{
const Item *const item1 = pair1->mItem;
const Item *const item2 = pair2->mItem;
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const std::string name1 = item1->getInfo().getName(
@@ -112,7 +112,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const int id1 = pair1->mItem->getId();
@@ -134,7 +134,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const int w1 = pair1->mItem->getInfo().getWeight();
@@ -164,7 +164,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const int c1 = pair1->mItem->getQuantity();
@@ -194,7 +194,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const ItemInfo &info1 = pair1->mItem->getInfo();
@@ -232,7 +232,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
mCellBackgroundImg(Theme::getImageFromThemeXml("inventory_cell.xml", "")),
mName(),
mShowMatrix(nullptr),
- mSkin(theme ? theme->load("itemcontainer.xml", "") : nullptr),
+ mSkin(theme != nullptr ? theme->load("itemcontainer.xml", "") : nullptr),
mVertexes(new ImageCollection),
mEquipedColor(getThemeColor(ThemeColorId::ITEM_EQUIPPED)),
mEquipedColor2(getThemeColor(ThemeColorId::ITEM_EQUIPPED_OUTLINE)),
@@ -246,12 +246,12 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
mTag(0),
mSortType(0),
mClicks(1),
- mBoxWidth(mSkin ? mSkin->getOption("boxWidth", 35) : 35),
- mBoxHeight(mSkin ? mSkin->getOption("boxHeight", 43) : 43),
- mEquippedTextPadding(mSkin ? mSkin->getOption(
+ mBoxWidth(mSkin != nullptr ? mSkin->getOption("boxWidth", 35) : 35),
+ mBoxHeight(mSkin != nullptr ? mSkin->getOption("boxHeight", 43) : 43),
+ mEquippedTextPadding(mSkin != nullptr ? mSkin->getOption(
"equippedTextPadding", 29) : 29),
- mPaddingItemX(mSkin ? mSkin->getOption("paddingItemX", 0) : 0),
- mPaddingItemY(mSkin ? mSkin->getOption("paddingItemY", 0) : 0),
+ mPaddingItemX(mSkin != nullptr ? mSkin->getOption("paddingItemX", 0) : 0),
+ mPaddingItemY(mSkin != nullptr ? mSkin->getOption("paddingItemY", 0) : 0),
mMaxColumns(maxColumns),
mSelectionStatus(SEL_NONE),
mForceQuantity(forceQuantity),
@@ -267,26 +267,26 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
ItemContainer::~ItemContainer()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (mSelImg)
+ if (mSelImg != nullptr)
{
mSelImg->decRef();
mSelImg = nullptr;
}
- if (mProtectedImg)
+ if (mProtectedImg != nullptr)
{
mProtectedImg->decRef();
mProtectedImg = nullptr;
}
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
{
mCellBackgroundImg->decRef();
mCellBackgroundImg = nullptr;
}
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
delete []mShowMatrix;
@@ -298,7 +298,7 @@ void ItemContainer::logic()
BLOCK_START("ItemContainer::logic")
Widget::logic();
- if (!mInventory)
+ if (mInventory == nullptr)
{
BLOCK_END("ItemContainer::logic")
return;
@@ -316,13 +316,13 @@ void ItemContainer::logic()
void ItemContainer::draw(Graphics *const graphics)
{
- if (!mInventory || !mShowMatrix)
+ if ((mInventory == nullptr) || (mShowMatrix == nullptr))
return;
BLOCK_START("ItemContainer::draw")
Font *const font = getFont();
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
{
if (mRedraw || graphics->getRedraw())
{
@@ -367,22 +367,22 @@ void ItemContainer::draw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
if (mShowMatrix[itemIndex] == mSelectedIndex)
{
- if (mSelImg)
+ if (mSelImg != nullptr)
graphics->drawImage(mSelImg, itemX, itemY);
}
image->setAlpha(1.0F); // ensure the image if fully drawn...
graphics->drawImage(image,
itemX + mPaddingItemX,
itemY + mPaddingItemY);
- if (mProtectedImg && PlayerInfo::isItemProtected(
+ if ((mProtectedImg != nullptr) && PlayerInfo::isItemProtected(
item->getId()))
{
graphics->drawImage(mProtectedImg,
@@ -408,7 +408,7 @@ void ItemContainer::draw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
// Draw item caption
@@ -447,13 +447,13 @@ void ItemContainer::draw(Graphics *const graphics)
void ItemContainer::safeDraw(Graphics *const graphics)
{
- if (!mInventory || !mShowMatrix)
+ if ((mInventory == nullptr) || (mShowMatrix == nullptr))
return;
BLOCK_START("ItemContainer::draw")
Font *const font = getFont();
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
{
const int invSize = mInventory->getSize();
const int maxRows = mShowEmptyRows == ShowEmptyRows_true ?
@@ -489,22 +489,22 @@ void ItemContainer::safeDraw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
if (mShowMatrix[itemIndex] == mSelectedIndex)
{
- if (mSelImg)
+ if (mSelImg != nullptr)
graphics->drawImage(mSelImg, itemX, itemY);
}
image->setAlpha(1.0F); // ensure the image if fully drawn...
graphics->drawImage(image,
itemX + mPaddingItemX,
itemY + mPaddingItemY);
- if (mProtectedImg && PlayerInfo::isItemProtected(
+ if ((mProtectedImg != nullptr) && PlayerInfo::isItemProtected(
item->getId()))
{
graphics->drawImage(mProtectedImg,
@@ -530,7 +530,7 @@ void ItemContainer::safeDraw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
// Draw item caption
@@ -592,7 +592,7 @@ void ItemContainer::setSelectedIndex(const int newIndex)
Item *ItemContainer::getSelectedItem() const
{
- if (mInventory)
+ if (mInventory != nullptr)
return mInventory->getItem(mSelectedIndex);
else
return nullptr;
@@ -602,7 +602,7 @@ void ItemContainer::distributeValueChangedEvent()
{
FOR_EACH (SelectionListenerIterator, i, mSelectionListeners)
{
- if (*i)
+ if (*i != nullptr)
{
SelectionEvent event(this);
(*i)->valueChanged(event);
@@ -620,7 +620,7 @@ void ItemContainer::keyReleased(KeyEvent &event A_UNUSED)
void ItemContainer::mousePressed(MouseEvent &event)
{
- if (!mInventory)
+ if (mInventory == nullptr)
return;
const MouseButtonT button = event.getButton();
@@ -636,7 +636,7 @@ void ItemContainer::mousePressed(MouseEvent &event)
Item *const item = mInventory->getItem(index);
// put item name into chat window
- if (item && mDescItems && chatWindow)
+ if ((item != nullptr) && mDescItems && (chatWindow != nullptr))
chatWindow->addItemText(item->getInfo().getName());
DragDropSourceT src = DragDropSource::Empty;
@@ -674,7 +674,7 @@ void ItemContainer::mousePressed(MouseEvent &event)
dragDrop.select(item);
mSelectionStatus = SEL_DESELECTING;
}
- else if (item && item->getId())
+ else if ((item != nullptr) && (item->getId() != 0))
{
if (index >= 0)
{
@@ -683,16 +683,16 @@ void ItemContainer::mousePressed(MouseEvent &event)
setSelectedIndex(index);
mSelectionStatus = SEL_SELECTING;
- if (itemShortcutWindow)
+ if (itemShortcutWindow != nullptr)
{
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS))
{
- if (itemShortcut[num])
+ if (itemShortcut[num] != nullptr)
itemShortcut[num]->setItemSelected(item);
}
}
- if (shopWindow)
+ if (shopWindow != nullptr)
shopWindow->setItemSelected(item->getId());
}
}
@@ -712,8 +712,12 @@ void ItemContainer::mouseDragged(MouseEvent &event A_UNUSED)
void ItemContainer::mouseReleased(MouseEvent &event)
{
- if (mClicks == 2 || !inventoryHandler || !tradeHandler)
+ if (mClicks == 2 ||
+ inventoryHandler == nullptr ||
+ tradeHandler == nullptr)
+ {
return;
+ }
switch (mSelectionStatus)
{
@@ -742,7 +746,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
inventoryHandler->moveItem(mSelectedIndex, index);
selectNone();
}
- else if (mInventory)
+ else if (mInventory != nullptr)
{
const DragDropSourceT src = dragDrop.getSource();
DragDropSourceT dst = DragDropSource::Empty;
@@ -809,7 +813,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
return;
if (index == mSelectedIndex || mSelectedIndex == -1)
return;
- if (inventoryWindow)
+ if (inventoryWindow != nullptr)
inventoryWindow->combineItems(index, mSelectedIndex);
return;
}
@@ -845,7 +849,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
|| dst == DragDropSource::Mail))
{
inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
{
Item *const item = inventory->getItem(dragDrop.getTag());
if (mInventory->addVirtualItem(
@@ -868,7 +872,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
const int index = getSlotByXY(event.getX(), event.getY());
if (index == Inventory::NO_SLOT_INDEX)
{
- if (inventory)
+ if (inventory != nullptr)
inventory->virtualRestore(item, 1);
mInventory->removeItemAt(dragDrop.getTag());
return;
@@ -886,17 +890,17 @@ void ItemContainer::mouseReleased(MouseEvent &event)
Equipm_false,
Equipped_false);
Item *const item2 = mInventory->getItem(index);
- if (item2)
+ if (item2 != nullptr)
item2->setTag(item->getTag());
mInventory->removeItemAt(dragDrop.getTag());
}
else
{
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(
dragDrop.getTag());
- if (item)
+ if (item != nullptr)
{
inventory->virtualRestore(item, 1);
mInventory->removeItemAt(dragDrop.getTag());
@@ -909,10 +913,10 @@ void ItemContainer::mouseReleased(MouseEvent &event)
dst == DragDropSource::Craft)
{
inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
{
Item *const item = inventory->getItem(dragDrop.getTag());
- if (!item || item->isEquipped() == Equipped_true)
+ if ((item == nullptr) || item->isEquipped() == Equipped_true)
return;
const int slot = getSlotByXY(event.getX(), event.getY());
if (item->getQuantity() > 1
@@ -948,7 +952,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
const int index = getSlotByXY(event.getX(), event.getY());
if (index == Inventory::NO_SLOT_INDEX)
{
- if (inventory)
+ if (inventory != nullptr)
{
inventory->virtualRestore(item,
item->getQuantity());
@@ -960,11 +964,11 @@ void ItemContainer::mouseReleased(MouseEvent &event)
}
else
{
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(
dragDrop.getTag());
- if (item)
+ if (item != nullptr)
{
inventory->virtualRestore(item,
item->getQuantity());
@@ -977,19 +981,19 @@ void ItemContainer::mouseReleased(MouseEvent &event)
else if (src == DragDropSource::Mail)
{
inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(dragDrop.getTag());
- if (item)
+ if (item != nullptr)
mInventory->removeItemAt(dragDrop.getTag());
}
return;
}
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(dragDrop.getTag());
- if (item)
+ if (item != nullptr)
{
if (srcContainer != InventoryType::TypeEnd)
{ // inventory <--> storage, cart
@@ -1013,13 +1017,13 @@ void ItemContainer::mouseReleased(MouseEvent &event)
void ItemContainer::mouseMoved(MouseEvent &event)
{
- if (!mInventory)
+ if (mInventory == nullptr)
return;
const Item *const item = mInventory->getItem(
getSlotIndex(event.getX(), event.getY()));
- if (item && viewport)
+ if ((item != nullptr) && (viewport != nullptr))
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -1057,7 +1061,7 @@ void ItemContainer::widgetMoved(const Event &event A_UNUSED)
void ItemContainer::adjustHeight()
{
- if (!mGridColumns)
+ if (mGridColumns == 0)
return;
mGridRows = (mLastUsedSlot + 1) / mGridColumns;
@@ -1081,7 +1085,7 @@ void ItemContainer::adjustHeight()
void ItemContainer::updateMatrix()
{
- if (!mInventory)
+ if (mInventory == nullptr)
return;
mRedraw = true;
@@ -1100,7 +1104,9 @@ void ItemContainer::updateMatrix()
{
Item *const item = mInventory->getItem(idx);
- if (!item || item->getId() == 0 || !item->isHaveTag(mTag))
+ if (item == nullptr ||
+ item->getId() == 0 ||
+ !item->isHaveTag(mTag))
{
if (mShowEmptyRows == ShowEmptyRows_true)
sortedItems.push_back(new ItemIdPair(idx, nullptr));
@@ -1174,7 +1180,7 @@ void ItemContainer::updateMatrix()
int ItemContainer::getSlotIndex(int x, int y) const
{
- if (!mShowMatrix)
+ if (mShowMatrix == nullptr)
return Inventory::NO_SLOT_INDEX;
if (x < mDimension.width && y < mDimension.height && x >= 0 && y >= 0)
@@ -1194,7 +1200,7 @@ int ItemContainer::getSlotIndex(int x, int y) const
int ItemContainer::getSlotByXY(int x, int y) const
{
- if (!mShowMatrix)
+ if (mShowMatrix == nullptr)
return Inventory::NO_SLOT_INDEX;
if (x < mDimension.width && y < mDimension.height && x >= 0 && y >= 0)
@@ -1223,7 +1229,7 @@ void ItemContainer::setSortType(const int sortType)
void ItemContainer::setCellBackgroundImage(const std::string &xmlName)
{
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
mCellBackgroundImg->decRef();
mCellBackgroundImg = Theme::getImageFromThemeXml(xmlName, "");
mRedraw = true;
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index 2d732ad3c..ba640d374 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -126,7 +126,7 @@ class ItemContainer final : public Widget,
void updateMatrix();
bool getClickCount() const noexcept2 A_WARN_UNUSED
- { return mClicks; }
+ { return mClicks != 0; }
void unsetInventory() noexcept2
{ mInventory = nullptr; }
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 90a26a4a0..295e41d16 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -95,7 +95,7 @@ void ItemLinkHandler::handleCommandLink(const std::string &link,
void ItemLinkHandler::handleHelpLink(const std::string &link)
{
- if (helpWindow)
+ if (helpWindow != nullptr)
{
helpWindow->loadHelp(link.substr(7));
helpWindow->requestMoveToTop();
@@ -105,7 +105,7 @@ void ItemLinkHandler::handleHelpLink(const std::string &link)
void ItemLinkHandler::handleHttpLink(const std::string &link,
const MouseEvent *const event)
{
- if (!event)
+ if (event == nullptr)
return;
std::string url = link;
replaceAll(url, " ", "");
@@ -124,14 +124,14 @@ void ItemLinkHandler::handleHttpLink(const std::string &link,
}
else if (button == MouseButton::RIGHT)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->showLinkPopup(url);
}
}
void ItemLinkHandler::handleItemLink(const std::string &link)
{
- if (!itemPopup || link.empty())
+ if ((itemPopup == nullptr) || link.empty())
return;
const char ch = link[0];
@@ -160,7 +160,7 @@ void ItemLinkHandler::handleItemLink(const std::string &link)
{
itemPopup->setVisible(Visible_false);
}
- else if (viewport)
+ else if (viewport != nullptr)
{
itemPopup->position(viewport->mMouseX,
viewport->mMouseY);
@@ -170,7 +170,7 @@ void ItemLinkHandler::handleItemLink(const std::string &link)
void ItemLinkHandler::handleSearchLink(const std::string &link)
{
- if (helpWindow)
+ if (helpWindow != nullptr)
{
helpWindow->search(link.substr(1));
helpWindow->requestMoveToTop();
@@ -205,7 +205,7 @@ void ItemLinkHandler::handleLink(const std::string &link,
}
else if (link == "news")
{
- if (helpWindow)
+ if (helpWindow != nullptr)
helpWindow->loadHelpSimple("news");
}
else if (link == "copyright")
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 424986efe..400ae0d88 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -63,7 +63,7 @@ ItemShortcutContainer::ItemShortcutContainer(Widget2 *const widget,
mUnEquipedColor(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED)),
mUnEquipedColor2(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE))
{
- if (itemShortcut[mNumber])
+ if (itemShortcut[mNumber] != nullptr)
mMaxItems = itemShortcut[mNumber]->getItemCount();
else
mMaxItems = 0;
@@ -88,7 +88,7 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
{
BLOCK_START("ItemShortcutContainer::draw")
const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -96,7 +96,7 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -105,7 +105,7 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
drawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -136,11 +136,11 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
if (itemId < SPELL_MIN_ID)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -171,17 +171,17 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
}
}
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{ // this is magic shortcut
const TextCommand *const spell = spellManager
->getSpellByItem(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -195,15 +195,15 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
itemX + 2, itemY + mBoxHeight / 2);
}
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
const SkillInfo *const skill = skillDialog->getSkill(
itemId - SKILL_MIN_ID);
- if (skill)
+ if (skill != nullptr)
{
Image *const image = skill->data->icon;
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -225,7 +225,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
{
BLOCK_START("ItemShortcutContainer::draw")
const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -233,7 +233,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -242,7 +242,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
safeDrawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -273,11 +273,11 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
if (itemId < SPELL_MIN_ID)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -308,17 +308,17 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
}
}
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{ // this is magic shortcut
const TextCommand *const spell = spellManager
->getSpellByItem(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -332,15 +332,15 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
itemX + 2, itemY + mBoxHeight / 2);
}
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
const SkillInfo *const skill = skillDialog->getSkill(
itemId - SKILL_MIN_ID);
- if (skill)
+ if (skill != nullptr)
{
Image *const image = skill->data->icon;
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -361,7 +361,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
void ItemShortcutContainer::mouseDragged(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -383,13 +383,13 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
event.consume();
if (itemId < SPELL_MIN_ID)
{ // items
- if (!PlayerInfo::getInventory())
+ if (PlayerInfo::getInventory() == nullptr)
return;
const Item *const item = PlayerInfo::getInventory()->findItem(
itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
selShortcut->removeItem(index);
dragDrop.dragItem(item, DragDropSource::Shortcuts, index);
@@ -401,7 +401,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
}
else if (itemId < SKILL_MIN_ID)
{ // spells/commands
- if (!spellManager)
+ if (spellManager == nullptr)
{
dragDrop.clear();
return;
@@ -409,7 +409,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
const TextCommand *const spell = spellManager->getSpellByItem(
itemId);
- if (spell)
+ if (spell != nullptr)
{
selShortcut->removeItem(index);
dragDrop.dragCommand(spell,
@@ -423,14 +423,14 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
}
else
{ // skills
- if (!skillDialog)
+ if (skillDialog == nullptr)
{
dragDrop.clear();
return;
}
const SkillInfo *const skill
= skillDialog->getSkillByItem(itemId);
- if (skill)
+ if (skill != nullptr)
{
const std::string itemData = selShortcut->getItemData(
index);
@@ -454,7 +454,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
void ItemShortcutContainer::mousePressed(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -466,17 +466,17 @@ void ItemShortcutContainer::mousePressed(MouseEvent &event)
{
event.consume();
// Stores the selected item if theirs one.
- if (selShortcut->isItemSelected() && inventoryWindow &&
+ if (selShortcut->isItemSelected() && (inventoryWindow != nullptr) &&
(inventoryWindow->isWindowVisible()
|| selShortcut->getSelectedItem() >= SPELL_MIN_ID))
{
selShortcut->setItem(index);
selShortcut->setItemSelected(-1);
- if (spellShortcut)
+ if (spellShortcut != nullptr)
spellShortcut->setItemSelected(-1);
inventoryWindow->unselectItem();
}
- else if (selShortcut->getItem(index))
+ else if (selShortcut->getItem(index) != 0)
{
mItemClicked = true;
}
@@ -484,7 +484,9 @@ void ItemShortcutContainer::mousePressed(MouseEvent &event)
else if (event.getButton() == MouseButton::RIGHT)
{
event.consume();
- if (popupMenu && selShortcut && viewport)
+ if (popupMenu != nullptr &&
+ selShortcut != nullptr &&
+ viewport != nullptr)
{
popupMenu->showItemPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -497,7 +499,7 @@ void ItemShortcutContainer::mousePressed(MouseEvent &event)
void ItemShortcutContainer::mouseReleased(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -511,7 +513,7 @@ void ItemShortcutContainer::mouseReleased(MouseEvent &event)
if (dragDrop.isEmpty())
{
- if (selShortcut->getItem(index) && mItemClicked)
+ if ((selShortcut->getItem(index) != 0) && mItemClicked)
selShortcut->useItem(index);
}
else
@@ -541,7 +543,7 @@ void ItemShortcutContainer::mouseReleased(MouseEvent &event)
void ItemShortcutContainer::mouseMoved(MouseEvent &event)
{
const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -561,11 +563,11 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
spellPopup->setVisible(Visible_false);
Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const Item *const item = inv->findItem(itemId, itemColor);
- if (item && viewport)
+ if ((item != nullptr) && (viewport != nullptr))
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -575,12 +577,12 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
itemPopup->setVisible(Visible_false);
}
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{
skillPopup->setVisible(Visible_false);
itemPopup->setVisible(Visible_false);
const TextCommand *const spell = spellManager->getSpellByItem(itemId);
- if (spell && viewport)
+ if ((spell != nullptr) && (viewport != nullptr))
{
spellPopup->setItem(spell);
spellPopup->view(viewport->mMouseX,
@@ -591,12 +593,12 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
spellPopup->setVisible(Visible_false);
}
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
itemPopup->setVisible(Visible_false);
spellPopup->setVisible(Visible_false);
const SkillInfo *const skill = skillDialog->getSkillByItem(itemId);
- if (!skill)
+ if (skill == nullptr)
return;
const std::string data = selShortcut->getItemData(index);
@@ -629,18 +631,18 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
// Hide ItemTooltip
void ItemShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
- if (skillPopup)
+ if (skillPopup != nullptr)
skillPopup->setVisible(Visible_false);
}
void ItemShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 52fdbd716..aeacddbdb 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -106,16 +106,16 @@ Label::Label(const Widget2 *const widget,
Label::~Label()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances --;
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
removeMouseListener(this);
@@ -130,12 +130,12 @@ void Label::init()
mForegroundColor2 = getThemeColor(ThemeColorId::LABEL_OUTLINE);
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load("label.xml", "");
}
mInstances ++;
- if (mSkin)
+ if (mSkin != nullptr)
mPadding = mSkin->getPadding();
else
mPadding = 0;
@@ -179,7 +179,7 @@ void Label::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, textX, textY);
BLOCK_END("Label::draw")
}
@@ -262,14 +262,14 @@ void Label::setCaption(const std::string& caption)
void Label::setParent(Widget *const widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
void Label::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/layoutarray.cpp b/src/gui/widgets/layoutarray.cpp
index 7bd6ff34f..de9c8cd30 100644
--- a/src/gui/widgets/layoutarray.cpp
+++ b/src/gui/widgets/layoutarray.cpp
@@ -61,15 +61,15 @@ LayoutCell &LayoutArray::at(const int x, const int y,
{
resizeGrid(x + w, y + h);
LayoutCell *&cell = mCells[CAST_SIZE(y)][static_cast<size_t>(x)];
- if (!cell)
+ if (cell == nullptr)
cell = new LayoutCell;
return *cell;
}
void LayoutArray::resizeGrid(int w, const int h)
{
- const bool extW = w && w > CAST_S32(mSizes[0].size());
- const bool extH = h && h > CAST_S32(mSizes[1].size());
+ const bool extW = (w != 0) && w > CAST_S32(mSizes[0].size());
+ const bool extH = (h != 0) && h > CAST_S32(mSizes[1].size());
if (!extW && !extH)
return;
@@ -132,7 +132,7 @@ LayoutCell &LayoutArray::place(Widget *const widget, const int x,
assert(cell.mType == LayoutCell::NONE);
cell.mType = LayoutCell::WIDGET;
cell.mWidget = widget;
- if (widget)
+ if (widget != nullptr)
{
cell.mSize[0] = w == 1 ? widget->getWidth() : 0;
cell.mSize[1] = h == 1 ? widget->getHeight() : 0;
@@ -166,7 +166,7 @@ void LayoutArray::align(int &restrict pos, int &restrict size, const int dim,
return;
int size_max = sizes[0];
int cnt = cell.mExtent[dim];
- if (sizeCount && cell.mExtent[dim] > sizeCount)
+ if ((sizeCount != 0) && cell.mExtent[dim] > sizeCount)
cnt = sizeCount;
for (int i = 1; i < cnt; ++i)
@@ -208,7 +208,7 @@ std::vector<int> LayoutArray::getSizes(const int dim, int upp) const
{
const LayoutCell *const cell = mCells[CAST_SIZE(gridY)]
[CAST_SIZE(gridX)];
- if (!cell || cell->mType == LayoutCell::NONE)
+ if ((cell == nullptr) || cell->mType == LayoutCell::NONE)
continue;
if (cell->mExtent[dim] == 1)
@@ -297,7 +297,7 @@ void LayoutArray::reflow(const int nx, const int ny,
{
LayoutCell *const cell = mCells[CAST_SIZE(gridY)]
[CAST_SIZE(gridX)];
- if (cell && cell->mType != LayoutCell::NONE)
+ if ((cell != nullptr) && cell->mType != LayoutCell::NONE)
{
int dx = x, dy = y, dw = 0, dh = 0;
align(dx, dw, 0, *cell,
diff --git a/src/gui/widgets/layoutcell.cpp b/src/gui/widgets/layoutcell.cpp
index 21efd4818..b898b1dfc 100644
--- a/src/gui/widgets/layoutcell.cpp
+++ b/src/gui/widgets/layoutcell.cpp
@@ -44,7 +44,7 @@ LayoutArray &LayoutCell::getArray()
return tempArray;
if (mType == ARRAY)
{
- if (!mArray)
+ if (mArray == nullptr)
return tempArray;
return *mArray;
}
@@ -90,7 +90,7 @@ void LayoutCell::computeSizes()
while (j != i->end())
{
LayoutCell *const cell = *j;
- if (cell && cell->mType == ARRAY)
+ if ((cell != nullptr) && cell->mType == ARRAY)
cell->computeSizes();
++j;
diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp
index 2de26dbab..19114c1ae 100644
--- a/src/gui/widgets/layouthelper.cpp
+++ b/src/gui/widgets/layouthelper.cpp
@@ -32,13 +32,13 @@ LayoutHelper::LayoutHelper(BasicContainer2 *const container) :
mLayout(),
mContainer(container)
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->addWidgetListener(this);
}
LayoutHelper::~LayoutHelper()
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->removeWidgetListener(this);
}
@@ -51,7 +51,7 @@ LayoutCell &LayoutHelper::place(const int x, const int y,
Widget *const wg,
const int w, const int h)
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->add(wg);
return mLayout.place(wg, x, y, w, h);
}
@@ -64,13 +64,13 @@ ContainerPlacer LayoutHelper::getPlacer(const int x, const int y)
void LayoutHelper::reflowLayout(int w, int h)
{
mLayout.reflow(w, h);
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->setSize(w, h);
}
void LayoutHelper::widgetResized(const Event &event A_UNUSED)
{
- if (!mContainer)
+ if (mContainer == nullptr)
return;
const Rect area = mContainer->getChildrenArea();
int w = area.width;
diff --git a/src/gui/widgets/linepart.cpp b/src/gui/widgets/linepart.cpp
index 0f9403c85..2e1cab392 100644
--- a/src/gui/widgets/linepart.cpp
+++ b/src/gui/widgets/linepart.cpp
@@ -27,7 +27,7 @@
LinePart::~LinePart()
{
- if (mImage)
+ if (mImage != nullptr)
mImage->decRef();
mImage = nullptr;
}
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 0095baf1f..9628c2764 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -114,10 +114,10 @@ ListBox::ListBox(const Widget2 *const widget,
mForegroundColor = getThemeColor(ThemeColorId::LISTBOX);
mForegroundColor2 = getThemeColor(ThemeColorId::LISTBOX_OUTLINE);
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load(skin, "listbox.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mItemPadding = mSkin->getOption("itemPadding");
@@ -135,10 +135,10 @@ void ListBox::postInit()
ListBox::~ListBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
@@ -153,7 +153,7 @@ void ListBox::updateAlpha()
void ListBox::draw(Graphics *const graphics)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
BLOCK_START("ListBox::draw")
@@ -245,9 +245,15 @@ void ListBox::keyPressed(KeyEvent &event)
else if (action == InputAction::GUI_UP)
{
if (mSelected > 0)
+ {
setSelected(mSelected - 1);
- else if (mSelected == 0 && mWrappingEnabled && getListModel())
+ }
+ else if (mSelected == 0 &&
+ mWrappingEnabled &&
+ getListModel() != nullptr)
+ {
setSelected(getListModel()->getNumberOfElements() - 1);
+ }
event.consume();
}
else if (action == InputAction::GUI_DOWN)
@@ -264,7 +270,7 @@ void ListBox::keyPressed(KeyEvent &event)
setSelected(0);
event.consume();
}
- else if (action == InputAction::GUI_END && getListModel())
+ else if (action == InputAction::GUI_END && (getListModel() != nullptr))
{
setSelected(getListModel()->getNumberOfElements() - 1);
event.consume();
@@ -311,7 +317,7 @@ void ListBox::mouseReleased(MouseEvent &event)
mOldSelected = mSelected;
break;
case 2:
- if (gui)
+ if (gui != nullptr)
gui->resetClickCount();
if (mOldSelected == mSelected)
mouseReleased1(event);
@@ -343,13 +349,13 @@ void ListBox::mouseDragged(MouseEvent &event)
return;
// Make list selection update on drag, but guard against negative y
- if (getRowHeight())
+ if (getRowHeight() != 0u)
setSelected(std::max(0, getSelectionByMouse(event.getY())));
}
void ListBox::refocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
if (isFocusable())
@@ -359,7 +365,7 @@ void ListBox::refocus()
void ListBox::adjustSize()
{
BLOCK_START("ListBox::adjustSize")
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(CAST_S32(getRowHeight()) *
mListModel->getNumberOfElements() + 2 * mPadding);
@@ -383,7 +389,7 @@ int ListBox::getSelectionByMouse(const int y) const
void ListBox::setSelected(const int selected)
{
- if (!mListModel)
+ if (mListModel == nullptr)
{
mSelected = -1;
}
diff --git a/src/gui/widgets/passwordfield.cpp b/src/gui/widgets/passwordfield.cpp
index 7400ffd76..bc2ca4827 100644
--- a/src/gui/widgets/passwordfield.cpp
+++ b/src/gui/widgets/passwordfield.cpp
@@ -29,7 +29,7 @@
PasswordField::PasswordField(const Widget2 *const widget,
const std::string &text) :
TextField(widget, text),
- mPasswordChar(mSkin ? CAST_8(
+ mPasswordChar(mSkin != nullptr ? CAST_8(
mSkin->getOption("passwordChar", 42))
: CAST_8(42))
{
@@ -40,7 +40,7 @@ void PasswordField::draw(Graphics *const graphics)
BLOCK_START("PasswordField::draw")
// std::string uses cow, thus cheap copy
const std::string original = mText;
- if (mPasswordChar)
+ if (mPasswordChar != 0)
mText.assign(mText.length(), mPasswordChar);
else
mText.clear();
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 47221af1f..b6217383f 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -76,7 +76,7 @@ PlayerBox::PlayerBox(Widget2 *const widget,
PlayerBox::~PlayerBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
Theme::unloadRect(mBackground);
@@ -90,13 +90,13 @@ void PlayerBox::init(std::string name, std::string selectedName)
setFrameSize(2);
addMouseListener(this);
- if (theme)
+ if (theme != nullptr)
{
if (name.empty())
name = "playerbox.xml";
mSkin = theme->loadSkinRect(mBackground,
name, "playerbox_background.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
mDrawBackground = (mSkin->getOption("drawbackground") != 0);
mOffsetX = mSkin->getOption("offsetX", -mapTileSize / 2);
@@ -120,7 +120,7 @@ void PlayerBox::init(std::string name, std::string selectedName)
void PlayerBox::draw(Graphics *const graphics)
{
BLOCK_START("PlayerBox::draw")
- if (mBeing)
+ if (mBeing != nullptr)
{
const int bs = mFrameSize;
const int x = mDimension.width / 2 + bs + mOffsetX;
@@ -133,7 +133,7 @@ void PlayerBox::draw(Graphics *const graphics)
const float alpha = settings.guiAlpha;
for (int a = 0; a < 9; a++)
{
- if (mBackground.grid[a])
+ if (mBackground.grid[a] != nullptr)
mBackground.grid[a]->setAlpha(alpha);
}
}
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 978e5b9ca..bf2b2bb83 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -60,17 +60,17 @@ Popup::Popup(const std::string &name,
if (skin.empty())
skin = "popup.xml";
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load(skin, "popup.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
setPadding(mSkin->getPadding());
setPalette(mSkin->getOption("palette"));
}
}
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->add(this);
// Popups are invisible by default
@@ -83,9 +83,9 @@ Popup::~Popup()
delete2(mVertexes);
- if (mSkin)
+ if (mSkin != nullptr)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
mSkin = nullptr;
}
@@ -106,7 +106,7 @@ void Popup::draw(Graphics *const graphics)
{
BLOCK_START("Popup::draw")
- if (mSkin)
+ if (mSkin != nullptr)
{
if (mRedraw)
{
@@ -130,7 +130,7 @@ void Popup::safeDraw(Graphics *const graphics)
{
BLOCK_START("Popup::safeDraw")
- if (mSkin)
+ if (mSkin != nullptr)
{
graphics->drawImageRect(0, 0,
mDimension.width, mDimension.height,
@@ -169,7 +169,7 @@ void Popup::setContentSize(int width, int height)
void Popup::setLocationRelativeTo(const Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
int wx, wy;
@@ -187,7 +187,7 @@ void Popup::setLocationRelativeTo(const Widget *const widget)
void Popup::setMinWidth(const int width)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinWidth = width > mSkin->getMinWidth()
? width : mSkin->getMinWidth();
@@ -200,7 +200,7 @@ void Popup::setMinWidth(const int width)
void Popup::setMinHeight(const int height)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinHeight = height > mSkin->getMinHeight() ?
height : mSkin->getMinHeight();
@@ -248,7 +248,7 @@ void Popup::position(const int x, const int y)
void Popup::mouseMoved(MouseEvent &event A_UNUSED)
{
- if (popupManager)
+ if (popupManager != nullptr)
{
popupManager->hideBeingPopup();
popupManager->hideTextPopup();
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
index d623fd811..0260945ce 100644
--- a/src/gui/widgets/popuplist.cpp
+++ b/src/gui/widgets/popuplist.cpp
@@ -61,7 +61,7 @@ void PopupList::postInit()
Popup::postInit();
add(mScrollArea);
- if (gui)
+ if (gui != nullptr)
gui->addGlobalFocusListener(this);
addKeyListener(mDropDown);
@@ -71,9 +71,9 @@ void PopupList::postInit()
PopupList::~PopupList()
{
- if (mParent)
+ if (mParent != nullptr)
mParent->removeFocusListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeGlobalFocusListener(this);
removeKeyListener(mDropDown);
}
@@ -105,7 +105,7 @@ void PopupList::widgetResized(const Event &event)
void PopupList::setSelected(const int selected)
{
- if (!mListBox)
+ if (mListBox == nullptr)
return;
mListBox->setSelected(selected);
@@ -113,7 +113,7 @@ void PopupList::setSelected(const int selected)
int PopupList::getSelected() const
{
- if (!mListBox)
+ if (mListBox == nullptr)
return -1;
return mListBox->getSelected();
@@ -121,7 +121,7 @@ int PopupList::getSelected() const
void PopupList::setListModel(ListModel *const model)
{
- if (mListBox)
+ if (mListBox != nullptr)
mListBox->setListModel(model);
mListModel = model;
}
@@ -155,7 +155,7 @@ void PopupList::mouseReleased(MouseEvent& event)
mPressedIndex = -2;
if (event.getSource() == mScrollArea)
return;
- if (mDropDown)
+ if (mDropDown != nullptr)
mDropDown->updateSelection();
setVisible(Visible_false);
if (mModal == Modal_true)
@@ -174,7 +174,7 @@ void PopupList::focusGained(const Event& event)
return;
}
- if (mDropDown)
+ if (mDropDown != nullptr)
mDropDown->updateSelection();
setVisible(Visible_false);
if (mModal == Modal_true)
@@ -183,6 +183,6 @@ void PopupList::focusGained(const Event& event)
void PopupList::focusLost(const Event& event A_UNUSED)
{
- if (mDropDown)
+ if (mDropDown != nullptr)
mDropDown->updateSelection();
}
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index e84200973..7299140c6 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -80,10 +80,10 @@ ProgressBar::ProgressBar(const Widget2 *const widget,
addWidgetListener(this);
setSize(width, height);
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load(skin, "progressbar.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
setPadding(mSkin->getPadding());
mFillPadding = mSkin->getOption("fillPadding");
@@ -99,13 +99,13 @@ ProgressBar::ProgressBar(const Widget2 *const widget,
ProgressBar::~ProgressBar()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances--;
- if (mSkin)
+ if (mSkin != nullptr)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
mSkin = nullptr;
}
@@ -157,7 +157,7 @@ void ProgressBar::updateAlpha()
void ProgressBar::draw(Graphics *const graphics)
{
BLOCK_START("ProgressBar::draw")
- if (!mSkin)
+ if (mSkin == nullptr)
{
BLOCK_END("ProgressBar::draw")
return;
@@ -223,7 +223,7 @@ void ProgressBar::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
{
const int textX = (mDimension.width - font->getWidth(mText)) / 2;
const int textY = (mDimension.height - font->getHeight()) / 2;
@@ -236,7 +236,7 @@ void ProgressBar::draw(Graphics *const graphics)
void ProgressBar::safeDraw(Graphics *const graphics)
{
BLOCK_START("ProgressBar::safeDraw")
- if (!mSkin)
+ if (mSkin == nullptr)
{
BLOCK_END("ProgressBar::safeDraw")
return;
@@ -294,7 +294,7 @@ void ProgressBar::safeDraw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
{
const int textX = (mDimension.width - font->getWidth(mText)) / 2;
const int textY = (mDimension.height - font->getHeight()) / 2;
diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp
index 1b2b333e2..abeee678c 100644
--- a/src/gui/widgets/progressindicator.cpp
+++ b/src/gui/widgets/progressindicator.cpp
@@ -39,7 +39,7 @@ ProgressIndicator::ProgressIndicator(const Widget2 *const widget) :
ImageSet *const images = Theme::getImageSetFromTheme(
"progress-indicator.png", 32, 32);
- if (images)
+ if (images != nullptr)
{
Animation *const anim = new Animation("progress indicator");
for (ImageSet::size_type i = 0, fsz = images->size();
@@ -57,7 +57,7 @@ ProgressIndicator::ProgressIndicator(const Widget2 *const widget) :
ProgressIndicator::~ProgressIndicator()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
delete2(mIndicator);
@@ -66,7 +66,7 @@ ProgressIndicator::~ProgressIndicator()
void ProgressIndicator::logic()
{
BLOCK_START("ProgressIndicator::logic")
- if (mIndicator)
+ if (mIndicator != nullptr)
mIndicator->update(10);
BLOCK_END("ProgressIndicator::logic")
}
@@ -74,7 +74,7 @@ void ProgressIndicator::logic()
void ProgressIndicator::draw(Graphics *const graphics)
{
BLOCK_START("ProgressIndicator::draw")
- if (mIndicator)
+ if (mIndicator != nullptr)
{
// Draw the indicator centered on the widget
const int x = (mDimension.width - 32) / 2;
@@ -87,7 +87,7 @@ void ProgressIndicator::draw(Graphics *const graphics)
void ProgressIndicator::safeDraw(Graphics *const graphics)
{
BLOCK_START("ProgressIndicator::draw")
- if (mIndicator)
+ if (mIndicator != nullptr)
{
// Draw the indicator centered on the widget
const int x = (mDimension.width - 32) / 2;
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 3a781061c..71b7171ae 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -119,7 +119,7 @@ RadioButton::RadioButton(const Widget2 *const widget,
mForegroundColor2 = getThemeColor(ThemeColorId::RADIOBUTTON_OUTLINE);
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load("radio.xml", "");
updateAlpha();
@@ -128,7 +128,7 @@ RadioButton::RadioButton(const Widget2 *const widget,
instances++;
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mImagePadding = mSkin->getOption("imagePadding");
@@ -142,19 +142,19 @@ RadioButton::RadioButton(const Widget2 *const widget,
RadioButton::~RadioButton()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
setGroup(std::string());
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
}
@@ -167,13 +167,13 @@ void RadioButton::updateAlpha()
if (mAlpha != alpha)
{
mAlpha = alpha;
- if (mSkin)
+ if (mSkin != nullptr)
{
const ImageRect &rect = mSkin->getBorder();
for (int a = 0; a < 4; a ++)
{
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -182,7 +182,7 @@ void RadioButton::updateAlpha()
void RadioButton::drawBox(Graphics *const graphics)
{
- if (!mSkin)
+ if (mSkin == nullptr)
return;
const ImageRect &rect = mSkin->getBorder();
@@ -217,7 +217,7 @@ void RadioButton::drawBox(Graphics *const graphics)
updateAlpha();
- if (box)
+ if (box != nullptr)
{
graphics->drawImage(box,
mImagePadding,
@@ -244,7 +244,7 @@ void RadioButton::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, mTextX, mPadding);
BLOCK_END("RadioButton::draw")
@@ -293,7 +293,7 @@ void RadioButton::setSelected(const bool selected)
iter != iterEnd;
++ iter)
{
- if (iter->second && iter->second->isSelected())
+ if ((iter->second != nullptr) && iter->second->isSelected())
iter->second->setSelected(false);
}
}
@@ -348,7 +348,7 @@ void RadioButton::setCaption(const std::string& caption)
void RadioButton::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
@@ -361,7 +361,7 @@ void RadioButton::widgetHidden(const Event &event A_UNUSED)
void RadioButton::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 4ac8f5dce..630f7e9bf 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -148,7 +148,7 @@ ScrollArea::ScrollArea(Widget2 *const widget2,
ScrollArea::~ScrollArea()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
// Garbage collection
@@ -166,7 +166,7 @@ ScrollArea::~ScrollArea()
{
for (int f = UP; f < BUTTONS_DIR; f ++)
{
- if (buttons[f][i])
+ if (buttons[f][i] != nullptr)
buttons[f][i]->decRef();
}
}
@@ -201,7 +201,7 @@ void ScrollArea::init(std::string skinName)
// +++ here probably need move background from static
if (skinName.empty())
skinName = "scroll_background.xml";
- if (theme)
+ if (theme != nullptr)
{
theme->loadRect(background, skinName, "scroll_background.xml");
theme->loadRect(vMarker, "scroll.xml", "");
@@ -213,14 +213,14 @@ void ScrollArea::init(std::string skinName)
for (int i = 0; i < 2; i ++)
{
Skin *skin = nullptr;
- if (theme)
+ if (theme != nullptr)
skin = theme->load(buttonFiles[i], "scrollbuttons.xml");
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
for (int f = UP; f < BUTTONS_DIR; f ++)
{
- if (rect.grid[f])
+ if (rect.grid[f] != nullptr)
rect.grid[f]->incRef();
buttons[f][i] = rect.grid[f];
}
@@ -236,7 +236,7 @@ void ScrollArea::init(std::string skinName)
for (int f = UP; f < BUTTONS_DIR; f ++)
buttons[f][i] = nullptr;
}
- if (theme)
+ if (theme != nullptr)
theme->unload(skin);
}
}
@@ -259,7 +259,7 @@ void ScrollArea::logic()
setHorizontalScrollAmount(getHorizontalScrollAmount());
Widget *const content = getContent();
- if (content)
+ if (content != nullptr)
{
unsigned int frameSize = content->getFrameSize();
content->setPosition(-mHScroll + frameSize, -mVScroll + frameSize);
@@ -301,15 +301,15 @@ void ScrollArea::updateAlpha()
mAlpha = alpha;
for (int a = 0; a < 9; a++)
{
- if (background.grid[a])
+ if (background.grid[a] != nullptr)
background.grid[a]->setAlpha(mAlpha);
- if (hBackground.grid[a])
+ if (hBackground.grid[a] != nullptr)
hBackground.grid[a]->setAlpha(mAlpha);
- if (vBackground.grid[a])
+ if (vBackground.grid[a] != nullptr)
vBackground.grid[a]->setAlpha(mAlpha);
- if (vMarker.grid[a])
+ if (vMarker.grid[a] != nullptr)
vMarker.grid[a]->setAlpha(mAlpha);
- if (vMarkerHi.grid[a])
+ if (vMarkerHi.grid[a] != nullptr)
vMarkerHi.grid[a]->setAlpha(mAlpha);
}
}
@@ -512,7 +512,7 @@ void ScrollArea::drawButton(Graphics *const graphics,
Rect dim;
const Image *const image = getImageByState(dim, dir);
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, dim.x, dim.y);
}
@@ -522,7 +522,7 @@ void ScrollArea::calcButton(Graphics *const graphics,
Rect dim;
const Image *const image = getImageByState(dim, dir);
- if (image)
+ if (image != nullptr)
{
static_cast<Graphics*>(graphics)->calcTileCollection(
mVertexes, image, dim.x, dim.y);
@@ -533,18 +533,18 @@ void ScrollArea::drawVBar(Graphics *const graphics) const
{
const Rect &dim = getVerticalBarDimension();
- if (vBackground.grid[4])
+ if (vBackground.grid[4] != nullptr)
{
graphics->drawPattern(vBackground.grid[4],
dim.x, dim.y, dim.width, dim.height);
}
- if (vBackground.grid[1])
+ if (vBackground.grid[1] != nullptr)
{
graphics->drawPattern(vBackground.grid[1],
dim.x, dim.y,
dim.width, vBackground.grid[1]->getHeight());
}
- if (vBackground.grid[7])
+ if (vBackground.grid[7] != nullptr)
{
graphics->drawPattern(vBackground.grid[7],
dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y,
@@ -556,21 +556,21 @@ void ScrollArea::calcVBar(const Graphics *const graphics)
{
const Rect &dim = getVerticalBarDimension();
- if (vBackground.grid[4])
+ if (vBackground.grid[4] != nullptr)
{
graphics->calcPattern(mVertexes,
vBackground.grid[4],
dim.x, dim.y,
dim.width, dim.height);
}
- if (vBackground.grid[1])
+ if (vBackground.grid[1] != nullptr)
{
graphics->calcPattern(mVertexes,
vBackground.grid[1],
dim.x, dim.y,
dim.width, vBackground.grid[1]->getHeight());
}
- if (vBackground.grid[7])
+ if (vBackground.grid[7] != nullptr)
{
graphics->calcPattern(mVertexes,
vBackground.grid[7],
@@ -583,21 +583,21 @@ void ScrollArea::drawHBar(Graphics *const graphics) const
{
const Rect &dim = getHorizontalBarDimension();
- if (hBackground.grid[4])
+ if (hBackground.grid[4] != nullptr)
{
graphics->drawPattern(hBackground.grid[4],
dim.x, dim.y,
dim.width, dim.height);
}
- if (hBackground.grid[3])
+ if (hBackground.grid[3] != nullptr)
{
graphics->drawPattern(hBackground.grid[3],
dim.x, dim.y,
hBackground.grid[3]->getWidth(), dim.height);
}
- if (hBackground.grid[5])
+ if (hBackground.grid[5] != nullptr)
{
graphics->drawPattern(hBackground.grid[5],
dim.x + dim.width - hBackground.grid[5]->getWidth(),
@@ -611,7 +611,7 @@ void ScrollArea::calcHBar(const Graphics *const graphics)
{
const Rect &dim = getHorizontalBarDimension();
- if (hBackground.grid[4])
+ if (hBackground.grid[4] != nullptr)
{
graphics->calcPattern(mVertexes,
hBackground.grid[4],
@@ -619,7 +619,7 @@ void ScrollArea::calcHBar(const Graphics *const graphics)
dim.width, dim.height);
}
- if (hBackground.grid[3])
+ if (hBackground.grid[3] != nullptr)
{
graphics->calcPattern(mVertexes,
hBackground.grid[3],
@@ -627,7 +627,7 @@ void ScrollArea::calcHBar(const Graphics *const graphics)
hBackground.grid[3]->getWidth(), dim.height);
}
- if (hBackground.grid[5])
+ if (hBackground.grid[5] != nullptr)
{
graphics->calcPattern(mVertexes,
hBackground.grid[5],
@@ -736,7 +736,7 @@ void ScrollArea::widgetResized(const Event &event A_UNUSED)
mRedraw = true;
const unsigned int frameSize = 2 * mFrameSize;
Widget *const content = getContent();
- if (content)
+ if (content != nullptr)
{
content->setSize(mDimension.width - frameSize,
mDimension.height - frameSize);
@@ -834,7 +834,9 @@ void ScrollArea::mousePressed(MouseEvent& event)
void ScrollArea::mouseReleased(MouseEvent& event)
{
- if (event.getButton() == MouseButton::LEFT && mClickX && mClickY)
+ if (event.getButton() == MouseButton::LEFT &&
+ mClickX != 0 &&
+ mClickY != 0)
{
if (!event.isConsumed())
{
@@ -869,7 +871,7 @@ void ScrollArea::mouseReleased(MouseEvent& event)
setHorizontalScrollAmount(s);
}
- else if (dy)
+ else if (dy != 0)
{
int s = mVScroll + dy;
if (s < 0)
@@ -887,7 +889,7 @@ void ScrollArea::mouseReleased(MouseEvent& event)
}
mClickX = 0;
mClickY = 0;
- if (mMouseConsume && (dx || dy))
+ if (mMouseConsume && ((dx != 0) || (dy != 0)))
event.consume();
}
}
@@ -1007,17 +1009,17 @@ Rect ScrollArea::getVerticalMarkerDimension()
height = mDimension.height - 2 * h2;
const int maxV = getVerticalMaxScroll();
- if (mMarkerSize && maxV)
+ if ((mMarkerSize != 0) && (maxV != 0))
{
pos = (mVScroll * height / maxV - mMarkerSize / 2);
length = mMarkerSize;
}
else
{
- if (content)
+ if (content != nullptr)
{
const int h3 = content->getHeight();
- if (h3)
+ if (h3 != 0)
length = (height * getChildrenArea().height) / h3;
else
length = height;
@@ -1065,17 +1067,17 @@ Rect ScrollArea::getHorizontalMarkerDimension()
width = mDimension.width - w2 - mScrollbarWidth;
const int maxH = getHorizontalMaxScroll();
- if (mMarkerSize && maxH)
+ if ((mMarkerSize != 0) && (maxH != 0))
{
pos = (mHScroll * width / maxH - mMarkerSize / 2);
length = mMarkerSize;
}
else
{
- if (content)
+ if (content != nullptr)
{
const int w3 = content->getWidth();
- if (w3)
+ if (w3 != 0)
length = (width * getChildrenArea().width) / w3;
else
length = width;
@@ -1164,7 +1166,7 @@ Rect ScrollArea::getRightButtonDimension() const
void ScrollArea::setContent(Widget* widget)
{
- if (widget)
+ if (widget != nullptr)
{
clear();
add(widget);
@@ -1242,7 +1244,7 @@ int ScrollArea::getHorizontalMaxScroll()
checkPolicies();
const Widget *const content = getContent();
- if (!content)
+ if (content == nullptr)
return 0;
const int value = content->getWidth() - getChildrenArea().width +
@@ -1259,7 +1261,7 @@ int ScrollArea::getVerticalMaxScroll()
checkPolicies();
const Widget *const content = getContent();
- if (!content)
+ if (content == nullptr)
return 0;
int value;
@@ -1282,7 +1284,7 @@ void ScrollArea::setScrollbarWidth(const int width)
void ScrollArea::showWidgetPart(Widget *const widget, const Rect &area)
{
const Widget *const content = getContent();
- if (widget != content || !content)
+ if (widget != content || (content == nullptr))
return;
BasicContainer::showWidgetPart(widget, area);
@@ -1362,7 +1364,7 @@ void ScrollArea::checkPolicies()
mVBarVisible = false;
const Widget *const content = getContent();
- if (!content)
+ if (content == nullptr)
{
mHBarVisible = (mHPolicy == SHOW_ALWAYS);
mVBarVisible = (mVPolicy == SHOW_ALWAYS);
diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp
index b455597a2..fc7bd9701 100644
--- a/src/gui/widgets/selldialog.cpp
+++ b/src/gui/widgets/selldialog.cpp
@@ -87,7 +87,7 @@ void SellDialog::postInit()
setMinHeight(220);
setDefaultSize(260, 230, ImagePosition::CENTER);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
// Create a ShopItems instance, that is aware of duplicate entries.
@@ -205,7 +205,7 @@ SellDialog::~SellDialog()
void SellDialog::reset()
{
mShopItems->clear();
- if (mSlider)
+ if (mSlider != nullptr)
mSlider->setValue(0);
mShopItemList->setSelected(-1);
updateButtonsAndLabels();
@@ -213,7 +213,7 @@ void SellDialog::reset()
void SellDialog::addItem(const Item *const item, const int price)
{
- if (!item)
+ if (item == nullptr)
return;
mShopItems->addItem2(item->getInvIndex(),
@@ -263,25 +263,30 @@ void SellDialog::action(const ActionEvent &event)
if (eventId == "slider")
{
- if (mSlider)
+ if (mSlider != nullptr)
{
mAmountItems = CAST_S32(mSlider->getValue());
updateButtonsAndLabels();
}
}
- else if (eventId == "inc" && mSlider && mAmountItems < mMaxItems)
+ else if (eventId == "inc" &&
+ mSlider != nullptr &&
+ mAmountItems < mMaxItems)
{
mAmountItems++;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (eventId == "dec" && mSlider && mAmountItems > 1)
+ else if (eventId == "dec" &&
+ mSlider != nullptr &&
+ mAmountItems > 1)
{
mAmountItems--;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (eventId == "max" && mSlider)
+ else if (eventId == "max" &&
+ mSlider != nullptr)
{
mAmountItems = mMaxItems;
mSlider->setValue(mAmountItems);
@@ -300,7 +305,7 @@ void SellDialog::valueChanged(const SelectionEvent &event A_UNUSED)
{
// Reset amount of items and update labels
mAmountItems = 1;
- if (mSlider)
+ if (mSlider != nullptr)
{
mSlider->setValue(0);
mSlider->setScale(1, mMaxItems);
@@ -320,10 +325,10 @@ void SellDialog::updateButtonsAndLabels()
int income = 0;
ShopItem *item = nullptr;
- if (selectedItem > -1 && mShopItems->at(selectedItem))
+ if (selectedItem > -1 && (mShopItems->at(selectedItem) != nullptr))
{
item = mShopItems->at(selectedItem);
- if (item)
+ if (item != nullptr)
{
mMaxItems = item->getQuantity();
if (mAmountItems > mMaxItems)
@@ -344,27 +349,27 @@ void SellDialog::updateButtonsAndLabels()
// Update Buttons and slider
mSellButton->setEnabled(mAmountItems > 0);
- if (mDecreaseButton)
+ if (mDecreaseButton != nullptr)
mDecreaseButton->setEnabled(mAmountItems > 1);
- if (mIncreaseButton)
+ if (mIncreaseButton != nullptr)
mIncreaseButton->setEnabled(mAmountItems < mMaxItems);
- if (mSlider)
+ if (mSlider != nullptr)
mSlider->setEnabled(mMaxItems > 1);
- if (mQuantityLabel)
+ if (mQuantityLabel != nullptr)
{
// Update the quantity and money labels
mQuantityLabel->setCaption(strprintf("%d / %d",
mAmountItems, mMaxItems));
}
- if (mMoneyLabel)
+ if (mMoneyLabel != nullptr)
{
// TRANSLATORS: sell dialog label
mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
UnitsDb::formatCurrency(income).c_str(),
UnitsDb::formatCurrency(mPlayerMoney + income).c_str()));
}
- if (item)
+ if (item != nullptr)
item->update();
}
@@ -374,7 +379,7 @@ void SellDialog::setVisible(Visible visible)
if (visible == Visible_true)
{
- if (mShopItemList)
+ if (mShopItemList != nullptr)
mShopItemList->requestFocus();
}
else
diff --git a/src/gui/widgets/serverslistbox.h b/src/gui/widgets/serverslistbox.h
index fb45dd01a..20d019f8d 100644
--- a/src/gui/widgets/serverslistbox.h
+++ b/src/gui/widgets/serverslistbox.h
@@ -47,7 +47,7 @@ class ServersListBox final : public ListBox
void draw(Graphics *const graphics) override final A_NONNULL(2)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
ServersListModel *const model
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 2ebd2ef19..8d6296d52 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -151,7 +151,7 @@ void SetupItem::save()
std::string SetupItem::getActionEventId() const
{
- if (!mWidget)
+ if (mWidget == nullptr)
return std::string();
return mWidget->getActionEventId();
@@ -159,7 +159,7 @@ std::string SetupItem::getActionEventId() const
void SetupItem::action(const ActionEvent &event)
{
- if (!mWidget)
+ if (mWidget == nullptr)
return;
if (event.getId() == mWidget->getActionEventId())
@@ -194,7 +194,7 @@ void SetupItem::externalUnloaded(const std::string &eventName A_UNUSED)
void SetupItem::fixFirstItemSize(Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
const int maxSize = mParent->getPreferredFirstItemSize();
if (widget->getWidth() < maxSize)
@@ -251,7 +251,7 @@ void SetupItemCheckBox::createControls()
void SetupItemCheckBox::fromWidget()
{
- if (!mCheckBox)
+ if (mCheckBox == nullptr)
return;
if (mCheckBox->isSelected())
@@ -262,7 +262,7 @@ void SetupItemCheckBox::fromWidget()
void SetupItemCheckBox::toWidget()
{
- if (!mCheckBox)
+ if (mCheckBox == nullptr)
return;
mCheckBox->setSelected(mValue != "0");
@@ -390,7 +390,7 @@ void SetupItemTextField::createControls()
void SetupItemTextField::fromWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mValue = mTextField->getText();
@@ -398,7 +398,7 @@ void SetupItemTextField::fromWidget()
void SetupItemTextField::toWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mTextField->setText(mValue);
@@ -406,11 +406,11 @@ void SetupItemTextField::toWidget()
void SetupItemTextField::action(const ActionEvent &event)
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
const std::string &eventId = event.getId();
- if (mWidget && eventId == mWidget->getActionEventId())
+ if ((mWidget != nullptr) && eventId == mWidget->getActionEventId())
{
fromWidget();
}
@@ -528,7 +528,7 @@ void SetupItemIntTextField::createControls()
void SetupItemIntTextField::fromWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mValue = mTextField->getText();
@@ -536,7 +536,7 @@ void SetupItemIntTextField::fromWidget()
void SetupItemIntTextField::toWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mTextField->setText(mValue);
@@ -544,11 +544,11 @@ void SetupItemIntTextField::toWidget()
void SetupItemIntTextField::action(const ActionEvent &event)
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
const std::string &eventId = event.getId();
- if (mWidget && eventId == mWidget->getActionEventId())
+ if ((mWidget != nullptr) && eventId == mWidget->getActionEventId())
{
fromWidget();
}
@@ -708,7 +708,7 @@ void SetupItemDropDown::createControls()
void SetupItemDropDown::fromWidget()
{
- if (!mDropDown)
+ if (mDropDown == nullptr)
return;
mValue = toString(mDropDown->getSelected());
@@ -716,7 +716,7 @@ void SetupItemDropDown::fromWidget()
void SetupItemDropDown::toWidget()
{
- if (!mDropDown)
+ if (mDropDown == nullptr)
return;
mDropDown->setSelected(atoi(mValue.c_str()));
@@ -810,7 +810,7 @@ void SetupItemSlider::createControls()
void SetupItemSlider::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mValue = toString(mSlider->getValue());
@@ -818,7 +818,7 @@ void SetupItemSlider::fromWidget()
void SetupItemSlider::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mSlider->setValue(atof(mValue.c_str()));
@@ -945,7 +945,7 @@ void SetupItemSlider2::createControls()
int SetupItemSlider2::getMaxWidth()
{
- if (!mValues || !gui)
+ if ((mValues == nullptr) || (gui == nullptr))
return 1;
int maxWidth = 0;
@@ -966,7 +966,7 @@ int SetupItemSlider2::getMaxWidth()
void SetupItemSlider2::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
int val = roundDouble(mSlider->getValue());
@@ -977,7 +977,7 @@ void SetupItemSlider2::fromWidget()
void SetupItemSlider2::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
int val = roundDouble(atof(mValue.c_str()));
@@ -1107,7 +1107,7 @@ void SetupItemSliderList::createControls()
void SetupItemSliderList::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mValue = mSlider->getSelectedString();
@@ -1115,7 +1115,7 @@ void SetupItemSliderList::fromWidget()
void SetupItemSliderList::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mSlider->setSelectedString(mValue);
@@ -1157,7 +1157,7 @@ void SetupItemSound::addMoreControls()
{
mButton = new Button(this, BUTTON_PLAY, 16, 16,
mEventName + "_PLAY", this);
- if (mHorizont)
+ if (mHorizont != nullptr)
mHorizont->add(mButton);
}
@@ -1165,7 +1165,7 @@ void SetupItemSound::action(const ActionEvent &event)
{
if (event.getId() == mEventName + "_PLAY")
{
- if (mSlider && mSlider->getSelected())
+ if ((mSlider != nullptr) && (mSlider->getSelected() != 0))
{
soundManager.playGuiSfx(pathJoin(branding.getStringValue(
"systemsounds"),
@@ -1202,7 +1202,7 @@ void SetupItemSliderInt::addMoreControls()
void SetupItemSliderInt::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mValue = toString(mSlider->getSelected() + mMin);
@@ -1210,7 +1210,7 @@ void SetupItemSliderInt::fromWidget()
void SetupItemSliderInt::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mSlider->setSelected(atoi(mValue.c_str()) - mMin);
diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp
index 8dbaf550f..122853c7e 100644
--- a/src/gui/widgets/setuptouchitem.cpp
+++ b/src/gui/widgets/setuptouchitem.cpp
@@ -87,7 +87,7 @@ SetupActionDropDown::~SetupActionDropDown()
void SetupActionDropDown::createControls()
{
- if (!mModel)
+ if (mModel == nullptr)
return;
load();
@@ -115,7 +115,7 @@ void SetupActionDropDown::createControls()
void SetupActionDropDown::fromWidget()
{
- if (!mDropDown || !mModel)
+ if ((mDropDown == nullptr) || (mModel == nullptr))
return;
mValue = toString(CAST_S32(mModel->getActionFromSelection(
@@ -124,7 +124,7 @@ void SetupActionDropDown::fromWidget()
void SetupActionDropDown::toWidget()
{
- if (!mDropDown || !mModel)
+ if ((mDropDown == nullptr) || (mModel == nullptr))
return;
mDropDown->setSelected(mModel->getSelectionFromAction(
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index f1e5ed32f..3df46b854 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -91,7 +91,7 @@ void ShopListBox::setPlayersMoney(const int money)
void ShopListBox::draw(Graphics *const graphics)
{
BLOCK_START("ShopListBox::draw")
- if (!mListModel || !mShopItems)
+ if ((mListModel == nullptr) || (mShopItems == nullptr))
{
BLOCK_END("ShopListBox::draw")
return;
@@ -116,7 +116,7 @@ void ShopListBox::draw(Graphics *const graphics)
Color* backgroundColor = &mBackgroundColor;
ShopItem *const item = mShopItems->at(i);
- if (item &&
+ if ((item != nullptr) &&
(item->getDisabled() ||
(mPlayerMoney < item->getPrice() && mPriceCheck) ||
(mProtectItems && PlayerInfo::isItemProtected(item->getId()))))
@@ -155,10 +155,10 @@ void ShopListBox::draw(Graphics *const graphics)
width, mRowHeight));
}
- if (mShopItems && item)
+ if ((mShopItems != nullptr) && (item != nullptr))
{
Image *const icon = item->getImage();
- if (icon)
+ if (icon != nullptr)
{
icon->setAlpha(1.0F);
graphics->drawImage(icon, mPadding, y + mPadding);
@@ -194,7 +194,7 @@ void ShopListBox::safeDraw(Graphics *const graphics)
void ShopListBox::adjustSize()
{
BLOCK_START("ShopListBox::adjustSize")
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(mRowHeight * mListModel->getNumberOfElements()
+ 2 * mPadding);
@@ -209,10 +209,10 @@ void ShopListBox::setPriceCheck(const bool check)
void ShopListBox::mouseMoved(MouseEvent &event)
{
- if (!itemPopup || !mRowHeight)
+ if ((itemPopup == nullptr) || (mRowHeight == 0u))
return;
- if (!mShopItems)
+ if (mShopItems == nullptr)
{
itemPopup->hide();
return;
@@ -227,7 +227,7 @@ void ShopListBox::mouseMoved(MouseEvent &event)
else
{
const Item *const item = mShopItems->at(index);
- if (item)
+ if (item != nullptr)
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -265,7 +265,7 @@ void ShopListBox::mouseReleased(MouseEvent& event)
inventory = PlayerInfo::getCartInventory();
else
return;
- if (!inventory)
+ if (inventory == nullptr)
return;
Item *const item = inventory->getItem(dragDrop.getTag());
if (mType == ShopListBoxType::BuyShop)
@@ -292,7 +292,7 @@ void ShopListBox::mouseReleased(MouseEvent& event)
return;
Item *const item = mShopItems->at(mSelected);
- if (popupMenu && viewport)
+ if ((popupMenu != nullptr) && (viewport != nullptr))
{
popupMenu->showItemPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -303,7 +303,7 @@ void ShopListBox::mouseReleased(MouseEvent& event)
void ShopListBox::mouseExited(MouseEvent& event A_UNUSED)
{
- if (!itemPopup)
+ if (itemPopup == nullptr)
return;
itemPopup->hide();
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index e9611b69f..a2b90514d 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -61,7 +61,7 @@ ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
mBackgroundImg = Theme::getImageFromThemeXml(
"item_shortcut_background.xml", "background.xml");
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
mBackgroundImg->setAlpha(settings.guiAlpha);
mBoxHeight = mBackgroundImg->getHeight();
@@ -76,13 +76,13 @@ ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
ShortcutContainer::~ShortcutContainer()
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
mBackgroundImg->decRef();
mBackgroundImg = nullptr;
}
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
delete2(mVertexes);
@@ -123,7 +123,7 @@ int ShortcutContainer::getIndexFromGrid(const int pointX,
void ShortcutContainer::drawBackground(Graphics *const g)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
if (mRedraw)
{
@@ -143,7 +143,7 @@ void ShortcutContainer::drawBackground(Graphics *const g)
void ShortcutContainer::safeDrawBackground(Graphics *const g)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
for (unsigned i = 0; i < mMaxItems; i ++)
{
diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h
index 2bada3a13..93c702381 100644
--- a/src/gui/widgets/skilllistbox.h
+++ b/src/gui/widgets/skilllistbox.h
@@ -58,8 +58,9 @@ class SkillListBox final : public ListBox
mTextColor(getThemeColor(ThemeColorId::TEXT)),
mTextColor2(getThemeColor(ThemeColorId::TEXT_OUTLINE)),
mCooldownColor(getThemeColor(ThemeColorId::SKILL_COOLDOWN)),
- mTextPadding(mSkin ? mSkin->getOption("textPadding", 34) : 34),
- mSpacing(mSkin ? mSkin->getOption("spacing", 0) : 0),
+ mTextPadding(mSkin != nullptr ?
+ mSkin->getOption("textPadding", 34) : 34),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing", 0) : 0),
mSkillClicked(false)
{
mRowHeight = getFont()->getHeight() * 2 + mSpacing + 2 * mPadding;
@@ -79,7 +80,7 @@ class SkillListBox final : public ListBox
SkillInfo *getSelectedInfo() const
{
const int selected = getSelected();
- if (!mListModel || selected < 0
+ if ((mListModel == nullptr) || selected < 0
|| selected > mListModel->getNumberOfElements())
{
return nullptr;
@@ -90,7 +91,7 @@ class SkillListBox final : public ListBox
void draw(Graphics *const graphics) override final A_NONNULL(2)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
SkillModel *const model = static_cast<SkillModel*>(mListModel);
@@ -121,9 +122,9 @@ class SkillListBox final : public ListBox
++i, y += getRowHeight())
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
- if (e->cooldown)
+ if (e->cooldown != 0)
{
graphics->fillRectangle(Rect(mPadding, y,
usableWidth * 100 / e->cooldown, 10));
@@ -136,7 +137,7 @@ class SkillListBox final : public ListBox
++i, y += getRowHeight())
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
const SkillData *const data = e->data;
const std::string &description = data->description;
@@ -183,10 +184,10 @@ class SkillListBox final : public ListBox
const SkillInfo *getSkillByEvent(const MouseEvent &event) const
{
const int y = (event.getY() + mPadding) / getRowHeight();
- if (!mModel || y >= mModel->getNumberOfElements())
+ if (mModel == nullptr || y >= mModel->getNumberOfElements())
return nullptr;
const SkillInfo *const skill = mModel->getSkillAt(y);
- if (!skill)
+ if (skill == nullptr)
return nullptr;
return skill;
}
@@ -194,11 +195,11 @@ class SkillListBox final : public ListBox
void mouseMoved(MouseEvent &event) override final
{
ListBox::mouseMoved(event);
- if (!viewport || !dragDrop.isEmpty())
+ if ((viewport == nullptr) || !dragDrop.isEmpty())
return;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
skillPopup->show(skill,
skill->customSelectedLevel,
@@ -219,7 +220,7 @@ class SkillListBox final : public ListBox
{
mSkillClicked = false;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
dragDrop.dragSkill(skill, DragDropSource::Skills);
dragDrop.setItem(skill->id + SKILL_MIN_ID);
@@ -245,13 +246,13 @@ class SkillListBox final : public ListBox
button == MouseButton::RIGHT)
{
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
event.consume();
mSkillClicked = true;
SkillModel *const model = static_cast<SkillModel*>(
mListModel);
- if (model &&
+ if ((model != nullptr) &&
mSelected >= 0 &&
model->getSkillAt(mSelected) == skill)
{
diff --git a/src/gui/widgets/skillrectanglelistbox.h b/src/gui/widgets/skillrectanglelistbox.h
index dc5c664d8..88698de1c 100644
--- a/src/gui/widgets/skillrectanglelistbox.h
+++ b/src/gui/widgets/skillrectanglelistbox.h
@@ -73,13 +73,13 @@ class SkillRectangleListBox final : public Widget,
mTextYOffset(44),
mSkillClicked(false)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load("skillrectanglelistbox.xml",
"listbox.xml");
}
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mBoxWidth = mSkin->getOption("boxWidth", 80);
@@ -103,7 +103,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (e->x > maxX)
maxX = e->x;
@@ -127,7 +127,7 @@ class SkillRectangleListBox final : public Widget,
SkillInfo *getSelectedInfo() const
{
- if (!mModel)
+ if (mModel == nullptr)
return nullptr;
const int selected = mSelected;
if (selected < 0 ||
@@ -141,7 +141,7 @@ class SkillRectangleListBox final : public Widget,
void draw(Graphics *const graphics) override final A_NONNULL(2)
{
- if (!mModel)
+ if (mModel == nullptr)
return;
SkillModel *const model = mModel;
@@ -155,7 +155,7 @@ class SkillRectangleListBox final : public Widget,
if (mSelected >= 0)
{
SkillInfo *const e = model->getSkillAt(mSelected);
- if (e)
+ if (e != nullptr)
{
const int x = e->x * mBoxWidth + mPadding;
const int y = e->y * mBoxHeight + mPadding;
@@ -180,7 +180,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (e->x > maxX)
maxX = e->x;
@@ -235,7 +235,7 @@ class SkillRectangleListBox final : public Widget,
const SkillInfo *getSkillByEvent(const MouseEvent &event) const
{
- if (!mModel)
+ if (mModel == nullptr)
return nullptr;
const int posX = (event.getX() - mPadding) / mBoxWidth;
const int posY = (event.getY() - mPadding) / mBoxHeight;
@@ -244,7 +244,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = mModel->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (posX == e->x && posY == e->y)
return e;
@@ -255,7 +255,7 @@ class SkillRectangleListBox final : public Widget,
int getSelectionByEvent(const MouseEvent &event) const
{
- if (!mModel)
+ if (mModel == nullptr)
return -1;
const int posX = (event.getX() - mPadding) / mBoxWidth;
const int posY = (event.getY() - mPadding) / mBoxHeight;
@@ -264,7 +264,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = mModel->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (posX == e->x && posY == e->y)
return i;
@@ -275,11 +275,11 @@ class SkillRectangleListBox final : public Widget,
void mouseMoved(MouseEvent &event) override final
{
- if (!viewport || !dragDrop.isEmpty())
+ if ((viewport == nullptr) || !dragDrop.isEmpty())
return;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
skillPopup->show(skill,
skill->customSelectedLevel,
@@ -302,7 +302,7 @@ class SkillRectangleListBox final : public Widget,
{
mSkillClicked = false;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
dragDrop.dragSkill(skill, DragDropSource::Skills);
dragDrop.setItem(skill->id + SKILL_MIN_ID);
@@ -321,12 +321,12 @@ class SkillRectangleListBox final : public Widget,
button == MouseButton::RIGHT)
{
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
event.consume();
mSkillClicked = true;
SkillModel *const model = mModel;
- if (model &&
+ if ((model != nullptr) &&
mSelected >= 0 &&
model->getSkillAt(mSelected) == skill)
{
@@ -381,7 +381,7 @@ class SkillRectangleListBox final : public Widget,
void setSelected(const int selected)
{
- if (!mModel)
+ if (mModel == nullptr)
{
mSelected = -1;
}
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 2c5ac7c20..0d25ad2c5 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -132,7 +132,7 @@ Slider::Slider(Widget2 *const widget,
Slider::~Slider()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
delete2(mVertexes);
@@ -158,7 +158,7 @@ void Slider::init()
// Load resources
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
for (int mode = 0; mode < 2; mode ++)
theme->loadRect(buttons[mode], data[mode], "slider.xml", 0, 8);
@@ -168,7 +168,7 @@ void Slider::init()
mInstances++;
- if (buttons[0].grid[SliderGrid::HGRIP])
+ if (buttons[0].grid[SliderGrid::HGRIP] != nullptr)
setMarkerLength(buttons[0].grid[SliderGrid::HGRIP]->getWidth());
}
@@ -184,7 +184,7 @@ void Slider::updateAlpha()
{
for (int d = 0; d < SliderGrid::SLIDER_MAX; d ++)
{
- if (buttons[f].grid[d])
+ if (buttons[f].grid[d] != nullptr)
buttons[f].grid[d]->setAlpha(mAlpha);
}
}
@@ -194,9 +194,9 @@ void Slider::updateAlpha()
void Slider::draw(Graphics *const graphics)
{
BLOCK_START("Slider::draw")
- if (!buttons[0].grid[SliderGrid::HSTART] ||
- !buttons[1].grid[SliderGrid::HSTART] ||
- !buttons[0].grid[SliderGrid::HEND])
+ if ((buttons[0].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[1].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[0].grid[SliderGrid::HEND] == nullptr))
{
BLOCK_END("Slider::draw")
return;
@@ -225,7 +225,7 @@ void Slider::draw(Graphics *const graphics)
w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[0].grid[SliderGrid::HMID])
+ if (buttons[0].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[0].grid[SliderGrid::HMID];
graphics->calcPattern(mVertexes,
@@ -240,7 +240,7 @@ void Slider::draw(Graphics *const graphics)
x, y);
const Image *const img = buttons[0].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->calcTileCollection(mVertexes,
img,
@@ -256,11 +256,11 @@ void Slider::draw(Graphics *const graphics)
const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth();
w -= width;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
w -= buttons[1].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[1].grid[SliderGrid::HMID])
+ if (buttons[1].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[1].grid[SliderGrid::HMID];
graphics->calcPattern(mVertexes,
@@ -270,14 +270,14 @@ void Slider::draw(Graphics *const graphics)
}
x += w;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
{
graphics->calcTileCollection(mVertexes,
buttons[1].grid[SliderGrid::HEND], x, y);
}
const Image *const img = buttons[1].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->calcTileCollection(mVertexes,
img,
@@ -295,9 +295,9 @@ void Slider::draw(Graphics *const graphics)
void Slider::safeDraw(Graphics *const graphics)
{
BLOCK_START("Slider::draw")
- if (!buttons[0].grid[SliderGrid::HSTART] ||
- !buttons[1].grid[SliderGrid::HSTART] ||
- !buttons[0].grid[SliderGrid::HEND])
+ if ((buttons[0].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[1].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[0].grid[SliderGrid::HEND] == nullptr))
{
BLOCK_END("Slider::draw")
return;
@@ -319,7 +319,7 @@ void Slider::safeDraw(Graphics *const graphics)
w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[0].grid[SliderGrid::HMID])
+ if (buttons[0].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[0].grid[SliderGrid::HMID];
graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
@@ -329,7 +329,7 @@ void Slider::safeDraw(Graphics *const graphics)
graphics->drawImage(buttons[0].grid[SliderGrid::HEND], x, y);
const Image *const img = buttons[0].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->drawImage(img, getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
@@ -341,22 +341,22 @@ void Slider::safeDraw(Graphics *const graphics)
const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth();
w -= width;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
w -= buttons[1].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[1].grid[SliderGrid::HMID])
+ if (buttons[1].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[1].grid[SliderGrid::HMID];
graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
}
x += w;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
graphics->drawImage(buttons[1].grid[SliderGrid::HEND], x, y);
const Image *const img = buttons[1].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->drawImage(img, getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
index 3b42b43e5..edce0cf02 100644
--- a/src/gui/widgets/sliderlist.cpp
+++ b/src/gui/widgets/sliderlist.cpp
@@ -68,7 +68,7 @@ void SliderList::postInit2(ActionListener *const listener,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
updateLabel();
@@ -135,7 +135,7 @@ void SliderList::safeDraw(Graphics *const graphics)
void SliderList::updateLabel()
{
- if (!mListModel || mSelectedIndex < 0
+ if ((mListModel == nullptr) || mSelectedIndex < 0
|| mSelectedIndex >= mListModel->getNumberOfElements())
{
return;
@@ -157,7 +157,7 @@ void SliderList::updateLabel()
void SliderList::action(const ActionEvent &event)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
const std::string &eventId = event.getId();
@@ -179,7 +179,7 @@ void SliderList::action(const ActionEvent &event)
void SliderList::setSelectedString(const std::string &str)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
for (int f = 0; f < mListModel->getNumberOfElements(); f ++)
@@ -194,7 +194,7 @@ void SliderList::setSelectedString(const std::string &str)
std::string SliderList::getSelectedString() const
{
- if (!mListModel)
+ if (mListModel == nullptr)
return std::string();
return mListModel->getElementAt(mSelectedIndex);
@@ -202,7 +202,7 @@ std::string SliderList::getSelectedString() const
void SliderList::setSelected(const int idx)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
mSelectedIndex = idx;
@@ -222,7 +222,7 @@ void SliderList::adjustSize()
int SliderList::getMaxLabelWidth() const
{
- if (!mListModel || !gui)
+ if ((mListModel == nullptr) || (gui == nullptr))
return 1;
int maxWidth = 0;
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 2b365c52d..6cc4def09 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -46,7 +46,7 @@ SpellShortcutContainer::SpellShortcutContainer(Widget2 *const widget,
mNumber(number),
mSpellClicked(false)
{
- if (spellShortcut)
+ if (spellShortcut != nullptr)
mMaxItems = spellShortcut->getSpellsCount();
else
mMaxItems = 0;
@@ -65,14 +65,14 @@ void SpellShortcutContainer::setWidget2(const Widget2 *const widget)
void SpellShortcutContainer::draw(Graphics *const graphics)
{
- if (!spellShortcut)
+ if (spellShortcut == nullptr)
return;
BLOCK_START("SpellShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
@@ -95,17 +95,17 @@ void SpellShortcutContainer::draw(Graphics *const graphics)
mBoxWidth - 1, mBoxHeight - 1));
}
- if (!spellManager)
+ if (spellManager == nullptr)
continue;
const TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -125,14 +125,14 @@ void SpellShortcutContainer::draw(Graphics *const graphics)
void SpellShortcutContainer::safeDraw(Graphics *const graphics)
{
- if (!spellShortcut)
+ if (spellShortcut == nullptr)
return;
BLOCK_START("SpellShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
@@ -155,17 +155,17 @@ void SpellShortcutContainer::safeDraw(Graphics *const graphics)
mBoxWidth - 1, mBoxHeight - 1));
}
- if (!spellManager)
+ if (spellManager == nullptr)
continue;
const TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -200,7 +200,7 @@ void SpellShortcutContainer::mouseDragged(MouseEvent &event)
return;
event.consume();
TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell)
+ if (spell != nullptr)
{
dragDrop.dragCommand(spell, DragDropSource::Spells, index);
dragDrop.setItem(spell->getId() + SPELL_MIN_ID);
@@ -234,7 +234,7 @@ void SpellShortcutContainer::mousePressed(MouseEvent &event)
}
else if (eventButton == MouseButton::MIDDLE)
{
- if (!spellShortcut || !spellManager)
+ if ((spellShortcut == nullptr) || (spellManager == nullptr))
return;
event.consume();
@@ -245,7 +245,7 @@ void SpellShortcutContainer::mousePressed(MouseEvent &event)
void SpellShortcutContainer::mouseReleased(MouseEvent &event)
{
- if (!spellShortcut || !spellManager)
+ if ((spellShortcut == nullptr) || (spellManager == nullptr))
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -287,11 +287,11 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
{
const TextCommand *const
spell = spellManager->getSpell(itemId);
- if (spell && !spell->isEmpty())
+ if ((spell != nullptr) && !spell->isEmpty())
{
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
- && itemShortcut[num])
+ && (itemShortcut[num] != nullptr))
{
itemShortcut[num]->setItemSelected(
spell->getId() + SPELL_MIN_ID);
@@ -303,7 +303,7 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
{
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
- && itemShortcut[num])
+ && (itemShortcut[num] != nullptr))
{
itemShortcut[num]->setItemSelected(-1);
}
@@ -317,7 +317,7 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
if (itemId >= 0)
spell = spellManager->getSpell(itemId);
- if (spell && popupMenu)
+ if ((spell != nullptr) && (popupMenu != nullptr))
{
popupMenu->showSpellPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -329,8 +329,12 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
// Show ItemTooltip
void SpellShortcutContainer::mouseMoved(MouseEvent &event)
{
- if (!spellPopup || !spellShortcut || !spellManager)
+ if (spellPopup == nullptr ||
+ spellShortcut == nullptr ||
+ spellManager == nullptr)
+ {
return;
+ }
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -340,7 +344,7 @@ void SpellShortcutContainer::mouseMoved(MouseEvent &event)
const int itemId = getItemByIndex(index);
spellPopup->setVisible(Visible_false);
const TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell && !spell->isEmpty())
+ if ((spell != nullptr) && !spell->isEmpty())
{
spellPopup->setItem(spell);
spellPopup->view(viewport->mMouseX, viewport->mMouseY);
@@ -353,13 +357,13 @@ void SpellShortcutContainer::mouseMoved(MouseEvent &event)
void SpellShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
}
void SpellShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/statspage.cpp b/src/gui/widgets/statspage.cpp
index db46931eb..eca98b1c4 100644
--- a/src/gui/widgets/statspage.cpp
+++ b/src/gui/widgets/statspage.cpp
@@ -72,7 +72,7 @@ void StatsPage::attributeChanged(const AttributesT id,
const int newVal A_UNUSED)
{
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
@@ -81,6 +81,6 @@ void StatsPage::statChanged(const AttributesT id,
const int oldVal2 A_UNUSED)
{
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
diff --git a/src/gui/widgets/statspagebasic.cpp b/src/gui/widgets/statspagebasic.cpp
index 23fd22243..bdf90e14f 100644
--- a/src/gui/widgets/statspagebasic.cpp
+++ b/src/gui/widgets/statspagebasic.cpp
@@ -83,7 +83,7 @@ void StatsPageBasic::statChanged(const AttributesT id,
const int oldVal2 A_UNUSED)
{
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
@@ -105,7 +105,7 @@ void StatsPageBasic::attributeChanged(const AttributesT id,
for (Attrs::const_iterator it = mAttrs.begin();
it != mAttrs.end(); ++it)
{
- if (it->second)
+ if (it->second != nullptr)
it->second->update();
}
return;
@@ -115,7 +115,7 @@ void StatsPageBasic::attributeChanged(const AttributesT id,
for (Attrs::const_iterator it = mAttrs.begin();
it != mAttrs.end(); ++it)
{
- if (it->second)
+ if (it->second != nullptr)
it->second->update();
}
return;
@@ -125,7 +125,7 @@ void StatsPageBasic::attributeChanged(const AttributesT id,
}
PRAGMA45(GCC diagnostic pop)
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
@@ -137,7 +137,7 @@ void StatsPageBasic::setPointsNeeded(const AttributesT id,
if (it != mAttrs.end())
{
AttrDisplay *const disp = it->second;
- if (disp && disp->getType() == AttrDisplay::CHANGEABLE)
+ if ((disp != nullptr) && disp->getType() == AttrDisplay::CHANGEABLE)
static_cast<ChangeDisplay*>(disp)->setPointsNeeded(needed);
}
}
@@ -151,7 +151,7 @@ std::string StatsPageBasic::getStatsStr() const
{
const ChangeDisplay *const attr = dynamic_cast<ChangeDisplay*>(
(*it).second);
- if (attr)
+ if (attr != nullptr)
{
str.append(strprintf("%s:%s ", attr->getShortName().c_str(),
attr->getValue().c_str()));
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 6df39dfe6..95ea305d6 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -120,7 +120,7 @@ void TabbedArea::postInit()
TabbedArea::~TabbedArea()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
// +++ virtual method calls
@@ -141,16 +141,16 @@ void TabbedArea::enableScrollButtons(const bool enable)
{
if (mEnableScrollButtons && !enable)
{
- if (mArrowButton[0])
+ if (mArrowButton[0] != nullptr)
remove(mArrowButton[0]);
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
remove(mArrowButton[1]);
}
else if (!mEnableScrollButtons && enable)
{
- if (mArrowButton[0])
+ if (mArrowButton[0] != nullptr)
add(mArrowButton[0]);
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
add(mArrowButton[1]);
}
mEnableScrollButtons = enable;
@@ -220,7 +220,7 @@ Widget *TabbedArea::getCurrentWidget() const
{
const Tab *const tab = getSelectedTab();
- if (tab)
+ if (tab != nullptr)
return getWidget(tab->getCaption());
else
return nullptr;
@@ -229,7 +229,7 @@ Widget *TabbedArea::getCurrentWidget() const
void TabbedArea::addTab(Tab *const tab,
Widget *const widget)
{
- if (!tab || !widget)
+ if ((tab == nullptr) || (widget == nullptr))
return;
tab->setTabbedArea(this);
@@ -238,7 +238,7 @@ void TabbedArea::addTab(Tab *const tab,
mTabContainer->add(tab);
mTabs.push_back(std::pair<Tab*, Widget*>(tab, widget));
- if (!mSelectedTab && tab->mVisible == Visible_true)
+ if ((mSelectedTab == nullptr) && tab->mVisible == Visible_true)
setSelectedTab(tab);
adjustTabPositions();
@@ -255,7 +255,7 @@ void TabbedArea::addTab(Tab *const tab,
void TabbedArea::adjustWidget(Widget *const widget) const
{
- if (!widget)
+ if (widget == nullptr)
return;
const int frameSize = 2 * mFrameSize;
widget->setSize(getWidth() - frameSize,
@@ -386,7 +386,7 @@ void TabbedArea::mousePressed(MouseEvent &event)
event.getX(), event.getY());
Tab *const tab = dynamic_cast<Tab *>(widget);
- if (tab)
+ if (tab != nullptr)
{
event.consume();
setSelectedTab(tab);
@@ -414,7 +414,7 @@ void TabbedArea::setSelectedTab(Tab *const tab)
Tab *const newTab = tab;
- if (newTab)
+ if (newTab != nullptr)
newTab->setCurrent();
widgetResized(Event(nullptr));
@@ -428,7 +428,7 @@ void TabbedArea::setSelectedTabDefault()
for (size_t i = 0; i < mTabs.size(); i++)
{
Tab *const tab = mTabs[i].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
{
setSelectedTab(tab);
return;
@@ -454,7 +454,7 @@ void TabbedArea::setSelectedTabByName(const std::string &name)
{
FOR_EACH (TabContainer::const_iterator, itr, mTabs)
{
- if ((*itr).first && (*itr).first->getCaption() == name)
+ if (((*itr).first != nullptr) && (*itr).first->getCaption() == name)
{
setSelectedTab((*itr).first);
return;
@@ -476,7 +476,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
Widget *const w = getCurrentWidget();
ScrollArea *const scr = dynamic_cast<ScrollArea *>(w);
- if (scr)
+ if (scr != nullptr)
{
if (mFollowDownScroll && height != 0)
{
@@ -492,14 +492,14 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
+ rect.height - height;
w->setSize(mWidgetContainer->getWidth() - frameSize,
mWidgetContainer->getHeight() - frameSize);
- if (newScroll)
+ if (newScroll != 0)
scr->setVerticalScrollAmount(newScroll);
}
}
}
}
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
{
// Check whether there is room to show more tabs now.
int innerWidth = w1 - 4 - mArrowButton[0]->getWidth()
@@ -508,10 +508,10 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
innerWidth = 0;
int newWidth = mVisibleTabsWidth;
- while (mTabScrollIndex && newWidth < innerWidth)
+ while ((mTabScrollIndex != 0u) && newWidth < innerWidth)
{
Tab *const tab = mTabs[mTabScrollIndex - 1].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
{
newWidth += tab->getWidth();
if (newWidth < innerWidth)
@@ -519,7 +519,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
}
}
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
{
// Move the right arrow to fit the windows content.
newWidth = width - mArrowButton[1]->getWidth() - mRightMargin;
@@ -539,7 +539,7 @@ void TabbedArea::updateTabsWidth()
FOR_EACH (TabContainer::const_iterator, itr, mTabs)
{
Tab *const tab = (*itr).first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
mTabsWidth += tab->getWidth();
}
updateVisibleTabsWidth();
@@ -551,7 +551,7 @@ void TabbedArea::updateVisibleTabsWidth()
for (size_t i = mTabScrollIndex, sz = mTabs.size(); i < sz; ++i)
{
Tab *const tab = mTabs[i].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
mVisibleTabsWidth += CAST_S32(tab->getWidth());
}
}
@@ -574,7 +574,7 @@ void TabbedArea::adjustSize()
mWidgetContainer->setPosition(0, maxTabHeight);
mWidgetContainer->setSize(width, height - maxTabHeight);
Widget *const w = getCurrentWidget();
- if (w)
+ if (w != nullptr)
{
const int wFrameSize = w->getFrameSize();
const int frame2 = 2 * wFrameSize;
@@ -600,7 +600,7 @@ void TabbedArea::adjustTabPositions()
for (size_t i = 0; i < sz; ++i)
{
const Tab *const tab = mTabs[i].first;
- if (tab &&
+ if ((tab != nullptr) &&
tab->mVisible == Visible_true &&
tab->getHeight() > maxTabHeight)
{
@@ -613,7 +613,7 @@ void TabbedArea::adjustTabPositions()
for (size_t i = mTabScrollIndex; i < sz; ++i)
{
Tab *const tab = mTabs[i].first;
- if (!tab || tab->mVisible == Visible_false)
+ if ((tab == nullptr) || tab->mVisible == Visible_false)
continue;
tab->setPosition(x, maxTabHeight - tab->getHeight());
x += tab->getWidth();
@@ -626,7 +626,7 @@ void TabbedArea::adjustTabPositions()
for (unsigned i = 0; i < mTabScrollIndex; ++i)
{
Tab *const tab = mTabs[i].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
{
x -= tab->getWidth();
tab->setPosition(x, maxTabHeight - tab->getHeight());
@@ -640,7 +640,7 @@ void TabbedArea::action(const ActionEvent& actionEvent)
Widget *const source = actionEvent.getSource();
Tab *const tab = dynamic_cast<Tab *>(source);
- if (tab)
+ if (tab != nullptr)
{
setSelectedTab(tab);
}
@@ -649,7 +649,7 @@ void TabbedArea::action(const ActionEvent& actionEvent)
const std::string &eventId = actionEvent.getId();
if (eventId == "shift_left")
{
- if (mTabScrollIndex)
+ if (mTabScrollIndex != 0u)
--mTabScrollIndex;
}
else if (eventId == "shift_right")
@@ -665,7 +665,7 @@ void TabbedArea::action(const ActionEvent& actionEvent)
void TabbedArea::updateArrowEnableState()
{
updateTabsWidth();
- if (!mArrowButton[0] || !mArrowButton[1])
+ if ((mArrowButton[0] == nullptr) || (mArrowButton[1] == nullptr))
return;
const int width = mDimension.width;
@@ -684,7 +684,7 @@ void TabbedArea::updateArrowEnableState()
}
// Left arrow consistency check
- if (!mTabScrollIndex)
+ if (mTabScrollIndex == 0u)
mArrowButton[0]->setEnabled(false);
else
mArrowButton[0]->setEnabled(true);
@@ -801,7 +801,7 @@ void TabbedArea::death(const Event &event)
{
Tab *const tab = dynamic_cast<Tab*>(event.getSource());
- if (tab)
+ if (tab != nullptr)
removeTab(tab);
else
BasicContainer::death(event);
diff --git a/src/gui/widgets/tabs/chat/channeltab.cpp b/src/gui/widgets/tabs/chat/channeltab.cpp
index d67de5287..37e6237a0 100644
--- a/src/gui/widgets/tabs/chat/channeltab.cpp
+++ b/src/gui/widgets/tabs/chat/channeltab.cpp
@@ -39,7 +39,7 @@ ChannelTab::ChannelTab(const Widget2 *const widget,
ChannelTab::~ChannelTab()
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->removeChannel(mChannelName);
}
@@ -55,11 +55,11 @@ bool ChannelTab::handleCommand(const std::string &restrict type,
{
if (type == "close")
{
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->scheduleDelete(this);
else
delete this;
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->defaultTab();
}
else
diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp
index e59d11eb4..fc2f09350 100644
--- a/src/gui/widgets/tabs/chat/chattab.cpp
+++ b/src/gui/widgets/tabs/chat/chattab.cpp
@@ -84,7 +84,7 @@ ChatTab::ChatTab(const Widget2 *const widget,
mTextOutput->setOpaque(Opaque_false);
mTextOutput->setMaxRow(config.getIntValue("ChatLogLength"));
- if (chatWindow)
+ if (chatWindow != nullptr)
mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler);
mTextOutput->setAlwaysUpdate(false);
@@ -92,13 +92,13 @@ ChatTab::ChatTab(const Widget2 *const widget,
ScrollArea::SHOW_ALWAYS);
mScrollArea->setScrollAmount(0, 1);
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->addTab(this);
}
ChatTab::~ChatTab()
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->removeTab(this);
delete2(mTextOutput);
@@ -225,7 +225,7 @@ void ChatTab::chatLog(std::string line,
// if configured, move magic messages log to debug chat tab
if (Net::getNetworkType() == ServerType::TMWATHENA
- && localChatTab && this == localChatTab
+ && (localChatTab != nullptr) && this == localChatTab
&& ((config.getBoolValue("showMagicInDebug")
&& own == ChatMsgType::BY_PLAYER
&& tmp.text.length() > 1
@@ -235,7 +235,7 @@ void ChatTab::chatLog(std::string line,
&& (own == ChatMsgType::BY_SERVER
|| tmp.nick.empty()))))
{
- if (debugChatTab)
+ if (debugChatTab != nullptr)
debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
return;
}
@@ -247,7 +247,7 @@ void ChatTab::chatLog(std::string line,
if (config.getBoolValue("useLocalTime"))
{
const tm *const timeInfo = localtime(&t);
- if (timeInfo)
+ if (timeInfo != nullptr)
{
line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(),
timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(),
@@ -292,7 +292,7 @@ void ChatTab::chatLog(std::string line,
addRow(line);
}
- if (chatWindow && this == localChatTab)
+ if ((chatWindow != nullptr) && this == localChatTab)
chatWindow->addToAwayLog(line);
mScrollArea->logic();
@@ -307,7 +307,7 @@ void ChatTab::chatLog(std::string line,
}
const TabbedArea *const tabArea = getTabbedArea();
- if (!tabArea)
+ if (tabArea == nullptr)
return;
const bool notFocused = WindowManager::getIsMinimized() ||
@@ -317,7 +317,8 @@ void ChatTab::chatLog(std::string line,
{
if (getFlash() == 0)
{
- if (chatWindow && chatWindow->findHighlight(tmp.text))
+ if (chatWindow != nullptr &&
+ chatWindow->findHighlight(tmp.text))
{
setFlash(2);
soundManager.playGuiSound(SOUND_HIGHLIGHT);
@@ -329,8 +330,11 @@ void ChatTab::chatLog(std::string line,
}
else if (getFlash() == 2)
{
- if (chatWindow && chatWindow->findHighlight(tmp.text))
+ if (chatWindow != nullptr &&
+ chatWindow->findHighlight(tmp.text))
+ {
soundManager.playGuiSound(SOUND_HIGHLIGHT);
+ }
}
}
@@ -341,13 +345,13 @@ void ChatTab::chatLog(std::string line,
{
if (own == ChatMsgType::BY_GM)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->unHideWindow();
soundManager.playGuiSound(SOUND_GLOBAL);
}
else if (own != ChatMsgType::BY_SERVER)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->unHideWindow();
playNewMessageSound();
}
@@ -358,7 +362,7 @@ void ChatTab::chatLog(std::string line,
void ChatTab::chatLog(const std::string &nick, std::string msg)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const ChatMsgTypeT byWho = (nick == localPlayer->getName()
@@ -441,7 +445,7 @@ void ChatTab::handleCommandStr(const std::string &msg)
void ChatTab::handleHelp(const std::string &msg)
{
- if (helpWindow)
+ if (helpWindow != nullptr)
{
helpWindow->search(msg);
helpWindow->requestMoveToTop();
@@ -457,7 +461,7 @@ bool ChatTab::handleCommands(const std::string &type, const std::string &args)
void ChatTab::saveToLogFile(const std::string &msg) const
{
- if (chatLogger)
+ if (chatLogger != nullptr)
{
if (getType() == ChatTabType::INPUT)
{
@@ -498,7 +502,7 @@ void ChatTab::addRow(std::string &line)
void ChatTab::loadFromLogFile(const std::string &name)
{
- if (chatLogger)
+ if (chatLogger != nullptr)
{
std::list<std::string> list;
chatLogger->loadLast(name, list, 5);
diff --git a/src/gui/widgets/tabs/chat/emulateguildtab.cpp b/src/gui/widgets/tabs/chat/emulateguildtab.cpp
index 4c4401242..4374f6b2c 100644
--- a/src/gui/widgets/tabs/chat/emulateguildtab.cpp
+++ b/src/gui/widgets/tabs/chat/emulateguildtab.cpp
@@ -56,13 +56,15 @@ EmulateGuildTab::~EmulateGuildTab()
bool EmulateGuildTab::handleCommand(const std::string &restrict type,
const std::string &restrict args)
{
- if (type == "invite" && guildManager)
+ if (guildManager == nullptr)
+ return false;
+ if (type == "invite")
guildManager->invite(args);
- else if (type == "leave" && guildManager)
+ else if (type == "leave")
guildManager->leave();
- else if (type == "kick" && guildManager)
+ else if (type == "kick")
guildManager->kick(args);
- else if (type == "notice" && guildManager)
+ else if (type == "notice")
guildManager->notice(args);
else
return false;
@@ -72,14 +74,14 @@ bool EmulateGuildTab::handleCommand(const std::string &restrict type,
void EmulateGuildTab::handleInput(const std::string &msg)
{
- if (!guildManager)
+ if (guildManager == nullptr)
return;
guildManager->chat(ChatWindow::doReplace(msg));
}
void EmulateGuildTab::getAutoCompleteList(StringVect &names) const
{
- if (!guildManager)
+ if (guildManager == nullptr)
return;
guildManager->getNames(names);
diff --git a/src/gui/widgets/tabs/chat/guildtab.cpp b/src/gui/widgets/tabs/chat/guildtab.cpp
index 982c27da5..51416b8ef 100644
--- a/src/gui/widgets/tabs/chat/guildtab.cpp
+++ b/src/gui/widgets/tabs/chat/guildtab.cpp
@@ -60,23 +60,23 @@ GuildTab::~GuildTab()
bool GuildTab::handleCommand(const std::string &restrict type,
const std::string &restrict args)
{
- if (type == "invite" && EAthena::taGuild)
+ if (type == "invite" && (EAthena::taGuild != nullptr))
{
guildHandler->invite(args);
}
- else if (type == "leave" && EAthena::taGuild)
+ else if (type == "leave" && (EAthena::taGuild != nullptr))
{
inputManager.executeChatCommand(InputAction::LEAVE_GUILD,
std::string(),
this);
}
- else if (type == "kick" && EAthena::taGuild)
+ else if (type == "kick" && (EAthena::taGuild != nullptr))
{
inputManager.executeChatCommand(InputAction::KICK_GUILD,
args,
this);
}
- else if (type == "notice" && EAthena::taGuild)
+ else if (type == "notice" && (EAthena::taGuild != nullptr))
{
inputManager.executeChatCommand(InputAction::GUILD_NOTICE,
args,
@@ -92,7 +92,7 @@ bool GuildTab::handleCommand(const std::string &restrict type,
void GuildTab::handleInput(const std::string &msg)
{
- if (!EAthena::taGuild)
+ if (EAthena::taGuild == nullptr)
return;
guildHandler->chat(ChatWindow::doReplace(msg));
@@ -100,7 +100,7 @@ void GuildTab::handleInput(const std::string &msg)
void GuildTab::getAutoCompleteList(StringVect &names) const
{
- if (EAthena::taGuild)
+ if (EAthena::taGuild != nullptr)
EAthena::taGuild->getNames(names);
}
diff --git a/src/gui/widgets/tabs/chat/partytab.cpp b/src/gui/widgets/tabs/chat/partytab.cpp
index 366a78241..befbb0393 100644
--- a/src/gui/widgets/tabs/chat/partytab.cpp
+++ b/src/gui/widgets/tabs/chat/partytab.cpp
@@ -118,12 +118,12 @@ bool PartyTab::handleCommand(const std::string &restrict type,
void PartyTab::getAutoCompleteList(StringVect &names) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Party *const p = localPlayer->getParty();
- if (p)
+ if (p != nullptr)
p->getNames(names);
}
diff --git a/src/gui/widgets/tabs/chat/whispertab.cpp b/src/gui/widgets/tabs/chat/whispertab.cpp
index 1cbf471c7..d8672b22d 100644
--- a/src/gui/widgets/tabs/chat/whispertab.cpp
+++ b/src/gui/widgets/tabs/chat/whispertab.cpp
@@ -45,7 +45,7 @@ WhisperTab::WhisperTab(const Widget2 *const widget,
WhisperTab::~WhisperTab()
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->removeWhisper(mNick);
}
@@ -55,7 +55,7 @@ void WhisperTab::handleInput(const std::string &msg)
newMsg = ChatWindow::doReplace(msg);
chatHandler->privateMessage(mNick, newMsg);
- if (localPlayer)
+ if (localPlayer != nullptr)
chatLog(localPlayer->getName(), newMsg);
else
chatLog("?", newMsg);
@@ -78,7 +78,7 @@ void WhisperTab::handleCommandStr(const std::string &msg)
{
std::string str = textToMe(args);
chatHandler->privateMessage(mNick, str);
- if (localPlayer)
+ if (localPlayer != nullptr)
chatLog(localPlayer->getName(), str);
else
chatLog("?", str);
@@ -94,11 +94,11 @@ bool WhisperTab::handleCommand(const std::string &restrict type,
{
if (type == "close")
{
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->scheduleDelete(this);
else
delete this;
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->defaultTab();
}
else
diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp
index e75e1d42d..4a600d2fd 100644
--- a/src/gui/widgets/tabs/debugwindowtabs.cpp
+++ b/src/gui/widgets/tabs/debugwindowtabs.cpp
@@ -171,7 +171,7 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) :
void MapDebugTab::logic()
{
BLOCK_START("MapDebugTab::logic")
- if (localPlayer)
+ if (localPlayer != nullptr)
{
// TRANSLATORS: debug window label
mXYLabel->setCaption(strprintf("%s (%d, %d)", _("Player Position:"),
@@ -184,7 +184,7 @@ void MapDebugTab::logic()
}
const Map *const map = Game::instance()->getCurrentMap();
- if (map && viewport)
+ if ((map != nullptr) && (viewport != nullptr))
{
// Get the current mouse position
const int mouseTileX = (viewport->mMouseX + viewport->getCameraX())
@@ -329,7 +329,7 @@ TargetDebugTab::TargetDebugTab(const Widget2 *const widget) :
void TargetDebugTab::logic()
{
BLOCK_START("TargetDebugTab::logic")
- if (localPlayer && localPlayer->getTarget())
+ if ((localPlayer != nullptr) && (localPlayer->getTarget() != nullptr))
{
const Being *const target = localPlayer->getTarget();
@@ -344,7 +344,7 @@ void TargetDebugTab::logic()
mTargetTypeLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Target type:"), toInt(target->getSubType(), int)));
- if (target->getLevel())
+ if (target->getLevel() != 0)
{
mTargetLevelLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
@@ -389,7 +389,7 @@ void TargetDebugTab::logic()
_("Effects:"), target->getStatusEffectsString().c_str()));
const int delay = target->getAttackDelay();
- if (delay)
+ if (delay != 0)
{
mAttackDelayLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
@@ -469,7 +469,7 @@ NetDebugTab::NetDebugTab(const Widget2 *const widget) :
void NetDebugTab::logic()
{
BLOCK_START("NetDebugTab::logic")
- if (localPlayer)
+ if (localPlayer != nullptr)
{
// TRANSLATORS: debug window label
mPingLabel->setCaption(strprintf(_("Ping: %s ms"),
diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp
index 0b958951a..7a37f2d89 100644
--- a/src/gui/widgets/tabs/setup_audio.cpp
+++ b/src/gui/widgets/tabs/setup_audio.cpp
@@ -181,10 +181,10 @@ void Setup_Audio::apply()
soundManager.init();
if (config.getBoolValue("playMusic"))
{
- if (viewport)
+ if (viewport != nullptr)
{ // in game
const Map *const map = viewport->getMap();
- if (map)
+ if (map != nullptr)
{
soundManager.playMusic(map->getMusicFile(),
SkipError_false);
diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp
index c9d0565b9..b27e1ec53 100644
--- a/src/gui/widgets/tabs/setup_chat.cpp
+++ b/src/gui/widgets/tabs/setup_chat.cpp
@@ -333,7 +333,7 @@ void Setup_Chat::apply()
{
SetupTabScroll::apply();
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->adjustTabSize();
chatWindow->parseHighlights();
diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp
index 9f7ad0154..f4efb2832 100644
--- a/src/gui/widgets/tabs/setup_colors.cpp
+++ b/src/gui/widgets/tabs/setup_colors.cpp
@@ -201,7 +201,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) :
Setup_Colors::~Setup_Colors()
{
- if (mPreviewBox && mPreviewBox->getContent() == mPreview)
+ if ((mPreviewBox != nullptr) && mPreviewBox->getContent() == mPreview)
delete2(mTextPreview)
else
delete2(mPreview)
@@ -246,7 +246,7 @@ void Setup_Colors::action(const ActionEvent &event)
void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
{
- if (!userPalette)
+ if (userPalette == nullptr)
return;
mSelected = mColorBox->getSelected();
@@ -308,7 +308,7 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
break;
case UserColorId::ATTACK_RANGE_BORDER:
case UserColorId::HOME_PLACE_BORDER:
- if (gui)
+ if (gui != nullptr)
mTextPreview->setFont(gui->getFont());
mTextPreview->setTextColor(col);
mTextPreview->setOutline(false);
@@ -398,21 +398,21 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
void Setup_Colors::setEntry(Slider *const s, TextField *const t,
const int value)
{
- if (s)
+ if (s != nullptr)
s->setValue(value);
- if (t)
+ if (t != nullptr)
t->setText(toString(value));
}
void Setup_Colors::apply()
{
- if (userPalette)
+ if (userPalette != nullptr)
userPalette->commit();
}
void Setup_Colors::cancel()
{
- if (!userPalette)
+ if (userPalette == nullptr)
return;
userPalette->rollback();
@@ -430,7 +430,7 @@ void Setup_Colors::cancel()
void Setup_Colors::updateGradType()
{
- if (mSelected == -1 || !userPalette)
+ if (mSelected == -1 || (userPalette == nullptr))
return;
mSelected = mColorBox->getSelected();
@@ -463,7 +463,7 @@ void Setup_Colors::updateGradType()
void Setup_Colors::updateColor() const
{
- if (mSelected == -1 || !userPalette)
+ if (mSelected == -1 || (userPalette == nullptr))
return;
const UserColorIdT type = static_cast<UserColorIdT>(
diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp
index 2b7c4bedd..dc1e531f8 100644
--- a/src/gui/widgets/tabs/setup_input.cpp
+++ b/src/gui/widgets/tabs/setup_input.cpp
@@ -91,7 +91,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) :
mKeyListModel->setSize(mActionDataSize[0]);
refreshKeys();
- if (gui)
+ if (gui != nullptr)
mKeyList->setFont(gui->getHelpFont());
mKeyList->addActionListener(this);
@@ -106,7 +106,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) :
mTabs->addActionListener(this);
mTabs->setActionEventId("tabs_");
int k = 0;
- while (pages[k])
+ while (pages[k] != nullptr)
{
mTabs->addButton(gettext(pages[k]), pages[k], false);
k ++;
@@ -257,13 +257,13 @@ void Setup_Input::action(const ActionEvent &event)
{
int k = 0;
std::string str("tabs_");
- while (pages[k])
+ while (pages[k] != nullptr)
{
if (str + pages[k] == id)
break;
k ++;
}
- if (pages[k] && str + pages[k] == id)
+ if ((pages[k] != nullptr) && str + pages[k] == id)
{
mKeyListModel->setSelectedData(k);
mKeyListModel->setSize(mActionDataSize[k]);
diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp
index 784197eb9..12cf331a0 100644
--- a/src/gui/widgets/tabs/setup_joystick.cpp
+++ b/src/gui/widgets/tabs/setup_joystick.cpp
@@ -73,7 +73,7 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
mNamesDropDown->setActionEventId("name");
mNamesDropDown->addActionListener(this);
- if (joystick)
+ if (joystick != nullptr)
{
mNamesDropDown->setSelected(joystick->getNumber());
}
@@ -113,12 +113,12 @@ void Setup_Joystick::action(const ActionEvent &event)
}
else if (source == mNamesDropDown)
{
- if (joystick)
+ if (joystick != nullptr)
joystick->setNumber(mNamesDropDown->getSelected());
}
else if (source == mDetectButton)
{
- if (joystick)
+ if (joystick != nullptr)
{
joystick->reload();
Joystick::getNames(mNamesModel->getNames());
@@ -127,7 +127,7 @@ void Setup_Joystick::action(const ActionEvent &event)
}
else
{
- if (!joystick)
+ if (joystick == nullptr)
return;
if (joystick->isCalibrating())
@@ -155,7 +155,7 @@ void Setup_Joystick::setTempEnabled(const bool sel)
{
Joystick::setEnabled(sel);
mCalibrateButton->setEnabled(sel);
- if (joystick)
+ if (joystick != nullptr)
{
if (sel)
joystick->open();
@@ -166,7 +166,7 @@ void Setup_Joystick::setTempEnabled(const bool sel)
void Setup_Joystick::cancel()
{
- if (joystick)
+ if (joystick != nullptr)
joystick->setEnabled(mOriginalJoystickEnabled);
if (mOriginalJoystickEnabled != mJoystickEnabled->isSelected())
@@ -177,7 +177,7 @@ void Setup_Joystick::cancel()
void Setup_Joystick::apply()
{
- if (!joystick)
+ if (joystick == nullptr)
return;
config.setValue("joystickEnabled", joystick->isEnabled());
diff --git a/src/gui/widgets/tabs/setup_mods.cpp b/src/gui/widgets/tabs/setup_mods.cpp
index 994001763..7ee8f2f34 100644
--- a/src/gui/widgets/tabs/setup_mods.cpp
+++ b/src/gui/widgets/tabs/setup_mods.cpp
@@ -82,7 +82,7 @@ void Setup_Mods::loadMods()
FOR_EACH (ModInfoCIterator, it, mods)
{
const ModInfo *const info = (*it).second;
- if (!info)
+ if (info == nullptr)
continue;
std::string name = info->getName();
@@ -108,7 +108,7 @@ void Setup_Mods::saveMods() const
FOR_EACH (std::set<SetupItem*>::const_iterator, it, modsList)
{
const SetupItem *const item = *it;
- if (!item)
+ if (item == nullptr)
continue;
const std::string val = item->getValue();
if (val == "1")
diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp
index cca3acee9..4f9d8f856 100644
--- a/src/gui/widgets/tabs/setup_players.cpp
+++ b/src/gui/widgets/tabs/setup_players.cpp
@@ -186,6 +186,6 @@ void Setup_Players::externalUpdated()
void Setup_Players::apply()
{
SetupTabScroll::apply();
- settings.enableRemoteCommands = serverConfig.getValue(
- "enableRemoteCommands", 1);
+ settings.enableRemoteCommands = (serverConfig.getValue(
+ "enableRemoteCommands", 1) != 0);
}
diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp
index 0054da32b..d81bca9a9 100644
--- a/src/gui/widgets/tabs/setup_relations.cpp
+++ b/src/gui/widgets/tabs/setup_relations.cpp
@@ -70,10 +70,10 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) :
mPlayerScrollArea(new ScrollArea(this, mPlayerTable)),
// TRANSLATORS: relation dialog button
mDefaultTrading(new CheckBox(this, _("Allow trading"),
- player_relations.getDefault() & PlayerRelation::TRADE)),
+ (player_relations.getDefault() & PlayerRelation::TRADE) != 0u)),
// TRANSLATORS: relation dialog button
mDefaultWhisper(new CheckBox(this, _("Allow whispers"),
- player_relations.getDefault() & PlayerRelation::WHISPER)),
+ (player_relations.getDefault() & PlayerRelation::WHISPER) != 0u)),
// TRANSLATORS: relation dialog button
mDeleteButton(new Button(this, _("Delete"), ACTION_DELETE, this)),
mIgnoreActionChoicesModel(new IgnoreChoicesListModel),
@@ -112,7 +112,7 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) :
int ignore_strategy_index = 0; // safe default
- if (player_relations.getPlayerIgnoreStrategy())
+ if (player_relations.getPlayerIgnoreStrategy() != nullptr)
{
ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex(
player_relations.getPlayerIgnoreStrategy()->mShortName);
@@ -177,10 +177,10 @@ void Setup_Relations::apply()
| (mDefaultTrading->isSelected() ? PlayerRelation::TRADE : 0)
| (mDefaultWhisper->isSelected() ? PlayerRelation::WHISPER : 0));
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->updatePlayerNames();
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setCheckNameSetting(true);
}
@@ -231,10 +231,10 @@ void Setup_Relations::updatedPlayer(const std::string &name A_UNUSED)
{
mPlayerTableModel->playerRelationsUpdated();
mDefaultTrading->setSelected(
- player_relations.getDefault() & PlayerRelation::TRADE);
+ (player_relations.getDefault() & PlayerRelation::TRADE) != 0u);
mDefaultWhisper->setSelected(
- player_relations.getDefault() & PlayerRelation::WHISPER);
- if (localPlayer)
+ (player_relations.getDefault() & PlayerRelation::WHISPER) != 0u);
+ if (localPlayer != nullptr)
localPlayer->updateName();
}
@@ -246,7 +246,7 @@ void Setup_Relations::updateAll()
mPlayerTableModel = model;
int ignore_strategy_index = 0; // safe default
- if (player_relations.getPlayerIgnoreStrategy())
+ if (player_relations.getPlayerIgnoreStrategy() != nullptr)
{
ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex(
player_relations.getPlayerIgnoreStrategy()->mShortName);
@@ -260,7 +260,7 @@ void Setup_Relations::updateAll()
void Setup_Relations::externalUpdated()
{
mDefaultTrading->setSelected(
- player_relations.getDefault() & PlayerRelation::TRADE);
+ (player_relations.getDefault() & PlayerRelation::TRADE) != 0u);
mDefaultWhisper->setSelected(
- player_relations.getDefault() & PlayerRelation::WHISPER);
+ (player_relations.getDefault() & PlayerRelation::WHISPER) != 0u);
}
diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp
index c97f192a0..47cbb2b92 100644
--- a/src/gui/widgets/tabs/setup_theme.cpp
+++ b/src/gui/widgets/tabs/setup_theme.cpp
@@ -237,7 +237,7 @@ void Setup_Theme::updateInfo()
{
delete mInfo;
mInfo = Theme::loadInfo(mTheme);
- if (mInfo)
+ if (mInfo != nullptr)
{
// TRANSLATORS: theme name
mThemeInfo = std::string(_("Name: ")).append(mInfo->name)
@@ -356,7 +356,7 @@ void Setup_Theme::apply()
}
config.setValue("selectedSkin", "");
- if (config.getStringValue("theme") != mTheme && mInfo)
+ if (config.getStringValue("theme") != mTheme && (mInfo != nullptr))
{
updateField(font, mFont);
updateField(boldFont, mBoldFont);
@@ -366,13 +366,13 @@ void Setup_Theme::apply()
updateField(npcFont, mNpcFont);
updateField(japanFont, mJapanFont);
updateField(chinaFont, mChinaFont);
- if (mInfo->fontSize)
+ if (mInfo->fontSize != 0)
{
const int size = mInfo->fontSize - 9;
if (size >= 0)
mFontSizeDropDown->setSelected(size);
}
- if (mInfo->npcfontSize)
+ if (mInfo->npcfontSize != 0)
{
const int size = mInfo->npcfontSize - 9;
if (size >= 0)
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index 24fa8951f..b11b20f39 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -360,7 +360,7 @@ void Setup_Video::action(const ActionEvent &event)
if (mode == "custom")
{
- if (mDialog)
+ if (mDialog != nullptr)
{
mode = mDialog->getText();
mDialog = nullptr;
@@ -379,7 +379,7 @@ void Setup_Video::action(const ActionEvent &event)
}
const int width = atoi(mode.substr(0, mode.find('x')).c_str());
const int height = atoi(mode.substr(mode.find('x') + 1).c_str());
- if (!width || !height)
+ if ((width == 0) || (height == 0))
return;
if (width != mainGraphics->mActualWidth
@@ -491,7 +491,7 @@ void Setup_Video::action(const ActionEvent &event)
else if (id == "detect")
{
TestMain *test = graphicsManager.startDetection();
- if (test)
+ if (test != nullptr)
{
Configuration &conf = test->getConfig();
const int val = conf.getValueInt("opengl", -1);
diff --git a/src/gui/widgets/tabs/setuptabscroll.cpp b/src/gui/widgets/tabs/setuptabscroll.cpp
index 898db7b3e..0cb623687 100644
--- a/src/gui/widgets/tabs/setuptabscroll.cpp
+++ b/src/gui/widgets/tabs/setuptabscroll.cpp
@@ -72,7 +72,7 @@ void SetupTabScroll::clear()
void SetupTabScroll::addControl(SetupItem *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
const std::string actionId = widget->getActionEventId();
if (!actionId.empty())
@@ -109,7 +109,7 @@ void SetupTabScroll::apply()
iter = mItems.begin(), iter_end = mItems.end();
iter != iter_end; ++ iter)
{
- if ((*iter).second)
+ if ((*iter).second != nullptr)
(*iter).second->apply((*iter).first);
}
}
@@ -120,7 +120,7 @@ void SetupTabScroll::cancel()
iter = mItems.begin(), iter_end = mItems.end();
iter != iter_end; ++ iter)
{
- if ((*iter).second)
+ if ((*iter).second != nullptr)
(*iter).second->cancel((*iter).first);
}
}
@@ -132,7 +132,7 @@ void SetupTabScroll::externalUpdated()
iter != iter_end; ++ iter)
{
SetupItem *const widget = (*iter).second;
- if (widget && widget->isMainConfig() == MainConfig_false)
+ if ((widget != nullptr) && widget->isMainConfig() == MainConfig_false)
widget->externalUpdated((*iter).first);
}
}
@@ -144,7 +144,7 @@ void SetupTabScroll::externalUnloaded()
iter != iter_end; ++ iter)
{
SetupItem *const widget = (*iter).second;
- if (widget && widget->isMainConfig() == MainConfig_false)
+ if ((widget != nullptr) && widget->isMainConfig() == MainConfig_false)
widget->externalUnloaded((*iter).first);
}
}
@@ -158,6 +158,6 @@ void SetupTabScroll::widgetResized(const Event &event A_UNUSED)
void SetupTabScroll::reread(const std::string &name)
{
SetupItem *const item = mItems[name + "Event"];
- if (item)
+ if (item != nullptr)
item->rereadValue();
}
diff --git a/src/gui/widgets/tabs/skilltab.h b/src/gui/widgets/tabs/skilltab.h
index 3845444d6..9086a4d0c 100644
--- a/src/gui/widgets/tabs/skilltab.h
+++ b/src/gui/widgets/tabs/skilltab.h
@@ -65,9 +65,9 @@ class SkillTab final : public Tab
SkillInfo *getSelectedInfo() const
{
- if (mListBox)
+ if (mListBox != nullptr)
return mListBox->getSelectedInfo();
- else if (mRectangleListBox)
+ else if (mRectangleListBox != nullptr)
return mRectangleListBox->getSelectedInfo();
else
return nullptr;
@@ -76,7 +76,7 @@ class SkillTab final : public Tab
protected:
void setCurrent() override
{
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->updateTabSelection();
}
diff --git a/src/gui/widgets/tabs/socialfriendsfunctor.h b/src/gui/widgets/tabs/socialfriendsfunctor.h
index a15f566d6..e68647a77 100644
--- a/src/gui/widgets/tabs/socialfriendsfunctor.h
+++ b/src/gui/widgets/tabs/socialfriendsfunctor.h
@@ -35,11 +35,14 @@ class SortFriendsFunctor final
bool operator() (const Avatar *const m1,
const Avatar *const m2) const
{
- if (!m1 || !m2)
+ if ((m1 == nullptr) || (m2 == nullptr))
return false;
if (m1->getOnline() != m2->getOnline())
- return m1->getOnline() > m2->getOnline();
+ {
+ return static_cast<int>(m1->getOnline()) >
+ static_cast<int>(m2->getOnline());
+ }
if (m1->getName() != m2->getName())
{
diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h
index 616fba43d..dfae61090 100644
--- a/src/gui/widgets/tabs/socialfriendstab.h
+++ b/src/gui/widgets/tabs/socialfriendstab.h
@@ -71,7 +71,7 @@ class SocialFriendsTab final : public SocialTab
void getPlayersAvatars()
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
@@ -90,7 +90,7 @@ class SocialFriendsTab final : public SocialTab
const std::set<std::string> &players2
= whoIsOnline->getOnlineNicks();
- if (!players)
+ if (players == nullptr)
return;
int online = 0;
@@ -99,8 +99,8 @@ class SocialFriendsTab final : public SocialTab
FOR_EACHP (StringVectCIter, it, players)
{
Avatar *const ava = new Avatar(*it);
- if (actorManager->findBeingByName(*it, ActorType::Player)
- || players2.find(*it) != players2.end())
+ if (actorManager->findBeingByName(*it, ActorType::Player) !=
+ nullptr || players2.find(*it) != players2.end())
{
ava->setOnline(true);
online ++;
diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h
index 53b7d46f4..775e22c6f 100644
--- a/src/gui/widgets/tabs/socialguildtab.h
+++ b/src/gui/widgets/tabs/socialguildtab.h
@@ -78,7 +78,7 @@ class SocialGuildTab final : public SocialTab,
const std::string name = mInviteDialog->getText();
guildHandler->invite(name);
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: chat message
@@ -96,7 +96,7 @@ class SocialGuildTab final : public SocialTab,
else if (eventId == "yes")
{
guildHandler->leave(mGuild->getId());
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: chat message
@@ -137,7 +137,7 @@ class SocialGuildTab final : public SocialTab,
void buildCounter(const int online0, const int total0) override final
{
- if (online0 || total0)
+ if ((online0 != 0) || (total0 != 0))
{
// TRANSLATORS: social window label
mCounterString = strprintf(_("Members: %u/%u"),
@@ -146,11 +146,11 @@ class SocialGuildTab final : public SocialTab,
}
else
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Guild *const guild = localPlayer->getGuild();
- if (!guild)
+ if (guild == nullptr)
return;
const Guild::MemberList *const members = guild->getMembers();
diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h
index a21594aab..f26e99421 100644
--- a/src/gui/widgets/tabs/socialguildtab2.h
+++ b/src/gui/widgets/tabs/socialguildtab2.h
@@ -77,11 +77,11 @@ class SocialGuildTab2 final : public SocialTab,
void buildCounter(const int online0 A_UNUSED,
const int total0 A_UNUSED) override final
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Guild *const guild = localPlayer->getGuild();
- if (!guild)
+ if (guild == nullptr)
return;
const Guild::MemberList *const members = guild->getMembers();
diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h
index 0f72b60f9..80b5910f3 100644
--- a/src/gui/widgets/tabs/socialnavigationtab.h
+++ b/src/gui/widgets/tabs/socialnavigationtab.h
@@ -72,11 +72,11 @@ class SocialNavigationTab final : public SocialTab
void updateList() override final
{
- if (!socialWindow || !localPlayer)
+ if ((socialWindow == nullptr) || (localPlayer == nullptr))
return;
const Map *const map = socialWindow->getMap();
- if (!map || map->empty())
+ if ((map == nullptr) || map->empty())
return;
if (socialWindow->getProcessedPortals())
@@ -105,7 +105,7 @@ class SocialNavigationTab final : public SocialTab
while (i != portals.end())
{
MapItem *portal = *i;
- if (!portal)
+ if (portal == nullptr)
continue;
const int x = portal->getX();
@@ -115,7 +115,7 @@ class SocialNavigationTab final : public SocialTab
portal->getComment().c_str(), x, y);
Avatar *const ava = new Avatar(name);
- if (localPlayer)
+ if (localPlayer != nullptr)
ava->setOnline(localPlayer->isReachable(x, y, true));
else
ava->setOnline(false);
@@ -130,21 +130,21 @@ class SocialNavigationTab final : public SocialTab
total ++;
if (config.getBoolValue("drawHotKeys")
- && idx < 80 && outfitWindow)
+ && idx < 80 && (outfitWindow != nullptr))
{
Being *const being = actorManager
->findPortalByTile(x, y);
- if (being)
+ if (being != nullptr)
{
being->setName(keyboard.getKeyShortString(
outfitWindow->keyName(idx)));
}
- if (specialLayer)
+ if (specialLayer != nullptr)
{
portal = specialLayer->getTile(
ava->getX(), ava->getY());
- if (portal)
+ if (portal != nullptr)
{
portal->setName(keyboard.getKeyShortString(
outfitWindow->keyName(idx)));
@@ -155,7 +155,7 @@ class SocialNavigationTab final : public SocialTab
++i;
idx ++;
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->setProcessedPortals(true);
// TRANSLATORS: social window label
@@ -167,7 +167,7 @@ class SocialNavigationTab final : public SocialTab
void selectIndex(const unsigned num) override final
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
@@ -175,19 +175,19 @@ class SocialNavigationTab final : public SocialTab
return;
const Avatar *const ava = avatars->at(num);
- if (ava && localPlayer)
+ if ((ava != nullptr) && (localPlayer != nullptr))
localPlayer->navigateTo(ava->getX(), ava->getY());
}
void updateNames()
{
- if (!socialWindow)
+ if (socialWindow == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return;
std::vector<Avatar*>::const_iterator i = avatars->begin();
@@ -195,12 +195,12 @@ class SocialNavigationTab final : public SocialTab
while (i != i_end)
{
Avatar *const ava = *i;
- if (!ava)
+ if (ava == nullptr)
break;
const MapItem *const item = map->findPortalXY(
ava->getX(), ava->getY());
- if (item)
+ if (item != nullptr)
{
const std::string name = strprintf("%s [%d %d]",
item->getComment().c_str(),
@@ -215,12 +215,12 @@ class SocialNavigationTab final : public SocialTab
int getPortalIndex(const int x, const int y)
{
- if (!socialWindow)
+ if (socialWindow == nullptr)
return -1;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return -1;
std::vector<Avatar*>::const_iterator i = avatars->begin();
@@ -229,7 +229,7 @@ class SocialNavigationTab final : public SocialTab
while (i != i_end)
{
const Avatar *const ava = *i;
- if (!ava)
+ if (ava == nullptr)
break;
if (ava->getX() == x && ava->getY() == y)
@@ -243,23 +243,23 @@ class SocialNavigationTab final : public SocialTab
void addPortal(const int x, const int y)
{
- if (!socialWindow || !localPlayer)
+ if ((socialWindow == nullptr) || (localPlayer == nullptr))
return;
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
const MapItem *const portal = map->findPortalXY(x, y);
- if (!portal)
+ if (portal == nullptr)
return;
const std::string name = strprintf("%s [%d %d]",
portal->getComment().c_str(), x, y);
Avatar *const ava = new Avatar(name);
- if (localPlayer)
+ if (localPlayer != nullptr)
ava->setOnline(localPlayer->isReachable(x, y, true));
else
ava->setOnline(false);
@@ -272,11 +272,11 @@ class SocialNavigationTab final : public SocialTab
void removePortal(const int x, const int y)
{
- if (!socialWindow || !localPlayer)
+ if ((socialWindow == nullptr) || (localPlayer == nullptr))
return;
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
@@ -287,7 +287,7 @@ class SocialNavigationTab final : public SocialTab
{
Avatar *ava = (*i);
- if (!ava)
+ if (ava == nullptr)
break;
if (ava->getX() == x && ava->getY() == y)
diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h
index 93625f7eb..b24f8f411 100644
--- a/src/gui/widgets/tabs/socialpartytab.h
+++ b/src/gui/widgets/tabs/socialpartytab.h
@@ -80,7 +80,7 @@ class SocialPartyTab final : public SocialTab,
const std::string name = mInviteDialog->getText();
partyHandler->invite(name);
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: chat message
@@ -97,7 +97,7 @@ class SocialPartyTab final : public SocialTab,
else if (eventId == "yes")
{
partyHandler->leave();
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: tab in social window
@@ -139,11 +139,11 @@ class SocialPartyTab final : public SocialTab,
void buildCounter(const int online0 A_UNUSED,
const int total0 A_UNUSED) override final
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Party *const party = localPlayer->getParty();
- if (!party)
+ if (party == nullptr)
return;
const Party::MemberList *const members = party->getMembers();
diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h
index 2a80b3005..447e0791e 100644
--- a/src/gui/widgets/tabs/socialplayerstab.h
+++ b/src/gui/widgets/tabs/socialplayerstab.h
@@ -71,18 +71,18 @@ class SocialPlayersTab final : public SocialTab
void updateAvatar(const std::string &name) override final
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
BLOCK_START("SocialPlayersTab::updateAvatar")
Avatar *const avatar = findAvatarbyName(name);
- if (!avatar)
+ if (avatar == nullptr)
return;
- if (Party::getParty(1))
+ if (Party::getParty(1) != nullptr)
{
const PartyMember *const
pm = Party::getParty(1)->getMember(name);
- if (pm && pm->getMaxHp() > 0)
+ if ((pm != nullptr) && pm->getMaxHp() > 0)
{
avatar->setMaxHp(pm->getMaxHp());
avatar->setHp(pm->getHp());
@@ -90,7 +90,7 @@ class SocialPlayersTab final : public SocialTab
}
const Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
avatar->setDamageHp(being->getDamageTaken());
avatar->setLevel(being->getLevel());
@@ -103,17 +103,17 @@ class SocialPlayersTab final : public SocialTab
void resetDamage(const std::string &name) override final
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
Avatar *const avatar = findAvatarbyName(name);
- if (!avatar)
+ if (avatar == nullptr)
return;
avatar->setDamageHp(0);
Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being)
+ if (being != nullptr)
being->setDamageTaken(0);
}
@@ -126,7 +126,7 @@ class SocialPlayersTab final : public SocialTab
while (i != i_end)
{
ava = (*i);
- if (ava && ava->getName() == name)
+ if ((ava != nullptr) && ava->getName() == name)
return ava;
++i;
}
@@ -139,7 +139,7 @@ class SocialPlayersTab final : public SocialTab
void getPlayersAvatars()
{
std::vector<Avatar*> *const avatars = mBeings->getMembers();
- if (actorManager)
+ if (actorManager != nullptr)
{
StringVect names;
actorManager->getPlayerNames(names, NpcNames_false);
@@ -149,7 +149,7 @@ class SocialPlayersTab final : public SocialTab
{
bool finded = false;
const Avatar *const ava = (*ai);
- if (!ava)
+ if (ava == nullptr)
break;
StringVectCIter i = names.begin();
diff --git a/src/gui/widgets/tabs/socialtab.h b/src/gui/widgets/tabs/socialtab.h
index 7458e62ee..34f864561 100644
--- a/src/gui/widgets/tabs/socialtab.h
+++ b/src/gui/widgets/tabs/socialtab.h
@@ -88,14 +88,14 @@ class SocialTab notfinal : public Tab
virtual ~SocialTab()
{
// Cleanup dialogs
- if (mInviteDialog)
+ if (mInviteDialog != nullptr)
{
mInviteDialog->close();
mInviteDialog->scheduleDelete();
mInviteDialog = nullptr;
}
- if (mConfirmDialog)
+ if (mConfirmDialog != nullptr)
{
mConfirmDialog->close();
mConfirmDialog->scheduleDelete();
@@ -122,13 +122,13 @@ class SocialTab notfinal : public Tab
void updateCounter() const
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateCounter(this, mCounterString);
}
void updateMenu() const
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateMenu(this, mMenuAction);
}
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index 95588e98d..a4a2f583b 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -130,11 +130,11 @@ Tab::Tab(const Widget2 *const widget) :
Tab::~Tab()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances--;
- if (mInstances == 0 && theme)
+ if (mInstances == 0 && (theme != nullptr))
{
for (int mode = 0; mode < TAB_COUNT; mode ++)
theme->unload(tabImg[mode]);
@@ -142,7 +142,7 @@ Tab::~Tab()
delete2(mLabel);
- if (mImage)
+ if (mImage != nullptr)
{
mImage->decRef();
mImage = nullptr;
@@ -162,7 +162,7 @@ void Tab::init()
if (mInstances == 0)
{
// Load the skin
- if (theme)
+ if (theme != nullptr)
{
for (int mode = 0; mode < TAB_COUNT; mode ++)
tabImg[mode] = theme->load(data[mode], "tab.xml");
@@ -174,7 +174,7 @@ void Tab::init()
add(mLabel);
const Skin *const skin = tabImg[TAB_STANDARD];
- if (!skin)
+ if (skin == nullptr)
return;
const int padding = skin->getPadding();
@@ -194,11 +194,11 @@ void Tab::updateAlpha()
for (int t = 0; t < TAB_COUNT; t++)
{
Skin *const skin = tabImg[t];
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -212,7 +212,7 @@ void Tab::draw(Graphics *const graphics)
int mode = TAB_STANDARD;
// check which type of tab to draw
- if (mTabbedArea)
+ if (mTabbedArea != nullptr)
{
int labelMode = mFlash;
@@ -223,7 +223,7 @@ void Tab::draw(Graphics *const graphics)
// if tab is selected, it doesnt need to highlight activity
mFlash = 0;
}
- else if (!labelMode)
+ else if (labelMode == 0)
{
if (mHasMouse)
{
@@ -269,7 +269,7 @@ void Tab::draw(Graphics *const graphics)
}
const Skin *const skin = tabImg[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Tab::draw")
return;
@@ -288,10 +288,10 @@ void Tab::draw(Graphics *const graphics)
mDimension.width, mDimension.height,
rect);
- if (mImage)
+ if (mImage != nullptr)
{
const Skin *const skin1 = tabImg[TAB_STANDARD];
- if (skin1)
+ if (skin1 != nullptr)
{
const int padding = skin1->getPadding();
graphics->calcTileCollection(mVertexes,
@@ -315,7 +315,7 @@ void Tab::safeDraw(Graphics *const graphics)
int mode = TAB_STANDARD;
// check which type of tab to draw
- if (mTabbedArea)
+ if (mTabbedArea != nullptr)
{
int labelMode = mFlash;
@@ -326,7 +326,7 @@ void Tab::safeDraw(Graphics *const graphics)
// if tab is selected, it doesnt need to highlight activity
mFlash = 0;
}
- else if (!labelMode)
+ else if (labelMode == 0)
{
if (mHasMouse)
{
@@ -370,7 +370,7 @@ void Tab::safeDraw(Graphics *const graphics)
}
const Skin *const skin = tabImg[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Tab::draw")
return;
@@ -381,10 +381,10 @@ void Tab::safeDraw(Graphics *const graphics)
graphics->drawImageRect(0, 0,
mDimension.width, mDimension.height,
skin->getBorder());
- if (mImage)
+ if (mImage != nullptr)
{
const Skin *const skin1 = tabImg[TAB_STANDARD];
- if (skin1)
+ if (skin1 != nullptr)
{
const int padding = skin1->getPadding();
graphics->drawImage(mImage, padding, padding);
@@ -407,7 +407,7 @@ void Tab::widgetMoved(const Event &event A_UNUSED)
void Tab::setLabelFont(Font *const font)
{
- if (!mLabel)
+ if (mLabel == nullptr)
return;
mLabel->setFont(font);
@@ -420,11 +420,11 @@ void Tab::setLabelFont(Font *const font)
void Tab::adjustSize()
{
const Skin *const skin = tabImg[TAB_STANDARD];
- if (!skin)
+ if (skin == nullptr)
return;
const int pad2 = skin->getPadding() * 2;
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &rect = mImage->mBounds;
setSize(rect.w + pad2, rect.h + pad2);
@@ -435,7 +435,7 @@ void Tab::adjustSize()
mLabel->getHeight() + pad2);
}
- if (mTabbedArea)
+ if (mTabbedArea != nullptr)
mTabbedArea->adjustTabPositions();
}
@@ -458,7 +458,7 @@ void Tab::setCaption(const std::string &caption)
void Tab::setImage(Image *const image)
{
- if (mImage)
+ if (mImage != nullptr)
mImage->decRef();
mImage = image;
adjustSize();
diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp
index 1f8db0d5e..2a8299ea1 100644
--- a/src/gui/widgets/tabstrip.cpp
+++ b/src/gui/widgets/tabstrip.cpp
@@ -50,7 +50,7 @@ Widget *TabStrip::createWidget(const std::string &text,
widget->setStick(true);
widget->setCaption(text);
widget->adjustSize();
- if ((!mCount && mPressFirst) || pressed)
+ if (((mCount == 0) && mPressFirst) || pressed)
widget->setPressed(true);
widget->setTag(CAST_S32(mWidgets.size()));
return widget;
@@ -59,11 +59,11 @@ Widget *TabStrip::createWidget(const std::string &text,
void TabStrip::action(const ActionEvent &event)
{
WidgetGroup::action(event);
- if (event.getSource())
+ if (event.getSource() != nullptr)
{
Widget *const widget = event.getSource();
Button *const button = static_cast<Button*>(widget);
- if (!button)
+ if (button == nullptr)
return;
if (button->isPressed2())
{
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 5b8acdb2e..31e000082 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -101,14 +101,14 @@ TextBox::TextBox(const Widget2 *const widget) :
TextBox::~TextBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
}
void TextBox::setTextWrapped(const std::string &text, const int minDimension)
{
// Make sure parent scroll area sets width of this widget
- if (getParent())
+ if (getParent() != nullptr)
getParent()->logic();
// Take the supplied minimum dimension as a starting
@@ -384,7 +384,7 @@ void TextBox::keyPressed(KeyEvent& event)
{
Widget *const par = getParent();
- if (par)
+ if (par != nullptr)
{
const int rowsPerPage = par->getChildrenArea().height
/ getFont()->getHeight();
@@ -400,7 +400,7 @@ void TextBox::keyPressed(KeyEvent& event)
{
Widget *const par = getParent();
- if (par)
+ if (par != nullptr)
{
const int rowsPerPage = par->getChildrenArea().height
/ getFont()->getHeight();
@@ -605,7 +605,7 @@ void TextBox::mousePressed(MouseEvent& event)
if (event.getButton() == MouseButton::LEFT)
{
const int height = getFont()->getHeight();
- if (!height)
+ if (height == 0)
return;
event.consume();
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index ce37879a4..e536b5b13 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -123,7 +123,7 @@ TextField::TextField(const Widget2 *restrict const widget,
mCaretColor(&getThemeColor(ThemeColorId::CARET)),
mMinimum(0),
mMaximum(0),
- mLastEventPaste(false),
+ mLastEventPaste(0),
mPadding(1),
mNumeric(false),
mLoseFocusOnTab(loseFocusOnTab),
@@ -144,7 +144,7 @@ TextField::TextField(const Widget2 *restrict const widget,
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->loadSkinRect(skin, "textfield.xml",
"textfield_background.xml");
@@ -153,7 +153,7 @@ TextField::TextField(const Widget2 *restrict const widget,
instances++;
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mFrameSize = mSkin->getOption("frameSize", 2);
@@ -163,22 +163,22 @@ TextField::TextField(const Widget2 *restrict const widget,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
TextField::~TextField()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
theme->unload(mSkin);
Theme::unloadRect(skin);
@@ -197,7 +197,7 @@ void TextField::updateAlpha()
mAlpha = alpha;
for (int a = 0; a < 9; a++)
{
- if (skin.grid[a])
+ if (skin.grid[a] != nullptr)
skin.grid[a]->setAlpha(mAlpha);
}
}
@@ -227,7 +227,7 @@ void TextField::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, mPadding - mXScroll, mPadding);
BLOCK_END("TextField::draw")
@@ -269,7 +269,7 @@ void TextField::setNumeric(const bool numeric)
return;
const char *const text = mText.c_str();
- for (const char *textPtr = text; *textPtr; ++textPtr)
+ for (const char *textPtr = text; *textPtr != 0; ++textPtr)
{
if (*textPtr < '0' || *textPtr > '9')
{
@@ -318,7 +318,8 @@ void TextField::keyPressed(KeyEvent &event)
{
if (mNumeric)
{
- if ((val >= '0' && val <= '9') || (val == '-' && !mCaretPosition))
+ if ((val >= '0' && val <= '9') ||
+ (val == '-' && mCaretPosition == 0u))
{
char buf[2];
buf[0] = CAST_8(val);
@@ -333,7 +334,7 @@ void TextField::keyPressed(KeyEvent &event)
return;
}
}
- else if (!mMaximum ||
+ else if ((mMaximum == 0) ||
CAST_S32(mText.size()) < mMaximum)
{
int len;
@@ -566,7 +567,7 @@ void TextField::handleCtrlKeys(const InputActionT action, bool &consumed)
#else // USE_SDL2
// hack to prevent paste key sticking
- if (mLastEventPaste && mLastEventPaste > cur_time)
+ if ((mLastEventPaste != 0) && mLastEventPaste > cur_time)
break;
handlePaste();
mLastEventPaste = cur_time + 2;
@@ -771,7 +772,7 @@ void TextField::mousePressed(MouseEvent &event)
if (event.getButton() == MouseButton::RIGHT)
{
#ifndef DYECMD
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->showTextFieldPopup(this);
#endif // DYECMD
}
@@ -817,14 +818,14 @@ void TextField::widgetHidden(const Event &event A_UNUSED)
void TextField::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
void TextField::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 04d2b39aa..53f84badc 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -55,13 +55,13 @@ TextPreview::TextPreview(const Widget2 *const widget,
mAllowLogic = false;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load("textpreview.xml", "");
}
instances++;
- if (mSkin)
+ if (mSkin != nullptr)
mPadding = mSkin->getOption("padding", 0);
adjustSize();
@@ -69,21 +69,21 @@ TextPreview::TextPreview(const Widget2 *const widget,
TextPreview::~TextPreview()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
}
void TextPreview::draw(Graphics *const graphics)
{
- if (!mFont)
+ if (mFont == nullptr)
return;
BLOCK_START("TextPreview::draw")
@@ -103,7 +103,7 @@ void TextPreview::draw(Graphics *const graphics)
mDimension.width, mDimension.height));
}
- if (mTextBGColor)
+ if (mTextBGColor != nullptr)
{
const int x = mFont->getWidth(mText) + 1
+ 2 * ((mOutline || mShadow) ? 1 :0);
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index 9aaad702d..e15dc2481 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -48,7 +48,7 @@ void VertContainer::add1(Widget *const widget, const int spacing)
void VertContainer::add2(Widget *const widget, const bool resizable,
const int spacing)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp
index dda7217c4..6b7642a3d 100644
--- a/src/gui/widgets/virtshortcutcontainer.cpp
+++ b/src/gui/widgets/virtshortcutcontainer.cpp
@@ -52,7 +52,7 @@ VirtShortcutContainer::VirtShortcutContainer(Widget2 *const widget,
mUnEquipedColor2(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE)),
mShortcut(shortcut)
{
- if (mShortcut)
+ if (mShortcut != nullptr)
mMaxItems = mShortcut->getItemCount();
else
mMaxItems = 0;
@@ -73,21 +73,21 @@ void VirtShortcutContainer::setWidget2(const Widget2 *const widget)
void VirtShortcutContainer::draw(Graphics *const graphics)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
BLOCK_START("VirtShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
drawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("VirtShortcutContainer::draw")
return;
@@ -106,12 +106,12 @@ void VirtShortcutContainer::draw(Graphics *const graphics)
const Item *const item = inv->findItem(mShortcut->getItem(i),
mShortcut->getItemColor(i));
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -147,21 +147,21 @@ void VirtShortcutContainer::draw(Graphics *const graphics)
void VirtShortcutContainer::safeDraw(Graphics *const graphics)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
BLOCK_START("VirtShortcutContainer::safeDraw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
safeDrawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("VirtShortcutContainer::safeDraw")
return;
@@ -180,12 +180,12 @@ void VirtShortcutContainer::safeDraw(Graphics *const graphics)
const Item *const item = inv->findItem(mShortcut->getItem(i),
mShortcut->getItemColor(i));
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -221,7 +221,7 @@ void VirtShortcutContainer::safeDraw(Graphics *const graphics)
void VirtShortcutContainer::mouseDragged(MouseEvent &event)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -240,12 +240,12 @@ void VirtShortcutContainer::mouseDragged(MouseEvent &event)
return;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
Item *const item = inv->findItem(itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
dragDrop.dragItem(item, DragDropSource::Drop);
mShortcut->removeItem(index);
@@ -260,7 +260,7 @@ void VirtShortcutContainer::mouseDragged(MouseEvent &event)
void VirtShortcutContainer::mousePressed(MouseEvent &event)
{
- if (!mShortcut || !inventoryWindow)
+ if ((mShortcut == nullptr) || (inventoryWindow == nullptr))
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -290,13 +290,13 @@ void VirtShortcutContainer::mousePressed(MouseEvent &event)
else if (eventButton == MouseButton::RIGHT)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
Item *const item = inv->findItem(mShortcut->getItem(index),
mShortcut->getItemColor(index));
- if (popupMenu)
+ if (popupMenu != nullptr)
{
popupMenu->showDropPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -307,7 +307,7 @@ void VirtShortcutContainer::mousePressed(MouseEvent &event)
void VirtShortcutContainer::mouseReleased(MouseEvent &event)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -339,7 +339,7 @@ void VirtShortcutContainer::mouseReleased(MouseEvent &event)
// Show ItemTooltip
void VirtShortcutContainer::mouseMoved(MouseEvent &event)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -354,12 +354,12 @@ void VirtShortcutContainer::mouseMoved(MouseEvent &event)
return;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const Item *const item = inv->findItem(itemId, itemColor);
- if (item && viewport)
+ if ((item != nullptr) && (viewport != nullptr))
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -372,12 +372,12 @@ void VirtShortcutContainer::mouseMoved(MouseEvent &event)
void VirtShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
void VirtShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp
index 9523cb4b5..260272936 100644
--- a/src/gui/widgets/widget.cpp
+++ b/src/gui/widgets/widget.cpp
@@ -179,7 +179,7 @@ void Widget::setDimension(const Rect& dimension)
bool Widget::isFocused() const
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return false;
return (mFocusHandler->isFocused(this));
@@ -187,7 +187,7 @@ bool Widget::isFocused() const
void Widget::setFocusable(const bool focusable)
{
- if (!focusable && isFocused() && mFocusHandler)
+ if (!focusable && isFocused() && (mFocusHandler != nullptr))
mFocusHandler->focusNone();
mFocusable = focusable;
}
@@ -199,7 +199,7 @@ bool Widget::isFocusable() const
void Widget::requestFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
if (isFocusable())
@@ -208,19 +208,19 @@ void Widget::requestFocus()
void Widget::requestMoveToTop()
{
- if (mParent)
+ if (mParent != nullptr)
mParent->moveToTop(this);
}
void Widget::requestMoveToBottom()
{
- if (mParent)
+ if (mParent != nullptr)
mParent->moveToBottom(this);
}
void Widget::setVisible(Visible visible)
{
- if (visible == Visible_false && isFocused() && mFocusHandler)
+ if (visible == Visible_false && isFocused() && (mFocusHandler != nullptr))
mFocusHandler->focusNone();
if (visible == Visible_true)
@@ -233,13 +233,13 @@ void Widget::setVisible(Visible visible)
void Widget::setFocusHandler(FocusHandler *const focusHandler)
{
- if (mFocusHandler)
+ if (mFocusHandler != nullptr)
{
releaseModalFocus();
mFocusHandler->remove(this);
}
- if (focusHandler)
+ if (focusHandler != nullptr)
focusHandler->add(this);
mFocusHandler = focusHandler;
@@ -307,7 +307,7 @@ void Widget::removeWidgetListener(WidgetListener *const widgetListener)
void Widget::getAbsolutePosition(int& x, int& y) const
{
- if (!mParent)
+ if (mParent == nullptr)
{
x = mDimension.x;
y = mDimension.y;
@@ -326,7 +326,7 @@ void Widget::getAbsolutePosition(int& x, int& y) const
Font* Widget::getFont() const
{
- if (!mCurrentFont)
+ if (mCurrentFont == nullptr)
return mGlobalFont;
return mCurrentFont;
}
@@ -337,7 +337,7 @@ void Widget::setGlobalFont(Font *const font)
FOR_EACH (std::list<Widget*>::const_iterator, iter, mAllWidgets)
{
- if (!(*iter)->mCurrentFont)
+ if ((*iter)->mCurrentFont == nullptr)
(*iter)->fontChanged();
}
}
@@ -375,38 +375,38 @@ bool Widget::isEnabled() const
void Widget::requestModalFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->requestModalFocus(this);
}
void Widget::requestModalMouseInputFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->requestModalMouseInputFocus(this);
}
void Widget::releaseModalFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->releaseModalFocus(this);
}
void Widget::releaseModalMouseInputFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->releaseModalMouseInputFocus(this);
}
bool Widget::isModalFocused() const
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return false;
- if (mParent)
+ if (mParent != nullptr)
{
return (mFocusHandler->getModalFocused() == this)
|| mParent->isModalFocused();
@@ -417,10 +417,10 @@ bool Widget::isModalFocused() const
bool Widget::isModalMouseInputFocused() const
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return false;
- if (mParent)
+ if (mParent != nullptr)
{
return (mFocusHandler->getModalMouseInputFocused() == this)
|| mParent->isModalMouseInputFocused();
@@ -506,7 +506,7 @@ void Widget::distributeShownEvent()
void Widget::showPart(const Rect &rectangle)
{
- if (mParent)
+ if (mParent != nullptr)
mParent->showWidgetPart(this, rectangle);
}
@@ -517,7 +517,7 @@ void Widget::windowResized()
Widget *Widget::callPostInit(Widget *const widget)
{
- if (widget)
+ if (widget != nullptr)
widget->postInit();
return widget;
}
diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h
index 2a8cae343..bbb1bc103 100644
--- a/src/gui/widgets/widget.h
+++ b/src/gui/widgets/widget.h
@@ -377,7 +377,7 @@ class Widget notfinal : public Widget2
bool isVisible() const A_WARN_UNUSED
{
return mVisible == Visible_true &&
- (!mParent || mParent->isVisible());
+ ((mParent == nullptr) || mParent->isVisible());
}
/**
diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h
index d76bd696e..ed9110ba4 100644
--- a/src/gui/widgets/widget2.h
+++ b/src/gui/widgets/widget2.h
@@ -52,7 +52,7 @@ class Widget2 notfinal
bool &valid)
const A_WARN_UNUSED A_INLINE
{
- if (!theme)
+ if (theme == nullptr)
return Palette::BLACK;
const ThemeColorIdT colorId = theme->getIdByChar(c, valid);
if (valid)
@@ -63,7 +63,7 @@ class Widget2 notfinal
virtual void setWidget2(const Widget2 *const widget)
{
- mPaletteOffset = widget ? widget->mPaletteOffset : 0;
+ mPaletteOffset = widget != nullptr ? widget->mPaletteOffset : 0;
}
void setPalette(int palette)
@@ -101,8 +101,8 @@ class Widget2 notfinal
protected:
explicit Widget2(const Widget2 *const widget) :
- mPaletteOffset(widget ? widget->mPaletteOffset : 0),
- mWindow(widget ? widget->getWindow() : nullptr),
+ mPaletteOffset(widget != nullptr ? widget->mPaletteOffset : 0),
+ mWindow(widget != nullptr ? widget->getWindow() : nullptr),
mForegroundColor2()
{
checkPalette();
diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp
index 18bd81a4f..72524b07c 100644
--- a/src/gui/widgets/widgetgroup.cpp
+++ b/src/gui/widgets/widgetgroup.cpp
@@ -46,7 +46,7 @@ void WidgetGroup::addButton(const std::string &restrict text,
return;
Widget *const widget = createWidget(text, pressed);
- if (widget)
+ if (widget != nullptr)
{
widget->setActionEventId(mActionEventId + tag);
widget->addActionListener(this);
@@ -66,7 +66,7 @@ void WidgetGroup::action(const ActionEvent &event)
void WidgetGroup::addWidget(Widget *const widget,
const int spacing)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 86c2188d1..4a3103b99 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -180,10 +180,10 @@ Window::Window(const std::string &caption,
int childPalette = 1;
// Loads the skin
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load(skin, "window.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
setPadding(mSkin->getPadding());
if (getOptionBool("titlebarBold"))
@@ -191,10 +191,10 @@ Window::Window(const std::string &caption,
mTitlePadding = mSkin->getTitlePadding();
mGripPadding = getOption("resizePadding");
mCaptionOffsetX = getOption("captionoffsetx");
- if (!mCaptionOffsetX)
+ if (mCaptionOffsetX == 0)
mCaptionOffsetX = 7;
mCaptionOffsetY = getOption("captionoffsety");
- if (!mCaptionOffsetY)
+ if (mCaptionOffsetY == 0)
mCaptionOffsetY = 5;
mCaptionAlign = static_cast<Graphics::Alignment>(
getOption("captionalign"));
@@ -205,7 +205,7 @@ Window::Window(const std::string &caption,
}
setTitleBarHeight(CAST_U32(
getOption("titlebarHeight")));
- if (!mTitleBarHeight)
+ if (mTitleBarHeight == 0u)
mTitleBarHeight = mCaptionFont->getHeight() + mPadding;
mTitleBarHeight += getOption("titlebarHeightRelative");
@@ -219,7 +219,7 @@ Window::Window(const std::string &caption,
}
// Add this window to the window container
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->add(this);
if (mModal == Modal_true)
@@ -241,11 +241,11 @@ Window::~Window()
{
logger->log("Window::~Window(\"%s\")", getCaption().c_str());
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
#ifndef DYECMD
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->unregisterWindowForReset(this);
#endif // DYECMD
@@ -265,13 +265,13 @@ Window::~Window()
windowInstances--;
- if (mSkin)
+ if (mSkin != nullptr)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
mSkin = nullptr;
}
- if (mGrip)
+ if (mGrip != nullptr)
{
mGrip->decRef();
mGrip = nullptr;
@@ -290,7 +290,7 @@ void Window::setWindowContainer(WindowContainer *const wc)
void Window::draw(Graphics *const graphics)
{
- if (!mSkin)
+ if (mSkin == nullptr)
return;
BLOCK_START("Window::draw")
@@ -318,7 +318,7 @@ void Window::draw(Graphics *const graphics)
{
const Image *const button = mSkin->getCloseImage(
mResizeHandles == CLOSE);
- if (button)
+ if (button != nullptr)
{
graphics->calcTileCollection(mVertexes,
button,
@@ -330,7 +330,7 @@ void Window::draw(Graphics *const graphics)
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
- if (button)
+ if (button != nullptr)
{
graphics->calcTileCollection(mVertexes,
button,
@@ -339,7 +339,7 @@ void Window::draw(Graphics *const graphics)
}
}
- if (mGrip)
+ if (mGrip != nullptr)
{
graphics->calcTileCollection(mVertexes,
mGrip,
@@ -383,7 +383,7 @@ void Window::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, x, mCaptionOffsetY);
}
@@ -402,7 +402,7 @@ void Window::draw(Graphics *const graphics)
void Window::safeDraw(Graphics *const graphics)
{
- if (!mSkin)
+ if (mSkin == nullptr)
return;
BLOCK_START("Window::safeDraw")
@@ -417,18 +417,18 @@ void Window::safeDraw(Graphics *const graphics)
{
const Image *const button = mSkin->getCloseImage(
mResizeHandles == CLOSE);
- if (button)
+ if (button != nullptr)
graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
}
// Draw Sticky Button
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
- if (button)
+ if (button != nullptr)
graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
}
- if (mGrip)
+ if (mGrip != nullptr)
graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
// Draw title
@@ -460,7 +460,7 @@ void Window::safeDraw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, x, mCaptionOffsetY);
}
@@ -488,7 +488,7 @@ void Window::setContentSize(int width, int height)
void Window::setLocationRelativeTo(const Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
int wx, wy;
@@ -505,7 +505,7 @@ void Window::setLocationRelativeTo(const Widget *const widget)
void Window::setLocationHorisontallyRelativeTo(const Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
int wx, wy;
@@ -566,7 +566,7 @@ void Window::setLocationRelativeTo(const ImagePosition::Type &position,
void Window::setMinWidth(const int width)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinWinWidth = width > mSkin->getMinWidth()
? width : mSkin->getMinWidth();
@@ -579,7 +579,7 @@ void Window::setMinWidth(const int width)
void Window::setMinHeight(const int height)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinWinHeight = height > mSkin->getMinHeight()
? height : mSkin->getMinHeight();
@@ -605,12 +605,12 @@ void Window::setResizable(const bool r)
if ((mGrip != nullptr) == r)
return;
- if (mGrip)
+ if (mGrip != nullptr)
mGrip->decRef();
if (r)
{
mGrip = Theme::getImageFromThemeXml("resize.xml", "");
- if (mGrip)
+ if (mGrip != nullptr)
{
mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
mGripRect.y = mDimension.height - mGrip->getHeight()
@@ -632,26 +632,26 @@ void Window::widgetResized(const Event &event A_UNUSED)
{
const Rect area = getChildrenArea();
- if (mGrip)
+ if (mGrip != nullptr)
{
mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
mGripRect.y = mDimension.height - mGrip->getHeight() - mGripPadding;
}
- if (mLayout)
+ if (mLayout != nullptr)
{
int w = area.width;
int h = area.height;
mLayout->reflow(w, h);
}
- if (mSkin)
+ if (mSkin != nullptr)
{
const bool showClose = mCloseWindowButton
- && mSkin->getCloseImage(false);
+ && (mSkin->getCloseImage(false) != nullptr);
if (showClose)
{
const Image *const button = mSkin->getCloseImage(false);
- if (button)
+ if (button != nullptr)
{
const int buttonWidth = button->getWidth();
mCloseRect.x = mDimension.width - buttonWidth - mClosePadding;
@@ -663,7 +663,7 @@ void Window::widgetResized(const Event &event A_UNUSED)
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
- if (button)
+ if (button != nullptr)
{
const int buttonWidth = button->getWidth();
int x = mDimension.width - buttonWidth
@@ -709,10 +709,10 @@ void Window::widgetHidden(const Event &event A_UNUSED)
mTextChanged = true;
mRedraw = true;
- if (gui)
+ if (gui != nullptr)
gui->setCursorType(Cursor::CURSOR_POINTER);
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
for (WidgetListConstIterator it = mWidgets.begin();
@@ -732,7 +732,7 @@ void Window::setCloseButton(const bool flag)
bool Window::isResizable() const
{
- return mGrip;
+ return mGrip != nullptr;
}
void Window::setStickyButton(const bool flag)
@@ -781,11 +781,11 @@ void Window::setVisible(const Visible visible, const bool forceSticky)
{
if (mPlayVisibleSound)
soundManager.playGuiSound(SOUND_SHOW_WINDOW);
- if (gui)
+ if (gui != nullptr)
{
MouseEvent *const event = reinterpret_cast<MouseEvent*>(
gui->createMouseEvent(this));
- if (event)
+ if (event != nullptr)
{
const int x = event->getX();
const int y = event->getY();
@@ -817,7 +817,7 @@ void Window::mousePressed(MouseEvent &event)
if (event.getSource() == this)
{
- if (getParent())
+ if (getParent() != nullptr)
getParent()->moveToTop(this);
mDragOffsetX = event.getX();
@@ -832,21 +832,25 @@ void Window::mousePressed(MouseEvent &event)
const int y = event.getY();
// Handle close button
- if (mCloseWindowButton && mSkin && mCloseRect.isPointInRect(x, y))
+ if (mCloseWindowButton &&
+ mSkin != nullptr &&
+ mCloseRect.isPointInRect(x, y))
{
mouseResize = 0;
- mMoved = 0;
+ mMoved = false;
event.consume();
close();
return;
}
// Handle sticky button
- if (mStickyButton && mSkin && mStickyRect.isPointInRect(x, y))
+ if (mStickyButton &&
+ mSkin != nullptr &&
+ mStickyRect.isPointInRect(x, y))
{
setSticky(!isSticky());
mouseResize = 0;
- mMoved = 0;
+ mMoved = false;
event.consume();
return;
}
@@ -856,14 +860,14 @@ void Window::mousePressed(MouseEvent &event)
if (mouseResize != 0)
event.consume();
if (canMove())
- mMoved = !mouseResize;
+ mMoved = (mouseResize == 0);
else
mMoved = false;
}
#ifndef DYECMD
else if (button == MouseButton::RIGHT)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
{
event.consume();
popupMenu->showWindowPopup(this);
@@ -879,10 +883,10 @@ void Window::close()
void Window::mouseReleased(MouseEvent &event A_UNUSED)
{
- if (mGrip && mouseResize)
+ if ((mGrip != nullptr) && (mouseResize != 0))
{
mouseResize = 0;
- if (gui)
+ if (gui != nullptr)
gui->setCursorType(Cursor::CURSOR_POINTER);
}
@@ -896,13 +900,13 @@ void Window::mouseEntered(MouseEvent &event)
void Window::mouseExited(MouseEvent &event A_UNUSED)
{
- if (mGrip && !mouseResize && gui)
+ if ((mGrip != nullptr) && (mouseResize == 0) && (gui != nullptr))
gui->setCursorType(Cursor::CURSOR_POINTER);
}
void Window::updateResizeHandler(MouseEvent &event)
{
- if (!gui)
+ if (gui == nullptr)
return;
#ifndef DYECMD
@@ -940,7 +944,7 @@ void Window::updateResizeHandler(MouseEvent &event)
void Window::mouseMoved(MouseEvent &event)
{
updateResizeHandler(event);
- if (popupManager && !event.isConsumed())
+ if ((popupManager != nullptr) && !event.isConsumed())
{
popupManager->hideBeingPopup();
popupManager->hideTextPopup();
@@ -983,31 +987,31 @@ void Window::mouseDragged(MouseEvent &event)
std::max(0, mDimension.y)));
}
- if (mouseResize && !mMoved)
+ if ((mouseResize != 0) && !mMoved)
{
const int dx = event.getX() - mDragOffsetX;
const int dy = event.getY() - mDragOffsetY;
Rect newDim = getDimension();
- if (mouseResize & (TOP | BOTTOM))
+ if ((mouseResize & (TOP | BOTTOM)) != 0)
{
const int newHeight = newDim.height
- + ((mouseResize & TOP) ? -dy : dy);
+ + ((mouseResize & TOP) != 0 ? -dy : dy);
newDim.height = std::min(mMaxWinHeight,
std::max(mMinWinHeight, newHeight));
- if (mouseResize & TOP)
+ if ((mouseResize & TOP) != 0)
newDim.y -= newDim.height - getHeight();
}
- if (mouseResize & (LEFT | RIGHT))
+ if ((mouseResize & (LEFT | RIGHT)) != 0)
{
const int newWidth = newDim.width
- + ((mouseResize & LEFT) ? -dx : dx);
+ + ((mouseResize & LEFT) != 0 ? -dx : dx);
newDim.width = std::min(mMaxWinWidth,
std::max(mMinWinWidth, newWidth));
- if (mouseResize & LEFT)
+ if ((mouseResize & LEFT) != 0)
newDim.x -= newDim.width - mDimension.width;
}
@@ -1028,10 +1032,10 @@ void Window::mouseDragged(MouseEvent &event)
newDim.height = mainGraphics->mHeight - newDim.y;
// Update mouse offset when dragging bottom or right border
- if (mouseResize & BOTTOM)
+ if ((mouseResize & BOTTOM) != 0)
mDragOffsetY += newDim.height - mDimension.height;
- if (mouseResize & RIGHT)
+ if ((mouseResize & RIGHT) != 0)
mDragOffsetX += newDim.width - mDimension.width;
// Set the new window and content dimensions
@@ -1046,7 +1050,7 @@ void Window::setModal(const Modal modal)
mModal = modal;
if (mModal == Modal_true)
{
- if (gui)
+ if (gui != nullptr)
gui->setCursorType(Cursor::CURSOR_POINTER);
requestModalFocus();
}
@@ -1078,7 +1082,7 @@ void Window::loadWindowState()
+ "Sticky", isSticky()));
}
- if (mGrip)
+ if (mGrip != nullptr)
{
int width = config.getValueInt(name + "WinWidth", mDefaultWidth);
int height = config.getValueInt(name + "WinHeight", mDefaultHeight);
@@ -1102,7 +1106,7 @@ void Window::loadWindowState()
// Check if the window is off screen...
ensureOnScreen();
- if (viewport)
+ if (viewport != nullptr)
{
int width = mDimension.width;
int height = mDimension.height;
@@ -1133,7 +1137,7 @@ void Window::saveWindowState()
if (mStickyButton)
config.setValue(mWindowName + "Sticky", isSticky());
- if (mGrip)
+ if (mGrip != nullptr)
{
if (getMinWidth() > mDimension.width)
setWidth(getMinWidth());
@@ -1257,7 +1261,7 @@ void Window::adjustPositionAfterResize(const int oldScreenWidth,
void Window::adjustSizeToScreen()
{
- if (!mGrip)
+ if (mGrip == nullptr)
return;
const int screenWidth = mainGraphics->mWidth;
@@ -1289,7 +1293,7 @@ int Window::getResizeHandles(const MouseEvent &event)
if (!mStickyButtonLock || !mSticky)
{
- if (mGrip &&
+ if ((mGrip != nullptr) &&
(y > mTitleBarHeight ||
(CAST_S32(y) < mPadding &&
CAST_S32(mTitleBarHeight) > mPadding)))
@@ -1319,7 +1323,7 @@ bool Window::isResizeAllowed(const MouseEvent &event) const
{
const int y = event.getY();
- if (mGrip &&
+ if ((mGrip != nullptr) &&
(y > CAST_S32(mTitleBarHeight) ||
y < mPadding))
{
@@ -1337,7 +1341,7 @@ bool Window::isResizeAllowed(const MouseEvent &event) const
Layout &Window::getLayout()
{
- if (!mLayout)
+ if (mLayout == nullptr)
mLayout = new Layout;
return *mLayout;
}
@@ -1347,7 +1351,7 @@ void Window::clearLayout()
clear();
// Recreate layout instance when one is present
- if (mLayout)
+ if (mLayout != nullptr)
{
delete mLayout;
mLayout = new Layout;
@@ -1368,7 +1372,7 @@ ContainerPlacer Window::getPlacer(const int x, const int y)
void Window::reflowLayout(int w, int h)
{
- if (!mLayout)
+ if (mLayout == nullptr)
return;
mLayout->reflow(w, h);
@@ -1378,7 +1382,7 @@ void Window::reflowLayout(int w, int h)
void Window::redraw()
{
- if (mLayout)
+ if (mLayout != nullptr)
{
const Rect area = getChildrenArea();
int w = area.width;
@@ -1426,10 +1430,10 @@ Rect Window::getWindowArea() const
int Window::getOption(const std::string &name, const int def) const
{
- if (mSkin)
+ if (mSkin != nullptr)
{
const int val = mSkin->getOption(name);
- if (val)
+ if (val != 0)
return val;
return def;
}
@@ -1438,8 +1442,8 @@ int Window::getOption(const std::string &name, const int def) const
bool Window::getOptionBool(const std::string &name, const bool def) const
{
- if (mSkin)
- return mSkin->getOption(name, def) != 0;
+ if (mSkin != nullptr)
+ return mSkin->getOption(name, static_cast<int>(def)) != 0;
return def;
}
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
index 9529945b0..38efd1a77 100644
--- a/src/gui/widgets/windowcontainer.cpp
+++ b/src/gui/widgets/windowcontainer.cpp
@@ -44,7 +44,7 @@ void WindowContainer::slowLogic()
void WindowContainer::scheduleDelete(Widget *const widget)
{
- if (widget)
+ if (widget != nullptr)
mDeathList.push_back(widget);
}
diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp
index ffc3e6593..c683a6f77 100644
--- a/src/gui/windowmanager.cpp
+++ b/src/gui/windowmanager.cpp
@@ -194,7 +194,7 @@ void WindowManager::updateTitle()
void WindowManager::setFramerate(const unsigned int fpsLimit)
{
- if (!fpsLimit)
+ if (fpsLimit == 0u)
return;
if (!settings.limitFps)
@@ -240,7 +240,7 @@ void WindowManager::resizeVideo(int actualWidth,
actualWidth = std::max(470, actualWidth);
actualHeight = std::max(320, actualHeight);
- if (!mainGraphics)
+ if (mainGraphics == nullptr)
return;
if (!always
&& mainGraphics->mActualWidth == actualWidth
@@ -255,21 +255,21 @@ void WindowManager::resizeVideo(int actualWidth,
const int height = mainGraphics->mHeight;
touchManager.resize(width, height);
- if (gui)
+ if (gui != nullptr)
gui->videoResized();
- if (desktop)
+ if (desktop != nullptr)
desktop->setSize(width, height);
client->moveButtons(width);
#ifndef DYECMD
Game *const game = Game::instance();
- if (game)
+ if (game != nullptr)
game->videoResized(width, height);
#endif // DYECMD
- if (gui)
+ if (gui != nullptr)
gui->draw();
config.setValue("screenwidth", actualWidth);
@@ -285,7 +285,7 @@ bool WindowManager::setFullScreen(const bool fs)
return true;
#else // __native_client__
- if (!mainGraphics)
+ if (mainGraphics == nullptr)
return false;
return mainGraphics->setFullscreen(fs);
#endif // __native_client__
@@ -400,7 +400,7 @@ void WindowManager::setIcon()
#else // WIN32
mIcon = MIMG_Load(iconFile.c_str());
- if (mIcon)
+ if (mIcon != nullptr)
{
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(mIcon, SDL_ALPHA_OPAQUE);
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index e9a37b2d4..f45b292f0 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -51,9 +51,9 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
ActionListener(),
SelectionListener(),
MouseListener(),
- mSkin(theme ? theme->load("windowmenu.xml", "") : nullptr),
- mPadding(mSkin ? mSkin->getPadding() : 1),
- mSpacing(mSkin ? mSkin->getOption("spacing", 3) : 3),
+ mSkin(theme != nullptr ? theme->load("windowmenu.xml", "") : nullptr),
+ mPadding(mSkin != nullptr ? mSkin->getPadding() : 1),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing", 3) : 3),
mButtons(),
mButtonTexts(),
mButtonNames(),
@@ -192,7 +192,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
_("Setup"), x, h, InputAction::WINDOW_SETUP);
x += mPadding - mSpacing;
- if (mainGraphics)
+ if (mainGraphics != nullptr)
setDimension(Rect(mainGraphics->mWidth - x, 0, x, h));
loadButtons();
@@ -219,16 +219,16 @@ WindowMenu::~WindowMenu()
FOR_EACH (std::vector <Button*>::iterator, it, mButtons)
{
Button *const btn = *it;
- if (!btn)
+ if (btn == nullptr)
continue;
if (btn->mVisible == Visible_false)
delete btn;
}
delete_all(mButtonTexts);
mButtonTexts.clear();
- if (mSkin)
+ if (mSkin != nullptr)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
mSkin = nullptr;
}
@@ -243,7 +243,7 @@ void WindowMenu::action(const ActionEvent &event)
return;
const ButtonInfo *const info = (*it).second;
- if (!info)
+ if (info == nullptr)
return;
inputManager.executeAction(info->key);
@@ -272,7 +272,7 @@ void WindowMenu::addButton(const char *const text,
void WindowMenu::mousePressed(MouseEvent &event)
{
- if (!popupManager)
+ if (popupManager == nullptr)
return;
if (event.getButton() == MouseButton::RIGHT)
@@ -282,9 +282,9 @@ void WindowMenu::mousePressed(MouseEvent &event)
event.consume();
Button *const btn = dynamic_cast<Button*>(event.getSource());
- if (!btn)
+ if (btn == nullptr)
return;
- if (popupMenu)
+ if (popupMenu != nullptr)
{
popupMenu->showPopup(getX() + event.getX(),
getY() + event.getY(), btn);
@@ -296,7 +296,7 @@ void WindowMenu::mouseMoved(MouseEvent &event)
{
mHaveMouse = true;
- if (!textPopup)
+ if (textPopup == nullptr)
return;
if (event.getSource() == this)
@@ -308,7 +308,7 @@ void WindowMenu::mouseMoved(MouseEvent &event)
const Button *const btn = dynamic_cast<const Button *>(
event.getSource());
- if (!btn)
+ if (btn == nullptr)
{
textPopup->hide();
return;
@@ -334,7 +334,7 @@ void WindowMenu::mouseMoved(MouseEvent &event)
void WindowMenu::mouseExited(MouseEvent& event A_UNUSED)
{
mHaveMouse = false;
- if (!textPopup)
+ if (textPopup == nullptr)
return;
textPopup->hide();
@@ -344,7 +344,7 @@ void WindowMenu::showButton(const std::string &name,
const Visible visible)
{
const ButtonInfo *const info = mButtonNames[name];
- if (!info || !info->button)
+ if ((info == nullptr) || (info->button == nullptr))
return;
info->button->setVisible(visible);
@@ -362,7 +362,7 @@ void WindowMenu::updateButtons()
FOR_EACH (std::vector <Button*>::iterator, it, mButtons)
{
Button *const btn = *it;
- if (!btn)
+ if (btn == nullptr)
continue;
if (btn->mVisible == Visible_true)
{
@@ -373,7 +373,7 @@ void WindowMenu::updateButtons()
}
}
x += mPadding - mSpacing;
- if (mainGraphics)
+ if (mainGraphics != nullptr)
setDimension(Rect(mainGraphics->mWidth - x, 0, x, h));
}
@@ -388,8 +388,12 @@ void WindowMenu::loadButtons()
it_fend = mButtonNames.end(); it != it_fend; ++it)
{
const ButtonInfo *const info = (*it).second;
- if (!info || !info->button || info->visible == Visible_true)
+ if (info == nullptr ||
+ info->button == nullptr ||
+ info->visible == Visible_true)
+ {
continue;
+ }
info->button->setVisible(Visible_false);
}
updateButtons();
@@ -403,7 +407,7 @@ void WindowMenu::loadButtons()
if (str.empty() || str == "SET")
continue;
const ButtonInfo *const info = mButtonNames[str];
- if (!info || !info->button)
+ if ((info == nullptr) || (info->button == nullptr))
continue;
info->button->setVisible(Visible_false);
}
@@ -415,7 +419,7 @@ void WindowMenu::loadButtons()
it_fend = mButtonNames.end(); it != it_fend; ++it)
{
const ButtonInfo *const info = (*it).second;
- if (!info || !info->button)
+ if ((info == nullptr) || (info->button == nullptr))
continue;
Button *const button = info->button;
const std::string &str = button->getActionEventId();
@@ -432,7 +436,7 @@ void WindowMenu::saveButtons() const
FOR_EACH (std::vector <Button*>::const_iterator, it, mButtons)
{
const Button *const btn = *it;
- if (btn && btn->mVisible == Visible_false)
+ if ((btn != nullptr) && btn->mVisible == Visible_false)
{
config.setValue("windowmenu" + toString(i),
btn->getActionEventId());
@@ -445,8 +449,11 @@ void WindowMenu::saveButtons() const
void WindowMenu::drawChildren(Graphics *const graphics)
{
- if (mHaveMouse || !mAutoHide || (mAutoHide == 1
- && mainGraphics && (mSmallWindow || mainGraphics->mWidth > 800)))
+ if (mHaveMouse ||
+ mAutoHide == 0 ||
+ (mAutoHide == 1 &&
+ mainGraphics != nullptr &&
+ (mSmallWindow || mainGraphics->mWidth > 800)))
{
Container::drawChildren(graphics);
}
@@ -454,8 +461,11 @@ void WindowMenu::drawChildren(Graphics *const graphics)
void WindowMenu::safeDrawChildren(Graphics *const graphics)
{
- if (mHaveMouse || !mAutoHide || (mAutoHide == 1
- && mainGraphics && (mSmallWindow || mainGraphics->mWidth > 800)))
+ if (mHaveMouse ||
+ mAutoHide == 0 ||
+ (mAutoHide == 1 &&
+ mainGraphics != nullptr &&
+ (mSmallWindow || mainGraphics->mWidth > 800)))
{
Container::safeDrawChildren(graphics);
}
diff --git a/src/gui/windows/bankwindow.cpp b/src/gui/windows/bankwindow.cpp
index d6e33148c..242d30aa1 100644
--- a/src/gui/windows/bankwindow.cpp
+++ b/src/gui/windows/bankwindow.cpp
@@ -55,7 +55,7 @@ BankWindow::BankWindow() :
setWindowName("Bank");
setCloseButton(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mBankMoneyLabel->adjustSize();
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index a07f9d849..edac6293d 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -74,7 +74,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const int price1 = item1->getPrice();
@@ -93,7 +93,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const std::string &name1 = item1->getDisplayName();
@@ -112,7 +112,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const int id1 = item1->getId();
@@ -131,7 +131,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const int weight1 = item1->getInfo().getWeight();
@@ -150,7 +150,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const int amount1 = item1->getQuantity();
@@ -169,7 +169,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const ItemDbTypeT type1 = item1->getInfo().getType();
@@ -263,7 +263,7 @@ BuyDialog::BuyDialog(const Being *const being,
mFilterTextField(new TextField(this, "", LoseFocusOnTab_true,
this, "namefilter", true)),
mFilterLabel(nullptr),
- mNick(being ? being->getName() : std::string()),
+ mNick(being != nullptr ? being->getName() : std::string()),
mCurrency(currency),
mNpcId(fromInt(Vending, BeingId)),
mMoney(0),
@@ -293,7 +293,7 @@ void BuyDialog::init()
}
#endif // TMWA_SUPPORT
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mShopItems = new ShopItems(false,
@@ -376,7 +376,7 @@ void BuyDialog::init()
placer(0, 6, mAmountLabel, 2);
placer(2, 6, mAmountField, 2);
placer(0, 7, mMoneyLabel, 8);
- if (mSortDropDown)
+ if (mSortDropDown != nullptr)
{
placer(0, 8, mSortDropDown, 2);
}
@@ -409,7 +409,7 @@ void BuyDialog::init()
instances.push_back(this);
setVisible(Visible_true);
- if (mSortDropDown)
+ if (mSortDropDown != nullptr)
mSortDropDown->setSelected(config.getIntValue("buySortOrder"));
}
@@ -418,7 +418,7 @@ BuyDialog::~BuyDialog()
delete2(mShopItems);
delete2(mSortModel);
instances.remove(this);
- if (buySellHandler)
+ if (buySellHandler != nullptr)
buySellHandler->cleanDialogReference(this);
}
@@ -459,7 +459,7 @@ ShopItem *BuyDialog::addItem(const int id,
void BuyDialog::sort()
{
- if (mSortDropDown && mShopItems)
+ if ((mSortDropDown != nullptr) && (mShopItems != nullptr))
{
std::vector<ShopItem*> &items = mShopItems->items();
switch (mSortDropDown->getSelected())
@@ -525,7 +525,7 @@ void BuyDialog::action(const ActionEvent &event)
else if (eventId == "sort")
{
sort();
- if (mSortDropDown)
+ if (mSortDropDown != nullptr)
config.setValue("buySortOrder", mSortDropDown->getSelected());
return;
}
@@ -576,7 +576,7 @@ void BuyDialog::action(const ActionEvent &event)
else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems)
{
ShopItem *const item = mShopItems->at(selectedItem);
- if (!item)
+ if (item == nullptr)
return;
if (mNpcId == fromInt(Items, BeingId))
{
@@ -587,7 +587,7 @@ void BuyDialog::action(const ActionEvent &event)
#ifdef TMWA_SUPPORT
else if (mNpcId == fromInt(Nick, BeingId))
{
- if (tradeWindow)
+ if (tradeWindow != nullptr)
{
buySellHandler->sendBuyRequest(mNick,
item, mAmountItems);
@@ -600,7 +600,7 @@ void BuyDialog::action(const ActionEvent &event)
{
item->increaseUsedQuantity(mAmountItems);
item->update();
- if (mConfirmButton)
+ if (mConfirmButton != nullptr)
mConfirmButton->setEnabled(true);
}
#ifdef TMWA_SUPPORT
@@ -613,7 +613,7 @@ void BuyDialog::action(const ActionEvent &event)
{
item->increaseUsedQuantity(mAmountItems);
item->update();
- if (mConfirmButton)
+ if (mConfirmButton != nullptr)
mConfirmButton->setEnabled(true);
}
else if (mNpcId == fromInt(Market, BeingId))
@@ -656,7 +656,7 @@ void BuyDialog::action(const ActionEvent &event)
const Being *const being = actorManager->findBeingByName(
mNick,
ActorType::Player);
- if (being)
+ if (being != nullptr)
{
vendingHandler->buyItems(being,
items);
@@ -680,7 +680,7 @@ void BuyDialog::updateSlider(const int selectedItem)
// that can be bought
mMaxItems -= mAmountItems;
const ShopItem *const item = mShopItems->at(selectedItem);
- if (item)
+ if (item != nullptr)
setMoney(mMoney - mAmountItems * item->getPrice());
else
setMoney(mMoney);
@@ -711,14 +711,14 @@ void BuyDialog::updateButtonsAndLabels()
if (selectedItem > -1)
{
const ShopItem *const item = mShopItems->at(selectedItem);
- if (item)
+ if (item != nullptr)
{
const int itemPrice = item->getPrice();
// Calculate how many the player can afford
if (mNpcId == fromInt(Items, BeingId))
mMaxItems = 100;
- else if (itemPrice)
+ else if (itemPrice != 0)
mMaxItems = mMoney / itemPrice;
else
mMaxItems = 1;
@@ -755,7 +755,7 @@ void BuyDialog::setVisible(Visible visible)
{
Window::setVisible(visible);
- if (visible == Visible_true && mShopItemList)
+ if (visible == Visible_true && (mShopItemList != nullptr))
mShopItemList->requestFocus();
else
scheduleDelete();
@@ -765,7 +765,7 @@ void BuyDialog::closeAll()
{
FOR_EACH (DialogList::const_iterator, it, instances)
{
- if (*it)
+ if (*it != nullptr)
(*it)->close();
}
}
@@ -778,7 +778,7 @@ void BuyDialog::applyNameFilter(const std::string &filter)
FOR_EACH (std::vector<ShopItem*>::iterator, it, items)
{
ShopItem *const item = *it;
- if (!item)
+ if (item == nullptr)
continue;
std::string name = item->getName();
toLower(name);
diff --git a/src/gui/windows/buyingstoreselldialog.cpp b/src/gui/windows/buyingstoreselldialog.cpp
index 8fd3103e6..369d52223 100644
--- a/src/gui/windows/buyingstoreselldialog.cpp
+++ b/src/gui/windows/buyingstoreselldialog.cpp
@@ -53,15 +53,15 @@ void BuyingStoreSellDialog::sellAction(const ActionEvent &event A_UNUSED)
const int selectedItem = mShopItemList->getSelected();
const ShopItem *const item1 = mShopItems->at(selectedItem);
- if (!item1 || PlayerInfo::isItemProtected(item1->getId()))
+ if ((item1 == nullptr) || PlayerInfo::isItemProtected(item1->getId()))
return;
const Being *const being = actorManager->findBeing(mAccountId);
- if (!being)
+ if (being == nullptr)
return;
const Item *const item2 = PlayerInfo::getInventory()->findItem(
item1->getId(),
item1->getColor());
- if (!item2)
+ if (item2 == nullptr)
return;
mPlayerMoney += mAmountItems * item1->getPrice();
diff --git a/src/gui/windows/buyselldialog.cpp b/src/gui/windows/buyselldialog.cpp
index 0914dc43e..009a24839 100644
--- a/src/gui/windows/buyselldialog.cpp
+++ b/src/gui/windows/buyselldialog.cpp
@@ -64,7 +64,7 @@ void BuySellDialog::init()
setWindowName("BuySell");
setCloseButton(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
static const char *const buttonNames[] =
@@ -81,16 +81,18 @@ void BuySellDialog::init()
int x = buttonPadding;
const int y = buttonPadding;
- for (const char *const *curBtn = buttonNames; *curBtn; curBtn++)
+ for (const char *const *curBtn = buttonNames;
+ *curBtn != nullptr;
+ curBtn++)
{
Button *const btn = new Button(this, gettext(*curBtn), *curBtn, this);
- if (!mBuyButton)
+ if (mBuyButton == nullptr)
mBuyButton = btn; // For focus request
btn->setPosition(x, y);
add(btn);
x += btn->getWidth() + buttonPadding;
}
- if (mBuyButton)
+ if (mBuyButton != nullptr)
{
mBuyButton->requestFocus();
setContentSize(x, 2 * y + mBuyButton->getHeight());
@@ -116,7 +118,7 @@ void BuySellDialog::setVisible(Visible visible)
if (visible == Visible_true)
{
- if (mBuyButton)
+ if (mBuyButton != nullptr)
mBuyButton->requestFocus();
}
else
@@ -133,7 +135,7 @@ void BuySellDialog::action(const ActionEvent &event)
if (mNpcId != BeingId_negOne)
{
const Being *const being = actorManager->findBeing(mNpcId);
- if (being)
+ if (being != nullptr)
npcHandler->buy(being);
else
npcHandler->buy(mNpcId);
@@ -158,7 +160,7 @@ void BuySellDialog::closeAll()
{
FOR_EACH (DialogList::const_iterator, it, dialogInstances)
{
- if (*it)
+ if (*it != nullptr)
(*it)->close();
}
}
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index bf90a3fb3..535ee956f 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -162,12 +162,12 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
beingSlot.cardsId);
}
- if (!maxHairColor)
+ if (maxHairColor == 0u)
maxHairColor = ColorDB::getHairSize();
- if (!maxHairStyle)
+ if (maxHairStyle == 0u)
maxHairStyle = ItemDB::getNumOfHairstyles();
- if (maxHairStyle)
+ if (maxHairStyle != 0u)
{
mHairStyle = (CAST_U32(rand())
% maxHairStyle) + minHairStyle;
@@ -176,7 +176,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
{
mHairStyle = 0;
}
- if (maxHairColor)
+ if (maxHairColor != 0u)
{
mHairColor = (CAST_U32(rand())
% maxHairColor) + minHairColor;
@@ -311,13 +311,13 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
const uint32_t labelX = mPadding;
uint32_t nameX = leftX + labelPadding;
uint32_t y = 30;
- if (mPrevHairColorButton)
+ if (mPrevHairColorButton != nullptr)
nameX += mPrevHairColorButton->getWidth();
- else if (mPrevHairStyleButton)
+ else if (mPrevHairStyleButton != nullptr)
nameX += mPrevHairStyleButton->getWidth();
- else if (mPrevLookButton)
+ else if (mPrevLookButton != nullptr)
nameX += mPrevLookButton->getWidth();
- else if (mPrevRaceButton)
+ else if (mPrevRaceButton != nullptr)
nameX += mPrevRaceButton->getWidth();
if (maxHairColor > minHairColor)
@@ -341,27 +341,27 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook)
{
- if (mPrevLookButton)
+ if (mPrevLookButton != nullptr)
mPrevLookButton->setPosition(leftX, y);
- if (mNextLookButton)
+ if (mNextLookButton != nullptr)
mNextLookButton->setPosition(rightX, y);
y += 5;
- if (mLookLabel)
+ if (mLookLabel != nullptr)
mLookLabel->setPosition(labelX, y);
- if (mLookNameLabel)
+ if (mLookNameLabel != nullptr)
mLookNameLabel->setPosition(nameX, y); // 93
y += 24;
}
if (serverFeatures->haveRaceSelection() && mMinRace < mMaxRace)
{
- if (mPrevRaceButton)
+ if (mPrevRaceButton != nullptr)
mPrevRaceButton->setPosition(leftX, y);
- if (mNextRaceButton)
+ if (mNextRaceButton != nullptr)
mNextRaceButton->setPosition(rightX, y);
y += 5;
- if (mRaceLabel)
+ if (mRaceLabel != nullptr)
mRaceLabel->setPosition(labelX, y);
- if (mRaceNameLabel)
+ if (mRaceNameLabel != nullptr)
mRaceNameLabel->setPosition(nameX, y);
}
mMaxY = y + 29 + getTitlePadding();
@@ -429,7 +429,7 @@ CharCreateDialog::~CharCreateDialog()
{
delete2(mPlayer);
- if (charServerHandler)
+ if (charServerHandler != nullptr)
charServerHandler->setCharCreateDialog(nullptr);
}
@@ -688,7 +688,7 @@ void CharCreateDialog::setAttributes(const StringVect &labels,
}
updateSliders();
- if (!available)
+ if (available == 0)
{
mAttributesLeft->setVisible(Visible_false);
h = y;
@@ -744,13 +744,13 @@ void CharCreateDialog::updateHair()
mHairStyle = minHairStyle;
}
const ItemInfo &item = ItemDB::get(-mHairStyle);
- if (mHairStyleNameLabel)
+ if (mHairStyleNameLabel != nullptr)
{
mHairStyleNameLabel->setCaption(item.getName());
mHairStyleNameLabel->resizeTo(150, 150);
}
- if (ColorDB::getHairSize())
+ if (ColorDB::getHairSize() != 0)
mHairColor %= ColorDB::getHairSize();
else
mHairColor = 0;
@@ -761,7 +761,7 @@ void CharCreateDialog::updateHair()
{
mHairColor = minHairColor;
}
- if (mHairColorNameLabel)
+ if (mHairColorNameLabel != nullptr)
{
mHairColorNameLabel->setCaption(ColorDB::getHairColorName(
fromInt(mHairColor, ItemColor)));
@@ -803,12 +803,12 @@ void CharCreateDialog::updateLook()
}
mPlayer->setSubtype(fromInt(mRace, BeingTypeId),
CAST_U8(mLook));
- if (mRaceNameLabel)
+ if (mRaceNameLabel != nullptr)
{
mRaceNameLabel->setCaption(item.getName());
mRaceNameLabel->resizeTo(150, 150);
}
- if (mLookNameLabel)
+ if (mLookNameLabel != nullptr)
{
mLookNameLabel->setCaption(item.getColorName(
fromInt(mLook, ItemColor)));
@@ -819,14 +819,14 @@ void CharCreateDialog::updateLook()
void CharCreateDialog::logic()
{
BLOCK_START("CharCreateDialog::logic")
- if (mPlayer)
+ if (mPlayer != nullptr)
mPlayer->logic();
BLOCK_END("CharCreateDialog::logic")
}
void CharCreateDialog::updatePlayer()
{
- if (mPlayer)
+ if (mPlayer != nullptr)
{
mPlayer->setDirection(directions[mDirection]);
mPlayer->setAction(actions[mAction], 0);
@@ -857,7 +857,7 @@ void CharCreateDialog::setButtonsPosition(const int w, const int h)
const int h2 = h - 5 - mCancelButton->getHeight();
if (mainGraphics->getHeight() < 480)
{
- if (mMaxPoints)
+ if (mMaxPoints != 0)
{
mCreateButton->setPosition(337, 160);
mCancelButton->setPosition(337 + mCreateButton->getWidth(), 160);
diff --git a/src/gui/windows/chardeleteconfirm.h b/src/gui/windows/chardeleteconfirm.h
index 9c2d43318..7049050a3 100644
--- a/src/gui/windows/chardeleteconfirm.h
+++ b/src/gui/windows/chardeleteconfirm.h
@@ -51,7 +51,7 @@ class CharDeleteConfirm final : public ConfirmDialog
void action(const ActionEvent &event) override final
{
- if (event.getId() == "yes" && mMaster)
+ if (event.getId() == "yes" && (mMaster != nullptr))
mMaster->askPasswordForDeletion(mIndex);
ConfirmDialog::action(event);
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index d697ebf2b..cd801f61d 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -209,13 +209,13 @@ void CharSelectDialog::action(const ActionEvent &event)
return;
}
else if (eventId == "delete"
- && mCharacterEntries[selected]->getCharacter())
+ && (mCharacterEntries[selected]->getCharacter() != nullptr))
{
CREATEWIDGET(CharDeleteConfirm, this, selected);
return;
}
else if (eventId == "rename"
- && mCharacterEntries[selected]->getCharacter())
+ && (mCharacterEntries[selected]->getCharacter() != nullptr))
{
const LocalPlayer *const player = mCharacterEntries[
selected]->getCharacter()->dummy;
@@ -232,11 +232,11 @@ void CharSelectDialog::action(const ActionEvent &event)
{
Net::Character *const character = mCharacterEntries[
selected]->getCharacter();
- if (!character)
+ if (character == nullptr)
return;
const LocalPlayer *const data = character->dummy;
- if (!data)
+ if (data == nullptr)
return;
const std::string msg = strprintf(
@@ -282,7 +282,7 @@ void CharSelectDialog::action(const ActionEvent &event)
}
else if (eventId == "try delete character")
{
- if (mDeleteDialog && mDeleteIndex != -1)
+ if ((mDeleteDialog != nullptr) && mDeleteIndex != -1)
{
if (serverFeatures->haveEmailOnDelete())
{
@@ -316,8 +316,8 @@ void CharSelectDialog::action(const ActionEvent &event)
void CharSelectDialog::use(const int selected)
{
- if (mCharacterEntries[selected]
- && mCharacterEntries[selected]->getCharacter())
+ if ((mCharacterEntries[selected] != nullptr)
+ && (mCharacterEntries[selected]->getCharacter() != nullptr))
{
attemptCharacterSelect(selected);
}
@@ -363,7 +363,7 @@ void CharSelectDialog::keyPressed(KeyEvent &event)
int idx = mCharacterView->getSelected();
if (idx >= 0)
{
- if (!idx || idx == SLOTS_PER_ROW)
+ if ((idx == 0) || idx == SLOTS_PER_ROW)
break;
idx --;
mCharacterView->show(idx);
@@ -406,8 +406,8 @@ void CharSelectDialog::keyPressed(KeyEvent &event)
{
event.consume();
const int idx = mCharacterView->getSelected();
- if (idx >= 0 && mCharacterEntries[idx]
- && mCharacterEntries[idx]->getCharacter())
+ if (idx >= 0 && (mCharacterEntries[idx] != nullptr)
+ && (mCharacterEntries[idx]->getCharacter() != nullptr))
{
CREATEWIDGET(CharDeleteConfirm, this, idx);
}
@@ -435,7 +435,7 @@ void CharSelectDialog::attemptCharacterDelete(const int index,
if (mLocked)
return;
- if (mCharacterEntries[index])
+ if (mCharacterEntries[index] != nullptr)
{
mCharServerHandler->deleteCharacter(
mCharacterEntries[index]->getCharacter(),
@@ -474,11 +474,11 @@ void CharSelectDialog::askPasswordForDeletion(const int index)
*/
void CharSelectDialog::attemptCharacterSelect(const int index)
{
- if (mLocked || !mCharacterEntries[index])
+ if (mLocked || (mCharacterEntries[index] == nullptr))
return;
setVisible(Visible_false);
- if (mCharServerHandler)
+ if (mCharServerHandler != nullptr)
{
mCharServerHandler->chooseCharacter(
mCharacterEntries[index]->getCharacter());
@@ -492,7 +492,7 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters)
FOR_EACH (std::vector<CharacterDisplay*>::const_iterator,
iter, mCharacterEntries)
{
- if (*iter)
+ if (*iter != nullptr)
(*iter)->setCharacter(nullptr);
}
@@ -503,7 +503,7 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters)
void CharSelectDialog::setCharacter(Net::Character *const character)
{
- if (!character)
+ if (character == nullptr)
return;
const int characterSlot = character->slot;
if (characterSlot >= CAST_S32(mCharacterEntries.size()))
@@ -512,7 +512,7 @@ void CharSelectDialog::setCharacter(Net::Character *const character)
return;
}
- if (mCharacterEntries[characterSlot])
+ if (mCharacterEntries[characterSlot] != nullptr)
mCharacterEntries[characterSlot]->setCharacter(character);
}
@@ -531,17 +531,17 @@ void CharSelectDialog::setLocked(const bool locked)
{
mLocked = locked;
- if (mSwitchLoginButton)
+ if (mSwitchLoginButton != nullptr)
mSwitchLoginButton->setEnabled(!locked);
- if (mChangePasswordButton)
+ if (mChangePasswordButton != nullptr)
mChangePasswordButton->setEnabled(!locked);
mPlayButton->setEnabled(!locked);
- if (mDeleteButton)
+ if (mDeleteButton != nullptr)
mDeleteButton->setEnabled(!locked);
for (size_t i = 0, sz = mCharacterEntries.size(); i < sz; ++i)
{
- if (mCharacterEntries[i])
+ if (mCharacterEntries[i] != nullptr)
mCharacterEntries[i]->setActive(!mLocked);
}
}
@@ -554,13 +554,14 @@ bool CharSelectDialog::selectByName(const std::string &name,
for (size_t i = 0, sz = mCharacterEntries.size(); i < sz; ++i)
{
- if (mCharacterEntries[i])
+ if (mCharacterEntries[i] != nullptr)
{
const Net::Character *const character
= mCharacterEntries[i]->getCharacter();
- if (character)
+ if (character != nullptr)
{
- if (character->dummy && character->dummy->getName() == name)
+ if (character->dummy != nullptr &&
+ character->dummy->getName() == name)
{
mCharacterView->show(CAST_S32(i));
updateState();
@@ -597,14 +598,15 @@ void CharSelectDialog::updateState()
}
mPlayButton->setEnabled(true);
- if (mCharacterEntries[idx] && mCharacterEntries[idx]->getCharacter())
+ if (mCharacterEntries[idx] != nullptr &&
+ mCharacterEntries[idx]->getCharacter() != nullptr)
{
// TRANSLATORS: char select dialog. button.
mPlayButton->setCaption(_("Play"));
const LocalPlayer *const player = mCharacterEntries[
idx]->getCharacter()->dummy;
- if (player && mRenameButton)
+ if ((player != nullptr) && (mRenameButton != nullptr))
mRenameButton->setEnabled(player->getRename() ? true : false);
}
else
@@ -621,13 +623,13 @@ void CharSelectDialog::setName(const BeingId id, const std::string &newName)
i < fsz;
++i)
{
- if (!mCharacterEntries[i])
+ if (mCharacterEntries[i] == nullptr)
continue;
CharacterDisplay *const character = mCharacterEntries[i];
- if (!character)
+ if (character == nullptr)
continue;
LocalPlayer *const player = character->getCharacter()->dummy;
- if (player && player->getId() == id)
+ if ((player != nullptr) && player->getId() == id)
{
player->setName(newName);
character->update();
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 45353fdc7..a9c686f3a 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -112,21 +112,23 @@ ChatWindow::ChatWindow() :
mHighlights(),
mGlobalsFilter(),
mChatColor(config.getIntValue("chatColor")),
- mEmoteButtonSpacing(mSkin ? mSkin->getOption("emoteButtonSpacing", 2) : 2),
- mEmoteButtonY(mSkin ? mSkin->getOption("emoteButtonY", -2) : -2),
+ mEmoteButtonSpacing(mSkin != nullptr ?
+ mSkin->getOption("emoteButtonSpacing", 2) : 2),
+ mEmoteButtonY(mSkin != nullptr ?
+ mSkin->getOption("emoteButtonY", -2) : -2),
mChatHistoryIndex(0),
mReturnToggles(config.getBoolValue("ReturnToggles")),
mGMLoaded(false),
mHaveMouse(false),
mAutoHide(config.getBoolValue("autohideChat")),
mShowBattleEvents(config.getBoolValue("showBattleEvents")),
- mShowAllLang(serverConfig.getValue("showAllLang", 0)),
+ mShowAllLang(serverConfig.getValue("showAllLang", 0) != 0),
mEnableTradeFilter(config.getBoolValue("enableTradeFilter")),
mTmpVisible(false)
{
setWindowName("Chat");
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setShowTitle(false);
@@ -159,7 +161,7 @@ ChatWindow::ChatWindow() :
setTitleBarHeight(getPadding() + getTitlePadding());
- if (emoteWindow)
+ if (emoteWindow != nullptr)
emoteWindow->addListeners(this);
mChatButton->adjustSize();
@@ -191,7 +193,7 @@ ChatWindow::ChatWindow() :
updateTabsMargin();
fillCommands();
- if (localPlayer && localPlayer->isGM())
+ if ((localPlayer != nullptr) && localPlayer->isGM())
loadGMCommands();
initTradeFilter();
loadCustomList();
@@ -312,10 +314,10 @@ void ChatWindow::adjustTabSize()
}
const ChatTab *const tab = getFocused();
- if (tab)
+ if (tab != nullptr)
{
Widget *const content = tab->mScrollArea;
- if (content)
+ if (content != nullptr)
{
const int contentFrame2 = 2 * content->getFrameSize();
content->setSize(mChatTabs->getWidth() - contentFrame2,
@@ -344,7 +346,7 @@ ChatTab *ChatWindow::getFocused() const
void ChatWindow::clearTab(ChatTab *const tab)
{
- if (tab)
+ if (tab != nullptr)
tab->clearText();
}
@@ -355,7 +357,7 @@ void ChatWindow::clearTab() const
void ChatWindow::prevTab()
{
- if (!mChatTabs)
+ if (mChatTabs == nullptr)
return;
int tab = mChatTabs->getSelectedTabIndex();
@@ -369,7 +371,7 @@ void ChatWindow::prevTab()
void ChatWindow::nextTab()
{
- if (!mChatTabs)
+ if (mChatTabs == nullptr)
return;
int tab = mChatTabs->getSelectedTabIndex();
@@ -383,7 +385,7 @@ void ChatWindow::nextTab()
void ChatWindow::selectTabByType(const ChatTabTypeT &type)
{
- if (!mChatTabs)
+ if (mChatTabs == nullptr)
return;
int sz = mChatTabs->getNumberOfTabs();
@@ -391,7 +393,7 @@ void ChatWindow::selectTabByType(const ChatTabTypeT &type)
{
ChatTab *const tab = dynamic_cast<ChatTab*>(
mChatTabs->getTabByIndex(f));
- if (tab && tab->getType() == type)
+ if ((tab != nullptr) && tab->getType() == type)
{
mChatTabs->setSelectedTab(tab);
break;
@@ -401,12 +403,12 @@ void ChatWindow::selectTabByType(const ChatTabTypeT &type)
void ChatWindow::closeTab() const
{
- if (!mChatTabs)
+ if (mChatTabs == nullptr)
return;
ChatTab *const tab = dynamic_cast<ChatTab*>(mChatTabs->getTabByIndex(
mChatTabs->getSelectedTabIndex()));
- if (!tab)
+ if (tab == nullptr)
return;
const ChatTabTypeT &type = tab->getType();
if (type == ChatTabType::WHISPER || type == ChatTabType::CHANNEL)
@@ -415,7 +417,7 @@ void ChatWindow::closeTab() const
void ChatWindow::defaultTab()
{
- if (mChatTabs)
+ if (mChatTabs != nullptr)
mChatTabs->setSelectedTabByIndex(CAST_U32(0));
}
@@ -446,7 +448,7 @@ void ChatWindow::action(const ActionEvent &event)
{
// Remove focus and hide input
mChatInput->unprotectFocus();
- if (mFocusHandler)
+ if (mFocusHandler != nullptr)
mFocusHandler->focusNone();
// If the chatWindow is shown up because you want to send a message
@@ -457,7 +459,7 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == "emote")
{
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
const std::string str = emoteWindow->getSelectedEmote();
if (!str.empty())
@@ -469,7 +471,7 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == "openemote")
{
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
if (emoteWindow->mVisible == Visible_true)
emoteWindow->hide();
@@ -479,7 +481,7 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == "color")
{
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
const std::string str = emoteWindow->getSelectedColor();
if (!str.empty())
@@ -491,7 +493,7 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == "font")
{
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
const std::string str = emoteWindow->getSelectedFont();
if (!str.empty())
@@ -503,7 +505,7 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == "text")
{
- if (emoteWindow && reverseDictionary)
+ if ((emoteWindow != nullptr) && (reverseDictionary != nullptr))
{
const int idx = emoteWindow->getSelectedTextIndex();
if (idx >= 0)
@@ -517,14 +519,14 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == ACTION_COLOR_PICKER)
{
- if (mColorPicker)
+ if (mColorPicker != nullptr)
{
mChatColor = mColorPicker->getSelected();
config.setValue("chatColor", mChatColor);
}
}
- if (mColorPicker)
+ if (mColorPicker != nullptr)
{
const Visible vis = fromBool(config.getBoolValue(
"showChatColorsList"), Visible);
@@ -571,7 +573,7 @@ void ChatWindow::removeTab(ChatTab *const tab)
void ChatWindow::addTab(ChatTab *const tab)
{
- if (!tab)
+ if (tab == nullptr)
return;
mChatTabs->addTab(tab, tab->mScrollArea);
@@ -632,7 +634,7 @@ void ChatWindow::ignoreAllWhispers()
++ iter)
{
WhisperTab *const tab = iter->second;
- if (tab)
+ if (tab != nullptr)
{
if (player_relations.getRelation(tab->getNick())
!= Relation::IGNORED)
@@ -654,7 +656,7 @@ void ChatWindow::chatInput(const std::string &message) const
if (config.getBoolValue("allowCommandsInChatTabs")
&& msg.length() > 1
&& ((msg.at(0) == '#' && msg.at(1) != '#') || msg.at(0) == '@')
- && localChatTab)
+ && (localChatTab != nullptr))
{
tab = localChatTab;
}
@@ -664,14 +666,14 @@ void ChatWindow::chatInput(const std::string &message) const
if (tab == nullptr)
tab = localChatTab;
}
- if (tab)
+ if (tab != nullptr)
tab->chatInput(msg);
Game::instance()->setValidSpeed();
}
void ChatWindow::localChatInput(const std::string &msg) const
{
- if (localChatTab)
+ if (localChatTab != nullptr)
localChatTab->chatInput(msg);
else
chatInput(msg);
@@ -679,7 +681,7 @@ void ChatWindow::localChatInput(const std::string &msg) const
void ChatWindow::doPresent() const
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
const ActorSprites &actors = actorManager->getAll();
@@ -702,7 +704,7 @@ void ChatWindow::doPresent() const
_("Present: %s; %d players are present."),
response.c_str(), playercount);
- if (getFocused())
+ if (getFocused() != nullptr)
getFocused()->chatLog(log, ChatMsgType::BY_SERVER);
}
@@ -712,7 +714,7 @@ void ChatWindow::scroll(const int amount) const
return;
ChatTab *const tab = getFocused();
- if (tab)
+ if (tab != nullptr)
tab->scroll(amount);
}
@@ -723,11 +725,11 @@ void ChatWindow::mousePressed(MouseEvent &event)
if (event.getButton() == MouseButton::RIGHT)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
{
ChatTab *const cTab = dynamic_cast<ChatTab*>(
mChatTabs->getSelectedTab());
- if (cTab)
+ if (cTab != nullptr)
{
event.consume();
if (inputManager.isActionActive(InputAction::CHAT_MOD))
@@ -757,13 +759,13 @@ void ChatWindow::mousePressed(MouseEvent &event)
if (clicks == 2)
{
toggleChatFocus();
- if (gui)
+ if (gui != nullptr)
gui->resetClickCount();
}
else if (clicks == 1)
{
const ChatTab *const tab = getFocused();
- if (tab)
+ if (tab != nullptr)
mMoved = !isResizeAllowed(event);
}
}
@@ -862,9 +864,9 @@ void ChatWindow::keyPressed(KeyEvent &event)
mChatInput->mVisible == Visible_true)
{
const ChatTab *const tab = getFocused();
- if (tab && tab->hasRows())
+ if ((tab != nullptr) && tab->hasRows())
{
- if (!mChatHistoryIndex)
+ if (mChatHistoryIndex == 0u)
{
mChatHistoryIndex = CAST_U32(
tab->getRows().size());
@@ -894,7 +896,7 @@ void ChatWindow::keyPressed(KeyEvent &event)
mChatInput->mVisible == Visible_true)
{
const ChatTab *const tab = getFocused();
- if (tab && tab->hasRows())
+ if ((tab != nullptr) && tab->hasRows())
{
const std::list<std::string> &rows = tab->getRows();
const size_t &tabSize = rows.size();
@@ -928,7 +930,7 @@ void ChatWindow::keyPressed(KeyEvent &event)
}
else if (actionId == InputAction::GUI_F1)
{
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
if (emoteWindow->mVisible == Visible_true)
emoteWindow->hide();
@@ -998,7 +1000,7 @@ void ChatWindow::statChanged(const AttributesT id,
return;
const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
- if (oldVal1 > exp.first || !oldVal2)
+ if (oldVal1 > exp.first || (oldVal2 == 0))
return;
const int change = exp.first - oldVal1;
@@ -1082,7 +1084,7 @@ void ChatWindow::addWhisper(const std::string &restrict nick,
const std::string &restrict mes,
const ChatMsgTypeT own)
{
- if (mes.empty() || !localPlayer)
+ if (mes.empty() || (localPlayer == nullptr))
return;
std::string playerName = localPlayer->getName();
@@ -1104,11 +1106,11 @@ void ChatWindow::addWhisper(const std::string &restrict nick,
else if (config.getBoolValue("whispertab"))
{
tab = addWhisperTab(nick, nick);
- if (tab)
+ if (tab != nullptr)
saveState();
}
- if (tab)
+ if (tab != nullptr)
{
if (own == ChatMsgType::BY_PLAYER)
{
@@ -1149,7 +1151,7 @@ void ChatWindow::addWhisper(const std::string &restrict nick,
localPlayer->afkRespond(tab, nick);
}
}
- else if (localChatTab)
+ else if (localChatTab != nullptr)
{
if (own == ChatMsgType::BY_PLAYER)
{
@@ -1166,7 +1168,7 @@ void ChatWindow::addWhisper(const std::string &restrict nick,
" : ").append(mes),
ChatMsgType::ACT_WHISPER,
IgnoreRecord_false);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->afkRespond(nullptr, nick);
}
}
@@ -1176,7 +1178,7 @@ WhisperTab *ChatWindow::addWhisperTab(const std::string &caption,
const std::string &nick,
const bool switchTo)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return nullptr;
std::string playerName = localPlayer->getName();
@@ -1198,7 +1200,7 @@ WhisperTab *ChatWindow::addWhisperTab(const std::string &caption,
else
{
ret = new WhisperTab(this, caption, nick);
- if (gui && !player_relations.isGoodName(nick))
+ if ((gui != nullptr) && !player_relations.isGoodName(nick))
ret->setLabelFont(gui->getSecureFont());
mWhispers[tempNick] = ret;
if (config.getBoolValue("showChatHistory"))
@@ -1213,7 +1215,7 @@ WhisperTab *ChatWindow::addWhisperTab(const std::string &caption,
WhisperTab *ChatWindow::getWhisperTab(const std::string &nick) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return nullptr;
std::string playerName = localPlayer->getName();
@@ -1240,7 +1242,7 @@ ChatTab *ChatWindow::addSpecialChannelTab(const std::string &name,
ChatTab *ret = nullptr;
if (name == TRADE_CHANNEL)
{
- if (!tradeChatTab)
+ if (tradeChatTab == nullptr)
{
tradeChatTab = new TradeTab(chatWindow);
tradeChatTab->setAllowHighlight(false);
@@ -1250,7 +1252,7 @@ ChatTab *ChatWindow::addSpecialChannelTab(const std::string &name,
}
else if (name == GM_CHANNEL)
{
- if (!gmChatTab)
+ if (gmChatTab == nullptr)
{
gmChatTab = new GmTab(chatWindow);
chatHandler->joinChannel(gmChatTab->getChannelName());
@@ -1270,7 +1272,7 @@ ChatTab *ChatWindow::addChannelTab(const std::string &name,
toLower(tempName);
ChatTab *const tab = addSpecialChannelTab(name, switchTo);
- if (tab)
+ if (tab != nullptr)
return tab;
const ChannelMap::const_iterator i = mChannels.find(tempName);
@@ -1304,7 +1306,7 @@ ChatTab *ChatWindow::addChatTab(const std::string &name,
name[0] == '#')
{
ChatTab *const tab = addChannelTab(name, switchTo);
- if (tab && join)
+ if ((tab != nullptr) && join)
chatHandler->joinChannel(name);
return tab;
}
@@ -1319,11 +1321,11 @@ void ChatWindow::postConnection()
FOR_EACH (ChannelMap::const_iterator, iter, mChannels)
{
ChatTab *const tab = iter->second;
- if (!tab)
+ if (tab == nullptr)
return;
chatHandler->joinChannel(tab->getChannelName());
}
- if (langChatTab)
+ if (langChatTab != nullptr)
chatHandler->joinChannel(langChatTab->getChannelName());
}
@@ -1417,32 +1419,32 @@ void ChatWindow::autoComplete()
mChatTabs->getSelectedTab());
StringVect nameList;
- if (cTab)
+ if (cTab != nullptr)
cTab->getAutoCompleteList(nameList);
std::string newName = autoComplete(nameList, name);
- if (!newName.empty() && !startName)
+ if (!newName.empty() && (startName == 0))
secureChatCommand(newName);
- if (cTab && newName.empty())
+ if ((cTab != nullptr) && newName.empty())
{
cTab->getAutoCompleteCommands(nameList);
newName = autoComplete(nameList, name);
}
- if (newName.empty() && actorManager)
+ if (newName.empty() && (actorManager != nullptr))
{
actorManager->getPlayerNames(nameList, NpcNames_true);
newName = autoComplete(nameList, name);
- if (!newName.empty() && !startName)
+ if (!newName.empty() && (startName == 0))
secureChatCommand(newName);
}
if (newName.empty())
newName = autoCompleteHistory(name);
- if (newName.empty() && spellManager)
+ if (newName.empty() && (spellManager != nullptr))
newName = spellManager->autoComplete(name);
if (newName.empty())
newName = autoComplete(name, &mCommands);
- if (newName.empty() && actorManager)
+ if (newName.empty() && (actorManager != nullptr))
{
actorManager->getMobNames(nameList);
newName = autoComplete(nameList, name);
@@ -1504,7 +1506,7 @@ std::string ChatWindow::autoComplete(const StringVect &names,
std::string ChatWindow::autoComplete(const std::string &partName,
const History *const words) const
{
- if (!words)
+ if (words == nullptr)
return "";
ChatCommands::const_iterator i = words->begin();
@@ -1585,7 +1587,7 @@ bool ChatWindow::resortChatLog(std::string line,
prefix = std::string("##3").append(channel).append("##0");
}
else if (mEnableTradeFilter &&
- tradeChatTab &&
+ (tradeChatTab != nullptr) &&
findI(line, mTradeFilter) != std::string::npos)
{
// TRANSLATORS: prefix for moved message to trade tab.
@@ -1661,7 +1663,7 @@ bool ChatWindow::resortChatLog(std::string line,
replaceAll(line, ": \302\202\304", ": ");
}
- if (tradeChatTab)
+ if (tradeChatTab != nullptr)
{
line = line.erase(idx + 2, 2);
tradeChatTab->chatLog(prefix + line,
@@ -1669,7 +1671,7 @@ bool ChatWindow::resortChatLog(std::string line,
ignoreRecord,
tryRemoveColors);
}
- else if (localChatTab)
+ else if (localChatTab != nullptr)
{
line = line.erase(idx + 2, 2);
localChatTab->chatLog(prefix + line,
@@ -1683,7 +1685,7 @@ bool ChatWindow::resortChatLog(std::string line,
if (!channel.empty())
{
- if (langChatTab)
+ if (langChatTab != nullptr)
{
if (langChatTab->getChannelName() == channel)
{
@@ -1710,7 +1712,7 @@ bool ChatWindow::resortChatLog(std::string line,
tryRemoveColors);
}
}
- else if (localChatTab && channel.empty())
+ else if ((localChatTab != nullptr) && channel.empty())
{
localChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
}
@@ -1723,9 +1725,9 @@ void ChatWindow::battleChatLog(const std::string &line, ChatMsgTypeT own,
{
if (own == ChatMsgType::BY_UNKNOWN)
own = ChatMsgType::BY_SERVER;
- if (battleChatTab)
+ if (battleChatTab != nullptr)
battleChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
- else if (debugChatTab)
+ else if (debugChatTab != nullptr)
debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
}
@@ -1748,11 +1750,11 @@ void ChatWindow::channelChatLog(const std::string &channel,
else
{
tab = addChannelTab(channel, false);
- if (tab)
+ if (tab != nullptr)
saveState();
}
- if (tab)
+ if (tab != nullptr)
tab->chatLog(line, own, ignoreRecord, tryRemoveColors);
}
@@ -1764,7 +1766,8 @@ void ChatWindow::initTradeFilter()
std::ifstream tradeFile;
struct stat statbuf;
- if (!stat(tradeListName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode))
+ if (stat(tradeListName.c_str(), &statbuf) == 0 &&
+ S_ISREG(statbuf.st_mode))
{
tradeFile.open(tradeListName.c_str(), std::ios::in);
if (tradeFile.is_open())
@@ -1785,18 +1788,18 @@ void ChatWindow::updateOnline(const std::set<std::string> &onlinePlayers) const
{
const Party *party = nullptr;
const Guild *guild = nullptr;
- if (localPlayer)
+ if (localPlayer != nullptr)
{
party = localPlayer->getParty();
guild = localPlayer->getGuild();
}
FOR_EACH (TabMap::const_iterator, iter, mWhispers)
{
- if (!iter->second)
+ if (iter->second == nullptr)
return;
WhisperTab *const tab = static_cast<WhisperTab*>(iter->second);
- if (!tab)
+ if (tab == nullptr)
continue;
if (onlinePlayers.find(tab->getNick()) != onlinePlayers.end())
@@ -1806,29 +1809,29 @@ void ChatWindow::updateOnline(const std::set<std::string> &onlinePlayers) const
else
{
const std::string &nick = tab->getNick();
- if (actorManager)
+ if (actorManager != nullptr)
{
const Being *const being = actorManager->findBeingByName(
nick, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
tab->setWhisperTabColors();
continue;
}
}
- if (party)
+ if (party != nullptr)
{
const PartyMember *const pm = party->getMember(nick);
- if (pm && pm->getOnline())
+ if ((pm != nullptr) && pm->getOnline())
{
tab->setWhisperTabColors();
continue;
}
}
- if (guild)
+ if (guild != nullptr)
{
const GuildMember *const gm = guild->getMember(nick);
- if (gm && gm->getOnline())
+ if ((gm != nullptr) && gm->getOnline())
{
tab->setWhisperTabColors();
continue;
@@ -1854,11 +1857,11 @@ void ChatWindow::loadState()
"chatWhisperFlags" + toString(num), 1);
ChatTab *const tab = addChatTab(nick, false, false);
- if (tab)
+ if (tab != nullptr)
{
- tab->setAllowHighlight(flags & 1);
- tab->setRemoveNames((flags & 2) / 2);
- tab->setNoAway((flags & 4) / 4);
+ tab->setAllowHighlight((flags & 1) != 0);
+ tab->setRemoveNames(((flags & 2) / 2) != 0);
+ tab->setNoAway(((flags & 4) / 4) != 0);
}
num ++;
}
@@ -1870,7 +1873,7 @@ void ChatWindow::saveState() const
for (ChannelMap::const_iterator iter = mChannels.begin(),
iter_end = mChannels.end(); iter != iter_end && num < 50; ++iter)
{
- if (!iter->second)
+ if (iter->second == nullptr)
return;
if (!saveTab(num, iter->second))
continue;
@@ -1880,7 +1883,7 @@ void ChatWindow::saveState() const
for (TabMap::const_iterator iter = mWhispers.begin(),
iter_end = mWhispers.end(); iter != iter_end && num < 50; ++iter)
{
- if (!iter->second)
+ if (iter->second == nullptr)
return;
if (!saveTab(num, iter->second))
continue;
@@ -1898,7 +1901,7 @@ void ChatWindow::saveState() const
bool ChatWindow::saveTab(const int num,
const ChatTab *const tab) const
{
- if (!tab)
+ if (tab == nullptr)
return false;
serverConfig.setValue("chatWhisper" + toString(num),
@@ -1927,7 +1930,7 @@ void ChatWindow::loadCustomList()
std::string listName = settings.serverConfigDir
+ "/customwords.txt";
- if (!stat(listName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode))
+ if ((stat(listName.c_str(), &statbuf) == 0) && S_ISREG(statbuf.st_mode))
{
listFile.open(listName.c_str(), std::ios::in);
if (listFile.is_open())
@@ -1958,7 +1961,7 @@ void ChatWindow::addToAwayLog(const std::string &line)
void ChatWindow::displayAwayLog() const
{
- if (!localChatTab)
+ if (localChatTab == nullptr)
return;
std::list<std::string>::const_iterator i = mAwayLog.begin();
@@ -1975,7 +1978,7 @@ void ChatWindow::displayAwayLog() const
void ChatWindow::parseHighlights()
{
mHighlights.clear();
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
splitToStringVector(mHighlights, config.getStringValue(
@@ -1987,7 +1990,7 @@ void ChatWindow::parseHighlights()
void ChatWindow::parseGlobalsFilter()
{
mGlobalsFilter.clear();
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
splitToStringVector(mGlobalsFilter, config.getStringValue(
@@ -2004,11 +2007,11 @@ bool ChatWindow::findHighlight(const std::string &str)
void ChatWindow::copyToClipboard(const int x, const int y) const
{
const ChatTab *const tab = getFocused();
- if (!tab)
+ if (tab == nullptr)
return;
const BrowserBox *const text = tab->mTextOutput;
- if (!text)
+ if (text == nullptr)
return;
std::string str = text->getTextAtPos(x, y);
@@ -2071,7 +2074,7 @@ void ChatWindow::safeDraw(Graphics *const graphics)
void ChatWindow::updateVisibility()
{
- if (!gui)
+ if (gui == nullptr)
return;
int mouseX = 0;
@@ -2107,10 +2110,15 @@ void ChatWindow::logicChildren()
void ChatWindow::addGlobalMessage(const std::string &line)
{
- if (debugChatTab && findI(line, mGlobalsFilter) != std::string::npos)
+ if (debugChatTab != nullptr &&
+ findI(line, mGlobalsFilter) != std::string::npos)
+ {
debugChatTab->chatLog(line, ChatMsgType::BY_OTHER);
+ }
else
+ {
localChatTab->chatLog(line, ChatMsgType::BY_GM);
+ }
}
bool ChatWindow::isTabPresent(const ChatTab *const tab) const
@@ -2120,13 +2128,13 @@ bool ChatWindow::isTabPresent(const ChatTab *const tab) const
void ChatWindow::debugMessage(const std::string &msg)
{
- if (debugChatTab)
+ if (debugChatTab != nullptr)
debugChatTab->chatLog(msg, ChatMsgType::BY_SERVER);
}
void ChatWindow::showGMTab()
{
- if (!gmChatTab &&
+ if ((gmChatTab == nullptr) &&
config.getBoolValue("enableGmTab") &&
localPlayer->getGMLevel() >= paths.getIntValue("gmTabMinimalLevel"))
{
@@ -2145,7 +2153,7 @@ void ChatWindow::toggleChatFocus()
void ChatWindow::joinRoom(const bool isJoin)
{
Tab *const tab = mChatTabs->getTabByIndex(0);
- if (tab)
+ if (tab != nullptr)
{
std::string name;
if (isJoin)
diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp
index 201b3af79..913fb7c41 100644
--- a/src/gui/windows/confirmdialog.cpp
+++ b/src/gui/windows/confirmdialog.cpp
@@ -65,7 +65,7 @@ void ConfirmDialog::postInit()
int inWidth = yesButton->getWidth() + noButton->getWidth() +
(2 * mPadding);
- if (ignoreButton)
+ if (ignoreButton != nullptr)
inWidth += ignoreButton->getWidth();
const int fontHeight = getFont()->getHeight();
@@ -90,7 +90,7 @@ void ConfirmDialog::postInit()
yesButton->setPosition((width - inWidth) / 2, height + buttonPadding);
noButton->setPosition(yesButton->getX() + yesButton->getWidth()
+ (2 * mPadding), height + buttonPadding);
- if (ignoreButton)
+ if (ignoreButton != nullptr)
{
ignoreButton->setPosition(noButton->getX() + noButton->getWidth()
+ (2 * mPadding), height + buttonPadding);
@@ -100,10 +100,10 @@ void ConfirmDialog::postInit()
add(yesButton);
add(noButton);
- if (mIgnore && ignoreButton)
+ if (mIgnore && (ignoreButton != nullptr))
add(ignoreButton);
- if (getParent())
+ if (getParent() != nullptr)
{
center();
getParent()->moveToTop(this);
diff --git a/src/gui/windows/cutinwindow.cpp b/src/gui/windows/cutinwindow.cpp
index 79bc1e1e9..2713dfdfc 100644
--- a/src/gui/windows/cutinwindow.cpp
+++ b/src/gui/windows/cutinwindow.cpp
@@ -69,7 +69,7 @@ void CutInWindow::safeDraw(Graphics *const graphics)
void CutInWindow::draw2(Graphics *const graphics)
{
- if (mImage)
+ if (mImage != nullptr)
mImage->drawRaw(graphics, mPadding, mTitleBarHeight);
}
@@ -87,7 +87,7 @@ void CutInWindow::show(const std::string &name,
pathJoin(paths.getStringValue("cutInsDir"),
name).append(
".xml"));
- if (mImage)
+ if (mImage != nullptr)
{
mImage->update(1);
const bool showTitle = (cutin == CutIn::MovableClose);
@@ -145,7 +145,7 @@ void CutInWindow::hide()
void CutInWindow::logic()
{
- if (mImage)
+ if (mImage != nullptr)
{
const int time = tick_time * MILLISECONDS_IN_A_TICK;
mImage->update(time);
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index 1648a37ed..8b4144b98 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -47,7 +47,7 @@ DebugWindow::DebugWindow() :
mNetWidget(new NetDebugTab(this))
{
setWindowName("Debug");
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setResizable(true);
@@ -94,7 +94,7 @@ void DebugWindow::postInit()
void DebugWindow::slowLogic()
{
BLOCK_START("DebugWindow::slowLogic")
- if (!isWindowVisible() || !mTabs)
+ if (!isWindowVisible() || (mTabs == nullptr))
{
BLOCK_END("DebugWindow::slowLogic")
return;
@@ -114,7 +114,7 @@ void DebugWindow::slowLogic()
break;
}
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->tryPingRequest();
BLOCK_END("DebugWindow::slowLogic")
}
@@ -124,10 +124,10 @@ void DebugWindow::draw(Graphics *const g)
BLOCK_START("DebugWindow::draw")
Window::draw(g);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
const Being *const target = localPlayer->getTarget();
- if (target)
+ if (target != nullptr)
{
target->draw(g, -target->getPixelX() + mapTileSize / 2
+ mDimension.width / 2, -target->getPixelY() + mapTileSize
@@ -142,10 +142,10 @@ void DebugWindow::safeDraw(Graphics *const g)
BLOCK_START("DebugWindow::draw")
Window::safeDraw(g);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
const Being *const target = localPlayer->getTarget();
- if (target)
+ if (target != nullptr)
{
target->draw(g, -target->getPixelX() + mapTileSize / 2
+ mDimension.width / 2, -target->getPixelY() + mapTileSize
diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp
index f5a01b42d..f358ece83 100644
--- a/src/gui/windows/didyouknowwindow.cpp
+++ b/src/gui/windows/didyouknowwindow.cpp
@@ -75,7 +75,7 @@ DidYouKnowWindow::DidYouKnowWindow() :
setResizable(true);
setStickyButtonLock(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setDefaultSize(500, 400, ImagePosition::CENTER);
@@ -84,7 +84,7 @@ DidYouKnowWindow::DidYouKnowWindow() :
Button *const okButton = new Button(this, _("Close"), "close", this);
mBrowserBox->setLinkHandler(mItemLinkHandler);
- if (gui)
+ if (gui != nullptr)
mBrowserBox->setFont(gui->getHelpFont());
mBrowserBox->setProcessVars(true);
mBrowserBox->setEnableImages(true);
@@ -144,7 +144,7 @@ void DidYouKnowWindow::action(const ActionEvent &event)
void DidYouKnowWindow::loadData(int num)
{
mBrowserBox->clearRows();
- if (!num)
+ if (num == 0)
{
const int curTip = config.getIntValue("currentTip");
if (curTip == 1)
diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp
index d4bec498f..37683caf5 100644
--- a/src/gui/windows/editserverdialog.cpp
+++ b/src/gui/windows/editserverdialog.cpp
@@ -228,7 +228,7 @@ void EditServerDialog::action(const ActionEvent &event)
mPortField->getText().c_str()));
mServer.persistentIp = mPersistentIp->isSelected();
- if (mTypeField)
+ if (mTypeField != nullptr)
{
switch (mTypeField->getSelected())
{
diff --git a/src/gui/windows/eggselectiondialog.cpp b/src/gui/windows/eggselectiondialog.cpp
index 6055eada2..5e77d8ec1 100644
--- a/src/gui/windows/eggselectiondialog.cpp
+++ b/src/gui/windows/eggselectiondialog.cpp
@@ -60,7 +60,7 @@ void EggSelectionDialog::sellAction(const ActionEvent &event A_UNUSED)
const int selectedItem = mShopItemList->getSelected();
const ShopItem *const item = mShopItems->at(selectedItem);
- if (!item)
+ if (item == nullptr)
return;
inventoryHandler->selectEgg(item);
scheduleDelete();
diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp
index 796e3f342..0125177b1 100644
--- a/src/gui/windows/emotewindow.cpp
+++ b/src/gui/windows/emotewindow.cpp
@@ -77,7 +77,7 @@ EmoteWindow::EmoteWindow() :
setShowTitle(false);
setResizable(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
addMouseListener(this);
@@ -110,12 +110,12 @@ void EmoteWindow::postInit()
mFontPage->setCenter(true);
mTextPage->setCenter(true);
- if (mImageSet && mImageSet->size() >= 3)
+ if ((mImageSet != nullptr) && mImageSet->size() >= 3)
{
for (int f = 0; f < 3; f ++)
{
Image *const image = mImageSet->get(f);
- if (image)
+ if (image != nullptr)
image->incRef();
}
@@ -155,7 +155,7 @@ EmoteWindow::~EmoteWindow()
delete2(mTextPage);
delete2(mTextModel);
delete2(mScrollTextPage);
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
@@ -230,7 +230,7 @@ std::string EmoteWindow::getSelectedFont() const
if (index < 0)
return std::string();
- if (!index)
+ if (index == 0)
return "##b";
else
return "##B";
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index c0ed8b5d4..d77302035 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -104,10 +104,10 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment,
mYPadding = mTabs->getHeight() + getOption("tabPadding", 2);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
- if (!mBoxSize)
+ if (mBoxSize == 0)
mBoxSize = 36;
// Control that shows the Player
@@ -154,7 +154,7 @@ EquipmentWindow::~EquipmentWindow()
{
if (this == beingEquipmentWindow)
{
- if (mEquipment)
+ if (mEquipment != nullptr)
delete mEquipment->getBackend();
delete2(mEquipment)
}
@@ -165,14 +165,14 @@ EquipmentWindow::~EquipmentWindow()
boxes.clear();
delete *it;
}
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
}
- if (mSlotBackground)
+ if (mSlotBackground != nullptr)
mSlotBackground->decRef();
- if (mSlotHighlightedBackground)
+ if (mSlotHighlightedBackground != nullptr)
mSlotHighlightedBackground->decRef();
delete2(mVertexes);
}
@@ -194,7 +194,7 @@ void EquipmentWindow::draw(Graphics *const graphics)
FOR_EACH (std::vector<EquipmentBox*>::const_iterator, it, boxes)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
{
i ++;
continue;
@@ -217,7 +217,7 @@ void EquipmentWindow::draw(Graphics *const graphics)
}
graphics->drawTileCollection(mVertexes);
- if (!mEquipment)
+ if (mEquipment == nullptr)
{
BLOCK_END("EquipmentWindow::draw")
return;
@@ -229,14 +229,14 @@ void EquipmentWindow::draw(Graphics *const graphics)
it_end = boxes.end(); it != it_end; ++ it, ++ i)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
const Item *const item = mEquipment->getEquipment(i);
- if (item)
+ if (item != nullptr)
{
// Draw Item.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F); // Ensure the image is drawn
// with maximum opacity
@@ -254,7 +254,7 @@ void EquipmentWindow::draw(Graphics *const graphics)
}
}
}
- else if (box->image)
+ else if (box->image != nullptr)
{
graphics->drawImage(box->image,
box->x + mItemPadding,
@@ -279,7 +279,7 @@ void EquipmentWindow::safeDraw(Graphics *const graphics)
it_end = boxes.end(); it != it_end; ++ it, ++ i)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
if (i == mSelected)
{
@@ -292,7 +292,7 @@ void EquipmentWindow::safeDraw(Graphics *const graphics)
}
}
- if (!mEquipment)
+ if (mEquipment == nullptr)
{
BLOCK_END("EquipmentWindow::draw")
return;
@@ -304,14 +304,14 @@ void EquipmentWindow::safeDraw(Graphics *const graphics)
it_end = boxes.end(); it != it_end; ++ it, ++ i)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
const Item *const item = mEquipment->getEquipment(i);
- if (item)
+ if (item != nullptr)
{
// Draw Item.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F); // Ensure the image is drawn
// with maximum opacity
@@ -329,7 +329,7 @@ void EquipmentWindow::safeDraw(Graphics *const graphics)
}
}
}
- else if (box->image)
+ else if (box->image != nullptr)
{
graphics->drawImage(box->image,
box->x + mItemPadding,
@@ -344,17 +344,17 @@ void EquipmentWindow::action(const ActionEvent &event)
const std::string &eventId = event.getId();
if (eventId == "unequip")
{
- if (!mEquipment || mSelected == -1)
+ if ((mEquipment == nullptr) || mSelected == -1)
return;
const Item *const item = mEquipment->getEquipment(mSelected);
PlayerInfo::unequipItem(item, Sfx_true);
setSelected(-1);
}
- else if (!eventId.find("tab_"))
+ else if (eventId.find("tab_") == 0u)
{
Button *const button = dynamic_cast<Button*>(event.getSource());
- if (!button)
+ if (button == nullptr)
return;
mSelectedTab = button->getTag();
updatePage();
@@ -367,13 +367,13 @@ void EquipmentWindow::action(const ActionEvent &event)
{
return;
}
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
- if (!inventory)
+ if (inventory == nullptr)
return;
Item *const item = inventory->findItem(dragDrop.getItem(),
dragDrop.getItemColor());
- if (!item)
+ if (item == nullptr)
return;
if (dragDrop.getSource() == DragDropSource::Inventory)
@@ -402,7 +402,7 @@ void EquipmentWindow::updatePage()
const Item *EquipmentWindow::getItem(const int x, const int y) const
{
- if (!mEquipment)
+ if (mEquipment == nullptr)
return nullptr;
int i = 0;
@@ -412,7 +412,7 @@ const Item *EquipmentWindow::getItem(const int x, const int y) const
it_end = boxes.end(); it != it_end; ++ it, ++ i)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
@@ -424,7 +424,7 @@ const Item *EquipmentWindow::getItem(const int x, const int y) const
void EquipmentWindow::mousePressed(MouseEvent& event)
{
- if (!mEquipment)
+ if (mEquipment == nullptr)
{
Window::mousePressed(event);
return;
@@ -450,7 +450,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
it_end = boxes.end(); it != it_end; ++ it, ++ i)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
const Item *const item = mEquipment->getEquipment(i);
const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
@@ -458,7 +458,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
if (tRect.isPointInRect(x, y))
{
inBox = true;
- if (item)
+ if (item != nullptr)
{
event.consume();
setSelected(i);
@@ -474,7 +474,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
{
if (const Item *const item = getItem(x, y))
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
/* Convert relative to the window coordinates to absolute screen
@@ -482,7 +482,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
*/
const int mx = x + getX();
const int my = y + getY();
- if (popupMenu)
+ if (popupMenu != nullptr)
{
event.consume();
if (mForing)
@@ -510,14 +510,14 @@ void EquipmentWindow::mouseReleased(MouseEvent &event)
{
return;
}
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
- if (!inventory)
+ if (inventory == nullptr)
return;
Item *const item = inventory->findItem(dragDrop.getItem(),
dragDrop.getItemColor());
- if (!item)
+ if (item == nullptr)
return;
if (dragDrop.getSource() == DragDropSource::Inventory)
@@ -540,7 +540,7 @@ void EquipmentWindow::mouseReleased(MouseEvent &event)
it != it_end; ++ it)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
@@ -561,7 +561,7 @@ void EquipmentWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
- if (!itemPopup)
+ if (itemPopup == nullptr)
return;
const int x = event.getX();
@@ -569,7 +569,7 @@ void EquipmentWindow::mouseMoved(MouseEvent &event)
const Item *const item = getItem(x, y);
- if (item)
+ if (item != nullptr)
{
itemPopup->setItem(item, false);
itemPopup->position(x + getX(), y + getY());
@@ -583,7 +583,7 @@ void EquipmentWindow::mouseMoved(MouseEvent &event)
// Hide ItemTooltip
void EquipmentWindow::mouseExited(MouseEvent &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
@@ -591,9 +591,9 @@ void EquipmentWindow::setSelected(const int index)
{
mSelected = index;
mRedraw = true;
- if (mUnequip)
+ if (mUnequip != nullptr)
mUnequip->setEnabled(mSelected != -1);
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
@@ -601,10 +601,10 @@ void EquipmentWindow::setBeing(Being *const being)
{
mPlayerBox->setPlayer(being);
mBeing = being;
- if (mEquipment)
+ if (mEquipment != nullptr)
delete mEquipment->getBackend();
delete mEquipment;
- if (!being)
+ if (being == nullptr)
{
mEquipment = nullptr;
return;
@@ -631,14 +631,14 @@ void EquipmentWindow::fillBoxes()
UseVirtFs_true,
SkipError_false);
XmlNodeConstPtr root = doc->rootNode();
- if (!root)
+ if (root == nullptr)
{
delete doc;
fillDefault();
return;
}
- if (mImageSet)
+ if (mImageSet != nullptr)
mImageSet->decRef();
mImageSet = Theme::getImageSetFromTheme(XML::getProperty(
@@ -668,7 +668,7 @@ void EquipmentWindow::addDefaultPage()
void EquipmentWindow::loadPage(XmlNodeConstPtr node)
{
- if (!node)
+ if (node == nullptr)
return;
// TRANSLATORS: unknown equipment page name
const std::string &name = XML::langProperty(node, "name", _("Unknown"));
@@ -696,7 +696,7 @@ void EquipmentWindow::loadSlot(XmlNodeConstPtr slotNode,
const ImageSet *const imageset,
const int page)
{
- if (!imageset)
+ if (imageset == nullptr)
return;
const int slot = parseSlotName(XML::getProperty(slotNode, "name", ""));
if (slot < 0)
@@ -712,7 +712,7 @@ void EquipmentWindow::loadSlot(XmlNodeConstPtr slotNode,
image = imageset->get(imageIndex);
std::vector<EquipmentBox*> &boxes = mPages[page]->boxes;
- if (boxes[slot])
+ if (boxes[slot] != nullptr)
{
EquipmentBox *const box = boxes[slot];
box->x = x;
@@ -740,7 +740,7 @@ void EquipmentWindow::prepareSlotNames()
UseVirtFs_true,
SkipError_false);
XmlNodeConstPtrConst root = doc.rootNode();
- if (!root)
+ if (root == nullptr)
return;
for_each_xml_child_node(slotNode, root)
@@ -776,7 +776,7 @@ int EquipmentWindow::parseSlotName(const std::string &name)
void EquipmentWindow::fillDefault()
{
- if (mImageSet)
+ if (mImageSet != nullptr)
mImageSet->decRef();
addDefaultPage();
@@ -802,7 +802,7 @@ void EquipmentWindow::addBox(const int idx, int x, int y, const int imageIndex)
{
Image *image = nullptr;
- if (mImageSet && imageIndex >= 0 && imageIndex
+ if ((mImageSet != nullptr) && imageIndex >= 0 && imageIndex
< CAST_S32(mImageSet->size()))
{
image = mImageSet->get(imageIndex);
diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h
index 00db41fd8..9bd9dd26f 100644
--- a/src/gui/windows/equipmentwindow.h
+++ b/src/gui/windows/equipmentwindow.h
@@ -79,7 +79,10 @@ class EquipmentWindow final : public Window,
void mousePressed(MouseEvent& event) override final;
const Item* getEquipment(const int i) const A_WARN_UNUSED
- { return mEquipment ? mEquipment->getEquipment(i) : nullptr; }
+ {
+ return mEquipment != nullptr ?
+ mEquipment->getEquipment(i) : nullptr;
+ }
void setBeing(Being *const being);
diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp
index 226284a35..3a2c542ad 100644
--- a/src/gui/windows/helpwindow.cpp
+++ b/src/gui/windows/helpwindow.cpp
@@ -72,7 +72,7 @@ HelpWindow::HelpWindow() :
setResizable(true);
setStickyButtonLock(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setDefaultSize(500, 400, ImagePosition::CENTER);
@@ -80,7 +80,7 @@ HelpWindow::HelpWindow() :
mBrowserBox->setOpaque(Opaque_false);
mBrowserBox->setLinkHandler(this);
- if (gui)
+ if (gui != nullptr)
mBrowserBox->setFont(gui->getHelpFont());
mBrowserBox->setProcessVars(true);
mBrowserBox->setEnableImages(true);
@@ -196,7 +196,7 @@ void HelpWindow::search(const std::string &text0)
}
else
{
- if (!translator)
+ if (translator == nullptr)
return;
mBrowserBox->clearRows();
loadFile("header");
diff --git a/src/gui/windows/insertcarddialog.cpp b/src/gui/windows/insertcarddialog.cpp
index efcd8877c..590df6aba 100644
--- a/src/gui/windows/insertcarddialog.cpp
+++ b/src/gui/windows/insertcarddialog.cpp
@@ -43,7 +43,7 @@ InsertCardDialog::InsertCardDialog(const int itemIndex,
{
// TRANSLATORS: insert card dialog name
setWindowName(_("Insert card"));
- if (item)
+ if (item != nullptr)
{
// TRANSLATORS: insert card dialog name
setCaption(strprintf(_("Insert card %s"),
@@ -72,7 +72,7 @@ void InsertCardDialog::sellAction(const ActionEvent &event A_UNUSED)
const int selectedItem = mShopItemList->getSelected();
const ShopItem *const item = mShopItems->at(selectedItem);
- if (!item)
+ if (item == nullptr)
return;
inventoryHandler->insertCard(mItemIndex, item->getInvIndex());
scheduleDelete();
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 7f4f4600b..a39e648b4 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -116,7 +116,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
mSlotsBar->setColor(getThemeColor(ThemeColorId::SLOTS_BAR),
getThemeColor(ThemeColorId::SLOTS_BAR_OUTLINE));
- if (inventory)
+ if (inventory != nullptr)
{
setCaption(gettext(inventory->getName().c_str()));
setWindowName(inventory->getName());
@@ -151,8 +151,8 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
mSortDropDown->setSelected(0);
}
- if (setupWindow &&
- inventory &&
+ if ((setupWindow != nullptr) &&
+ (inventory != nullptr) &&
inventory->getType() != InventoryType::Storage)
{
setupWindow->registerWindowForReset(this);
@@ -184,7 +184,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
for (size_t f = 0; f < sz; f ++)
mFilter->addButton(tags[f], tags[f], false);
- if (!mInventory)
+ if (mInventory == nullptr)
{
invInstances.push_back(this);
return;
@@ -352,14 +352,17 @@ void InventoryWindow::postInit()
mItems->setSortType(mSortDropDown->getSelected());
widgetResized(Event(nullptr));
- if (mInventory && mInventory->getType() == InventoryType::Storage)
+ if (mInventory != nullptr &&
+ mInventory->getType() == InventoryType::Storage)
+ {
setVisible(Visible_true);
+ }
}
InventoryWindow::~InventoryWindow()
{
invInstances.remove(this);
- if (mInventory)
+ if (mInventory != nullptr)
mInventory->removeInventoyListener(this);
if (!invInstances.empty())
invInstances.front()->updateDropButton();
@@ -370,7 +373,7 @@ InventoryWindow::~InventoryWindow()
void InventoryWindow::storeSortOrder() const
{
- if (mInventory)
+ if (mInventory != nullptr)
{
switch (mInventory->getType())
{
@@ -422,20 +425,20 @@ void InventoryWindow::action(const ActionEvent &event)
}
else if (eventId == "store")
{
- if (!inventoryWindow || !inventoryWindow->isWindowVisible())
+ if (inventoryWindow == nullptr || !inventoryWindow->isWindowVisible())
return;
Item *const item = inventoryWindow->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
- if (storageWindow)
+ if (storageWindow != nullptr)
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreAdd,
this, item);
}
- else if (cartWindow && cartWindow->isWindowVisible())
+ else if ((cartWindow != nullptr) && cartWindow->isWindowVisible())
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::CartAdd,
this, item);
@@ -452,7 +455,7 @@ void InventoryWindow::action(const ActionEvent &event)
mItems->setName(mNameFilter->getText());
mItems->updateMatrix();
}
- else if (!eventId.find("tag_"))
+ else if (eventId.find("tag_") == 0u)
{
std::string tagName = event.getId().substr(4);
mItems->setFilter(ItemDB::getTagId(tagName));
@@ -461,7 +464,7 @@ void InventoryWindow::action(const ActionEvent &event)
Item *const item = mItems->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
if (eventId == "use")
@@ -481,7 +484,7 @@ void InventoryWindow::action(const ActionEvent &event)
item->getQuantity(),
InventoryType::Storage);
}
- else if (cartWindow && cartWindow->isWindowVisible())
+ else if ((cartWindow != nullptr) && cartWindow->isWindowVisible())
{
inventoryHandler->moveItem2(InventoryType::Inventory,
item->getInvIndex(),
@@ -512,12 +515,12 @@ void InventoryWindow::action(const ActionEvent &event)
}
else if (eventId == "retrieve")
{
- if (storageWindow)
+ if (storageWindow != nullptr)
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreRemove,
this, item);
}
- else if (cartWindow && cartWindow->isWindowVisible())
+ else if ((cartWindow != nullptr) && cartWindow->isWindowVisible())
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::CartRemove,
this, item);
@@ -538,7 +541,7 @@ void InventoryWindow::unselectItem()
void InventoryWindow::widgetHidden(const Event &event)
{
Window::widgetHidden(event);
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
@@ -548,23 +551,23 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
const int clicks = event.getClickCount();
- if (clicks == 2 && gui)
+ if (clicks == 2 && (gui != nullptr))
gui->resetClickCount();
const bool mod = (isStorageActive() &&
inputManager.isActionActive(InputAction::STOP_ATTACK));
- const bool mod2 = (tradeWindow &&
+ const bool mod2 = ((tradeWindow != nullptr) &&
tradeWindow->isWindowVisible() &&
inputManager.isActionActive(InputAction::STOP_ATTACK));
- if (mInventory)
+ if (mInventory != nullptr)
{
if (!mod && !mod2 && event.getButton() == MouseButton::RIGHT)
{
Item *const item = mItems->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
/* Convert relative to the window coordinates to absolute screen
@@ -573,7 +576,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
const int mx = event.getX() + getX();
const int my = event.getY() + getY();
- if (popupMenu)
+ if (popupMenu != nullptr)
{
popupMenu->showPopup(this,
mx, my,
@@ -592,7 +595,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
{
Item *const item = mItems->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
if (mod)
@@ -643,7 +646,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
}
else
{
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->tradeItem(item, item->getQuantity(), true);
}
}
@@ -657,7 +660,8 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
ItemAmountWindowUsage::StoreAdd,
inventoryWindow, item);
}
- else if (tradeWindow && tradeWindow->isWindowVisible())
+ else if (tradeWindow != nullptr &&
+ tradeWindow->isWindowVisible())
{
if (PlayerInfo::isItemProtected(item->getId()))
return;
@@ -686,11 +690,11 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
void InventoryWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
- if (!textPopup)
+ if (textPopup == nullptr)
return;
const Widget *const src = event.getSource();
- if (!src)
+ if (src == nullptr)
{
textPopup->hide();
return;
@@ -708,7 +712,7 @@ void InventoryWindow::mouseMoved(MouseEvent &event)
else
{
const Button *const btn = dynamic_cast<const Button *>(src);
- if (!btn)
+ if (btn == nullptr)
{
textPopup->hide();
return;
@@ -738,12 +742,12 @@ void InventoryWindow::keyReleased(KeyEvent &event)
void InventoryWindow::valueChanged(const SelectionEvent &event A_UNUSED)
{
- if (!mInventory || !mInventory->isMainInventory())
+ if ((mInventory == nullptr) || !mInventory->isMainInventory())
return;
Item *const item = mItems->getSelectedItem();
- if (mSplit && item && inventoryHandler->
+ if (mSplit && (item != nullptr) && inventoryHandler->
canSplit(mItems->getSelectedItem()))
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemSplit,
@@ -754,29 +758,29 @@ void InventoryWindow::valueChanged(const SelectionEvent &event A_UNUSED)
void InventoryWindow::updateButtons(const Item *item)
{
- if (!mInventory || !mInventory->isMainInventory())
+ if ((mInventory == nullptr) || !mInventory->isMainInventory())
return;
const Item *const selectedItem = mItems->getSelectedItem();
- if (item && selectedItem != item)
+ if ((item != nullptr) && selectedItem != item)
return;
- if (!item)
+ if (item == nullptr)
item = selectedItem;
- if (!item || item->getQuantity() == 0)
+ if ((item == nullptr) || item->getQuantity() == 0)
{
- if (mUseButton)
+ if (mUseButton != nullptr)
mUseButton->setEnabled(false);
- if (mDropButton)
+ if (mDropButton != nullptr)
mDropButton->setEnabled(false);
return;
}
- if (mDropButton)
+ if (mDropButton != nullptr)
mDropButton->setEnabled(true);
- if (mUseButton)
+ if (mUseButton != nullptr)
{
const ItemInfo &info = item->getInfo();
const std::string &str = (item->isEquipment() == Equipm_true
@@ -800,7 +804,7 @@ void InventoryWindow::updateButtons(const Item *item)
void InventoryWindow::close()
{
- if (!mInventory)
+ if (mInventory == nullptr)
{
Window::close();
return;
@@ -814,7 +818,7 @@ void InventoryWindow::close()
break;
case InventoryType::Storage:
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
{
inventoryHandler->closeStorage();
inventoryHandler->forgotStorage();
@@ -835,7 +839,7 @@ void InventoryWindow::close()
void InventoryWindow::updateWeight()
{
- if (!mInventory || !mWeightBar)
+ if ((mInventory == nullptr) || (mWeightBar == nullptr))
return;
const InventoryTypeT type = mInventory->getType();
if (type != InventoryType::Inventory &&
@@ -868,7 +872,7 @@ void InventoryWindow::slotsChanged(const Inventory *const inventory)
const int usedSlots = mInventory->getNumberOfSlotsUsed();
const int maxSlots = mInventory->getSize();
- if (maxSlots)
+ if (maxSlots != 0)
{
mSlotsBar->setProgress(static_cast<float>(usedSlots)
/ static_cast<float>(maxSlots));
@@ -881,10 +885,11 @@ void InventoryWindow::slotsChanged(const Inventory *const inventory)
void InventoryWindow::updateDropButton()
{
- if (!mDropButton)
+ if (mDropButton == nullptr)
return;
- if (isStorageActive() || (cartWindow && cartWindow->isWindowVisible()))
+ if (isStorageActive() ||
+ (cartWindow != nullptr && cartWindow->isWindowVisible()))
{
// TRANSLATORS: inventory button
mDropButton->setCaption(_("Store"));
@@ -892,7 +897,7 @@ void InventoryWindow::updateDropButton()
else
{
const Item *const item = mItems->getSelectedItem();
- if (item && item->getQuantity() > 1)
+ if ((item != nullptr) && item->getQuantity() > 1)
{
// TRANSLATORS: inventory button
mDropButton->setCaption(_("Drop..."));
@@ -907,14 +912,14 @@ void InventoryWindow::updateDropButton()
bool InventoryWindow::isInputFocused() const
{
- return mNameFilter && mNameFilter->isFocused();
+ return (mNameFilter != nullptr) && mNameFilter->isFocused();
}
bool InventoryWindow::isAnyInputFocused()
{
FOR_EACH (WindowList::const_iterator, it, invInstances)
{
- if ((*it) && (*it)->isInputFocused())
+ if (((*it) != nullptr) && (*it)->isInputFocused())
return true;
}
return false;
@@ -925,7 +930,7 @@ InventoryWindow *InventoryWindow::getFirstVisible()
std::set<Widget*> list;
FOR_EACH (WindowList::const_iterator, it, invInstances)
{
- if ((*it) && (*it)->isWindowVisible())
+ if (((*it) != nullptr) && (*it)->isWindowVisible())
list.insert(*it);
}
InventoryWindow *const window = dynamic_cast<InventoryWindow*>(
@@ -936,14 +941,14 @@ InventoryWindow *InventoryWindow::getFirstVisible()
void InventoryWindow::nextTab()
{
const InventoryWindow *const window = getFirstVisible();
- if (window)
+ if (window != nullptr)
window->mFilter->nextTab();
}
void InventoryWindow::prevTab()
{
const InventoryWindow *const window = getFirstVisible();
- if (window)
+ if (window != nullptr)
window->mFilter->prevTab();
}
@@ -951,7 +956,7 @@ void InventoryWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
- if (!mInventory)
+ if (mInventory == nullptr)
return;
const InventoryTypeT type = mInventory->getType();
if (type != InventoryType::Inventory &&
@@ -988,10 +993,10 @@ void InventoryWindow::setVisible(Visible visible)
void InventoryWindow::unsetInventory()
{
- if (mInventory)
+ if (mInventory != nullptr)
{
mInventory->removeInventoyListener(this);
- if (mItems)
+ if (mItems != nullptr)
mItems->unsetInventory();
}
mInventory = nullptr;
@@ -1013,13 +1018,13 @@ void InventoryWindow::attributeChanged(const AttributesT id,
void InventoryWindow::combineItems(const int index1,
const int index2)
{
- if (!mInventory)
+ if (mInventory == nullptr)
return;
const Item *item1 = mInventory->getItem(index1);
- if (!item1)
+ if (item1 == nullptr)
return;
const Item *item2 = mInventory->getItem(index2);
- if (!item2)
+ if (item2 == nullptr)
return;
if (item1->getType() != ItemType::Card)
@@ -1046,15 +1051,15 @@ void InventoryWindow::combineItems(const int index1,
void InventoryWindow::moveItemToCraft(const int craftSlot)
{
- if (!npcHandler)
+ if (npcHandler == nullptr)
return;
Item *const item = mItems->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
- if (dialog &&
+ if ((dialog != nullptr) &&
dialog->getInputState() == NpcInputState::ITEM_CRAFT)
{
if (item->getQuantity() > 1
diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h
index 5159973d3..e1acc962b 100644
--- a/src/gui/windows/inventorywindow.h
+++ b/src/gui/windows/inventorywindow.h
@@ -126,13 +126,16 @@ class InventoryWindow final : public Window,
void slotsChanged(const Inventory *const inventory) override final;
bool isMainInventory() const A_WARN_UNUSED
- { return mInventory ? mInventory->isMainInventory() : false; }
+ {
+ return mInventory != nullptr ?
+ mInventory->isMainInventory() : false;
+ }
/**
* Returns true if any instances exist.
*/
static bool isStorageActive() A_WARN_UNUSED
- { return storageWindow; }
+ { return storageWindow != nullptr; }
void updateDropButton();
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index dc318b103..d31e263c4 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -65,12 +65,12 @@ void ItemAmountWindow::finish(Item *const item,
const int price,
const ItemAmountWindowUsageT usage)
{
- if (!item)
+ if (item == nullptr)
return;
switch (usage)
{
case ItemAmountWindowUsage::TradeAdd:
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->tradeItem(item, amount);
break;
case ItemAmountWindowUsage::ItemDrop:
@@ -88,11 +88,11 @@ void ItemAmountWindow::finish(Item *const item,
item->getInvIndex(), amount, InventoryType::Inventory);
break;
case ItemAmountWindowUsage::ShopBuyAdd:
- if (shopWindow)
+ if (shopWindow != nullptr)
shopWindow->addBuyItem(item, amount, price);
break;
case ItemAmountWindowUsage::ShopSellAdd:
- if (shopWindow)
+ if (shopWindow != nullptr)
shopWindow->addSellItem(item, amount, price);
break;
case ItemAmountWindowUsage::CartAdd:
@@ -104,13 +104,13 @@ void ItemAmountWindow::finish(Item *const item,
item->getInvIndex(), amount, InventoryType::Inventory);
break;
case ItemAmountWindowUsage::MailAdd:
- if (mailEditWindow)
+ if (mailEditWindow != nullptr)
mailEditWindow->addItem(item, amount);
break;
case ItemAmountWindowUsage::CraftAdd:
{
NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
- if (dialog)
+ if (dialog != nullptr)
dialog->addCraftItem(item, amount, price); // price as slot
break;
}
@@ -130,7 +130,7 @@ ItemAmountWindow::ItemAmountWindow(const ItemAmountWindowUsageT usage,
mItemPriceTextField(nullptr),
mGPLabel(nullptr),
mItem(item),
- mItemIcon(new Icon(this, item ? item->getImage() : nullptr)),
+ mItemIcon(new Icon(this, item != nullptr ? item->getImage() : nullptr)),
mItemAmountSlide(new Slider(this, 1.0, maxRange, 1.0)),
mItemPriceSlide(nullptr),
mItemDropDown(nullptr),
@@ -140,12 +140,12 @@ ItemAmountWindow::ItemAmountWindow(const ItemAmountWindowUsageT usage,
mUsage(usage),
mEnabledKeyboard(keyboard.isEnabled())
{
- if (!mItem)
+ if (mItem == nullptr)
return;
if (usage == ItemAmountWindowUsage::ShopBuyAdd)
mMax = 10000;
- else if (!mMax)
+ else if (mMax == 0)
mMax = mItem->getQuantity();
keyboard.setEnabled(false);
@@ -318,7 +318,7 @@ void ItemAmountWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
- if (!viewport || !itemPopup)
+ if ((viewport == nullptr) || (itemPopup == nullptr))
return;
if (event.getSource() == mItemIcon)
@@ -331,7 +331,7 @@ void ItemAmountWindow::mouseMoved(MouseEvent &event)
// Hide ItemTooltip
void ItemAmountWindow::mouseExited(MouseEvent &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
@@ -350,7 +350,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
}
else if (eventId == "ok")
{
- if (mItemPriceTextField)
+ if (mItemPriceTextField != nullptr)
{
finish(mItem,
mItemAmountTextField->getValue(),
@@ -379,7 +379,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
}
else if (eventId == "itemType")
{
- if (!mItemDropDown || !mItemsModal)
+ if ((mItemDropDown == nullptr) || (mItemsModal == nullptr))
return;
const int id = ItemDB::get(mItemsModal->getElementAt(
@@ -398,7 +398,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
if (mUsage == ItemAmountWindowUsage::ShopBuyAdd)
mMax = 10000;
- else if (!mMax)
+ else if (mMax == 0)
mMax = mItem->getQuantity();
mItemIcon->setImage(mItem->getImage());
@@ -417,7 +417,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
mItemAmountTextField->setValue(amount);
mItemAmountSlide->setValue(amount);
- if (mItemPriceTextField && mItemPriceSlide)
+ if ((mItemPriceTextField != nullptr) && (mItemPriceSlide != nullptr))
{
if (mPrice > 7)
mPrice = 7;
@@ -443,7 +443,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
else if (eventId == "slidePrice")
{
price = CAST_S32(mItemPriceSlide->getValue());
- if (price)
+ if (price != 0)
mPrice = CAST_S32(log(static_cast<float>(price)));
else
mPrice = 0;
@@ -470,10 +470,10 @@ void ItemAmountWindow::showWindow(const ItemAmountWindowUsageT usage,
int maxRange,
int tag)
{
- if (!item)
+ if (item == nullptr)
return;
- if (!maxRange)
+ if (maxRange == 0)
maxRange = item->getQuantity();
if (usage != ItemAmountWindowUsage::ShopBuyAdd &&
diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp
index 005052fd4..da3b6224e 100644
--- a/src/gui/windows/killstats.cpp
+++ b/src/gui/windows/killstats.cpp
@@ -108,13 +108,13 @@ KillStats::KillStats() :
setStickyButtonLock(true);
setDefaultSize(250, 250, 350, 300);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
const int xp(PlayerInfo::getAttribute(Attributes::PLAYER_EXP));
int xpNextLevel(PlayerInfo::getAttribute(Attributes::PLAYER_EXP_NEEDED));
- if (!xpNextLevel)
+ if (xpNextLevel == 0)
xpNextLevel = 1;
// TRANSLATORS: kill stats window label
@@ -205,7 +205,7 @@ void KillStats::gainXp(int xp)
Attributes::PLAYER_EXP_NEEDED);
if (xp == expNeed)
xp = 0;
- else if (!xp)
+ else if (xp == 0)
return;
mKillCounter++;
@@ -213,7 +213,7 @@ void KillStats::gainXp(int xp)
mExpCounter = mExpCounter + xp;
mExpTCounter = mExpTCounter + xp;
- if (!mKillCounter)
+ if (mKillCounter == 0)
mKillCounter = 1;
const float AvgExp = static_cast<float>(mExpCounter)
@@ -223,7 +223,7 @@ void KillStats::gainXp(int xp)
if (mKillTimer == 0)
mKillTimer = cur_time;
- if (!xpNextLevel)
+ if (xpNextLevel == 0)
xpNextLevel = 1;
double timeDiff = difftime(cur_time, mKillTimer) / 60;
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
index 731db0cc9..746d37878 100644
--- a/src/gui/windows/logindialog.cpp
+++ b/src/gui/windows/logindialog.cpp
@@ -85,7 +85,8 @@ LoginDialog::LoginDialog(LoginData &data,
mRegisterButton(new Button(this, _("Register"), "register", this)),
// TRANSLATORS: login dialog checkbox
mCustomUpdateHost(new CheckBox(this, _("Custom update host"),
- mLoginData->updateType & UpdateType::Custom, this, "customhost")),
+ (mLoginData->updateType & UpdateType::Custom) != 0,
+ this, "customhost")),
mUpdateHostText(new TextField(this, serverConfig.getValue(
"customUpdateHost", ""))),
mUpdateListModel(nullptr),
@@ -96,7 +97,7 @@ LoginDialog::LoginDialog(LoginData &data,
setCloseButton(true);
setWindowName("Login");
- if (charServerHandler)
+ if (charServerHandler != nullptr)
charServerHandler->clear();
mergeUpdateHosts();
@@ -155,7 +156,7 @@ LoginDialog::LoginDialog(LoginData &data,
place(0, 6, mUpdateTypeLabel, 1);
place(1, 6, mUpdateTypeDropDown, 8);
int n = 7;
- if (mUpdateHostDropDown)
+ if (mUpdateHostDropDown != nullptr)
{
place(0, 7, mUpdateHostDropDown, 9);
n += 1;
@@ -176,7 +177,7 @@ void LoginDialog::postInit()
setVisible(Visible_true);
const int h = 200;
- if (mUpdateHostDropDown)
+ if (mUpdateHostDropDown != nullptr)
setContentSize(310, 250);
setContentSize(310, h);
#ifdef ANDROID
@@ -196,7 +197,7 @@ void LoginDialog::postInit()
mPassField->requestFocus();
mLoginButton->setEnabled(canSubmit());
- if (loginHandler)
+ if (loginHandler != nullptr)
{
mRegisterButton->setEnabled(loginHandler->isRegistrationEnabled()
|| !mLoginData->registerUrl.empty());
@@ -209,9 +210,9 @@ void LoginDialog::postInit()
LoginDialog::~LoginDialog()
{
- if (mUpdateTypeDropDown)
+ if (mUpdateTypeDropDown != nullptr)
mUpdateTypeDropDown->hideDrop(false);
- if (mUpdateHostDropDown)
+ if (mUpdateHostDropDown != nullptr)
mUpdateHostDropDown->hideDrop(false);
delete2(mUpdateTypeModel);
@@ -329,7 +330,7 @@ void LoginDialog::prepareUpdate()
else
{
std::string str;
- if (mUpdateHostDropDown)
+ if (mUpdateHostDropDown != nullptr)
{
const int sel = mUpdateHostDropDown->getSelected();
if (sel >= 0)
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index c37cf0bac..a2f7fe6c8 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -132,17 +132,17 @@ void MailEditWindow::action(const ActionEvent &event)
else if (eventId == "send")
{
const int money = mMoneyField->getValue();
- if (money)
+ if (money != 0)
mailHandler->setAttachMoney(money);
const Item *const tempItem = mInventory->getItem(0);
- if (tempItem)
+ if (tempItem != nullptr)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
const Item *const item = inv->findItem(
tempItem->getId(), ItemColor_one);
- if (item)
+ if (item != nullptr)
{
mailHandler->setAttach(item->getInvIndex(),
tempItem->getQuantity());
@@ -164,7 +164,7 @@ void MailEditWindow::action(const ActionEvent &event)
{
Item *const item = inventoryWindow->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
ItemAmountWindow::showWindow(ItemAmountWindowUsage::MailAdd,
@@ -175,7 +175,7 @@ void MailEditWindow::action(const ActionEvent &event)
void MailEditWindow::addItem(const Item *const item,
const int amount)
{
- if (!item)
+ if (item == nullptr)
return;
mInventory->addItem(item->getId(),
item->getType(),
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index 54c3edca7..19d1211bb 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -99,7 +99,7 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
placer(0, n++, mTimeLabel);
placer(0, n++, mFromLabel);
placer(0, n++, mSubjectLabel);
- if (message->money)
+ if (message->money != 0)
{
// TRANSLATORS: mail view window label
mMoneyLabel = new Label(this, strprintf("%s %d", _("Money:"),
@@ -107,7 +107,7 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
placer(0, n++, mMoneyLabel);
}
placer(0, n++, mMessageLabel);
- if (message->itemId)
+ if (message->itemId != 0)
{
const ItemInfo &item = ItemDB::get(message->itemId);
// +++ need use message->cards and ItemColorManager for colors
@@ -135,7 +135,7 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
placer(0, n, mItemLabel);
placer(1, n++, mIcon);
}
- if (message->money || message->itemId)
+ if ((message->money != 0) || (message->itemId != 0))
{
mGetAttachButton = new Button(this,
// TRANSLATORS: mail view attach button
@@ -158,10 +158,10 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
MailViewWindow::~MailViewWindow()
{
- if (mIcon)
+ if (mIcon != nullptr)
{
Image *const image = mIcon->getImage();
- if (image)
+ if (image != nullptr)
image->decRef();
}
delete2(mMessage);
@@ -177,24 +177,24 @@ void MailViewWindow::action(const ActionEvent &event)
}
else if (eventId == "attach")
{
- if (mGetAttachButton)
+ if (mGetAttachButton != nullptr)
mailHandler->getAttach(mMessage->id);
}
else if (eventId == "next")
{
- if (mMessage)
+ if (mMessage != nullptr)
mailWindow->viewNext(mMessage->id);
}
else if (eventId == "prev")
{
- if (mMessage)
+ if (mMessage != nullptr)
mailWindow->viewPrev(mMessage->id);
}
else if (eventId == "reply")
{
- if (!mMessage)
+ if (mMessage == nullptr)
return;
- if (mailEditWindow)
+ if (mailEditWindow != nullptr)
mailEditWindow->scheduleDelete();
CREATEWIDGETV0(mailEditWindow, MailEditWindow);
mailEditWindow->setTo(mMessage->sender);
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp
index 96df275e6..98570340f 100644
--- a/src/gui/windows/mailwindow.cpp
+++ b/src/gui/windows/mailwindow.cpp
@@ -78,7 +78,7 @@ MailWindow::MailWindow() :
setSaveVisible(true);
setStickyButtonLock(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setDefaultSize(310, 180, ImagePosition::CENTER);
@@ -122,7 +122,7 @@ void MailWindow::action(const ActionEvent &event)
}
else if (eventId == "new")
{
- if (!mailEditWindow)
+ if (mailEditWindow == nullptr)
{
CREATEWIDGETV0(mailEditWindow, MailEditWindow);
}
@@ -164,7 +164,7 @@ void MailWindow::clear()
void MailWindow::addMail(MailMessage *const message)
{
- if (!message)
+ if (message == nullptr)
return;
mMessages.push_back(message);
mMailModel->add(strprintf("%s %s",
@@ -184,7 +184,7 @@ void MailWindow::removeMail(const int id)
FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages)
{
MailMessage *message = *it;
- if (message && message->id == id)
+ if ((message != nullptr) && message->id == id)
{
mMessages.erase(it);
delete message;
@@ -195,7 +195,7 @@ void MailWindow::removeMail(const int id)
FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages)
{
MailMessage *message = *it;
- if (message)
+ if (message != nullptr)
{
mMailModel->add(strprintf("%s %s",
message->unread ? " " : "U",
@@ -206,7 +206,7 @@ void MailWindow::removeMail(const int id)
void MailWindow::showMessage(MailMessage *const mail)
{
- if (!mail)
+ if (mail == nullptr)
return;
const std::map<int, MailMessage*>::const_iterator
it = mMessagesMap.find(mail->id);
@@ -225,7 +225,7 @@ void MailWindow::viewNext(const int id)
FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages)
{
MailMessage *message = *it;
- if (message && message->id == id)
+ if ((message != nullptr) && message->id == id)
{
++ it;
if (it == mMessages.end())
@@ -249,7 +249,7 @@ void MailWindow::viewPrev(const int id)
FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages)
{
MailMessage *message = *it;
- if (message && message->id == id)
+ if ((message != nullptr) && message->id == id)
{
if (it == mMessages.begin())
{
@@ -288,7 +288,7 @@ void MailWindow::postConnection()
void MailWindow::createMail(const std::string &to)
{
- if (mailEditWindow)
+ if (mailEditWindow != nullptr)
return;
CREATEWIDGETV0(mailEditWindow, MailEditWindow);
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 2cee038bd..869fede55 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -79,7 +79,7 @@ Minimap::Minimap() :
// set this to false as the minimap window size is changed
// depending on the map size
setResizable(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setDefaultVisible(true);
@@ -103,7 +103,7 @@ Minimap::~Minimap()
void Minimap::deleteMapImage()
{
- if (mMapImage)
+ if (mMapImage != nullptr)
{
if (mCustomMapImage)
delete mMapImage;
@@ -118,7 +118,7 @@ void Minimap::setMap(const Map *const map)
BLOCK_START("Minimap::setMap")
std::string caption;
- if (map)
+ if (map != nullptr)
caption = map->getName();
if (caption.empty())
@@ -130,14 +130,14 @@ void Minimap::setMap(const Map *const map)
setCaption(caption);
deleteMapImage();
- if (map)
+ if (map != nullptr)
{
if (config.getBoolValue("showExtMinimaps"))
{
SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_SWSURFACE,
map->getWidth(), map->getHeight(), 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000);
- if (!surface)
+ if (surface == nullptr)
{
if (!isSticky())
setVisible(Visible_false);
@@ -148,7 +148,7 @@ void Minimap::setMap(const Map *const map)
// I'm not sure if the locks are necessary since it's a SWSURFACE
SDL_LockSurface(surface);
int* data = static_cast<int*>(surface->pixels);
- if (!data)
+ if (data == nullptr)
{
if (!isSticky())
setVisible(Visible_false);
@@ -163,7 +163,7 @@ void Minimap::setMap(const Map *const map)
for (int ptr = 0; ptr < size; ptr ++)
{
- *(data ++) = (map->mMetaTiles[ptr].blockmask & mask) ?
+ *(data ++) = (map->mMetaTiles[ptr].blockmask & mask) != 0 ?
0x0 : 0x00ffffff;
}
@@ -200,7 +200,7 @@ void Minimap::setMap(const Map *const map)
}
}
- if (mMapImage && map)
+ if ((mMapImage != nullptr) && (map != nullptr))
{
const int width = mMapImage->mBounds.w + 2 * getPadding();
const int height = mMapImage->mBounds.h
@@ -265,7 +265,9 @@ void Minimap::safeDraw(Graphics *const graphics)
void Minimap::draw2(Graphics *const graphics)
{
- if (!userPalette || !localPlayer || !viewport)
+ if (userPalette == nullptr ||
+ localPlayer == nullptr ||
+ viewport == nullptr)
{
BLOCK_END("Minimap::draw")
return;
@@ -275,7 +277,7 @@ void Minimap::draw2(Graphics *const graphics)
graphics->pushClipArea(a);
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("Minimap::draw")
return;
@@ -284,7 +286,7 @@ void Minimap::draw2(Graphics *const graphics)
mMapOriginX = 0;
mMapOriginY = 0;
- if (mMapImage)
+ if (mMapImage != nullptr)
{
const SDL_Rect &rect = mMapImage->mBounds;
const int w = rect.w;
@@ -316,11 +318,11 @@ void Minimap::draw2(Graphics *const graphics)
const ActorSprites &actors = actorManager->getAll();
FOR_EACH (ActorSpritesConstIterator, it, actors)
{
- if (!(*it) || (*it)->getType() == ActorType::FloorItem)
+ if (((*it) == nullptr) || (*it)->getType() == ActorType::FloorItem)
continue;
const Being *const being = static_cast<const Being *>(*it);
- if (!being)
+ if (being == nullptr)
continue;
int dotSize = 2;
@@ -380,7 +382,7 @@ void Minimap::draw2(Graphics *const graphics)
}
}
- if (userPalette)
+ if (userPalette != nullptr)
graphics->setColor(userPalette->getColor(type));
const int offsetHeight = CAST_S32(static_cast<float>(
@@ -397,12 +399,12 @@ void Minimap::draw2(Graphics *const graphics)
if (localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
const PartyMember *const m = party->getMember(
localPlayer->getName());
const Party::MemberList *const members = party->getMembers();
- if (m)
+ if (m != nullptr)
{
const std::string curMap = m->getMap();
Party::MemberList::const_iterator it = members->begin();
@@ -411,10 +413,10 @@ void Minimap::draw2(Graphics *const graphics)
while (it != it_end)
{
const PartyMember *const member = *it;
- if (member && member->getMap() == curMap
+ if ((member != nullptr) && member->getMap() == curMap
&& member->getOnline() && member != m)
{
- if (userPalette)
+ if (userPalette != nullptr)
{
graphics->setColor(userPalette->getColor(
UserColorId::PARTY));
@@ -454,14 +456,14 @@ void Minimap::draw2(Graphics *const graphics)
if (w <= a.width)
{
- if (x < 0 && w)
+ if (x < 0 && (w != 0))
x = 0;
if (x + w > a.width)
x = a.width - w;
}
if (h <= a.height)
{
- if (y < 0 && h)
+ if (y < 0 && (h != 0))
y = 0;
if (y + h > a.height)
y = a.height - h;
@@ -484,7 +486,7 @@ void Minimap::mouseReleased(MouseEvent &event)
{
Window::mouseReleased(event);
- if (!localPlayer || !popupManager)
+ if ((localPlayer == nullptr) || (popupManager == nullptr))
return;
if (event.getButton() == MouseButton::LEFT)
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index f57ea2e79..b3e63c226 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -114,14 +114,14 @@ MiniStatusWindow::MiniStatusWindow() :
// TRANSLATORS: status bar name
"status bar", _("status bar"))),
mStatusPopup(CREATEWIDGETR0(StatusPopup)),
- mSpacing(mSkin ? mSkin->getOption("spacing", 3) : 3),
- mIconPadding(mSkin ? mSkin->getOption("iconPadding", 3) : 3),
- mIconSpacing(mSkin ? mSkin->getOption("iconSpacing", 2) : 2),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing", 3) : 3),
+ mIconPadding(mSkin != nullptr ? mSkin->getOption("iconPadding", 3) : 3),
+ mIconSpacing(mSkin != nullptr ? mSkin->getOption("iconSpacing", 2) : 2),
mMaxX(0)
{
StatusWindow::updateHPBar(mHpBar);
- if (statusWindow)
+ if (statusWindow != nullptr)
statusWindow->updateMPBar(mMpBar);
const bool job = serverConfig.getValueBool("showJob", true);
@@ -145,7 +145,7 @@ MiniStatusWindow::MiniStatusWindow() :
setVisible(Visible_true);
addMouseListener(this);
Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
inv->addInventoyListener(this);
StatusWindow::updateMoneyBar(mMoneyBar);
@@ -160,13 +160,13 @@ MiniStatusWindow::~MiniStatusWindow()
mIcons.clear();
Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
inv->removeInventoyListener(this);
FOR_EACH (ProgressBarVectorCIter, it, mBars)
{
ProgressBar *bar = *it;
- if (!bar)
+ if (bar == nullptr)
continue;
if (bar->mVisible == Visible_false)
delete bar;
@@ -205,7 +205,7 @@ void MiniStatusWindow::updateBars()
FOR_EACH (ProgressBarVectorCIter, it, mBars)
{
ProgressBar *const bar = *it;
- if (!bar)
+ if (bar == nullptr)
continue;
if (bar->mVisible == Visible_true)
{
@@ -216,7 +216,7 @@ void MiniStatusWindow::updateBars()
}
}
- if (lastBar)
+ if (lastBar != nullptr)
{
setContentSize(lastBar->getX() + lastBar->getWidth(),
lastBar->getY() + lastBar->getHeight());
@@ -249,7 +249,7 @@ void MiniStatusWindow::drawIcons(Graphics *const graphics)
for (size_t i = 0, sz = mIcons.size(); i < sz; i ++)
{
const AnimatedSprite *const icon = mIcons[i];
- if (icon)
+ if (icon != nullptr)
{
icon->draw(graphics, icon_x, mIconPadding);
icon_x += mIconSpacing + icon->getWidth();
@@ -261,7 +261,7 @@ void MiniStatusWindow::statChanged(const AttributesT id A_UNUSED,
const int oldVal1 A_UNUSED,
const int oldVal2 A_UNUSED)
{
- if (statusWindow)
+ if (statusWindow != nullptr)
statusWindow->updateMPBar(mMpBar);
StatusWindow::updateJobBar(mJobBar);
}
@@ -301,9 +301,9 @@ void MiniStatusWindow::attributeChanged(const AttributesT id,
void MiniStatusWindow::updateStatus()
{
- if (statusWindow)
+ if (statusWindow != nullptr)
statusWindow->updateStatusBar(mStatusBar);
- if (mStatusPopup && mStatusPopup->isPopupVisible())
+ if ((mStatusPopup != nullptr) && mStatusPopup->isPopupVisible())
mStatusPopup->update();
}
@@ -315,7 +315,7 @@ void MiniStatusWindow::logic()
for (size_t i = 0, sz = mIcons.size(); i < sz; i++)
{
AnimatedSprite *const icon = mIcons[i];
- if (icon)
+ if (icon != nullptr)
icon->update(tick_time * 10);
}
BLOCK_END("MiniStatusWindow::logic")
@@ -351,7 +351,7 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event)
else if (event.getSource() == mXpBar)
{
std::string level;
- if (localPlayer && localPlayer->isGM())
+ if ((localPlayer != nullptr) && localPlayer->isGM())
{
// TRANSLATORS: status bar label
level = strprintf(_("Level: %d (GM %d)"),
@@ -430,7 +430,7 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event)
else if (event.getSource() == mInvSlotsBar)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
const int usedSlots = inv->getNumberOfSlotsUsed();
const int maxSlots = inv->getSize();
@@ -459,10 +459,10 @@ void MiniStatusWindow::mousePressed(MouseEvent &event)
{
const ProgressBar *const bar = dynamic_cast<ProgressBar*>(
event.getSource());
- if (!bar)
+ if (bar == nullptr)
return;
event.consume();
- if (popupManager)
+ if (popupManager != nullptr)
{
popupMenu->showPopup(getX() + event.getX(),
getY() + event.getY(), bar);
@@ -482,7 +482,7 @@ void MiniStatusWindow::showBar(const std::string &name,
const Visible visible)
{
ProgressBar *const bar = mBarNames[name];
- if (!bar)
+ if (bar == nullptr)
return;
bar->setVisible(visible);
updateBars();
@@ -491,19 +491,19 @@ void MiniStatusWindow::showBar(const std::string &name,
void MiniStatusWindow::loadBars()
{
- if (!config.getIntValue("ministatussaved"))
+ if (config.getIntValue("ministatussaved") == 0)
{
- if (mWeightBar)
+ if (mWeightBar != nullptr)
mWeightBar->setVisible(Visible_false);
- if (mInvSlotsBar)
+ if (mInvSlotsBar != nullptr)
mInvSlotsBar->setVisible(Visible_false);
- if (mMoneyBar)
+ if (mMoneyBar != nullptr)
mMoneyBar->setVisible(Visible_false);
- if (mArrowsBar)
+ if (mArrowsBar != nullptr)
mArrowsBar->setVisible(Visible_false);
- if (mStatusBar)
+ if (mStatusBar != nullptr)
mStatusBar->setVisible(Visible_false);
- if (mJobBar)
+ if (mJobBar != nullptr)
mJobBar->setVisible(Visible_true);
return;
}
@@ -515,7 +515,7 @@ void MiniStatusWindow::loadBars()
if (str.empty())
continue;
ProgressBar *const bar = mBarNames[str];
- if (!bar)
+ if (bar == nullptr)
continue;
bar->setVisible(Visible_false);
}
@@ -542,7 +542,7 @@ void MiniStatusWindow::saveBars() const
void MiniStatusWindow::slotsChanged(const Inventory *const inventory)
{
- if (!inventory)
+ if (inventory == nullptr)
return;
if (inventory->getType() == InventoryType::Inventory)
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index a6c7fe857..453f35126 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -226,10 +226,10 @@ void NpcDialog::postInit()
enableVisibleSound(true);
soundManager.playGuiSound(SOUND_SHOW_WINDOW);
- if (actorManager)
+ if (actorManager != nullptr)
{
const Being *const being = actorManager->findBeing(mNpcId);
- if (being)
+ if (being != nullptr)
{
showAvatar(NPCDB::getAvatarFor(fromInt(
being->getSubType(), BeingTypeId)));
@@ -246,7 +246,7 @@ NpcDialog::~NpcDialog()
CHECKLISTENERS
clearLayout();
- if (mPlayerBox)
+ if (mPlayerBox != nullptr)
{
delete mPlayerBox->getBeing();
delete mPlayerBox;
@@ -276,7 +276,7 @@ NpcDialog::~NpcDialog()
FOR_EACH (ImageVectorIter, it, mImages)
{
- if (*it)
+ if (*it != nullptr)
(*it)->decRef();
}
@@ -328,7 +328,7 @@ void NpcDialog::action(const ActionEvent &event)
else if (mActionState == NpcActionState::CLOSE
|| mActionState == NpcActionState::WAIT)
{
- if (cutInWindow)
+ if (cutInWindow != nullptr)
cutInWindow->hide();
closeDialog();
}
@@ -340,9 +340,9 @@ void NpcDialog::action(const ActionEvent &event)
{
case NpcInputState::LIST:
{
- if (mDialogInfo)
+ if (mDialogInfo != nullptr)
return;
- if (gui)
+ if (gui != nullptr)
gui->resetClickCount();
const int selectedIndex = mItemList->getSelected();
@@ -401,7 +401,7 @@ void NpcDialog::action(const ActionEvent &event)
else
{
const Item *item = mInventory->getItem(0);
- if (item)
+ if (item != nullptr)
{
str = strprintf("%d,%d", item->getId(),
toInt(item->getColor(), int));
@@ -414,7 +414,7 @@ void NpcDialog::action(const ActionEvent &event)
{
str.append(";");
item = mInventory->getItem(f);
- if (item)
+ if (item != nullptr)
{
str.append(strprintf("%d,%d", item->getId(),
toInt(item->getColor(), int)));
@@ -449,7 +449,7 @@ void NpcDialog::action(const ActionEvent &event)
else
{
const Item *item = mInventory->getItem(0);
- if (item)
+ if (item != nullptr)
{
str = strprintf("%d", item->getTag());
}
@@ -461,7 +461,7 @@ void NpcDialog::action(const ActionEvent &event)
{
str.append(";");
item = mInventory->getItem(f);
- if (item)
+ if (item != nullptr)
str.append(strprintf("%d", item->getTag()));
else
str.append("-1");
@@ -600,18 +600,18 @@ void NpcDialog::action(const ActionEvent &event)
npcHandler->listInput(mNpcId, 255);
break;
}
- if (cutInWindow)
+ if (cutInWindow != nullptr)
cutInWindow->hide();
closeDialog();
}
}
else if (eventId == "add")
{
- if (inventoryWindow)
+ if (inventoryWindow != nullptr)
{
Item *const item = inventoryWindow->getSelectedItem();
Inventory *const inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
{
if (mInputState == NpcInputState::ITEM_CRAFT)
{
@@ -684,7 +684,7 @@ void NpcDialog::choiceRequest()
mItems.clear();
FOR_EACH (ImageVectorIter, it, mImages)
{
- if (*it)
+ if (*it != nullptr)
(*it)->decRef();
}
mImages.clear();
@@ -765,7 +765,7 @@ bool NpcDialog::isAnyInputFocused()
{
FOR_EACH (DialogList::const_iterator, it, instances)
{
- if ((*it) && (*it)->isInputFocused())
+ if (((*it) != nullptr) && (*it)->isInputFocused())
return true;
}
@@ -851,7 +851,7 @@ NpcDialog *NpcDialog::getActive()
FOR_EACH (DialogList::const_iterator, it, instances)
{
- if ((*it) && (*it)->isFocused())
+ if (((*it) != nullptr) && (*it)->isFocused())
return (*it);
}
@@ -862,7 +862,7 @@ void NpcDialog::closeAll()
{
FOR_EACH (DialogList::const_iterator, it, instances)
{
- if (*it)
+ if (*it != nullptr)
(*it)->close();
}
}
@@ -908,7 +908,7 @@ void NpcDialog::placeMenuControls()
void NpcDialog::placeSkinControls()
{
createSkinControls();
- if (mDialogInfo && mDialogInfo->hideText)
+ if ((mDialogInfo != nullptr) && mDialogInfo->hideText)
{
if (mShowAvatar)
{
@@ -988,7 +988,7 @@ void NpcDialog::placeIntInputControls()
void NpcDialog::placeItemInputControls()
{
- if (mDialogInfo)
+ if (mDialogInfo != nullptr)
{
mItemContainer->setCellBackgroundImage(mDialogInfo->inventory.cell);
mItemContainer->setMaxColumns(mDialogInfo->inventory.columns);
@@ -1004,7 +1004,7 @@ void NpcDialog::placeItemInputControls()
else
mItemContainer->setInventory(mInventory);
- if (mDialogInfo && mDialogInfo->hideText)
+ if ((mDialogInfo != nullptr) && mDialogInfo->hideText)
{
if (mShowAvatar)
{
@@ -1064,7 +1064,7 @@ void NpcDialog::buildLayout()
switch (mInputState)
{
case NpcInputState::LIST:
- if (!mDialogInfo)
+ if (mDialogInfo == nullptr)
placeMenuControls();
else
placeSkinControls();
@@ -1099,7 +1099,7 @@ void NpcDialog::buildLayout()
void NpcDialog::saveCamera()
{
- if (!viewport || mCameraMode >= 0)
+ if ((viewport == nullptr) || mCameraMode >= 0)
return;
mCameraMode = CAST_S32(settings.cameraMode);
@@ -1109,12 +1109,12 @@ void NpcDialog::saveCamera()
void NpcDialog::restoreCamera()
{
- if (!viewport || mCameraMode == -1)
+ if ((viewport == nullptr) || mCameraMode == -1)
return;
if (CAST_S32(settings.cameraMode) != mCameraMode)
viewport->toggleCameraMode();
- if (mCameraMode)
+ if (mCameraMode != 0)
{
viewport->setCameraRelativeX(mCameraX);
viewport->setCameraRelativeY(mCameraY);
@@ -1139,14 +1139,14 @@ void NpcDialog::showAvatar(const BeingTypeId avatarId)
const BeingInfo *const info = AvatarDB::get(avatarId);
const int pad2 = 2 * mPadding;
int width = 0;
- if (info)
+ if (info != nullptr)
{
width = info->getWidth();
mPlayerBox->setWidth(width + pad2);
mPlayerBox->setHeight(info->getHeight() + pad2);
}
const Sprite *const sprite = mAvatarBeing->mSprites[0];
- if (sprite && !width)
+ if ((sprite != nullptr) && (width == 0))
{
mPlayerBox->setWidth(sprite->getWidth() + pad2);
mPlayerBox->setHeight(sprite->getHeight() + pad2);
@@ -1172,14 +1172,14 @@ void NpcDialog::showAvatar(const BeingTypeId avatarId)
void NpcDialog::setAvatarDirection(const uint8_t direction)
{
Being *const being = mPlayerBox->getBeing();
- if (being)
+ if (being != nullptr)
being->setDirection(direction);
}
void NpcDialog::setAvatarAction(const int actionId)
{
Being *const being = mPlayerBox->getBeing();
- if (being)
+ if (being != nullptr)
being->setAction(static_cast<BeingActionT>(actionId), 0);
}
@@ -1187,13 +1187,13 @@ void NpcDialog::logic()
{
BLOCK_START("NpcDialog::logic")
Window::logic();
- if (mShowAvatar && mAvatarBeing)
+ if (mShowAvatar && (mAvatarBeing != nullptr))
{
mAvatarBeing->logic();
if (mPlayerBox->getWidth() < CAST_S32(3 * getPadding()))
{
const Sprite *const sprite = mAvatarBeing->mSprites[0];
- if (sprite)
+ if (sprite != nullptr)
{
mPlayerBox->setWidth(sprite->getWidth() + 2 * getPadding());
mPlayerBox->setHeight(sprite->getHeight() + 2 * getPadding());
@@ -1228,7 +1228,7 @@ void NpcDialog::mousePressed(MouseEvent &event)
&& event.getSource() == mTextBox)
{
event.consume();
- if (popupMenu)
+ if (popupMenu != nullptr)
{
popupMenu->showNpcDialogPopup(mNpcId,
viewport->mMouseX,
@@ -1252,7 +1252,7 @@ void NpcDialog::setSkin(const std::string &skin)
return;
}
const NpcDialogInfo *const dialog = NpcDialogDB::getDialog(skin);
- if (!dialog)
+ if (dialog == nullptr)
{
logger->log("Error: creating controls for not existing npc dialog %s",
skin.c_str());
@@ -1271,7 +1271,7 @@ void NpcDialog::createSkinControls()
{
deleteSkinControls();
- if (!mDialogInfo)
+ if (mDialogInfo == nullptr)
return;
FOR_EACH (std::vector<NpcImageInfo*>::const_iterator,
@@ -1280,7 +1280,7 @@ void NpcDialog::createSkinControls()
{
const NpcImageInfo *const info = *it;
Image *const image = Theme::getImageFromTheme(info->name);
- if (image)
+ if (image != nullptr)
{
Icon *const icon = new Icon(this, image, AutoRelease_true);
icon->setPosition(info->x, info->y);
@@ -1338,18 +1338,18 @@ void NpcDialog::createSkinControls()
void NpcDialog::restoreVirtuals()
{
Inventory *const inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
inventory->restoreVirtuals();
}
std::string NpcDialog::complexItemToStr(const ComplexItem *const item)
{
std::string str;
- if (item)
+ if (item != nullptr)
{
const std::vector<Item*> &items = item->getChilds();
const size_t sz = items.size();
- if (!sz)
+ if (sz == 0u)
return str;
const Item *item2 = items[0];
@@ -1382,7 +1382,7 @@ void NpcDialog::addCraftItem(Item *const item,
Inventory *const inventory = PlayerInfo::getInventory();
- if (!inventory)
+ if (inventory == nullptr)
return;
if (mComplexInventory->addVirtualItem(
diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h
index 0c16c7df2..8e041b087 100644
--- a/src/gui/windows/npcdialog.h
+++ b/src/gui/windows/npcdialog.h
@@ -223,7 +223,7 @@ class NpcDialog final : public Window,
void mousePressed(MouseEvent &event) override final;
int isCloseState() const
- { return mActionState == NpcActionState::CLOSE; }
+ { return static_cast<int>(mActionState == NpcActionState::CLOSE); }
void setSkin(const std::string &skin);
diff --git a/src/gui/windows/npcselldialog.cpp b/src/gui/windows/npcselldialog.cpp
index 7238cd8c6..c00edda6c 100644
--- a/src/gui/windows/npcselldialog.cpp
+++ b/src/gui/windows/npcselldialog.cpp
@@ -57,7 +57,7 @@ void NpcSellDialog::sellAction(const ActionEvent &event)
const std::string &eventId = event.getId();
const int selectedItem = mShopItemList->getSelected();
const ShopItem *const item = mShopItems->at(selectedItem);
- if (!item || PlayerInfo::isItemProtected(item->getId()))
+ if ((item == nullptr) || PlayerInfo::isItemProtected(item->getId()))
return;
if (eventId == "presell")
@@ -101,7 +101,7 @@ void NpcSellDialog::sellManyItems(const std::string &eventId)
ShopItem *const item = mShopItems->at(selectedItem);
item->increaseUsedQuantity(mAmountItems);
item->update();
- if (mConfirmButton)
+ if (mConfirmButton != nullptr)
mConfirmButton->setEnabled(true);
}
}
@@ -130,7 +130,7 @@ void NpcSellDialog::sellOneItem()
mAmountItems = 1;
mSlider->setValue(0);
- if (mMaxItems)
+ if (mMaxItems != 0)
{
updateButtonsAndLabels();
}
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index 21e17b8e3..51254e9a0 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -73,7 +73,7 @@ OutfitWindow::OutfitWindow() :
serverConfig.getValueBool("OutfitUnequip0", true))),
// TRANSLATORS: outfits window checkbox
mAwayOutfitCheck(new CheckBox(this, _("Away outfit"),
- serverConfig.getValue("OutfitAwayIndex", OUTFITS_COUNT - 1))),
+ serverConfig.getValue("OutfitAwayIndex", OUTFITS_COUNT - 1) != 0u)),
// TRANSLATORS: outfits window label
mKeyLabel(new Label(this, strprintf(_("Key: %s"),
keyName(0).c_str()))),
@@ -100,7 +100,7 @@ OutfitWindow::OutfitWindow() :
setMinWidth(145);
setMinHeight(220);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mCurrentLabel->setAlignment(Graphics::CENTER);
@@ -181,7 +181,7 @@ void OutfitWindow::load()
if (mAwayOutfit >= CAST_S32(OUTFITS_COUNT))
mAwayOutfit = CAST_S32(OUTFITS_COUNT) - 1;
- if (mAwayOutfitCheck)
+ if (mAwayOutfitCheck != nullptr)
mAwayOutfitCheck->setSelected(mAwayOutfit == mCurrentOutfit);
}
@@ -195,7 +195,7 @@ void OutfitWindow::save() const
for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++)
{
const int val = mItems[o][i];
- const int res = val ? val : -1;
+ const int res = val != 0 ? val : -1;
if (res != -1)
good = true;
outfitStr.append(toString(res));
@@ -255,7 +255,7 @@ void OutfitWindow::action(const ActionEvent &event)
else if (eventId == "equip")
{
wearOutfit(mCurrentOutfit);
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
}
else if (eventId == "away")
@@ -279,9 +279,9 @@ void OutfitWindow::wearOutfit(const int outfit, const bool unwearEmpty,
const Item *const item = PlayerInfo::getInventory()->findItem(
mItems[outfit][i],
mItemColors[outfit][i]);
- if (item
+ if ((item != nullptr)
&& item->isEquipped() == Equipped_false
- && item->getQuantity())
+ && (item->getQuantity() != 0))
{
if (item->isEquipment() == Equipm_true)
{
@@ -348,15 +348,15 @@ void OutfitWindow::draw(Graphics *const graphics)
bool foundItem = false;
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
const Item *const item = inv->findItem(mItems[mCurrentOutfit][i],
mItemColors[mCurrentOutfit][i]);
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
const Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image, itemX, itemY);
foundItem = true;
@@ -367,7 +367,7 @@ void OutfitWindow::draw(Graphics *const graphics)
{
Image *const image = Item::getImage(mItems[mCurrentOutfit][i],
mItemColors[mCurrentOutfit][i]);
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image, itemX, itemY);
image->decRef();
@@ -404,15 +404,15 @@ void OutfitWindow::safeDraw(Graphics *const graphics)
bool foundItem = false;
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
const Item *const item = inv->findItem(mItems[mCurrentOutfit][i],
mItemColors[mCurrentOutfit][i]);
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
const Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image, itemX, itemY);
foundItem = true;
@@ -423,7 +423,7 @@ void OutfitWindow::safeDraw(Graphics *const graphics)
{
Image *const image = Item::getImage(mItems[mCurrentOutfit][i],
mItemColors[mCurrentOutfit][i]);
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image, itemX, itemY);
image->decRef();
@@ -462,10 +462,10 @@ void OutfitWindow::mouseDragged(MouseEvent &event)
mMoved = false;
event.consume();
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
Item *const item = inv->findItem(itemId, itemColor);
- if (item)
+ if (item != nullptr)
dragDrop.dragItem(item, DragDropSource::Outfit);
else
dragDrop.clear();
@@ -479,7 +479,7 @@ void OutfitWindow::mouseDragged(MouseEvent &event)
void OutfitWindow::mousePressed(MouseEvent &event)
{
const int index = getIndexFromGrid(event.getX(), event.getY());
- if (event.getButton() == MouseButton::RIGHT && popupMenu)
+ if (event.getButton() == MouseButton::RIGHT && (popupMenu != nullptr))
{
popupMenu->showOutfitsWindowPopup(viewport->mMouseX,
viewport->mMouseY);
@@ -565,14 +565,14 @@ void OutfitWindow::unequipNotInOutfit(const int outfit) const
// here we think that outfit is correct index
const Inventory *const inventory = PlayerInfo::getInventory();
- if (!inventory)
+ if (inventory == nullptr)
return;
const unsigned int invSize = inventory->getSize();
for (unsigned i = 0; i < invSize; i++)
{
const Item *const item = inventory->getItem(i);
- if (item && item->isEquipped() == Equipped_true)
+ if ((item != nullptr) && item->isEquipped() == Equipped_true)
{
bool found = false;
for (unsigned f = 0; f < OUTFIT_ITEM_COUNT; f++)
@@ -680,14 +680,14 @@ void OutfitWindow::copyFromEquiped()
void OutfitWindow::copyFromEquiped(const int dst)
{
const Inventory *const inventory = PlayerInfo::getInventory();
- if (!inventory)
+ if (inventory == nullptr)
return;
int outfitCell = 0;
for (unsigned i = 0, sz = inventory->getSize(); i < sz; i++)
{
const Item *const item = inventory->getItem(i);
- if (item && item->isEquipped() == Equipped_true)
+ if ((item != nullptr) && item->isEquipped() == Equipped_true)
{
mItems[dst][outfitCell] = item->getId();
mItemColors[dst][outfitCell++] = item->getColor();
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
index bf3b1c19a..5515489e6 100644
--- a/src/gui/windows/questswindow.cpp
+++ b/src/gui/windows/questswindow.cpp
@@ -100,7 +100,7 @@ QuestsWindow::QuestsWindow() :
setMinWidth(310);
setMinHeight(220);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mQuestsListBox->setActionEventId("select");
@@ -111,7 +111,7 @@ QuestsWindow::QuestsWindow() :
mText->setLinkHandler(mItemLinkHandler);
mTextScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
mQuestsListBox->setWidth(500);
- if (!gui || gui->getNpcFont()->getHeight() < 20)
+ if ((gui == nullptr) || gui->getNpcFont()->getHeight() < 20)
mQuestsListBox->setRowHeight(20);
else
mQuestsListBox->setRowHeight(gui->getNpcFont()->getHeight());
@@ -143,12 +143,12 @@ QuestsWindow::~QuestsWindow()
delete2(mItemLinkHandler);
mQuestLinks.clear();
mQuestReverseLinks.clear();
- if (mCompleteIcon)
+ if (mCompleteIcon != nullptr)
{
mCompleteIcon->decRef();
mCompleteIcon = nullptr;
}
- if (mIncompleteIcon)
+ if (mIncompleteIcon != nullptr)
{
mIncompleteIcon->decRef();
mIncompleteIcon = nullptr;
@@ -200,7 +200,7 @@ void QuestsWindow::rebuild(const bool playSound)
const std::vector<QuestItem*> &quests = (*mQuests)[var];
FOR_EACH (std::vector<QuestItem*>::const_iterator, it2, quests)
{
- if (!*it2)
+ if (*it2 == nullptr)
continue;
QuestItem *const quest = *it2;
// complete quest
@@ -238,7 +238,7 @@ void QuestsWindow::rebuild(const bool playSound)
mQuestLinks.push_back(quest);
mQuestReverseLinks[quest->var] = k;
names.push_back(quest->name);
- if (mCompleteIcon)
+ if (mCompleteIcon != nullptr)
{
mCompleteIcon->incRef();
images.push_back(mCompleteIcon);
@@ -262,7 +262,7 @@ void QuestsWindow::rebuild(const bool playSound)
mQuestLinks.push_back(quest);
mQuestReverseLinks[quest->var] = k;
names.push_back(quest->name);
- if (mIncompleteIcon)
+ if (mIncompleteIcon != nullptr)
{
mIncompleteIcon->incRef();
images.push_back(mIncompleteIcon);
@@ -285,7 +285,7 @@ void QuestsWindow::rebuild(const bool playSound)
{
mQuestsListBox->setSelected(updatedQuest);
showQuest(mQuestLinks[updatedQuest]);
- if (playSound && effectManager)
+ if (playSound && (effectManager != nullptr))
{
switch (newCompleteStatus)
{
@@ -306,7 +306,7 @@ void QuestsWindow::rebuild(const bool playSound)
void QuestsWindow::showQuest(const QuestItem *const quest)
{
- if (!quest)
+ if (quest == nullptr)
return;
const std::vector<QuestItemText> &texts = quest->texts;
@@ -373,14 +373,14 @@ void QuestsWindow::setMap(const Map *const map)
{
mMap = map;
mMapEffects.clear();
- if (!mMap)
+ if (mMap == nullptr)
return;
const std::string name = mMap->getProperty("shortName");
FOR_EACHP (std::vector<QuestEffect*>::const_iterator, it, mAllEffects)
{
const QuestEffect *const effect = *it;
- if (effect && name == effect->map)
+ if ((effect != nullptr) && name == effect->map)
mMapEffects.push_back(effect);
}
updateEffects();
@@ -396,7 +396,7 @@ void QuestsWindow::updateEffects()
it, mMapEffects)
{
const QuestEffect *const effect = *it;
- if (effect)
+ if (effect != nullptr)
{
const NpcQuestVarMapCIter varIt = mVars->find(effect->var);
if (varIt != mVars->end())
@@ -407,7 +407,7 @@ void QuestsWindow::updateEffects()
}
}
}
- if (!actorManager)
+ if (actorManager == nullptr)
return;
std::set<BeingTypeId> removeEffects;
@@ -452,7 +452,7 @@ void QuestsWindow::updateEffects()
void QuestsWindow::addEffect(Being *const being)
{
- if (!being)
+ if (being == nullptr)
return;
const BeingTypeId id = being->getSubType();
const std::map<BeingTypeId, const QuestEffect*>::const_iterator
@@ -460,7 +460,7 @@ void QuestsWindow::addEffect(Being *const being)
if (it != mNpcEffects.end())
{
const QuestEffect *const effect = (*it).second;
- if (effect)
+ if (effect != nullptr)
being->addSpecialEffect(effect->effectId);
}
}
diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp
index 4a786d22a..e04b28d18 100644
--- a/src/gui/windows/quitdialog.cpp
+++ b/src/gui/windows/quitdialog.cpp
@@ -130,7 +130,7 @@ void QuitDialog::postInit()
QuitDialog::~QuitDialog()
{
- if (mMyPointer)
+ if (mMyPointer != nullptr)
*mMyPointer = nullptr;
delete2(mForceQuit);
delete2(mLogoutQuit);
@@ -150,10 +150,10 @@ void QuitDialog::action(const ActionEvent &event)
soundManager.playGuiSound(SOUND_HIDE_WINDOW);
if (event.getId() == "ok")
{
- if (viewport)
+ if (viewport != nullptr)
{
const Map *const map = viewport->getMap();
- if (map)
+ if (map != nullptr)
map->saveExtraLayer();
}
@@ -166,7 +166,7 @@ void QuitDialog::action(const ActionEvent &event)
DialogsManager::closeDialogs();
client->setState(State::EXIT);
}
- else if (mRate && mRate->isSelected())
+ else if ((mRate != nullptr) && mRate->isSelected())
{
openBrowser("https://play.google.com/store/apps/details?"
"id=org.evolonline.beta.manaplus");
@@ -241,7 +241,7 @@ void QuitDialog::keyPressed(KeyEvent &event)
if (it == mOptions.end())
{
- if (mOptions[0])
+ if (mOptions[0] != nullptr)
mOptions[0]->setSelected(true);
return;
}
diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp
index c1940eb8d..699023d93 100644
--- a/src/gui/windows/registerdialog.cpp
+++ b/src/gui/windows/registerdialog.cpp
@@ -211,14 +211,15 @@ void RegisterDialog::action(const ActionEvent &event)
errorMsg = _("Passwords do not match.");
error = 2;
}
- else if (mEmailField &&
+ else if ((mEmailField != nullptr) &&
mEmailField->getText().find('@') == std::string::npos)
{
// TRANSLATORS: error message
errorMsg = _("Incorrect email.");
error = 1;
}
- else if (mEmailField && mEmailField->getText().size() > 40)
+ else if (mEmailField != nullptr &&
+ mEmailField->getText().size() > 40)
{
// TRANSLATORS: error message
errorMsg = _("Email too long.");
@@ -257,7 +258,7 @@ void RegisterDialog::action(const ActionEvent &event)
mLoginData->password = mPasswordField->getText();
if (features.getIntValue("forceAccountGender") == -1)
{
- if (mFemaleButton && mFemaleButton->isSelected())
+ if ((mFemaleButton != nullptr) && mFemaleButton->isSelected())
mLoginData->gender = Gender::FEMALE;
else
mLoginData->gender = Gender::MALE;
@@ -268,7 +269,7 @@ void RegisterDialog::action(const ActionEvent &event)
CAST_U8(features.getIntValue("forceAccountGender")));
}
- if (mEmailField)
+ if (mEmailField != nullptr)
mLoginData->email = mEmailField->getText();
mLoginData->registerLogin = true;
@@ -306,7 +307,7 @@ bool RegisterDialog::canSubmit() const
!mPasswordField->getText().empty() &&
!mConfirmField->getText().empty() &&
client->getState() == State::REGISTER &&
- (!mEmailField || !mEmailField->getText().empty());
+ ((mEmailField == nullptr) || !mEmailField->getText().empty());
}
void RegisterDialog::close()
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index a86fa0b1e..51f937666 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -199,7 +199,7 @@ void ServerDialog::postInit()
ServerDialog::~ServerDialog()
{
- if (mDownload)
+ if (mDownload != nullptr)
{
mDownload->cancel();
delete2(mDownload)
@@ -216,7 +216,7 @@ void ServerDialog::connectToSelectedServer()
if (index < 0)
return;
- if (mDownload)
+ if (mDownload != nullptr)
mDownload->cancel();
mQuitButton->setEnabled(false);
@@ -244,7 +244,7 @@ void ServerDialog::connectToSelectedServer()
settings.supportUrl = mServerInfo->supportUrl;
settings.updateMirrors = mServerInfo->updateMirrors;
- if (chatLogger)
+ if (chatLogger != nullptr)
chatLogger->setServerName(mServerInfo->hostname);
saveCustomServers(*mServerInfo);
@@ -254,7 +254,7 @@ void ServerDialog::connectToSelectedServer()
if (mServerInfo->hostname != LoginDialog::savedPasswordKey)
{
LoginDialog::savedPassword.clear();
- if (desktop)
+ if (desktop != nullptr)
desktop->reloadWallpaper();
}
}
@@ -433,7 +433,7 @@ void ServerDialog::downloadServerList()
if (listFile.empty())
listFile = "http://manaplus.org/serverlist.xml";
- if (mDownload)
+ if (mDownload != nullptr)
{
mDownload->cancel();
delete2(mDownload)
@@ -485,7 +485,7 @@ void ServerDialog::loadServers(const bool addNew)
SkipError_false);
XmlNodeConstPtr rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "serverlist"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "serverlist"))
{
logger->log1("Error loading server list!");
return;
@@ -663,7 +663,7 @@ void ServerDialog::loadCustomServers()
server.hostname = config.getValue(hostKey, "");
server.type = ServerInfo::parseType(config.getValue(typeKey, ""));
server.persistentIp = config.getValue(
- persistentIpKey, 0) ? true : false;
+ persistentIpKey, 0) != 0 ? true : false;
server.packetVersion = config.getValue(packetVersionKey, 0);
const int defaultPort = defaultPortForServerType(server.type);
@@ -747,13 +747,13 @@ int ServerDialog::downloadUpdate(void *ptr,
size_t total,
const size_t remaining)
{
- if (!ptr || status == DownloadStatus::Cancelled)
+ if ((ptr == nullptr) || status == DownloadStatus::Cancelled)
return -1;
ServerDialog *const sd = reinterpret_cast<ServerDialog*>(ptr);
bool finished = false;
- if (!sd->mDownload)
+ if (sd->mDownload == nullptr)
return -1;
if (status == DownloadStatus::Complete)
@@ -769,7 +769,7 @@ int ServerDialog::downloadUpdate(void *ptr,
else
{
float progress = static_cast<float>(remaining);
- if (total)
+ if (total != 0u)
progress /= static_cast<float>(total);
if (progress != progress || progress < 0.0F)
@@ -809,7 +809,7 @@ bool ServerDialog::needUpdateServers() const
void ServerDialog::close()
{
- if (mDownload)
+ if (mDownload != nullptr)
mDownload->cancel();
client->setState(State::FORCE_QUIT);
Window::close();
diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp
index 07ecc9ed7..bf5272d24 100644
--- a/src/gui/windows/setupwindow.cpp
+++ b/src/gui/windows/setupwindow.cpp
@@ -111,7 +111,9 @@ void SetupWindow::postInit()
};
int x = width;
mButtonPadding = getOption("buttonPadding", 5);
- for (const char *const * curBtn = buttonNames; *curBtn; ++ curBtn)
+ for (const char *const * curBtn = buttonNames;
+ *curBtn != nullptr;
+ ++ curBtn)
{
Button *const btn = new Button(this, gettext(*curBtn), *curBtn, this);
mButtons.push_back(btn);
@@ -120,7 +122,7 @@ void SetupWindow::postInit()
add(btn);
// Store this button, as it needs to be enabled/disabled
- if (!strcmp(*curBtn, "Reset Windows"))
+ if (strcmp(*curBtn, "Reset Windows") == 0)
mResetWindows = btn;
}
@@ -148,7 +150,7 @@ void SetupWindow::postInit()
}
add(mPanel);
- if (mResetWindows)
+ if (mResetWindows != nullptr)
{
mVersion->setPosition(9,
height - mVersion->getHeight() - mResetWindows->getHeight() - 9);
@@ -175,7 +177,7 @@ SetupWindow::~SetupWindow()
void SetupWindow::action(const ActionEvent &event)
{
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->resetAdjustLevel();
const std::string &eventId = event.getId();
@@ -190,7 +192,7 @@ void SetupWindow::action(const ActionEvent &event)
}
else if (eventId == "Store")
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->saveState();
config.write();
serverConfig.write();
@@ -199,12 +201,12 @@ void SetupWindow::action(const ActionEvent &event)
{
// Bail out if this action happens to be activated before the windows
// are created (though it should be disabled then)
- if (!statusWindow)
+ if (statusWindow == nullptr)
return;
FOR_EACH (std::list<Window*>::const_iterator, it, mWindowsToReset)
{
- if (*it)
+ if (*it != nullptr)
(*it)->resetToDefaultSize();
}
}
@@ -212,7 +214,7 @@ void SetupWindow::action(const ActionEvent &event)
void SetupWindow::setInGame(const bool inGame)
{
- if (mResetWindows)
+ if (mResetWindows != nullptr)
mResetWindows->setEnabled(inGame);
}
@@ -227,14 +229,14 @@ void SetupWindow::externalUpdate()
mPanel->addTab(mQuickTab->getName(), mQuickTab);
FOR_EACH (std::list<SetupTab*>::const_iterator, it, mTabs)
{
- if (*it)
+ if (*it != nullptr)
(*it)->externalUpdated();
}
}
void SetupWindow::unloadTab(SetupTab *const page)
{
- if (page)
+ if (page != nullptr)
{
mTabs.remove(page);
mPanel->removeTab(mPanel->getTab(page->getName()));
@@ -253,7 +255,7 @@ void SetupWindow::externalUnload()
{
FOR_EACH (std::list<SetupTab*>::const_iterator, it, mTabs)
{
- if (*it)
+ if (*it != nullptr)
(*it)->externalUnloaded();
}
unloadAdditionalTabs();
@@ -281,7 +283,7 @@ void SetupWindow::hideWindows()
FOR_EACH (std::list<Window*>::const_iterator, it, mWindowsToReset)
{
Window *const window = *it;
- if (window && !window->isSticky())
+ if ((window != nullptr) && !window->isSticky())
window->setVisible(Visible_false);
}
setVisible(Visible_false);
@@ -320,7 +322,7 @@ void SetupWindow::widgetResized(const Event &event)
x -= btn->getWidth() + mButtonPadding;
btn->setPosition(x, height - btn->getHeight() - mButtonPadding);
}
- if (mResetWindows)
+ if (mResetWindows != nullptr)
{
mVersion->setPosition(9,
height - mVersion->getHeight() - mResetWindows->getHeight() - 9);
diff --git a/src/gui/windows/shopselldialog.cpp b/src/gui/windows/shopselldialog.cpp
index 5b9d88df2..26911836b 100644
--- a/src/gui/windows/shopselldialog.cpp
+++ b/src/gui/windows/shopselldialog.cpp
@@ -49,11 +49,11 @@ void ShopSellDialog::sellAction(const ActionEvent &event A_UNUSED)
const int selectedItem = mShopItemList->getSelected();
ShopItem *const item = mShopItems->at(selectedItem);
- if (!item || PlayerInfo::isItemProtected(item->getId()))
+ if (item == nullptr || PlayerInfo::isItemProtected(item->getId()))
return;
buySellHandler->sendSellRequest(mNick, item, mAmountItems);
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->addAutoItem(mNick, item, mAmountItems);
}
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 4ba33a214..5dbc0bec9 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -155,7 +155,7 @@ ShopWindow::ShopWindow() :
else
setDefaultSize(380, 300, ImagePosition::CENTER);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
const int size = config.getIntValue("fontSize")
@@ -280,18 +280,19 @@ void ShopWindow::action(const ActionEvent &event)
{
if (isBuySelected)
{
- if (mBuyShopItemList && mBuyShopItemList->getSelected() >= 0)
+ if (mBuyShopItemList != nullptr &&
+ mBuyShopItemList->getSelected() >= 0)
{
mBuyShopItems->del(mBuyShopItemList->getSelected());
- if (isShopEmpty() && localPlayer)
+ if (isShopEmpty() && (localPlayer != nullptr))
localPlayer->updateStatus();
}
}
- else if (mSellShopItemList
+ else if ((mSellShopItemList != nullptr)
&& mSellShopItemList->getSelected() >= 0)
{
mSellShopItems->del(mSellShopItemList->getSelected());
- if (isShopEmpty() && localPlayer)
+ if (isShopEmpty() && (localPlayer != nullptr))
localPlayer->updateStatus();
}
}
@@ -338,20 +339,20 @@ void ShopWindow::action(const ActionEvent &event)
std::vector<ShopItem*> &oldItems = mSellShopItems->items();
std::vector<ShopItem*> items;
const Inventory *const inv = PlayerInfo::getCartInventory();
- if (!inv)
+ if (inv == nullptr)
return;
FOR_EACH (std::vector<ShopItem*>::iterator, it, oldItems)
{
ShopItem *const item = *it;
- if (!item)
+ if (item == nullptr)
continue;
const Item *const cartItem = inv->findItem(item->getId(),
item->getColor());
- if (!cartItem)
+ if (cartItem == nullptr)
continue;
item->setInvIndex(cartItem->getInvIndex());
const int amount = cartItem->getQuantity();
- if (!amount)
+ if (amount == 0)
continue;
if (item->getQuantity() > amount)
item->setQuantity(amount);
@@ -380,12 +381,12 @@ void ShopWindow::action(const ActionEvent &event)
const Inventory *const inv = mHaveVending && !isBuySelected
? PlayerInfo::getCartInventory() : PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
// +++ need support for colors
Item *const item = inv->findItem(mSelectedItem, ItemColor_zero);
- if (item)
+ if (item != nullptr)
{
if (eventId == "add")
{
@@ -424,7 +425,7 @@ void ShopWindow::updateButtonsAndLabels()
allowDel = !mEnableBuyingStore
&& mBuyShopItemList->getSelected() != -1
&& mBuyShopItems->getNumberOfElements() > 0;
- if (mPublishButton)
+ if (mPublishButton != nullptr)
{
if (mEnableBuyingStore)
{
@@ -449,7 +450,7 @@ void ShopWindow::updateButtonsAndLabels()
allowDel = !mEnableVending
&& mSellShopItemList->getSelected() != -1
&& sellNotEmpty;
- if (mPublishButton)
+ if (mPublishButton != nullptr)
{
if (mEnableVending)
{
@@ -464,7 +465,7 @@ void ShopWindow::updateButtonsAndLabels()
mPublishButton->adjustSize();
if (sellNotEmpty
&& mSellShopSize > 0
- && localPlayer
+ && (localPlayer != nullptr)
&& localPlayer->getHaveCart())
{
mPublishButton->setEnabled(true);
@@ -477,7 +478,7 @@ void ShopWindow::updateButtonsAndLabels()
}
mAddButton->setEnabled(allowAdd);
mDeleteButton->setEnabled(allowDel);
- if (mRenameButton)
+ if (mRenameButton != nullptr)
mRenameButton->setEnabled(!mEnableVending);
}
@@ -489,7 +490,7 @@ void ShopWindow::setVisible(Visible visible)
void ShopWindow::addBuyItem(const Item *const item, const int amount,
const int price)
{
- if (!item)
+ if (item == nullptr)
return;
const bool emp = isShopEmpty();
mBuyShopItems->addItemNoDup(item->getId(),
@@ -497,7 +498,7 @@ void ShopWindow::addBuyItem(const Item *const item, const int amount,
item->getColor(),
amount,
price);
- if (emp && localPlayer)
+ if (emp && (localPlayer != nullptr))
localPlayer->updateStatus();
updateButtonsAndLabels();
@@ -506,7 +507,7 @@ void ShopWindow::addBuyItem(const Item *const item, const int amount,
void ShopWindow::addSellItem(const Item *const item, const int amount,
const int price)
{
- if (!item)
+ if (item == nullptr)
return;
const bool emp = isShopEmpty();
mSellShopItems->addItemNoDup(item->getId(),
@@ -514,7 +515,7 @@ void ShopWindow::addSellItem(const Item *const item, const int amount,
item->getColor(),
amount,
price);
- if (emp && localPlayer)
+ if (emp && (localPlayer != nullptr))
localPlayer->updateStatus();
updateButtonsAndLabels();
@@ -531,7 +532,7 @@ void ShopWindow::loadList()
const std::string shopListName = settings.serverConfigDir
+ "/shoplist.txt";
- if (!stat(shopListName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode))
+ if ((stat(shopListName.c_str(), &statbuf) == 0) && S_ISREG(statbuf.st_mode))
{
shopFile.open(shopListName.c_str(), std::ios::in);
if (!shopFile.is_open())
@@ -554,10 +555,10 @@ void ShopWindow::loadList()
while (ss >> buf)
tokens.push_back(atoi(buf.c_str()));
- if (tokens.size() == 5 && tokens[0])
+ if (tokens.size() == 5 && (tokens[0] != 0))
{
// +++ need impliment colors?
- if (tokens[1] && tokens[2])
+ if ((tokens[1] != 0) && (tokens[2] != 0))
{
mBuyShopItems->addItem(
tokens[0],
@@ -566,7 +567,7 @@ void ShopWindow::loadList()
tokens[1],
tokens[2]);
}
- if (tokens[3] && tokens[4])
+ if ((tokens[3] != 0) && (tokens[4] != 0))
{
mSellShopItems->addItem(
tokens[0],
@@ -601,20 +602,20 @@ void ShopWindow::saveList() const
FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
{
ShopItem *const item = *(it);
- if (item)
+ if (item != nullptr)
mapItems[item->getId()] = item;
}
items = mSellShopItems->items();
FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
{
- if (!(*it))
+ if ((*it) == nullptr)
continue;
const ShopItem *const sellItem = *(it);
const ShopItem *const buyItem = mapItems[sellItem->getId()];
shopFile << sellItem->getId();
- if (buyItem)
+ if (buyItem != nullptr)
{
shopFile << strprintf(" %d %d ", buyItem->getQuantity(),
buyItem->getPrice());
@@ -635,7 +636,7 @@ void ShopWindow::saveList() const
++mapIt)
{
const ShopItem *const buyItem = (*mapIt).second;
- if (buyItem)
+ if (buyItem != nullptr)
{
shopFile << buyItem->getId();
shopFile << strprintf(" %d %d ", buyItem->getQuantity(),
@@ -650,7 +651,7 @@ void ShopWindow::saveList() const
#ifdef TMWA_SUPPORT
void ShopWindow::announce(ShopItems *const list, const int mode)
{
- if (!list)
+ if (list == nullptr)
return;
std::string data;
@@ -659,14 +660,14 @@ void ShopWindow::announce(ShopItems *const list, const int mode)
else
data.append("Sell ");
- if (mAnnonceTime && (mAnnonceTime + (2 * 60) > cur_time
- || mAnnonceTime > cur_time))
+ if (mAnnonceTime != 0 &&
+ (mAnnonceTime + (2 * 60) > cur_time || mAnnonceTime > cur_time))
{
return;
}
mAnnonceTime = cur_time;
- if (mAnnounceButton)
+ if (mAnnounceButton != nullptr)
mAnnounceButton->setEnabled(false);
std::vector<ShopItem*> items = list->items();
@@ -709,20 +710,23 @@ void ShopWindow::announce(ShopItems *const list, const int mode)
void ShopWindow::startTrade()
{
- if (!actorManager || !tradeWindow)
+ if (actorManager == nullptr ||
+ tradeWindow == nullptr)
+ {
return;
+ }
const Being *const being = actorManager->findBeingByName(
mTradeNick, ActorType::Player);
tradeWindow->clear();
- if (mTradeMoney)
+ if (mTradeMoney != 0)
{
tradeWindow->addAutoMoney(mTradeNick, mTradeMoney);
}
else
{
tradeWindow->addAutoItem(mTradeNick, mTradeItem,
- mTradeItem->getQuantity());
+ mTradeItem->getQuantity());
}
tradeHandler->request(being);
tradePartnerName = mTradeNick;
@@ -747,11 +751,11 @@ void ShopWindow::giveList(const std::string &nick, const int mode)
list = mSellShopItems;
data.append("B1");
}
- if (!list)
+ if (list == nullptr)
return;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
std::vector<ShopItem*> items = list->items();
@@ -759,20 +763,20 @@ void ShopWindow::giveList(const std::string &nick, const int mode)
FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
{
const ShopItem *const item = *(it);
- if (!item)
+ if (item == nullptr)
continue;
if (mode == SELL)
{
const Item *const item2 = inv->findItem(item->getId(),
ItemColor_zero);
- if (item2)
+ if (item2 != nullptr)
{
int amount = item->getQuantity();
if (item2->getQuantity() < amount)
amount = item2->getQuantity();
- if (amount)
+ if (amount != 0)
{
data.append(strprintf("%s%s%s",
encodeStr(item->getId(), 2).c_str(),
@@ -807,7 +811,7 @@ void ShopWindow::sendMessage(const std::string &nick,
std::string data,
const bool random)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return;
if (random)
@@ -827,7 +831,7 @@ void ShopWindow::sendMessage(const std::string &nick,
void ShopWindow::showList(const std::string &nick, std::string data)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
BuyDialog *buyDialog = nullptr;
@@ -847,9 +851,9 @@ void ShopWindow::showList(const std::string &nick, std::string data)
return;
}
- if (buyDialog)
+ if (buyDialog != nullptr)
buyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
- if (sellDialog)
+ if (sellDialog != nullptr)
sellDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
for (unsigned f = 0; f < data.length(); f += 9)
@@ -860,7 +864,7 @@ void ShopWindow::showList(const std::string &nick, std::string data)
const int id = decodeStr(data.substr(f, 2));
const int price = decodeStr(data.substr(f + 2, 4));
int amount = decodeStr(data.substr(f + 6, 3));
- if (buyDialog && amount > 0)
+ if (buyDialog != nullptr && amount > 0)
{
buyDialog->addItem(id,
ItemType::Unknown,
@@ -868,10 +872,10 @@ void ShopWindow::showList(const std::string &nick, std::string data)
amount,
price);
}
- if (sellDialog)
+ if (sellDialog != nullptr)
{
const Item *const item = inv->findItem(id, ItemColor_zero);
- if (item)
+ if (item != nullptr)
{
if (item->getQuantity() < amount)
amount = item->getQuantity();
@@ -886,28 +890,29 @@ void ShopWindow::showList(const std::string &nick, std::string data)
amount,
price);
- if (shopItem && amount <= 0)
+ if (shopItem != nullptr && amount <= 0)
shopItem->setDisabled(true);
}
}
- if (buyDialog)
+ if (buyDialog != nullptr)
buyDialog->sort();
}
-void ShopWindow::processRequest(const std::string &nick, std::string data,
+void ShopWindow::processRequest(const std::string &nick,
+ std::string data,
const int mode)
{
- if (!localPlayer ||
+ if (localPlayer == nullptr ||
!mTradeNick.empty() ||
PlayerInfo::isTrading() == Trading_true ||
- !actorManager ||
- !actorManager->findBeingByName(nick, ActorType::Player))
+ actorManager == nullptr ||
+ actorManager->findBeingByName(nick, ActorType::Player) == nullptr)
{
return;
}
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const size_t idx = data.find(' ');
@@ -964,8 +969,9 @@ void ShopWindow::processRequest(const std::string &nick, std::string data,
// +++ need support for colors
const Item *const item2 = inv->findItem(mTradeItem->getId(),
ItemColor_zero);
- if (!item2 || item2->getQuantity() < amount
- || !findShopItem(mTradeItem, SELL))
+ if (item2 == nullptr ||
+ item2->getQuantity() < amount ||
+ !findShopItem(mTradeItem, SELL))
{
sendMessage(nick,
// TRANSLATORS: error buy/sell shop request
@@ -1026,13 +1032,13 @@ void ShopWindow::processRequest(const std::string &nick, std::string data,
void ShopWindow::updateTimes()
{
BLOCK_START("ShopWindow::updateTimes")
- if (!mAnnounceButton)
+ if (mAnnounceButton == nullptr)
{
BLOCK_END("ShopWindow::updateTimes")
return;
}
- if (mAnnonceTime + (2 * 60) < cur_time
- || mAnnonceTime > cur_time)
+ if (mAnnonceTime + (2 * 60) < cur_time ||
+ mAnnonceTime > cur_time)
{
mAnnounceButton->setEnabled(true);
}
@@ -1041,7 +1047,7 @@ void ShopWindow::updateTimes()
bool ShopWindow::checkFloodCounter(time_t &counterTime)
{
- if (!counterTime || counterTime > cur_time)
+ if (counterTime == 0 || counterTime > cur_time)
counterTime = cur_time;
else if (counterTime + 10 > cur_time)
return false;
@@ -1053,7 +1059,7 @@ bool ShopWindow::checkFloodCounter(time_t &counterTime)
bool ShopWindow::findShopItem(const ShopItem *const shopItem,
const int mode) const
{
- if (!shopItem)
+ if (shopItem == nullptr)
return false;
std::vector<ShopItem*> items;
@@ -1065,7 +1071,7 @@ bool ShopWindow::findShopItem(const ShopItem *const shopItem,
FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
{
const ShopItem *const item = *(it);
- if (!item)
+ if (item == nullptr)
continue;
if (item->getId() == shopItem->getId()
@@ -1081,18 +1087,18 @@ bool ShopWindow::findShopItem(const ShopItem *const shopItem,
int ShopWindow::sumAmount(const Item *const shopItem)
{
- if (!localPlayer || !shopItem)
+ if ((localPlayer == nullptr) || (shopItem == nullptr))
return 0;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return 0;
int sum = 0;
for (unsigned f = 0; f < inv->getSize(); f ++)
{
const Item *const item = inv->getItem(f);
- if (item && item->getId() == shopItem->getId())
+ if ((item != nullptr) && item->getId() == shopItem->getId())
sum += item->getQuantity();
}
return sum;
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
index be96b6416..ffac3d320 100644
--- a/src/gui/windows/shortcutwindow.cpp
+++ b/src/gui/windows/shortcutwindow.cpp
@@ -70,15 +70,15 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title,
mDragOffsetX = 0;
mDragOffsetY = 0;
- if (content)
+ if (content != nullptr)
content->setWidget2(this);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setMinWidth(32);
setMinHeight(32);
const int border = SCROLL_PADDING * 2 + getPadding() * 2;
- if (mItems)
+ if (mItems != nullptr)
{
const int bw = mItems->getBoxWidth();
const int bh = mItems->getBoxHeight();
@@ -130,10 +130,10 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title,
mDragOffsetX = 0;
mDragOffsetY = 0;
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
- if (width && height)
+ if ((width != 0) && (height != 0))
setDefaultSize(width, height, ImagePosition::LOWER_RIGHT);
setMinWidth(32);
@@ -151,7 +151,7 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title,
ShortcutWindow::~ShortcutWindow()
{
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->removeAll();
delete2(mTabs);
delete2(mItems);
@@ -168,7 +168,7 @@ void ShortcutWindow::addButton(const std::string &text,
void ShortcutWindow::addTab(const std::string &name,
ShortcutContainer *const content)
{
- if (!content || !mTabs)
+ if ((content == nullptr) || (mTabs == nullptr))
return;
ScrollArea *const scroll = new ScrollArea(this, content, Opaque_false);
scroll->setPosition(SCROLL_PADDING, SCROLL_PADDING);
@@ -181,7 +181,7 @@ void ShortcutWindow::addTab(const std::string &name,
int ShortcutWindow::getTabIndex() const
{
- if (!mTabs)
+ if (mTabs == nullptr)
return 0;
return mTabs->getSelectedTabIndex();
}
@@ -189,18 +189,18 @@ int ShortcutWindow::getTabIndex() const
void ShortcutWindow::widgetHidden(const Event &event)
{
Window::widgetHidden(event);
- if (mItems)
+ if (mItems != nullptr)
mItems->widgetHidden(event);
- if (mTabs)
+ if (mTabs != nullptr)
{
ScrollArea *const scroll = static_cast<ScrollArea *>(
mTabs->getCurrentWidget());
- if (scroll)
+ if (scroll != nullptr)
{
ShortcutContainer *const content = static_cast<ShortcutContainer*>(
scroll->getContent());
- if (content)
+ if (content != nullptr)
content->widgetHidden(event);
}
}
@@ -240,7 +240,7 @@ void ShortcutWindow::mouseDragged(MouseEvent &event)
void ShortcutWindow::widgetMoved(const Event& event)
{
Window::widgetMoved(event);
- if (mItems)
+ if (mItems != nullptr)
mItems->setRedraw(true);
FOR_EACH (std::vector<ShortcutContainer*>::iterator, it, mPages)
(*it)->setRedraw(true);
@@ -248,13 +248,13 @@ void ShortcutWindow::widgetMoved(const Event& event)
void ShortcutWindow::nextTab()
{
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->selectNextTab();
}
void ShortcutWindow::prevTab()
{
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->selectPrevTab();
}
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 9a99c32ca..52dd067ea 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -102,7 +102,7 @@ SkillDialog::SkillDialog() :
setSaveVisible(true);
setStickyButtonLock(true);
setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mUseButton->setEnabled(false);
@@ -156,11 +156,11 @@ void SkillDialog::action(const ActionEvent &event)
const std::string &eventId = event.getId();
if (eventId == "inc")
{
- if (!playerHandler)
+ if (playerHandler == nullptr)
return;
const SkillTab *const tab = static_cast<const SkillTab *>(
mTabs->getSelectedTab());
- if (tab)
+ if (tab != nullptr)
{
if (const SkillInfo *const info = tab->getSelectedInfo())
playerHandler->increaseSkill(CAST_U16(info->id));
@@ -170,7 +170,7 @@ void SkillDialog::action(const ActionEvent &event)
{
const SkillTab *const tab = static_cast<const SkillTab *>(
mTabs->getSelectedTab());
- if (tab)
+ if (tab != nullptr)
{
if (const SkillInfo *const info = tab->getSelectedInfo())
{
@@ -179,7 +179,7 @@ void SkillDialog::action(const ActionEvent &event)
mIncreaseButton->setEnabled(info->id < SKILL_VAR_MIN_ID);
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
- && itemShortcut[num])
+ && (itemShortcut[num] != nullptr))
{
itemShortcut[num]->setItemSelected(
info->id + SKILL_MIN_ID);
@@ -198,7 +198,7 @@ void SkillDialog::action(const ActionEvent &event)
{
const SkillTab *const tab = static_cast<const SkillTab *>(
mTabs->getSelectedTab());
- if (tab)
+ if (tab != nullptr)
{
const SkillInfo *const info = tab->getSelectedInfo();
useSkill(info,
@@ -224,7 +224,7 @@ std::string SkillDialog::update(const int id)
if (i != mSkills.end())
{
SkillInfo *const info = i->second;
- if (info)
+ if (info != nullptr)
{
info->update();
return info->data->name;
@@ -244,7 +244,7 @@ void SkillDialog::update()
FOR_EACH (SkillMap::const_iterator, it, mSkills)
{
SkillInfo *const info = (*it).second;
- if (info && info->modifiable == Modifiable_true)
+ if ((info != nullptr) && info->modifiable == Modifiable_true)
info->update();
}
@@ -258,17 +258,17 @@ void SkillDialog::updateModels()
FOR_EACH (SkillMap::const_iterator, it, mSkills)
{
SkillInfo *const info = (*it).second;
- if (info)
+ if (info != nullptr)
{
SkillModel *const model = info->model;
- if (model)
+ if (model != nullptr)
models.insert(model);
}
}
FOR_EACH (std::set<SkillModel*>::iterator, it, models)
{
SkillModel *const model = *it;
- if (model)
+ if (model != nullptr)
model->updateVisibilities();
}
}
@@ -290,7 +290,7 @@ void SkillDialog::hideSkills(const SkillOwner::Type owner)
FOR_EACH (SkillMap::iterator, it, mSkills)
{
SkillInfo *const info = (*it).second;
- if (info && info->owner == owner)
+ if ((info != nullptr) && info->owner == owner)
{
PlayerInfo::setSkillLevel(info->id, 0);
if (info->alwaysVisible == Visible_false)
@@ -322,7 +322,7 @@ void SkillDialog::loadXmlFile(const std::string &fileName,
int setCount = 0;
- if (!root || !xmlNameEqual(root, "skills"))
+ if ((root == nullptr) || !xmlNameEqual(root, "skills"))
{
logger->log("Error loading skills: " + fileName);
return;
@@ -399,7 +399,7 @@ void SkillDialog::loadXmlFile(const std::string &fileName,
setTypeStr.c_str());
return;
}
- if (!mDefaultModel)
+ if (mDefaultModel == nullptr)
{
mDefaultModel = model;
mDefaultTab = tab;
@@ -453,7 +453,7 @@ SkillInfo *SkillDialog::loadSkill(XmlNodeConstPtr node,
strprintf(_("Skill %d"), id));
SkillInfo *skill = getSkill(id);
- if (!skill)
+ if (skill == nullptr)
{
skill = new SkillInfo;
skill->id = CAST_U32(id);
@@ -495,12 +495,12 @@ SkillInfo *SkillDialog::loadSkill(XmlNodeConstPtr node,
void SkillDialog::loadSkillData(XmlNodeConstPtr node,
SkillInfo *const skill)
{
- if (!skill)
+ if (skill == nullptr)
return;
const int level = (skill->alwaysVisible == Visible_true) ?
0 : XML::getProperty(node, "level", 0);
SkillData *data = skill->getData(level);
- if (!data)
+ if (data == nullptr)
data = new SkillData;
const std::string name = XML::langProperty(node, "name",
@@ -573,7 +573,7 @@ void SkillDialog::removeSkill(const int id)
if (it != mSkills.end())
{
SkillInfo *const info = it->second;
- if (info)
+ if (info != nullptr)
{
info->level = 0;
info->update();
@@ -595,14 +595,14 @@ bool SkillDialog::updateSkill(const int id,
if (it != mSkills.end())
{
SkillInfo *const info = it->second;
- if (info)
+ if (info != nullptr)
{
info->modifiable = modifiable;
info->range = range;
info->type = type;
info->sp = sp;
info->update();
- if (info->tab)
+ if (info->tab != nullptr)
{
info->tab->setVisible(Visible_true);
mTabs->adjustTabPositions();
@@ -623,7 +623,7 @@ void SkillDialog::addSkill(const SkillOwner::Type owner,
const SkillType::SkillType type,
const int sp)
{
- if (mDefaultModel)
+ if (mDefaultModel != nullptr)
{
SkillInfo *const skill = new SkillInfo;
skill->id = CAST_U32(id);
@@ -699,7 +699,7 @@ void SkillDialog::setSkillDuration(const SkillOwner::Type owner,
{
info = (*it).second;
}
- if (info)
+ if (info != nullptr)
{
info->duration = duration;
info->durationTime = tick_time;
@@ -711,7 +711,7 @@ void SkillDialog::widgetResized(const Event &event)
{
Window::widgetResized(event);
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->adjustSize();
}
@@ -757,7 +757,7 @@ void SkillDialog::updateTabSelection()
{
const SkillTab *const tab = static_cast<SkillTab*>(
mTabs->getSelectedTab());
- if (tab)
+ if (tab != nullptr)
{
if (const SkillInfo *const info = tab->getSelectedInfo())
{
@@ -786,7 +786,7 @@ void SkillDialog::updateQuest(const int var,
if (it != mSkills.end())
{
SkillInfo *const info = it->second;
- if (info)
+ if (info != nullptr)
{
PlayerInfo::setSkillLevel(id, val1);
info->level = val1;
@@ -801,7 +801,7 @@ SkillData *SkillDialog::getSkillData(const int id) const
if (it != mSkills.end())
{
SkillInfo *const info = it->second;
- if (info)
+ if (info != nullptr)
return info->data;
}
return nullptr;
@@ -814,7 +814,7 @@ SkillData *SkillDialog::getSkillDataByLevel(const int id,
if (it != mSkills.end())
{
SkillInfo *const info = it->second;
- if (info)
+ if (info != nullptr)
return info->getData1(level);
}
return nullptr;
@@ -822,10 +822,10 @@ SkillData *SkillDialog::getSkillDataByLevel(const int id,
void SkillDialog::playUpdateEffect(const int id) const
{
- if (!effectManager)
+ if (effectManager == nullptr)
return;
const SkillData *const data = getSkillData(id);
- if (!data)
+ if (data == nullptr)
return;
effectManager->triggerDefault(data->updateEffectId,
localPlayer,
@@ -834,10 +834,10 @@ void SkillDialog::playUpdateEffect(const int id) const
void SkillDialog::playRemoveEffect(const int id) const
{
- if (!effectManager)
+ if (effectManager == nullptr)
return;
const SkillData *const data = getSkillData(id);
- if (!data)
+ if (data == nullptr)
return;
effectManager->triggerDefault(data->removeEffectId,
localPlayer,
@@ -850,10 +850,10 @@ void SkillDialog::playCastingDstTileEffect(const int id,
const int y,
const int delay) const
{
- if (!effectManager)
+ if (effectManager == nullptr)
return;
SkillData *const data = getSkillDataByLevel(id, level);
- if (!data)
+ if (data == nullptr)
return;
effectManager->triggerDefault(data->castingGroundEffectId,
x * 32,
@@ -872,7 +872,7 @@ void SkillDialog::useSkill(const int skillId,
const int offsetY)
{
SkillInfo *const info = skillDialog->getSkill(skillId);
- if (!info)
+ if (info == nullptr)
return;
if (castType == CastType::Default)
castType = info->customCastType;
@@ -895,13 +895,13 @@ void SkillDialog::useSkill(const SkillInfo *const info,
const int offsetX,
const int offsetY)
{
- if (!info || !localPlayer)
+ if ((info == nullptr) || (localPlayer == nullptr))
return;
- if (!level)
+ if (level == 0)
level = info->level;
const SkillData *data = info->getData1(level);
- if (data)
+ if (data != nullptr)
{
const std::string cmd = data->invokeCmd;
if (!cmd.empty())
@@ -973,15 +973,15 @@ void SkillDialog::useSkillTarget(const SkillInfo *const info,
SkillType::SkillType type = info->type;
if ((type & SkillType::Attack) != 0)
{
- if (!being && autoTarget == AutoTarget_true)
+ if ((being == nullptr) && autoTarget == AutoTarget_true)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
being = localPlayer->setNewTarget(ActorType::Monster,
AllowSort_true);
}
}
- if (being)
+ if (being != nullptr)
{
skillHandler->useBeing(info->id,
level,
@@ -990,9 +990,9 @@ void SkillDialog::useSkillTarget(const SkillInfo *const info,
}
else if ((type & SkillType::Support) != 0)
{
- if (!being)
+ if (being == nullptr)
being = localPlayer;
- if (being)
+ if (being != nullptr)
{
skillHandler->useBeing(info->id,
level,
@@ -1007,7 +1007,7 @@ void SkillDialog::useSkillTarget(const SkillInfo *const info,
}
else if ((type & SkillType::Ground) != 0)
{
- if (!being)
+ if (being == nullptr)
return;
being->fixDirectionOffsets(offsetX, offsetY);
const int x = being->getTileX() + offsetX;
@@ -1157,12 +1157,12 @@ void SkillDialog::useSkillDefault(const SkillInfo *const info,
if ((type & SkillType::Attack) != 0)
{
const Being *being = localPlayer->getTarget();
- if (!being && autoTarget == AutoTarget_true)
+ if ((being == nullptr) && autoTarget == AutoTarget_true)
{
being = localPlayer->setNewTarget(ActorType::Monster,
AllowSort_true);
}
- if (being)
+ if (being != nullptr)
{
skillHandler->useBeing(info->id,
level,
@@ -1172,9 +1172,9 @@ void SkillDialog::useSkillDefault(const SkillInfo *const info,
else if ((type & SkillType::Support) != 0)
{
const Being *being = localPlayer->getTarget();
- if (!being)
+ if (being == nullptr)
being = localPlayer;
- if (being)
+ if (being != nullptr)
{
skillHandler->useBeing(info->id,
level,
@@ -1247,7 +1247,7 @@ void SkillDialog::useSkillDefault(const SkillInfo *const info,
void SkillDialog::addSkillDuration(SkillInfo *const skill)
{
- if (!skill)
+ if (skill == nullptr)
return;
FOR_EACH (std::vector<SkillInfo*>::const_iterator, it, mDurations)
@@ -1263,7 +1263,7 @@ void SkillDialog::slowLogic()
FOR_EACH_SAFE (std::vector<SkillInfo*>::iterator, it, mDurations)
{
SkillInfo *const skill = *it;
- if (skill)
+ if (skill != nullptr)
{
const int time = get_elapsed_time(skill->durationTime);
if (time >= skill->duration)
@@ -1277,7 +1277,7 @@ void SkillDialog::slowLogic()
if (it != mDurations.begin())
-- it;
}
- else if (time)
+ else if (time != 0)
{
skill->cooldown = skill->duration * 100 / time;
}
@@ -1289,7 +1289,7 @@ void SkillDialog::selectSkillLevel(const int skillId,
const int level)
{
SkillInfo *const info = getSkill(skillId);
- if (!info)
+ if (info == nullptr)
return;
if (level > info->level)
info->customSelectedLevel = info->level;
@@ -1302,7 +1302,7 @@ void SkillDialog::selectSkillCastType(const int skillId,
const CastTypeT type)
{
SkillInfo *const info = getSkill(skillId);
- if (!info)
+ if (info == nullptr)
return;
info->customCastType = type;
info->update();
@@ -1312,7 +1312,7 @@ void SkillDialog::setSkillOffsetX(const int skillId,
const int offset)
{
SkillInfo *const info = getSkill(skillId);
- if (!info)
+ if (info == nullptr)
return;
info->customOffsetX = offset;
info->update();
@@ -1322,7 +1322,7 @@ void SkillDialog::setSkillOffsetY(const int skillId,
const int offset)
{
SkillInfo *const info = getSkill(skillId);
- if (!info)
+ if (info == nullptr)
return;
info->customOffsetY = offset;
info->update();
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 78f7724ee..11207d47f 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -95,7 +95,7 @@ void SocialWindow::postInit()
setMinWidth(120);
setMinHeight(55);
setDefaultSize(590, 200, 180, 300);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
place(0, 0, mMenuButton);
@@ -135,10 +135,10 @@ void SocialWindow::postInit()
mPickupFilter = nullptr;
}
- if (localPlayer && localPlayer->getParty())
+ if ((localPlayer != nullptr) && (localPlayer->getParty() != nullptr))
addTab(localPlayer->getParty());
- if (localPlayer && localPlayer->getGuild())
+ if ((localPlayer != nullptr) && (localPlayer->getGuild() != nullptr))
addTab(localPlayer->getGuild());
enableVisibleSound(true);
@@ -149,7 +149,7 @@ void SocialWindow::postInit()
SocialWindow::~SocialWindow()
{
player_relations.removeListener(this);
- if (mGuildAcceptDialog)
+ if (mGuildAcceptDialog != nullptr)
{
mGuildAcceptDialog->close();
mGuildAcceptDialog->scheduleDelete();
@@ -158,7 +158,7 @@ SocialWindow::~SocialWindow()
mGuildInvited = 0;
}
- if (mPartyAcceptDialog)
+ if (mPartyAcceptDialog != nullptr)
{
mPartyAcceptDialog->close();
mPartyAcceptDialog->scheduleDelete();
@@ -185,7 +185,7 @@ SocialWindow::~SocialWindow()
bool SocialWindow::addTab(Guild *const guild)
{
- if (!guild)
+ if (guild == nullptr)
return false;
if (mGuilds.find(guild) != mGuilds.end())
@@ -230,7 +230,7 @@ bool SocialWindow::removeTab(Guild *const guild)
bool SocialWindow::addTab(Party *const party)
{
- if (!party)
+ if (party == nullptr)
return false;
if (mParties.find(party) != mParties.end())
@@ -270,7 +270,7 @@ void SocialWindow::action(const ActionEvent &event)
{
if (eventId == "yes")
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(
// TRANSLATORS: chat message
@@ -282,7 +282,7 @@ void SocialWindow::action(const ActionEvent &event)
}
else if (eventId == "no")
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(
// TRANSLATORS: chat message
@@ -300,7 +300,7 @@ void SocialWindow::action(const ActionEvent &event)
{
if (eventId == "yes")
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(
// TRANSLATORS: chat message
@@ -309,7 +309,7 @@ void SocialWindow::action(const ActionEvent &event)
ChatMsgType::BY_SERVER);
}
#ifdef TMWA_SUPPORT
- if (!guildManager || !GuildManager::getEnableGuildBot())
+ if (guildManager == nullptr || !GuildManager::getEnableGuildBot())
guildHandler->inviteResponse(mGuildInvited, true);
else
guildManager->inviteResponse(true);
@@ -320,7 +320,7 @@ void SocialWindow::action(const ActionEvent &event)
}
else if (eventId == "no")
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(
// TRANSLATORS: chat message
@@ -329,7 +329,7 @@ void SocialWindow::action(const ActionEvent &event)
ChatMsgType::BY_SERVER);
}
#ifdef TMWA_SUPPORT
- if (!guildManager || !GuildManager::getEnableGuildBot())
+ if (guildManager == nullptr || !GuildManager::getEnableGuildBot())
guildHandler->inviteResponse(mGuildInvited, false);
else
guildManager->inviteResponse(false);
@@ -379,7 +379,7 @@ void SocialWindow::showGuildInvite(const std::string &restrict guildName,
// check there isnt already an invite showing
if (mGuildInvited != 0)
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: chat message
localChatTab->chatLog(_("Received guild request, but one already "
@@ -394,7 +394,7 @@ void SocialWindow::showGuildInvite(const std::string &restrict guildName,
_("%s has invited you to join the guild %s."),
inviterName.c_str(), guildName.c_str());
- if (localChatTab)
+ if (localChatTab != nullptr)
localChatTab->chatLog(msg, ChatMsgType::BY_SERVER);
CREATEWIDGETV(mGuildAcceptDialog, ConfirmDialog,
@@ -416,7 +416,7 @@ void SocialWindow::showPartyInvite(const std::string &restrict partyName,
// check there isnt already an invite showing
if (!mPartyInviter.empty())
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: chat message
localChatTab->chatLog(_("Received party request, but one already "
@@ -457,7 +457,7 @@ void SocialWindow::showPartyInvite(const std::string &restrict partyName,
}
}
- if (localChatTab)
+ if (localChatTab != nullptr)
localChatTab->chatLog(msg, ChatMsgType::BY_SERVER);
// show invite
@@ -519,25 +519,25 @@ void SocialWindow::updateButtons()
void SocialWindow::updatePortals()
{
- if (mNavigation)
+ if (mNavigation != nullptr)
mNavigation->updateList();
}
void SocialWindow::updatePortalNames()
{
- if (mNavigation)
+ if (mNavigation != nullptr)
static_cast<SocialNavigationTab*>(mNavigation)->updateNames();
}
void SocialWindow::selectPortal(const unsigned num)
{
- if (mNavigation)
+ if (mNavigation != nullptr)
mNavigation->selectIndex(num);
}
int SocialWindow::getPortalIndex(const int x, const int y)
{
- if (mNavigation)
+ if (mNavigation != nullptr)
{
return static_cast<SocialNavigationTab*>(
mNavigation)->getPortalIndex(x, y);
@@ -550,47 +550,47 @@ int SocialWindow::getPortalIndex(const int x, const int y)
void SocialWindow::addPortal(const int x, const int y)
{
- if (mNavigation)
+ if (mNavigation != nullptr)
static_cast<SocialNavigationTab*>(mNavigation)->addPortal(x, y);
}
void SocialWindow::removePortal(const int x, const int y)
{
- if (mNavigation)
+ if (mNavigation != nullptr)
static_cast<SocialNavigationTab*>(mNavigation)->removePortal(x, y);
}
void SocialWindow::nextTab()
{
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->selectNextTab();
}
void SocialWindow::prevTab()
{
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->selectPrevTab();
}
void SocialWindow::updateAttackFilter()
{
- if (mAttackFilter)
+ if (mAttackFilter != nullptr)
mAttackFilter->updateList();
}
void SocialWindow::updatePickupFilter()
{
- if (mPickupFilter)
+ if (mPickupFilter != nullptr)
mPickupFilter->updateList();
}
void SocialWindow::updateParty()
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
const PartyMap::iterator it = mParties.find(party);
if (it != mParties.end())
@@ -604,7 +604,7 @@ void SocialWindow::updateParty()
void SocialWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->adjustSize();
}
@@ -627,11 +627,11 @@ void SocialWindow::updateMenu(const SocialTab *const tab,
void SocialWindow::updateGuildCounter(const int online, const int total)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
const GuildMap::iterator it = mGuilds.find(guild);
if (it != mGuilds.end())
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 9b1fa0770..3ec369b93 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -62,7 +62,7 @@
StatusWindow *statusWindow = nullptr;
StatusWindow::StatusWindow() :
- Window(localPlayer ? localPlayer->getName() :
+ Window(localPlayer != nullptr ? localPlayer->getName() :
"?", Modal_false, nullptr, "status.xml"),
ActionListener(),
AttributeListener(),
@@ -89,7 +89,7 @@ StatusWindow::StatusWindow() :
mCopyButton(new Button(this, _("Copy to chat"), "copy", this))
{
setWindowName("Status");
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setResizable(true);
setCloseButton(true);
@@ -102,14 +102,14 @@ StatusWindow::StatusWindow() :
mTabs->getWidgetContainer()->setSelectable(false);
mTabs->getTabContainer()->setSelectable(false);
- if (localPlayer && !localPlayer->getRaceName().empty())
+ if ((localPlayer != nullptr) && !localPlayer->getRaceName().empty())
{
setCaption(strprintf("%s (%s)", localPlayer->getName().c_str(),
localPlayer->getRaceName().c_str()));
}
int max = PlayerInfo::getAttribute(Attributes::PLAYER_MAX_HP);
- if (!max)
+ if (max == 0)
max = 1;
mHpBar = new ProgressBar(this,
@@ -125,7 +125,7 @@ StatusWindow::StatusWindow() :
max = PlayerInfo::getAttribute(Attributes::PLAYER_EXP_NEEDED);
mXpBar = new ProgressBar(this,
- max ?
+ max != 0 ?
static_cast<float>(PlayerInfo::getAttribute(Attributes::PLAYER_EXP)) /
static_cast<float>(max) : static_cast<float>(0),
80,
@@ -143,7 +143,7 @@ StatusWindow::StatusWindow() :
mMpLabel = new Label(this, _("MP:"));
const bool useMagic = playerHandler->canUseMagic();
mMpBar = new ProgressBar(this,
- max ? static_cast<float>(PlayerInfo::getAttribute(
+ max != 0 ? static_cast<float>(PlayerInfo::getAttribute(
Attributes::PLAYER_MAX_MP)) / static_cast<float>(max)
: static_cast<float>(0),
80,
@@ -258,7 +258,7 @@ void StatusWindow::addTabBasic(const std::string &name)
void StatusWindow::updateLevelLabel()
{
- if (localPlayer && localPlayer->isGM())
+ if ((localPlayer != nullptr) && localPlayer->isGM())
{
// TRANSLATORS: status window label
mLvlLabel->setCaption(strprintf(_("Level: %d (GM %d)"),
@@ -284,13 +284,13 @@ void StatusWindow::statChanged(const AttributesT id,
if (id == Attributes::PLAYER_JOB)
{
- if (mJobLvlLabel)
+ if (mJobLvlLabel != nullptr)
{
int lvl = PlayerInfo::getStatBase(id);
const int oldExp = oldVal1;
const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
- if (!lvl)
+ if (lvl == 0)
{
// possible server broken and don't send job level,
// then we fixing it :)
@@ -381,7 +381,7 @@ void StatusWindow::setPointsNeeded(const AttributesT id,
void StatusWindow::updateHPBar(ProgressBar *const bar, const bool showMax)
{
- if (!bar)
+ if (bar == nullptr)
return;
const int hp = PlayerInfo::getAttribute(Attributes::PLAYER_HP);
@@ -400,7 +400,7 @@ void StatusWindow::updateHPBar(ProgressBar *const bar, const bool showMax)
void StatusWindow::updateMPBar(ProgressBar *const bar,
const bool showMax) const
{
- if (!bar)
+ if (bar == nullptr)
return;
const int mp = PlayerInfo::getAttribute(Attributes::PLAYER_MP);
@@ -435,7 +435,7 @@ void StatusWindow::updateProgressBar(ProgressBar *const bar,
const int max,
const bool percent)
{
- if (!bar)
+ if (bar == nullptr)
return;
if (max == 0)
@@ -464,7 +464,7 @@ void StatusWindow::updateProgressBar(ProgressBar *const bar,
void StatusWindow::updateXPBar(ProgressBar *const bar, const bool percent)
{
- if (!bar)
+ if (bar == nullptr)
return;
updateProgressBar(bar, PlayerInfo::getAttribute(Attributes::PLAYER_EXP),
@@ -473,7 +473,7 @@ void StatusWindow::updateXPBar(ProgressBar *const bar, const bool percent)
void StatusWindow::updateJobBar(ProgressBar *const bar, const bool percent)
{
- if (!bar)
+ if (bar == nullptr)
return;
const std::pair<int, int> exp = PlayerInfo::getStatExperience(
@@ -491,7 +491,7 @@ void StatusWindow::updateProgressBar(ProgressBar *const bar,
void StatusWindow::updateWeightBar(ProgressBar *const bar)
{
- if (!bar)
+ if (bar == nullptr)
return;
if (PlayerInfo::getAttribute(Attributes::MAX_WEIGHT) == 0)
@@ -506,7 +506,7 @@ void StatusWindow::updateWeightBar(ProgressBar *const bar)
Attributes::TOTAL_WEIGHT);
const int maxWeight = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT);
float progress = 1.0F;
- if (maxWeight)
+ if (maxWeight != 0)
{
progress = static_cast<float>(totalWeight)
/ static_cast<float>(maxWeight);
@@ -520,7 +520,7 @@ void StatusWindow::updateWeightBar(ProgressBar *const bar)
void StatusWindow::updateMoneyBar(ProgressBar *const bar)
{
- if (!bar)
+ if (bar == nullptr)
return;
const int money = PlayerInfo::getAttribute(Attributes::MONEY);
@@ -539,13 +539,13 @@ void StatusWindow::updateMoneyBar(ProgressBar *const bar)
void StatusWindow::updateArrowsBar(ProgressBar *const bar)
{
- if (!bar || !equipmentWindow)
+ if ((bar == nullptr) || (equipmentWindow == nullptr))
return;
const Item *const item = equipmentWindow->getEquipment(
inventoryHandler->getProjectileSlot());
- if (item && item->getQuantity() > 0)
+ if ((item != nullptr) && item->getQuantity() > 0)
bar->setText(toString(item->getQuantity()));
else
bar->setText("0");
@@ -553,17 +553,17 @@ void StatusWindow::updateArrowsBar(ProgressBar *const bar)
void StatusWindow::updateInvSlotsBar(ProgressBar *const bar)
{
- if (!bar)
+ if (bar == nullptr)
return;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const int usedSlots = inv->getNumberOfSlotsUsed();
const int maxSlots = inv->getSize();
- if (maxSlots)
+ if (maxSlots != 0)
{
bar->setProgress(static_cast<float>(usedSlots)
/ static_cast<float>(maxSlots));
@@ -576,7 +576,7 @@ std::string StatusWindow::translateLetter(const char *const letters)
{
char buf[2];
char *const str = gettext(letters);
- if (!str || strlen(str) != 3)
+ if ((str == nullptr) || strlen(str) != 3)
return letters;
buf[0] = str[1];
@@ -595,7 +595,7 @@ std::string StatusWindow::translateLetter2(const std::string &letters)
void StatusWindow::updateStatusBar(ProgressBar *const bar,
const bool percent A_UNUSED) const
{
- if (!bar)
+ if (bar == nullptr)
return;
bar->setText(translateLetter2(GameModifiers::getMoveTypeString())
.append(translateLetter2(GameModifiers::getCrazyMoveTypeString()))
@@ -626,7 +626,7 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar,
void StatusWindow::action(const ActionEvent &event)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return;
if (event.getId() == "copy")
diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp
index 4adeacbc6..5c8ee1357 100644
--- a/src/gui/windows/textcommandeditor.cpp
+++ b/src/gui/windows/textcommandeditor.cpp
@@ -52,7 +52,7 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
Window(_("Command Editor"), Modal_false, nullptr, "commandeditor.xml"),
ActionListener(),
#ifdef TMWA_SUPPORT
- mIsMagicCommand(command ?
+ mIsMagicCommand(command != nullptr ?
(command->getCommandType() == TextCommandType::Magic) : false),
#endif // TMWA_SUPPORT
mCommand(command),
@@ -136,14 +136,14 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
mIconDropDown->setActionEventId("icon");
mIconDropDown->addActionListener(this);
- if (mCommand)
+ if (mCommand != nullptr)
mIconDropDown->setSelectedString(mCommand->getIcon());
mSaveButton->adjustSize();
mCancelButton->adjustSize();
mDeleteButton->adjustSize();
- if (command)
+ if (command != nullptr)
{
#ifdef TMWA_SUPPORT
if (command->getCommandType() == TextCommandType::Magic)
@@ -290,7 +290,7 @@ void TextCommandEditor::scheduleDelete()
void TextCommandEditor::save()
{
- if (!mCommand)
+ if (mCommand == nullptr)
return;
#ifdef TMWA_SUPPORT
if (mIsMagicCommand)
@@ -314,13 +314,13 @@ void TextCommandEditor::save()
mCommand->setSchoolLvl(mSchoolLvlField->getValue());
#endif // TMWA_SUPPORT
- if (spellManager)
+ if (spellManager != nullptr)
spellManager->save();
}
void TextCommandEditor::deleteCommand()
{
- if (!mCommand)
+ if (mCommand == nullptr)
return;
mCommand->setSymbol("");
mCommand->setCommand("");
@@ -335,6 +335,6 @@ void TextCommandEditor::deleteCommand()
mCommand->setSchoolLvl(0);
#endif // TMWA_SUPPORT
- if (spellManager)
+ if (spellManager != nullptr)
spellManager->save();
}
diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp
index 17e3e90e4..87c9dcfa8 100644
--- a/src/gui/windows/textdialog.cpp
+++ b/src/gui/windows/textdialog.cpp
@@ -82,16 +82,16 @@ TextDialog::TextDialog(const std::string &restrict title,
void TextDialog::postInit()
{
Window::postInit();
- if (getParent())
+ if (getParent() != nullptr)
{
setLocationRelativeTo(getParent());
getParent()->moveToTop(this);
}
setVisible(Visible_true);
requestModalFocus();
- if (mPasswordField)
+ if (mPasswordField != nullptr)
mPasswordField->requestFocus();
- else if (mTextField)
+ else if (mTextField != nullptr)
mTextField->requestFocus();
instances++;
@@ -113,18 +113,18 @@ void TextDialog::action(const ActionEvent &event)
const std::string &TextDialog::getText() const
{
- if (mTextField)
+ if (mTextField != nullptr)
return mTextField->getText();
- else if (mPasswordField)
+ else if (mPasswordField != nullptr)
return mPasswordField->getText();
return emptyStr;
}
void TextDialog::setText(const std::string &text)
{
- if (mTextField)
+ if (mTextField != nullptr)
mTextField->setText(text);
- else if (mPasswordField)
+ else if (mPasswordField != nullptr)
mPasswordField->setText(text);
}
diff --git a/src/gui/windows/textdialog.h b/src/gui/windows/textdialog.h
index dbe4c0bb6..a2901e04e 100644
--- a/src/gui/windows/textdialog.h
+++ b/src/gui/windows/textdialog.h
@@ -69,7 +69,7 @@ class TextDialog final : public Window,
void setText(const std::string &text);
static bool isActive() noexcept2 A_WARN_UNUSED
- { return instances; }
+ { return instances != 0; }
void close() override final;
diff --git a/src/gui/windows/textselectdialog.cpp b/src/gui/windows/textselectdialog.cpp
index c99e09c74..f7a5afb22 100644
--- a/src/gui/windows/textselectdialog.cpp
+++ b/src/gui/windows/textselectdialog.cpp
@@ -69,7 +69,7 @@ void TextSelectDialog::postInit()
setMinHeight(220);
setDefaultSize(260, 230, ImagePosition::CENTER);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setActionEventId("OK");
@@ -104,7 +104,7 @@ void TextSelectDialog::postInit()
placer = getPlacer(0, 0);
placer(0, 0, mScrollArea, 8, 5).setPadding(3);
- if (mQuitButton)
+ if (mQuitButton != nullptr)
{
placer(6, 5, mSelectButton);
placer(7, 5, mQuitButton);
@@ -174,7 +174,7 @@ void TextSelectDialog::setVisible(Visible visible)
if (visible == Visible_true)
{
- if (mItemList)
+ if (mItemList != nullptr)
mItemList->requestFocus();
}
else
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index de89eeca3..295f60a7d 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -107,7 +107,7 @@ TradeWindow::TradeWindow() :
setMinWidth(310);
setMinHeight(180);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
const Font *const fnt = mOkButton->getFont();
@@ -259,7 +259,7 @@ void TradeWindow::changeQuantity(const int index, const bool own,
item = mMyInventory->getItem(index);
else
item = mPartnerInventory->getItem(index);
- if (item)
+ if (item != nullptr)
item->setQuantity(quantity);
}
@@ -271,7 +271,7 @@ void TradeWindow::increaseQuantity(const int index, const bool own,
item = mMyInventory->getItem(index);
else
item = mPartnerInventory->getItem(index);
- if (item)
+ if (item != nullptr)
item->increaseQuantity(quantity);
}
@@ -324,18 +324,18 @@ void TradeWindow::tradeItem(const Item *const item, const int quantity,
void TradeWindow::valueChanged(const SelectionEvent &event)
{
- if (!mMyItemContainer || !mPartnerItemContainer)
+ if ((mMyItemContainer == nullptr) || (mPartnerItemContainer == nullptr))
return;
/* If an item is selected in one container, make sure no item is selected
* in the other container.
*/
if (event.getSource() == mMyItemContainer &&
- mMyItemContainer->getSelectedItem())
+ (mMyItemContainer->getSelectedItem() != nullptr))
{
mPartnerItemContainer->selectNone();
}
- else if (mPartnerItemContainer->getSelectedItem())
+ else if (mPartnerItemContainer->getSelectedItem() != nullptr)
{
mMyItemContainer->selectNone();
}
@@ -374,7 +374,7 @@ void TradeWindow::setStatus(const Status s)
void TradeWindow::action(const ActionEvent &event)
{
- if (!inventoryWindow)
+ if (inventoryWindow == nullptr)
return;
Item *const item = inventoryWindow->getSelectedItem();
@@ -391,7 +391,7 @@ void TradeWindow::action(const ActionEvent &event)
return;
}
- if (!item)
+ if (item == nullptr)
return;
if (mMyInventory->getFreeSlot() == -1)
@@ -437,7 +437,7 @@ void TradeWindow::action(const ActionEvent &event)
const int curMoney = PlayerInfo::getAttribute(Attributes::MONEY);
if (v > curMoney)
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: trade error
localChatTab->chatLog(_("You don't have enough money."),
@@ -485,23 +485,23 @@ void TradeWindow::addAutoMoney(const std::string &nick, const int money)
void TradeWindow::initTrade(const std::string &nick)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (!mAutoAddToNick.empty() && mAutoAddToNick == nick)
{
- if (mAutoAddItem && mAutoAddItem->getQuantity())
+ if ((mAutoAddItem != nullptr) && (mAutoAddItem->getQuantity() != 0))
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
const Item *const item = inv->findItem(mAutoAddItem->getId(),
mAutoAddItem->getColor());
- if (item)
+ if (item != nullptr)
tradeItem(item, mAutoAddAmount);
}
}
- if (mAutoMoney)
+ if (mAutoMoney != 0)
{
tradeHandler->setMoney(mAutoMoney);
mMoneyField->setText(strprintf("%d", mAutoMoney));
@@ -514,7 +514,7 @@ void TradeWindow::initTrade(const std::string &nick)
bool TradeWindow::checkItem(const Item *const item) const
{
- if (!item)
+ if (item == nullptr)
return false;
const int itemId = item->getId();
@@ -523,10 +523,10 @@ bool TradeWindow::checkItem(const Item *const item) const
const Item *const tItem = mMyInventory->findItem(
itemId, item->getColor());
- if (tItem && (tItem->getQuantity() > 1
+ if ((tItem != nullptr) && (tItem->getQuantity() > 1
|| item->getQuantity() > 1))
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: trade error
localChatTab->chatLog(_("Failed adding item. You can not "
@@ -538,7 +538,7 @@ bool TradeWindow::checkItem(const Item *const item) const
if (Net::getNetworkType() != ServerType::TMWATHENA &&
item->isEquipped() == Equipped_true)
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(
// TRANSLATORS: trade error
@@ -552,5 +552,5 @@ bool TradeWindow::checkItem(const Item *const item) const
bool TradeWindow::isInpupFocused() const
{
- return (mMoneyField && mMoneyField->isFocused());
+ return ((mMoneyField != nullptr) && mMoneyField->isFocused());
}
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index a88aba197..3c63fb2ed 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -81,7 +81,7 @@ static std::vector<UpdateFile> loadXMLFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_false, SkipError_false);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "updates"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "updates"))
{
logger->log("Error loading update file: %s", fileName.c_str());
return files;
@@ -265,7 +265,7 @@ UpdaterWindow::~UpdaterWindow()
if (mLoadUpdates)
loadUpdates();
- if (mDownload)
+ if (mDownload != nullptr)
{
mDownload->cancel();
@@ -297,7 +297,7 @@ void UpdaterWindow::enable()
if (client->getState() != State::GAME)
{
- if (mUpdateType & UpdateType::Close)
+ if ((mUpdateType & UpdateType::Close) != 0)
client->setState(State::LOAD_DATA);
}
else
@@ -316,7 +316,7 @@ void UpdaterWindow::action(const ActionEvent &event)
// Skip the updating process
if (mDownloadStatus != UpdateDownloadStatus::UPDATE_COMPLETE)
{
- if (mDownload)
+ if (mDownload != nullptr)
mDownload->cancel();
mDownloadStatus = UpdateDownloadStatus::UPDATE_ERROR;
}
@@ -359,7 +359,7 @@ void UpdaterWindow::keyPressed(KeyEvent &event)
void UpdaterWindow::loadNews()
{
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
{
logger->log1("Couldn't load news");
return;
@@ -368,7 +368,7 @@ void UpdaterWindow::loadNews()
// Reallocate and include terminating 0 character
mMemoryBuffer = static_cast<char*>(realloc(
mMemoryBuffer, mDownloadedBytes + 1));
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
{
logger->log1("Couldn't load news");
return;
@@ -392,7 +392,7 @@ void UpdaterWindow::loadNews()
{
firstLine = false;
const size_t i = line.find("##9 Latest client version: ##6");
- if (!i)
+ if (i == 0u)
continue;
if (file.is_open())
@@ -427,7 +427,7 @@ void UpdaterWindow::loadNews()
void UpdaterWindow::loadPatch()
{
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
{
logger->log1("Couldn't load patch");
return;
@@ -436,7 +436,7 @@ void UpdaterWindow::loadPatch()
// Reallocate and include terminating 0 character
mMemoryBuffer = static_cast<char*>(
realloc(mMemoryBuffer, mDownloadedBytes + 1));
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
{
logger->log1("Couldn't load patch");
return;
@@ -447,13 +447,13 @@ void UpdaterWindow::loadPatch()
// Tokenize and add each line separately
char *line = strtok(mMemoryBuffer, "\n");
- if (line)
+ if (line != nullptr)
{
version = line;
if (serverVersion < 1)
{
line = strtok(nullptr, "\n");
- if (line)
+ if (line != nullptr)
{
mBrowserBox->addRow(strprintf("##9 Latest client version: "
"##6ManaPlus %s##0", line), true);
@@ -500,7 +500,7 @@ int UpdaterWindow::updateProgress(void *ptr,
const size_t dn)
{
UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(ptr);
- if (!uw)
+ if (uw == nullptr)
return -1;
if (status == DownloadStatus::Complete)
@@ -524,7 +524,7 @@ int UpdaterWindow::updateProgress(void *ptr,
}
}
- if (!dt)
+ if (dt == 0u)
dt = 1;
float progress = static_cast<float>(dn) /
@@ -559,11 +559,11 @@ size_t UpdaterWindow::memoryWrite(void *ptr, size_t size,
{
UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(stream);
const size_t totalMem = size * nmemb;
- if (!uw)
+ if (uw == nullptr)
return 0;
uw->mMemoryBuffer = static_cast<char*>(realloc(uw->mMemoryBuffer,
CAST_SIZE(uw->mDownloadedBytes) + totalMem));
- if (uw->mMemoryBuffer)
+ if (uw->mMemoryBuffer != nullptr)
{
memcpy(&(uw->mMemoryBuffer[uw->mDownloadedBytes]), ptr, totalMem);
uw->mDownloadedBytes += CAST_S32(totalMem);
@@ -574,7 +574,7 @@ size_t UpdaterWindow::memoryWrite(void *ptr, size_t size,
void UpdaterWindow::download()
{
- if (mDownload)
+ if (mDownload != nullptr)
{
mDownload->cancel();
delete mDownload;
@@ -757,7 +757,7 @@ void UpdaterWindow::loadManaPlusUpdates(const std::string &dir)
struct stat statbuf;
std::string fileName = pathJoin(fixPath,
name);
- if (!stat(fileName.c_str(), &statbuf))
+ if (stat(fileName.c_str(), &statbuf) == 0)
{
VirtFs::mountZip(fileName,
Append_false);
@@ -784,7 +784,7 @@ void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir)
struct stat statbuf;
const std::string file = pathJoin(
fixPath, name);
- if (!stat(file.c_str(), &statbuf))
+ if (stat(file.c_str(), &statbuf) == 0)
VirtFs::unmountZip(file);
}
}
@@ -801,7 +801,7 @@ void UpdaterWindow::addUpdateFile(const std::string &restrict path,
const std::string fixFile = pathJoin(fixPath, file);
struct stat statbuf;
- if (!stat(fixFile.c_str(), &statbuf))
+ if (stat(fixFile.c_str(), &statbuf) == 0)
VirtFs::mountZip(fixFile, append);
if (append == Append_true)
@@ -815,7 +815,7 @@ void UpdaterWindow::removeUpdateFile(const std::string &restrict path,
VirtFs::unmountZip(pathJoin(path, file));
const std::string fixFile = pathJoin(fixPath, file);
struct stat statbuf;
- if (!stat(fixFile.c_str(), &statbuf))
+ if (stat(fixFile.c_str(), &statbuf) == 0)
VirtFs::unmountZip(fixFile);
}
@@ -836,7 +836,7 @@ void UpdaterWindow::logic()
}
mProgressBar->setProgress(mDownloadProgress);
- if (mUpdateFiles.size()
+ if ((mUpdateFiles.size() != 0u)
&& CAST_SIZE(mUpdateIndex) <= mUpdateFiles.size())
{
mProgressBar->setText(strprintf("%u/%u", mUpdateIndex
@@ -860,7 +860,7 @@ void UpdaterWindow::logic()
mBrowserBox->addRow(_("##1 It is strongly recommended that"));
// TRANSLATORS: Begins "It is strongly recommended that".
mBrowserBox->addRow(_("##1 you try again later."));
- if (mDownload)
+ if (mDownload != nullptr)
mBrowserBox->addRow(mDownload->getError());
mScrollArea->setVerticalScrollAmount(
mScrollArea->getVerticalMaxScroll());
@@ -1063,7 +1063,7 @@ bool UpdaterWindow::validateFile(const std::string &filePath,
const unsigned long hash)
{
FILE *const file = fopen(filePath.c_str(), "rb");
- if (!file)
+ if (file == nullptr)
return false;
const unsigned long adler = Net::Download::fadler32(file);
@@ -1144,7 +1144,7 @@ void UpdaterWindow::loadMods(const std::string &dir,
struct stat statbuf;
std::string fileName = pathJoin(fixPath,
name);
- if (!stat(fileName.c_str(), &statbuf))
+ if (stat(fileName.c_str(), &statbuf) == 0)
{
VirtFs::mountZip(fileName,
Append_false);
@@ -1171,7 +1171,7 @@ void UpdaterWindow::loadDirMods(const std::string &dir)
if (modIt == mods.end())
continue;
const ModInfo *const mod = (*modIt).second;
- if (mod)
+ if (mod != nullptr)
{
const std::string &localDir = mod->getLocalDir();
if (!localDir.empty())
@@ -1196,7 +1196,7 @@ void UpdaterWindow::unloadMods(const std::string &dir)
if (modIt == mods.end())
continue;
const ModInfo *const mod = (*modIt).second;
- if (mod)
+ if (mod != nullptr)
{
const std::string &localDir = mod->getLocalDir();
if (!localDir.empty())
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index 18e18a101..e5040077a 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -141,7 +141,7 @@ void WhoIsOnline::postInit()
setStickyButtonLock(true);
setSaveVisible(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mUpdateButton->setEnabled(false);
@@ -174,7 +174,7 @@ WhoIsOnline::~WhoIsOnline()
config.removeListeners(this);
CHECKLISTENERS
- if (mThread && SDL_GetThreadID(mThread))
+ if ((mThread != nullptr) && (SDL_GetThreadID(mThread) != 0u))
SDL_WaitThread(mThread, nullptr);
free(mMemoryBuffer);
@@ -191,9 +191,9 @@ WhoIsOnline::~WhoIsOnline()
void WhoIsOnline::handleLink(const std::string& link, MouseEvent *event)
{
- if (!event || event->getButton() == MouseButton::LEFT)
+ if ((event == nullptr) || event->getButton() == MouseButton::LEFT)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
{
const std::string text = decodeLinkText(link);
if (config.getBoolValue("whispertab"))
@@ -209,18 +209,18 @@ void WhoIsOnline::handleLink(const std::string& link, MouseEvent *event)
}
else if (event->getButton() == MouseButton::RIGHT)
{
- if (localPlayer && link == localPlayer->getName())
+ if ((localPlayer != nullptr) && link == localPlayer->getName())
return;
- if (popupMenu)
+ if (popupMenu != nullptr)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
const std::string text = decodeLinkText(link);
Being *const being = actorManager->findBeingByName(
text, ActorType::Player);
- if (being && popupManager)
+ if ((being != nullptr) && (popupManager != nullptr))
{
popupMenu->showPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -286,7 +286,7 @@ void WhoIsOnline::updateWindow(size_t numOnline)
void WhoIsOnline::handlerPlayerRelation(const std::string &nick,
OnlinePlayer *const player)
{
- if (!player)
+ if (player == nullptr)
return;
switch (player_relations.getRelation(nick))
{
@@ -350,11 +350,11 @@ void WhoIsOnline::loadList(const std::vector<OnlinePlayer*> &list)
updateWindow(numOnline);
if (!mOnlineNicks.empty())
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->updateOnline(mOnlineNicks);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateActiveList();
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->updateSeenPlayers(mOnlineNicks);
}
updateSize();
@@ -367,13 +367,13 @@ void WhoIsOnline::loadList(const std::vector<OnlinePlayer*> &list)
#ifdef TMWA_SUPPORT
void WhoIsOnline::loadWebList()
{
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
return;
// Reallocate and include terminating 0 character
mMemoryBuffer = static_cast<char*>(
realloc(mMemoryBuffer, mDownloadedBytes + 1));
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
return;
mMemoryBuffer[mDownloadedBytes] = '\0';
@@ -396,7 +396,7 @@ void WhoIsOnline::loadWebList()
mShowLevel = config.getBoolValue("showlevel");
- while (line)
+ while (line != nullptr)
{
std::string nick;
lineStr = line;
@@ -444,11 +444,11 @@ void WhoIsOnline::loadWebList()
if (!lineStr.empty())
level = atoi(lineStr.c_str());
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const being = actorManager->findBeingByName(
nick, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
if (level > 0)
{
@@ -503,7 +503,7 @@ size_t WhoIsOnline::memoryWrite(void *restrict ptr,
size_t nmemb,
FILE *restrict stream)
{
- if (!stream)
+ if (stream == nullptr)
return 0;
WhoIsOnline *restrict const wio =
@@ -511,7 +511,7 @@ size_t WhoIsOnline::memoryWrite(void *restrict ptr,
const size_t totalMem = size * nmemb;
wio->mMemoryBuffer = static_cast<char*>(realloc(wio->mMemoryBuffer,
CAST_SIZE(wio->mDownloadedBytes) + totalMem));
- if (wio->mMemoryBuffer)
+ if (wio->mMemoryBuffer != nullptr)
{
memcpy(&(wio->mMemoryBuffer[wio->mDownloadedBytes]), ptr, totalMem);
wio->mDownloadedBytes += CAST_S32(totalMem);
@@ -524,7 +524,7 @@ int WhoIsOnline::downloadThread(void *ptr)
{
int attempts = 0;
WhoIsOnline *const wio = reinterpret_cast<WhoIsOnline *>(ptr);
- if (!wio)
+ if (wio == nullptr)
return 0;
CURLcode res;
const std::string url(settings.onlineListUrl + "/online.txt");
@@ -532,7 +532,7 @@ int WhoIsOnline::downloadThread(void *ptr)
while (attempts < 1 && !wio->mDownloadComplete)
{
CURL *curl = curl_easy_init();
- if (curl)
+ if (curl != nullptr)
{
if (!wio->mAllowUpdate)
{
@@ -625,7 +625,7 @@ void WhoIsOnline::download()
else if (mWebList)
{
mDownloadComplete = true;
- if (mThread && SDL_GetThreadID(mThread))
+ if (mThread != nullptr && SDL_GetThreadID(mThread) != 0U)
SDL_WaitThread(mThread, nullptr);
mDownloadComplete = false;
@@ -674,7 +674,7 @@ void WhoIsOnline::slowLogic()
{
case UPDATE_ERROR:
logger->assertLog("Failed to fetch the online list:");
- if (mCurlError)
+ if (mCurlError != nullptr)
logger->assertLog("%s", mCurlError);
mDownloadStatus = UPDATE_COMPLETE;
// TRANSLATORS: who is online window name
@@ -694,11 +694,11 @@ void WhoIsOnline::slowLogic()
updateSize();
if (!mOnlineNicks.empty())
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->updateOnline(mOnlineNicks);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateActiveList();
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->updateSeenPlayers(mOnlineNicks);
}
}
@@ -722,11 +722,11 @@ void WhoIsOnline::action(const ActionEvent &event)
if (mDownloadStatus == UPDATE_COMPLETE)
{
mUpdateTimer = cur_time - 20;
- if (mUpdateButton)
+ if (mUpdateButton != nullptr)
mUpdateButton->setEnabled(false);
// TRANSLATORS: who is online window name
setCaption(_("Who Is Online - Update"));
- if (mThread && SDL_GetThreadID(mThread))
+ if (mThread != nullptr && SDL_GetThreadID(mThread) != 0U)
{
SDL_WaitThread(mThread, nullptr);
mThread = nullptr;
@@ -755,12 +755,12 @@ void WhoIsOnline::widgetResized(const Event &event)
void WhoIsOnline::updateSize()
{
const Rect area = getChildrenArea();
- if (mUpdateButton)
+ if (mUpdateButton != nullptr)
mUpdateButton->setWidth(area.width - 10);
- if (mScrollArea)
+ if (mScrollArea != nullptr)
mScrollArea->setSize(area.width - 10, area.height - 10 - 30);
- if (mBrowserBox)
+ if (mBrowserBox != nullptr)
mBrowserBox->setWidth(area.width - 10);
}
@@ -792,10 +792,10 @@ void WhoIsOnline::optionChanged(const std::string &name)
void WhoIsOnline::setNeutralColor(OnlinePlayer *const player)
{
- if (!player)
+ if (player == nullptr)
return;
- if (actorManager && localPlayer)
+ if ((actorManager != nullptr) && (localPlayer != nullptr))
{
const std::string &nick = player->getNick();
if (nick == localPlayer->getName())
@@ -806,9 +806,9 @@ void WhoIsOnline::setNeutralColor(OnlinePlayer *const player)
if (localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
- if (party->getMember(nick))
+ if (party->getMember(nick) != nullptr)
{
player->setText("P");
return;
@@ -817,16 +817,16 @@ void WhoIsOnline::setNeutralColor(OnlinePlayer *const player)
}
const Being *const being = actorManager->findBeingByName(nick);
- if (being)
+ if (being != nullptr)
{
const Guild *const guild2 = localPlayer->getGuild();
- if (guild2)
+ if (guild2 != nullptr)
{
const Guild *const guild1 = being->getGuild();
- if (guild1)
+ if (guild1 != nullptr)
{
if (guild1->getId() == guild2->getId()
- || guild2->getMember(nick))
+ || (guild2->getMember(nick) != nullptr))
{
player->setText("U");
return;
@@ -840,7 +840,7 @@ void WhoIsOnline::setNeutralColor(OnlinePlayer *const player)
}
}
const Guild *const guild3 = Guild::getGuild(1);
- if (guild3 && guild3->isMember(nick))
+ if ((guild3 != nullptr) && guild3->isMember(nick))
{
player->setText("U");
return;
@@ -860,11 +860,11 @@ void OnlinePlayer::setText(std::string color)
{
mText.clear();
- if (mStatus != 255 && actorManager)
+ if (mStatus != 255 && (actorManager != nullptr))
{
Being *const being = actorManager->findBeingByName(
mNick, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
being->setState(mStatus);
// for now highlight versions > 3
@@ -873,7 +873,7 @@ void OnlinePlayer::setText(std::string color)
}
}
- if ((mStatus != 255 && mStatus & BeingFlag::GM) || mIsGM)
+ if ((mStatus != 255 && ((mStatus & BeingFlag::GM) != 0)) || mIsGM)
mText.append("(GM) ");
if (mLevel > 0)
@@ -886,20 +886,20 @@ void OnlinePlayer::setText(std::string color)
if (mStatus > 0 && mStatus != 255)
{
- if (mStatus & BeingFlag::SHOP)
+ if ((mStatus & BeingFlag::SHOP) != 0)
mText.append("$");
- if (mStatus & BeingFlag::AWAY)
+ if ((mStatus & BeingFlag::AWAY) != 0)
{
// TRANSLATORS: this away status writed in player nick
mText.append(_("A"));
}
- if (mStatus & BeingFlag::INACTIVE)
+ if ((mStatus & BeingFlag::INACTIVE) != 0)
{
// TRANSLATORS: this inactive status writed in player nick
mText.append(_("I"));
}
- if (mStatus & BeingFlag::GM && color == "0")
+ if (((mStatus & BeingFlag::GM) != 0) && color == "0")
color = "2";
}
else if (mIsGM && color == "0")