Skip to content
Permalink
Browse files

Reduce IL size of CenterCallback by 436 bytes

  • Loading branch information...
UnknownShadow200 committed Sep 20, 2017
1 parent 8d45e1a commit 7c2f47373a144fb63396521a447982ee6ec90907
Showing with 28 additions and 57 deletions.
  1. +28 −57 fCraft/Commands/BuildingCommands.cs
@@ -768,8 +768,8 @@ private static void WallsHandler(Player player, CommandReader cmd)
if (cmd.CountRemaining < 2) {
CdDisPlace.PrintUsage(player);
return;
}
}
Block block;
if (!cmd.NextBlock(player, false, out block)) return;
int dis;
@@ -925,74 +925,45 @@ private static void WallsHandler(Player player, CommandReader cmd)
player.Message("&WCannot deduce desired block. Click a block or type out the block name.");
return;
}
int sx = Math.Min(marks[0].X, marks[1].X), ex = Math.Max(marks[0].X, marks[1].X),
sy = Math.Min(marks[0].Y, marks[1].Y), ey = Math.Max(marks[0].Y, marks[1].Y),
sz = Math.Min(marks[0].Z, marks[1].Z), ez = Math.Max(marks[0].Z, marks[1].Z);

BoundingBox bounds = new BoundingBox(sx, sy, sz, ex, ey, ez);
int blocksDrawn = 0,
blocksSkipped = 0;

BoundingBox bounds = new BoundingBox(marks[0], marks[1]);
int blocksDrawn = 0, blocksSkipped = 0;
UndoState undoState = player.DrawBegin(null);

World playerWorld = player.World;
if (playerWorld == null)
PlayerOpException.ThrowNoWorld(player);

Map map = player.WorldMap;
if (((bounds.XMin + bounds.XMax) % 2) == 1)
{
Vector3I cPos = new Vector3I(bounds.XCentre + 1, bounds.YCentre, bounds.ZCentre);
DrawOneBlock(player, player.World.Map, player.LastUsedBlockType, cPos,
BlockChangeContext.Drawn,
ref blocksDrawn, ref blocksSkipped, undoState);
}
if (((bounds.XMin + bounds.XMax) % 2) == 1 && ((bounds.YMin + bounds.YMax) % 2) == 1)
{
Vector3I cPos = new Vector3I(bounds.XCentre + 1, bounds.YCentre + 1, bounds.ZCentre);
DrawOneBlock(player, player.World.Map, player.LastUsedBlockType, cPos,
BlockChangeContext.Drawn,
ref blocksDrawn, ref blocksSkipped, undoState);
Vector3I[] coords = new Vector3I[8];
int count = 0, cenX = bounds.XCentre, cenY = bounds.YCentre, cenZ = bounds.ZCentre;

if ((bounds.Width % 2) == 0) {
coords[count] = new Vector3I(cenX + 1, cenY, cenZ); count++;
}
if (((bounds.XMin + bounds.XMax) % 2) == 1 && ((bounds.ZMin + bounds.ZMax) % 2) == 1)
{
Vector3I cPos = new Vector3I(bounds.XCentre + 1, bounds.YCentre, bounds.ZCentre + 1);
DrawOneBlock(player, player.World.Map, player.LastUsedBlockType, cPos,
BlockChangeContext.Drawn,
ref blocksDrawn, ref blocksSkipped, undoState);
if ((bounds.Width % 2) == 0 && (bounds.Length % 2) == 0) {
coords[count] = new Vector3I(cenX + 1, cenY + 1, cenZ); count++;
}
if (((bounds.XMin + bounds.XMax) % 2) == 1 && ((bounds.YMin + bounds.YMax) % 2) == 1 && ((bounds.ZMin + bounds.ZMax) % 2) == 1)
{
Vector3I cPos = new Vector3I(bounds.XCentre + 1, bounds.YCentre + 1, bounds.ZCentre + 1);
DrawOneBlock(player, player.World.Map, player.LastUsedBlockType, cPos,
BlockChangeContext.Drawn,
ref blocksDrawn, ref blocksSkipped, undoState);
if ((bounds.Width % 2) == 0 && (bounds.Height % 2) == 0) {
coords[count] = new Vector3I(cenX + 1, cenY, cenZ + 1); count++;
}
if (((bounds.YMin + bounds.YMax) % 2) == 1)
{
Vector3I cPos = new Vector3I(bounds.XCentre, bounds.YCentre + 1, bounds.ZCentre);
DrawOneBlock(player, player.World.Map, player.LastUsedBlockType, cPos,
BlockChangeContext.Drawn,
ref blocksDrawn, ref blocksSkipped, undoState);
if ((bounds.Width % 2) == 0 && (bounds.Length % 2) == 0 && (bounds.Height % 2) == 0) {
coords[count] = new Vector3I(cenX + 1, cenY + 1, cenZ + 1); count++;
}
if (((bounds.YMin + bounds.YMax) % 2) == 1 && ((bounds.ZMin + bounds.ZMax) % 2) == 1)
{
Vector3I cPos = new Vector3I(bounds.XCentre, bounds.YCentre + 1, bounds.ZCentre + 1);
DrawOneBlock(player, player.World.Map, player.LastUsedBlockType, cPos,
BlockChangeContext.Drawn,
ref blocksDrawn, ref blocksSkipped, undoState);
if ((bounds.Length % 2) == 0) {
coords[count] = new Vector3I(cenX, cenY + 1, cenZ); count++;
}
if (((bounds.ZMin + bounds.ZMax) % 2) == 1)
{
Vector3I cPos = new Vector3I(bounds.XCentre, bounds.YCentre, bounds.ZCentre + 1);
DrawOneBlock(player, player.World.Map, player.LastUsedBlockType, cPos,
BlockChangeContext.Drawn,
ref blocksDrawn, ref blocksSkipped, undoState);
if ((bounds.Length % 2) == 0 && (bounds.Height % 2) == 0) {
coords[count] = new Vector3I(cenX, cenY + 1, cenZ + 1); count++;
}
if ((bounds.Height % 2) == 0) {
coords[count] = new Vector3I(cenX, cenY, cenZ + 1); count++;
}
coords[count] = new Vector3I(cenX, cenY, cenZ); count++;

Vector3I cPoso = new Vector3I(bounds.XCentre, bounds.YCentre, bounds.ZCentre);
DrawOneBlock(player, player.World.Map, player.LastUsedBlockType, cPoso,
BlockChangeContext.Drawn,
ref blocksDrawn, ref blocksSkipped, undoState);
for (int i = 0; i < count; i++) {
DrawOneBlock(player, player.World.Map, player.LastUsedBlockType, coords[i],
BlockChangeContext.Drawn, ref blocksDrawn, ref blocksSkipped, undoState);
}
DrawingFinished(player, "Placed", blocksDrawn, blocksSkipped);
}
#endregion

0 comments on commit 7c2f473

Please sign in to comment.
You can’t perform that action at this time.