예제 #1
0
        public override void DoOperation(Dictionary <int, LocalUpdateFlags> blockUpdateChain)
        {
            base.DoOperation(blockUpdateChain);
            MapChangeTracker.MarkLandBlockForSave(m_Map.MapID, new Point2D(m_Location.X >> 3, m_Location.Y >> 3));


            if (blockUpdateChain == null)
            {
                SendOutLocalUpdates(m_Map, m_Location.X, m_Location.Y, LocalUpdateFlags.Terrain);
            }
            else
            {
                if (blockUpdateChain.ContainsKey(m_BlockNumber))
                {
                    blockUpdateChain[m_BlockNumber] = blockUpdateChain[m_BlockNumber] | LocalUpdateFlags.Terrain;
                }
                else
                {
                    blockUpdateChain.Add(m_BlockNumber, LocalUpdateFlags.Terrain);
                }
            }
        }
예제 #2
0
        public override void DoOperation(Dictionary <int, LocalUpdateFlags> blockUpdateChain)
        {
            //invalidate CRC
            base.DoOperation(blockUpdateChain);

            //mark block for saving statics
            MapChangeTracker.MarkStaticsBlockForSave(m_Map.MapID, new Point2D(m_Location.X >> 3, m_Location.Y >> 3));

            if (blockUpdateChain == null)
            {
                SendOutLocalUpdates(m_Map, m_Location.X, m_Location.Y, LocalUpdateFlags.Statics);
            }
            else
            {
                if (blockUpdateChain.ContainsKey(m_BlockNumber))
                {
                    blockUpdateChain[m_BlockNumber] = blockUpdateChain[m_BlockNumber] | LocalUpdateFlags.Statics;
                }
                else
                {
                    blockUpdateChain.Add(m_BlockNumber, LocalUpdateFlags.Statics);
                }
            }
        }
예제 #3
0
        public static void LiveFreeze(Mobile from, Map targetMap, Point3D start3d, Point3D end3d)
        {
            Dictionary <Point2D, List <Item> > ItemsByBlockLocation = new Dictionary <Point2D, List <Item> >();

            if (targetMap != null && start3d != NullP3D && end3d != NullP3D)
            {
                Point2D           start = targetMap.Bound(new Point2D(start3d));
                Point2D           end   = targetMap.Bound(new Point2D(end3d));
                IPooledEnumerable eable = targetMap.GetItemsInBounds(new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1));

                Console.WriteLine(string.Format("Invoking live freeze from {0},{1} to {2},{3}", start.X, start.Y, end.X, end.Y));

                foreach (Item item in eable)
                {
                    if (item is Static || item is BaseFloor || item is BaseWall)
                    {
                        Map itemMap = item.Map;
                        if (itemMap == null || itemMap == Map.Internal)
                        {
                            continue;
                        }

                        Point2D p = new Point2D(item.X >> 3, item.Y >> 3);
                        if (!(ItemsByBlockLocation.ContainsKey(p)))
                        {
                            ItemsByBlockLocation.Add(p, new List <Item>());
                        }
                        ItemsByBlockLocation[p].Add(item);
                    }
                }

                eable.Free();
            }
            else
            {
                from.SendMessage("That was not a proper area. Please retarget and reissue the command.");
                return;
            }

            TileMatrix matrix = targetMap.Tiles;

            foreach (KeyValuePair <Point2D, List <Item> > kvp in ItemsByBlockLocation)
            {
                StaticTile[][][] blockOfTiles = matrix.GetStaticBlock(kvp.Key.X, kvp.Key.Y);
                Dictionary <Point2D, List <StaticTile> > newBlockStatics = new Dictionary <Point2D, List <StaticTile> >();

                foreach (Item item in kvp.Value)
                {
                    int xOffset = item.X - (kvp.Key.X * 8);
                    int yOffset = item.Y - (kvp.Key.Y * 8);
                    if (xOffset < 0 || xOffset >= 8 || yOffset < 0 || yOffset >= 8)
                    {
                        continue;
                    }

                    StaticTile newTile  = new StaticTile((ushort)item.ItemID, (byte)xOffset, (byte)yOffset, (sbyte)item.Z, (short)item.Hue);
                    Point2D    refPoint = new Point2D(xOffset, yOffset);

                    if (!(newBlockStatics.ContainsKey(refPoint)))
                    {
                        newBlockStatics.Add(refPoint, new List <StaticTile>());
                    }

                    newBlockStatics[refPoint].Add(newTile);
                    item.Delete();
                }

                for (int i = 0; i < blockOfTiles.Length; i++)
                {
                    for (int j = 0; j < blockOfTiles[i].Length; j++)
                    {
                        for (int k = 0; k < blockOfTiles[i][j].Length; k++)
                        {
                            Point2D refPoint = new Point2D(i, j);
                            if (!(newBlockStatics.ContainsKey(refPoint)))
                            {
                                newBlockStatics.Add(refPoint, new List <StaticTile>());
                            }

                            newBlockStatics[refPoint].Add(blockOfTiles[i][j][k]);
                        }
                    }
                }

                StaticTile[][][] newblockOfTiles = new StaticTile[8][][];

                for (int i = 0; i < 8; i++)
                {
                    newblockOfTiles[i] = new StaticTile[8][];
                    for (int j = 0; j < 8; j++)
                    {
                        Point2D p      = new Point2D(i, j);
                        int     length = 0;
                        if (newBlockStatics.ContainsKey(p))
                        {
                            length = newBlockStatics[p].Count;
                        }
                        newblockOfTiles[i][j] = new StaticTile[length];
                        for (int k = 0; k < length; k++)
                        {
                            if (newBlockStatics.ContainsKey(p))
                            {
                                newblockOfTiles[i][j][k] = newBlockStatics[p][k];
                            }
                        }
                    }
                }

                matrix.SetStaticBlock(kvp.Key.X, kvp.Key.Y, newblockOfTiles);
                int blockNum = ((kvp.Key.X * matrix.BlockHeight) + kvp.Key.Y);

                List <Mobile> candidates = new List <Mobile>();
                int           bX         = kvp.Key.X * 8;
                int           bY         = kvp.Key.Y * 8;

                IPooledEnumerable eable = targetMap.GetMobilesInRange(new Point3D(bX, bY, 0));

                foreach (Mobile m in eable)
                {
                    if (m.Player)
                    {
                        candidates.Add(m);
                    }
                }
                eable.Free();

                CRC.InvalidateBlockCRC(targetMap.MapID, blockNum);
                foreach (Mobile m in candidates)
                {
                    m.Send(new UpdateStaticsPacket(new Point2D(kvp.Key.X, kvp.Key.Y), m));
                }
                MapChangeTracker.MarkStaticsBlockForSave(targetMap.MapID, kvp.Key);
            }
        }