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 | |
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. :)
-rw-r--r-- | src/being.cpp | 8 | ||||
-rw-r--r-- | src/game.cpp | 4 | ||||
-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 | ||||
-rw-r--r-- | src/net/partyhandler.cpp | 2 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 2 | ||||
-rw-r--r-- | src/simpleanimation.cpp | 2 | ||||
-rw-r--r-- | src/sound.cpp | 8 |
15 files changed, 33 insertions, 47 deletions
diff --git a/src/being.cpp b/src/being.cpp index 1acbdb50..7a7f3df7 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -344,8 +344,8 @@ void Being::setDirection(Uint8 direction) for (int i = 0; i < VECTOREND_SPRITE; i++) { - if (mSprites[i] != NULL) - mSprites[i]->setDirection(dir); + if (mSprites[i]) + mSprites[i]->setDirection(dir); } } @@ -446,7 +446,7 @@ void Being::logic() for (int i = 0; i < VECTOREND_SPRITE; i++) { - if (mSprites[i] != NULL) + if (mSprites[i]) mSprites[i]->update(tick_time * 10); } @@ -468,7 +468,7 @@ void Being::draw(Graphics *graphics, int offsetX, int offsetY) const for (int i = 0; i < VECTOREND_SPRITE; i++) { - if (mSprites[i] != NULL) + if (mSprites[i]) { mSprites[i]->draw(graphics, px, py); } diff --git a/src/game.cpp b/src/game.cpp index 99888c73..9552c2ef 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -516,8 +516,8 @@ void Game::handleInput() { // Input chat window if (!(chatWindow->isInputFocused() || - deathNotice != NULL || - weightNotice != NULL)) + deathNotice || + weightNotice)) { // Quit by pressing Enter if the exit confirm is there if (exitConfirm && 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); } diff --git a/src/net/partyhandler.cpp b/src/net/partyhandler.cpp index 3378a5d0..b65ff2c9 100644 --- a/src/net/partyhandler.cpp +++ b/src/net/partyhandler.cpp @@ -69,7 +69,7 @@ void PartyHandler::handleMessage(MessageIn *msg) { int id = msg->readInt32(); Being *being = beingManager->findBeing(id); - if (being == NULL) + if (!being) { break; } diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index fcd9495f..d6ab39a0 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -160,7 +160,7 @@ void ResourceManager::searchAndAddArchives(const std::string &path, const char *dirSep = PHYSFS_getDirSeparator(); char **list = PHYSFS_enumerateFiles(path.c_str()); - for (char **i = list; *i != NULL; i++) + for (char **i = list; *i; i++) { size_t len = strlen(*i); diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 09e8e0d3..ab50674b 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -51,7 +51,7 @@ SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode): // Get animation frames for ( xmlNodePtr frameNode = animationNode->xmlChildrenNode; - frameNode != NULL; + frameNode; frameNode = frameNode->next) { int delay = XML::getProperty(frameNode, "delay", 0); diff --git a/src/sound.cpp b/src/sound.cpp index 083ffb6a..5b8dedef 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -129,7 +129,7 @@ void Sound::playMusic(const std::string &filename, int loop) { if (!mInstalled) return; - if (mMusic != NULL) { + if (mMusic) { stopMusic(); } @@ -155,7 +155,7 @@ void Sound::stopMusic() logger->log("Sound::stopMusic()"); - if (mMusic != NULL) { + if (mMusic) { Mix_HaltMusic(); Mix_FreeMusic(mMusic); mMusic = NULL; @@ -166,7 +166,7 @@ void Sound::fadeInMusic(const std::string &path, int loop, int ms) { if (!mInstalled) return; - if (mMusic != NULL) { + if (mMusic) { stopMusic(); } @@ -189,7 +189,7 @@ void Sound::fadeOutMusic(int ms) logger->log("Sound::fadeOutMusic() Fading-out (%i ms)", ms); - if (mMusic != NULL) { + if (mMusic) { Mix_FadeOutMusic(ms); Mix_FreeMusic(mMusic); mMusic = NULL; |