public void highlightStuff(string[] fileContent, Int64 seconds, Player p)
        {
            Player.UndoPos Pos;

            for (int i = fileContent.Length / 7; i >= 0; i--)
            {
                try
                {
                    if (Convert.ToDateTime(fileContent[(i * 7) + 4].Replace('&', ' ')).AddSeconds(seconds) >= DateTime.Now)
                    {
                        Level foundLevel = Level.Find(fileContent[i * 7]);
                        if (foundLevel != null && foundLevel == p.level)
                        {
                            Pos.mapName = foundLevel.name;
                            Pos.x = Convert.ToUInt16(fileContent[(i * 7) + 1]);
                            Pos.y = Convert.ToUInt16(fileContent[(i * 7) + 2]);
                            Pos.z = Convert.ToUInt16(fileContent[(i * 7) + 3]);

                            Pos.type = foundLevel.GetTile(Pos.x, Pos.y, Pos.z);

                            if (Pos.type == Convert.ToByte(fileContent[(i * 7) + 6]) || Block.Convert(Pos.type) == Block.water || Block.Convert(Pos.type) == Block.lava)
                            {
                                if (Pos.type == Block.air || Block.Convert(Pos.type) == Block.water || Block.Convert(Pos.type) == Block.lava)
                                    p.SendBlockchange(Pos.x, Pos.y, Pos.z, Block.red);
                                else p.SendBlockchange(Pos.x, Pos.y, Pos.z, Block.green);
                            }
                        }
                    }
                    else break;
                }
                catch { }
            }
        }
Exemple #2
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            int counter = 0;
            ushort xx, yy, zz;
            for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        if (selectedBlock <= 0)
                        {
                            counter++;
                            p.SendBlockchange(xx, yy, zz, 0); // xray block
                        }
                        else
                        {
                            if (p.level.GetTile(xx, yy, zz) == selectedBlock) // check if block is selected block
                            {
                                counter++;
                                p.SendBlockchange(xx, yy, zz, 0); // xray block
                            }
                        }
            Player.SendMessage(p, "X-Rayed " + counter + " blocks.");
            Player.SendMessage(p, "Use /reveal to restore all x-rayed blocks.");
        }
Exemple #3
0
 public void AddGoalPos(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     p.level.Blockchange(x, y, z, Block.air);
     if (type == Block.red && goalBuffer.Count > 0)
     {
         p.SendBlockchange(x, y, z, Block.air);
         foreach (PushBallTeam.Pos pp in goalBuffer)
         {
             p.level.pushBall.pushBallTeams.Find(team => team.color == goalPosColor[1]).goalPositions.Add(pp);
             p.SendBlockchange(pp.x, pp.y, pp.z, Block.air);
         }
         Player.SendMessage(p, "Goal positions selected for " + p.level.pushBall.pushBallTeams.Find(team => team.color == goalPosColor[1]).teamstring);
         goalBuffer.Clear();
         goalPosColor = "";
     }
     else
     {
         p.SendBlockchange(x, y, z, Block.green);
         PushBallTeam.Pos gp = new PushBallTeam.Pos();
         gp.x = x; gp.y = y; gp.z = z;
         goalBuffer.Add(gp);
         Player.SendMessage(p, "&aGoal position added. &cPlace a red block to finish.");
         p.Blockchange += new Player.BlockchangeEventHandler(AddGoalPos);
     }
 }
Exemple #4
0
        public void ExitChange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            portalPos bp = (portalPos)p.blockchangeObject;

            foreach (portPos pos in bp.port)
            {
                DataTable Portals = MySQL.fillData("SELECT * FROM `Portals" + pos.portMapName + "` WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z);
                Portals.Dispose();

                if (Portals.Rows.Count == 0)
                {
                    MySQL.executeQuery("INSERT INTO `Portals" + pos.portMapName + "` (EntryX, EntryY, EntryZ, ExitMap, ExitX, ExitY, ExitZ) VALUES (" + (int)pos.x + ", " + (int)pos.y + ", " + (int)pos.z + ", '" + p.level.name + "', " + (int)x + ", " + (int)y + ", " + (int)z + ")");
                }
                else
                {
                    MySQL.executeQuery("UPDATE `Portals" + pos.portMapName + "` SET ExitMap='" + p.level.name + "', ExitX=" + (int)x + ", ExitY=" + (int)y + ", ExitZ=" + (int)z + " WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z);
                }
                //DB

                if (pos.portMapName == p.level.name) p.SendBlockchange(pos.x, pos.y, pos.z, bp.type);
            }

            Player.SendMessage(p, "&3Exit" + "&g block placed");

            if (p.staticCommands) { bp.port.Clear(); p.blockchangeObject = bp; p.Blockchange += new Player.BlockchangeEventHandler(EntryChange); }
        }
Exemple #5
0
        public void EntryChange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            portalPos bp = (portalPos)p.blockchangeObject;

            if (bp.Multi.ToLower() == "multi" && type == Block.red && bp.port.Count > 0) { ExitChange(p, x, y, z, type); return; }

            byte b = p.level.GetTile(x, y, z);
            p.level.Blockchange(p, x, y, z, bp.type);
            p.SendBlockchange(x, y, z, Block.green);
            portPos Port;

            Port.portMapName = p.level.name;
            Port.x = x; Port.y = y; Port.z = z;

            bp.port.Add(Port);

            p.blockchangeObject = bp;

            if (bp.Multi.ToLower() != "multi")
            {
                p.Blockchange += new Player.BlockchangeEventHandler(ExitChange);
                Player.SendMessage(p, "&aEntry block placed");
            }
            else if (bp.Multi.ToLower() == "multi")
            {
                p.Blockchange += new Player.BlockchangeEventHandler(EntryChange);
                Player.SendMessage(p, "&aEntry block placed. &cPlace a Red block for exit.");
            }
        }
Exemple #6
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            Level.Zone Zn;

            Zn.smallX = Math.Min(cpos.x, x);
            Zn.smallY = Math.Min(cpos.y, y);
            Zn.smallZ = Math.Min(cpos.z, z);
            Zn.bigX = Math.Max(cpos.x, x);
            Zn.bigY = Math.Max(cpos.y, y);
            Zn.bigZ = Math.Max(cpos.z, z);
            Zn.Owner = cpos.Owner;

            p.level.ZoneList.Add(Zn);

            //DB
            MySQL.executeQuery("INSERT INTO `Zone" + p.level.name + "` (SmallX, SmallY, SmallZ, BigX, BigY, BigZ, Owner) VALUES (" + Zn.smallX + ", " + Zn.smallY + ", " + Zn.smallZ + ", " + Zn.bigX + ", " + Zn.bigY + ", " + Zn.bigZ + ", '" + Zn.Owner + "')");
            //DB

            Player.SendMessage(p, "Added zone for &b" + cpos.Owner);
        }
Exemple #7
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            ushort xx, yy, zz; int foundBlocks = 0;

            for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(xx, yy, zz) != cpos.toIgnore) foundBlocks++;
                    }

            Player.SendMessage(p, foundBlocks + " blocks are between (" + cpos.x + ", " + cpos.y + ", " + cpos.z + ") and (" + x + ", " + y + ", " + z + ")");

            ushort xdiff = (ushort)((Math.Max(cpos.x, x)) - Math.Min(cpos.x, x));
            ushort ydiff = (ushort)((Math.Max(cpos.y, y)) - Math.Min(cpos.y, y));
            ushort zdiff = (ushort)((Math.Max(cpos.z, z)) - Math.Min(cpos.z, z));

            Player.SendMessage(p, "The selected area was " + xdiff + " blocks wide, " + ydiff + " blocks high, " + zdiff + " blocks deep.");

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            cpos.message = cpos.message.Replace("'", "\\'");

            DataTable Messages = MySQL.fillData("SELECT * FROM `Commandblocks" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);
            Messages.Dispose();

            if (Messages.Rows.Count == 0)
            {
                MySQL.executeQuery("INSERT INTO `Commandblocks" + p.level.name + "` (X, Y, Z, Message) VALUES (" + (int)x + ", " + (int)y + ", " + (int)z + ", '" + cpos.message + "')");
            }
            else
            {
                MySQL.executeQuery("UPDATE `Commandblocks" + p.level.name + "` SET Message='" + cpos.message + "' WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);
            }

            Player.SendMessage(p, "Message block placed.");
            p.level.Blockchange(p, x, y, z, cpos.type);
            p.SendBlockchange(x, y, z, cpos.type);

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            List<CatchPos> buffer = new List<CatchPos>();
            CatchPos pos = new CatchPos();
            //int totalChecks = 0;

            //if (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z) > 8000) { Player.SendMessage(p, "Tried to restart too many blocks. You may only restart 8000"); return; }

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
            {
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                {
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(xx, yy, zz) != Block.air)
                        {
                            pos.x = xx; pos.y = yy; pos.z = zz;
                            pos.extraInfo = cpos.extraInfo;
                            buffer.Add(pos);
                        }
                    }
                }
            }

            try
            {
                if (cpos.extraInfo == "")
                {
                    if (buffer.Count > Server.rpNormLimit)
                    {
                        Player.SendMessage(p, "Cannot restart more than " + Server.rpNormLimit + " blocks.");
                        Player.SendMessage(p, "Tried to restart " + buffer.Count + " blocks.");
                        return;
                    }
                }
                else
                {
                    if (buffer.Count > Server.rpLimit)
                    {
                        Player.SendMessage(p, "Tried to add physics to " + buffer.Count + " blocks.");
                        Player.SendMessage(p, "Cannot add physics to more than " + Server.rpLimit + " blocks.");
                        return;
                    }
                }
            }
            catch { return; }

            foreach (CatchPos pos1 in buffer)
            {
                p.level.AddCheck(p.level.PosToInt(pos1.x, pos1.y, pos1.z), pos1.extraInfo, true);
            }

            Player.SendMessage(p, "Activated " + buffer.Count + " blocks.");
            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Exemple #10
0
        public void AboutBlockchange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            if (!p.staticCommands) p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            if (b == Block.Zero) { Player.SendMessage(p, "Invalid Block(" + x + "," + y + "," + z + ")!"); return; }
            p.SendBlockchange(x, y, z, b);

            string message = "Block (" + x + "," + y + "," + z + "): ";
            message += "&f" + b + " = " + Block.Name(b);
            Player.SendMessage(p, message + "&g.");
            message = p.level.foundInfo(x, y, z);
            if (message != "") Player.SendMessage(p, "Physics information: &a" + message);

            DataTable Blocks = MySQL.fillData("SELECT * FROM `Block" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);

            string Username, TimePerformed, BlockUsed;
            bool Deleted, foundOne = false;

            for (int i = 0; i < Blocks.Rows.Count; i++)
            {
                foundOne = true;
                Username = Blocks.Rows[i]["Username"].ToString();
                TimePerformed = DateTime.Parse(Blocks.Rows[i]["TimePerformed"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                BlockUsed = Block.Name((byte)Blocks.Rows[i]["Type"]).ToString();
                Deleted = (bool)Blocks.Rows[i]["Deleted"];

                if (!Deleted)
                    Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed);
                else
                    Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed);
                Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
            }

            List<Level.BlockPos> inCache = p.level.blockCache.FindAll(bP => bP.x == x && bP.y == y && bP.z == z);

            for (int i = 0; i < inCache.Count; i++)
            {
                foundOne = true;
                Deleted = inCache[i].deleted;
                Username = inCache[i].name;
                TimePerformed = inCache[i].TimePerformed.ToString("yyyy-MM-dd HH:mm:ss");
                BlockUsed = Block.Name(inCache[i].type);

                if (!Deleted)
                    Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed);
                else
                    Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed);
                Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
            }

            if (!foundOne)
                Player.SendMessage(p, "This block has not been modified since the map was cleared.");

            Blocks.Dispose();

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Exemple #11
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            if (cpos.y == y)
            {
                Player.SendMessage(p, "Cannot create a stairway 0 blocks high.");
                return;
            }

            ushort xx, zz; int currentState = 0;
            xx = cpos.x; zz = cpos.z;

            if (cpos.x > x && cpos.z > z) currentState = 0;
            else if (cpos.x > x && cpos.z < z) currentState = 1;
            else if (cpos.x < x && cpos.z > z) currentState = 2;
            else currentState = 3;

            for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
            {
                if (currentState == 0)
                {
                    xx++; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    xx++; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 1;
                }
                else if (currentState == 1)
                {
                    zz++; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    zz++; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 2;
                }
                else if (currentState == 2)
                {
                    xx--; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    xx--; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 3;
                }
                else
                {
                    zz--; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    zz--; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 0;
                }
                /*
                if (cpos.x == xx && cpos.z == zz || cpos.x == xx + 1 && cpos.z == zz) xx++;
                else if (cpos.x == xx + 2 && cpos.z == zz || cpos.x == xx + 2 && cpos.z == zz + 1) zz++;
                else if (cpos.x == xx + 2 && cpos.z == zz + 2 || cpos.x == xx + 1 && cpos.z == zz + 2) xx--;
                else zz--;
                */
            }

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Exemple #12
0
 public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     byte b = p.level.GetTile(x, y, z);
     p.SendBlockchange(x, y, z, b);
     CatchPos bp = (CatchPos)p.blockchangeObject;
     bp.x = x; bp.y = y; bp.z = z; p.blockchangeObject = bp;
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
 }
 public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     byte b = p.level.GetTile(x, y, z);
     p.SendBlockchange(x, y, z, b);
     Level.Reflection r = (Level.Reflection)p.blockchangeObject;
     Level.ReflectionPos rp = new Level.ReflectionPos();
     rp.x = x; rp.y = y; rp.z = z;
     r.reflectionPositions.Add(rp);
     p.blockchangeObject = r;
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
 }
Exemple #14
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            int[] xxx = { Math.Min(cpos.x, x), Math.Max(cpos.x, x) };
            int[] yyy = { Math.Min(cpos.y, y), Math.Max(cpos.y, y) };
            int[] zzz = { Math.Min(cpos.z, z), Math.Max(cpos.z, z) };

            bool unevenZ, unevenY, unevenX;

            ushort medz = (ushort)(GetMedian(zzz, out unevenZ));
            ushort medy = (ushort)(GetMedian(yyy, out unevenY));
            ushort medx = (ushort)(GetMedian(xxx, out unevenX));

            ushort meepZ = (unevenZ) ? (ushort)(medz + 1) : (ushort)0;
            ushort meepY = (unevenY) ? (ushort)(medy + 1) : (ushort)0;
            ushort meepX = (unevenX) ? (ushort)(medx + 1) : (ushort)0;

            if (unevenZ)
            {
                Player.SendMessage(p, "The Z coordinate was even. Placing 2 blocks for accuracy.");
            }
            if (unevenY)
            {
                Player.SendMessage(p, "The Y coordinate was even. Placing 2 blocks for accuracy.");
            }
            if (unevenX)
            {
                Player.SendMessage(p, "The X coordinate was even. Placing 2 blocks for accuracy.");
            }

            if (p.level.GetTile(medx, medy, medz) != type)
            {
                p.level.Blockchange(p, medx, medy, medz, type);
                if (meepZ != 0)
                {
                    p.level.Blockchange(p, medx, medy, meepZ, type);
                }
                if (meepY != 0)
                {
                    p.level.Blockchange(p, medx, meepY, meepZ, type);
                }
                if (meepX != 0)
                {
                    p.level.Blockchange(p, meepX, medy, meepZ, type);
                }
            }

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Exemple #15
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            p.CopyBuffer.Clear();
            int TotalAir = 0;
            if (cpos.type == 2) p.copyAir = true; else p.copyAir = false;

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        b = p.level.GetTile(xx, yy, zz);
                        if (Block.canPlace(p, b))
                        {
                            if (b == Block.air && cpos.type != 2 || cpos.ignoreTypes.Contains(b)) TotalAir++;

                            if (cpos.ignoreTypes.Contains(b)) BufferAdd(p, (ushort)(xx - cpos.x), (ushort)(yy - cpos.y), (ushort)(zz - cpos.z), Block.air);
                            else BufferAdd(p, (ushort)(xx - cpos.x), (ushort)(yy - cpos.y), (ushort)(zz - cpos.z), b);
                        }
                        else BufferAdd(p, (ushort)(xx - cpos.x), (ushort)(yy - cpos.y), (ushort)(zz - cpos.z), Block.air);
                    }

            if ((p.CopyBuffer.Count - TotalAir) > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to copy " + p.CopyBuffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot copy more than " + p.group.maxBlocks + ".");
                p.CopyBuffer.Clear();
                return;
            }

            if (cpos.type == 1)
                for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                        for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        {
                            b = p.level.GetTile(xx, yy, zz);
                            if (b != Block.air && Block.canPlace(p, b))
                                p.level.Blockchange(p, xx, yy, zz, Block.air);
                        }

            Player.SendMessage(p, (p.CopyBuffer.Count - TotalAir) + " blocks copied.");
            if (allowoffset != -1)
            {
                Player.SendMessage(p, "Place a block to determine where to paste from");
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange3);
            }
        }
Exemple #16
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);

            Player.UndoPos Pos1;
            //p.UndoBuffer.Clear();

            Level l = p.level;
            p.activeCuboids++;
            Thread t = new Thread(new ThreadStart(delegate
            {
                try
                {
                    int c = 0;
                    p.CopyBuffer.ForEach(delegate(Player.CopyPos pos)
                    {
                        c++;
                        if (p.activeCuboids == 0) return;
                        Pos1.x = (ushort)(Math.Abs(pos.x) + x);
                        Pos1.y = (ushort)(Math.Abs(pos.y) + y);
                        Pos1.z = (ushort)(Math.Abs(pos.z) + z);

                        if (pos.type != Block.air || p.copyAir)
                            unchecked
                            {
                                if (p.level.GetTile(Pos1.x, Pos1.y, Pos1.z) != Block.Zero)
                                    l.Blockchange(p, (ushort)(Pos1.x + p.copyoffset[0]), (ushort)(Pos1.y + p.copyoffset[1]), (ushort)(Pos1.z + p.copyoffset[2]), pos.type);
                            }
                        if (Server.throttle > 0)
                        {
                            while (Server.pauseCuboids) { Thread.Sleep(1000); }
                            if (c >= Server.throttle)
                            {
                                c = 0;
                                if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                            }
                        }
                    });
                    Player.SendMessage(p, "Pasted " + p.CopyBuffer.Count + " blocks.");
                    if (p.activeCuboids > 0) p.activeCuboids--;
                    if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                }
                catch (Exception ex) { Server.ErrorLog(ex); Player.SendMessage(p, "Error!"); return; }
            })); t.IsBackground = true; t.Priority = ThreadPriority.Lowest; t.Start();
        }
Exemple #17
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
            List<Pos> buffer = new List<Pos>();
            Pos pos;

            bool AddMe = false;

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        AddMe = false;

                        if (p.level.GetTile((ushort)(xx - 1), yy, zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile((ushort)(xx + 1), yy, zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, (ushort)(yy - 1), zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, (ushort)(yy + 1), zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, yy, (ushort)(zz - 1)) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, yy, (ushort)(zz + 1)) == cpos.type) AddMe = true;

                        if (AddMe && p.level.GetTile(xx, yy, zz) != cpos.type) { pos.x = xx; pos.y = yy; pos.z = zz; buffer.Add(pos); }
                    }

            if (buffer.Count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to outline more than " + buffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot outline more than " + p.group.maxBlocks + ".");
                return;
            }

            buffer.ForEach(delegate(Pos pos1)
            {
                p.level.Blockchange(p, pos1.x, pos1.y, pos1.z, cpos.type2);
            });

            Player.SendMessage(p, "You outlined " + buffer.Count + " blocks.");

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Exemple #18
0
 public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     byte b = p.level.GetTile(x, y, z);
     p.SendBlockchange(x, y, z, b);
     bool there = false;
     while (!there )
     {
         y++;
         if (Block.Walkthrough(p.level.GetTile(x, y, z)))
             if (Block.Walkthrough(p.level.GetTile(x, (ushort)(y + 1), z)))
                 if (!Block.Walkthrough(p.level.GetTile(x, (ushort)(y - 1), z)))
                 {
                     Player.SendMessage(p, "Teleported up.");
                     unchecked { p.SendPos((byte)-1, (ushort)(x * 32), (ushort)((y + 1) * 32), (ushort)(z * 32), p.rot[0], p.rot[1]); }
                     there = true;
                 }
     }
     if (!there) { Player.SendMessage(p, "No free spaces available."); }
     if (p.staticCommands) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
 }
Exemple #19
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            if (!p.staticCommands) p.ClearBlockchange();
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            byte oldType = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, oldType);

            int diffX = 0, diffZ = 0;

            if (p.rot[0] <= 32 || p.rot[0] >= 224) { diffZ = -1; }
            else if (p.rot[0] <= 96) { diffX = 1; }
            else if (p.rot[0] <= 160) { diffZ = 1; }
            else diffX = -1;

            List<Pos> buffer = new List<Pos>();
            Pos pos;
            int total = 0;

            if (diffX != 0)
            {
                for (ushort xx = x; total < cpos.distance; xx += (ushort)diffX)
                {
                    for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
                        for (ushort zz = (ushort)(z - 1); zz <= (ushort)(z + 1); zz++)
                        {
                            pos.x = xx; pos.y = yy; pos.z = zz;
                            buffer.Add(pos);
                        }
                    total++;
                }
            }
            else
            {
                for (ushort zz = z; total < cpos.distance; zz += (ushort)diffZ)
                {
                    for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
                        for (ushort xx = (ushort)(x - 1); xx <= (ushort)(x + 1); xx++)
                        {
                            pos.x = xx; pos.y = yy; pos.z = zz;
                            buffer.Add(pos);
                        }
                    total++;
                }
            }

            Level l = p.level;
            p.activeCuboids++;
            Thread t = new Thread(new ThreadStart(delegate
            {
                try
                {
                    int c;
                    if (Server.forceCuboid)
                    {
                        c = 0;
                        int counter = 1;
                        foreach (Pos pos1 in buffer)
                        {
                            if (counter <= p.group.maxBlocks)
                            {
                                c++;
                                if (p.activeCuboids == 0) return;
                                counter++;
                                if (l.GetTile(pos1.x, pos1.y, pos1.z) == oldType)
                                    l.Blockchange(p, pos1.x, pos1.y, pos1.z, Block.air);
                                if (c >= 2)
                                {
                                    c = 0;
                                    if (!Server.pauseCuboids) Thread.Sleep(10 - Server.throttle);
                                    else { while (Server.pauseCuboids) { Thread.Sleep(1000); } }
                                }
                            }
                        }
                        if (counter >= p.group.maxBlocks)
                        {
                            Player.SendMessage(p, "Tried to cuboid " + buffer.Count + " blocks, but your limit is " + p.group.maxBlocks + ".");
                            Player.SendMessage(p, "Executed cuboid up to limit.");
                        }
                        else
                        {
                            Player.SendMessage(p, buffer.Count.ToString() + " blocks.");
                        }

                        if (p.activeCuboids > 0) p.activeCuboids--;
                        if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                        return;
                    }

                    if (buffer.Count > p.group.maxBlocks)
                    {
                        Player.SendMessage(p, "You tried to cuboid " + buffer.Count + " blocks.");
                        Player.SendMessage(p, "You cannot cuboid more than " + p.group.maxBlocks + ".");
                        return;
                    }

                    Player.SendMessage(p, buffer.Count.ToString() + " blocks.");

                    c = 0;
                    foreach (Pos pos1 in buffer)
                    {
                        c++;
                        if (p.activeCuboids == 0) return;
                        if (l.GetTile(pos1.x, pos1.y, pos1.z) == oldType)
                            l.Blockchange(p, pos1.x, pos1.y, pos1.z, Block.air);
                        if (c >= 2)
                        {
                            c = 0;
                            if (!Server.pauseCuboids) Thread.Sleep(10 - Server.throttle);
                            else { while (Server.pauseCuboids) { Thread.Sleep(1000); } }
                        }
                    }

                    if (p.activeCuboids > 0) p.activeCuboids--;
                    if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                }
                catch (Exception ex) { Server.ErrorLog(ex); Player.SendMessage(p, "Error!"); return; }
            })); t.IsBackground = true; t.Priority = ThreadPriority.Lowest; t.Start();
        }
Exemple #20
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            cpos.x = (ushort)(x + cpos.radius); cpos.y = (ushort)(y + cpos.radius); cpos.z = (ushort)(z + cpos.radius);
            x = (ushort)(x - cpos.radius); y = (ushort)(y - cpos.radius); z = (ushort)(z - cpos.radius);
            type = cpos.type;
            unchecked { if (cpos.type != (byte)-1) type = cpos.type; else type = p.bindings[type]; }
            List<Pos> buffer = new List<Pos>();

            ushort xx; ushort yy; ushort zz;

            // find axis lengths
            double rx = (Math.Max(cpos.x, x) - Math.Min(cpos.x, x) + 1) / 2d;
            double ry = (Math.Max(cpos.y, y) - Math.Min(cpos.y, y) + 1) / 2d;
            double rz = (Math.Max(cpos.z, z) - Math.Min(cpos.z, z) + 1) / 2d;

            double rx2 = 1 / (rx * rx);
            double ry2 = 1 / (ry * ry);
            double rz2 = 1 / (rz * rz);

            // find center points
            double cx = (Math.Max(cpos.x, x) + Math.Min(cpos.x, x)) / 2d;
            double cy = (Math.Max(cpos.y, y) + Math.Min(cpos.y, y) + 1) / 2d;
            double cz = (Math.Max(cpos.z, z) + Math.Min(cpos.z, z)) / 2d;

            switch (cpos.brush)
            {
                case BrushType.sphere:
                    for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); xx += 8)
                        for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy += 8)
                            for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); zz += 8)
                                for (int z3 = 0; z3 < 8 && zz + z3 <= Math.Max(cpos.z, z); z3++)
                                    for (int y3 = 0; y3 < 8 && yy + y3 <= Math.Max(cpos.y, y); y3++)
                                        for (int x3 = 0; x3 < 8 && xx + x3 <= Math.Max(cpos.x, x); x3++)
                                        {
                                            // get relative coordinates
                                            double dx = (xx + x3 - cx);
                                            double dy = (yy + y3 - cy);
                                            double dz = (zz + z3 - cz);

                                            // test if it's inside ellipse
                                            if ((dx * dx) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 <= 1)
                                                if (p.level.GetTile((ushort)(xx + x3), (ushort)(yy + y3), (ushort)(zz + z3)) != type)
                                                    BufferAdd(buffer, (ushort)(xx + x3), (ushort)(yy + y3), (ushort)(zz + z3));
                                        }
                    break;
                case BrushType.cube:
                    buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
                    for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                        for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                            for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                            {
                                if (p.level.GetTile(xx, yy, zz) != type) { BufferAdd(buffer, xx, yy, zz); }
                            }
                    break;
                case BrushType.random:
                    Random rand = new Random();
                    for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); xx += 8)
                        for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy += 8)
                            for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); zz += 8)
                                for (int z3 = 0; z3 < 8 && zz + z3 <= Math.Max(cpos.z, z); z3++)
                                    for (int y3 = 0; y3 < 8 && yy + y3 <= Math.Max(cpos.y, y); y3++)
                                        for (int x3 = 0; x3 < 8 && xx + x3 <= Math.Max(cpos.x, x); x3++)
                                        {
                                            // get relative coordinates
                                            double dx = (xx + x3 - cx);
                                            double dy = (yy + y3 - cy);
                                            double dz = (zz + z3 - cz);

                                            // test if it's inside ellipse
                                            if ((dx * dx) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 <= 1)
                                                if (p.level.GetTile((ushort)(xx + x3), (ushort)(yy + y3), (ushort)(zz + z3)) != type)
                                                    if (rand.Next(1, 11) <= 5)
                                                        BufferAdd(buffer, (ushort)(xx + x3), (ushort)(yy + y3), (ushort)(zz + z3));
                                        }
                    break;
            }

            Level l = p.level;
            p.activeCuboids++;
            Thread t = new Thread(new ThreadStart(delegate
            {
                try
                {
                    int c;
                    if (Server.forceCuboid)
                    {
                        int counter = 1;
                        c = 0;
                        for (int i = 0; i < buffer.Count; i++)
                        {
                            if (counter <= p.group.maxBlocks)
                            {
                                c++;
                                if (p.activeCuboids == 0) return;
                                counter++;
                                l.Blockchange(p, buffer[i].x, buffer[i].y, buffer[i].z, type);
                                if (Server.throttle > 0)
                                {
                                    while (Server.pauseCuboids) { Thread.Sleep(1000); }
                                    if (c >= Server.throttle)
                                    {
                                        c = 0;
                                        if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                                    }
                                }
                            }
                        }
                        if (counter >= p.group.maxBlocks)
                        {
                            Player.SendMessage(p, "Tried to brush " + buffer.Count + " blocks, but your limit is " + p.group.maxBlocks + ".");
                            Player.SendMessage(p, "Executed brush up to limit.");
                        }
                        else
                        {
                            Player.SendMessage(p, buffer.Count.ToString() + " blocks.");
                        }

                        if (p.activeCuboids > 0) p.activeCuboids--;
                        p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                        return;
                    }

                    if (buffer.Count > p.group.maxBlocks)
                    {
                        Player.SendMessage(p, "You tried to brush " + buffer.Count + " blocks.");
                        Player.SendMessage(p, "You cannot brush more than " + p.group.maxBlocks + ".");
                        return;
                    }

                    Player.SendMessage(p, buffer.Count.ToString() + " blocks.");

                    c = 0;
                    for (int i = 0; i < buffer.Count; i++)
                    {
                        c++;
                        if (p.activeCuboids == 0) return;
                        l.Blockchange(p, buffer[i].x, buffer[i].y, buffer[i].z, type);
                        if (Server.throttle > 0)
                        {
                            while (Server.pauseCuboids) { Thread.Sleep(1000); }
                            if (c >= Server.throttle)
                            {
                                c = 0;
                                if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                            }
                        }
                    }

                    if (p.activeCuboids > 0) p.activeCuboids--;
                    p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                }
                catch (Exception ex) { Server.ErrorLog(ex); Player.SendMessage(p, "Error!"); return; }
            })); t.IsBackground = true; t.Priority = ThreadPriority.Lowest; t.Start();
        }
Exemple #21
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            try
            {
                p.ClearBlockchange();
                CatchPos cpos = (CatchPos)p.blockchangeObject;
                if (cpos.type == Block.Zero) cpos.type = p.bindings[type];

                byte oldType = p.level.GetTile(x, y, z);
                p.SendBlockchange(x, y, z, oldType);

                if (cpos.type == oldType) { Player.SendMessage(p, "Cannot fill the same time"); return; }
                if (!Block.canPlace(p, oldType) && !Block.BuildIn(oldType)) { Player.SendMessage(p, "Cannot fill that."); return; }

                byte[] mapBlocks = new byte[p.level.blocks.Length];
                List<Pos> buffer = new List<Pos>();
                p.level.blocks.CopyTo(mapBlocks, 0);

                fromWhere.Clear();
                deep = 0;
                FloodFill(p, x, y, z, cpos.type, oldType, cpos.FillType, ref mapBlocks, ref buffer);

                int totalFill = fromWhere.Count;
                for (int i = 0; i < totalFill; i++)
                {
                    totalFill = fromWhere.Count;
                    Pos pos = fromWhere[i];
                    deep = 0;
                    FloodFill(p, pos.x, pos.y, pos.z, cpos.type, oldType, cpos.FillType, ref mapBlocks, ref buffer);
                    totalFill = fromWhere.Count;
                }
                fromWhere.Clear();

                Level l = p.level;
                p.activeCuboids++;
                Thread t = new Thread(new ThreadStart(delegate
                {
                    try
                    {
                        int c;
                        if (Server.forceCuboid)
                        {
                            c = 0;
                            int counter = 1;
                            buffer.ForEach(delegate(Pos pos)
                            {
                                c++;
                                if (counter <= p.group.maxBlocks)
                                {
                                    if (p.activeCuboids == 0) return;
                                    counter++;
                                    l.Blockchange(p, pos.x, pos.y, pos.z, cpos.type);
                                    while (Server.pauseCuboids) { Thread.Sleep(1000); }
                                    if (c >= Server.throttle)
                                    {
                                        c = 0;
                                        if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                                    }
                                }
                            });
                            if (counter >= p.group.maxBlocks)
                            {
                                Player.SendMessage(p, "Tried to cuboid " + buffer.Count + " blocks, but your limit is " + p.group.maxBlocks + ".");
                                Player.SendMessage(p, "Executed cuboid up to limit.");
                            }
                            else
                            {
                                Player.SendMessage(p, "Filled " + buffer.Count + " blocks.");
                                buffer.Clear();
                            }

                            if (p.activeCuboids > 0) p.activeCuboids--;
                            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                            return;
                        }

                        if (buffer.Count > p.group.maxBlocks)
                        {
                            Player.SendMessage(p, "You tried to fill " + buffer.Count + " blocks.");
                            Player.SendMessage(p, "You cannot fill more than " + p.group.maxBlocks + ".");
                            return;
                        }

                        c = 0;
                        buffer.ForEach(delegate(Pos pos)
                        {
                            c++;
                            if (p.activeCuboids == 0) return;
                            l.Blockchange(p, pos.x, pos.y, pos.z, cpos.type);
                            while (Server.pauseCuboids) { Thread.Sleep(1000); }
                            if (c >= Server.throttle)
                            {
                                c = 0;
                                if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                            }
                        });

                        Player.SendMessage(p, "Filled " + buffer.Count + " blocks.");
                        buffer.Clear();

                        if (p.activeCuboids > 0) p.activeCuboids--;
                        if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                    }
                    catch (Exception ex) { Server.ErrorLog(ex); Player.SendMessage(p, "Error!"); return; }
                })); t.IsBackground = true; t.Priority = ThreadPriority.Lowest; t.Start();
            }
            catch (Exception e)
            {
                Server.ErrorLog(e);
            }
        }
Exemple #22
0
        public override void Use(Player p, string message)
        {
            p.isFlying = !p.isFlying;
            if (!p.isFlying) return;

            Player.SendMessage(p, "You are now flying. &cJump!");

            Thread flyThread = new Thread(new ThreadStart(delegate
            {
                Pos pos;
                List<Pos> buffer = new List<Pos>();
                while (p.isFlying)
                {
                    Thread.Sleep(20);
                    try
                    {
                        List<Pos> tempBuffer = new List<Pos>();

                        ushort x = (ushort)((p.pos[0]) / 32);
                        ushort y = (ushort)((p.pos[1] - 60) / 32);
                        ushort z = (ushort)((p.pos[2]) / 32);

                        try
                        {
                            for (ushort xx = (ushort)(x - 2); xx <= x + 2; xx++)
                            {
                                for (ushort yy = (ushort)(y - 1); yy <= y; yy++)
                                {
                                    for (ushort zz = (ushort)(z - 2); zz <= z + 2; zz++)
                                    {
                                        if (p.level.GetTile(xx, yy, zz) == Block.air)
                                        {
                                            pos.x = xx; pos.y = yy; pos.z = zz;
                                            tempBuffer.Add(pos);
                                        }
                                    }
                                }
                            }

                            List<Pos> toRemove = new List<Pos>();
                            foreach (Pos cP in buffer)
                            {
                                if (!tempBuffer.Contains(cP))
                                {
                                    p.SendBlockchange(cP.x, cP.y, cP.z, Block.air);
                                    toRemove.Add(cP);
                                }
                            }

                            foreach (Pos cP in toRemove)
                            {
                                buffer.Remove(cP);
                            }

                            foreach (Pos cP in tempBuffer)
                            {
                                if (!buffer.Contains(cP))
                                {
                                    buffer.Add(cP);
                                    p.SendBlockchange(cP.x, cP.y, cP.z, Block.glass);
                                }
                            }

                            tempBuffer.Clear();
                            toRemove.Clear();
                        }
                        catch { }
                    }
                    catch { }
                }

                foreach (Pos cP in buffer)
                {
                    p.SendBlockchange(cP.x, cP.y, cP.z, Block.air);
                }

                Player.SendMessage(p, "Stopped flying");
            }));
            flyThread.Start();
        }
Exemple #23
0
        public override void Use(Player p, string message)
        {
            byte b; Int64 seconds;
            Player who;
            Player.UndoPos Pos;
            int CurrentPos = 0;
            bool FoundUser = false;

            if (message == "") message = p.name + " 300";

            if (message.Split(' ').Length == 2)
            {
                try
                {
                    seconds = Int64.Parse(message.Split(' ')[1]);
                }
                catch
                {
                    Player.SendMessage(p, "Invalid seconds.");
                    return;
                }
            }
            else
            {
                try
                {
                    seconds = int.Parse(message);
                    if (p != null) message = p.name + " " + message;
                }
                catch
                {
                    seconds = 300;
                    message = message + " 300";
                }
            }

            if (seconds == 0) seconds = 5400;

            who = Player.Find(message.Split(' ')[0]);
            if (who != null)
            {
                message = who.name + " " + seconds;
                FoundUser = true;
                for (CurrentPos = who.UndoBuffer.Count - 1; CurrentPos >= 0; --CurrentPos)
                {
                    try
                    {
                        Pos = who.UndoBuffer[CurrentPos];
                        Level foundLevel = Level.Find(Pos.mapName);
                        if (foundLevel == p.level)
                        {
                            b = foundLevel.GetTile(Pos.x, Pos.y, Pos.z);
                            if (Pos.timePlaced.AddSeconds(seconds) >= DateTime.Now)
                            {
                                if (b == Pos.newtype || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                                {
                                    if (b == Block.air || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava) p.SendBlockchange(Pos.x, Pos.y, Pos.z, Block.red);
                                    else p.SendBlockchange(Pos.x, Pos.y, Pos.z, Block.green);
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    catch { }
                }
            }

            try
            {
                DirectoryInfo di;
                string[] fileContent;

                if (Directory.Exists("extra/undo/" + message.Split(' ')[0]))
                {
                    di = new DirectoryInfo("extra/undo/" + message.Split(' ')[0]);

                    for (int i = 0; i < di.GetFiles("*.undo").Length; i++)
                    {
                        fileContent = File.ReadAllText("extra/undo/" + message.Split(' ')[0] + "/" + i + ".undo").Split(' ');
                        highlightStuff(fileContent, seconds, p);
                    }
                    FoundUser = true;
                }

                if (Directory.Exists("extra/undoPrevious/" + message.Split(' ')[0]))
                {
                    di = new DirectoryInfo("extra/undoPrevious/" + message.Split(' ')[0]);

                    for (int i = 0; i < di.GetFiles("*.undo").Length; i++)
                    {
                        fileContent = File.ReadAllText("extra/undoPrevious/" + message.Split(' ')[0] + "/" + i + ".undo").Split(' ');
                        highlightStuff(fileContent, seconds, p);
                    }
                    FoundUser = true;
                }

                if (FoundUser)
                {
                    Player.SendMessage(p, "Now highlighting &b" + seconds + "&g seconds for " + Server.FindColor(message.Split(' ')[0]) + message.Split(' ')[0]);
                    Player.SendMessage(p, "&cUse /reveal to un-highlight");
                }
                else
                {
                    Player.SendMessage(p, "Could not find player specified.");
                }
            }
            catch (Exception e)
            {
                Server.ErrorLog(e);
            }
        }
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            Level.Reflection r = (Level.Reflection)p.blockchangeObject;
            Level.ReflectionPos rp = new Level.ReflectionPos();
            rp.x = x; rp.y = y; rp.z = z;
            r.reflectionPositions.Add(rp);
            p.blockchangeObject = r;
            if (r.reflectionType != Level.ReflectionType.Line) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange3); }
            else
            {
                if (r.reflectionPositions.Count != 2) { Player.SendMessage(p, "Incorrect number of blocks placed."); return; }
                #region AddLine
                Level.ReflectionLinePos pos;
                List<Level.ReflectionLinePos> buffer = new List<Level.ReflectionLinePos>();
                int i, dx, dy, dz, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2;
                int[] pixel = new int[3];

                Level.Reflection reflection = new Level.Reflection();
                for (int ii = 0; ii < p.level.reflections.Keys.Count; ii++)
                    if (new List<string>(p.level.reflections.Keys)[ii] == p.name.ToLower())
                        reflection = new List<Level.Reflection>(p.level.reflections.Values)[ii];

                pixel[0] = reflection.reflectionPositions[0].x; pixel[1] = reflection.reflectionPositions[0].y; pixel[2] = reflection.reflectionPositions[0].z;
                dx = x - reflection.reflectionPositions[0].x; dy = y - reflection.reflectionPositions[0].y; dz = z - reflection.reflectionPositions[0].z;

                x_inc = (dx < 0) ? -1 : 1; l = Math.Abs(dx);
                y_inc = (dy < 0) ? -1 : 1; m = Math.Abs(dy);
                z_inc = (dz < 0) ? -1 : 1; n = Math.Abs(dz);

                dx2 = l << 1; dy2 = m << 1; dz2 = n << 1;

                if ((m >= l) && (m >= n)) { dy = 0; m = 0; dy2 = m << 1; }
                if ((l >= m) && (l >= n))
                {
                    err_1 = dy2 - l;
                    err_2 = dz2 - l;
                    for (i = 0; i < p.level.width; i++)
                    {
                        pos.x = (ushort)pixel[0];
                        pos.y = (ushort)pixel[1];
                        pos.z = (ushort)pixel[2];
                        pos.type = p.level.GetTile(pos.x, pos.y, pos.z);
                        buffer.Add(pos);

                        if (err_1 > 0)
                        {
                            pixel[1] += y_inc;
                            err_1 -= dx2;
                        }
                        if (err_2 > 0)
                        {
                            pixel[2] += z_inc;
                            err_2 -= dx2;
                        }
                        err_1 += dy2;
                        err_2 += dz2;
                        pixel[0] += x_inc;
                    }
                }
                else
                {
                    err_1 = dy2 - n;
                    err_2 = dx2 - n;
                    for (i = 0; i < p.level.depth; i++)
                    {
                        pos.x = (ushort)pixel[0];
                        pos.y = (ushort)pixel[1];
                        pos.z = (ushort)pixel[2];
                        pos.type = p.level.GetTile(pos.x, pos.y, pos.z);
                        buffer.Add(pos);

                        if (err_1 > 0)
                        {
                            pixel[1] += y_inc;
                            err_1 -= dz2;
                        }
                        if (err_2 > 0)
                        {
                            pixel[0] += x_inc;
                            err_2 -= dz2;
                        }
                        err_1 += dy2;
                        err_2 += dx2;
                        pixel[2] += z_inc;
                    }
                }

                pos.x = (ushort)pixel[0];
                pos.y = (ushort)pixel[1];
                pos.z = (ushort)pixel[2];
                pos.type = p.level.GetTile(pos.x, pos.y, pos.z);
                buffer.Add(pos);

                if (p.level.reflectionLines.ContainsKey(p.name.ToLower()))
                    p.level.reflectionLines.Remove(p.name.ToLower());
                p.level.reflectionLines.Add(p.name.ToLower(), buffer);
                #endregion
                p.level.ShowReflectionsLines(p);
                Player.SendMessage(p, "Reflection line set. Use /reflection clear to remove.");
            }
        }
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            List<Pos> buffer = new List<Pos>();

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
            {
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                {
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(xx, yy, zz) != cpos.type) { BufferAdd(buffer, xx, yy, zz); }
                    }
                }
            }

            Level l = p.level;
            p.activeCuboids++;
            Thread t = new Thread(new ThreadStart(delegate
            {
                try
                {
                    int c;
                    if (Server.forceCuboid)
                    {
                        c = 0;
                        int counter = 1;
                        buffer.ForEach(delegate(Pos pos)
                        {
                            if (counter <= p.group.maxBlocks)
                            {
                                c++;
                                if (p.activeCuboids == 0) return;
                                counter++;
                                l.Blockchange(p, pos.x, pos.y, pos.z, type);
                                if (Server.throttle > 0)
                                {
                                    while (Server.pauseCuboids) { Thread.Sleep(1000); }
                                    if (c >= Server.throttle)
                                    {
                                        c = 0;
                                        if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                                    }
                                }
                            }
                        });
                        if (counter >= p.group.maxBlocks)
                        {
                            Player.SendMessage(p, "Tried to cuboid " + buffer.Count + " blocks, but your limit is " + p.group.maxBlocks + ".");
                            Player.SendMessage(p, "Executed cuboid up to limit.");
                        }
                        else
                        {
                            Player.SendMessage(p, buffer.Count.ToString() + " blocks.");
                        }

                        if (p.activeCuboids > 0) p.activeCuboids--;
                        if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                        return;
                    }

                    if (buffer.Count > p.group.maxBlocks)
                    {
                        Player.SendMessage(p, "You tried to replace " + buffer.Count + " blocks.");
                        Player.SendMessage(p, "You cannot replace more than " + p.group.maxBlocks + ".");
                        return;
                    }

                    Player.SendMessage(p, buffer.Count.ToString() + " blocks.");

                    c = 0;
                    buffer.ForEach(delegate(Pos pos)
                    {
                        c++;
                        if (p.activeCuboids == 0) return;
                        l.Blockchange(p, pos.x, pos.y, pos.z, type);
                        if (Server.throttle > 0)
                        {
                            while (Server.pauseCuboids) { Thread.Sleep(1000); }
                            if (c >= Server.throttle)
                            {
                                c = 0;
                                if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                            }
                        }
                    });

                    if (p.activeCuboids > 0) p.activeCuboids--;
                    if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                }
                catch (Exception ex) { Server.ErrorLog(ex); Player.SendMessage(p, "Error!"); return; }
            })); t.IsBackground = true; t.Priority = ThreadPriority.Lowest; t.Start();

            if (buffer.Count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to replace " + buffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot replace more than " + p.group.maxBlocks + ".");
                return;
            }
        }
Exemple #26
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            type = p.bindings[type];

            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);

            CatchPos cpos = (CatchPos)p.blockchangeObject;

            ushort cur;

            if (x == cpos.x && z == cpos.z) { Player.SendMessage(p, "No direction was selected"); return; }

            ushort msgLength = 0; int breaksmade = 0;
            if (Math.Abs(cpos.x - x) > Math.Abs(cpos.z - z))
            {
                cur = cpos.x;
                if (x > cpos.x)
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        msgLength += (ushort)(FindReference.charWidth(c) + 1);
                        if ((ushort)(cpos.x + msgLength) >= p.level.width)
                        {
                            cpos.y = (ushort)(cpos.y - 6);
                            cur = FindReference.writeLetter(p, c, (ushort)(x - 1), cpos.y, cpos.z, type, 0);
                            breaksmade++;
                            msgLength = 0;
                        }
                        else { cur = FindReference.writeLetter(p, c, cur, cpos.y, cpos.z, type, 0); }
                    }
                }
                else
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        msgLength += (ushort)(FindReference.charWidth(c) + 1);
                        if ((ushort)(cpos.x - msgLength) <= 0)
                        {
                            cpos.y = (ushort)(cpos.y - 6);
                            cur = FindReference.writeLetter(p, c, (ushort)(x + 1), cpos.y, cpos.z, type, 0);
                            breaksmade++;
                            msgLength = 0;
                        }
                        else { cur = FindReference.writeLetter(p, c, cur, cpos.y, cpos.z, type, 1); }
                    }
                }
            }
            else
            {
                cur = cpos.z;
                if (z > cpos.z)
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        msgLength += (ushort)(FindReference.charWidth(c) + 1);
                        if ((ushort)(cpos.z + msgLength) >= p.level.width)
                        {
                            cpos.y = (ushort)(cpos.y - 6);
                            cur = FindReference.writeLetter(p, c, cpos.x, cpos.y, (ushort)(z - 1), type, 2);
                            breaksmade++;
                            msgLength = 0;
                        }
                        else { cur = FindReference.writeLetter(p, c, cpos.x, cpos.y, cur, type, 2); }
                    }
                }
                else
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        msgLength += (ushort)(FindReference.charWidth(c) + 1);
                        if ((ushort)(cpos.z - msgLength) <= 0)
                        {
                            cpos.y = (ushort)(cpos.y - 6);
                            cur = FindReference.writeLetter(p, c, cpos.x, cpos.y, (ushort)(z + 1), type, 3);
                            breaksmade++;
                            msgLength = 0;
                        }
                        else { cur = FindReference.writeLetter(p, c, cpos.x, cpos.y, cur, type, 3); }
                    }
                }
            }

            if (breaksmade > 0) { Player.SendMessage(p, breaksmade + " line breaks were added."); }

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
        public void showMBs(Player p)
        {
            p.showMBs = !p.showMBs;

            DataTable Messages = new DataTable("Messages");
            Messages = MySQL.fillData("SELECT * FROM `Messages" + p.level.name + "`");

            int i;

            if (p.showMBs)
            {
                for (i = 0; i < Messages.Rows.Count; i++)
                    p.SendBlockchange((ushort)Messages.Rows[i]["X"], (ushort)Messages.Rows[i]["Y"], (ushort)Messages.Rows[i]["Z"], Block.MsgWhite);
                Player.SendMessage(p, "Now showing &a" + i.ToString() + "&g CommandBlocks.");
            }
            else
            {
                for (i = 0; i < Messages.Rows.Count; i++)
                    p.SendBlockchange((ushort)Messages.Rows[i]["X"], (ushort)Messages.Rows[i]["Y"], (ushort)Messages.Rows[i]["Z"], p.level.GetTile((ushort)Messages.Rows[i]["X"], (ushort)Messages.Rows[i]["Y"], (ushort)Messages.Rows[i]["Z"]));
                Player.SendMessage(p, "Now hiding CommandBlocks.");
            }
            Messages.Dispose();
        }
Exemple #28
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            List<Pos> buffer = new List<Pos>();
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            unchecked { if (cpos.type != (byte)-1) type = cpos.type; else type = p.bindings[type]; }

            ushort xx; ushort yy; ushort zz;

            switch (cpos.solid)
            {
                case SolidType.solid:
                    buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
                    for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                        for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                            for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                            {
                                if (p.level.GetTile(xx, yy, zz) != type) { BufferAdd(buffer, xx, yy, zz); }
                            }
                    break;
                case SolidType.hollow:
                    //todo work out if theres 800 blocks used before making the buffer
                    for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                        for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        {
                            if (p.level.GetTile(cpos.x, yy, zz) != type) { BufferAdd(buffer, cpos.x, yy, zz); }
                            if (cpos.x != x) { if (p.level.GetTile(x, yy, zz) != type) { BufferAdd(buffer, x, yy, zz); } }
                        }
                    if (Math.Abs(cpos.x - x) >= 2)
                    {
                        for (xx = (ushort)(Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
                            for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                            {
                                if (p.level.GetTile(xx, cpos.y, zz) != type) { BufferAdd(buffer, xx, cpos.y, zz); }
                                if (cpos.y != y) { if (p.level.GetTile(xx, y, zz) != type) { BufferAdd(buffer, xx, y, zz); } }
                            }
                        if (Math.Abs(cpos.y - y) >= 2)
                        {
                            for (xx = (ushort)(Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
                                for (yy = (ushort)(Math.Min(cpos.y, y) + 1); yy <= Math.Max(cpos.y, y) - 1; ++yy)
                                {
                                    if (p.level.GetTile(xx, yy, cpos.z) != type) { BufferAdd(buffer, xx, yy, cpos.z); }
                                    if (cpos.z != z) { if (p.level.GetTile(xx, yy, z) != type) { BufferAdd(buffer, xx, yy, z); } }
                                }
                        }
                    }
                    break;
                case SolidType.walls:
                    for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                        for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        {
                            if (p.level.GetTile(cpos.x, yy, zz) != type) { BufferAdd(buffer, cpos.x, yy, zz); }
                            if (cpos.x != x) { if (p.level.GetTile(x, yy, zz) != type) { BufferAdd(buffer, x, yy, zz); } }
                        }
                    if (Math.Abs(cpos.x - x) >= 2)
                    {
                        if (Math.Abs(cpos.z - z) >= 2)
                        {
                            for (xx = (ushort)(Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
                                for (yy = (ushort)(Math.Min(cpos.y, y)); yy <= Math.Max(cpos.y, y); ++yy)
                                {
                                    if (p.level.GetTile(xx, yy, cpos.z) != type) { BufferAdd(buffer, xx, yy, cpos.z); }
                                    if (cpos.z != z) { if (p.level.GetTile(xx, yy, z) != type) { BufferAdd(buffer, xx, yy, z); } }
                                }
                        }
                    }
                    break;
                case SolidType.holes:
                    bool Checked = true, startZ, startY;

                    for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                    {
                        startY = Checked;
                        for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                        {
                            startZ = Checked;
                            for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                            {
                                Checked = !Checked;
                                if (Checked && p.level.GetTile(xx, yy, zz) != type) BufferAdd(buffer, xx, yy, zz);
                            } Checked = !startZ;
                        } Checked = !startY;
                    }
                    break;
                case SolidType.wire:
                    for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                    {
                        BufferAdd(buffer, xx, y, z);
                        BufferAdd(buffer, xx, y, cpos.z);
                        BufferAdd(buffer, xx, cpos.y, z);
                        BufferAdd(buffer, xx, cpos.y, cpos.z);
                    }
                    for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    {
                        BufferAdd(buffer, x, yy, z);
                        BufferAdd(buffer, x, yy, cpos.z);
                        BufferAdd(buffer, cpos.x, yy, z);
                        BufferAdd(buffer, cpos.x, yy, cpos.z);
                    }
                    for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        BufferAdd(buffer, x, y, zz);
                        BufferAdd(buffer, x, cpos.y, zz);
                        BufferAdd(buffer, cpos.x, y, zz);
                        BufferAdd(buffer, cpos.x, cpos.y, zz);
                    }
                    break;
                case SolidType.random:
                    Random rand = new Random();
                    for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                        for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                            for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                            {
                                if (rand.Next(1, 11) <= 5 && p.level.GetTile(xx, yy, zz) != type) { BufferAdd(buffer, xx, yy, zz); }
                            }
                    break;
            }

            Level l = p.level;
            p.activeCuboids++;
            Thread t = new Thread(new ThreadStart(delegate
            {
                try
                {
                    int c;
                    if (Server.forceCuboid)
                    {
                        int counter = 1;
                        c = 0;
                        for (int i = 0; i < buffer.Count; i++)
                        {
                            if (counter <= p.group.maxBlocks)
                            {
                                c++;
                                if (p.activeCuboids == 0) return;
                                counter++;
                                l.Blockchange(p, buffer[i].x, buffer[i].y, buffer[i].z, type);
                                while (Server.pauseCuboids) { Thread.Sleep(1000); }
                                if (c >= Server.throttle)
                                {
                                    c = 0;
                                    if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                                }
                            }
                        }

                        if (counter >= p.group.maxBlocks)
                        {
                            Player.SendMessage(p, "Tried to cuboid " + buffer.Count + " blocks, but your limit is " + p.group.maxBlocks + ".");
                            Player.SendMessage(p, "Executed cuboid up to limit.");
                        }
                        else
                        {
                            Player.SendMessage(p, buffer.Count.ToString() + " blocks.");
                        }

                        if (p.activeCuboids > 0) p.activeCuboids--;
                        if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                        return;
                    }

                    if (buffer.Count > p.group.maxBlocks)
                    {
                        Player.SendMessage(p, "You tried to cuboid " + buffer.Count + " blocks.");
                        Player.SendMessage(p, "You cannot cuboid more than " + p.group.maxBlocks + ".");
                        return;
                    }

                    Player.SendMessage(p, buffer.Count.ToString() + " blocks.");

                    //var st = Stopwatch.StartNew();
                    c = 0;
                    for (int i = 0; i < buffer.Count; i++)
                    {
                        c++;
                        if (p.activeCuboids == 0) return;
                        l.Blockchange(p, buffer[i].x, buffer[i].y, buffer[i].z, type);
                        while (Server.pauseCuboids) { Thread.Sleep(1000); }
                        if (c >= Server.throttle)
                        {
                            c = 0;
                            if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                        }
                    }
                    //st.Stop();
                    //Player.SendMessage(p, "Completed in " + st.Elapsed.TotalMilliseconds + " milliseconds."); st.Reset();

                    if (p.activeCuboids > 0) p.activeCuboids--;
                    if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                }
                catch (Exception ex) { Server.ErrorLog(ex); Player.SendMessage(p, "Error!"); return; }
            })); t.IsBackground = true; t.Priority = ThreadPriority.Lowest; t.Start();
        }
Exemple #29
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            List<Pos> buffer = new List<Pos>();
            Pos pos;

            bool AddMe = false;

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        AddMe = true;

                        if (!Block.RightClick(Block.Convert(p.level.GetTile(xx, yy, zz)), true) && p.level.GetTile(xx, yy, zz) != cpos.countOther)
                        {
                            if (Block.RightClick(Block.Convert(p.level.GetTile((ushort)(xx - 1), yy, zz))) || p.level.GetTile((ushort)(xx - 1), yy, zz) == cpos.countOther) AddMe = false;
                            else if (Block.RightClick(Block.Convert(p.level.GetTile((ushort)(xx + 1), yy, zz))) || p.level.GetTile((ushort)(xx + 1), yy, zz) == cpos.countOther) AddMe = false;
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, (ushort)(yy - 1), zz))) || p.level.GetTile(xx, (ushort)(yy - 1), zz) == cpos.countOther) AddMe = false;
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, (ushort)(yy + 1), zz))) || p.level.GetTile(xx, (ushort)(yy + 1), zz) == cpos.countOther) AddMe = false;
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, yy, (ushort)(zz - 1)))) || p.level.GetTile(xx, yy, (ushort)(zz - 1)) == cpos.countOther) AddMe = false;
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, yy, (ushort)(zz + 1)))) || p.level.GetTile(xx, yy, (ushort)(zz + 1)) == cpos.countOther) AddMe = false;
                        }
                        else AddMe = false;

                        if (AddMe) { pos.x = xx; pos.y = yy; pos.z = zz; buffer.Add(pos); }
                    }

            Level l = p.level;
            p.activeCuboids++;
            Thread t = new Thread(new ThreadStart(delegate
            {
                try
                {
                    int c;
                    if (Server.forceCuboid)
                    {
                        c = 0;
                        int counter = 1;
                        buffer.ForEach(delegate(Pos pos1)
                        {
                            if (counter <= p.group.maxBlocks)
                            {
                                c++;
                                if (p.activeCuboids == 0) return;
                                counter++;
                                l.Blockchange(p, pos1.x, pos1.y, pos1.z, Block.air);
                                if (Server.throttle > 0)
                                {
                                    while (Server.pauseCuboids) { Thread.Sleep(1000); }
                                    if (c >= Server.throttle)
                                    {
                                        c = 0;
                                        if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                                    }
                                }
                            }
                        });
                        if (counter >= p.group.maxBlocks)
                        {
                            Player.SendMessage(p, "Tried to cuboid " + buffer.Count + " blocks, but your limit is " + p.group.maxBlocks + ".");
                            Player.SendMessage(p, "Executed cuboid up to limit.");
                        }
                        else
                        {
                            Player.SendMessage(p, "You hollowed " + buffer.Count + " blocks.");
                        }

                        if (p.activeCuboids > 0) p.activeCuboids--;
                        if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                        return;
                    }

                    if (buffer.Count > p.group.maxBlocks)
                    {
                        Player.SendMessage(p, "You tried to hollow " + buffer.Count + " blocks.");
                        Player.SendMessage(p, "You cannot hollow more than " + p.group.maxBlocks + ".");
                        return;
                    }

                    Player.SendMessage(p, "You hollowed " + buffer.Count + " blocks.");

                    c = 0;
                    buffer.ForEach(delegate(Pos pos1)
                    {
                        c++;
                        if (p.activeCuboids == 0) return;
                        l.Blockchange(p, pos1.x, pos1.y, pos1.z, Block.air);
                        if (Server.throttle > 0)
                        {
                            while (Server.pauseCuboids) { Thread.Sleep(1000); }
                            if (c >= Server.throttle)
                            {
                                c = 0;
                                if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                            }
                        }
                    });

                    if (p.activeCuboids > 0) p.activeCuboids--;
                    if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                }
                catch (Exception ex) { Server.ErrorLog(ex); Player.SendMessage(p, "Error!"); return; }
            })); t.IsBackground = true; t.Priority = ThreadPriority.Lowest; t.Start();
        }
Exemple #30
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            if (cpos.type == Block.Zero) type = p.bindings[type]; else type = cpos.type;
            List<CatchPos> buffer = new List<CatchPos>();
            CatchPos pos = new CatchPos();

            if (cpos.extraType == 2)
            {  //Fun part of making a straight line
                int xdif = Math.Abs(cpos.x - x);
                int ydif = Math.Abs(cpos.y - y);
                int zdif = Math.Abs(cpos.z - z);

                if (xdif > ydif && xdif > zdif)
                {
                    y = cpos.y; z = cpos.z;
                }
                else if (ydif > xdif && ydif > zdif)
                {
                    x = cpos.x; z = cpos.z;
                }
                else if (zdif > ydif && zdif > xdif)
                {
                    y = cpos.y; x = cpos.x;
                }
            }

            if (cpos.maxNum == 0) cpos.maxNum = 100000;

            int i, dx, dy, dz, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2;
            int[] pixel = new int[3];

            pixel[0] = cpos.x; pixel[1] = cpos.y; pixel[2] = cpos.z;
            dx = x - cpos.x; dy = y - cpos.y; dz = z - cpos.z;

            x_inc = (dx < 0) ? -1 : 1; l = Math.Abs(dx);
            y_inc = (dy < 0) ? -1 : 1; m = Math.Abs(dy);
            z_inc = (dz < 0) ? -1 : 1; n = Math.Abs(dz);

            dx2 = l << 1; dy2 = m << 1; dz2 = n << 1;

            if ((l >= m) && (l >= n))
            {
                err_1 = dy2 - l;
                err_2 = dz2 - l;
                for (i = 0; i < l; i++)
                {
                    pos.x = (ushort)pixel[0];
                    pos.y = (ushort)pixel[1];
                    pos.z = (ushort)pixel[2];
                    buffer.Add(pos);

                    if (err_1 > 0)
                    {
                        pixel[1] += y_inc;
                        err_1 -= dx2;
                    }
                    if (err_2 > 0)
                    {
                        pixel[2] += z_inc;
                        err_2 -= dx2;
                    }
                    err_1 += dy2;
                    err_2 += dz2;
                    pixel[0] += x_inc;
                }
            }
            else if ((m >= l) && (m >= n))
            {
                err_1 = dx2 - m;
                err_2 = dz2 - m;
                for (i = 0; i < m; i++)
                {
                    pos.x = (ushort)pixel[0];
                    pos.y = (ushort)pixel[1];
                    pos.z = (ushort)pixel[2];
                    buffer.Add(pos);

                    if (err_1 > 0)
                    {
                        pixel[0] += x_inc;
                        err_1 -= dy2;
                    }
                    if (err_2 > 0)
                    {
                        pixel[2] += z_inc;
                        err_2 -= dy2;
                    }
                    err_1 += dx2;
                    err_2 += dz2;
                    pixel[1] += y_inc;
                }
            }
            else
            {
                err_1 = dy2 - n;
                err_2 = dx2 - n;
                for (i = 0; i < n; i++)
                {
                    pos.x = (ushort)pixel[0];
                    pos.y = (ushort)pixel[1];
                    pos.z = (ushort)pixel[2];
                    buffer.Add(pos);

                    if (err_1 > 0)
                    {
                        pixel[1] += y_inc;
                        err_1 -= dz2;
                    }
                    if (err_2 > 0)
                    {
                        pixel[0] += x_inc;
                        err_2 -= dz2;
                    }
                    err_1 += dy2;
                    err_2 += dx2;
                    pixel[2] += z_inc;
                }
            }

            pos.x = (ushort)pixel[0];
            pos.y = (ushort)pixel[1];
            pos.z = (ushort)pixel[2];
            buffer.Add(pos);

            int count;
            count = Math.Min(buffer.Count, cpos.maxNum);
            if (cpos.extraType == 1) count = count * Math.Abs(cpos.y - y);

            if (count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to fill " + count + " blocks at once.");
                Player.SendMessage(p, "You are limited to " + p.group.maxBlocks);
                return;
            }

            for (count = 0; count < cpos.maxNum && count < buffer.Count; count++)
            {
                if (cpos.extraType != 1)
                {
                    p.level.Blockchange(p, buffer[count].x, buffer[count].y, buffer[count].z, type);
                }
                else
                {
                    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy++)
                    {
                        p.level.Blockchange(p, buffer[count].x, yy, buffer[count].z, type);
                    }
                }
            }

            Player.SendMessage(p, "Line was " + count.ToString() + " blocks long.");

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }