summaryrefslogtreecommitdiff
path: root/src/net/chathandler.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-05-14 18:57:32 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-05-14 18:57:32 +0000
commit2d648c5dc29a1ceae154194c23c799c7076894b4 (patch)
treef6c31a30260b80713257be211b139263b3291098 /src/net/chathandler.cpp
parent41906acb990895831e3b2c39102f41c9b580ae10 (diff)
downloadmana-2d648c5dc29a1ceae154194c23c799c7076894b4.tar.gz
mana-2d648c5dc29a1ceae154194c23c799c7076894b4.tar.bz2
mana-2d648c5dc29a1ceae154194c23c799c7076894b4.tar.xz
mana-2d648c5dc29a1ceae154194c23c799c7076894b4.zip
Added ability to define friends, players you want to ignore or disregard and
configure whether trading is allowed. Based on new popup code, configuration improvements to store hierarchical data and a table model.
Diffstat (limited to 'src/net/chathandler.cpp')
-rw-r--r--src/net/chathandler.cpp43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/net/chathandler.cpp b/src/net/chathandler.cpp
index d2e1361e..524911d3 100644
--- a/src/net/chathandler.cpp
+++ b/src/net/chathandler.cpp
@@ -32,6 +32,7 @@
#include "../being.h"
#include "../beingmanager.h"
#include "../game.h"
+#include "../player_relations.h"
#include "../gui/chat.h"
@@ -40,6 +41,8 @@
extern Being *player_node;
+#define SERVER_NAME "Server"
+
ChatHandler::ChatHandler()
{
static const Uint16 _messages[] = {
@@ -89,14 +92,20 @@ void ChatHandler::handleMessage(MessageIn *msg)
break;
chatMsg = msg->readString(chatMsgLength);
- if (nick != "Server")
+ if (nick != SERVER_NAME)
chatMsg = nick + " : " + chatMsg;
- chatWindow->chatLog(chatMsg, (nick == "Server") ? BY_SERVER : ACT_WHISPER);
+
+ if (nick == SERVER_NAME)
+ chatWindow->chatLog(chatMsg, BY_SERVER);
+ else {
+ if (player_relations.hasPermission(nick, PlayerRelation::WHISPER))
+ chatWindow->chatLog(chatMsg, ACT_WHISPER);
+ }
break;
// Received speech from being
- case SMSG_BEING_CHAT:
+ case SMSG_BEING_CHAT: {
chatMsgLength = msg->readInt16() - 8;
being = beingManager->findBeing(msg->readInt32());
@@ -106,14 +115,27 @@ void ChatHandler::handleMessage(MessageIn *msg)
}
chatMsg = msg->readString(chatMsgLength);
- chatWindow->chatLog(chatMsg, BY_OTHER);
- chatMsg.erase(0, chatMsg.find(" : ", 0) + 3);
+
+ std::string::size_type pos = chatMsg.find(" : ", 0);
+ std::string sender_name = ((pos == std::string::npos)
+ ? ""
+ : chatMsg.substr(0, pos));
+
+ // We use getIgnorePlayer instead of ignoringPlayer here because ignorePlayer' side
+ // effects are triggered right below for Being::IGNORE_SPEECH_FLOAT.
+ if (player_relations.checkPermissionSilently(sender_name, PlayerRelation::SPEECH_LOG))
+ chatWindow->chatLog(chatMsg, BY_OTHER);
+
+ chatMsg.erase(0, pos + 3);
trim(chatMsg);
- being->setSpeech(chatMsg, SPEECH_TIME);
+
+ if (player_relations.hasPermission(sender_name, PlayerRelation::SPEECH_FLOAT))
+ being->setSpeech(chatMsg, SPEECH_TIME);
break;
+ }
case SMSG_PLAYER_CHAT:
- case SMSG_GM_CHAT:
+ case SMSG_GM_CHAT: {
chatMsgLength = msg->readInt16() - 4;
if (chatMsgLength <= 0)
@@ -122,17 +144,17 @@ void ChatHandler::handleMessage(MessageIn *msg)
}
chatMsg = msg->readString(chatMsgLength);
+ std::string::size_type pos = chatMsg.find(" : ", 0);
if (msg->getId() == SMSG_PLAYER_CHAT)
{
chatWindow->chatLog(chatMsg, BY_PLAYER);
- std::string::size_type pos = chatMsg.find(" : ", 0);
if (pos != std::string::npos)
- {
chatMsg.erase(0, pos + 3);
- }
+
trim(chatMsg);
+
player_node->setSpeech(chatMsg, SPEECH_TIME);
}
else
@@ -140,6 +162,7 @@ void ChatHandler::handleMessage(MessageIn *msg)
chatWindow->chatLog(chatMsg, BY_GM);
}
break;
+ }
case SMSG_WHO_ANSWER:
chatWindow->chatLog("Online users: " + toString(msg->readInt32()),