Skip to content

Commit de83c29

Browse files
est31nerzhul
authored andcommittedOct 6, 2016
Fix crash regression when chatting in the ncurses console
Fixes #4579, a regression introduced by commit d4c7625 "Chat: new settings to prevent spam"
1 parent 61d1751 commit de83c29

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed
 

‎src/server.cpp

+14-12
Original file line numberDiff line numberDiff line change
@@ -2751,19 +2751,21 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
27512751
if (ate)
27522752
return L"";
27532753

2754-
switch (player->canSendChatMessage()) {
2755-
case RPLAYER_CHATRESULT_FLOODING: {
2756-
std::wstringstream ws;
2757-
ws << L"You cannot send more messages. You are limited to "
2758-
<< g_settings->getFloat("chat_message_limit_per_10sec")
2759-
<< " messages per 10 seconds.";
2760-
return ws.str();
2754+
if (player) {
2755+
switch (player->canSendChatMessage()) {
2756+
case RPLAYER_CHATRESULT_FLOODING: {
2757+
std::wstringstream ws;
2758+
ws << L"You cannot send more messages. You are limited to "
2759+
<< g_settings->getFloat("chat_message_limit_per_10sec")
2760+
<< " messages per 10 seconds.";
2761+
return ws.str();
2762+
}
2763+
case RPLAYER_CHATRESULT_KICK:
2764+
DenyAccess_Legacy(player->peer_id, L"You have been kicked due to message flooding.");
2765+
return L"";
2766+
case RPLAYER_CHATRESULT_OK: break;
2767+
default: FATAL_ERROR("Unhandled chat filtering result found.");
27612768
}
2762-
case RPLAYER_CHATRESULT_KICK:
2763-
DenyAccess_Legacy(player->peer_id, L"You have been kicked due to message flooding.");
2764-
return L"";
2765-
case RPLAYER_CHATRESULT_OK: break;
2766-
default: FATAL_ERROR("Unhandled chat filtering result found.");
27672769
}
27682770

27692771
if (m_max_chatmessage_length > 0 && wmessage.length() > m_max_chatmessage_length) {

0 commit comments

Comments
 (0)
Please sign in to comment.