Rename Ping -> Latency.

This commit is contained in:
Paul Chote
2013-04-25 13:43:05 +12:00
parent a1d2229a58
commit fd58461d43
7 changed files with 41 additions and 41 deletions

View File

@@ -61,9 +61,9 @@ namespace OpenRA.Network
public bool IsAdmin;
public bool IsReady { get { return State == ClientState.Ready; } }
public bool IsObserver { get { return Slot == null; } }
public int Ping = -1;
public int PingJitter = -1;
public int[] PingHistory = {};
public int Latency = -1;
public int LatencyJitter = -1;
public int[] LatencyHistory = {};
}
public class Slot

View File

@@ -469,16 +469,16 @@ namespace OpenRA.Server
break;
}
var history = fromClient.PingHistory.ToList();
var history = fromClient.LatencyHistory.ToList();
history.Add(Environment.TickCount - pingSent);
// Cap ping history at 5 values (25 seconds)
if (history.Count > 5)
history.RemoveRange(0, history.Count - 5);
fromClient.Ping = history.Sum() / history.Count;
fromClient.PingJitter = (history.Max() - history.Min())/2;
fromClient.PingHistory = history.ToArray();
fromClient.Latency = history.Sum() / history.Count;
fromClient.LatencyJitter = (history.Max() - history.Min())/2;
fromClient.LatencyHistory = history.ToArray();
if (State == ServerState.WaitingPlayers)
SyncLobbyInfo();

View File

@@ -388,7 +388,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (template == null || template.Id != EditablePlayerTemplate.Id)
template = EditablePlayerTemplate.Clone();
LobbyUtils.SetupAdminPingWidget(template, slot, client, orderManager, client.Bot == null);
LobbyUtils.SetupClientWidget(template, slot, client, orderManager, client.Bot == null);
if (client.Bot != null)
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager);
@@ -408,7 +408,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (template == null || template.Id != NonEditablePlayerTemplate.Id)
template = NonEditablePlayerTemplate.Clone();
LobbyUtils.SetupAdminPingWidget(template, slot, client, orderManager, client.Bot == null);
LobbyUtils.SetupClientWidget(template, slot, client, orderManager, client.Bot == null);
LobbyUtils.SetupNameWidget(template, slot, client);
LobbyUtils.SetupKickWidget(template, slot, client, orderManager);
LobbyUtils.SetupColorWidget(template, slot, client);
@@ -459,7 +459,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
LobbyUtils.SetupReadyWidget(template, null, client);
}
LobbyUtils.SetupAdminPingWidget(template, null, c, orderManager, true);
LobbyUtils.SetupClientWidget(template, null, c, orderManager, true);
template.IsVisible = () => true;
if (idx >= Players.Children.Count)

View File

@@ -158,26 +158,26 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
}
static Color GetPingColor(Session.Client c)
static Color GetLatencyColor(Session.Client c)
{
if (c.Ping < 0) // Ping unknown
if (c.Latency < 0) // Ping unknown
return Color.Gray;
if (c.Ping > 720) // OrderLag > 6
if (c.Latency > 720) // OrderLag > 6
return Color.Red;
if (c.Ping > 360) // OrderLag > 3
if (c.Latency > 360) // OrderLag > 3
return Color.Orange;
return Color.LimeGreen;
}
public static void SetupAdminPingWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, bool visible)
public static void SetupClientWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, bool visible)
{
parent.Get("ADMIN_INDICATOR").IsVisible = () => c.IsAdmin;
var block = parent.Get("PING_BLOCK");
var block = parent.Get("LATENCY");
block.IsVisible = () => visible;
if (visible)
block.Get<ColorBlockWidget>("PING_COLOR").GetColor = () => GetPingColor(c);
block.Get<ColorBlockWidget>("LATENCY_COLOR").GetColor = () => GetLatencyColor(c);
}
public static void SetupEditableNameWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager)

View File

@@ -73,7 +73,7 @@ Container@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Background@PING_BLOCK:
Background@LATENCY:
Background:button
X:0
Y:6
@@ -81,7 +81,7 @@ Container@SERVER_LOBBY:
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4
@@ -161,7 +161,7 @@ Container@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Background@PING_BLOCK:
Background@LATENCY:
Background:button
X:0
Y:6
@@ -169,7 +169,7 @@ Container@SERVER_LOBBY:
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4
@@ -263,7 +263,7 @@ Container@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Background@PING_BLOCK:
Background@LATENCY:
Background:button
X:0
Y:6
@@ -271,7 +271,7 @@ Container@SERVER_LOBBY:
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4
@@ -319,7 +319,7 @@ Container@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Background@PING_BLOCK:
Background@LATENCY:
Background:button
X:0
Y:6
@@ -327,7 +327,7 @@ Container@SERVER_LOBBY:
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4

View File

@@ -54,14 +54,14 @@ Background@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Container@PING_BLOCK:
Container@LATENCY:
X:0
Y:6
Width:11
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4
@@ -140,14 +140,14 @@ Background@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Container@PING_BLOCK:
Container@LATENCY:
X:0
Y:6
Width:11
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4
@@ -240,14 +240,14 @@ Background@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Container@PING_BLOCK:
Container@LATENCY:
X:0
Y:6
Width:11
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4
@@ -302,14 +302,14 @@ Background@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Container@PING_BLOCK:
Container@LATENCY:
X:0
Y:6
Width:11
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4

View File

@@ -54,14 +54,14 @@ Background@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Container@PING_BLOCK:
Container@LATENCY:
X:0
Y:6
Width:11
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4
@@ -140,14 +140,14 @@ Background@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Container@PING_BLOCK:
Container@LATENCY:
X:0
Y:6
Width:11
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4
@@ -240,14 +240,14 @@ Background@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Container@PING_BLOCK:
Container@LATENCY:
X:0
Y:6
Width:11
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4
@@ -302,14 +302,14 @@ Background@SERVER_LOBBY:
ImageName:admin
X:2
Visible:false
Container@PING_BLOCK:
Container@LATENCY:
X:0
Y:6
Width:11
Height:14
Visible:false
Children:
ColorBlock@PING_COLOR:
ColorBlock@LATENCY_COLOR:
X:2
Y:2
Width:PARENT_RIGHT-4