don't crash map preview when the tileset can not be found

fixes #3033
This commit is contained in:
Matthias Mailänder
2013-12-05 19:14:00 +01:00
parent 6a0c0ae202
commit 147fb64185

View File

@@ -183,12 +183,16 @@ namespace OpenRA.Widgets
} }
} }
bool compatibleTileset;
void GeneratePreview() void GeneratePreview()
{ {
var m = Map(); var m = Map();
if (m == null) if (m == null)
return; return;
compatibleTileset = Rules.TileSets.Values.Any(t => t.Id == m.Tileset);
var status = Status(m); var status = Status(m);
if (status == PreviewStatus.Uncached) if (status == PreviewStatus.Uncached)
lock (syncRoot) lock (syncRoot)
@@ -201,7 +205,7 @@ namespace OpenRA.Widgets
} }
} }
static PreviewStatus Status(Map m) PreviewStatus Status(Map m)
{ {
if (m == null) if (m == null)
return PreviewStatus.Invalid; return PreviewStatus.Invalid;
@@ -213,6 +217,9 @@ namespace OpenRA.Widgets
if (cacheUids.Contains(m.Uid)) if (cacheUids.Contains(m.Uid))
return PreviewStatus.Generating; return PreviewStatus.Generating;
if (!compatibleTileset)
return PreviewStatus.Invalid;
} }
return PreviewStatus.Uncached; return PreviewStatus.Uncached;
} }