Rename Ping -> Latency.
This commit is contained in:
@@ -61,9 +61,9 @@ namespace OpenRA.Network
|
|||||||
public bool IsAdmin;
|
public bool IsAdmin;
|
||||||
public bool IsReady { get { return State == ClientState.Ready; } }
|
public bool IsReady { get { return State == ClientState.Ready; } }
|
||||||
public bool IsObserver { get { return Slot == null; } }
|
public bool IsObserver { get { return Slot == null; } }
|
||||||
public int Ping = -1;
|
public int Latency = -1;
|
||||||
public int PingJitter = -1;
|
public int LatencyJitter = -1;
|
||||||
public int[] PingHistory = {};
|
public int[] LatencyHistory = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Slot
|
public class Slot
|
||||||
|
|||||||
@@ -469,16 +469,16 @@ namespace OpenRA.Server
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var history = fromClient.PingHistory.ToList();
|
var history = fromClient.LatencyHistory.ToList();
|
||||||
history.Add(Environment.TickCount - pingSent);
|
history.Add(Environment.TickCount - pingSent);
|
||||||
|
|
||||||
// Cap ping history at 5 values (25 seconds)
|
// Cap ping history at 5 values (25 seconds)
|
||||||
if (history.Count > 5)
|
if (history.Count > 5)
|
||||||
history.RemoveRange(0, history.Count - 5);
|
history.RemoveRange(0, history.Count - 5);
|
||||||
|
|
||||||
fromClient.Ping = history.Sum() / history.Count;
|
fromClient.Latency = history.Sum() / history.Count;
|
||||||
fromClient.PingJitter = (history.Max() - history.Min())/2;
|
fromClient.LatencyJitter = (history.Max() - history.Min())/2;
|
||||||
fromClient.PingHistory = history.ToArray();
|
fromClient.LatencyHistory = history.ToArray();
|
||||||
|
|
||||||
if (State == ServerState.WaitingPlayers)
|
if (State == ServerState.WaitingPlayers)
|
||||||
SyncLobbyInfo();
|
SyncLobbyInfo();
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
if (template == null || template.Id != EditablePlayerTemplate.Id)
|
if (template == null || template.Id != EditablePlayerTemplate.Id)
|
||||||
template = EditablePlayerTemplate.Clone();
|
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)
|
if (client.Bot != null)
|
||||||
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager);
|
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager);
|
||||||
@@ -408,7 +408,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
if (template == null || template.Id != NonEditablePlayerTemplate.Id)
|
if (template == null || template.Id != NonEditablePlayerTemplate.Id)
|
||||||
template = NonEditablePlayerTemplate.Clone();
|
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.SetupNameWidget(template, slot, client);
|
||||||
LobbyUtils.SetupKickWidget(template, slot, client, orderManager);
|
LobbyUtils.SetupKickWidget(template, slot, client, orderManager);
|
||||||
LobbyUtils.SetupColorWidget(template, slot, client);
|
LobbyUtils.SetupColorWidget(template, slot, client);
|
||||||
@@ -459,7 +459,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
LobbyUtils.SetupReadyWidget(template, null, client);
|
LobbyUtils.SetupReadyWidget(template, null, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
LobbyUtils.SetupAdminPingWidget(template, null, c, orderManager, true);
|
LobbyUtils.SetupClientWidget(template, null, c, orderManager, true);
|
||||||
template.IsVisible = () => true;
|
template.IsVisible = () => true;
|
||||||
|
|
||||||
if (idx >= Players.Children.Count)
|
if (idx >= Players.Children.Count)
|
||||||
|
|||||||
@@ -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;
|
return Color.Gray;
|
||||||
if (c.Ping > 720) // OrderLag > 6
|
if (c.Latency > 720) // OrderLag > 6
|
||||||
return Color.Red;
|
return Color.Red;
|
||||||
if (c.Ping > 360) // OrderLag > 3
|
if (c.Latency > 360) // OrderLag > 3
|
||||||
return Color.Orange;
|
return Color.Orange;
|
||||||
|
|
||||||
return Color.LimeGreen;
|
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;
|
parent.Get("ADMIN_INDICATOR").IsVisible = () => c.IsAdmin;
|
||||||
var block = parent.Get("PING_BLOCK");
|
var block = parent.Get("LATENCY");
|
||||||
block.IsVisible = () => visible;
|
block.IsVisible = () => visible;
|
||||||
|
|
||||||
if (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)
|
public static void SetupEditableNameWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ Container@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Background@PING_BLOCK:
|
Background@LATENCY:
|
||||||
Background:button
|
Background:button
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
@@ -81,7 +81,7 @@ Container@SERVER_LOBBY:
|
|||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
@@ -161,7 +161,7 @@ Container@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Background@PING_BLOCK:
|
Background@LATENCY:
|
||||||
Background:button
|
Background:button
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
@@ -169,7 +169,7 @@ Container@SERVER_LOBBY:
|
|||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
@@ -263,7 +263,7 @@ Container@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Background@PING_BLOCK:
|
Background@LATENCY:
|
||||||
Background:button
|
Background:button
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
@@ -271,7 +271,7 @@ Container@SERVER_LOBBY:
|
|||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
@@ -319,7 +319,7 @@ Container@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Background@PING_BLOCK:
|
Background@LATENCY:
|
||||||
Background:button
|
Background:button
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
@@ -327,7 +327,7 @@ Container@SERVER_LOBBY:
|
|||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
|
|||||||
@@ -54,14 +54,14 @@ Background@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Container@PING_BLOCK:
|
Container@LATENCY:
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
Width:11
|
Width:11
|
||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
@@ -140,14 +140,14 @@ Background@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Container@PING_BLOCK:
|
Container@LATENCY:
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
Width:11
|
Width:11
|
||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
@@ -240,14 +240,14 @@ Background@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Container@PING_BLOCK:
|
Container@LATENCY:
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
Width:11
|
Width:11
|
||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
@@ -302,14 +302,14 @@ Background@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Container@PING_BLOCK:
|
Container@LATENCY:
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
Width:11
|
Width:11
|
||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
|
|||||||
@@ -54,14 +54,14 @@ Background@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Container@PING_BLOCK:
|
Container@LATENCY:
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
Width:11
|
Width:11
|
||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
@@ -140,14 +140,14 @@ Background@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Container@PING_BLOCK:
|
Container@LATENCY:
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
Width:11
|
Width:11
|
||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
@@ -240,14 +240,14 @@ Background@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Container@PING_BLOCK:
|
Container@LATENCY:
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
Width:11
|
Width:11
|
||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
@@ -302,14 +302,14 @@ Background@SERVER_LOBBY:
|
|||||||
ImageName:admin
|
ImageName:admin
|
||||||
X:2
|
X:2
|
||||||
Visible:false
|
Visible:false
|
||||||
Container@PING_BLOCK:
|
Container@LATENCY:
|
||||||
X:0
|
X:0
|
||||||
Y:6
|
Y:6
|
||||||
Width:11
|
Width:11
|
||||||
Height:14
|
Height:14
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ColorBlock@PING_COLOR:
|
ColorBlock@LATENCY_COLOR:
|
||||||
X:2
|
X:2
|
||||||
Y:2
|
Y:2
|
||||||
Width:PARENT_RIGHT-4
|
Width:PARENT_RIGHT-4
|
||||||
|
|||||||
Reference in New Issue
Block a user