H:/PortableApps/GitPortable/App/Git/line uses DrawOp now, also remove duplication of line making code in CmdMissile.

This commit is contained in:
UnknownShadow200 2016-01-23 12:03:56 +11:00
parent 6b70fa09dc
commit 5d7c2fc1ed
26 changed files with 201 additions and 263 deletions

View File

@ -21,7 +21,7 @@ namespace MCGalaxy.Commands
{ {
public override string name { get { return "emote"; } } public override string name { get { return "emote"; } }
public override string shortcut { get { return "<3"; } } public override string shortcut { get { return "<3"; } }
public override string type { get { return CommandTypes.Other; } } public override string type { get { return CommandTypes.Chat; } }
public override bool museumUsable { get { return true; } } public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public CmdEmote() { } public CmdEmote() { }

View File

@ -23,33 +23,24 @@ namespace MCGalaxy.Commands
{ {
public override string name { get { return "high5"; } } public override string name { get { return "high5"; } }
public override string shortcut { get { return ""; } } public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Other; } } public override string type { get { return CommandTypes.Chat; } }
public override bool museumUsable { get { return false; } } public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } } public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public CmdHigh5() { } public CmdHigh5() { }
public override void Use(Player p, string message)
{ public override void Use(Player p, string message) {
if (message == "") if (message == "") { Help(p); return; }
{ Player who = Player.Find(message);
Help(p); if (who == null || who.hidden) {
return; Player.SendMessage(p, "Could not find player specified."); return;
}
Player player1 = Player.Find(message);
if (player1 == null || player1.hidden)
{
Player.SendMessage(p, "Could not find player specified.");
return;
} }
string giver = (p == null) ? "The Console" : p.DisplayName; string giver = (p == null) ? "(console)" : p.color + p.DisplayName;
string color = (p == null) ? "" : p.color; Player.SendMessage(who, giver + " just highfived you");
Player.SendMessage(player1, giver + " just highfived you"); Player.GlobalMessage(giver + " %Sjust highfived " + who.color + who.DisplayName);
Player.GlobalMessage(color + giver + " " + Server.DefaultColor + "just highfived " + player1.color + player1.DisplayName);
} }
// This one controls what happens when you use /help [commandname]. public override void Help(Player p) {
public override void Help(Player p)
{
Player.SendMessage(p, "/high5 <player> - High five someone :D"); Player.SendMessage(p, "/high5 <player> - High five someone :D");
} }
} }

View File

@ -23,22 +23,22 @@ namespace MCGalaxy
{ {
public override string name { get { return "hug"; } } public override string name { get { return "hug"; } }
public override string shortcut { get { return ""; } } public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Other; } } public override string type { get { return CommandTypes.Chat; } }
public override bool museumUsable { get { return true; } } public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } } public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public override void Use(Player p, string message)
{ public override void Use(Player p, string message) {
if (message == "") { Help(p); return; }
Player who = Player.Find(message); Player who = Player.Find(message);
if (who == null || who.hidden) { Player.SendMessage(p, "Could not find specified player!"); return; } if (who == null || who.hidden) {
else Player.SendMessage(p, "Could not find player specified."); return;
{
string msg = String.Format("the {0}Console [&a{1}{0}]", Server.DefaultColor, Server.ZallState);
string giver = (p == null) ? msg : p.color + p.DisplayName;
Player.GlobalMessage(who.color + who.DisplayName + Server.DefaultColor + " was hugged by " + giver);
} }
string giver = (p == null) ? "(console)" : p.color + p.DisplayName;
Player.GlobalMessage(who.color + who.DisplayName + " %Swas hugged by " + giver);
} }
public override void Help(Player p)
{ public override void Help(Player p) {
Player.SendMessage(p, "/hug <player> - hugs the given player"); Player.SendMessage(p, "/hug <player> - hugs the given player");
} }
} }

View File

@ -48,10 +48,7 @@ namespace MCGalaxy.Commands
} }
if (brush == null) brush = new SolidBrush(cpos.type, cpos.extType); if (brush == null) brush = new SolidBrush(cpos.type, cpos.extType);
ushort x1 = Math.Min(cpos.x, x), x2 = Math.Max(cpos.x, x); if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
ushort y1 = Math.Min(cpos.y, y), y2 = Math.Max(cpos.y, y);
ushort z1 = Math.Min(cpos.z, z), z2 = Math.Max(cpos.z, z);
if (!DrawOp.DoDrawOp(drawOp, brush, p, x1, y1, z1, x2, y2, z2))
return; return;
if (p.staticCommands) if (p.staticCommands)
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);

View File

@ -53,94 +53,33 @@ namespace MCGalaxy.Commands {
RevertAndClearState(p, x, y, z); RevertAndClearState(p, x, y, z);
CatchPos cpos = (CatchPos)p.blockchangeObject; CatchPos cpos = (CatchPos)p.blockchangeObject;
GetRealBlock(type, extType, p, ref cpos); GetRealBlock(type, extType, p, ref cpos);
List<Pos> buffer = new List<Pos>();
Pos pos = new Pos();
if (cpos.solid == SolidType.straight) { if (cpos.solid == SolidType.straight) {
int xdif = Math.Abs(cpos.x - x); int dx = Math.Abs(cpos.x - x);
int ydif = Math.Abs(cpos.y - y); int dy = Math.Abs(cpos.y - y);
int zdif = Math.Abs(cpos.z - z); int dz = Math.Abs(cpos.z - z);
if (xdif > ydif && xdif > zdif) { if (dx > dy && dx > dz) {
y = cpos.y; z = cpos.z; y = cpos.y; z = cpos.z;
} else if (ydif > xdif && ydif > zdif) { } else if (dy > dx && dy > dz) {
x = cpos.x; z = cpos.z; x = cpos.x; z = cpos.z;
} else if (zdif > ydif && zdif > xdif) { } else if (dz > dy && dz > dx) {
y = cpos.y; x = cpos.x; y = cpos.y; x = cpos.x;
} }
} }
Line lx, ly, lz; LineDrawOp drawOp = new LineDrawOp();
int[] pixel = { cpos.x, cpos.y, cpos.z }; drawOp.WallsMode = cpos.solid == SolidType.walls;
int dx = x - cpos.x, dy = y - cpos.y, dz = z - cpos.z; if (cpos.data != null)
lx.inc = Math.Sign(dx); ly.inc = Math.Sign(dy); lz.inc = Math.Sign(dz); drawOp.MaxLength = (ushort)cpos.data;
Brush brush = new SolidBrush(cpos.type, cpos.extType);
int xLen = Math.Abs(dx), yLen = Math.Abs(dy), zLen = Math.Abs(dz);
lx.dx2 = xLen << 1; ly.dx2 = yLen << 1; lz.dx2 = zLen << 1; if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
lx.index = 0; ly.index = 1; lz.index = 2;
if (xLen >= yLen && xLen >= zLen)
DoLine(ly, lz, lx, xLen, pixel, buffer);
else if (yLen >= xLen && yLen >= zLen)
DoLine(lx, lz, ly, yLen, pixel, buffer);
else
DoLine(ly, lx, lz, zLen, pixel, buffer);
pos.x = (ushort)pixel[0]; pos.y = (ushort)pixel[1]; pos.z = (ushort)pixel[2];
buffer.Add(pos);
int maxLen = cpos.data == null ? int.MaxValue : (ushort)cpos.data;
int count = Math.Min(buffer.Count, maxLen);
if (cpos.solid == SolidType.walls)
count *= Math.Abs(cpos.y - y);
if (count > p.group.maxBlocks) {
Player.SendMessage(p, "You tried to draw " + count + " blocks at once.");
Player.SendMessage(p, "You are limited to " + p.group.maxBlocks);
return; return;
}
for (int i = 0; i < maxLen && i < buffer.Count; i++) {
pos = buffer[i];
if (cpos.solid == SolidType.walls) {
for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy++) {
p.level.Blockchange(p, pos.x, yy, pos.z, type, extType);
}
} else {
p.level.Blockchange(p, pos.x, pos.y, pos.z, type, extType);
}
}
count = Math.Min(maxLen, buffer.Count);
Player.SendMessage(p, "Line was " + count + " blocks long.");
if (p.staticCommands) if (p.staticCommands)
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
} }
struct Line { public int dx2, inc, index; }
struct Pos { public ushort x, y, z; }
static void DoLine(Line l1, Line l2, Line l3, int len, int[] pixel, List<Pos> buffer) {
int err_1 = l1.dx2 - len, err_2 = l2.dx2 - len;
Pos pos;
for (int i = 0; i < len; i++) {
pos.x = (ushort)pixel[0]; pos.y = (ushort)pixel[1]; pos.z = (ushort)pixel[2];
buffer.Add(pos);
if (err_1 > 0) {
pixel[l1.index] += l1.inc;
err_1 -= l3.dx2;
}
if (err_2 > 0) {
pixel[l2.index] += l2.inc;
err_2 -= l3.dx2;
}
err_1 += l1.dx2; err_2 += l2.dx2;
pixel[l3.index] += l3.inc;
}
}
public override void Help(Player p) { public override void Help(Player p) {
Player.SendMessage(p, "%T/line [block type] <mode> <length>"); Player.SendMessage(p, "%T/line [block type] <mode> <length>");
Player.SendMessage(p, " %HCreates a line between two points."); Player.SendMessage(p, " %HCreates a line between two points.");

View File

@ -45,10 +45,7 @@ namespace MCGalaxy.Commands
drawOp = new PyramidReverseDrawOp(); break; drawOp = new PyramidReverseDrawOp(); break;
} }
ushort x1 = Math.Min(cpos.x, x), x2 = Math.Max(cpos.x, x); if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
ushort y1 = Math.Min(cpos.y, y), y2 = Math.Max(cpos.y, y);
ushort z1 = Math.Min(cpos.z, z), z2 = Math.Max(cpos.z, z);
if (!DrawOp.DoDrawOp(drawOp, brush, p, x1, y1, z1, x2, y2, z2))
return; return;
if (p.staticCommands) if (p.staticCommands)
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);

View File

@ -45,14 +45,11 @@ namespace MCGalaxy.Commands {
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
RevertAndClearState(p, x, y, z); RevertAndClearState(p, x, y, z);
CatchPos cpos = (CatchPos)p.blockchangeObject; CatchPos cpos = (CatchPos)p.blockchangeObject;
ushort x1 = Math.Min(cpos.x, x), x2 = Math.Max(cpos.x, x);
ushort y1 = Math.Min(cpos.y, y), y2 = Math.Max(cpos.y, y);
ushort z1 = Math.Min(cpos.z, z), z2 = Math.Max(cpos.z, z);
ReplaceDrawOp drawOp = new ReplaceDrawOp(); ReplaceDrawOp drawOp = new ReplaceDrawOp();
drawOp.ToReplace = toAffect; drawOp.ToReplace = toAffect;
drawOp.Target = target; drawOp.Target = target;
if (!DrawOp.DoDrawOp(drawOp, null, p, x1, y1, z1, x2, y2, z2)) if (!DrawOp.DoDrawOp(drawOp, null, p, cpos.x, cpos.y, cpos.z, x, y, z))
return; return;
if (p.staticCommands) if (p.staticCommands)
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);

View File

@ -44,14 +44,11 @@ namespace MCGalaxy.Commands {
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
RevertAndClearState(p, x, y, z); RevertAndClearState(p, x, y, z);
CatchPos cpos = (CatchPos)p.blockchangeObject; CatchPos cpos = (CatchPos)p.blockchangeObject;
ushort x1 = Math.Min(cpos.x, x), x2 = Math.Max(cpos.x, x);
ushort y1 = Math.Min(cpos.y, y), y2 = Math.Max(cpos.y, y);
ushort z1 = Math.Min(cpos.z, z), z2 = Math.Max(cpos.z, z);
ReplaceNotDrawOp drawOp = new ReplaceNotDrawOp(); ReplaceNotDrawOp drawOp = new ReplaceNotDrawOp();
drawOp.ToReplace = toAffect; drawOp.ToReplace = toAffect;
drawOp.Target = target; drawOp.Target = target;
if (!DrawOp.DoDrawOp(drawOp, null, p, x1, y1, z1, x2, y2, z2)) if (!DrawOp.DoDrawOp(drawOp, null, p, cpos.x, cpos.y, cpos.z, x, y, z))
return; return;
if (p.staticCommands) if (p.staticCommands)
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);

View File

@ -39,11 +39,8 @@ namespace MCGalaxy.Commands {
case SolidType.vertical: case SolidType.vertical:
drawOp = new CylinderDrawOp(); break; drawOp = new CylinderDrawOp(); break;
} }
ushort x1 = Math.Min(cpos.x, x), x2 = Math.Max(cpos.x, x); if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
ushort y1 = Math.Min(cpos.y, y), y2 = Math.Max(cpos.y, y);
ushort z1 = Math.Min(cpos.z, z), z2 = Math.Max(cpos.z, z);
if (!DrawOp.DoDrawOp(drawOp, brush, p, x1, y1, z1, x2, y2, z2))
return; return;
if (p.staticCommands) if (p.staticCommands)
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);

View File

@ -184,6 +184,7 @@ namespace MCGalaxy.Commands
pos.z = startZ; pos.z = startZ;
int total = 0; int total = 0;
List<FillPos> buffer = new List<FillPos>(2);
while (true) while (true)
{ {
@ -198,7 +199,7 @@ namespace MCGalaxy.Commands
CatchPos lookedAt; CatchPos lookedAt;
int i; int i;
for (i = 1; true; i++) for (i = 1; ; i++)
{ {
lookedAt.x = (ushort)Math.Round(startX + (double)(a * i)); lookedAt.x = (ushort)Math.Round(startX + (double)(a * i));
lookedAt.y = (ushort)Math.Round(startY + (double)(c * i)); lookedAt.y = (ushort)Math.Round(startY + (double)(c * i));
@ -266,7 +267,7 @@ namespace MCGalaxy.Commands
lookedAt.y = (ushort)Math.Round(startY + (double)(c * (i - 1))); lookedAt.y = (ushort)Math.Round(startY + (double)(c * (i - 1)));
lookedAt.z = (ushort)Math.Round(startZ + (double)(b * (i - 1))); lookedAt.z = (ushort)Math.Round(startZ + (double)(b * (i - 1)));
findNext(lookedAt, ref pos); FindNext(lookedAt, ref pos, buffer);
by = p.level.GetTile(pos.x, pos.y, pos.z); by = p.level.GetTile(pos.x, pos.y, pos.z);
if (total > 3) if (total > 3)
@ -361,100 +362,22 @@ namespace MCGalaxy.Commands
})); }));
gunThread.Name = "MCG_Missile"; gunThread.Name = "MCG_Missile";
gunThread.Start(); gunThread.Start();
} }
public override void Help(Player p)
{
Player.SendMessage(p, "/missile [at end] - Allows you to fire missiles at people");
Player.SendMessage(p, "Available [at end] values: &cexplode, destroy");
Player.SendMessage(p, "Differs from /gun in that the missile is guided");
}
struct CatchPos { public ushort x, y, z; } struct CatchPos { public ushort x, y, z; }
struct Pos { public ushort x, y, z; public int ending; } struct Pos { public ushort x, y, z; public int ending; }
void findNext(CatchPos lookedAt, ref CatchPos pos) void FindNext(CatchPos lookedAt, ref CatchPos pos, List<FillPos> buffer) {
{ LineDrawOp.DrawLine(pos.x, pos.y, pos.z, 2, lookedAt.x, lookedAt.y, lookedAt.z, buffer);
int dx, dy, dz, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2; FillPos end = buffer[buffer.Count - 1];
int[] pixel = new int[3]; pos.x = end.X; pos.y = end.Y; pos.z = end.Z;
buffer.Clear();
pixel[0] = pos.x; pixel[1] = pos.y; pixel[2] = pos.z; }
dx = lookedAt.x - pos.x; dy = lookedAt.y - pos.y; dz = lookedAt.z - pos.z;
public override void Help(Player p) {
x_inc = (dx < 0) ? -1 : 1; l = Math.Abs(dx); Player.SendMessage(p, "/missile [at end] - Allows you to fire missiles at people");
y_inc = (dy < 0) ? -1 : 1; m = Math.Abs(dy); Player.SendMessage(p, "Available [at end] values: &cexplode, destroy");
z_inc = (dz < 0) ? -1 : 1; n = Math.Abs(dz); Player.SendMessage(p, "Differs from /gun in that the missile is guided");
dx2 = l << 1; dy2 = m << 1; dz2 = n << 1;
if ((l >= m) && (l >= n))
{
err_1 = dy2 - l;
err_2 = dz2 - l;
pixel[0] += x_inc;
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;
pos.x = (ushort)pixel[0];
pos.y = (ushort)pixel[1];
pos.z = (ushort)pixel[2];
}
else if ((m >= l) && (m >= n))
{
err_1 = dx2 - m;
err_2 = dz2 - m;
pixel[1] += y_inc;
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;
pos.x = (ushort)pixel[0];
pos.y = (ushort)pixel[1];
pos.z = (ushort)pixel[2];
}
else
{
err_1 = dy2 - n;
err_2 = dx2 - n;
pixel[2] += z_inc;
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;
pos.x = (ushort)pixel[0];
pos.y = (ushort)pixel[1];
pos.z = (ushort)pixel[2];
}
} }
} }
} }

View File

@ -27,6 +27,8 @@ namespace MCGalaxy {
protected const int reloadLimit = 10000; protected const int reloadLimit = 10000;
protected int method; protected int method;
public virtual bool MinMaxCoords { get { return true; } }
public abstract string Name { get; } public abstract string Name { get; }
public abstract int GetBlocksAffected(Level lvl, ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2); public abstract int GetBlocksAffected(Level lvl, ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2);
@ -91,6 +93,13 @@ namespace MCGalaxy {
public static bool DoDrawOp(DrawOp op, Brush brush, Player p, public static bool DoDrawOp(DrawOp op, Brush brush, Player p,
ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2) { ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2) {
int affected = 0; int affected = 0;
if (op.MinMaxCoords) {
ushort xx1 = x1, yy1 = y1, zz1 = z1, xx2 = x2, yy2 = y2, zz2 = z2;
x1 = Math.Min(xx1, xx2); x2 = Math.Max(xx1, xx2);
y1 = Math.Min(yy1, yy2); y2 = Math.Max(yy1, yy2);
z1 = Math.Min(zz1, zz2); z2 = Math.Max(zz1, zz2);
}
if (!op.CanDraw(x1, y1, z1, x2, y2, z2, p, out affected)) if (!op.CanDraw(x1, y1, z1, x2, y2, z2, p, out affected))
return false; return false;
Player.SendMessage(p, op.Name + ": affecting up to an estimated " + affected + " blocks"); Player.SendMessage(p, op.Name + ": affecting up to an estimated " + affected + " blocks");

View File

@ -0,0 +1,109 @@
/*
Copyright 2011 MCGalaxy
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
using System;
using System.Collections.Generic;
namespace MCGalaxy {
public class LineDrawOp : DrawOp {
public bool WallsMode;
public int MaxLength = int.MaxValue;
public override string Name { get { return "Line"; } }
public override bool MinMaxCoords { get { return false; } }
public override int GetBlocksAffected(Level lvl, ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2) {
double dx = Math.Abs(x2 - x1) + 0.25, dy = Math.Abs(y2 - y1) + 0.25, dz = Math.Abs(z2 - z1) + 0.25;
if (WallsMode) {
int baseLen = (int)Math.Ceiling(Math.Sqrt(dx * dx + dz * dz));
return Math.Min(baseLen, MaxLength) * (Math.Abs(y2 - y1) + 1);
} else {
int baseLen = (int)Math.Ceiling(Math.Sqrt(dx * dx + dy * dy + dz * dz));
return Math.Min(baseLen, MaxLength);
}
}
public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2,
ushort y2, ushort z2, Player p, Level lvl, Brush brush) {
List<FillPos> buffer = new List<FillPos>();
DrawLine(x1, y1, z1, MaxLength, x2, y2, z2, buffer);
if (WallsMode) {
ushort yy1 = y1, yy2 = y2;
y1 = Math.Min(yy1, yy2); y2 = Math.Max(yy1, yy2);
}
for (int i = 0; i < buffer.Count; i++) {
FillPos pos = buffer[i];
if (WallsMode) {
for (ushort yy = y1; yy <= y2; yy++)
PlaceBlock(p, lvl, pos.X, yy, pos.Z, brush);
} else {
PlaceBlock(p, lvl, pos.X, pos.Y, pos.Z, brush);
}
}
}
internal static void DrawLine(ushort x1, ushort y1, ushort z1, int maxLen,
ushort x2, ushort y2, ushort z2, List<FillPos> buffer) {
Line lx, ly, lz;
int[] pixel = { x1, y1, z1 };
int dx = x2 - x1, dy = y2 - y1, dz = z2 - z1;
lx.inc = Math.Sign(dx); ly.inc = Math.Sign(dy); lz.inc = Math.Sign(dz);
int xLen = Math.Abs(dx), yLen = Math.Abs(dy), zLen = Math.Abs(dz);
lx.dx2 = xLen << 1; ly.dx2 = yLen << 1; lz.dx2 = zLen << 1;
lx.index = 0; ly.index = 1; lz.index = 2;
if (xLen >= yLen && xLen >= zLen)
DoLine(ly, lz, lx, xLen, pixel, maxLen, buffer);
else if (yLen >= xLen && yLen >= zLen)
DoLine(lx, lz, ly, yLen, pixel, maxLen, buffer);
else
DoLine(ly, lx, lz, zLen, pixel, maxLen, buffer);
FillPos pos;
pos.X = (ushort)pixel[0]; pos.Y = (ushort)pixel[1]; pos.Z = (ushort)pixel[2];
buffer.Add(pos);
}
struct Line { public int dx2, inc, index; }
static void DoLine(Line l1, Line l2, Line l3, int len,
int[] pixel, int maxLen, List<FillPos> buffer) {
int err_1 = l1.dx2 - len, err_2 = l2.dx2 - len;
FillPos pos;
for (int i = 0; i < len && i < (maxLen - 1); i++) {
pos.X = (ushort)pixel[0]; pos.Y = (ushort)pixel[1]; pos.Z = (ushort)pixel[2];
buffer.Add(pos);
if (err_1 > 0) {
pixel[l1.index] += l1.inc;
err_1 -= l3.dx2;
}
if (err_2 > 0) {
pixel[l2.index] += l2.inc;
err_2 -= l3.dx2;
}
err_1 += l1.dx2; err_2 += l2.dx2;
pixel[l3.index] += l3.inc;
}
}
}
}

View File

@ -680,35 +680,16 @@ namespace MCGalaxy
return true; return true;
} }
public void ChatLevel(string message) public void ChatLevel(string message) { ChatLevel(message, LevelPermission.Banned); }
{
foreach (Player pl in Player.players.Where(pl => pl.level == this))
{
pl.SendMessage(message);
}
}
public void ChatLevelOps(string message) public void ChatLevelOps(string message) { ChatLevel(message, Server.opchatperm); }
{
foreach (
Player pl in
Player.players.Where(
pl =>
pl.level == this &&
pl.group.Permission >= Server.opchatperm))
{
pl.SendMessage(message);
}
}
public void ChatLevelAdmins(string message) public void ChatLevelAdmins(string message) { ChatLevel(message, Server.adminchatperm); }
{
foreach ( public void ChatLevel(string message, LevelPermission minPerm) {
Player pl in foreach (Player pl in Player.players) {
Player.players.Where( if (pl.level != this) continue;
pl => pl.level == this && if (pl.group.Permission < minPerm) continue;
pl.group.Permission >= Server.adminchatperm))
{
pl.SendMessage(message); pl.SendMessage(message);
} }
} }

View File

@ -138,10 +138,13 @@
<Compile Include="Commands\building\ReplaceCmd.cs" /> <Compile Include="Commands\building\ReplaceCmd.cs" />
<Compile Include="Commands\Chat\CmdAdminChat.cs" /> <Compile Include="Commands\Chat\CmdAdminChat.cs" />
<Compile Include="Commands\Chat\CmdChatRoom.cs" /> <Compile Include="Commands\Chat\CmdChatRoom.cs" />
<Compile Include="Commands\Chat\CmdEmote.cs" />
<Compile Include="Commands\Chat\CmdGcaccept.cs" /> <Compile Include="Commands\Chat\CmdGcaccept.cs" />
<Compile Include="Commands\Chat\CmdGcrules.cs" /> <Compile Include="Commands\Chat\CmdGcrules.cs" />
<Compile Include="Commands\Chat\CmdGlobal.cs" /> <Compile Include="Commands\Chat\CmdGlobal.cs" />
<Compile Include="Commands\Chat\CmdGlobalCLS.cs" /> <Compile Include="Commands\Chat\CmdGlobalCLS.cs" />
<Compile Include="Commands\Chat\CmdHigh5.cs" />
<Compile Include="Commands\Chat\CmdHug.cs" />
<Compile Include="Commands\Chat\CmdIgnore.cs" /> <Compile Include="Commands\Chat\CmdIgnore.cs" />
<Compile Include="Commands\Chat\CmdMe.cs" /> <Compile Include="Commands\Chat\CmdMe.cs" />
<Compile Include="Commands\Chat\CmdOpChat.cs" /> <Compile Include="Commands\Chat\CmdOpChat.cs" />
@ -167,16 +170,18 @@
<Compile Include="Commands\Economy\CmdGive.cs" /> <Compile Include="Commands\Economy\CmdGive.cs" />
<Compile Include="Commands\Economy\CmdMoney.cs" /> <Compile Include="Commands\Economy\CmdMoney.cs" />
<Compile Include="Commands\Economy\CmdPay.cs" /> <Compile Include="Commands\Economy\CmdPay.cs" />
<Compile Include="Commands\Games\CmdCountdown.cs" /> <Compile Include="Commands\Fun\CmdCountdown.cs" />
<Compile Include="Commands\Games\CmdCtf.cs" /> <Compile Include="Commands\Fun\CmdCtf.cs" />
<Compile Include="Commands\Games\CmdDisinfect.cs" /> <Compile Include="Commands\Fun\CmdDisinfect.cs" />
<Compile Include="Commands\Games\CmdInfect.cs" /> <Compile Include="Commands\Fun\CmdFliphead.cs" />
<Compile Include="Commands\Games\CmdInfected.cs" /> <Compile Include="Commands\Fun\CmdFlipHeads.cs" />
<Compile Include="Commands\Games\CmdLavaSurvival.cs" /> <Compile Include="Commands\Fun\CmdInfect.cs" />
<Compile Include="Commands\Games\CmdTntWars.cs" /> <Compile Include="Commands\Fun\CmdInfected.cs" />
<Compile Include="Commands\Games\CmdZombieGame.cs" /> <Compile Include="Commands\Fun\CmdLavaSurvival.cs" />
<Compile Include="Commands\Games\CmdZombieSpawn.cs" /> <Compile Include="Commands\Fun\CmdTntWars.cs" />
<Compile Include="Commands\Games\CmdZombieSurvival.cs" /> <Compile Include="Commands\Fun\CmdZombieGame.cs" />
<Compile Include="Commands\Fun\CmdZombieSpawn.cs" />
<Compile Include="Commands\Fun\CmdZombieSurvival.cs" />
<Compile Include="Commands\Information\CmdAbout.cs" /> <Compile Include="Commands\Information\CmdAbout.cs" />
<Compile Include="Commands\Information\CmdAfk.cs" /> <Compile Include="Commands\Information\CmdAfk.cs" />
<Compile Include="Commands\Information\CmdBlocks.cs" /> <Compile Include="Commands\Information\CmdBlocks.cs" />
@ -306,17 +311,12 @@
<Compile Include="Commands\Other\cmdCTFADSFD.cs" /> <Compile Include="Commands\Other\cmdCTFADSFD.cs" />
<Compile Include="Commands\Other\CmdDescend.cs" /> <Compile Include="Commands\Other\CmdDescend.cs" />
<Compile Include="Commands\Other\CmdDisagree.cs" /> <Compile Include="Commands\Other\CmdDisagree.cs" />
<Compile Include="Commands\Other\CmdEmote.cs" />
<Compile Include="Commands\Other\CmdFakerank.cs" /> <Compile Include="Commands\Other\CmdFakerank.cs" />
<Compile Include="Commands\Other\CmdFliphead.cs" />
<Compile Include="Commands\Other\CmdFlipHeads.cs" />
<Compile Include="Commands\Other\CmdFly.cs" /> <Compile Include="Commands\Other\CmdFly.cs" />
<Compile Include="Commands\Other\CmdGarbage.cs" /> <Compile Include="Commands\Other\CmdGarbage.cs" />
<Compile Include="Commands\Other\CmdGun.cs" /> <Compile Include="Commands\Other\CmdGun.cs" />
<Compile Include="Commands\Other\CmdHackRank.cs" /> <Compile Include="Commands\Other\CmdHackRank.cs" />
<Compile Include="Commands\Other\CmdHeartbeat.cs" /> <Compile Include="Commands\Other\CmdHeartbeat.cs" />
<Compile Include="Commands\Other\CmdHigh5.cs" />
<Compile Include="Commands\Other\CmdHug.cs" />
<Compile Include="Commands\Other\CmdImpersonate.cs" /> <Compile Include="Commands\Other\CmdImpersonate.cs" />
<Compile Include="Commands\Other\CmdInterval.cs" /> <Compile Include="Commands\Other\CmdInterval.cs" />
<Compile Include="Commands\Other\CmdInvincible.cs" /> <Compile Include="Commands\Other\CmdInvincible.cs" />
@ -396,6 +396,7 @@
<Compile Include="Drawing\DrawOps\CuboidDrawOp.cs" /> <Compile Include="Drawing\DrawOps\CuboidDrawOp.cs" />
<Compile Include="Drawing\DrawOps\DrawOp.cs" /> <Compile Include="Drawing\DrawOps\DrawOp.cs" />
<Compile Include="Drawing\DrawOps\FillDrawOp.cs" /> <Compile Include="Drawing\DrawOps\FillDrawOp.cs" />
<Compile Include="Drawing\DrawOps\LineDrawOp.cs" />
<Compile Include="Drawing\DrawOps\ReplaceDrawOp.cs" /> <Compile Include="Drawing\DrawOps\ReplaceDrawOp.cs" />
<Compile Include="Drawing\DrawOps\SpheroidDrawOp.cs" /> <Compile Include="Drawing\DrawOps\SpheroidDrawOp.cs" />
<Compile Include="Drawing\DrawOps\PyramidDrawOp.cs" /> <Compile Include="Drawing\DrawOps\PyramidDrawOp.cs" />
@ -697,7 +698,7 @@
<ItemGroup> <ItemGroup>
<Folder Include="Commands" /> <Folder Include="Commands" />
<Folder Include="Commands\Building" /> <Folder Include="Commands\Building" />
<Folder Include="Commands\Games" /> <Folder Include="Commands\Fun" />
<Folder Include="Commands\Information" /> <Folder Include="Commands\Information" />
<Folder Include="Commands\Moderation" /> <Folder Include="Commands\Moderation" />
<Folder Include="Commands\Economy" /> <Folder Include="Commands\Economy" />