mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Use more efficient bulk block sending for console draw ops (i.e. /undo). [Untested]
This commit is contained in:
parent
ad08d6fa7e
commit
f17b95891f
@ -68,9 +68,15 @@ namespace MCGalaxy.Drawing.Ops {
|
|||||||
|
|
||||||
static void AppendDrawOp(Player p, DrawOp op, Brush brush, Vec3S32[] marks, long affected) {
|
static void AppendDrawOp(Player p, DrawOp op, Brush brush, Vec3S32[] marks, long affected) {
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
foreach (var block in op.Perform(marks, p, op.Level, brush))
|
BufferedBlockSender buffer = new BufferedBlockSender(op.Level);
|
||||||
op.Level.Blockchange(block.X, block.Y, block.Z, block.Block,
|
foreach (var b in op.Perform(marks, p, op.Level, brush)) {
|
||||||
false, default(PhysicsArgs), block.ExtBlock);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,12 +78,10 @@ namespace MCGalaxy {
|
|||||||
ulong flags = lvl.blockqueue[i];
|
ulong flags = lvl.blockqueue[i];
|
||||||
int index = (int)(flags >> 32);
|
int index = (int)(flags >> 32);
|
||||||
byte type = (flags & 0x100) != 0 ? Block.custom_block : (byte)flags;
|
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.Add(index, type, extType);
|
||||||
bulkSender.CheckIfSend(false);
|
|
||||||
}
|
}
|
||||||
bulkSender.CheckIfSend(true);
|
bulkSender.Send(true);
|
||||||
lvl.blockqueue.RemoveRange(0, count);
|
lvl.blockqueue.RemoveRange(0, count);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Server.s.ErrorCase("error:" + e);
|
Server.s.ErrorCase("error:" + e);
|
||||||
|
@ -188,10 +188,9 @@ namespace MCGalaxy {
|
|||||||
} catch {
|
} catch {
|
||||||
Server.s.Log("Phys update issue");
|
Server.s.Log("Phys update issue");
|
||||||
}
|
}
|
||||||
bulkSender.CheckIfSend(false);
|
|
||||||
}
|
}
|
||||||
if (bulkSender != null)
|
if (bulkSender != null)
|
||||||
bulkSender.CheckIfSend(true);
|
bulkSender.Send(true);
|
||||||
ListUpdate.Clear(); listUpdateExists.Clear();
|
ListUpdate.Clear(); listUpdateExists.Clear();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Server.s.Log("Level physics error");
|
Server.s.Log("Level physics error");
|
||||||
|
@ -72,7 +72,7 @@ namespace MCGalaxy {
|
|||||||
public bool IsAfk = false, AutoAfk;
|
public bool IsAfk = false, AutoAfk;
|
||||||
public bool cmdTimer = false;
|
public bool cmdTimer = false;
|
||||||
public bool UsingWom = false;
|
public bool UsingWom = false;
|
||||||
public string BrushName = "normal", DefaultBrushArgs = "";
|
public string BrushName = "normal", DefaultBrushArgs = "", TransformName = "none";
|
||||||
public string afkMessage;
|
public string afkMessage;
|
||||||
|
|
||||||
byte[] leftBuffer = new byte[0];
|
byte[] leftBuffer = new byte[0];
|
||||||
|
@ -48,14 +48,14 @@ namespace MCGalaxy.Undo {
|
|||||||
foreach (UndoFormatEntry P in format.GetEntries(s, args)) {
|
foreach (UndoFormatEntry P in format.GetEntries(s, args)) {
|
||||||
if (P.LevelName != lastMap) {
|
if (P.LevelName != lastMap) {
|
||||||
lvl = LevelInfo.FindExact(P.LevelName);
|
lvl = LevelInfo.FindExact(P.LevelName);
|
||||||
buffer.CheckIfSend(true);
|
buffer.Send(true);
|
||||||
buffer.level = lvl;
|
buffer.level = lvl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lvl == null || P.Time > end) continue;
|
if (lvl == null || P.Time > end) continue;
|
||||||
UndoBlock(args.Player, lvl, P, buffer);
|
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)) {
|
foreach (UndoFormatEntry P in format.GetEntries(s, args)) {
|
||||||
if (P.LevelName != lastMap) {
|
if (P.LevelName != lastMap) {
|
||||||
lvl = LevelInfo.FindExact(P.LevelName);
|
lvl = LevelInfo.FindExact(P.LevelName);
|
||||||
buffer.CheckIfSend(true);
|
buffer.Send(true);
|
||||||
buffer.level = lvl;
|
buffer.level = lvl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ namespace MCGalaxy.Undo {
|
|||||||
if (P.X > max.X || P.Y > max.Y || P.Z > max.Z) continue;
|
if (P.X > max.X || P.Y > max.Y || P.Z > max.Z) continue;
|
||||||
UndoBlock(args.Player, lvl, P, buffer);
|
UndoBlock(args.Player, lvl, P, buffer);
|
||||||
}
|
}
|
||||||
buffer.CheckIfSend(true);
|
buffer.Send(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -121,9 +121,8 @@ namespace MCGalaxy.Undo {
|
|||||||
? Block.red : Block.green;
|
? Block.red : Block.green;
|
||||||
|
|
||||||
buffer.Add(lvl.PosToInt(P.X, P.Y, P.Z), highlight, 0);
|
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)) {
|
foreach (UndoFormatEntry P in format.GetEntries(s, args)) {
|
||||||
if (P.Time > end) continue;
|
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.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;
|
lvl.changed = true;
|
||||||
|
|
||||||
if (pl != null) {
|
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.Add(lvl.PosToInt(P.X, P.Y, P.Z), P.Block, P.ExtBlock);
|
||||||
buffer.CheckIfSend(false);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
bool diff = Block.Convert(lvlBlock) != Block.Convert(P.Block);
|
bool diff = Block.Convert(lvlBlock) != Block.Convert(P.Block);
|
||||||
if (!diff && lvlBlock == Block.custom_block)
|
if (!diff && lvlBlock == Block.custom_block)
|
||||||
diff = lvl.GetExtTile(P.X, P.Y, P.Z) != P.ExtBlock;
|
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.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);
|
lvl.SetTile(P.X, P.Y, P.Z, P.Block);
|
||||||
if (P.ExtBlock == Block.custom_block)
|
if (P.ExtBlock == Block.custom_block)
|
||||||
|
@ -42,21 +42,25 @@ namespace MCGalaxy {
|
|||||||
this.level = player.level;
|
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;
|
indices[count] = index;
|
||||||
if (type == Block.custom_block) types[count] = extType;
|
if (type == Block.custom_block) types[count] = extType;
|
||||||
else types[count] = Block.Convert(type);
|
else types[count] = Block.Convert(type);
|
||||||
count++;
|
count++;
|
||||||
|
return Send(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Sends the block change packets if either 'force' is true,
|
/// <summary> Sends the block change packets if either 'force' is true,
|
||||||
/// or the number of blocks in the buffer has reached the limit. </summary>
|
/// or the number of blocks in the buffer has reached the limit. </summary>
|
||||||
public void CheckIfSend(bool force) {
|
/// <returns> Whether block change packets were actually sent. </returns>
|
||||||
|
public bool Send(bool force) {
|
||||||
if (count > 0 && (force || count == 256)) {
|
if (count > 0 && (force || count == 256)) {
|
||||||
if (player != null) SendPlayer();
|
if (player != null) SendPlayer();
|
||||||
else SendLevel();
|
else SendLevel();
|
||||||
count = 0;
|
count = 0;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendLevel() {
|
void SendLevel() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user