Require GeoLite2 database path to be specified by the server operator.

This commit is contained in:
Paul Chote
2020-01-12 10:48:43 +00:00
committed by abcdefg30
parent 8dda6d8e3d
commit c430884c8b
2 changed files with 6 additions and 2 deletions

View File

@@ -97,6 +97,9 @@ namespace OpenRA.Network
/// <summary>URL to a 32x32 px icon for the mod.</summary> /// <summary>URL to a 32x32 px icon for the mod.</summary>
public readonly string ModIcon32 = ""; public readonly string ModIcon32 = "";
/// <summary>GeoIP resolved server location.</summary>
public readonly string Location = "";
/// <summary>Password protected</summary> /// <summary>Password protected</summary>
public readonly bool Protected = false; public readonly bool Protected = false;

View File

@@ -370,6 +370,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (addressNode != null) if (addressNode != null)
addressNode.Value.Value = bl.Address.ToString().Split(':')[0] + ":" + addressNode.Value.Value.Split(':')[1]; addressNode.Value.Value = bl.Address.ToString().Split(':')[0] + ":" + addressNode.Value.Value.Split(':')[1];
game.Nodes.Add(new MiniYamlNode("Location", "Local Network"));
lanGames.Add(new GameServer(game)); lanGames.Add(new GameServer(game));
} }
} }
@@ -658,8 +660,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (location != null) if (location != null)
{ {
var font = Game.Renderer.Fonts[location.Font]; var font = Game.Renderer.Fonts[location.Font];
var cachedServerLocation = game.Id != -1 ? GeoIP.LookupCountry(game.Address.Split(':')[0]) : "Local Network"; var label = WidgetUtils.TruncateText(game.Location, location.Bounds.Width, font);
var label = WidgetUtils.TruncateText(cachedServerLocation, location.Bounds.Width, font);
location.GetText = () => label; location.GetText = () => label;
location.GetColor = () => canJoin ? location.TextColor : incompatibleGameColor; location.GetColor = () => canJoin ? location.TextColor : incompatibleGameColor;
} }