summaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorred-001 <red-001@outlook.ie>2017-06-10 12:49:44 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-06-10 13:49:44 +0200
commit25ae0739ed70be8b6a46bdc98aee4b7e33f478ab (patch)
tree723c05468fb9178a3b6511d98d92f0ced5135c85 /src/server.cpp
parent07be63b28747714903281a4051cecea0dc3e1cb7 (diff)
downloadminetest-25ae0739ed70be8b6a46bdc98aee4b7e33f478ab.tar.gz
minetest-25ae0739ed70be8b6a46bdc98aee4b7e33f478ab.tar.bz2
minetest-25ae0739ed70be8b6a46bdc98aee4b7e33f478ab.zip
Add a server-sided way to remove color codes from incoming chat messages (#5948)
These code be generated by CSM, a modded client or just copy and pasted by the player. Changes - Update configuration example and setting translation file. - Remove colour codes before logging chat. - Add setting to remove colour codes before processing the chat.
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 52eb97608..179147637 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -2880,12 +2880,15 @@ void Server::handleChatInterfaceEvent(ChatEvent *evt)
}
std::wstring Server::handleChat(const std::string &name, const std::wstring &wname,
- const std::wstring &wmessage, bool check_shout_priv, RemotePlayer *player)
+ std::wstring wmessage, bool check_shout_priv, RemotePlayer *player)
{
// If something goes wrong, this player is to blame
RollbackScopeActor rollback_scope(m_rollback,
std::string("player:") + name);
+ if (g_settings->getBool("strip_color_codes"))
+ wmessage = unescape_enriched(wmessage);
+
if (player) {
switch (player->canSendChatMessage()) {
case RPLAYER_CHATRESULT_FLOODING: {
@@ -2940,7 +2943,7 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
/*
Send the message to others
*/
- actionstream << "CHAT: " << wide_to_narrow(line) << std::endl;
+ actionstream << "CHAT: " << wide_to_narrow(unescape_enriched(line)) << std::endl;
std::vector<u16> clients = m_clients.getClientIDs();