summaryrefslogtreecommitdiff
path: root/src/gui/windows
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/windows
parentf1518dd8476c968a43fa57cfb06198e290a4f77a (diff)
downloadmv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/gui/windows')
-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
51 files changed, 887 insertions, 852 deletions
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")