summaryrefslogtreecommitdiff
path: root/src/net/tmwa/chatrecv.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-01 17:20:43 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-01 17:20:43 +0300
commit478aa714cef69dd526c74196d0cfa484ccc5f420 (patch)
tree381222bdf96949310bd7334ae6bc18595118a896 /src/net/tmwa/chatrecv.cpp
parent75669b2822ef0d764d204b019e0b692fa2e64390 (diff)
downloadmv-478aa714cef69dd526c74196d0cfa484ccc5f420.tar.gz
mv-478aa714cef69dd526c74196d0cfa484ccc5f420.tar.bz2
mv-478aa714cef69dd526c74196d0cfa484ccc5f420.tar.xz
mv-478aa714cef69dd526c74196d0cfa484ccc5f420.zip
Show chat messages in public chat from hidden gms. (tmwa)
Diffstat (limited to 'src/net/tmwa/chatrecv.cpp')
-rw-r--r--src/net/tmwa/chatrecv.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/net/tmwa/chatrecv.cpp b/src/net/tmwa/chatrecv.cpp
index d4543dd9c..afa8c1573 100644
--- a/src/net/tmwa/chatrecv.cpp
+++ b/src/net/tmwa/chatrecv.cpp
@@ -290,12 +290,8 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
BLOCK_START("ChatRecv::processBeingChat")
int chatMsgLength = msg.readInt16("len") - 8;
- Being *const being = actorManager->findBeing(msg.readBeingId("being id"));
- if (!being)
- {
- BLOCK_END("ChatRecv::processBeingChat")
- return;
- }
+ const BeingId beingId = msg.readBeingId("being id");
+ Being *const being = actorManager->findBeing(beingId);
if (chatMsgLength <= 0)
{
@@ -305,7 +301,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
std::string chatMsg = msg.readRawString(chatMsgLength, "message");
- if (being->getType() == ActorType::Player)
+ if (being && being->getType() == ActorType::Player)
being->setTalkTime();
const size_t pos = chatMsg.find(" : ", 0);
@@ -315,12 +311,14 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
if (serverFeatures->haveIncompleteChatMessages())
{
// work around for "new" tmw server
- sender_name = being->getName();
+ if (being)
+ sender_name = being->getName();
if (sender_name.empty())
- sender_name = "?";
+ sender_name = "?" + toString(static_cast<int>(beingId));
}
- else if (sender_name != being->getName()
- && being->getType() == ActorType::Player)
+ else if (being &&
+ sender_name != being->getName() &&
+ being->getType() == ActorType::Player)
{
if (!being->getName().empty())
sender_name = being->getName();
@@ -337,7 +335,8 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
// because ignorePlayer' side effects are triggered
// right below for Being::IGNORE_SPEECH_FLOAT.
if (player_relations.checkPermissionSilently(sender_name,
- PlayerRelation::SPEECH_LOG) && chatWindow)
+ PlayerRelation::SPEECH_LOG) &&
+ chatWindow)
{
allow = chatWindow->resortChatLog(
removeColors(sender_name).append(" : ").append(chatMsg),
@@ -347,7 +346,9 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
TryRemoveColors_true);
}
- if (allow && player_relations.hasPermission(sender_name,
+ if (allow &&
+ being &&
+ player_relations.hasPermission(sender_name,
PlayerRelation::SPEECH_FLOAT))
{
being->setSpeech(chatMsg, GENERAL_CHANNEL);