IPv6 fixes:
- Fixed IPv6 addresses being clipped from the end in the server list screen because the IP textbox was too small to fit them. - Fixed clients parsing IPv6 addresses wrong because they assumed the first ":" in the address is the separator between the IP and port.
This commit is contained in:
@@ -122,19 +122,17 @@ namespace Barotrauma.Networking
|
|||||||
public void ConnectToServer(string hostIP)
|
public void ConnectToServer(string hostIP)
|
||||||
{
|
{
|
||||||
string[] address = hostIP.Split(':');
|
string[] address = hostIP.Split(':');
|
||||||
if (address.Length==1)
|
if (address.Length == 1)
|
||||||
{
|
{
|
||||||
serverIP = hostIP;
|
serverIP = hostIP;
|
||||||
Port = NetConfig.DefaultPort;
|
Port = NetConfig.DefaultPort;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
serverIP = address[0];
|
serverIP = string.Join(":", address.Take(address.Length - 1));
|
||||||
|
if (!int.TryParse(address[address.Length - 1], out int port))
|
||||||
int port = 0;
|
|
||||||
if (!int.TryParse(address[1], out port))
|
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Invalid port: "+address[1]+"!");
|
DebugConsole.ThrowError("Invalid port: " + address[address.Length - 1] + "!");
|
||||||
Port = NetConfig.DefaultPort;
|
Port = NetConfig.DefaultPort;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -172,7 +170,7 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
new GUIMessageBox("Could not connect to server", "Failed to resolve address \""+serverIP+":"+Port+"\". Please make sure you have entered a valid IP address.");
|
new GUIMessageBox("Could not connect to server", "Failed to resolve address \"" + serverIP + ":" + Port + "\". Please make sure you have entered a valid IP address.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +184,7 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Couldn't connect to "+hostIP+". Error message: "+e.Message);
|
DebugConsole.ThrowError("Couldn't connect to " + hostIP + ". Error message: " + e.Message);
|
||||||
Disconnect();
|
Disconnect();
|
||||||
|
|
||||||
GameMain.ServerListScreen.Select();
|
GameMain.ServerListScreen.Select();
|
||||||
|
|||||||
@@ -64,7 +64,11 @@ namespace Barotrauma
|
|||||||
clientNameBox.Text = GameMain.Config.DefaultPlayerName;
|
clientNameBox.Text = GameMain.Config.DefaultPlayerName;
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, 100, 0, 30), TextManager.Get("ServerIP"), "", menu);
|
new GUITextBlock(new Rectangle(0, 100, 0, 30), TextManager.Get("ServerIP"), "", menu);
|
||||||
ipBox = new GUITextBox(new Rectangle(0, 130, 200, 30), "", menu);
|
ipBox = new GUITextBox(new Rectangle(0, 130, 200, 30), "", menu)
|
||||||
|
{
|
||||||
|
//max IPv6 address length + port
|
||||||
|
MaxTextLength = 45 + 6
|
||||||
|
};
|
||||||
|
|
||||||
int middleX = (int)(width * 0.35f);
|
int middleX = (int)(width * 0.35f);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user