summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorred-001 <red-001@outlook.ie>2017-06-09 20:39:25 +0100
committerSmallJoker <mk939@ymail.com>2018-06-03 17:31:59 +0200
commitc399f5a5419efdafec766268af008ed24418fcd4 (patch)
tree2142dbcc7f56f33a783a3fbb4a28a6b3ed685847 /builtin
parentf736226c1a289c52cb59e5639ce4a39ad6451ac6 (diff)
downloadminetest-c399f5a5419efdafec766268af008ed24418fcd4.tar.gz
minetest-c399f5a5419efdafec766268af008ed24418fcd4.tar.bz2
minetest-c399f5a5419efdafec766268af008ed24418fcd4.zip
Fix sending color codes to clients that don't support them. (#5950)
Also remove `disable_escape_sequences` since it's not needed anymore.
Diffstat (limited to 'builtin')
-rw-r--r--builtin/common/misc_helpers.lua44
-rw-r--r--builtin/settingtypes.txt5
2 files changed, 13 insertions, 36 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index 68481f7c8..0bdd4b02a 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -642,44 +642,26 @@ end
local ESCAPE_CHAR = string.char(0x1b)
--- Client-side mods don't have access to settings
-if core.settings and core.settings:get_bool("disable_escape_sequences") then
-
- function core.get_color_escape_sequence(color)
- return ""
- end
-
- function core.get_background_escape_sequence(color)
- return ""
- end
-
- function core.colorize(color, message)
- return message
- end
-
-else
-
- function core.get_color_escape_sequence(color)
- return ESCAPE_CHAR .. "(c@" .. color .. ")"
- end
-
- function core.get_background_escape_sequence(color)
- return ESCAPE_CHAR .. "(b@" .. color .. ")"
- end
+function core.get_color_escape_sequence(color)
+ return ESCAPE_CHAR .. "(c@" .. color .. ")"
+end
- function core.colorize(color, message)
- local lines = tostring(message):split("\n", true)
- local color_code = core.get_color_escape_sequence(color)
+function core.get_background_escape_sequence(color)
+ return ESCAPE_CHAR .. "(b@" .. color .. ")"
+end
- for i, line in ipairs(lines) do
- lines[i] = color_code .. line
- end
+function core.colorize(color, message)
+ local lines = tostring(message):split("\n", true)
+ local color_code = core.get_color_escape_sequence(color)
- return table.concat(lines, "\n") .. core.get_color_escape_sequence("#ffffff")
+ for i, line in ipairs(lines) do
+ lines[i] = color_code .. line
end
+ return table.concat(lines, "\n") .. core.get_color_escape_sequence("#ffffff")
end
+
function core.strip_foreground_colors(str)
return (str:gsub(ESCAPE_CHAR .. "%(c@[^)]+%)", ""))
end
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index ba3339d32..5182cb3f7 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -721,11 +721,6 @@ server_announce (Announce server) bool false
# If you want to announce your ipv6 address, use serverlist_url = v6.servers.minetest.net.
serverlist_url (Serverlist URL) string servers.minetest.net
-# Disable escape sequences, e.g. chat coloring.
-# Use this if you want to run a server with pre-0.4.14 clients and you want to disable
-# the escape sequences generated by mods.
-disable_escape_sequences (Disable escape sequences) bool false
-
[*Network]
# Network port to listen (UDP).