even better playername regex

This commit is contained in:
Yannik
2023-04-11 20:47:28 +02:00
parent f985225515
commit 20d1ade391
2 changed files with 18 additions and 9 deletions

View File

@@ -9,7 +9,9 @@ public partial class player_variables : Node
{
get
{
_playername = Regex.Replace(_playername, "[^a-zA-Z0-9 ]+", "").StripEdges();
_playername = Regex.Replace(_playername, @"[\[\]<>\\\*\$\@\|\~\+§%/#\^°':;!?=\-`´卐卍࿕࿖࿗࿘ꖦ‍⃠\uD83C-\uDBFF\uDC00-\uDFFF]", "").Trim('"').StripEdges(); //todo swearword censoring with bbcode effect
if (_playername.Length > 12)
_playername = _playername.Substring(0, 12);
return Regex.Replace(_playername, @"\s+", " ");
}
set { _playername = value; }

View File

@@ -129,7 +129,14 @@ public partial class console : PopupPanel
}
void playername(string name)
{
string tmpPlayerName = player_variables.PlayerName;
player_variables.PlayerName = name;
if (player_variables.PlayerName == "")
{
player_variables.PlayerName = tmpPlayerName;
Print("The name had too much incorrect symbols and would be empty when changed.");
}
else
Print("Your new name is now: " + player_variables.PlayerName);
}
void closedialogue()