Populate MapLocations from LoadMaps.

This ensures that the map locations won't be created by the utility
but means that LoadMaps must be called before attempting to use MapLocations.
This commit is contained in:
Paul Chote
2017-09-25 21:31:20 +01:00
committed by Matthias Mailänder
parent 64afe4cfde
commit a1347a7f32

View File

@@ -28,6 +28,7 @@ namespace OpenRA
{ {
public static readonly MapPreview UnknownMap = new MapPreview(null, null, MapGridType.Rectangular, null); public static readonly MapPreview UnknownMap = new MapPreview(null, null, MapGridType.Rectangular, null);
public readonly IReadOnlyDictionary<IReadOnlyPackage, MapClassification> MapLocations; public readonly IReadOnlyDictionary<IReadOnlyPackage, MapClassification> MapLocations;
readonly Dictionary<IReadOnlyPackage, MapClassification> mapLocations = new Dictionary<IReadOnlyPackage, MapClassification>();
readonly Cache<string, MapPreview> previews; readonly Cache<string, MapPreview> previews;
readonly ModData modData; readonly ModData modData;
@@ -45,8 +46,16 @@ namespace OpenRA
previews = new Cache<string, MapPreview>(uid => new MapPreview(modData, uid, gridType.Value, this)); previews = new Cache<string, MapPreview>(uid => new MapPreview(modData, uid, gridType.Value, this));
sheetBuilder = new SheetBuilder(SheetType.BGRA); sheetBuilder = new SheetBuilder(SheetType.BGRA);
MapLocations = new ReadOnlyDictionary<IReadOnlyPackage, MapClassification>(mapLocations);
}
public void LoadMaps()
{
// Utility mod that does not support maps
if (!modData.Manifest.Contains<MapGrid>())
return;
// Enumerate map directories // Enumerate map directories
var mapLocations = new Dictionary<IReadOnlyPackage, MapClassification>();
foreach (var kv in modData.Manifest.MapFolders) foreach (var kv in modData.Manifest.MapFolders)
{ {
var name = kv.Key; var name = kv.Key;
@@ -82,15 +91,6 @@ namespace OpenRA
mapLocations.Add(package, classification); mapLocations.Add(package, classification);
} }
MapLocations = new ReadOnlyDictionary<IReadOnlyPackage, MapClassification>(mapLocations);
}
public void LoadMaps()
{
// Utility mod that does not support maps
if (!modData.Manifest.Contains<MapGrid>())
return;
var mapGrid = modData.Manifest.Get<MapGrid>(); var mapGrid = modData.Manifest.Get<MapGrid>();
foreach (var kv in MapLocations) foreach (var kv in MapLocations)
{ {