Merge pull request #4276 from pchote/initial-map

Improved automatic map selection.
This commit is contained in:
Matthias Mailänder
2013-12-09 14:22:47 -08:00
2 changed files with 27 additions and 1 deletions

View File

@@ -229,7 +229,31 @@ namespace OpenRA.Widgets
{
var availableMaps = Game.modData.AvailableMaps;
if (string.IsNullOrEmpty(map) || !availableMaps.ContainsKey(map))
return availableMaps.First(m => m.Value.Selectable).Key;
{
Func<Map, bool> isIdealMap = m =>
{
if (!m.Selectable)
return false;
// Other map types may have confusing settings or gameplay
if (m.Type != "Conquest")
return false;
// Maps with bots disabled confuse new players
if (m.Players.Any(s => !s.Value.AllowBots))
return false;
// Large maps expose unfortunate performance problems
if (m.MapSize.X > 128 || m.MapSize.Y > 128)
return false;
return true;
};
var selected = availableMaps.Values.Where(m => isIdealMap(m)).RandomOrDefault(Game.CosmeticRandom) ??
availableMaps.Values.First(m => m.Selectable);
return selected.Uid;
}
return map;
}

View File

@@ -139,6 +139,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
void StartSkirmishGame()
{
var map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
Game.Settings.Server.Map = map;
Game.Settings.Save();
ConnectionLogic.Connect(IPAddress.Loopback.ToString(),
Game.CreateLocalServer(map),