diff options
author | red-001 <red-001@outlook.ie> | 2017-06-10 12:49:44 +0100 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2018-06-03 17:31:59 +0200 |
commit | 0664b5f77226b7a2308e85898295378e04158923 (patch) | |
tree | 4078e94042837335f43f1b56387d553cc1b95de9 /src/server.cpp | |
parent | 14b039f0b4c8bddc1d4760dc7277f72392385d7d (diff) | |
download | minetest-0664b5f77226b7a2308e85898295378e04158923.tar.gz minetest-0664b5f77226b7a2308e85898295378e04158923.tar.bz2 minetest-0664b5f77226b7a2308e85898295378e04158923.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.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/server.cpp b/src/server.cpp index e9ccc3d79..a0c4e30d8 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2873,12 +2873,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: { @@ -2933,7 +2936,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(); |