summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-08-03 11:43:34 -0600
committerJared Adams <jaxad0127@gmail.com>2010-08-03 11:43:34 -0600
commit94f91a5fd9f3f609e93224fe71d2a3bcce1c0866 (patch)
tree3541e3e91bca871cfa5e4cf395d35957d8f7c5cf /src/net
parent71ea8233334803a079ad24396ead02280a80d8d4 (diff)
parent98abc793f8fb45d647e1e8c51cf5f38170c6b703 (diff)
downloadmana-client-94f91a5fd9f3f609e93224fe71d2a3bcce1c0866.tar.gz
mana-client-94f91a5fd9f3f609e93224fe71d2a3bcce1c0866.tar.bz2
mana-client-94f91a5fd9f3f609e93224fe71d2a3bcce1c0866.tar.xz
mana-client-94f91a5fd9f3f609e93224fe71d2a3bcce1c0866.zip
Merge remote branch 'origin/1.0'
Conflicts: src/net/tmwa/chathandler.cpp
Diffstat (limited to 'src/net')
-rw-r--r--src/net/tmwa/chathandler.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index 68c6dece..55259624 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -129,7 +129,8 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
break;
// Received speech from being
- case SMSG_BEING_CHAT: {
+ case SMSG_BEING_CHAT:
+ {
chatMsgLength = msg.readInt16() - 8;
int beingId = msg.readInt32();
being = actorSpriteManager->findBeing(beingId);
@@ -141,8 +142,23 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
std::string::size_type pos = chatMsg.find(" : ", 0);
std::string sender_name = ((pos == std::string::npos)
- ? ""
- : chatMsg.substr(0, pos));
+ ? "" : chatMsg.substr(0, pos));
+
+ if (sender_name != being->getName()
+ && being->getType() == Being::PLAYER)
+ {
+ if (!being->getName().empty())
+ sender_name = being->getName();
+ }
+ else
+ {
+ chatMsg.erase(0, pos + 3);
+ }
+
+ trim(chatMsg);
+
+ std::string reducedMessage = chatMsg;
+ chatMsg = removeColors(sender_name) + " : " + reducedMessage;
// We use getIgnorePlayer instead of ignoringPlayer here because ignorePlayer' side
// effects are triggered right below for Being::IGNORE_SPEECH_FLOAT.
@@ -150,21 +166,23 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
{
Mana::Event event("Being");
event.setString("message", chatMsg);
+ event.setString("text", reducedMessage);
event.setString("nick", sender_name);
event.setInt("beingId", beingId);
Mana::EventManager::trigger("Chat", event);
}
- chatMsg.erase(0, pos + 3);
- trim(chatMsg);
-
- if (player_relations.hasPermission(sender_name, PlayerRelation::SPEECH_FLOAT))
+ 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)