Merge pull request #7731 from pchote/ts-tileset-fixes

Fix TS/RA2 tileset importer and apply correctness fixes to TS temperate.
This commit is contained in:
Matthias Mailänder
2015-03-26 22:13:31 +01:00
3 changed files with 646 additions and 638 deletions

View File

@@ -282,7 +282,10 @@ namespace OpenRA
public TerrainTileInfo GetTileInfo(TerrainTile r)
{
var tpl = Templates[r.Type];
TerrainTemplateInfo tpl;
if (!Templates.TryGetValue(r.Type, out tpl))
return null;
return tpl.Contains(r.Index) ? tpl[r.Index] : null;
}

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.TS.UtilityCommands
{
public string Name { get { return "--tileset-import"; } }
[Desc("FILENAME", "Convert a legacy tileset to the OpenRA format.")]
[Desc("FILENAME", "TEMPLATEEXTENSION", "Convert a legacy tileset to the OpenRA format.")]
public void Run(ModData modData, string[] args)
{
// HACK: The engine code assumes that Game.modData is set.
@@ -30,23 +30,28 @@ namespace OpenRA.Mods.TS.UtilityCommands
GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest);
var file = new IniFile(File.Open(args[1], FileMode.Open));
var extension = args[2];
var templateIndex = 0;
var extension = "tem";
var terrainTypes = new Dictionary<int, string>()
var terrainTypes = new string[]
{
{ 1, "Clear" }, // Desert sand(?)
{ 5, "Road" }, // Paved road
{ 6, "Rail" }, // Monorail track
{ 7, "Impassable" }, // Building
{ 9, "Water" }, // Deep water(?)
{ 10, "Water" }, // Shallow water
{ 11, "Road" }, // Paved road (again?)
{ 12, "DirtRoad" }, // Dirt road
{ 13, "Clear" }, // Regular clear terrain
{ 14, "Rough" }, // Rough terrain (cracks etc)
{ 15, "Cliff" }, // Cliffs
"Clear",
"Clear", // Note: sometimes "Ice"
"Ice",
"Ice",
"Ice",
"Road", // TS defines this as "Tunnel", but we don't need this
"Rail",
"Impassable", // TS defines this as "Rock", but also uses it for buildings
"Impassable",
"Water",
"Water", // TS defines this as "Beach", but uses it for water...?
"Road",
"DirtRoad", // TS defines this as "Road", but we may want different speeds
"Clear",
"Rough",
"Cliff" // TS defines this as "Rock"
};
// Loop over template sets
@@ -72,7 +77,7 @@ namespace OpenRA.Mods.TS.UtilityCommands
Console.WriteLine("\tTemplate@{0}:", templateIndex);
Console.WriteLine("\t\tCategory: {0}", sectionCategory);
Console.WriteLine("\t\tId: {0}", templateIndex);
Console.WriteLine("\t\tImage: {0}{1:D2}", sectionFilename, i);
Console.WriteLine("\t\tImage: {0}{1:D2}.{2}", sectionFilename, i, extension);
var templateWidth = s.ReadUInt32();
var templateHeight = s.ReadUInt32();
@@ -95,7 +100,7 @@ namespace OpenRA.Mods.TS.UtilityCommands
var terrainType = s.ReadUInt8();
var rampType = s.ReadUInt8();
if (!terrainTypes.ContainsKey(terrainType))
if (terrainType >= terrainTypes.Length)
throw new InvalidDataException("Unknown terrain type {0} in {1}".F(terrainType, templateFilename));
Console.WriteLine("\t\t\t{0}: {1}", j, terrainTypes[terrainType]);
@@ -105,8 +110,8 @@ namespace OpenRA.Mods.TS.UtilityCommands
if (rampType != 0)
Console.WriteLine("\t\t\t\tRampType: {0}", rampType);
Console.WriteLine("\t\t\t\tMinimapLeftColor: {0},{1},{2}", s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8());
Console.WriteLine("\t\t\t\tMinimapRightColor: {0},{1},{2}", s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8());
Console.WriteLine("\t\t\t\tLeftColor: {0},{1},{2}", s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8());
Console.WriteLine("\t\t\t\tRightColor: {0},{1},{2}", s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8());
}
}
}

File diff suppressed because it is too large Load Diff