Ejemplo n.º 1
0
        bool RedoBlocks(Player p, Action <DrawOpBlock> output)
        {
            UndoFormatArgs args   = new UndoFormatArgs(p, Start, End, output);
            UndoFormat     format = new UndoFormatOnline(p.UndoBuffer);

            UndoFormat.DoRedo(null, format, args);
            return(args.Stop);
        }
Ejemplo n.º 2
0
        static bool HighlightBlocks(Player p, DateTime start, UndoCache cache)
        {
            UndoFormatArgs args   = new UndoFormatArgs(p, start, DateTime.MaxValue, null);
            UndoFormat     format = new UndoFormatOnline(cache);

            UndoFormat.DoHighlight(null, format, args);
            return(args.Stop);
        }
Ejemplo n.º 3
0
        public override void Perform(Vec3S32[] marks, Brush brush, Action <DrawOpBlock> output)
        {
            string         target = whoName.ToLower();
            UndoFormatArgs args   = new UndoFormatArgs(Player, Start, DateTime.MaxValue, output);

            if (Min.X != ushort.MaxValue)
            {
                UndoFormat.DoUndoArea(target, Min, Max, ref found, args);
            }
            else
            {
                UndoFormat.DoUndo(target, ref found, args);
            }
        }
Ejemplo n.º 4
0
        bool UndoBlocks(Player p, Player who, Action <DrawOpBlock> output)
        {
            UndoFormatArgs args   = new UndoFormatArgs(p, Start, End, output);
            UndoFormat     format = new UndoFormatOnline(who.UndoBuffer);

            if (Min.X != ushort.MaxValue)
            {
                UndoFormat.DoUndoArea(null, Min, Max, format, args);
            }
            else
            {
                UndoFormat.DoUndo(null, format, args);
            }
            return(args.Stop);
        }
Ejemplo n.º 5
0
        public override void Use(Player p, string message)
        {
            if (CheckSuper(p, message, "player name"))
            {
                return;
            }
            int ignored = 0;

            if (message == "")
            {
                UndoSelf(p); return;
            }
            else if (p != null && int.TryParse(message, out ignored))
            {
                message = p.name.ToLower() + " " + message;
            }

            string[] parts       = message.Split(' ');
            bool     undoPhysics = parts[0].CaselessEq("physics");
            Player   who         = undoPhysics ? null : PlayerInfo.Find(parts[0]);
            TimeSpan delta       = GetDelta(p, who, parts.Length > 1 ? parts[1] : "30m");

            if (delta == TimeSpan.MinValue)
            {
                return;
            }

            if (parts.Length > 1 && parts[1].CaselessEq("update"))
            {
                UndoFormat.UpgradePlayerUndoFiles(parts[0]);
                Player.Message(p, "Updated undo files for " + parts[0] + " to the new binary format.");
                return;
            }

            Vec3S32[] marks = new Vec3S32[] { Vec3U16.MaxVal, Vec3U16.MaxVal };
            if (who != null)
            {
                UndoOnlinePlayer(p, delta, who, marks);
            }
            else if (undoPhysics)
            {
                UndoLevelPhysics(p, delta);
            }
            else
            {
                UndoOfflinePlayer(p, delta, parts[0], marks);
            }
        }
Ejemplo n.º 6
0
        public override void Perform(Vec3S32[] marks, Brush brush, Action <DrawOpBlock> output)
        {
            UndoCache cache = Player.UndoBuffer;

            using (IDisposable locker = cache.ClearLock.AccquireReadLock()) {
                if (RedoBlocks(Player, output))
                {
                    return;
                }
            }

            bool           found = false;
            UndoFormatArgs args  = new UndoFormatArgs(Player, Start, End, output);

            UndoFormat.DoRedo(Player.name.ToLower(), ref found, args);
        }
Ejemplo n.º 7
0
        void PerformOldUndo(UndoFormatArgs args)
        {
            List <string> files = UndoFormat.GetUndoFiles(who.ToLower());

            if (files.Count == 0)
            {
                return;
            }
            found = true;

            foreach (string file in files)
            {
                using (Stream s = File.OpenRead(file)) {
                    UndoFormat.GetFormat(file).EnumerateEntries(s, args);
                    if (args.Finished)
                    {
                        break;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public override void Perform(Vec3S32[] marks, Brush brush, Action <DrawOpBlock> output)
        {
            UndoCache cache = who.UndoBuffer;

            using (IDisposable locker = cache.ClearLock.AccquireReadLock()) {
                if (UndoBlocks(Player, who, output))
                {
                    return;
                }
            }
            bool   found  = false;
            string target = who.name.ToLower();

            UndoFormatArgs args = new UndoFormatArgs(Player, Start, End, output);

            if (Min.X != ushort.MaxValue)
            {
                UndoFormat.DoUndoArea(target, Min, Max, ref found, args);
            }
            else
            {
                UndoFormat.DoUndo(target, ref found, args);
            }
        }
Ejemplo n.º 9
0
        public override void Use(Player p, string message)
        {
            TimeSpan delta;
            bool     found = false;

            if (Player.IsSuper(p))
            {
                MessageInGameOnly(p); return;
            }
            if (message == "")
            {
                message = p.name + " 1800";
            }
            string[] args = message.Split(' ');

            if (args.Length >= 2)
            {
                if (!args[1].TryParseShort(p, 's', "highlight the past", out delta))
                {
                    return;
                }
            }
            else if (ParseTimespan(args[0], out delta))
            {
                args[0] = p.name;
            }
            else
            {
                delta = TimeSpan.FromMinutes(30);
            }

            DateTime start = DateTime.UtcNow.Subtract(delta);
            Player   who   = PlayerInfo.Find(args[0]);
            bool     done  = false;

            if (who != null)
            {
                found = true;
                UndoCache cache = who.UndoBuffer;
                using (IDisposable locker = cache.ClearLock.AccquireReadLock()) {
                    done = HighlightBlocks(p, start, cache);
                }
            }

            if (!done)
            {
                UndoFormatArgs undoArgs = new UndoFormatArgs(p, start, DateTime.MaxValue, null);
                UndoFormat.DoHighlight(args[0].ToLower(), ref found, undoArgs);
            }

            if (found)
            {
                Player.Message(p, "Now highlighting past &b{0} %Sfor {1}",
                               delta.Shorten(), PlayerInfo.GetColoredName(p, args[0]));
                Player.Message(p, "&cUse /reload to un-highlight");
            }
            else
            {
                Player.Message(p, "Could not find player specified.");
            }
        }