fixed NullReferenceException for unknown IPs

closes #3167
This commit is contained in:
Matthias Mailänder
2013-04-27 09:34:57 +02:00
parent 7ec4bcad0e
commit b5e8b5426e
2 changed files with 12 additions and 1 deletions

View File

@@ -35,6 +35,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var tooltipHeight = widget.Bounds.Height;
var margin = widget.Bounds.Width;
tooltipContainer.IsVisible = () => (orderManager.LobbyInfo.ClientWithIndex(clientIndex) != null);
tooltipContainer.BeforeRender = () =>
{
var width = Math.Max(adminFont.Measure(admin.GetText()).X, Math.Max(ipFont.Measure(ip.GetText()).X, latencyFont.Measure(latency.GetText()).X));
@@ -57,7 +59,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
admin.IsVisible = () => orderManager.LobbyInfo.ClientWithIndex(clientIndex).IsAdmin;
latency.GetText = () => "Latency: {0}".F(LobbyUtils.LatencyDescription(orderManager.LobbyInfo.ClientWithIndex(clientIndex).Latency));
ip.GetText = () => orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress;
ip.GetText = () => LobbyUtils.DescriptiveIpAddress(orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress);
}
}
}

View File

@@ -182,6 +182,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
return "Poor";
}
public static string DescriptiveIpAddress(string ip)
{
if (ip == null)
return "Unknown Host";
if (ip == "127.0.0.1")
return "Local Host";
return ip;
}
public static void SetupClientWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, bool visible)
{
parent.Get("ADMIN_INDICATOR").IsVisible = () => c.IsAdmin;