diff --git a/MCGalaxy/Database/BlockDB/BlockDB.cs b/MCGalaxy/Database/BlockDB/BlockDB.cs index 24951d3d0..ff1ca1a7d 100644 --- a/MCGalaxy/Database/BlockDB/BlockDB.cs +++ b/MCGalaxy/Database/BlockDB/BlockDB.cs @@ -128,7 +128,7 @@ namespace MCGalaxy.DB { int count = Cache.Count, index = (y * dims.Z + z) * dims.X + x; BlockDBEntry[] items = Cache.Items; - for (int i = count - 1; i >= 0; i--) { + for (int i = 0; i < count; i++) { if (items[i].Index != index) continue; output(items[i]); } diff --git a/MCGalaxy/Drawing/DrawOps/DrawOp.Performer.cs b/MCGalaxy/Drawing/DrawOps/DrawOp.Performer.cs index e7c9ac684..679eeafe2 100644 --- a/MCGalaxy/Drawing/DrawOps/DrawOp.Performer.cs +++ b/MCGalaxy/Drawing/DrawOps/DrawOp.Performer.cs @@ -129,7 +129,7 @@ namespace MCGalaxy.Drawing.Ops { if (item.Brush != null) item.Brush.Configure(item.Op, p); DoDrawOp(item, p); - timeDelta = (int)DateTime.UtcNow.Subtract(Server.StartTime).TotalSeconds; + timeDelta = (int)DateTime.UtcNow.Subtract(Server.StartTime).TotalSeconds + 1; entry.End = Server.StartTime.AddTicks(timeDelta * TimeSpan.TicksPerSecond); p.DrawOps.Add(entry); diff --git a/MCGalaxy/Drawing/DrawOps/RedoDrawOp.cs b/MCGalaxy/Drawing/DrawOps/RedoDrawOp.cs index c08d2e0b6..da0641132 100644 --- a/MCGalaxy/Drawing/DrawOps/RedoDrawOp.cs +++ b/MCGalaxy/Drawing/DrawOps/RedoDrawOp.cs @@ -40,31 +40,27 @@ namespace MCGalaxy.Drawing.Ops { public override void Perform(Vec3S32[] marks, Brush brush, Action output) { int[] ids = NameConverter.FindIds(Player.name); - Server.s.Log("FFFOUND: " + ids.Length); - if (ids.Length > 0) { - if (Level.BlockDB.FindChangesBy(ids, Start, End, out dims, RedoBlock)) return; - } + if (ids.Length == 0) return; - bool found = false; - UndoFormatArgs args = new UndoFormatArgs(Player, Start, End, output); - UndoFormat.DoRedo(Player.name.ToLower(), ref found, args); + this.output = output; + Level.BlockDB.FindChangesBy(ids, Start, End, out dims, RedoBlock); + this.output = null; } + Action output; Vec3U16 dims; void RedoBlock(BlockDBEntry entry) { byte block = entry.OldRaw, ext = 0; if ((entry.Flags & BlockDBFlags.OldCustom) != 0) { ext = block; block = Block.custom_block; - } - Server.s.Log("FFFFFFF " + block); if (block == Block.Invalid) return; // Exported BlockDB SQL table entries don't have previous block if ((entry.Flags & BlockDBFlags.UndoSelf) == 0) return; // not an undo int x = entry.Index % dims.X; int y = (entry.Index / dims.X) / dims.Z; int z = (entry.Index / dims.X) % dims.Z; - Place((ushort)x, (ushort)y, (ushort)z, block, ext); + output(Place((ushort)x, (ushort)y, (ushort)z, block, ext)); } } } diff --git a/MCGalaxy/Player/Undo/UndoFormat.Helpers.cs b/MCGalaxy/Player/Undo/UndoFormat.Helpers.cs index 92eb429e4..49008e902 100644 --- a/MCGalaxy/Player/Undo/UndoFormat.Helpers.cs +++ b/MCGalaxy/Player/Undo/UndoFormat.Helpers.cs @@ -111,31 +111,6 @@ namespace MCGalaxy.Undo { } - public static void DoRedo(string target, ref bool found, UndoFormatArgs args) { - List files = GetUndoFiles(target); - if (files.Count == 0) return; - found = true; - - foreach (string file in files) { - using (Stream s = File.OpenRead(file)) { - DoRedo(s, GetFormat(file), args); - if (args.Stop) break; - } - } - } - - public static void DoRedo(Stream s, UndoFormat format, UndoFormatArgs args) { - DrawOpBlock block; - foreach (UndoFormatEntry P in format.GetEntries(s, args)) { - if (P.Time > args.End) continue; - - block.X = P.X; block.Y = P.Y; block.Z = P.Z; - block.Block = P.Block; block.ExtBlock = P.ExtBlock; - args.Output(block); - } - } - - public static void UpgradePlayerUndoFiles(string name) { UpgradeFiles(undoDir, name); UpgradeFiles(prevUndoDir, name);