Fixing the chat client (#60920)

Corrects the chat restriction on using ASII characters only. (This PR was created for Skyrat-TG, but the collaborator of that repository asked me to adapt this PR for tgstation.)

This will fix #54598
In the original code, the chat client uses only ASII standard characters, which is very limited in its capabilities. For example, does not allow you to use specialized characters, which would have taken the atmosphere of the old messengers, as well as regional characters. The lack of regional characters complicates the game for non-English-speaking servers. For example, the Russian-speaking player community Space Station 13 The Fluffy Frontier uses the original Skyrat-tg build. And the players of this community almost do not use the chat client to communicate due to the fact that they can not use Cyrillic characters.
This commit is contained in:
twilightwanderer
2021-09-28 10:01:07 +03:00
committed by GitHub
parent 3b275f8fac
commit ff41f8a661
2 changed files with 35 additions and 4 deletions

View File

@@ -1,3 +1,6 @@
#define USERNAME_SIZE 32
#define CHANNELNAME_SIZE 12
#define MESSAGE_SIZE 2048
/datum/computer_file/program/chatclient
filename = "ntnrc_client"
@@ -44,7 +47,7 @@
if("PRG_speak")
if(!channel || isnull(active_channel))
return
var/message = reject_bad_text(params["message"])
var/message = reject_bad_chattext(params["message"], MESSAGE_SIZE)
if(!message)
return
if(channel.password && (!(src in channel.active_clients) && !(src in channel.offline_clients)))
@@ -76,7 +79,7 @@
active_channel = null
return TRUE
if("PRG_newchannel")
var/channel_title = reject_bad_text(params["new_channel_name"])
var/channel_title = reject_bad_chattext(params["new_channel_name"], CHANNELNAME_SIZE)
if(!channel_title)
return
var/datum/ntnet_conversation/C = new /datum/ntnet_conversation()
@@ -99,7 +102,7 @@
netadmin_mode = TRUE
return TRUE
if("PRG_changename")
var/newname = sanitize(params["new_name"])
var/newname = reject_bad_chattext(params["new_name"], USERNAME_SIZE)
newname = replacetext(newname, " ", "_")
if(!newname || newname == username)
return
@@ -135,7 +138,7 @@
if("PRG_renamechannel")
if(!authed)
return
var/newname = reject_bad_text(params["new_name"])
var/newname = reject_bad_chattext(params["new_name"], CHANNELNAME_SIZE)
if(!newname || !channel)
return
channel.add_status_message("Channel renamed from [channel.title] to [newname] by operator.")
@@ -267,3 +270,7 @@
data["messages"] = list()
return data
#undef USERNAME_SIZE
#undef CHANNELNAME_SIZE
#undef MESSAGE_SIZE