diff --git a/Drawing/DrawOps/DrawOp.Performer.cs b/Drawing/DrawOps/DrawOp.Performer.cs index 3d8f85abb..b64b36c18 100644 --- a/Drawing/DrawOps/DrawOp.Performer.cs +++ b/Drawing/DrawOps/DrawOp.Performer.cs @@ -68,9 +68,15 @@ namespace MCGalaxy.Drawing.Ops { static void AppendDrawOp(Player p, DrawOp op, Brush brush, Vec3S32[] marks, long affected) { if (p == null) { - foreach (var block in op.Perform(marks, p, op.Level, brush)) - op.Level.Blockchange(block.X, block.Y, block.Z, block.Block, - false, default(PhysicsArgs), block.ExtBlock); + BufferedBlockSender buffer = new BufferedBlockSender(op.Level); + foreach (var b in op.Perform(marks, p, op.Level, brush)) { + int index = op.Level.PosToInt(b.X, b.Y, b.Z); + if (!op.Level.DoPhysicsBlockchange(index, b.Block, false, + default(PhysicsArgs), b.ExtBlock)) continue; + + buffer.Add(index, b.Block, b.ExtBlock); + } + buffer.Send(true); return; } diff --git a/Levels/BlockQueue.cs b/Levels/BlockQueue.cs index 97649137a..c318244aa 100644 --- a/Levels/BlockQueue.cs +++ b/Levels/BlockQueue.cs @@ -78,12 +78,10 @@ namespace MCGalaxy { ulong flags = lvl.blockqueue[i]; int index = (int)(flags >> 32); byte type = (flags & 0x100) != 0 ? Block.custom_block : (byte)flags; - byte extType = (flags & 0x100) != 0 ? (byte)flags : Block.air; - + byte extType = (flags & 0x100) != 0 ? (byte)flags : Block.air; bulkSender.Add(index, type, extType); - bulkSender.CheckIfSend(false); } - bulkSender.CheckIfSend(true); + bulkSender.Send(true); lvl.blockqueue.RemoveRange(0, count); } catch (Exception e) { Server.s.ErrorCase("error:" + e); diff --git a/Levels/Level.Physics.cs b/Levels/Level.Physics.cs index b16230b11..4dd1cd041 100644 --- a/Levels/Level.Physics.cs +++ b/Levels/Level.Physics.cs @@ -188,10 +188,9 @@ namespace MCGalaxy { } catch { Server.s.Log("Phys update issue"); } - bulkSender.CheckIfSend(false); } if (bulkSender != null) - bulkSender.CheckIfSend(true); + bulkSender.Send(true); ListUpdate.Clear(); listUpdateExists.Clear(); } catch (Exception e) { Server.s.Log("Level physics error"); diff --git a/Player/Player.Fields.cs b/Player/Player.Fields.cs index 2f467522d..a1e658126 100644 --- a/Player/Player.Fields.cs +++ b/Player/Player.Fields.cs @@ -72,7 +72,7 @@ namespace MCGalaxy { public bool IsAfk = false, AutoAfk; public bool cmdTimer = false; public bool UsingWom = false; - public string BrushName = "normal", DefaultBrushArgs = ""; + public string BrushName = "normal", DefaultBrushArgs = "", TransformName = "none"; public string afkMessage; byte[] leftBuffer = new byte[0]; diff --git a/Player/Undo/UndoFormat.Helpers.cs b/Player/Undo/UndoFormat.Helpers.cs index 74e40e0fd..8d7873c14 100644 --- a/Player/Undo/UndoFormat.Helpers.cs +++ b/Player/Undo/UndoFormat.Helpers.cs @@ -48,14 +48,14 @@ namespace MCGalaxy.Undo { foreach (UndoFormatEntry P in format.GetEntries(s, args)) { if (P.LevelName != lastMap) { lvl = LevelInfo.FindExact(P.LevelName); - buffer.CheckIfSend(true); + buffer.Send(true); buffer.level = lvl; } if (lvl == null || P.Time > end) continue; UndoBlock(args.Player, lvl, P, buffer); } - buffer.CheckIfSend(true); + buffer.Send(true); } @@ -82,7 +82,7 @@ namespace MCGalaxy.Undo { foreach (UndoFormatEntry P in format.GetEntries(s, args)) { if (P.LevelName != lastMap) { lvl = LevelInfo.FindExact(P.LevelName); - buffer.CheckIfSend(true); + buffer.Send(true); buffer.level = lvl; } @@ -91,7 +91,7 @@ namespace MCGalaxy.Undo { if (P.X > max.X || P.Y > max.Y || P.Z > max.Z) continue; UndoBlock(args.Player, lvl, P, buffer); } - buffer.CheckIfSend(true); + buffer.Send(true); } @@ -121,9 +121,8 @@ namespace MCGalaxy.Undo { ? Block.red : Block.green; buffer.Add(lvl.PosToInt(P.X, P.Y, P.Z), highlight, 0); - buffer.CheckIfSend(false); } - buffer.CheckIfSend(true); + buffer.Send(true); } @@ -149,12 +148,10 @@ namespace MCGalaxy.Undo { foreach (UndoFormatEntry P in format.GetEntries(s, args)) { if (P.Time > end) continue; - if (!lvl.DoBlockchange(p, P.X, P.Y, P.Z, P.Block, P.ExtBlock, true)) continue; - + if (!lvl.DoBlockchange(p, P.X, P.Y, P.Z, P.Block, P.ExtBlock, true)) continue; buffer.Add(lvl.PosToInt(P.X, P.Y, P.Z), P.Block, P.ExtBlock); - buffer.CheckIfSend(false); } - buffer.CheckIfSend(true); + buffer.Send(true); } @@ -206,18 +203,14 @@ namespace MCGalaxy.Undo { lvl.changed = true; if (pl != null) { - if (lvl.DoBlockchange(pl, P.X, P.Y, P.Z, P.Block, P.ExtBlock, true)) { + if (lvl.DoBlockchange(pl, P.X, P.Y, P.Z, P.Block, P.ExtBlock, true)) buffer.Add(lvl.PosToInt(P.X, P.Y, P.Z), P.Block, P.ExtBlock); - buffer.CheckIfSend(false); - } } else { bool diff = Block.Convert(lvlBlock) != Block.Convert(P.Block); if (!diff && lvlBlock == Block.custom_block) diff = lvl.GetExtTile(P.X, P.Y, P.Z) != P.ExtBlock; - if (diff) { + if (diff) buffer.Add(lvl.PosToInt(P.X, P.Y, P.Z), P.Block, P.ExtBlock); - buffer.CheckIfSend(false); - } lvl.SetTile(P.X, P.Y, P.Z, P.Block); if (P.ExtBlock == Block.custom_block) diff --git a/util/BufferedBlockSender.cs b/util/BufferedBlockSender.cs index b7c31a692..edaa52131 100644 --- a/util/BufferedBlockSender.cs +++ b/util/BufferedBlockSender.cs @@ -42,21 +42,25 @@ namespace MCGalaxy { this.level = player.level; } - public void Add(int index, byte type, byte extType) { + public bool Add(int index, byte type, byte extType) { indices[count] = index; if (type == Block.custom_block) types[count] = extType; else types[count] = Block.Convert(type); count++; + return Send(false); } /// Sends the block change packets if either 'force' is true, /// or the number of blocks in the buffer has reached the limit. - public void CheckIfSend(bool force) { + /// Whether block change packets were actually sent. + public bool Send(bool force) { if (count > 0 && (force || count == 256)) { if (player != null) SendPlayer(); else SendLevel(); count = 0; + return false; } + return true; } void SendLevel() {