Skip to content

Commit

Permalink
Fix crash regression when chatting in the ncurses console
Browse files Browse the repository at this point in the history
Fixes #4579, a regression introduced by commit

d4c7625 "Chat: new settings to prevent spam"
  • Loading branch information
est31 authored and nerzhul committed Oct 6, 2016
1 parent 61d1751 commit de83c29
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/server.cpp
Expand Up @@ -2751,19 +2751,21 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
if (ate)
return L"";

switch (player->canSendChatMessage()) {
case RPLAYER_CHATRESULT_FLOODING: {
std::wstringstream ws;
ws << L"You cannot send more messages. You are limited to "
<< g_settings->getFloat("chat_message_limit_per_10sec")
<< " messages per 10 seconds.";
return ws.str();
if (player) {
switch (player->canSendChatMessage()) {
case RPLAYER_CHATRESULT_FLOODING: {
std::wstringstream ws;
ws << L"You cannot send more messages. You are limited to "
<< g_settings->getFloat("chat_message_limit_per_10sec")
<< " 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) {
Expand Down

0 comments on commit de83c29

Please sign in to comment.