Split tileset artwork loading out of TileSet.

This simplifies terrain loading and allows for
non-square tiles in game.

The editor still relies on the old code for now.
This commit is contained in:
Paul Chote
2013-08-14 20:28:41 +12:00
parent 2b6b212d02
commit 387ac04d9f
7 changed files with 122 additions and 90 deletions

View File

@@ -16,16 +16,15 @@ namespace OpenRA.FileFormats
public class Terrain
{
public readonly List<byte[]> TileBitmapBytes = new List<byte[]>();
public readonly int Width;
public readonly int Height;
public Terrain( Stream stream, int size )
public Terrain(Stream stream)
{
// Try loading as a cnc .tem
BinaryReader reader = new BinaryReader( stream );
int Width = reader.ReadUInt16();
int Height = reader.ReadUInt16();
if( Width != size || Height != size )
throw new InvalidDataException( "{0}x{1} != {2}x{2}".F(Width, Height, size ) );
Width = reader.ReadUInt16();
Height = reader.ReadUInt16();
/*NumTiles = */reader.ReadUInt16();
/*Zero1 = */reader.ReadUInt16();
@@ -65,8 +64,8 @@ namespace OpenRA.FileFormats
{
if (b != 255)
{
stream.Position = ImgStart + b * size * size;
TileBitmapBytes.Add(new BinaryReader(stream).ReadBytes(size * size));
stream.Position = ImgStart + b * Width * Height;
TileBitmapBytes.Add(new BinaryReader(stream).ReadBytes(Width * Height));
}
else
TileBitmapBytes.Add(null);