1 net tick is 120 ms and good order latency should be 2-3
color code names in lobby accordingly
This commit is contained in:
@@ -61,6 +61,7 @@ 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 class Slot
|
public class Slot
|
||||||
@@ -82,7 +83,7 @@ namespace OpenRA.Network
|
|||||||
public string Map;
|
public string Map;
|
||||||
public string[] Ban;
|
public string[] Ban;
|
||||||
public string[] Mods = { "ra" }; // mod names
|
public string[] Mods = { "ra" }; // mod names
|
||||||
public int OrderLatency = 3; // x 40 = ms
|
public int OrderLatency = 3; // net tick frames (x 120 = ms)
|
||||||
public int RandomSeed = 0;
|
public int RandomSeed = 0;
|
||||||
public bool FragileAlliances = false; // Allow diplomatic stance changes after game start.
|
public bool FragileAlliances = false; // Allow diplomatic stance changes after game start.
|
||||||
public bool AllowCheats = false;
|
public bool AllowCheats = false;
|
||||||
|
|||||||
@@ -322,6 +322,8 @@ namespace OpenRA.Server
|
|||||||
preConns.Remove(newConn);
|
preConns.Remove(newConn);
|
||||||
conns.Add(newConn);
|
conns.Add(newConn);
|
||||||
|
|
||||||
|
client.Ping = newConn.Latency;
|
||||||
|
|
||||||
// Enforce correct PlayerIndex and Slot
|
// Enforce correct PlayerIndex and Slot
|
||||||
client.Index = newConn.PlayerIndex;
|
client.Index = newConn.PlayerIndex;
|
||||||
client.Slot = lobbyInfo.FirstEmptySlot();
|
client.Slot = lobbyInfo.FirstEmptySlot();
|
||||||
@@ -565,7 +567,7 @@ namespace OpenRA.Server
|
|||||||
|
|
||||||
Log.Write("server", "Measured {0} ms as the highest connection round trip time.".F(highestLatency));
|
Log.Write("server", "Measured {0} ms as the highest connection round trip time.".F(highestLatency));
|
||||||
|
|
||||||
lobbyInfo.GlobalSettings.OrderLatency = highestLatency / 40; // 1 frame is 40 ms
|
lobbyInfo.GlobalSettings.OrderLatency = highestLatency / 120;
|
||||||
if (lobbyInfo.GlobalSettings.OrderLatency < 1) // should never be 0
|
if (lobbyInfo.GlobalSettings.OrderLatency < 1) // should never be 0
|
||||||
lobbyInfo.GlobalSettings.OrderLatency = 1;
|
lobbyInfo.GlobalSettings.OrderLatency = 1;
|
||||||
|
|
||||||
|
|||||||
@@ -477,6 +477,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
template.Get<LabelWidget>("NAME").GetText = () => client.Name;
|
template.Get<LabelWidget>("NAME").GetText = () => client.Name;
|
||||||
if (client.IsAdmin)
|
if (client.IsAdmin)
|
||||||
template.Get<LabelWidget>("NAME").Font = "Bold";
|
template.Get<LabelWidget>("NAME").Font = "Bold";
|
||||||
|
if (client.Ping > -1)
|
||||||
|
template.Get<LabelWidget>("NAME").GetColor = () => LobbyUtils.GetPingColor(client.Ping);
|
||||||
|
|
||||||
var color = template.Get<ColorBlockWidget>("COLOR");
|
var color = template.Get<ColorBlockWidget>("COLOR");
|
||||||
color.GetColor = () => client.ColorRamp.GetColor(0);
|
color.GetColor = () => client.ColorRamp.GetColor(0);
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
if (c.IsAdmin)
|
if (c.IsAdmin)
|
||||||
name.Font = "Bold";
|
name.Font = "Bold";
|
||||||
name.Text = c.Name;
|
name.Text = c.Name;
|
||||||
|
if (c.Ping > -1)
|
||||||
|
name.TextColor = GetPingColor(c.Ping);
|
||||||
name.OnEnterKey = () =>
|
name.OnEnterKey = () =>
|
||||||
{
|
{
|
||||||
name.Text = name.Text.Trim();
|
name.Text = name.Text.Trim();
|
||||||
@@ -189,5 +191,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
Game.Renderer.Fonts["Bold"].DrawTextWithContrast(client.Name, position + new int2(5, 5), Color.White, Color.Black, 1);
|
Game.Renderer.Fonts["Bold"].DrawTextWithContrast(client.Name, position + new int2(5, 5), Color.White, Color.Black, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Color GetPingColor(int ping)
|
||||||
|
{
|
||||||
|
if (ping > 720) // OrderLag > 6
|
||||||
|
return Color.Red;
|
||||||
|
if (ping > 360) // OrderLag > 3
|
||||||
|
return Color.Orange;
|
||||||
|
return Color.LimeGreen;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user