Exemple #1
0
        bool PlacedMark(Player p, Vec3S32[] marks, object state, BlockID block)
        {
            ushort x = (ushort)marks[0].X, y = (ushort)marks[0].Y, z = (ushort)marks[0].Z;

            block = p.level.GetBlock(x, y, z);
            p.RevertBlock(x, y, z);
            Dictionary <int, string> names = new Dictionary <int, string>();

            p.Message("Retrieving block change records..");

            bool foundAny = false;

            ListFromDatabase(p, ref foundAny, x, y, z);
            using (IDisposable rLock = p.level.BlockDB.Locker.AccquireRead(30 * 1000)) {
                if (rLock != null)
                {
                    p.level.BlockDB.FindChangesAt(x, y, z,
                                                  entry => OutputEntry(p, ref foundAny, names, entry));
                }
                else
                {
                    p.Message("&WUnable to accquire read lock on BlockDB after 30 seconds, aborting.");
                    return(false);
                }
            }

            if (!foundAny)
            {
                p.Message("No block change records found for this block.");
            }
            BlockID raw       = Block.IsPhysicsType(block) ? block : Block.ToRaw(block);
            string  blockName = Block.GetName(p, block);

            p.Message("Block ({0}, {1}, {2}): &f{3} = {4}%S.", x, y, z, raw, blockName);

            CommandData data = (CommandData)state;

            if (HasExtraPerm(p, data.Rank, 1))
            {
                BlockDBChange.OutputMessageBlock(p, block, x, y, z);
                BlockDBChange.OutputPortal(p, block, x, y, z);
            }
            Server.DoGC();
            return(true);
        }
Exemple #2
0
        void PlacedBlock(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            if (!p.staticCommands)
            {
                p.ClearBlockchange();
            }
            byte b = p.level.GetTile(x, y, z);

            if (b == Block.Invalid)
            {
                Player.Message(p, "Invalid Block ({0}, {1}, {2}).", x, y, z); return;
            }
            p.RevertBlock(x, y, z);

            byte id = b;

            if (b == Block.custom_block)
            {
                id = p.level.GetExtTile(x, y, z);
            }
            Dictionary <int, string> names = new Dictionary <int, string>();

            string blockName = p.level.BlockName(b, id);

            Player.Message(p, "Block ({0}, {1}, {2}): &f{3} = {4}%S.", x, y, z, id, blockName);
            bool foundAny = false;

            ListFromDatabase(p, ref foundAny, names, x, y, z);
            p.level.BlockDB.FindChangesAt(x, y, z,
                                          entry => OutputEntry(p, ref foundAny, names, entry));
            ListInMemory(p, ref foundAny, names, x, y, z);

            if (!foundAny)
            {
                Player.Message(p, "No block change records found for this block.");
            }
            BlockDBChange.OutputMessageBlock(p, b, id, x, y, z);
            BlockDBChange.OutputPortal(p, b, id, x, y, z);

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }