git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1305 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -62,9 +62,7 @@ namespace OpenRa.FileFormats
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] data = Convert.FromBase64String(sb.ToString());
|
byte[] data = Convert.FromBase64String(sb.ToString());
|
||||||
|
|
||||||
List<byte[]> chunks = new List<byte[]>();
|
List<byte[]> chunks = new List<byte[]>();
|
||||||
|
|
||||||
BinaryReader reader = new BinaryReader(new MemoryStream(data));
|
BinaryReader reader = new BinaryReader(new MemoryStream(data));
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -99,14 +97,19 @@ namespace OpenRa.FileFormats
|
|||||||
return (byte)ret;
|
return (byte)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ushort ReadWord(Stream s)
|
||||||
|
{
|
||||||
|
ushort ret = ReadByte(s);
|
||||||
|
ret |= (ushort)(ReadByte(s) << 8);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void UnpackTileData( MemoryStream ms )
|
void UnpackTileData( MemoryStream ms )
|
||||||
{
|
{
|
||||||
for( int i = 0 ; i < 128 ; i++ )
|
for( int i = 0 ; i < 128 ; i++ )
|
||||||
for( int j = 0 ; j < 128 ; j++ )
|
for( int j = 0 ; j < 128 ; j++ )
|
||||||
{
|
MapTiles[j, i].tile = ReadWord(ms);
|
||||||
MapTiles[ j, i ].tile = ReadByte( ms );
|
|
||||||
MapTiles[ j, i ].tile |= (ushort)( ReadByte( ms ) << 8 );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( int i = 0 ; i < 128 ; i++ )
|
for( int i = 0 ; i < 128 ; i++ )
|
||||||
for( int j = 0 ; j < 128 ; j++ )
|
for( int j = 0 ; j < 128 ; j++ )
|
||||||
@@ -132,40 +135,4 @@ namespace OpenRa.FileFormats
|
|||||||
return (x >= XOffset && y >= YOffset && x < XOffset + Width && y < YOffset + Height);
|
return (x >= XOffset && y >= YOffset && x < XOffset + Width && y < YOffset + Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct TileReference
|
|
||||||
{
|
|
||||||
public ushort tile;
|
|
||||||
public byte image;
|
|
||||||
|
|
||||||
public override int GetHashCode() { return tile.GetHashCode() ^ image.GetHashCode(); }
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
TileReference r = (TileReference)obj;
|
|
||||||
return (r.image == image && r.tile == tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(TileReference a, TileReference b) { return a.Equals(b); }
|
|
||||||
public static bool operator !=(TileReference a, TileReference b) { return !a.Equals(b); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct TreeReference
|
|
||||||
{
|
|
||||||
public readonly int X;
|
|
||||||
public readonly int Y;
|
|
||||||
public readonly string Image;
|
|
||||||
|
|
||||||
public TreeReference(int xy, string image)
|
|
||||||
{
|
|
||||||
X = xy % 128;
|
|
||||||
Y = xy / 128;
|
|
||||||
Image = image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point Location { get { return new Point(X, Y); } }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,9 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ShpReader.cs" />
|
<Compile Include="ShpReader.cs" />
|
||||||
<Compile Include="Terrain.cs" />
|
<Compile Include="Terrain.cs" />
|
||||||
|
<Compile Include="TileReference.cs" />
|
||||||
<Compile Include="TileSet.cs" />
|
<Compile Include="TileSet.cs" />
|
||||||
|
<Compile Include="TreeReference.cs" />
|
||||||
<Compile Include="Walkability.cs" />
|
<Compile Include="Walkability.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
|||||||
26
OpenRa.FileFormats/TileReference.cs
Normal file
26
OpenRa.FileFormats/TileReference.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenRa.FileFormats
|
||||||
|
{
|
||||||
|
public struct TileReference
|
||||||
|
{
|
||||||
|
public ushort tile;
|
||||||
|
public byte image;
|
||||||
|
|
||||||
|
public override int GetHashCode() { return tile.GetHashCode() ^ image.GetHashCode(); }
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TileReference r = (TileReference)obj;
|
||||||
|
return (r.image == image && r.tile == tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(TileReference a, TileReference b) { return a.Equals(b); }
|
||||||
|
public static bool operator !=(TileReference a, TileReference b) { return !a.Equals(b); }
|
||||||
|
}
|
||||||
|
}
|
||||||
23
OpenRa.FileFormats/TreeReference.cs
Normal file
23
OpenRa.FileFormats/TreeReference.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace OpenRa.FileFormats
|
||||||
|
{
|
||||||
|
public struct TreeReference
|
||||||
|
{
|
||||||
|
public readonly int X;
|
||||||
|
public readonly int Y;
|
||||||
|
public readonly string Image;
|
||||||
|
|
||||||
|
public TreeReference(int xy, string image)
|
||||||
|
{
|
||||||
|
X = xy % 128;
|
||||||
|
Y = xy / 128;
|
||||||
|
Image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point Location { get { return new Point(X, Y); } }
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user