diff --git a/Commands/Moderation/CmdHighlight.cs b/Commands/Moderation/CmdHighlight.cs index b43188737..8cecb79db 100644 --- a/Commands/Moderation/CmdHighlight.cs +++ b/Commands/Moderation/CmdHighlight.cs @@ -35,7 +35,7 @@ namespace MCGalaxy.Commands { long seconds; bool found = false; if (Player.IsSuper(p)) { MessageInGameOnly(p); return; } - if (message == "") message = p.name + " 300"; + if (message == "") message = p.name + " 1800"; string[] args = message.Split(' '); string name = args[0]; @@ -46,9 +46,9 @@ namespace MCGalaxy.Commands { } else if (long.TryParse(args[0], out seconds)) { args[0] = p.name; } else { - seconds = 300; + seconds = 30 * 60; } - if (seconds <= 0) seconds = 5400; + if (seconds <= 0) seconds = 30 * 60; DateTime start = DateTime.UtcNow.AddTicks(-seconds * TimeSpan.TicksPerSecond); Player who = PlayerInfo.Find(name); diff --git a/Drawing/DrawOps/UndoDrawOp.cs b/Drawing/DrawOps/UndoDrawOp.cs index 92f459532..9e22c7dfb 100644 --- a/Drawing/DrawOps/UndoDrawOp.cs +++ b/Drawing/DrawOps/UndoDrawOp.cs @@ -90,7 +90,7 @@ namespace MCGalaxy.Drawing.Ops { item.GetNewBlock(out Pos.newtype, out Pos.newExtType); item.GetBlock(out Pos.type, out Pos.extType); - UndoFormat.UndoBlock(p, lvl, Pos, timeDelta, buffer); + UndoFormat.UndoBlock(p, lvl, Pos, buffer); } buffer.CheckIfSend(true); node = node.Prev; diff --git a/Player/Undo/UndoFormat.cs b/Player/Undo/UndoFormat.cs index 9981ebd6e..1c5608eaf 100644 --- a/Player/Undo/UndoFormat.cs +++ b/Player/Undo/UndoFormat.cs @@ -77,8 +77,7 @@ namespace MCGalaxy.Undo { static void FilterEntries(Player p, string dir, string name, Vec3S32[] marks, DateTime start, bool highlight, ref bool FoundUser) { string path = Path.Combine(dir, name); - if (!Directory.Exists(path)) - return; + if (!Directory.Exists(path)) return; string[] files = Directory.GetFiles(path); Array.Sort(files, CompareFiles); UndoEntriesArgs args = new UndoEntriesArgs(p, start); @@ -99,7 +98,7 @@ namespace MCGalaxy.Undo { if (highlight) { DoHighlight(s, format, args); } else { - // TODO: fixy fix if (!format.UndoEntry(p, path, marks, ref temp, start)) break; + DoUndo(s, format, args); } if (args.Stop) break; } @@ -117,8 +116,43 @@ namespace MCGalaxy.Undo { return aNum.CompareTo(bNum); } + public static void DoHighlight(Stream s, UndoFormat format, UndoEntriesArgs args) { + BufferedBlockSender buffer = new BufferedBlockSender(args.Player); + Level lvl = args.Player.level; + + foreach (Player.UndoPos P in format.GetEntries(s, args)) { + byte type = P.type, newType = P.newtype; + byte block = (newType == Block.air + || Block.Convert(type) == Block.water || type == Block.waterstill + || Block.Convert(type) == Block.lava || type == Block.lavastill) + ? Block.red : Block.green; + + buffer.Add(lvl.PosToInt(P.x, P.y, P.z), block, 0); + buffer.CheckIfSend(false); + } + buffer.CheckIfSend(true); + } + + public static void DoUndo(Stream s, UndoFormat format, UndoEntriesArgs args) { + Level lvl = args.Player == null ? null : args.Player.level; + BufferedBlockSender buffer = new BufferedBlockSender(lvl); + string lastMap = null; + + foreach (Player.UndoPos P in format.GetEntries(s, args)) { + if (P.mapName != lastMap) { + lvl = LevelInfo.FindExact(P.mapName); + buffer.CheckIfSend(true); + buffer.level = lvl; + } + + if (lvl == null) continue; + UndoBlock(args.Player, lvl, P, buffer); + } + buffer.CheckIfSend(true); + } + protected internal static void UndoBlock(Player pl, Level lvl, Player.UndoPos P, - int timeDelta, BufferedBlockSender buffer) { + BufferedBlockSender buffer) { byte lvlTile = lvl.GetTile(P.x, P.y, P.z); if (lvlTile == P.newtype || Block.Convert(lvlTile) == Block.water || Block.Convert(lvlTile) == Block.lava || lvlTile == Block.grass) { @@ -126,7 +160,6 @@ namespace MCGalaxy.Undo { byte newExtType = P.newExtType; P.newtype = P.type; P.newExtType = P.extType; P.extType = newExtType; P.type = lvlTile; - P.timeDelta = timeDelta; if (pl != null) { if (lvl.DoBlockchange(pl, P.x, P.y, P.z, P.newtype, P.newExtType, true)) { @@ -149,23 +182,6 @@ namespace MCGalaxy.Undo { } } - public static void DoHighlight(Stream s, UndoFormat format, UndoEntriesArgs args) { - BufferedBlockSender buffer = new BufferedBlockSender(args.Player); - Level lvl = args.Player.level; - - foreach (Player.UndoPos P in format.GetEntries(s, args)) { - byte type = P.type, newType = P.newtype; - byte block = (newType == Block.air - || Block.Convert(type) == Block.water || type == Block.waterstill - || Block.Convert(type) == Block.lava || type == Block.lavastill) - ? Block.red : Block.green; - - buffer.Add(lvl.PosToInt(P.x, P.y, P.z), block, 0); - buffer.CheckIfSend(false); - } - buffer.CheckIfSend(true); - } - public static void CreateDefaultDirectories() { if (!Directory.Exists(undoDir)) @@ -193,8 +209,7 @@ namespace MCGalaxy.Undo { IEnumerable data = null; using (FileStream s = File.OpenRead(path)) { data = path.EndsWith(BinFormat.Ext) - ? BinFormat.GetEntries(s, args) - : TxtFormat.GetEntries(s, args); + ? BinFormat.GetEntries(s, args) : TxtFormat.GetEntries(s, args); foreach (Player.UndoPos pos in data) buffer.Add(pos);