diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index aeefcd8534..be44b976a0 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -515,34 +515,40 @@ namespace OpenRA var mod = Game.modData.Manifest.Mod; var dirPath = new[] { Platform.SupportDir, "maps", mod.Id }.Aggregate(Path.Combine); var tempFile = Path.Combine(dirPath, Path.GetRandomFileName()); - try + if (!Directory.Exists(dirPath)) + Directory.CreateDirectory(dirPath); + foreach (var MapRepository in Game.Settings.Game.MapRepositories) { - if (!Directory.Exists(dirPath)) - Directory.CreateDirectory(dirPath); - var url = Game.Settings.Game.MapRepository + mapHash; + try + { + var url = MapRepository + mapHash; - var request = WebRequest.Create(url); - request.Method = "HEAD"; - var res = request.GetResponse(); + var request = WebRequest.Create(url); + request.Method = "HEAD"; + var res = request.GetResponse(); - var mapPath = Path.Combine(dirPath, res.Headers["Content-Disposition"].Replace("attachment; filename = ", "")); - Console.Write("Trying to download map to {0} ... ".F(mapPath)); + if (res.Headers["Content-Disposition"] == null) + continue; + var mapPath = Path.Combine(dirPath, res.Headers ["Content-Disposition"].Replace("attachment; filename = ", "")); + Log.Write("debug", "Trying to download map to '{0}' using {1}", mapPath, MapRepository); - WebClient webClient = new WebClient(); - webClient.DownloadFile(url, tempFile); - File.Move(tempFile, mapPath); - Game.modData.AvailableMaps.Add(mapHash, new Map(mapPath)); - Console.WriteLine("done"); + WebClient webClient = new WebClient(); + webClient.DownloadFile(url, tempFile); + File.Move(tempFile, mapPath); + Game.modData.AvailableMaps.Add(mapHash, new Map(mapPath)); + Log.Write("debug", "New map has been downloaded to '{0}'", mapPath); - return true; - } - catch (WebException e) - { - Log.Write("debug", "Could not download map '{0}'", mapHash); - Log.Write("debug", e.ToString()); - File.Delete(tempFile); - return false; + return true; + } + catch (WebException e) + { + Log.Write("debug", "Could not download map '{0}' using {1}", mapHash, MapRepository); + Log.Write("debug", e.ToString()); + File.Delete(tempFile); + continue; + } } + return false; } } } diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index c7f67567df..15bf950ebf 100644 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -139,7 +139,7 @@ namespace OpenRA.GameRules public int Timestep = 40; public bool AllowDownloading = true; - public string MapRepository = "http://content.open-ra.org/map/"; + public string[] MapRepositories = { "http://resource.openra.net/map/", "http://resource.ihptru.net:8080/map/" }; } public class KeySettings