示例#1
0
        /// <summary>
        /// Important: x >> 3, y >> 3
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        private HuedTile[][][] ReadStaticBlock(int x, int y)
        {
            int lookup = (int)_staticIndex[(x * BlockHeight) + y].Offset;
            int length = _staticIndex[(x * BlockHeight) + y].Length;

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

            int count = length / 7;

            _filestatics.Seek(lookup);

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

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

            HuedTileList[][] list = _list;

            for (int i = 0; i < count; i++)
            {
                StaticTile tile = new StaticTile()
                {
                    ID  = _filestatics.ReadUShort(),
                    X   = _filestatics.ReadByte(),
                    Y   = _filestatics.ReadByte(),
                    Z   = _filestatics.ReadSByte(),
                    Hue = _filestatics.ReadUShort()
                };

                list[tile.X & 0x7][tile.Y & 0x7].Add(tile.ID, tile.Hue, tile.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] = list[i][j].ToArray();
                }
            }

            return(tiles);
        }
示例#2
0
        private int PatchStatics(TileMatrix matrix, string path, string pathidx, string pathlookup)
        {
            UOFileMul file   = new UOFileMul(path, pathidx, 0);
            UOFileMul lookup = new UOFileMul(pathlookup);

            int count = Math.Min((int)file.IdxFile.Length / 4, (int)lookup.Length / 12);

            file.Seek(0);
            file.IdxFile.Seek(0);
            lookup.Seek(0);

            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 = file.IdxFile.ReadInt();
                int blockX  = blockID / matrix.BlockHeight;
                int blockY  = blockID % matrix.BlockHeight;

                int offset = lookup.ReadInt();
                int length = lookup.ReadInt();

                lookup.Skip(4);

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

                file.Seek(offset);

                int tileCount = length / 7;
                if (_tileBuffer.Length < tileCount)
                {
                    _tileBuffer = new StaticTile[tileCount];
                }

                StaticTile[] statiles = _tileBuffer;

                for (int j = 0; j < tileCount; j++)
                {
                    statiles[j].ID  = file.ReadUShort();
                    statiles[j].X   = file.ReadByte();
                    statiles[j].Y   = file.ReadByte();
                    statiles[j].Z   = file.ReadSByte();
                    statiles[j].Hue = file.ReadUShort();

                    lists[statiles[j].X & 0x7][statiles[j].Y & 0x7].Add(statiles[j].ID, statiles[j].Hue, statiles[j].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;
            }

            return(count);
        }