git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1102 993157c7-ee19-0410-b2c4-bb4e9862e678

This commit is contained in:
bob
2007-07-05 11:38:48 +00:00
parent 6a188a1091
commit 866b45d3a7
5 changed files with 102 additions and 26 deletions

View File

@@ -17,6 +17,7 @@ namespace OpenRa.FileFormats
public readonly int Height;
public readonly TileReference[ , ] MapTiles = new TileReference[ 128, 128 ];
public readonly List<TreeReference> Trees = new List<TreeReference>();
public Map( IniFile file )
{
@@ -35,6 +36,8 @@ namespace OpenRa.FileFormats
MemoryStream ms = ReadMapPack( file );
UnpackTileData( ms );
ReadTrees( file );
}
static MemoryStream ReadMapPack( IniFile file )
@@ -104,6 +107,16 @@ namespace OpenRa.FileFormats
for( int j = 0 ; j < 128 ; j++ )
MapTiles[ j, i ].image = ReadByte( ms );
}
void ReadTrees( IniFile file )
{
IniSection terrain = file.GetSection( "TERRAIN" );
foreach( KeyValuePair<string, string> kv in terrain )
{
int xy = int.Parse( kv.Key );
Trees.Add( new TreeReference( xy % 128, xy / 128, kv.Value ) );
}
}
}
public struct TileReference
@@ -111,4 +124,18 @@ namespace OpenRa.FileFormats
public ushort tile;
public byte image;
}
public struct TreeReference
{
public readonly int X;
public readonly int Y;
public readonly string Image;
public TreeReference( int x, int y, string image )
{
X = x;
Y = y;
Image = image;
}
}
}