From 05e753294c1a603252d2eed4b1731c3f50543a7e Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 27 Mar 2009 12:35:09 +0100 Subject: Fixed some compiler warnings Fixed a faulty == statement that should have been an assignment and a mismatched 'else' block. --- src/gui/chat.cpp | 47 +++++++++++++++++++++--------------------- src/gui/chat.h | 2 +- src/gui/widgets/whispertab.cpp | 5 +++-- src/gui/widgets/whispertab.h | 11 +++++----- src/net/ea/chathandler.cpp | 9 ++++---- 5 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 8baf702e..7861bdb6 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -19,24 +19,25 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "chat.h" -#include "chatinput.h" -#include "itemlinkhandler.h" -#include "recorder.h" -#include "scrollarea.h" -#include "sdlinput.h" -#include "widgets/tabbedarea.h" -#include "widgets/whispertab.h" +#include "gui/chatinput.h" +#include "gui/itemlinkhandler.h" +#include "gui/recorder.h" +#include "gui/scrollarea.h" +#include "gui/sdlinput.h" -#include "../beingmanager.h" -#include "../configuration.h" -#include "../localplayer.h" +#include "gui/widgets/tabbedarea.h" +#include "gui/widgets/whispertab.h" -#include "../utils/dtor.h" -#include "../utils/stringutils.h" +#include "beingmanager.h" +#include "configuration.h" +#include "localplayer.h" + +#include "utils/dtor.h" +#include "utils/stringutils.h" + +#include #ifdef TMWSERV_SUPPORT ChatWindow::ChatWindow(): @@ -140,20 +141,21 @@ void ChatWindow::logic() Window::logic(); Tab *tab = getFocused(); - if (tab != currentTab) { - currentTab == tab; + if (tab != mCurrentTab) { + mCurrentTab = tab; adjustTabSize(); } } -ChatTab* ChatWindow::getFocused() const +ChatTab *ChatWindow::getFocused() const { return dynamic_cast(mChatTabs->getSelectedTab()); } -void ChatWindow::clearTab(ChatTab* tab) +void ChatWindow::clearTab(ChatTab *tab) { - if (tab) tab->clearText(); + if (tab) + tab->clearText(); } void ChatWindow::clearTab() @@ -373,11 +375,8 @@ void ChatWindow::whisper(std::string nick, std::string mes, bool own) toLower(playerName); toLower(tempNick); - if (tempNick.compare(playerName) == 0) - if (own) - ; - else - return; + if (!own && tempNick.compare(playerName) == 0) + return; ChatTab *tab = mWhispers[tempNick]; diff --git a/src/gui/chat.h b/src/gui/chat.h index 736f9284..7c080960 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -213,7 +213,7 @@ class ChatWindow : public Window, /** Tabbed area for holding each channel. */ TabbedArea *mChatTabs; - Tab *currentTab; + Tab *mCurrentTab; typedef std::map TabMap; /** Manage whisper tabs */ diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index b67b74f8..ba469c00 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -47,8 +47,9 @@ #include "../../utils/strprintf.h" #include "../../utils/stringutils.h" -WhisperTab::WhisperTab(std::string nick) : ChatTab(nick), - mNick(nick) +WhisperTab::WhisperTab(const std::string &nick) : + ChatTab(nick), + mNick(nick) { } diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h index 059346fa..e3ebf0f3 100644 --- a/src/gui/widgets/whispertab.h +++ b/src/gui/widgets/whispertab.h @@ -27,24 +27,23 @@ class Channel; /** - * A tab for whispers from a single nick. + * A tab for whispers from a single player. */ class WhisperTab : public ChatTab { public: - std::string getNick() { return mNick; } + const std::string &getNick() const { return mNick; } protected: friend class ChatWindow; /** * Constructor. + * + * @param nick the name of the player this tab is whispering to */ - WhisperTab(std::string nick); + WhisperTab(const std::string &nick); - /** - * Destructor. - */ ~WhisperTab(); void sendChat(std::string &msg); diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 2e7be21f..14432b28 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -35,7 +35,6 @@ #include "utils/gettext.h" #include "utils/stringutils.h" -#include #include extern Being *player_node; @@ -93,10 +92,14 @@ void ChatHandler::handleMessage(MessageIn &msg) chatMsg = msg.readString(chatMsgLength); if (nick != SERVER_NAME) + { if (player_relations.hasPermission(nick, PlayerRelation::WHISPER)) chatWindow->whisper(nick, chatMsg); + } else + { localChatTab->chatLog(chatMsg, BY_SERVER); + } break; @@ -106,9 +109,7 @@ void ChatHandler::handleMessage(MessageIn &msg) being = beingManager->findBeing(msg.readInt32()); if (!being || chatMsgLength <= 0) - { break; - } chatMsg = msg.readString(chatMsgLength); @@ -135,9 +136,7 @@ void ChatHandler::handleMessage(MessageIn &msg) chatMsgLength = msg.readInt16() - 4; if (chatMsgLength <= 0) - { break; - } chatMsg = msg.readString(chatMsgLength); std::string::size_type pos = chatMsg.find(" : ", 0); -- cgit v1.2.3-60-g2f50