From 748b37ede77bd86e4ba8668d2a87e531e77a2452 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Tue, 28 Apr 2015 20:51:41 +0100 Subject: [PATCH] Ensure we never return a null string from LookupCountry. --- OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index 0f3731f979..cc61b42482 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -237,14 +237,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic public static string LookupCountry(string ip) { + const string Unknown = "Unknown Location"; + try { - return Game.GeoIpDatabase.Country(ip).Country.Name; + return Game.GeoIpDatabase.Country(ip).Country.Name ?? Unknown; } catch (Exception e) { Log.Write("geoip", "LookupCountry failed: {0}", e); - return "Unknown Location"; + return Unknown; } }