fix more broken templates

This commit is contained in:
Chris Forbes
2010-05-10 21:28:31 +12:00
parent f16986e308
commit a64e17edc5
2 changed files with 14 additions and 3 deletions

View File

@@ -59,17 +59,22 @@ namespace OpenRA.FileFormats
foreach (var section in file.Sections) foreach (var section in file.Sections)
{ {
var name = section.GetValue("Name", null).ToLowerInvariant();
if (!section.Contains("width") || !section.Contains("height"))
throw new InvalidOperationException("no width/height for template `{0}`".F(name));
var tile = new TileTemplate var tile = new TileTemplate
{ {
Name = name,
Size = new int2( Size = new int2(
int.Parse(section.GetValue("width", "0")), int.Parse(section.GetValue("width", "--")),
int.Parse(section.GetValue("height", "0"))), int.Parse(section.GetValue("height", "--"))),
TerrainType = section TerrainType = section
.Where(p => p.Key.StartsWith("tiletype")) .Where(p => p.Key.StartsWith("tiletype"))
.ToDictionary( .ToDictionary(
p => int.Parse(p.Key.Substring(8)), p => int.Parse(p.Key.Substring(8)),
p => (TerrainType)Enum.Parse(typeof(TerrainType),p.Value)), p => (TerrainType)Enum.Parse(typeof(TerrainType),p.Value)),
Name = section.GetValue("Name", null).ToLowerInvariant(),
Bridge = section.GetValue("bridge", null), Bridge = section.GetValue("bridge", null),
HP = float.Parse(section.GetValue("hp", "0")) HP = float.Parse(section.GetValue("hp", "0"))
}; };

View File

@@ -2482,10 +2482,14 @@ tiletype1=3
[TEM227] [TEM227]
Name=D44 Name=D44
width=1
height=1
tiletype0=2 tiletype0=2
[TEM228] [TEM228]
Name=D45 Name=D45
width=1
height=1
tiletype0=2 tiletype0=2
[TEM229] [TEM229]
@@ -2797,6 +2801,8 @@ tiletype8=0
[TEM255] [TEM255]
Name=CLEAR1 Name=CLEAR1
width=1
height=1
tiletype0=0 tiletype0=0
tiletype1=0 tiletype1=0
tiletype2=0 tiletype2=0