diff options
author | est31 <MTest31@outlook.com> | 2015-11-13 01:35:54 +0100 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-11-13 02:35:02 +0100 |
commit | 657a16d90c42afc212e70c594296b1e204545a4c (patch) | |
tree | 3c244b11f64bddb513a9e13bcce1c84996046811 | |
parent | 36855522a5382614c525c69dd884560a197b875d (diff) | |
download | minetest-657a16d90c42afc212e70c594296b1e204545a4c.tar.gz minetest-657a16d90c42afc212e70c594296b1e204545a4c.tar.bz2 minetest-657a16d90c42afc212e70c594296b1e204545a4c.zip |
Only allow players with shout to chat
Fix regression of commit
5e507c9829942c434a6f1ae7a4f3a488c7e50bef "Add server side ncurses terminal"
which allowed all players, even those without a shout priv, to chat.
Fixes #3362.
-rw-r--r-- | src/network/serverpackethandler.cpp | 3 | ||||
-rw-r--r-- | src/server.cpp | 16 | ||||
-rw-r--r-- | src/server.h | 1 |
3 files changed, 14 insertions, 6 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index 3c446e31d..a4fa502ae 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -1063,7 +1063,8 @@ void Server::handleCommand_ChatMessage(NetworkPacket* pkt) std::string name = player->getName(); std::wstring wname = narrow_to_wide(name); - std::wstring answer_to_sender = handleChat(name, wname, message, pkt->getPeerId()); + std::wstring answer_to_sender = handleChat(name, wname, message, + true, pkt->getPeerId()); if (!answer_to_sender.empty()) { // Send the answer to sender SendChatMessage(pkt->getPeerId(), answer_to_sender); diff --git a/src/server.cpp b/src/server.cpp index c93abb10c..f6faccb1f 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2755,7 +2755,8 @@ void Server::handleChatInterfaceEvent(ChatEvent *evt) } std::wstring Server::handleChat(const std::string &name, const std::wstring &wname, - const std::wstring &wmessage, u16 peer_id_to_avoid_sending) + const std::wstring &wmessage, bool check_shout_priv, + u16 peer_id_to_avoid_sending) { // If something goes wrong, this player is to blame RollbackScopeActor rollback_scope(m_rollback, @@ -2783,10 +2784,15 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna else line += L"-!- Invalid command: " + str_split(wcmd, L' ')[0]; } else { - line += L"<"; - line += wname; - line += L"> "; - line += wmessage; + if (check_shout_priv && !checkPriv(name, "shout")) { + line += L"-!- You don't have permission to shout."; + broadcast_line = false; + } else { + line += L"<"; + line += wname; + line += L"> "; + line += wmessage; + } } /* diff --git a/src/server.h b/src/server.h index 5a19677cd..fd559ba14 100644 --- a/src/server.h +++ b/src/server.h @@ -481,6 +481,7 @@ private: // This returns the answer to the sender of wmessage, or "" if there is none std::wstring handleChat(const std::string &name, const std::wstring &wname, const std::wstring &wmessage, + bool check_shout_priv = false, u16 peer_id_to_avoid_sending = PEER_ID_INEXISTENT); void handleAdminChat(const ChatEventChat *evt); |