コード例 #1
0
        public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush)
        {
            PerformUndo(p, ref saveLevel);
            bool foundUser = false;

            UndoFile.UndoPlayer(p, who.name.ToLower(), marks, Start, ref foundUser);
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: Peteys93/MCGalaxy
 public static void SaveUndo(Player p)
 {
     try {
         UndoFile.SaveUndo(p);
     } catch (Exception e) {
         Server.s.Log("Error saving undo data for " + p.name + "!"); Server.ErrorLog(e);
     }
 }
コード例 #3
0
ファイル: CmdHighlight.cs プロジェクト: Peteys93/MCGalaxy
        public override void Use(Player p, string message)
        {
            long seconds;
            bool FoundUser = false;

            if (p == null)
            {
                MessageInGameOnly(p); return;
            }
            if (message == "")
            {
                message = p.name + " 300";
            }
            string[] args = message.Split(' ');
            string   name = args[0];

            if (args.Length >= 2)
            {
                if (!long.TryParse(args[1], out seconds))
                {
                    Player.SendMessage(p, "Invalid seconds."); return;
                }
            }
            else if (long.TryParse(args[0], out seconds))
            {
                args[0] = p.name;
            }
            else
            {
                seconds = 300;
            }
            if (seconds <= 0)
            {
                seconds = 5400;
            }

            Player who = PlayerInfo.Find(name);

            if (who != null)
            {
                FoundUser = true;
                PerformHighlight(p, seconds, who.UndoBuffer);
            }

            DateTime start = DateTime.UtcNow.AddTicks(-seconds * TimeSpan.TicksPerSecond);

            UndoFile.HighlightPlayer(p, name.ToLower(), start, ref FoundUser);
            if (FoundUser)
            {
                Player.SendMessage(p, "Now highlighting &b" + seconds + " %Sseconds for " + Server.FindColor(name) + name);
                Player.SendMessage(p, "&cUse /reload to un-highlight");
            }
            else
            {
                Player.SendMessage(p, "Could not find player specified.");
            }
        }
コード例 #4
0
        public override void Use(Player p, string message)
        {
            int ignored = 0;

            if (message == "")
            {
                if (p == null)
                {
                    Player.SendMessage(null, "Console doesn't have an undo buffer."); return;
                }
                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]);
            long     seconds     = GetSeconds(p, who, parts.Length > 1 ? parts[1] : "30");

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

            if (who != null)
            {
                UndoOnlinePlayer(p, seconds, who);
            }
            else if (undoPhysics)
            {
                UndoLevelPhysics(p, seconds);
            }
            else
            {
                UndoOfflinePlayer(p, seconds, parts[0]);
            }
        }
コード例 #5
0
        void PerformUndo(Player p, ref Level saveLvl)
        {
            UndoCache     cache = who.UndoBuffer;
            UndoCacheNode node  = cache.Tail;

            if (node == null)
            {
                return;
            }

            Vec3U16 min = Min, max = Max;
            bool    undoArea = min.X != ushort.MaxValue;

            Player.UndoPos Pos       = default(Player.UndoPos);
            int            timeDelta = (int)DateTime.UtcNow.Subtract(Server.StartTime).TotalSeconds;

            while (node != null)
            {
                Level lvl = LevelInfo.FindExact(node.MapName);
                if (lvl == null || (p.level != null && !p.level.name.CaselessEq(lvl.name)))
                {
                    node = node.Prev; continue;
                }
                Pos.mapName = lvl.name;

                saveLvl = lvl;
                List <UndoCacheItem> items  = node.Items;
                BufferedBlockSender  buffer = new BufferedBlockSender(lvl);
                if (!undoArea)
                {
                    min = new Vec3U16(0, 0, 0);
                    max = new Vec3U16((ushort)(lvl.Width - 1), (ushort)(lvl.Height - 1), (ushort)(lvl.Length - 1));
                }

                for (int i = items.Count - 1; i >= 0; i--)
                {
                    UndoCacheItem item = items[i];
                    node.Unpack(item.Index, out Pos.x, out Pos.y, out Pos.z);
                    if (Pos.x < min.X || Pos.y < min.Y || Pos.z < min.Z ||
                        Pos.x > max.X || Pos.y > max.Y || Pos.z > max.Z)
                    {
                        continue;
                    }

                    DateTime time = node.BaseTime.AddTicks(item.TimeDelta * TimeSpan.TicksPerSecond);
                    if (time > End)
                    {
                        continue;
                    }
                    if (time < Start)
                    {
                        buffer.CheckIfSend(true); return;
                    }

                    item.GetNewBlock(out Pos.newtype, out Pos.newExtType);
                    item.GetBlock(out Pos.type, out Pos.extType);
                    UndoFile.UndoBlock(p, lvl, Pos, timeDelta, buffer);
                }
                buffer.CheckIfSend(true);
                node = node.Prev;
            }
        }
コード例 #6
0
 public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush)
 {
     UndoFile.UndoPlayer(p, whoName.ToLower(), marks, Start, ref foundUser);
 }
コード例 #7
0
 public static void DeleteUndoFiles()
 {
     UndoFile.DeleteAllUndoFiles(App.AppUndoFolder);
 }