public void Add(short id, short hue, sbyte z)
        {
            if (this.m_Count + 1 > (int)this.m_Tiles.Length)
            {
                HuedTile[] mTiles = this.m_Tiles;
                this.m_Tiles = new HuedTile[(int)mTiles.Length * 2];
                for (int i = 0; i < (int)mTiles.Length; i++)
                {
                    this.m_Tiles[i] = mTiles[i];
                }
            }
            HuedTile[]   huedTileArray = this.m_Tiles;
            HuedTileList huedTileList  = this;
            int          mCount        = huedTileList.m_Count;
            int          num           = mCount;

            huedTileList.m_Count = mCount + 1;
            huedTileArray[num].Set(id, hue, z);
        }
Пример #2
0
        private int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath)
        {
            using (
                FileStream fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read),
                fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read),
                fsLookup = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (BinaryReader indexReader = new BinaryReader(fsIndex), lookupReader = new BinaryReader(fsLookup))
                {
                    int count = Math.Min((int)(indexReader.BaseStream.Length / 4), (int)(lookupReader.BaseStream.Length / 12));

                    var lists = new HuedTileList[8][];

                    for (int x = 0; x < 8; ++x)
                    {
                        lists[x] = new HuedTileList[8];

                        for (int y = 0; y < 8; ++y)
                        {
                            lists[x][y] = new HuedTileList();
                        }
                    }

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

                        int offset = lookupReader.ReadInt32();
                        int length = lookupReader.ReadInt32();
                        lookupReader.ReadInt32(); // Extra

                        if (offset < 0 || length <= 0)
                        {
                            if (StaticBlocks[blockX] == null)
                            {
                                StaticBlocks[blockX] = new HuedTile[matrix.BlockHeight][][][];
                            }

                            StaticBlocks[blockX][blockY] = TileMatrix.EmptyStaticBlock;
                            continue;
                        }

                        fsData.Seek(offset, SeekOrigin.Begin);

                        int tileCount = length / 7;

                        if (m_TileBuffer.Length < tileCount)
                        {
                            m_TileBuffer = new StaticTile[tileCount];
                        }

                        StaticTile[] staTiles = m_TileBuffer;

                        GCHandle gc = GCHandle.Alloc(staTiles, GCHandleType.Pinned);
                        try
                        {
                            if (m_Buffer == null || m_Buffer.Length < length)
                            {
                                m_Buffer = new byte[length];
                            }

                            fsData.Read(m_Buffer, 0, length);

                            Marshal.Copy(m_Buffer, 0, gc.AddrOfPinnedObject(), length);

                            for (int j = 0; j < tileCount; ++j)
                            {
                                StaticTile cur = staTiles[j];
                                lists[cur.m_X & 0x7][cur.m_Y & 0x7].Add(Art.GetLegalItemID(cur.m_ID), cur.m_Hue, cur.m_Z);
                            }

                            var tiles = new HuedTile[8][][];

                            for (int x = 0; x < 8; ++x)
                            {
                                tiles[x] = new HuedTile[8][];

                                for (int y = 0; y < 8; ++y)
                                {
                                    tiles[x][y] = lists[x][y].ToArray();
                                }
                            }

                            if (StaticBlocks[blockX] == null)
                            {
                                StaticBlocks[blockX] = new HuedTile[matrix.BlockHeight][][][];
                            }

                            StaticBlocks[blockX][blockY] = tiles;
                        }
                        finally
                        {
                            gc.Free();
                        }
                    }

                    return(count);
                }
            }
        }
Пример #3
0
        private unsafe HuedTile[][][] ReadStaticBlock(int x, int y)
        {
            m_IndexReader.BaseStream.Seek(((x * m_BlockHeight) + y) * 12, SeekOrigin.Begin);

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

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

                m_Statics.Seek(lookup, SeekOrigin.Begin);

                StaticTile[] staTiles = new StaticTile[count];

                fixed(StaticTile *pTiles = staTiles)
                {
                    _lread(m_Statics.Handle, pTiles, length);

                    if (m_Lists == null)
                    {
                        m_Lists = new HuedTileList[8][];

                        for (int i = 0; i < 8; ++i)
                        {
                            m_Lists[i] = new HuedTileList[8];

                            for (int j = 0; j < 8; ++j)
                            {
                                m_Lists[i][j] = new HuedTileList();
                            }
                        }
                    }

                    HuedTileList[][] lists = m_Lists;

                    StaticTile *pCur = pTiles, pEnd = pTiles + count;

                    while (pCur < pEnd)
                    {
                        lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add((short)((pCur->m_ID & 0x3FFF) + 0x4000), pCur->m_Hue, pCur->m_Z);
                        ++pCur;
                    }

                    HuedTile[][][] tiles = new HuedTile[8][][];

                    for (int i = 0; i < 8; ++i)
                    {
                        tiles[i] = new HuedTile[8][];

                        for (int j = 0; j < 8; ++j)
                        {
                            tiles[i][j] = lists[i][j].ToArray();
                        }
                    }

                    return(tiles);
                }
            }
        }
Пример #4
0
        private unsafe int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath)
        {
            using (FileStream fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read),
                              fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read),
                              fsLookup = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (BinaryReader indexReader = new BinaryReader(fsIndex),
                                    lookupReader = new BinaryReader(fsLookup))
                {
                    int count = Math.Min((int)(indexReader.BaseStream.Length / 4),
                                        (int)(lookupReader.BaseStream.Length / 12));

                    HuedTileList[][] lists = new HuedTileList[8][];

                    for (int x = 0; x < 8; ++x)
                    {
                        lists[x] = new HuedTileList[8];

                        for (int y = 0; y < 8; ++y)
                            lists[x][y] = new HuedTileList();
                    }

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

                        int offset = lookupReader.ReadInt32();
                        int length = lookupReader.ReadInt32();
                        lookupReader.ReadInt32(); // Extra

                        if (offset < 0 || length <= 0)
                        {
                            if (StaticBlocks[blockX] == null)
                                StaticBlocks[blockX] = new HuedTile[matrix.BlockHeight][][][];

                            StaticBlocks[blockX][blockY] = TileMatrix.EmptyStaticBlock;
                            continue;
                        }

                        fsData.Seek(offset, SeekOrigin.Begin);

                        int tileCount = length / 7;

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

                        StaticTile[] staTiles = m_TileBuffer;

                        GCHandle gc = GCHandle.Alloc(staTiles, GCHandleType.Pinned);
                        try
                        {
                            if (m_Buffer == null || m_Buffer.Length < length)
                                m_Buffer = new byte[length];

                            fsData.Read(m_Buffer, 0, length);

                            Marshal.Copy(m_Buffer, 0, gc.AddrOfPinnedObject(), length);

                            for (int j = 0; j < tileCount; ++j)
                            {
                                StaticTile cur = staTiles[j];
                                lists[cur.m_X & 0x7][cur.m_Y & 0x7].Add(Art.GetLegalItemID(cur.m_ID), cur.m_Hue, cur.m_Z);
                            }

                            HuedTile[][][] tiles = new HuedTile[8][][];

                            for (int x = 0; x < 8; ++x)
                            {
                                tiles[x] = new HuedTile[8][];

                                for (int y = 0; y < 8; ++y)
                                    tiles[x][y] = lists[x][y].ToArray();
                            }

                            if (StaticBlocks[blockX] == null)
                                StaticBlocks[blockX] = new HuedTile[matrix.BlockHeight][][][];

                            StaticBlocks[blockX][blockY] = tiles;
                        }
                        finally
                        {
                            gc.Free();
                        }
                    }

                    return count;
                }
            }
        }
Пример #5
0
        private unsafe HuedTile[][][] ReadStaticBlock(int x, int y)
        {
            try
            {
                if (!StaticIndexInit)
                {
                    InitStatics();
                }
                if (m_Statics == null || !m_Statics.CanRead || !m_Statics.CanSeek)
                {
                    if (staticsPath == null)
                    {
                        m_Statics = null;
                    }
                    else
                    {
                        m_Statics = new FileStream(staticsPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    }
                }

                if (m_Statics == null)
                {
                    return(EmptyStaticBlock);
                }

                int lookup = m_StaticIndex[(x * BlockHeight) + y].lookup;
                int length = m_StaticIndex[(x * BlockHeight) + y].length;

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

                    m_Statics.Seek(lookup, SeekOrigin.Begin);

                    if (m_Buffer == null || m_Buffer.Length < length)
                    {
                        m_Buffer = new byte[length];
                    }

                    GCHandle gc = GCHandle.Alloc(m_Buffer, GCHandleType.Pinned);
                    try
                    {
                        m_Statics.Read(m_Buffer, 0, length);

                        if (m_Lists == null)
                        {
                            m_Lists = new HuedTileList[8][];

                            for (int i = 0; i < 8; ++i)
                            {
                                m_Lists[i] = new HuedTileList[8];

                                for (int j = 0; j < 8; ++j)
                                {
                                    m_Lists[i][j] = new HuedTileList();
                                }
                            }
                        }

                        HuedTileList[][] lists = m_Lists;

                        for (int i = 0; i < count; ++i)
                        {
                            IntPtr     ptr = new IntPtr((long)gc.AddrOfPinnedObject() + i * sizeof(StaticTile));
                            StaticTile cur = (StaticTile)Marshal.PtrToStructure(ptr, typeof(StaticTile));
                            lists[cur.m_X & 0x7][cur.m_Y & 0x7].Add(Art.GetLegalItemID(cur.m_ID), cur.m_Hue, cur.m_Z);
                        }

                        HuedTile[][][] tiles = new HuedTile[8][][];

                        for (int i = 0; i < 8; ++i)
                        {
                            tiles[i] = new HuedTile[8][];

                            for (int j = 0; j < 8; ++j)
                            {
                                tiles[i][j] = lists[i][j].ToArray();
                            }
                        }

                        return(tiles);
                    }
                    finally
                    {
                        gc.Free();
                    }
                }
            }
            finally
            {
                //if (m_Statics != null)
                //    m_Statics.Close();
            }
        }
Пример #6
0
        private unsafe HuedTile[][][] ReadStaticBlock(int x, int y)
        {
            if (!StaticIndexInit)
            {
                InitStatics();
            }

            if (_statics?.CanRead != true || !_statics.CanSeek)
            {
                _statics = _staticsPath == null
                    ? null
                    : new FileStream(_staticsPath, FileMode.Open, FileAccess.Read, FileShare.Read);
            }

            if (_statics == null)
            {
                return(EmptyStaticBlock);
            }

            int lookup = _staticIndex[(x * BlockHeight) + y].Lookup;
            int length = _staticIndex[(x * BlockHeight) + y].Length;

            if (lookup < 0 || length <= 0)
            {
                return(EmptyStaticBlock);
            }

            int count = length / 7;

            _statics.Seek(lookup, SeekOrigin.Begin);

            if (_buffer == null || _buffer.Length < length)
            {
                _buffer = new byte[length];
            }

            GCHandle gc = GCHandle.Alloc(_buffer, GCHandleType.Pinned);

            try
            {
                _statics.Read(_buffer, 0, length);

                if (_lists == null)
                {
                    _lists = new HuedTileList[8][];

                    for (int i = 0; i < 8; ++i)
                    {
                        _lists[i] = new HuedTileList[8];

                        for (int j = 0; j < 8; ++j)
                        {
                            _lists[i][j] = new HuedTileList();
                        }
                    }
                }

                HuedTileList[][] lists = _lists;

                for (int i = 0; i < count; ++i)
                {
                    var ptr = new IntPtr((long)gc.AddrOfPinnedObject() + (i * sizeof(StaticTile)));
                    var cur = (StaticTile)Marshal.PtrToStructure(ptr, typeof(StaticTile));
                    lists[cur.X & 0x7][cur.Y & 0x7].Add(Art.GetLegalItemID(cur.Id), cur.Hue, cur.Z);
                }

                var tiles = new HuedTile[8][][];

                for (int i = 0; i < 8; ++i)
                {
                    tiles[i] = new HuedTile[8][];

                    for (int j = 0; j < 8; ++j)
                    {
                        tiles[i][j] = lists[i][j].ToArray();
                    }
                }

                return(tiles);
            }
            finally
            {
                gc.Free();
            }
        }
Пример #7
0
        private unsafe int PatchStatics( TileMatrix matrix, string dataPath, string indexPath, string lookupPath )
        {
            using ( FileStream fsData = new FileStream( dataPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
            {
                using ( FileStream fsIndex = new FileStream( indexPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
                {
                    using ( FileStream fsLookup = new FileStream( lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
                    {
                        BinaryReader indexReader = new BinaryReader( fsIndex );
                        BinaryReader lookupReader = new BinaryReader( fsLookup );

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

                        HuedTileList[][] lists = new HuedTileList[8][];

                        for ( int x = 0; x < 8; ++x )
                        {
                            lists[x] = new HuedTileList[8];

                            for ( int y = 0; y < 8; ++y )
                                lists[x][y] = new HuedTileList();
                        }

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

                            int offset = lookupReader.ReadInt32();
                            int length = lookupReader.ReadInt32();
                            lookupReader.ReadInt32(); // Extra

                            if ( offset < 0 || length <= 0 )
                            {
                                matrix.SetStaticBlock( blockX, blockY, matrix.EmptyStaticBlock );
                                continue;
                            }

                            fsData.Seek( offset, SeekOrigin.Begin );

                            int tileCount = length / 7;

                            StaticTile[] staTiles = new StaticTile[tileCount];

                            fixed ( StaticTile *pTiles = staTiles )
                            {
                                _lread(fsData.SafeFileHandle, pTiles, length);

                                StaticTile *pCur = pTiles, pEnd = pTiles + tileCount;

                                while ( pCur < pEnd )
                                {
                                    lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( (short)((pCur->m_ID & 0x3FFF) + 0x4000), pCur->m_Hue, pCur->m_Z );
                                    ++pCur;
                                }

                                HuedTile[][][] tiles = new HuedTile[8][][];

                                for ( int x = 0; x < 8; ++x )
                                {
                                    tiles[x] = new HuedTile[8][];

                                    for ( int y = 0; y < 8; ++y )
                                        tiles[x][y] = lists[x][y].ToArray();
                                }

                                matrix.SetStaticBlock( blockX, blockY, tiles );
                            }
                        }

                        return count;
                    }
                }
            }
        }
Пример #8
0
        private unsafe int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath)
        {
            using (FileStream fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (FileStream fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (FileStream fsLookup = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        BinaryReader indexReader  = new BinaryReader(fsIndex);
                        BinaryReader lookupReader = new BinaryReader(fsLookup);

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

                        HuedTileList[][] lists = new HuedTileList[8][];

                        for (int x = 0; x < 8; ++x)
                        {
                            lists[x] = new HuedTileList[8];

                            for (int y = 0; y < 8; ++y)
                            {
                                lists[x][y] = new HuedTileList();
                            }
                        }

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

                            int offset = lookupReader.ReadInt32();
                            int length = lookupReader.ReadInt32();
                            lookupReader.ReadInt32();                             // Extra

                            if (offset < 0 || length <= 0)
                            {
                                matrix.SetStaticBlock(blockX, blockY, matrix.EmptyStaticBlock);
                                continue;
                            }

                            fsData.Seek(offset, SeekOrigin.Begin);

                            int tileCount = length / 7;

                            StaticTile[] staTiles = new StaticTile[tileCount];

                            fixed(StaticTile *pTiles = staTiles)
                            {
                                _lread(fsData.Handle, pTiles, length);

                                StaticTile *pCur = pTiles, pEnd = pTiles + tileCount;

                                while (pCur < pEnd)
                                {
                                    lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add((short)((pCur->m_ID & 0x3FFF) + 0x4000), pCur->m_Hue, pCur->m_Z);
                                    ++pCur;
                                }

                                HuedTile[][][] tiles = new HuedTile[8][][];

                                for (int x = 0; x < 8; ++x)
                                {
                                    tiles[x] = new HuedTile[8][];

                                    for (int y = 0; y < 8; ++y)
                                    {
                                        tiles[x][y] = lists[x][y].ToArray();
                                    }
                                }

                                matrix.SetStaticBlock(blockX, blockY, tiles);
                            }
                        }

                        return(count);
                    }
                }
            }
        }
Пример #9
0
		private unsafe HuedTile[][][] ReadStaticBlock(int x, int y)
		{
			try
			{
				if (!StaticIndexInit)
				{
					InitStatics();
				}
				if (m_Statics == null || !m_Statics.CanRead || !m_Statics.CanSeek)
				{
					if (staticsPath == null)
					{
						m_Statics = null;
					}
					else
					{
						m_Statics = new FileStream(staticsPath, FileMode.Open, FileAccess.Read, FileShare.Read);
					}
				}
				if (m_Statics == null)
				{
					return EmptyStaticBlock;
				}

				int lookup = m_StaticIndex[(x * BlockHeight) + y].lookup;
				int length = m_StaticIndex[(x * BlockHeight) + y].length;

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

					m_Statics.Seek(lookup, SeekOrigin.Begin);

					if (m_Buffer == null || m_Buffer.Length < length)
					{
						m_Buffer = new byte[length];
					}

					GCHandle gc = GCHandle.Alloc(m_Buffer, GCHandleType.Pinned);
					try
					{
						m_Statics.Read(m_Buffer, 0, length);

						if (m_Lists == null)
						{
							m_Lists = new HuedTileList[8][];

							for (int i = 0; i < 8; ++i)
							{
								m_Lists[i] = new HuedTileList[8];

								for (int j = 0; j < 8; ++j)
								{
									m_Lists[i][j] = new HuedTileList();
								}
							}
						}

						HuedTileList[][] lists = m_Lists;

						for (int i = 0; i < count; ++i)
						{
							var ptr = new IntPtr((long)gc.AddrOfPinnedObject() + i * sizeof(StaticTile));
							var cur = (StaticTile)Marshal.PtrToStructure(ptr, typeof(StaticTile));
							lists[cur.m_X & 0x7][cur.m_Y & 0x7].Add(Art.GetLegalItemID(cur.m_ID), cur.m_Hue, cur.m_Z);
						}

						var tiles = new HuedTile[8][][];

						for (int i = 0; i < 8; ++i)
						{
							tiles[i] = new HuedTile[8][];

							for (int j = 0; j < 8; ++j)
							{
								tiles[i][j] = lists[i][j].ToArray();
							}
						}

						return tiles;
					}
					finally
					{
						gc.Free();
					}
				}
			}
			finally
			{
				//if (m_Statics != null)
				//    m_Statics.Close();
			}
		}
Пример #10
0
        private unsafe int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath)
        {
            int num;

            using (FileStream fileStream = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (FileStream fileStream1 = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (FileStream fileStream2 = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        BinaryReader     binaryReader  = new BinaryReader(fileStream1);
                        BinaryReader     binaryReader1 = new BinaryReader(fileStream2);
                        int              length        = (int)(binaryReader.BaseStream.Length / (long)4);
                        HuedTileList[][] huedTileList  = new HuedTileList[8][];
                        for (int i = 0; i < 8; i++)
                        {
                            huedTileList[i] = new HuedTileList[8];
                            for (int j = 0; j < 8; j++)
                            {
                                huedTileList[i][j] = new HuedTileList();
                            }
                        }
                        for (int k = 0; k < length; k++)
                        {
                            int num1         = binaryReader.ReadInt32();
                            int blockHeight  = num1 / matrix.BlockHeight;
                            int blockHeight1 = num1 % matrix.BlockHeight;
                            int num2         = binaryReader1.ReadInt32();
                            int num3         = binaryReader1.ReadInt32();
                            binaryReader1.ReadInt32();
                            if (num2 < 0 || num3 <= 0)
                            {
                                matrix.SetStaticBlock(blockHeight, blockHeight1, matrix.EmptyStaticBlock);
                            }
                            else
                            {
                                fileStream.Seek((long)num2, SeekOrigin.Begin);
                                int          num4            = num3 / 7;
                                StaticTile[] staticTileArray = new StaticTile[num4];
                                try
                                {
                                    fixed(StaticTile *staticTilePointer = &staticTileArray[0])
                                    {
                                        TileMatrixPatch._lread(fileStream.Handle, staticTilePointer, num3);
                                        StaticTile *staticTilePointer1 = staticTilePointer;
                                        StaticTile *staticTilePointer2 = staticTilePointer + num4 * sizeof(StaticTile);

                                        while (staticTilePointer1 < staticTilePointer2)
                                        {
                                            huedTileList[(*staticTilePointer1).m_X & 7][(*staticTilePointer1).m_Y & 7].Add((short)(((*staticTilePointer1).m_ID & 16383) + 16384), (*staticTilePointer1).m_Hue, (*staticTilePointer1).m_Z);
                                            staticTilePointer1 = staticTilePointer1 + sizeof(StaticTile);
                                        }
                                        HuedTile[][][] array = new HuedTile[8][][];
                                        for (int l = 0; l < 8; l++)
                                        {
                                            array[l] = new HuedTile[8][];
                                            for (int m = 0; m < 8; m++)
                                            {
                                                array[l][m] = huedTileList[l][m].ToArray();
                                            }
                                        }
                                        matrix.SetStaticBlock(blockHeight, blockHeight1, array);
                                    }
                                }
                                finally
                                {
                                    staticTilePointer = null;
                                }
                            }
                        }
                        num = length;
                    }
                }
            }
            return(num);
        }
Пример #11
0
        private unsafe int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath)
        {
            using (FileStream fileStream1 = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (FileStream fileStream2 = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (FileStream fileStream3 = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        BinaryReader     binaryReader1     = new BinaryReader((Stream)fileStream2);
                        BinaryReader     binaryReader2     = new BinaryReader((Stream)fileStream3);
                        int              num1              = (int)(binaryReader1.BaseStream.Length / 4L);
                        HuedTileList[][] huedTileListArray = new HuedTileList[8][];
                        for (int index1 = 0; index1 < 8; ++index1)
                        {
                            huedTileListArray[index1] = new HuedTileList[8];
                            for (int index2 = 0; index2 < 8; ++index2)
                            {
                                huedTileListArray[index1][index2] = new HuedTileList();
                            }
                        }
                        for (int index1 = 0; index1 < num1; ++index1)
                        {
                            int num2   = binaryReader1.ReadInt32();
                            int x      = num2 / matrix.BlockHeight;
                            int y      = num2 % matrix.BlockHeight;
                            int num3   = binaryReader2.ReadInt32();
                            int wBytes = binaryReader2.ReadInt32();
                            binaryReader2.ReadInt32();
                            if (num3 < 0 || wBytes <= 0)
                            {
                                matrix.SetStaticBlock(x, y, matrix.EmptyStaticBlock);
                            }
                            else
                            {
                                fileStream1.Seek((long)num3, SeekOrigin.Begin);
                                int          length          = wBytes / 7;
                                StaticTile[] staticTileArray = new StaticTile[length];
                                fixed(StaticTile *staticTilePtr1 = &staticTileArray[0])
                                {
                                    TileMatrixPatch._lread(fileStream1.Handle, (void *)staticTilePtr1, wBytes);
                                    StaticTile *staticTilePtr2 = staticTilePtr1;

                                    for (StaticTile *staticTilePtr3 = staticTilePtr1 + length; staticTilePtr2 < staticTilePtr3; ++staticTilePtr2)
                                    {
                                        huedTileListArray[(int)staticTilePtr2->m_X & 7][(int)staticTilePtr2->m_Y & 7].Add((short)(((int)staticTilePtr2->m_ID & 16383) + 16384), staticTilePtr2->m_Hue, staticTilePtr2->m_Z);
                                    }
                                    HuedTile[][][] huedTileArray = new HuedTile[8][][];
                                    for (int index2 = 0; index2 < 8; ++index2)
                                    {
                                        huedTileArray[index2] = new HuedTile[8][];
                                        for (int index3 = 0; index3 < 8; ++index3)
                                        {
                                            huedTileArray[index2][index3] = huedTileListArray[index2][index3].ToArray();
                                        }
                                    }
                                    matrix.SetStaticBlock(x, y, huedTileArray);
                                }
                            }
                        }
                        return(num1);
                    }
                }
            }
        }
 private unsafe int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath)
 {
     using (FileStream fileStream1 = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read))
       {
     using (FileStream fileStream2 = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read))
     {
       using (FileStream fileStream3 = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read))
       {
     BinaryReader binaryReader1 = new BinaryReader((Stream) fileStream2);
     BinaryReader binaryReader2 = new BinaryReader((Stream) fileStream3);
     int num1 = (int) (binaryReader1.BaseStream.Length / 4L);
     HuedTileList[][] huedTileListArray = new HuedTileList[8][];
     for (int index1 = 0; index1 < 8; ++index1)
     {
       huedTileListArray[index1] = new HuedTileList[8];
       for (int index2 = 0; index2 < 8; ++index2)
         huedTileListArray[index1][index2] = new HuedTileList();
     }
     for (int index1 = 0; index1 < num1; ++index1)
     {
       int num2 = binaryReader1.ReadInt32();
       int x = num2 / matrix.BlockHeight;
       int y = num2 % matrix.BlockHeight;
       int num3 = binaryReader2.ReadInt32();
       int wBytes = binaryReader2.ReadInt32();
       binaryReader2.ReadInt32();
       if (num3 < 0 || wBytes <= 0)
       {
         matrix.SetStaticBlock(x, y, matrix.EmptyStaticBlock);
       }
       else
       {
         fileStream1.Seek((long) num3, SeekOrigin.Begin);
         int length = wBytes / 7;
         StaticTile[] staticTileArray = new StaticTile[length];
         fixed (StaticTile* staticTilePtr1 = &staticTileArray[0])
         {
           TileMatrixPatch._lread(fileStream1.Handle, (void*) staticTilePtr1, wBytes);
           StaticTile* staticTilePtr2 = staticTilePtr1;
           for (StaticTile* staticTilePtr3 = staticTilePtr1 + length; staticTilePtr2 < staticTilePtr3; ++staticTilePtr2)
             huedTileListArray[(int) staticTilePtr2->m_X & 7][(int) staticTilePtr2->m_Y & 7].Add((short) (((int) staticTilePtr2->m_ID & 16383) + 16384), staticTilePtr2->m_Hue, staticTilePtr2->m_Z);
           HuedTile[][][] huedTileArray = new HuedTile[8][][];
           for (int index2 = 0; index2 < 8; ++index2)
           {
             huedTileArray[index2] = new HuedTile[8][];
             for (int index3 = 0; index3 < 8; ++index3)
               huedTileArray[index2][index3] = huedTileListArray[index2][index3].ToArray();
           }
           matrix.SetStaticBlock(x, y, huedTileArray);
         }
       }
     }
     return num1;
       }
     }
       }
 }
Пример #13
0
        private unsafe HuedTile[][][] ReadStaticBlock( int x, int y )
        {
            m_IndexReader.BaseStream.Seek( ((x * m_BlockHeight) + y) * 12, SeekOrigin.Begin );

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

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

                m_Statics.Seek( lookup, SeekOrigin.Begin );

                StaticTile[] staTiles = new StaticTile[count];

                fixed ( StaticTile *pTiles = staTiles )
                {
                    _lread(m_Statics.Handle, pTiles, length);

                    if ( m_Lists == null )
                    {
                        m_Lists = new HuedTileList[8][];

                        for ( int i = 0; i < 8; ++i )
                        {
                            m_Lists[i] = new HuedTileList[8];

                            for ( int j = 0; j < 8; ++j )
                                m_Lists[i][j] = new HuedTileList();
                        }
                    }

                    HuedTileList[][] lists = m_Lists;

                    StaticTile *pCur = pTiles, pEnd = pTiles + count;

                    while ( pCur < pEnd )
                    {
                        lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( (short)((pCur->m_ID & 0x3FFF) + 0x4000), pCur->m_Hue, pCur->m_Z );
                        ++pCur;
                    }

                    HuedTile[][][] tiles = new HuedTile[8][][];

                    for ( int i = 0; i < 8; ++i )
                    {
                        tiles[i] = new HuedTile[8][];

                        for ( int j = 0; j < 8; ++j )
                            tiles[i][j] = lists[i][j].ToArray();
                    }

                    return tiles;
                }
            }
        }