internal static void LineCallback(Player player, Position[] marks, object tag) //MODIFIED//
{
byte drawBlock = (byte)tag;
if (drawBlock == (byte)Block.Undefined)
{
drawBlock = (byte)player.lastUsedBlockType;
}
player.undoBuffer.Clear();
int blocks = 0;
bool cannotUndo = false;
// LINE CODE
int x1 = marks[0].x, y1 = marks[0].y, z1 = marks[0].h, x2 = marks[1].x, y2 = marks[1].y, z2 = marks[1].h;
int i, dx, dy, dz, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2;
int[] pixel = new int[3];
pixel[0] = x1;
pixel[1] = y1;
pixel[2] = z1;
dx = x2 - x1;
dy = y2 - y1;
dz = z2 - z1;
x_inc = (dx < 0) ? -1 : 1;
l = Math.Abs(dx);
y_inc = (dy < 0) ? -1 : 1;
m = Math.Abs(dy);
z_inc = (dz < 0) ? -1 : 1;
n = Math.Abs(dz);
dx2 = l << 1;
dy2 = m << 1;
dz2 = n << 1;
DrawOneBlock(player, drawBlock, x2, y2, z2, ref blocks, ref cannotUndo);
DrawOneBlock(player, drawBlock, x2, y2, z2, ref blocks, ref cannotUndo);
if ((l >= m) && (l >= n)) {
err_1 = dy2 - l;
err_2 = dz2 - l;
for (i = 0; i < l; i++) {
DrawOneBlock(player, drawBlock, pixel[0], pixel[1], pixel[2], ref blocks, ref cannotUndo);
if (err_1 > 0) {
pixel[1] += y_inc;
err_1 -= dx2;
}
if (err_2 > 0) {
pixel[2] += z_inc;
err_2 -= dx2;
}
err_1 += dy2;
err_2 += dz2;
pixel[0] += x_inc;
}
} else if ((m >= l) && (m >= n)) {
err_1 = dx2 - m;
err_2 = dz2 - m;
for (i = 0; i < m; i++) {
DrawOneBlock(player, drawBlock, pixel[0], pixel[1], pixel[2], ref blocks, ref cannotUndo);
if (err_1 > 0) {
pixel[0] += x_inc;
err_1 -= dy2;
}
if (err_2 > 0) {
pixel[2] += z_inc;
err_2 -= dy2;
}
err_1 += dx2;
err_2 += dz2;
pixel[1] += y_inc;
}
} else {
err_1 = dy2 - n;
err_2 = dx2 - n;
for (i = 0; i < n; i++) {
DrawOneBlock(player, drawBlock, pixel[0], pixel[1], pixel[2], ref blocks, ref cannotUndo);
if (err_1 > 0) {
pixel[1] += y_inc;
err_1 -= dz2;
}
if (err_2 > 0) {
pixel[0] += x_inc;
err_2 -= dz2;
}
err_1 += dy2;
err_2 += dx2;
pixel[2] += z_inc;
}
}
// END LINE CODE
}
Я не понимаю код, но, основываясь на указаниях, которые дал мне Джонас, я смог реализовать это и протестировать без ошибок.