aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2016-10-06 03:32:52 +0200
committerNer'zhul <nerzhul@users.noreply.github.com>2016-10-06 07:45:50 +0200
commitde83c29ba0a517630b361ffdbebd1a1f0b5eed4e (patch)
tree5d0d117ac3fc53d5ea1e8e6e4fd6578c14fe7c56 /src
parent61d1751dfff71d8fd433c6c84bd39db1672a3ee6 (diff)
downloadminetest-de83c29ba0a517630b361ffdbebd1a1f0b5eed4e.tar.gz
minetest-de83c29ba0a517630b361ffdbebd1a1f0b5eed4e.tar.bz2
minetest-de83c29ba0a517630b361ffdbebd1a1f0b5eed4e.zip
Fix crash regression when chatting in the ncurses console
Fixes #4579, a regression introduced by commit d4c76258e37337ea585cf24d8e05b50a30fa307d "Chat: new settings to prevent spam"
Diffstat (limited to 'src')
-rw-r--r--src/server.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 5b67b321a..a8494f76e 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -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) {