Move initial map suitability calculation to MapCache.
This was previously trying to use values that had not yet been initialised, which meant that *all* maps were treated as unsuitable. This would cause the mod to always fall back to the first installed map.
This commit is contained in:
@@ -243,11 +243,31 @@ namespace OpenRA
|
||||
});
|
||||
}
|
||||
|
||||
bool IsSuitableInitialMap(MapPreview map)
|
||||
{
|
||||
if (map.Status != MapStatus.Available || !map.Visibility.HasFlag(MapVisibility.Lobby))
|
||||
return false;
|
||||
|
||||
// Other map types may have confusing settings or gameplay
|
||||
if (!map.Categories.Contains("Conquest"))
|
||||
return false;
|
||||
|
||||
// Maps with bots disabled confuse new players
|
||||
if (map.Players.Players.Any(x => !x.Value.AllowBots))
|
||||
return false;
|
||||
|
||||
// Large maps expose unfortunate performance problems
|
||||
if (map.Bounds.Width > 128 || map.Bounds.Height > 128)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public string ChooseInitialMap(string initialUid, MersenneTwister random)
|
||||
{
|
||||
if (string.IsNullOrEmpty(initialUid) || previews[initialUid].Status != MapStatus.Available)
|
||||
{
|
||||
var selected = previews.Values.Where(x => x.SuitableForInitialMap).RandomOrDefault(random) ??
|
||||
var selected = previews.Values.Where(IsSuitableInitialMap).RandomOrDefault(random) ??
|
||||
previews.Values.First(m => m.Status == MapStatus.Available && m.Visibility.HasFlag(MapVisibility.Lobby));
|
||||
return selected.Uid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user