Evaluate player location on the server.

This commit is contained in:
Paul Chote
2020-01-11 12:14:10 +00:00
committed by abcdefg30
parent c430884c8b
commit 6b2c019caa
6 changed files with 8 additions and 26 deletions

View File

@@ -593,20 +593,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
HideChildWidget(parent, "STATUS_IMAGE");
}
public static string GetExternalIP(Session.Client client, OrderManager orderManager)
{
var address = client != null ? client.IpAddress : "";
var lc = orderManager.LocalClient;
if (lc != null && lc.Index == client.Index && address == IPAddress.Loopback.ToString())
{
var externalIP = UPnP.ExternalIP;
if (externalIP != null)
address = externalIP.ToString();
}
return address;
}
public static void SetupChatLine(ContainerWidget template, DateTime time, string name, Color nameColor, string text, Color textColor)
{
var nameLabel = template.Get<LabelWidget>("NAME");

View File

@@ -312,19 +312,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
[ObjectCreator.UseCtor]
public AnonymousProfileTooltipLogic(Widget widget, OrderManager orderManager, Session.Client client)
{
var address = LobbyUtils.GetExternalIP(client, orderManager);
var cachedDescriptiveIP = address ?? "Unknown IP";
var nameLabel = widget.Get<LabelWidget>("NAME");
var nameFont = Game.Renderer.Fonts[nameLabel.Font];
widget.Bounds.Width = nameFont.Measure(nameLabel.Text).X + 2 * nameLabel.Bounds.Left;
var ipLabel = widget.Get<LabelWidget>("IP");
ipLabel.GetText = () => cachedDescriptiveIP;
ipLabel.GetText = () => client.IpAddress;
var locationLabel = widget.Get<LabelWidget>("LOCATION");
var cachedCountryLookup = GeoIP.LookupCountry(address);
locationLabel.GetText = () => cachedCountryLookup;
locationLabel.GetText = () => client.Location;
if (client.IsAdmin)
{