(d2accb97f) Restrict server name length to 60 characters, prevent long server names from overflowing in the "host server" menu & server lobby
This commit is contained in:
@@ -948,7 +948,11 @@ namespace Barotrauma
|
|||||||
new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("HostServerButton"), textAlignment: Alignment.Center, font: GUI.LargeFont) { ForceUpperCase = true };
|
new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("HostServerButton"), textAlignment: Alignment.Center, font: GUI.LargeFont) { ForceUpperCase = true };
|
||||||
|
|
||||||
var label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerName"), textAlignment: textAlignment);
|
var label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerName"), textAlignment: textAlignment);
|
||||||
serverNameBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment);
|
serverNameBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
|
||||||
|
{
|
||||||
|
MaxTextLength = NetConfig.ServerNameMaxLength,
|
||||||
|
OverflowClip = true
|
||||||
|
};
|
||||||
|
|
||||||
label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerPort"), textAlignment: textAlignment);
|
label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerPort"), textAlignment: textAlignment);
|
||||||
portBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
|
portBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
|
||||||
|
|||||||
@@ -336,7 +336,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//server info ------------------------------------------------------------------
|
//server info ------------------------------------------------------------------
|
||||||
|
|
||||||
ServerName = new GUITextBox(new RectTransform(new Vector2(0.3f, 0.05f), infoFrameContent.RectTransform));
|
ServerName = new GUITextBox(new RectTransform(new Vector2(infoColumnContainer.RectTransform.RelativeSize.X, 0.05f), infoFrameContent.RectTransform))
|
||||||
|
{
|
||||||
|
MaxTextLength = NetConfig.ServerNameMaxLength,
|
||||||
|
OverflowClip = true
|
||||||
|
};
|
||||||
ServerName.OnDeselected += (textBox, key) =>
|
ServerName.OnDeselected += (textBox, key) =>
|
||||||
{
|
{
|
||||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Name);
|
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Name);
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
name = name.Replace(":", "");
|
name = name.Replace(":", "");
|
||||||
name = name.Replace(";", "");
|
name = name.Replace(";", "");
|
||||||
|
if (name.Length > NetConfig.ServerNameMaxLength)
|
||||||
|
{
|
||||||
|
name = name.Substring(0, NetConfig.ServerNameMaxLength);
|
||||||
|
}
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public const int MaxPlayers = 16;
|
public const int MaxPlayers = 16;
|
||||||
|
|
||||||
|
public const int ServerNameMaxLength = 60;
|
||||||
|
|
||||||
public static string MasterServerUrl = GameMain.Config.MasterServerUrl;
|
public static string MasterServerUrl = GameMain.Config.MasterServerUrl;
|
||||||
|
|
||||||
//if a Character is further than this from the sub and the players, the server will disable it
|
//if a Character is further than this from the sub and the players, the server will disable it
|
||||||
|
|||||||
Reference in New Issue
Block a user