cache the country lookup to avoid doing it every render tick
This commit is contained in:
@@ -70,8 +70,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var ipAddress = orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress;
|
||||
if ((ipAddress == null || ipAddress == "127.0.0.1") && UPnP.NatDevice != null)
|
||||
ipAddress = UPnP.NatDevice.GetExternalIP().ToString();
|
||||
ip.GetText = () => LobbyUtils.DescriptiveIpAddress(ipAddress);
|
||||
location.GetText = () => LobbyUtils.LookupCountry(ipAddress);
|
||||
var cachedDescriptiveIP = LobbyUtils.DescriptiveIpAddress(ipAddress);
|
||||
ip.GetText = () => cachedDescriptiveIP;
|
||||
var cachedCountryLookup = LobbyUtils.LookupCountry(ipAddress);
|
||||
location.GetText = () => cachedCountryLookup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +239,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
version.IsVisible = () => !game.CompatibleVersion();
|
||||
|
||||
var location = item.Get<LabelWidget>("LOCATION");
|
||||
location.GetText = () => LobbyUtils.LookupCountry(game.Address.Split(':')[0]);
|
||||
var cachedServerLocation = LobbyUtils.LookupCountry(game.Address.Split(':')[0]);
|
||||
location.GetText = () => cachedServerLocation;
|
||||
location.IsVisible = () => game.CompatibleVersion();
|
||||
|
||||
if (!canJoin)
|
||||
|
||||
Reference in New Issue
Block a user