diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-11 00:01:36 +0100 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-02-10 20:19:45 -0700 |
commit | d99b00a149e7828adb3c4651069483e51b0b458b (patch) | |
tree | 33f07f9d18dd006d10b14ff2dffbcbe337809d0c /src/gui | |
parent | d268447e18c6e3edd80658f8f8d4317740c33af9 (diff) | |
download | mana-d99b00a149e7828adb3c4651069483e51b0b458b.tar.gz mana-d99b00a149e7828adb3c4651069483e51b0b458b.tar.bz2 mana-d99b00a149e7828adb3c4651069483e51b0b458b.tar.xz mana-d99b00a149e7828adb3c4651069483e51b0b458b.zip |
Removed many pointless comparisons with NULL
Sometimes it's nice for clarity, but most of the time this is just
clutter. C++ != Java. :)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/focushandler.cpp | 2 | ||||
-rw-r--r-- | src/gui/playerbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 34 | ||||
-rw-r--r-- | src/gui/radiobutton.cpp | 2 | ||||
-rw-r--r-- | src/gui/scrollarea.cpp | 2 | ||||
-rw-r--r-- | src/gui/table.cpp | 4 | ||||
-rw-r--r-- | src/gui/truetypefont.cpp | 2 | ||||
-rw-r--r-- | src/gui/updatewindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/tabbedarea.cpp | 2 |
9 files changed, 20 insertions, 34 deletions
diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index cb52ae9f..c642127d 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -27,7 +27,7 @@ void FocusHandler::requestModalFocus(gcn::Widget *widget) /* If there is another widget with modal focus, remove its modal focus * and put it on the modal widget stack. */ - if (mModalFocusedWidget != NULL && mModalFocusedWidget != widget) + if (mModalFocusedWidget && mModalFocusedWidget != widget) { mModalStack.push_front(mModalFocusedWidget); mModalFocusedWidget = NULL; diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index e05288cc..e7ee3afe 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -88,7 +88,7 @@ void PlayerBox::draw(gcn::Graphics *graphics) y = getHeight() / 2 + bs; for (int i = 0; i < Being::VECTOREND_SPRITE; i++) { - if (mPlayer->getSprite(i) != NULL) + if (mPlayer->getSprite(i)) { mPlayer->getSprite(i)->draw(static_cast<Graphics*>(graphics), x, y); } diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index d10faa0d..7f82d1b5 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -145,55 +145,42 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem) void PopupMenu::handleLink(const std::string& link) { // Talk To action - if (link == "talk" && - mBeing != NULL && - mBeing->getType() == Being::NPC && + if (link == "talk" && mBeing && mBeing->getType() == Being::NPC && current_npc == 0) { dynamic_cast<NPC*>(mBeing)->talk(); } // Trade action - else if (link == "trade" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + else if (link == "trade" && mBeing && mBeing->getType() == Being::PLAYER) { player_node->trade(mBeing); tradePartnerName = mBeing->getName(); } // Attack action - else if (link == "attack" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + else if (link == "attack" && mBeing && mBeing->getType() == Being::PLAYER) { player_node->attack(mBeing, true); } - else if (link == "unignore" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + else if (link == "unignore" && mBeing && mBeing->getType() == Being::PLAYER) { player_relations.setRelation(mBeing->getName(), PlayerRelation::NEUTRAL); } - else if (link == "ignore" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + else if (link == "ignore" && mBeing && mBeing->getType() == Being::PLAYER) { player_relations.setRelation(mBeing->getName(), PlayerRelation::IGNORED); } - else if (link == "disregard" && - mBeing != NULL && + else if (link == "disregard" && mBeing && mBeing->getType() == Being::PLAYER) { player_relations.setRelation(mBeing->getName(), PlayerRelation::DISREGARDED); } - else if (link == "friend" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + else if (link == "friend" && mBeing && mBeing->getType() == Being::PLAYER) { player_relations.setRelation(mBeing->getName(), PlayerRelation::FRIEND); } @@ -206,7 +193,7 @@ void PopupMenu::handleLink(const std::string& link) /* // Add Buddy action - else if ((link == "buddy") && mBeing != NULL && mBeing->isPlayer()) + else if ((link == "buddy") && mBeing && mBeing->isPlayer()) { if (!buddyWindow->isVisible()) buddyWindow->setVisible(true); @@ -215,7 +202,7 @@ void PopupMenu::handleLink(const std::string& link) }*/ // Pick Up Floor Item action - else if ((link == "pickup") && mFloorItem != NULL) + else if ((link == "pickup") && mFloorItem) { player_node->pickUp(mFloorItem); } @@ -254,8 +241,7 @@ void PopupMenu::handleLink(const std::string& link) { new ItemAmountWindow(AMOUNT_ITEM_DROP, inventoryWindow, mItem); } - else if (link == "party-invite" && - mBeing != NULL && + else if (link == "party-invite" && mBeing && mBeing->getType() == Being::PLAYER) { MessageOut outMsg(player_node->getNetwork()); diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp index 2e48f78a..a8ab61c4 100644 --- a/src/gui/radiobutton.cpp +++ b/src/gui/radiobutton.cpp @@ -93,7 +93,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics) else box = radioDisabled; - if (box != NULL) + if (box) static_cast<Graphics*>(graphics)->drawImage(box, 2, 2); } diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index 4c225e81..d655ad52 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -154,7 +154,7 @@ void ScrollArea::logic() // When no scrollbar in a certain direction, adapt content size to match // the content dimension exactly. - if (content != NULL) + if (content) { if (getHorizontalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER) { diff --git a/src/gui/table.cpp b/src/gui/table.cpp index 425c5b6f..b79d43cf 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -186,7 +186,7 @@ int GuiTable::getColumnWidth(int i) void GuiTable::setSelectedRow(int selected) { - if (mModel == NULL) + if (!mModel) { mSelectedRow = -1; } @@ -214,7 +214,7 @@ void GuiTable::setSelectedRow(int selected) void GuiTable::setSelectedColumn(int selected) { - if (mModel == NULL) + if (!mModel) { mSelectedColumn = -1; } diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp index a92e0dab..24c60caf 100644 --- a/src/gui/truetypefont.cpp +++ b/src/gui/truetypefont.cpp @@ -89,7 +89,7 @@ TrueTypeFont::TrueTypeFont(const std::string& filename, int size) ++fontCounter; mFont = TTF_OpenFont(filename.c_str(), size); - if (mFont == NULL) + if (!mFont) { throw GCN_EXCEPTION("SDLTrueTypeFont::SDLTrueTypeFont: " + std::string(TTF_GetError())); diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 29e7e763..5a6f3f28 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -206,7 +206,7 @@ void UpdaterWindow::loadNews() // Tokenize and add each line separately char *line = strtok(mMemoryBuffer, "\n"); - while (line != NULL) + while (line) { mBrowserBox->addRow(line); line = strtok(NULL, "\n"); @@ -409,7 +409,7 @@ void UpdaterWindow::download() mDownloadComplete = false; mThread = SDL_CreateThread(UpdaterWindow::downloadThread, this); - if (mThread == NULL) + if (!mThread) { logger->log(_("Unable to create mThread")); mDownloadStatus = UPDATE_ERROR; diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index f0d719c6..aaa3463f 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -91,7 +91,7 @@ void TabbedArea::addTab(Tab *tab, gcn::Widget *widget) mTabContainer->add(tab); mTabs.push_back(std::pair<Tab*, gcn::Widget*>(tab, widget)); - if (mSelectedTab == NULL) + if (!mSelectedTab) { setSelectedTab(tab); } |