Fix crash regression when chatting in the ncurses console

Fixes #4579, a regression introduced by commit

d4c76258e37337ea585cf24d8e05b50a30fa307d "Chat: new settings to prevent spam"
This commit is contained in:
est31 2016-10-06 03:32:52 +02:00 committed by Ner'zhul
parent 61d1751dff
commit de83c29ba0

@ -2751,19 +2751,21 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
if (ate) if (ate)
return L""; return L"";
switch (player->canSendChatMessage()) { if (player) {
case RPLAYER_CHATRESULT_FLOODING: { switch (player->canSendChatMessage()) {
std::wstringstream ws; case RPLAYER_CHATRESULT_FLOODING: {
ws << L"You cannot send more messages. You are limited to " std::wstringstream ws;
<< g_settings->getFloat("chat_message_limit_per_10sec") ws << L"You cannot send more messages. You are limited to "
<< " messages per 10 seconds."; << g_settings->getFloat("chat_message_limit_per_10sec")
return ws.str(); << " messages per 10 seconds.";
return ws.str();
}
case RPLAYER_CHATRESULT_KICK:
DenyAccess_Legacy(player->peer_id, L"You have been kicked due to message flooding.");
return L"";
case RPLAYER_CHATRESULT_OK: break;
default: FATAL_ERROR("Unhandled chat filtering result found.");
} }
case RPLAYER_CHATRESULT_KICK:
DenyAccess_Legacy(player->peer_id, L"You have been kicked due to message flooding.");
return L"";
case RPLAYER_CHATRESULT_OK: break;
default: FATAL_ERROR("Unhandled chat filtering result found.");
} }
if (m_max_chatmessage_length > 0 && wmessage.length() > m_max_chatmessage_length) { if (m_max_chatmessage_length > 0 && wmessage.length() > m_max_chatmessage_length) {