From 7380aa6e86b51ef62530bea5d6f6f63244dffc4a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 8 Feb 2016 23:18:03 +0300 Subject: Add some missing checks and remove useless checks. --- src/gui/windows/shopwindow.cpp | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'src/gui/windows/shopwindow.cpp') diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 7c75c4f92..cf57312dd 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -270,10 +270,10 @@ void ShopWindow::action(const ActionEvent &event) { if (isBuySelected) { - if (mBuyShopItems && mBuyShopItems->getNumberOfElements() > 0) + if (mBuyShopItems->getNumberOfElements() > 0) announce(mBuyShopItems, BUY); } - else if (mSellShopItems && mSellShopItems->getNumberOfElements() > 0) + else if (mSellShopItems->getNumberOfElements() > 0) { announce(mSellShopItems, SELL); } @@ -493,7 +493,7 @@ void ShopWindow::setVisible(Visible visible) void ShopWindow::addBuyItem(const Item *const item, const int amount, const int price) { - if (!mBuyShopItems || !item) + if (!item) return; const bool emp = isShopEmpty(); mBuyShopItems->addItemNoDup(item->getId(), @@ -510,7 +510,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 (!mBuyShopItems || !item) + if (!item) return; const bool emp = isShopEmpty(); mSellShopItems->addItemNoDup(item->getId(), @@ -526,9 +526,6 @@ void ShopWindow::addSellItem(const Item *const item, const int amount, void ShopWindow::loadList() { - if (!mBuyShopItems || !mSellShopItems) - return; - std::ifstream shopFile; struct stat statbuf; @@ -562,12 +559,12 @@ void ShopWindow::loadList() if (tokens.size() == 5 && tokens[0]) { // +++ need impliment colors? - if (tokens[1] && tokens[2] && mBuyShopItems) + if (tokens[1] && tokens[2]) { mBuyShopItems->addItem( tokens[0], 0, ItemColor_one, tokens[1], tokens[2]); } - if (tokens[3] && tokens[4] && mSellShopItems) + if (tokens[3] && tokens[4]) { mSellShopItems->addItem( tokens[0], 0, ItemColor_one, tokens[3], tokens[4]); @@ -581,9 +578,6 @@ void ShopWindow::loadList() void ShopWindow::saveList() const { - if (!mBuyShopItems || !mSellShopItems) - return; - std::ofstream shopFile; const std::string shopListName = settings.serverConfigDir + "/shoplist.txt"; @@ -1045,17 +1039,9 @@ bool ShopWindow::findShopItem(const ShopItem *const shopItem, std::vector items; if (mode == SELL) - { - if (!mSellShopItems) - return false; items = mSellShopItems->items(); - } else - { - if (!mBuyShopItems) - return false; items = mBuyShopItems->items(); - } FOR_EACH (std::vector::const_iterator, it, items) { @@ -1095,8 +1081,6 @@ int ShopWindow::sumAmount(const Item *const shopItem) bool ShopWindow::isShopEmpty() const { - if (!mBuyShopItems || !mSellShopItems) - return true; if (mBuyShopItems->empty() && mSellShopItems->empty()) return true; return false; -- cgit v1.2.3-70-g09d2