Skip to content

Commit

Permalink
Remove Exts.WithDefault
Browse files Browse the repository at this point in the history
  • Loading branch information
RoosterDragon authored and Mailaender committed Aug 7, 2023
1 parent 169c608 commit 388222c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 0 additions & 6 deletions OpenRA.Game/Exts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ public static string FormatCurrent(this string format, params object[] args)
return string.Format(CultureInfo.CurrentCulture, format, args);
}

public static T WithDefault<T>(T def, Func<T> f)
{
try { return f(); }
catch { return def; }
}

public static Lazy<T> Lazy<T>(Func<T> p) { return new Lazy<T>(p); }

public static IEnumerable<string> GetNamespaces(this Assembly a)
Expand Down
3 changes: 2 additions & 1 deletion OpenRA.Mods.Common/Widgets/Logic/DirectConnectLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public DirectConnectLogic(Widget widget, Action onExit, Action openLobby, Connec

joinButton.OnClick = () =>
{
var port = Exts.WithDefault(1234, () => int.Parse(portField.Text, NumberFormatInfo.CurrentInfo));
if (!int.TryParse(portField.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out var port))
port = 1234;
Game.Settings.Player.LastServer = $"{ipField.Text}:{port}";
Game.Settings.Save();
Expand Down

0 comments on commit 388222c

Please sign in to comment.