tidy DirectConnectLogic
This commit is contained in:
@@ -31,9 +31,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
|
||||
panel.GetWidget<ButtonWidget>("JOIN_BUTTON").OnClick = () =>
|
||||
{
|
||||
int port;
|
||||
if (!int.TryParse(portField.Text, out port))
|
||||
port = 1234;
|
||||
var port = Exts.WithDefault(1234, () => int.Parse(portField.Text));
|
||||
|
||||
Game.Settings.Player.LastServer = "{0}:{1}".F(ipField.Text, port);
|
||||
Game.Settings.Save();
|
||||
|
||||
@@ -29,9 +29,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
if (addressParts.Length < 1 || addressParts.Length > 2)
|
||||
return;
|
||||
|
||||
int port;
|
||||
if (addressParts.Length != 2 || !int.TryParse(addressParts[1], out port))
|
||||
port = 1234;
|
||||
var port = Exts.WithDefault(1234, () => int.Parse(addressParts[1]));
|
||||
|
||||
Game.Settings.Player.LastServer = address;
|
||||
Game.Settings.Save();
|
||||
|
||||
Reference in New Issue
Block a user