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:
Matthias Mailänder
2013-04-18 23:42:32 +02:00
parent d2a6781e7e
commit ef20009310
4 changed files with 19 additions and 2 deletions

View File

@@ -61,6 +61,7 @@ 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 class Slot
@@ -82,7 +83,7 @@ namespace OpenRA.Network
public string Map;
public string[] Ban;
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 bool FragileAlliances = false; // Allow diplomatic stance changes after game start.
public bool AllowCheats = false;

View File

@@ -322,6 +322,8 @@ namespace OpenRA.Server
preConns.Remove(newConn);
conns.Add(newConn);
client.Ping = newConn.Latency;
// Enforce correct PlayerIndex and Slot
client.Index = newConn.PlayerIndex;
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));
lobbyInfo.GlobalSettings.OrderLatency = highestLatency / 40; // 1 frame is 40 ms
lobbyInfo.GlobalSettings.OrderLatency = highestLatency / 120;
if (lobbyInfo.GlobalSettings.OrderLatency < 1) // should never be 0
lobbyInfo.GlobalSettings.OrderLatency = 1;

View File

@@ -477,6 +477,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
template.Get<LabelWidget>("NAME").GetText = () => client.Name;
if (client.IsAdmin)
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");
color.GetColor = () => client.ColorRamp.GetColor(0);

View File

@@ -26,6 +26,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (c.IsAdmin)
name.Font = "Bold";
name.Text = c.Name;
if (c.Ping > -1)
name.TextColor = GetPingColor(c.Ping);
name.OnEnterKey = () =>
{
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);
}
}
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;
}
}
}