Make the legacy editor more robust against invalid templates.
This commit is contained in:
@@ -41,7 +41,7 @@ namespace OpenRA.Editor
|
||||
if (surface.Map.Contains(cell))
|
||||
{
|
||||
var z = u + v * template.Size.X;
|
||||
if (tile[z].Length > 0)
|
||||
if (tile != null && tile[z].Length > 0)
|
||||
{
|
||||
var index = template.PickAny ? (byte)((u + pos.X) % 4 + ((v + pos.Y) % 4) * 4) : (byte)z;
|
||||
surface.Map.MapTiles.Value[cell] = new TerrainTile(brushTemplate.N, index);
|
||||
|
||||
@@ -275,6 +275,9 @@ namespace OpenRA.Editor
|
||||
var vj = v * ChunkSize + j;
|
||||
var tr = Map.MapTiles.Value[ui, vj];
|
||||
var tile = TileSetRenderer.Data(tr.Type);
|
||||
if (tile == null)
|
||||
continue;
|
||||
|
||||
var index = (tr.Index < tile.Length) ? tr.Index : (byte)0;
|
||||
var rawImage = tile[index];
|
||||
for (var x = 0; x < TileSetRenderer.TileSize; x++)
|
||||
|
||||
@@ -104,7 +104,14 @@ namespace OpenRA.Editor
|
||||
|
||||
public byte[][] Data(ushort id)
|
||||
{
|
||||
return templates[id];
|
||||
byte[][] template;
|
||||
if (!templates.TryGetValue(id, out template))
|
||||
{
|
||||
Console.WriteLine("warning: Unknown tile template {0}", id);
|
||||
return null;
|
||||
}
|
||||
|
||||
return template;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user