Stage 2: Optimise /draw to do skip processing coordinates outside the map.

This commit is contained in:
UnknownShadow200 2016-03-28 22:54:19 +11:00
parent 8bd1e6423d
commit df5d6a1427
18 changed files with 115 additions and 99 deletions

View File

@ -46,43 +46,42 @@ namespace MCGalaxy.Commands
string[] parts = message.Split(' ');
Player.BlockchangeEventHandler newHandler = null;
bool help;
switch (parts[0].ToLower()) {
case "cone":
if (!CheckTwoArgs(p, 1, parts, out help)) { if (help) Help(p); return; }
if (!CheckTwoArgs(p, 1, parts)) return;
newHandler = new Player.BlockchangeEventHandler(BlockchangeCone); break;
case "hcone":
if (!CheckTwoArgs(p, 1, parts, out help)) { if (help) Help(p); return; }
if (!CheckTwoArgs(p, 1, parts)) return;
newHandler = new Player.BlockchangeEventHandler(BlockchangeHCone); break;
case "icone":
if (!CheckTwoArgs(p, 1, parts, out help)) { if (help) Help(p); return; }
if (!CheckTwoArgs(p, 1, parts)) return;
newHandler = new Player.BlockchangeEventHandler(BlockchangeICone); break;
case "hicone":
if (!CheckTwoArgs(p, 1, parts, out help)) { if (help) Help(p); return; }
if (!CheckTwoArgs(p, 1, parts)) return;
newHandler = new Player.BlockchangeEventHandler(BlockchangeHICone); break;
case "pyramid":
if (!CheckTwoArgs(p, 2, parts, out help)) { if (help) Help(p); return; }
if (!CheckTwoArgs(p, 2, parts)) return;
newHandler = new Player.BlockchangeEventHandler(BlockchangePyramid); break;
case "hpyramid":
if (!CheckTwoArgs(p, 2, parts, out help)) { if (help) Help(p); return; }
if (!CheckTwoArgs(p, 2, parts)) return;
newHandler = new Player.BlockchangeEventHandler(BlockchangeHPyramid); break;
case "ipyramid":
if (!CheckTwoArgs(p, 2, parts, out help)) { if (help) Help(p); return; }
if (!CheckTwoArgs(p, 2, parts)) return;
newHandler = new Player.BlockchangeEventHandler(BlockchangeIPyramid); break;
case "hipyramid":
if (!CheckTwoArgs(p, 2, parts, out help)) { if (help) Help(p); return; }
if (!CheckTwoArgs(p, 2, parts)) return;
newHandler = new Player.BlockchangeEventHandler(BlockchangeHIPyramid); break;
case "sphere":
if (!CheckOneArg(p, 3, parts, out help)) { if (help) Help(p); return; }
if (!CheckOneArg(p, 3, parts)) return;
newHandler = new Player.BlockchangeEventHandler(BlockchangeSphere); break;
case "hsphere":
if (!CheckOneArg(p, 3, parts, out help)) { if (help) Help(p); return; }
if (!CheckOneArg(p, 3, parts)) return;
newHandler = new Player.BlockchangeEventHandler(BlockchangeHSphere); break;
case "volcano":
if (!CheckTwoArgs(p, 4, parts, out help)) { if (help) Help(p); return; }
if (!CheckTwoArgs(p, 4, parts)) return;
newHandler = new Player.BlockchangeEventHandler(BlockchangeVolcano); break;
}
Player.SendMessage(p, "Place a block");
@ -90,36 +89,35 @@ namespace MCGalaxy.Commands
p.Blockchange += newHandler;
}
bool CheckTwoArgs(Player p, int addition, string[] parts, out bool help) {
bool CheckTwoArgs(Player p, int addition, string[] parts) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, addition)) {
Group group = Group.findPermInt(CommandOtherPerms.GetPerm(this, addition));
Player.SendMessage(p, "That commands addition is for " + group.name + "+");
help = false; return false;
return false;
}
help = true;
if (parts.Length != 3)
return false;
if (parts.Length != 3) { Help(p); return false; }
ushort height, radius;
if (!ushort.TryParse(parts[1], out height) || !ushort.TryParse(parts[2], out radius))
return false;
if (!ushort.TryParse(parts[1], out height) || height > 2000 ||
!ushort.TryParse(parts[2], out radius) || radius > 2000) {
Player.SendMessage(p, "Radius and height must be positive integers less than 2000."); return false;
}
p.BcVar = new int[] { height, radius };
return true;
}
bool CheckOneArg(Player p, int addition, string[] parts, out bool help) {
bool CheckOneArg(Player p, int addition, string[] parts) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, addition)) {
Group group = Group.findPermInt(CommandOtherPerms.GetPerm(this, addition));
Player.SendMessage(p, "That commands addition is for " + group.name + "+");
help = false; return false;
return false;
}
help = true;
if (parts.Length != 2)
return false;
if (parts.Length != 2) { Help(p); return false; }
ushort radius;
if (!ushort.TryParse(parts[1], out radius))
return false;
if (!ushort.TryParse(parts[1], out radius) || radius > 2000) {
Player.SendMessage(p, "Radius must be a positive integer less than 2000."); return false;
}
p.BcVar = new int[] { 0, radius };
return true;
}

View File

@ -29,16 +29,18 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Adv Cone"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
int R = Radius, H = Height;
return (int)(Math.PI / 3 * (R * R * H));
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
long R = Radius, H = Height;
return (long)(Math.PI / 3 * (R * R * H));
}
public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) {
Vec3U16 P = marks[0];
for (short yy = 0; yy <= Height; yy++)
for (short zz = (short)-Radius; zz <= Radius; zz++)
for (short xx = (short)-Radius; xx <= Radius; xx++)
int minX = Math.Max(P.X - Radius, 0) - P.X, maxX = Math.Min(P.X + Radius, lvl.Width - 1) - P.X;
int minZ = Math.Max(P.Z - Radius, 0) - P.Z, maxZ = Math.Min(P.Z + Radius, lvl.Length - 1) - P.Z;
for (int yy = 0; yy <= Height; yy++)
for (int zz = minZ; zz <= maxZ; zz++)
for (int xx = minX; xx <= maxX; xx++)
{
int curHeight = Invert ? yy : Height - yy;
if (curHeight == 0) continue;
@ -59,18 +61,21 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Adv Hollow Cone"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
int R = Radius, H = Height;
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
long R = Radius, H = Height;
double outer = (int)(Math.PI / 3 * (R * R * H));
double inner = (int)(Math.PI / 3 * ((R - 1) * (R - 1) * (H - 1)));
return (int)(outer - inner);
return (long)(outer - inner);
}
public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) {
Vec3U16 P = marks[0];
for (short yy = 0; yy <= Height; yy++)
for (short zz = (short)-Radius; zz <= Radius; zz++)
for (short xx = (short)-Radius; xx <= Radius; xx++)
int minX = Math.Max(P.X - Radius, 0) - P.X, maxX = Math.Min(P.X + Radius, lvl.Width - 1) - P.X;
int minZ = Math.Max(P.Z - Radius, 0) - P.Z, maxZ = Math.Min(P.Z + Radius, lvl.Length - 1) - P.Z;
int maxY = Math.Min(P.Y + Height, lvl.Height - 1) - P.Y;
for (int yy = 0; yy <= maxY; yy++)
for (int zz = minZ; zz <= maxZ; zz++)
for (int xx = minX; xx <= maxX; xx++)
{
int curHeight = Invert ? yy : Height - yy;
if (curHeight == 0) continue;
@ -92,18 +97,19 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Adv Volcano"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
int R = Radius, H = Height;
double outer = (int)(Math.PI / 3 * (R * R * H));
double inner = (int)(Math.PI / 3 * ((R - 1) * (R - 1) * (H - 1)));
return (int)(outer - inner);
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
long R = Radius, H = Height;
return (long)(Math.PI / 3 * (R * R * H));
}
public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) {
Vec3U16 P = marks[0];
for (short yy = 0; yy <= Height; yy++)
for (short zz = (short)-Radius; zz <= Radius; zz++)
for (short xx = (short)-Radius; xx <= Radius; xx++)
int minX = Math.Max(P.X - Radius, 0) - P.X, maxX = Math.Min(P.X + Radius, lvl.Width - 1) - P.X;
int minZ = Math.Max(P.Z - Radius, 0) - P.Z, maxZ = Math.Min(P.Z + Radius, lvl.Length - 1) - P.Z;
int maxY = Math.Min(P.Y + Height, lvl.Height - 1) - P.Y;
for (int yy = 0; yy <= maxY; yy++)
for (int zz = minZ; zz <= maxZ; zz++)
for (int xx = minX; xx <= maxX; xx++)
{
int cx = (P.X + xx), cy = (P.Y + yy), cz = (P.Z + zz);
int curHeight = Height - yy;

View File

@ -34,17 +34,20 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Adv Sphere"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
int R = Radius;
return (int)(Math.PI * 4.0 / 3.0 * (R * R * R));
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
long R = Radius;
return (long)(Math.PI * 4.0 / 3.0 * (R * R * R));
}
public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) {
Vec3U16 P = marks[0];
int upper = (Radius + 1) * (Radius + 1);
for (short yy = (short)-Radius; yy <= Radius; yy++)
for (short zz = (short)-Radius; zz <= Radius; zz++)
for (short xx = (short)-Radius; xx <= Radius; xx++)
int minX = Math.Max(P.X - Radius, 0) - P.X, maxX = Math.Min(P.X + Radius, lvl.Width - 1) - P.X;
int minY = Math.Max(P.Y - Radius, 0) - P.Y, maxY = Math.Min(P.Y + Radius, lvl.Height - 1) - P.Y;
int minZ = Math.Max(P.Z - Radius, 0) - P.Z, maxZ = Math.Min(P.Z + Radius, lvl.Length - 1) - P.Z;
for (int yy = minY; yy <= maxY; yy++)
for (int zz = minZ; zz <= maxZ; zz++)
for (int xx = minX; xx <= maxX; xx++)
{
int curDist = xx * xx + yy * yy + zz * zz;
if (curDist < upper)
@ -58,19 +61,22 @@ namespace MCGalaxy.Drawing.Ops {
public int Radius;
public override string Name { get { return "Adv Hollow Sphere"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
int R = Radius;
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
long R = Radius;
double outer = (int)(Math.PI * 4.0 / 3.0 * (R * R * R));
double inner = (int)(Math.PI * 4.0 / 3.0 * ((R - 1) * (R - 1) * (R - 1)));
return (int)(outer - inner);
return (long)(outer - inner);
}
public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) {
Vec3U16 P = marks[0];
int upper = (Radius + 1) * (Radius + 1), inner = (Radius - 1) * (Radius - 1);
for (short yy = (short)-Radius; yy <= Radius; yy++)
for (short zz = (short)-Radius; zz <= Radius; zz++)
for (short xx = (short)-Radius; xx <= Radius; xx++)
int minX = Math.Max(P.X - Radius, 0) - P.X, maxX = Math.Min(P.X + Radius, lvl.Width - 1) - P.X;
int minY = Math.Max(P.Y - Radius, 0) - P.Y, maxY = Math.Min(P.Y + Radius, lvl.Height - 1) - P.Y;
int minZ = Math.Max(P.Z - Radius, 0) - P.Z, maxZ = Math.Min(P.Z + Radius, lvl.Length - 1) - P.Z;
for (int yy = minY; yy <= maxY; yy++)
for (int zz = minZ; zz <= maxZ; zz++)
for (int xx = minX; xx <= maxX; xx++)
{
int curDist = xx * xx + yy * yy + zz * zz;
if (curDist < upper && curDist >= inner) {

View File

@ -29,20 +29,23 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Adv Pyramid"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
int R = Radius, H = Height;
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
long R = Radius, H = Height;
return (R * R * H) / 3;
}
public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) {
Vec3U16 P = marks[0];
for (short yy = 0; yy <= Height; yy++)
for (short zz = (short)-Radius; zz <= Radius; zz++)
for (short xx = (short)-Radius; xx <= Radius; xx++)
int minX = Math.Max(P.X - Radius, 0) - P.X, maxX = Math.Min(P.X + Radius, lvl.Width - 1) - P.X;
int minZ = Math.Max(P.Z - Radius, 0) - P.Z, maxZ = Math.Min(P.Z + Radius, lvl.Length - 1) - P.Z;
int maxY = Math.Min(P.Y + Height, lvl.Height - 1) - P.Y;
for (int yy = 0; yy <= maxY; yy++)
for (int zz = minZ; zz <= maxZ; zz++)
for (int xx = minX; xx <= maxX; xx++)
{
int curHeight = Invert ? yy : Height - yy;
if (curHeight == 0) continue;
int cx = P.X + xx, cy = P.Y + + (Height - curHeight), cz = P.Z + zz;
int cx = P.X + xx, cy = P.Y + (Height - curHeight), cz = P.Z + zz;
double curRadius = Radius * ((double)curHeight / (double)Height);
if (Math.Abs(xx) > curRadius || Math.Abs(zz) > curRadius)
@ -58,18 +61,21 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Adv Hollow Pyramid"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
int R = Radius, H = Height;
int outer = (R * R * H) / 3;
int inner = ((R - 1) * (R - 1) * (H - 1)) / 3;
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
long R = Radius, H = Height;
long outer = (R * R * H) / 3;
long inner = ((R - 1) * (R - 1) * (H - 1)) / 3;
return outer - inner;
}
public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) {
Vec3U16 P = marks[0];
for (short yy = 0; yy <= Height; yy++)
for (short zz = (short)-Radius; zz <= Radius; zz++)
for (short xx = (short)-Radius; xx <= Radius; xx++)
int minX = Math.Max(P.X - Radius, 0) - P.X, maxX = Math.Min(P.X + Radius, lvl.Width - 1) - P.X;
int minZ = Math.Max(P.Z - Radius, 0) - P.Z, maxZ = Math.Min(P.Z + Radius, lvl.Length - 1) - P.Z;
int maxY = Math.Min(P.Y + Height, lvl.Height - 1) - P.Y;
for (int yy = 0; yy <= maxY; yy++)
for (int zz = minZ; zz <= maxZ; zz++)
for (int xx = minX; xx <= maxX; xx++)
{
int curHeight = Invert ? yy : Height - yy;
if (curHeight == 0) continue;

View File

@ -24,7 +24,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Cuboid"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 p1 = marks[0], p2 = marks[1];
return (p2.X - p1.X + 1) * (p2.Y - p1.Y + 1) * (p2.Z - p1.Z + 1);
}
@ -44,7 +44,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Cuboid Hollow"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 p1 = marks[0], p2 = marks[1];
int lenX = (p2.X - p1.X + 1), lenY = (p2.Y - p1.Y + 1), lenZ = (p2.Z - p1.Z + 1);
int xQuadsVol = Math.Min(lenX, 2) * (lenY * lenZ);
@ -102,7 +102,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Cuboid Walls"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 p1 = marks[0], p2 = marks[1];
int lenX = (p2.X - p1.X + 1), lenY = (p2.Y - p1.Y + 1), lenZ = (p2.Z - p1.Z + 1);
int xQuadsVol = Math.Min(lenX, 2) * (lenY * lenZ);
@ -126,7 +126,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Cuboid Wireframe"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 p1 = marks[0], p2 = marks[1];
int lenX = (p2.X - p1.X + 1), lenY = (p2.Y - p1.Y + 1), lenZ = (p2.Z - p1.Z + 1);
int horSidesvol = 2 * (lenX * 2 + lenZ * 2); // TODO: slightly overestimated by at most four blocks.

View File

@ -66,11 +66,11 @@ namespace MCGalaxy.Drawing.Ops {
/// <summary> Estimates the total number of blocks that the drawing commands affects. <br/>
/// Note that this estimate assumes that all possibly affected blocks will be changed by the drawing command. </summary>
public abstract int GetBlocksAffected(Level lvl, Vec3U16[] marks);
public abstract long GetBlocksAffected(Level lvl, Vec3U16[] marks);
public abstract void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush);
public bool CanDraw(Vec3U16[] marks, Player p, out int affected) {
public bool CanDraw(Vec3U16[] marks, Player p, out long affected) {
affected = GetBlocksAffected(p.level, marks);
if (affected > p.group.maxBlocks) {
Player.SendMessage(p, "You tried to draw " + affected + " blocks.");
@ -80,7 +80,7 @@ namespace MCGalaxy.Drawing.Ops {
return true;
}
public virtual bool DetermineDrawOpMethod(Level lvl, int affected) {
public virtual bool DetermineDrawOpMethod(Level lvl, long affected) {
if (affected > Server.DrawReloadLimit) {
method = M_PSetTile;
return true;
@ -156,7 +156,7 @@ namespace MCGalaxy.Drawing.Ops {
}
op.Level = p.level;
int affected = 0;
long affected = 0;
if (!op.CanDraw(marks, p, out affected))
return false;
if (brush != null && affected != -1) {

View File

@ -27,7 +27,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Fill"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
return Positions.Count;
}

View File

@ -30,7 +30,7 @@ namespace MCGalaxy.Drawing.Ops {
public override bool MinMaxCoords { get { return false; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 p1 = marks[0], p2 = marks[1];
double dx = Math.Abs(p2.X - p1.X) + 0.25, dy = Math.Abs(p2.Y - p1.Y) + 0.25, dz = Math.Abs(p2.Z - p1.Z) + 0.25;
if (WallsMode) {

View File

@ -33,7 +33,7 @@ namespace MCGalaxy.Drawing.Ops {
byte[] r = new byte[1];
int width, length;
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
int lenX = (Math.Abs(marks[1].X - marks[0].X) + 1) / 2;
int lenZ = (Math.Abs(marks[1].Z - marks[0].Z) + 1) / 2;
return lenX * lenZ * 3;

View File

@ -29,7 +29,7 @@ namespace MCGalaxy.Drawing.Ops {
public override bool MinMaxCoords { get { return false; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
return CopyState.Volume;
}
@ -65,7 +65,7 @@ namespace MCGalaxy.Drawing.Ops {
public override bool MinMaxCoords { get { return false; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
return CopyState.Volume;
}

View File

@ -29,14 +29,14 @@ namespace MCGalaxy.Drawing.Ops {
this.yDir = yDir;
}
public override bool DetermineDrawOpMethod(Level lvl, int affected) {
public override bool DetermineDrawOpMethod(Level lvl, long affected) {
return baseOp.DetermineDrawOpMethod(lvl, affected);
}
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 origP1 = marks[0], origP2 = marks[1];
Vec3U16 p1 = marks[0], p2 = marks[1];
int total = 0;
long total = 0;
while (true) {
total += baseOp.GetBlocksAffected(lvl, marks);
if (p1.Y >= lvl.Height || Math.Abs(p2.X - p1.X) <= 1 || Math.Abs(p2.Z - p1.Z) <= 1)

View File

@ -30,7 +30,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Replace"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 p1 = marks[0], p2 = marks[1];
return (p2.X - p1.X + 1) * (p2.Y - p1.Y + 1) * (p2.Z - p1.Z + 1);
}
@ -60,7 +60,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "ReplaceNot"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 p1 = marks[0], p2 = marks[1];
return (p2.X - p1.X + 1) * (p2.Y - p1.Y + 1) * (p2.Z - p1.Z + 1);
}

View File

@ -24,7 +24,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Ellipsoid"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 p1 = marks[0], p2 = marks[1];
double rx = (p2.X - p1.X) / 2.0 + 0.25, ry = (p2.Y - p1.Y) / 2.0 + 0.25, rz = (p2.Z - p1.Z) / 2.0 + 0.25;
return (int)(Math.PI * 4.0/3.0 * rx * ry * rz);
@ -52,7 +52,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Ellipsoid Hollow"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 p1 = marks[0], p2 = marks[1];
double rx = (p2.X - p1.X) / 2.0 + 0.25, ry = (p2.Y - p1.Y) / 2.0 + 0.25, rz = (p2.Z - p1.Z) / 2.0 + 0.25;
return (int)(Math.PI * 4.0/3.0 * rx * ry * rz);
@ -86,7 +86,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Cylinder"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 p1 = marks[0], p2 = marks[1];
double rx = (p2.X - p1.X) / 2.0 + 0.25, rz = (p2.Z - p1.Z) / 2.0 + 0.25;
int height = (p2.Y - p1.Y + 1);

View File

@ -24,7 +24,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Torus"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
Vec3U16 p1 = marks[0], p2 = marks[1];
double rx = (p2.X - p1.X) / 2.0 + 0.25, ry = (p2.Y - p1.Y) / 2.0 + 0.25, rz = (p2.Z - p1.Z) / 2.0 + 0.25;
double rTube = ry, rCentre = Math.Min(rx, rz) - rTube;

View File

@ -39,7 +39,7 @@ namespace MCGalaxy.Drawing.Ops {
public const int T_Tree = 0, T_NotchTree = 1, T_NotchSwamp = 2, T_Cactus = 3;
static Brush defBrush = new SolidBrush(Block.leaf, 0);
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) { return -1; }
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) { return -1; }
public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) {
if (brush == null) brush = defBrush;

View File

@ -24,7 +24,7 @@ namespace MCGalaxy.Drawing.Ops {
public override string Name { get { return "Triangle"; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
// Applying Heron's Formula
double a = (marks[0] - marks[2]).Length;
double b = (marks[1] - marks[2]).Length;

View File

@ -35,7 +35,7 @@ namespace MCGalaxy.Drawing.Ops {
internal Player who;
internal Level saveLevel = null;
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) { return -1; }
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) { return -1; }
public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) {
PerformUndo(p, ref saveLevel);
@ -98,7 +98,7 @@ namespace MCGalaxy.Drawing.Ops {
internal string whoName;
internal bool foundUser = false;
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) { return -1; }
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) { return -1; }
public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) {
UndoFile.UndoPlayer(p, whoName.ToLower(), marks, Start, ref foundUser);
@ -111,7 +111,7 @@ namespace MCGalaxy.Drawing.Ops {
internal long seconds;
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) { return -1; }
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) { return -1; }
public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) {
if (lvl.UndoBuffer.Count != Server.physUndo) {

View File

@ -30,7 +30,7 @@ namespace MCGalaxy.Drawing.Ops {
public override bool MinMaxCoords { get { return false; } }
public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) {
public override long GetBlocksAffected(Level lvl, Vec3U16[] marks) {
int blocks = 0;
foreach (char c in Text) {
if ((int)c >= 256 || letters[(int)c] == null) {