Merge pull request #5115 from Mailaender/split-lobby-sync

Splitted LobbyInfo updates into smaller chunks
This commit is contained in:
Paul Chote
2014-05-17 18:37:36 +12:00
8 changed files with 317 additions and 90 deletions

View File

@@ -71,8 +71,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
};
admin.IsVisible = () => orderManager.LobbyInfo.ClientWithIndex(clientIndex).IsAdmin;
latency.GetText = () => LobbyUtils.LatencyDescription(orderManager.LobbyInfo.ClientWithIndex(clientIndex).Latency);
latency.GetColor = () => LobbyUtils.LatencyColor(orderManager.LobbyInfo.ClientWithIndex(clientIndex).Latency);
var client = orderManager.LobbyInfo.ClientWithIndex(clientIndex);
var ping = orderManager.LobbyInfo.PingFromClient(client);
latency.GetText = () => LobbyUtils.LatencyDescription(ping);
latency.GetColor = () => LobbyUtils.LatencyColor(ping);
var address = orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress;
if (address == "127.0.0.1" && UPnP.NatDevice != null)
address = UPnP.NatDevice.GetExternalIP().ToString();

View File

@@ -183,26 +183,32 @@ namespace OpenRA.Mods.RA.Widgets.Logic
orderManager.IssueOrder(Order.Command("spawn {0} {1}".F((playerToMove ?? orderManager.LocalClient).Index, selectedSpawn)));
}
public static Color LatencyColor(int latency)
public static Color LatencyColor(Session.ClientPing ping)
{
if (ping == null)
return Color.Gray;
// Levels set relative to the default order lag of 3 net ticks (360ms)
// TODO: Adjust this once dynamic lag is implemented
if (latency < 0)
if (ping.Latency < 0)
return Color.Gray;
if (latency < 300)
if (ping.Latency < 300)
return Color.LimeGreen;
if (latency < 600)
if (ping.Latency < 600)
return Color.Orange;
return Color.Red;
}
public static string LatencyDescription(int latency)
public static string LatencyDescription(Session.ClientPing ping)
{
if (latency < 0)
if (ping == null)
return "Unknown";
if (latency < 300)
if (ping.Latency < 0)
return "Unknown";
if (ping.Latency < 300)
return "Good";
if (latency < 600)
if (ping.Latency < 600)
return "Moderate";
return "Poor";
}
@@ -236,7 +242,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
block.IsVisible = () => visible;
if (visible)
block.Get<ColorBlockWidget>("LATENCY_COLOR").GetColor = () => LatencyColor(c.Latency);
block.Get<ColorBlockWidget>("LATENCY_COLOR").GetColor = () => LatencyColor(
orderManager.LobbyInfo.PingFromClient(c));
var tooltip = parent.Get<ClientTooltipRegionWidget>("CLIENT_REGION");
tooltip.IsVisible = () => visible;