aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorred-001 <red-001@outlook.ie>2017-06-10 12:49:44 +0100
committerSmallJoker <mk939@ymail.com>2018-06-03 17:31:59 +0200
commit0664b5f77226b7a2308e85898295378e04158923 (patch)
tree4078e94042837335f43f1b56387d553cc1b95de9 /src
parent14b039f0b4c8bddc1d4760dc7277f72392385d7d (diff)
downloadminetest-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')
-rw-r--r--src/defaultsettings.cpp1
-rw-r--r--src/server.cpp7
-rw-r--r--src/server.h2
-rw-r--r--src/settings_translation_file.cpp10
4 files changed, 12 insertions, 8 deletions
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 0a44069fd..3378e8b4a 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -252,6 +252,7 @@ void set_default_settings(Settings *settings)
// Server
settings->setDefault("disable_escape_sequences", "false");
+ settings->setDefault("strip_color_codes", "false");
// Network
settings->setDefault("enable_ipv6", "true");
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();
diff --git a/src/server.h b/src/server.h
index 2e735e77c..e3a4291d9 100644
--- a/src/server.h
+++ b/src/server.h
@@ -486,7 +486,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,
+ std::wstring wmessage_input,
bool check_shout_priv = false,
RemotePlayer *player = NULL);
void handleAdminChat(const ChatEventChat *evt);
diff --git a/src/settings_translation_file.cpp b/src/settings_translation_file.cpp
index 383da33a7..684b125b9 100644
--- a/src/settings_translation_file.cpp
+++ b/src/settings_translation_file.cpp
@@ -34,7 +34,7 @@ fake_function() {
gettext("Random input");
gettext("Enable random user input (only used for testing).");
gettext("Continuous forward");
- gettext("Continuous forward movement (only used for testing).");
+ gettext("Continuous forward movement, toggled by autoforward key.");
gettext("Enable Joysticks");
gettext("Enable Joysticks");
gettext("Joystick ID");
@@ -87,8 +87,8 @@ fake_function() {
gettext("Key for increasing the volume.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
gettext("Dec. volume key");
gettext("Key for decreasing the volume.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
- gettext("Autorun key");
- gettext("Key for toggling autorun.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
+ gettext("Autoforward key");
+ gettext("Key for toggling autoforward.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
gettext("Cinematic mode key");
gettext("Key for toggling cinematic mode.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
gettext("Minimap key");
@@ -362,8 +362,8 @@ fake_function() {
gettext("Automaticaly report to the serverlist.");
gettext("Serverlist URL");
gettext("Announce to this serverlist.\nIf you want to announce your ipv6 address, use serverlist_url = v6.servers.minetest.net.");
- gettext("Disable escape sequences");
- gettext("Disable escape sequences, e.g. chat coloring.\nUse this if you want to run a server with pre-0.4.14 clients and you want to disable\nthe escape sequences generated by mods.");
+ gettext("Strip color codes");
+ gettext("Remove color codes from incoming chat messages\nUse this to stop players from being able to use color in their messages");
gettext("Network");
gettext("Server port");
gettext("Network port to listen (UDP).\nThis value will be overridden when starting from the main menu.");