Server.TileMatrixPatch.PatchLand C# (CSharp) Method

PatchLand() private method

private PatchLand ( Server.TileMatrix matrix, string dataPath, string indexPath ) : int
matrix Server.TileMatrix
dataPath string
indexPath string
return int
		private unsafe int PatchLand( TileMatrix matrix, string dataPath, string indexPath )
		{
			using ( FileStream fsData = new FileStream( dataPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
			{
				using ( FileStream fsIndex = new FileStream( indexPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
				{
					BinaryReader indexReader = new BinaryReader( fsIndex );

					int count = (int)(indexReader.BaseStream.Length / 4);

					for ( int i = 0; i < count; ++i )
					{
						int blockID = indexReader.ReadInt32();
						int x = blockID / matrix.BlockHeight;
						int y = blockID % matrix.BlockHeight;

						fsData.Seek( 4, SeekOrigin.Current );

						LandTile[] tiles = new LandTile[64];

						fixed ( LandTile *pTiles = tiles )
						{
							NativeReader.Read( fsData.SafeFileHandle.DangerousGetHandle(), pTiles, 192 );
						}

						matrix.SetLandBlock( x, y, tiles );
					}
					
					indexReader.Close();

					return count;
				}
			}
		}