Exemplo n.º 1
0
        private unsafe int PatchLand(TileMatrix matrix, string dataPath, string indexPath)
        {
            using var fsData      = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read);
            using var fsIndex     = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read);
            using var indexReader = new BinaryReader(fsIndex);

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

            for (var i = 0; i < count; i++)
            {
                var blockID = indexReader.ReadInt32();
                var x       = Math.DivRem(blockID, matrix.BlockHeight, out var y);

                fsData.Seek(4, SeekOrigin.Current);

                var tiles = new LandTile[64];
                fixed(LandTile *pTiles = tiles)
                {
                    fsData.Read(new Span <byte>(pTiles, 192));
                }

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

            return(count);
        }
Exemplo n.º 2
0
        private unsafe int PatchLand(TileMatrix matrix, string dataPath, string indexPath)
        {
            using var fsData  = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read);
            using var fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read);
            var indexReader = new BinaryReader(fsIndex);

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

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

                fsData.Seek(4, SeekOrigin.Current);

                var tiles = new LandTile[64];

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

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

            indexReader.Close();

            return(count);
        }
Exemplo n.º 3
0
        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);

                        Tile[] tiles = new Tile[64];

                        fixed(Tile *pTiles = tiles)
                        {
#if !MONO
                            _lread(fsData.SafeFileHandle.DangerousGetHandle(), pTiles, 192);
#else
                            if (m_Buffer == null || 192 > m_Buffer.Length)
                            {
                                m_Buffer = new byte[192];
                            }

                            fsData.Read(m_Buffer, 0, 192);

                            fixed(byte *pbBuffer = m_Buffer)
                            {
                                Tile *pBuffer = (Tile *)pbBuffer;
                                Tile *pEnd    = pBuffer + 64;
                                Tile *pCur    = pTiles;

                                while (pBuffer < pEnd)
                                {
                                    *pCur++ = *pBuffer++;
                                }
                            }
#endif
                        }

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

                    indexReader.Close();

                    return(count);
                }
            }
        }
Exemplo n.º 4
0
        private 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);

                        Tile[] tiles = new Tile[64];

                        GCHandle handle = GCHandle.Alloc(tiles, GCHandleType.Pinned);
                        try {
                            if (m_Buffer == null || 192 > m_Buffer.Length)
                            {
                                m_Buffer = new byte[192];
                            }

                            fsData.Read(m_Buffer, 0, 192);

                            Marshal.Copy(m_Buffer, 0, handle.AddrOfPinnedObject(), 192);
                        } finally {
                            handle.Free();
                        }

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

                    indexReader.Close();

                    return(count);
                }
            }
        }
        private int PatchLand(TileMatrix matrix, string dataPath, string indexPath)
        {
            BinaryReader reader1;
            int          num1;
            int          num2;
            int          num3;
            int          num4;
            int          num5;

            Tile[] tileArray1;
            int    num6;

            using (FileStream stream1 = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (FileStream stream2 = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    reader1 = new BinaryReader(stream2);
                    num1    = ((int)(reader1.BaseStream.Length / 4));
                    for (num2 = 0; (num2 < num1); ++num2)
                    {
                        num3 = reader1.ReadInt32();
                        num4 = (num3 / matrix.BlockHeight);
                        num5 = (num3 % matrix.BlockHeight);
                        stream1.Seek(4, SeekOrigin.Current);
                        tileArray1 = new Tile[64];
                        try
                        {
                            fixed(Tile *local1 = tileArray1)
                            {
                            }
                            TileMatrixPatch._lread(stream1.Handle, ((void *)local1), 192);
                        }
                        finally
                        {
                            local1 = ((pinned ref Tile)IntPtr.Zero);
                        }
                        matrix.SetLandBlock(num4, num5, tileArray1);
                    }
                    return(num1);
                }
            }
            return(num6);
        }
Exemplo n.º 6
0
        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);

                        Tile[] tiles = new Tile[64];

                        fixed(Tile *pTiles = tiles)
                        {
                            if (m_Buffer == null || 192 > m_Buffer.Length)
                            {
                                m_Buffer = new byte[192];
                            }

                            fsData.Read(m_Buffer, 0, 192);

                            Marshal.Copy(m_Buffer, 0, new IntPtr(pTiles), 192);
                        }

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

                    indexReader.Close();

                    return(count);
                }
            }
        }
Exemplo n.º 7
0
        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)
                        {
#if !MONO
                            NativeReader.Read(fsData.SafeFileHandle.DangerousGetHandle(), pTiles, 192);
#else
                            NativeReader.Read(fsData.SafeFileHandle.DangerousGetHandle(), pTiles, 192);
//							NativeReader.Read( fsData.Handle, pTiles, 192 );
#endif
                        }

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

                    indexReader.Close();

                    return(count);
                }
            }
        }
Exemplo n.º 8
0
		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 )
						{
#if !MONO
							NativeReader.Read( fsData.SafeFileHandle.DangerousGetHandle(), pTiles, 192 );
#else
							NativeReader.Read( fsData.Handle, pTiles, 192 );
#endif
						}

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

					return count;
				}
			}
		}
		private 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 );

						Tile[] tiles = new Tile[64];

						GCHandle handle = GCHandle.Alloc(tiles, GCHandleType.Pinned);
						try {
							if ( m_Buffer == null || 192 > m_Buffer.Length )
								m_Buffer = new byte[192];

							fsData.Read( m_Buffer, 0, 192 );

							Marshal.Copy(m_Buffer, 0, handle.AddrOfPinnedObject(), 192);
						} finally {
							handle.Free();
						}

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

					indexReader.Close();

					return count;
				}
			}
		}
Exemplo n.º 10
0
        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 );

                        Tile[] tiles = new Tile[64];

                        fixed ( Tile *pTiles = tiles )
                        {
                            if ( m_Buffer == null || 192 > m_Buffer.Length )
                                m_Buffer = new byte[192];

                            fsData.Read( m_Buffer, 0, 192 );

                            Marshal.Copy(m_Buffer, 0, new IntPtr(pTiles), 192);
                        }

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

                    indexReader.Close();

                    return count;
                }
            }
        }
Exemplo n.º 11
0
		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);

						Tile[] tiles = new Tile[64];

						fixed (Tile* pTiles = tiles)
						{
#if !MONO
							_lread(fsData.Handle, pTiles, 192);
#else
							if ( m_Buffer == null || 192 > m_Buffer.Length )
								m_Buffer = new byte[192];

							fsData.Read( m_Buffer, 0, 192 );

							fixed ( byte *pbBuffer = m_Buffer )
							{
								Tile *pBuffer = (Tile *)pbBuffer;
								Tile *pEnd = pBuffer + 64;
								Tile *pCur = pTiles;

								while ( pBuffer < pEnd )
									*pCur++ = *pBuffer++;
							}
#endif
						}

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

					indexReader.Close();

					return count;
				}
			}
		}