Server.Statics.ReadStaticBlock C# (CSharp) Method

ReadStaticBlock() private static method

private static ReadStaticBlock ( BinaryReader idxReader, FileStream mulStream, int x, int y, int width, int height, int &count ) : Server.StaticTile[]
idxReader System.IO.BinaryReader
mulStream System.IO.FileStream
x int
y int
width int
height int
count int
return Server.StaticTile[]
		private static StaticTile[] ReadStaticBlock( BinaryReader idxReader, FileStream mulStream, int x, int y, int width, int height, out int count )
		{
			try
			{
				if ( x < 0 || x >= width || y < 0 || y >= height )
				{
					count = -1;
					return m_TileBuffer;
				}

				idxReader.BaseStream.Seek( ((x * height) + y) * 12, SeekOrigin.Begin );

				int lookup = idxReader.ReadInt32();
				int length = idxReader.ReadInt32();

				if ( lookup < 0 || length <= 0 )
				{
					count = 0;
				}
				else
				{
					count = length / 7;

					mulStream.Seek( lookup, SeekOrigin.Begin );

					if ( m_TileBuffer.Length < count )
						m_TileBuffer = new StaticTile[count];

					StaticTile[] staTiles = m_TileBuffer;

					if ( m_Buffer == null || length > m_Buffer.Length )
						m_Buffer = new byte[length];

					mulStream.Read( m_Buffer, 0, length );

					int index = 0;

					for ( int i = 0; i < count; ++i )
					{
						staTiles[i].Set((ushort)(m_Buffer[index++] | (m_Buffer[index++] << 8)),
								(byte)m_Buffer[index++], (byte)m_Buffer[index++], (sbyte)m_Buffer[index++],
								(short)(m_Buffer[index++] | (m_Buffer[index++] << 8)));
					}
				}
			}
			catch
			{
				count = -1;
			}

			return m_TileBuffer;
		}