prefer explicit array declarations

This commit is contained in:
UnknownShadow200 2017-03-02 10:01:05 +11:00
parent 377632e10b
commit c4287c2fb6
28 changed files with 71 additions and 58 deletions

View File

@ -57,7 +57,7 @@ namespace MCGalaxy.Blocks.Extended {
}
}
static string[] sep = { " |/" };
static string[] sep = new string[] { " |/" };
const StringSplitOptions opts = StringSplitOptions.RemoveEmptyEntries;
static List<string> empty = new List<string>();
internal static List<string> GetParts(string message, out string text) {

View File

@ -56,7 +56,7 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] spin <interval> <speed>",
static string[] help = new string[] { "%T/botai add [name] spin <interval> <speed>",
"%HCauses the bot to spin around for a period of time.",
"%H <interval> is in tenths of a second, so an interval of 20 means " +
"spin for two seconds. (defaults to 1 second)",
@ -95,7 +95,7 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] nod <interval> <speed>",
static string[] help = new string[] { "%T/botai add [name] nod <interval> <speed>",
"%HCauses the bot to nod up and down for a period of time.",
"%H <interval> is in tenths of a second, so an interval of 20 means " +
"nod for two seconds. (defaults to 1 second)",

View File

@ -88,7 +88,8 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] hunt <radius>",
static string[] help = new string[] {
"%T/botai add [name] hunt <radius>",
"%HCauses the bot to move towards the closest player in the search radius.",
"%H <radius> defaults to 75 blocks.",
};
@ -113,7 +114,8 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] kill",
static string[] help = new string[] {
"%T/botai add [name] kill",
"%HCauses the bot to kill any players it is touching.",
};
}
@ -167,7 +169,8 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] stare <radius>",
static string[] help = new string[] {
"%T/botai add [name] stare <radius>",
"%HCauses the bot to stare at the closest player in the search radius.",
"%H <radius> defaults to 20000 blocks.",
};

View File

@ -55,7 +55,8 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] teleport",
static string[] help = new string[] {
"%T/botai add [name] teleport",
"%HCauses the bot to instantly teleport to a position.",
"%H Note: The position saved to the AI is your current position.",
};
@ -82,7 +83,8 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] walk",
static string[] help = new string[] {
"%T/botai add [name] walk",
"%HCauses the bot to walk towards to a position.",
"%H Note: The position saved to the AI is your current position.",
};
@ -98,7 +100,8 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] jump",
static string[] help = new string[] {
"%T/botai add [name] jump",
"%HCauses the bot to perform a jump.",
"%H Note bots can also do other instructions while jumping",
"%H (e.g. For a \"jump\" then a \"walk\" instruction, the bot will jump while also walking",
@ -127,7 +130,8 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] speed [percentage]",
static string[] help = new string[] {
"%T/botai add [name] speed [percentage]",
"%HSets how fast the bot moves, relative to its normal speed.",
"%H 100 means it moves at normal speed",
"%H 50 means it moves at half speed",

View File

@ -29,7 +29,8 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] reset",
static string[] help = new string[] {
"%T/botai add [name] reset",
"%HCauses the bot to go back to the first instruction",
};
}
@ -43,7 +44,8 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] remove",
static string[] help = new string[] {
"%T/botai add [name] remove",
"%HCauses the bot to be removed from the world",
};
}
@ -77,7 +79,8 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] linkscript [ai name]",
static string[] help = new string[] {
"%T/botai add [name] linkscript [ai name]",
"%HCauses the bot to switch to the given AI, and execute that AI's instructions instead.",
};
}
@ -109,7 +112,8 @@ namespace MCGalaxy.Bots {
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] wait <interval>",
static string[] help = new string[] {
"%T/botai add [name] wait <interval>",
"%HCauses the bot to stay still for a period of time.",
"%H <interval> is in tenths of a second, so an interval of 20 means " +
"stay still for two seconds. (defaults to 1 second)",

View File

@ -51,7 +51,7 @@ namespace MCGalaxy.Commands {
p.SetMoney(p.money - 1);
}
static string[] defMessages = { "guzzled a grape", "chewed a cherry", "ate an avocado" };
static string[] defMessages = new string[] { "guzzled a grape", "chewed a cherry", "ate an avocado" };
public override void Help(Player p) {
Player.Message(p, "%T/eat %H- Eats a random snack.");

View File

@ -62,7 +62,7 @@ namespace MCGalaxy.Commands {
}
}
static ColumnDesc[] createInbox = {
static ColumnDesc[] createInbox = new ColumnDesc[] {
new ColumnDesc("PlayerFrom", ColumnType.Char, 20),
new ColumnDesc("TimeSent", ColumnType.DateTime),
new ColumnDesc("Contents", ColumnType.VarChar, 255),

View File

@ -23,7 +23,7 @@ namespace MCGalaxy.Commands {
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public CmdAwardMod() { }
static char[] awardArgs = { ':' };
static char[] awardArgs = new char[] { ':' };
public override void Use(Player p, string message) {
if (message == "" || message.IndexOf(' ') == -1) { Help(p); return; }

View File

@ -33,7 +33,7 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) {
string[] raw = message.Split(' ');
string[] args = { "", "", "", "", "", "", "", "" };
string[] args = new string[] { "", "", "", "", "", "", "", "" };
for (int i = 0; i < Math.Min(args.Length, raw.Length); i++)
args[i] = raw[i];
HandleSetup(p, args);

View File

@ -27,7 +27,8 @@ namespace MCGalaxy.Commands {
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public Cmd8Ball() { }
static string[] messages = { "Not likely." , "Very likely." , "Impossible!" , "No." , "Yes." , "Definitely!" , "Do some more thinking." };
static string[] messages = new string[] { "Not likely." , "Very likely." , "Impossible!" ,
"No." , "Yes." , "Definitely!" , "Do some more thinking." };
DateTime nextUse;
static TimeSpan delay = TimeSpan.FromSeconds(2);

View File

@ -33,7 +33,7 @@ namespace MCGalaxy.Commands {
bool DeleteZone = false, CheckZone = false, NoTntZone = false;
public override void Use(Player p, string message) {
string[] text = { "", "", "", "", "" };
string[] text = new string[] { "", "", "", "", "" };
string[] parts = message.ToLower().Split(' ');
for (int i = 0; i < Math.Min(text.Length, parts.Length); i++)
text[i] = parts[i];

View File

@ -42,7 +42,8 @@ namespace MCGalaxy.Commands {
SetPhysics(level, state);
}
internal static string[] states = { "&cOFF", "&aNormal", "&aAdvanced", "&aHardcore", "&aInstant", "&4Doors-only" };
internal static string[] states = new string[] { "&cOFF", "&aNormal", "&aAdvanced",
"&aHardcore", "&aInstant", "&4Doors-only" };
void ShowPhysics(Player p) {
Level[] loaded = LevelInfo.Loaded.Items;

View File

@ -48,7 +48,7 @@ namespace MCGalaxy.SQL {
return colTypes[(int)Type];
}
static string[] colTypes = {
static string[] colTypes = new string[] {
"TINYINT UNSIGNED", "SMALLINT UNSIGNED", "MEDIUMINT UNSIGNED",
"INT UNSIGNED", "BIGINT UNSIGNED", "TINYINT", "SMALLINT",
"MEDIUMINT", "INT", "BIGINT", "INTEGER", "BOOL", "DATETIME", "TEXT"

View File

@ -19,7 +19,7 @@ namespace MCGalaxy {
}
static char[] trimChars = {'='};
static char[] trimChars = new char[] {'='};
public static bool Load( Player p ) {
if (!File.Exists("players/" + p.name + "DB.txt")) return false;

View File

@ -39,7 +39,7 @@ namespace MCGalaxy.Drawing.Brushes {
public override string Name { get { return "BWRainbow"; } }
static byte[] blocks = { Block.iron, Block.white, Block.lightgrey,
static byte[] blocks = new byte[] { Block.iron, Block.white, Block.lightgrey,
Block.darkgrey, Block.obsidian, Block.darkgrey, Block.lightgrey, Block.white };
public override byte NextBlock(DrawOp op) {
int offset = (op.Coords.X + op.Coords.Y + op.Coords.Z) % 8;

View File

@ -60,13 +60,13 @@ namespace MCGalaxy.Drawing.Ops {
internal static void DrawLine(int x1, int y1, int z1, int maxLen,
int x2, int y2, int z2, List<Vec3S32> buffer) {
Line lx, ly, lz;
int[] pixel = { x1, y1, z1 };
int[] pixel = new int[] { 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);
lx.dir = Math.Sign(dx); ly.dir = Math.Sign(dy); lz.dir = 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;
lx.len2 = xLen << 1; ly.len2 = yLen << 1; lz.len2 = zLen << 1;
lx.axis = 0; ly.axis = 1; lz.axis = 2;
if (xLen >= yLen && xLen >= zLen)
DoLine(ly, lz, lx, xLen, pixel, maxLen, buffer);
@ -80,26 +80,26 @@ namespace MCGalaxy.Drawing.Ops {
buffer.Add(pos);
}
struct Line { public int dx2, inc, index; }
struct Line { public int len2, dir, axis; }
static void DoLine(Line l1, Line l2, Line l3, int len,
int[] pixel, int maxLen, List<Vec3S32> buffer) {
int err_1 = l1.dx2 - len, err_2 = l2.dx2 - len;
int err_1 = l1.len2 - len, err_2 = l2.len2 - len;
Vec3S32 pos;
for (int i = 0; i < len && i < (maxLen - 1); i++) {
pos.X = pixel[0]; pos.Y = pixel[1]; pos.Z = pixel[2];
buffer.Add(pos);
if (err_1 > 0) {
pixel[l1.index] += l1.inc;
err_1 -= l3.dx2;
pixel[l1.axis] += l1.dir;
err_1 -= l3.len2;
}
if (err_2 > 0) {
pixel[l2.index] += l2.inc;
err_2 -= l3.dx2;
pixel[l2.axis] += l2.dir;
err_2 -= l3.len2;
}
err_1 += l1.dx2; err_2 += l2.dx2;
pixel[l3.index] += l3.inc;
err_1 += l1.len2; err_2 += l2.len2;
pixel[l3.axis] += l3.dir;
}
}
}

View File

@ -26,7 +26,7 @@ namespace MCGalaxy.Drawing {
newState.Height = angle == 180 ? state.Height : state.Length;
newState.Length = angle == 180 ? state.Length : state.Height;
int[] m = { posX, negZ, posY };
int[] m = new int[] { posX, negZ, posY };
if (angle == 180) { m[1] = negY; m[2] = negZ; }
if (angle == 270) { m[1] = posZ; m[2] = negY; }
return Rotate(state, newState, m);
@ -37,7 +37,7 @@ namespace MCGalaxy.Drawing {
newState.Width = angle == 180 ? state.Width : state.Length;
newState.Length = angle == 180 ? state.Length : state.Width;
int[] m = { negZ, posY, posX };
int[] m = new int[] { negZ, posY, posX };
if (angle == 180) { m[0] = negX; m[2] = negZ; }
if (angle == 270) { m[0] = posZ; m[2] = negX; }
return Rotate(state, newState, m);
@ -48,7 +48,7 @@ namespace MCGalaxy.Drawing {
newState.Width = angle == 180 ? state.Width : state.Height;
newState.Height = angle == 180 ? state.Height : state.Width;
int[] m = { posY, negX, posZ };
int[] m = new int[] { posY, negX, posZ };
if (angle == 180) { m[0] = negX; m[1] = negY; }
if (angle == 270) { m[0] = negY; m[1] = posX; }
return Rotate(state, newState, m);

View File

@ -111,7 +111,7 @@ namespace MCGalaxy.Drawing {
}
static PaletteEntry[] Color = {
static PaletteEntry[] Color = new PaletteEntry[] {
new PaletteEntry(128, 86, 57, Block.dirt),
new PaletteEntry(162, 129, 75, Block.wood),
new PaletteEntry(244, 237, 174, Block.sand),
@ -135,21 +135,21 @@ namespace MCGalaxy.Drawing {
new PaletteEntry(0, 0, 0, Block.obsidian),
};
static PaletteEntry[] Grayscale = {
static PaletteEntry[] Grayscale = new PaletteEntry[] {
new PaletteEntry(0, 0, 0, Block.obsidian),
new PaletteEntry(46, 68, 47, Block.darkgrey),
new PaletteEntry(135, 145, 130, Block.lightgrey),
new PaletteEntry(230, 240, 225, Block.white),
};
static PaletteEntry[] GrayscaleSimple = {
static PaletteEntry[] GrayscaleSimple = new PaletteEntry[] {
new PaletteEntry(32, 32, 32, Block.obsidian),
new PaletteEntry(96, 96, 96, Block.darkgrey),
new PaletteEntry(160, 160, 160, Block.lightgrey),
new PaletteEntry(224, 224, 224, Block.white),
};
static PaletteEntry[] BlackWhite = {
static PaletteEntry[] BlackWhite = new PaletteEntry[] {
new PaletteEntry(255, 255, 255, Block.white),
new PaletteEntry(0, 0, 0, Block.obsidian),
};

View File

@ -29,7 +29,7 @@ namespace MCGalaxy {
public static bool Enabled;
const string propertiesFile = "properties/economy.properties";
static ColumnDesc[] createEconomy = {
static ColumnDesc[] createEconomy = new ColumnDesc[] {
new ColumnDesc("player", ColumnType.VarChar, 20, priKey: true),
new ColumnDesc("money", ColumnType.Int32),
new ColumnDesc("total", ColumnType.Integer, notNull: true, def: "0"),

View File

@ -227,7 +227,7 @@ namespace MCGalaxy.Games {
}
}
static ColumnDesc[] createSyntax = {
static ColumnDesc[] createSyntax = new ColumnDesc[] {
new ColumnDesc("ID", ColumnType.Integer, priKey: true, autoInc: true, notNull: true),
new ColumnDesc("Name", ColumnType.VarChar, 20),
new ColumnDesc("Points", ColumnType.UInt24),

View File

@ -23,8 +23,8 @@ namespace MCGalaxy.Games
{
public char color;
public int points = 0;
public ushort[] flagBase = { 0, 0, 0 };
public ushort[] flagLocation = { 0, 0, 0 };
public ushort[] flagBase = new ushort[3];
public ushort[] flagLocation = new ushort[3];
public List<Spawn> spawns = new List<Spawn>();
public List<Player> players = new List<Player>();
public Level mapOn;

View File

@ -250,7 +250,7 @@ namespace MCGalaxy.Games {
#region Database
static ColumnDesc[] createSyntax = {
static ColumnDesc[] createSyntax = new ColumnDesc[] {
new ColumnDesc("ID", ColumnType.Integer, priKey: true, autoInc: true, notNull: true),
new ColumnDesc("Name", ColumnType.Char, 20),
new ColumnDesc("TotalRounds", ColumnType.Int32),

View File

@ -121,7 +121,7 @@ namespace MCGalaxy {
}
internal static ColumnDesc[] createBlock = {
internal static ColumnDesc[] createBlock = new ColumnDesc[] {
new ColumnDesc("Username", ColumnType.Char, 20),
new ColumnDesc("TimePerformed", ColumnType.DateTime),
new ColumnDesc("X", ColumnType.UInt16),
@ -131,7 +131,7 @@ namespace MCGalaxy {
new ColumnDesc("Deleted", ColumnType.Bool),
};
internal static ColumnDesc[] createPortals = {
internal static ColumnDesc[] createPortals = new ColumnDesc[] {
new ColumnDesc("EntryX", ColumnType.UInt16),
new ColumnDesc("EntryY", ColumnType.UInt16),
new ColumnDesc("EntryZ", ColumnType.UInt16),
@ -141,14 +141,14 @@ namespace MCGalaxy {
new ColumnDesc("ExitZ", ColumnType.UInt16),
};
internal static ColumnDesc[] createMessages = {
internal static ColumnDesc[] createMessages = new ColumnDesc[] {
new ColumnDesc("X", ColumnType.UInt16),
new ColumnDesc("Y", ColumnType.UInt16),
new ColumnDesc("Z", ColumnType.UInt16),
new ColumnDesc("Message", ColumnType.Char, 255),
};
internal static ColumnDesc[] createZones = {
internal static ColumnDesc[] createZones = new ColumnDesc[] {
new ColumnDesc("SmallX", ColumnType.UInt16),
new ColumnDesc("SmallY", ColumnType.UInt16),
new ColumnDesc("SmallZ", ColumnType.UInt16),

View File

@ -35,7 +35,7 @@ namespace MCGalaxy {
static Timer timer;
readonly static IBeat[] Beats = {
readonly static IBeat[] Beats = new IBeat[] {
new ClassiCubeBeat()
}; //Keep these in order

View File

@ -37,7 +37,7 @@ namespace MCGalaxy {
byte retries = 0;
Dictionary<string, List<string>> users = new Dictionary<string, List<string>>();
static char[] trimChars = { ' ' };
static char[] trimChars = new char[] { ' ' };
ConnectionArgs args;
DateTime lastWho, lastOpWho;

View File

@ -23,7 +23,7 @@ using MCGalaxy.SQL;
namespace MCGalaxy {
public sealed partial class Server {
static ColumnDesc[] createPlayers = {
static ColumnDesc[] createPlayers = new ColumnDesc[] {
new ColumnDesc("ID", ColumnType.Integer, priKey: true, autoInc: true, notNull: true),
new ColumnDesc("Name", ColumnType.Text),
new ColumnDesc("IP", ColumnType.Char, 15),
@ -41,7 +41,7 @@ namespace MCGalaxy {
new ColumnDesc("title_color", ColumnType.VarChar, 6),
};
static ColumnDesc[] createOpstats = {
static ColumnDesc[] createOpstats = new ColumnDesc[] {
new ColumnDesc("ID", ColumnType.Integer, priKey: true, autoInc: true, notNull: true),
new ColumnDesc("Time", ColumnType.DateTime),
new ColumnDesc("Name", ColumnType.Text),

View File

@ -222,7 +222,7 @@ namespace Sharkbite.Irc
private const string MODE = "MODE";
private const string KILL = "KILL";
private const string ACTION = "\u0001ACTION";
private readonly char[] Separator = { ' ' };
private readonly char[] Separator = new char[] { ' ' };
private readonly Regex userPattern;
private readonly Regex channelPattern;
private readonly Regex replyRegex;

View File

@ -27,7 +27,7 @@ namespace MCGalaxy {
public static class Extensions {
static char[] trimChars = {' '};
static char[] trimChars = new char[] {' '};
public static string[] SplitSpaces(this string value, int maxParts) {
return value.Split(trimChars, maxParts);
}