diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-06-06 23:34:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-06-07 19:23:40 +0300 |
commit | 36ba43d6ea38062b17f7e63ef659962bfc51c64d (patch) | |
tree | 190156cb88b13a38a6d13c69ee0742cc078065a1 /src/gui/widgets/tabs/chat | |
parent | f1518dd8476c968a43fa57cfb06198e290a4f77a (diff) | |
download | manaplus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz manaplus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2 manaplus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz manaplus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip |
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/gui/widgets/tabs/chat')
-rw-r--r-- | src/gui/widgets/tabs/chat/channeltab.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chat/chattab.cpp | 36 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chat/emulateguildtab.cpp | 14 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chat/guildtab.cpp | 12 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chat/partytab.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chat/whispertab.cpp | 10 |
6 files changed, 44 insertions, 38 deletions
diff --git a/src/gui/widgets/tabs/chat/channeltab.cpp b/src/gui/widgets/tabs/chat/channeltab.cpp index d67de5287..37e6237a0 100644 --- a/src/gui/widgets/tabs/chat/channeltab.cpp +++ b/src/gui/widgets/tabs/chat/channeltab.cpp @@ -39,7 +39,7 @@ ChannelTab::ChannelTab(const Widget2 *const widget, ChannelTab::~ChannelTab() { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->removeChannel(mChannelName); } @@ -55,11 +55,11 @@ bool ChannelTab::handleCommand(const std::string &restrict type, { if (type == "close") { - if (windowContainer) + if (windowContainer != nullptr) windowContainer->scheduleDelete(this); else delete this; - if (chatWindow) + if (chatWindow != nullptr) chatWindow->defaultTab(); } else diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp index e59d11eb4..fc2f09350 100644 --- a/src/gui/widgets/tabs/chat/chattab.cpp +++ b/src/gui/widgets/tabs/chat/chattab.cpp @@ -84,7 +84,7 @@ ChatTab::ChatTab(const Widget2 *const widget, mTextOutput->setOpaque(Opaque_false); mTextOutput->setMaxRow(config.getIntValue("ChatLogLength")); - if (chatWindow) + if (chatWindow != nullptr) mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler); mTextOutput->setAlwaysUpdate(false); @@ -92,13 +92,13 @@ ChatTab::ChatTab(const Widget2 *const widget, ScrollArea::SHOW_ALWAYS); mScrollArea->setScrollAmount(0, 1); - if (chatWindow) + if (chatWindow != nullptr) chatWindow->addTab(this); } ChatTab::~ChatTab() { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->removeTab(this); delete2(mTextOutput); @@ -225,7 +225,7 @@ void ChatTab::chatLog(std::string line, // if configured, move magic messages log to debug chat tab if (Net::getNetworkType() == ServerType::TMWATHENA - && localChatTab && this == localChatTab + && (localChatTab != nullptr) && this == localChatTab && ((config.getBoolValue("showMagicInDebug") && own == ChatMsgType::BY_PLAYER && tmp.text.length() > 1 @@ -235,7 +235,7 @@ void ChatTab::chatLog(std::string line, && (own == ChatMsgType::BY_SERVER || tmp.nick.empty())))) { - if (debugChatTab) + if (debugChatTab != nullptr) debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors); return; } @@ -247,7 +247,7 @@ void ChatTab::chatLog(std::string line, if (config.getBoolValue("useLocalTime")) { const tm *const timeInfo = localtime(&t); - if (timeInfo) + if (timeInfo != nullptr) { line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(), timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(), @@ -292,7 +292,7 @@ void ChatTab::chatLog(std::string line, addRow(line); } - if (chatWindow && this == localChatTab) + if ((chatWindow != nullptr) && this == localChatTab) chatWindow->addToAwayLog(line); mScrollArea->logic(); @@ -307,7 +307,7 @@ void ChatTab::chatLog(std::string line, } const TabbedArea *const tabArea = getTabbedArea(); - if (!tabArea) + if (tabArea == nullptr) return; const bool notFocused = WindowManager::getIsMinimized() || @@ -317,7 +317,8 @@ void ChatTab::chatLog(std::string line, { if (getFlash() == 0) { - if (chatWindow && chatWindow->findHighlight(tmp.text)) + if (chatWindow != nullptr && + chatWindow->findHighlight(tmp.text)) { setFlash(2); soundManager.playGuiSound(SOUND_HIGHLIGHT); @@ -329,8 +330,11 @@ void ChatTab::chatLog(std::string line, } else if (getFlash() == 2) { - if (chatWindow && chatWindow->findHighlight(tmp.text)) + if (chatWindow != nullptr && + chatWindow->findHighlight(tmp.text)) + { soundManager.playGuiSound(SOUND_HIGHLIGHT); + } } } @@ -341,13 +345,13 @@ void ChatTab::chatLog(std::string line, { if (own == ChatMsgType::BY_GM) { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->unHideWindow(); soundManager.playGuiSound(SOUND_GLOBAL); } else if (own != ChatMsgType::BY_SERVER) { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->unHideWindow(); playNewMessageSound(); } @@ -358,7 +362,7 @@ void ChatTab::chatLog(std::string line, void ChatTab::chatLog(const std::string &nick, std::string msg) { - if (!localPlayer) + if (localPlayer == nullptr) return; const ChatMsgTypeT byWho = (nick == localPlayer->getName() @@ -441,7 +445,7 @@ void ChatTab::handleCommandStr(const std::string &msg) void ChatTab::handleHelp(const std::string &msg) { - if (helpWindow) + if (helpWindow != nullptr) { helpWindow->search(msg); helpWindow->requestMoveToTop(); @@ -457,7 +461,7 @@ bool ChatTab::handleCommands(const std::string &type, const std::string &args) void ChatTab::saveToLogFile(const std::string &msg) const { - if (chatLogger) + if (chatLogger != nullptr) { if (getType() == ChatTabType::INPUT) { @@ -498,7 +502,7 @@ void ChatTab::addRow(std::string &line) void ChatTab::loadFromLogFile(const std::string &name) { - if (chatLogger) + if (chatLogger != nullptr) { std::list<std::string> list; chatLogger->loadLast(name, list, 5); diff --git a/src/gui/widgets/tabs/chat/emulateguildtab.cpp b/src/gui/widgets/tabs/chat/emulateguildtab.cpp index 4c4401242..4374f6b2c 100644 --- a/src/gui/widgets/tabs/chat/emulateguildtab.cpp +++ b/src/gui/widgets/tabs/chat/emulateguildtab.cpp @@ -56,13 +56,15 @@ EmulateGuildTab::~EmulateGuildTab() bool EmulateGuildTab::handleCommand(const std::string &restrict type, const std::string &restrict args) { - if (type == "invite" && guildManager) + if (guildManager == nullptr) + return false; + if (type == "invite") guildManager->invite(args); - else if (type == "leave" && guildManager) + else if (type == "leave") guildManager->leave(); - else if (type == "kick" && guildManager) + else if (type == "kick") guildManager->kick(args); - else if (type == "notice" && guildManager) + else if (type == "notice") guildManager->notice(args); else return false; @@ -72,14 +74,14 @@ bool EmulateGuildTab::handleCommand(const std::string &restrict type, void EmulateGuildTab::handleInput(const std::string &msg) { - if (!guildManager) + if (guildManager == nullptr) return; guildManager->chat(ChatWindow::doReplace(msg)); } void EmulateGuildTab::getAutoCompleteList(StringVect &names) const { - if (!guildManager) + if (guildManager == nullptr) return; guildManager->getNames(names); diff --git a/src/gui/widgets/tabs/chat/guildtab.cpp b/src/gui/widgets/tabs/chat/guildtab.cpp index 982c27da5..51416b8ef 100644 --- a/src/gui/widgets/tabs/chat/guildtab.cpp +++ b/src/gui/widgets/tabs/chat/guildtab.cpp @@ -60,23 +60,23 @@ GuildTab::~GuildTab() bool GuildTab::handleCommand(const std::string &restrict type, const std::string &restrict args) { - if (type == "invite" && EAthena::taGuild) + if (type == "invite" && (EAthena::taGuild != nullptr)) { guildHandler->invite(args); } - else if (type == "leave" && EAthena::taGuild) + else if (type == "leave" && (EAthena::taGuild != nullptr)) { inputManager.executeChatCommand(InputAction::LEAVE_GUILD, std::string(), this); } - else if (type == "kick" && EAthena::taGuild) + else if (type == "kick" && (EAthena::taGuild != nullptr)) { inputManager.executeChatCommand(InputAction::KICK_GUILD, args, this); } - else if (type == "notice" && EAthena::taGuild) + else if (type == "notice" && (EAthena::taGuild != nullptr)) { inputManager.executeChatCommand(InputAction::GUILD_NOTICE, args, @@ -92,7 +92,7 @@ bool GuildTab::handleCommand(const std::string &restrict type, void GuildTab::handleInput(const std::string &msg) { - if (!EAthena::taGuild) + if (EAthena::taGuild == nullptr) return; guildHandler->chat(ChatWindow::doReplace(msg)); @@ -100,7 +100,7 @@ void GuildTab::handleInput(const std::string &msg) void GuildTab::getAutoCompleteList(StringVect &names) const { - if (EAthena::taGuild) + if (EAthena::taGuild != nullptr) EAthena::taGuild->getNames(names); } diff --git a/src/gui/widgets/tabs/chat/partytab.cpp b/src/gui/widgets/tabs/chat/partytab.cpp index 366a78241..befbb0393 100644 --- a/src/gui/widgets/tabs/chat/partytab.cpp +++ b/src/gui/widgets/tabs/chat/partytab.cpp @@ -118,12 +118,12 @@ bool PartyTab::handleCommand(const std::string &restrict type, void PartyTab::getAutoCompleteList(StringVect &names) const { - if (!localPlayer) + if (localPlayer == nullptr) return; const Party *const p = localPlayer->getParty(); - if (p) + if (p != nullptr) p->getNames(names); } diff --git a/src/gui/widgets/tabs/chat/whispertab.cpp b/src/gui/widgets/tabs/chat/whispertab.cpp index 1cbf471c7..d8672b22d 100644 --- a/src/gui/widgets/tabs/chat/whispertab.cpp +++ b/src/gui/widgets/tabs/chat/whispertab.cpp @@ -45,7 +45,7 @@ WhisperTab::WhisperTab(const Widget2 *const widget, WhisperTab::~WhisperTab() { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->removeWhisper(mNick); } @@ -55,7 +55,7 @@ void WhisperTab::handleInput(const std::string &msg) newMsg = ChatWindow::doReplace(msg); chatHandler->privateMessage(mNick, newMsg); - if (localPlayer) + if (localPlayer != nullptr) chatLog(localPlayer->getName(), newMsg); else chatLog("?", newMsg); @@ -78,7 +78,7 @@ void WhisperTab::handleCommandStr(const std::string &msg) { std::string str = textToMe(args); chatHandler->privateMessage(mNick, str); - if (localPlayer) + if (localPlayer != nullptr) chatLog(localPlayer->getName(), str); else chatLog("?", str); @@ -94,11 +94,11 @@ bool WhisperTab::handleCommand(const std::string &restrict type, { if (type == "close") { - if (windowContainer) + if (windowContainer != nullptr) windowContainer->scheduleDelete(this); else delete this; - if (chatWindow) + if (chatWindow != nullptr) chatWindow->defaultTab(); } else |