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:
@@ -282,7 +282,10 @@ namespace OpenRA
|
|||||||
|
|
||||||
public TerrainTileInfo GetTileInfo(TerrainTile r)
|
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;
|
return tpl.Contains(r.Index) ? tpl[r.Index] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
{
|
{
|
||||||
public string Name { get { return "--tileset-import"; } }
|
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)
|
public void Run(ModData modData, string[] args)
|
||||||
{
|
{
|
||||||
// HACK: The engine code assumes that Game.modData is set.
|
// HACK: The engine code assumes that Game.modData is set.
|
||||||
@@ -30,23 +30,28 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest);
|
GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest);
|
||||||
|
|
||||||
var file = new IniFile(File.Open(args[1], FileMode.Open));
|
var file = new IniFile(File.Open(args[1], FileMode.Open));
|
||||||
|
var extension = args[2];
|
||||||
|
|
||||||
var templateIndex = 0;
|
var templateIndex = 0;
|
||||||
var extension = "tem";
|
|
||||||
|
|
||||||
var terrainTypes = new Dictionary<int, string>()
|
var terrainTypes = new string[]
|
||||||
{
|
{
|
||||||
{ 1, "Clear" }, // Desert sand(?)
|
"Clear",
|
||||||
{ 5, "Road" }, // Paved road
|
"Clear", // Note: sometimes "Ice"
|
||||||
{ 6, "Rail" }, // Monorail track
|
"Ice",
|
||||||
{ 7, "Impassable" }, // Building
|
"Ice",
|
||||||
{ 9, "Water" }, // Deep water(?)
|
"Ice",
|
||||||
{ 10, "Water" }, // Shallow water
|
"Road", // TS defines this as "Tunnel", but we don't need this
|
||||||
{ 11, "Road" }, // Paved road (again?)
|
"Rail",
|
||||||
{ 12, "DirtRoad" }, // Dirt road
|
"Impassable", // TS defines this as "Rock", but also uses it for buildings
|
||||||
{ 13, "Clear" }, // Regular clear terrain
|
"Impassable",
|
||||||
{ 14, "Rough" }, // Rough terrain (cracks etc)
|
"Water",
|
||||||
{ 15, "Cliff" }, // Cliffs
|
"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
|
// Loop over template sets
|
||||||
@@ -72,7 +77,7 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
Console.WriteLine("\tTemplate@{0}:", templateIndex);
|
Console.WriteLine("\tTemplate@{0}:", templateIndex);
|
||||||
Console.WriteLine("\t\tCategory: {0}", sectionCategory);
|
Console.WriteLine("\t\tCategory: {0}", sectionCategory);
|
||||||
Console.WriteLine("\t\tId: {0}", templateIndex);
|
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 templateWidth = s.ReadUInt32();
|
||||||
var templateHeight = s.ReadUInt32();
|
var templateHeight = s.ReadUInt32();
|
||||||
@@ -95,7 +100,7 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
var terrainType = s.ReadUInt8();
|
var terrainType = s.ReadUInt8();
|
||||||
var rampType = 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));
|
throw new InvalidDataException("Unknown terrain type {0} in {1}".F(terrainType, templateFilename));
|
||||||
|
|
||||||
Console.WriteLine("\t\t\t{0}: {1}", j, terrainTypes[terrainType]);
|
Console.WriteLine("\t\t\t{0}: {1}", j, terrainTypes[terrainType]);
|
||||||
@@ -105,8 +110,8 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
if (rampType != 0)
|
if (rampType != 0)
|
||||||
Console.WriteLine("\t\t\t\tRampType: {0}", rampType);
|
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\tLeftColor: {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\tRightColor: {0},{1},{2}", s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user