From 4759316a7533136d312eb703a36ba3273bda93a6 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 23 Jan 2016 14:25:50 +1100 Subject: [PATCH] Fix /explode exploding on the player's instead of the target's level, cleanup /queue too. --- Commands/{Moderation => Fun}/CmdAlive.cs | 2 +- Commands/Fun/CmdQueue.cs | 70 ++++++++++ Commands/Moderation/CmdExplode.cs | 161 +++++++++-------------- Commands/Moderation/CmdQueue.cs | 97 -------------- Commands/other/CmdMissile.cs | 17 +-- MCGalaxy_.csproj | 4 +- 6 files changed, 140 insertions(+), 211 deletions(-) rename Commands/{Moderation => Fun}/CmdAlive.cs (94%) create mode 100644 Commands/Fun/CmdQueue.cs delete mode 100644 Commands/Moderation/CmdQueue.cs diff --git a/Commands/Moderation/CmdAlive.cs b/Commands/Fun/CmdAlive.cs similarity index 94% rename from Commands/Moderation/CmdAlive.cs rename to Commands/Fun/CmdAlive.cs index b5bfd9197..f5f93b3bf 100644 --- a/Commands/Moderation/CmdAlive.cs +++ b/Commands/Fun/CmdAlive.cs @@ -21,7 +21,7 @@ namespace MCGalaxy.Commands { public override string name { get { return "alive"; } } public override string shortcut { get { return "alive"; } } - public override string type { get { return CommandTypes.Moderation; } } + public override string type { get { return CommandTypes.Games; } } public override bool museumUsable { get { return true; } } public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } public CmdAlive() { } diff --git a/Commands/Fun/CmdQueue.cs b/Commands/Fun/CmdQueue.cs new file mode 100644 index 000000000..3a8248b56 --- /dev/null +++ b/Commands/Fun/CmdQueue.cs @@ -0,0 +1,70 @@ +/* + Copyright 2010 MCLawl Team - Written by Valek (Modified for use with 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.osedu.org/licenses/ECL-2.0 + 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.IO; +namespace MCGalaxy.Commands +{ + public sealed class CmdQueue : Command + { + public override string name { get { return "queue"; } } + public override string shortcut { get { return "qz"; } } + public override string type { get { return CommandTypes.Games; } } + public override bool museumUsable { get { return true; } } + public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } + public CmdQueue() { } + + public override void Use(Player p, string message) { + string[] args = message.Split(' '); + if (args.Length != 2) { Help(p); return; } + string value = args[1]; + + if (args[0] == "zombie") { + Player who = Player.Find(value); + if (who == null) { + p.SendMessage(value + " is not online."); + } else { + p.SendMessage(value + " was queued."); + Server.queZombie = true; + Server.nextZombie = value; + } + } else if (args[0] == "level") { + bool match = false; + DirectoryInfo di = new DirectoryInfo("levels/"); + FileInfo[] fi = di.GetFiles("*.lvl"); + foreach (FileInfo file in fi) { + if (file.Name.Replace(".lvl", "").ToLower() == value.ToLower()) + match = true; + } + + if (match) { + p.SendMessage(value + " was queued."); + Server.queLevel = true; + Server.nextLevel = value.ToLower(); + } else { + p.SendMessage("Level does not exist."); + } + } else { + p.SendMessage("You did not enter a valid option."); + } + } + + public override void Help(Player p) { + Player.SendMessage(p, "/queue zombie [name] - Next round [name] will be infected"); + Player.SendMessage(p, "/queue level [name] - Next round [name] will be the round loaded"); + } + } +} diff --git a/Commands/Moderation/CmdExplode.cs b/Commands/Moderation/CmdExplode.cs index 7b994eda9..7350f4517 100644 --- a/Commands/Moderation/CmdExplode.cs +++ b/Commands/Moderation/CmdExplode.cs @@ -1,22 +1,22 @@ /* Written by Jack1312 - 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. -*/ + 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; namespace MCGalaxy.Commands { @@ -24,98 +24,57 @@ namespace MCGalaxy.Commands { public override string name { get { return "explode"; } } public override string shortcut { get { return "ex"; } } - public override string type { get { return CommandTypes.Moderation; } } + public override string type { get { return CommandTypes.Moderation; } } public override bool museumUsable { get { return true; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public CmdExplode() { } - public override void Help(Player p) - { + + public override void Use(Player p, string message) { + if (message == "") { Help(p); return; } + string[] args = message.Split(' '); + if (!(args.Length == 1 || args.Length == 3)) { Help(p); return; } + if (message == "me" && p != null) args[0] = p.name; + + ushort x, y, z; + if (args.Length == 1) { + Player who = Player.Find(message); + if (who == null || who.hidden) { + Player.SendMessage(p, "The specified player does not exist!"); return; + } + if (who.level.physics < 3 || who.level.physics == 5) { + Player.SendMessage(p, "The physics on the player's level are not sufficient for exploding."); return; + } + + x = (ushort)(who.pos[0] / 32); + y = (ushort)(who.pos[1] / 32); + z = (ushort)(who.pos[2] / 32); + who.level.MakeExplosion(x, y, z, 1); + Player.SendMessage(p, who.color + who.DisplayName + Server.DefaultColor + " has been exploded!"); + } else if (args.Length == 3) { + try { + x = Convert.ToUInt16(args[0]); + y = Convert.ToUInt16(args[1]); + z = Convert.ToUInt16(args[2]); + } catch { + Player.SendMessage(p, "Invalid parameters"); return; + } + + Level level = p.level; + if (y >= p.level.Height) y = (ushort)(p.level.Height - 1); + + if (p.level.physics < 3 || p.level.physics == 5) { + Player.SendMessage(p, "The physics on this level are not sufficient for exploding!"); return; + } + p.level.MakeExplosion(x, y, z, 1); + Player.SendMessage(p, "An explosion was made at (" + x + ", " + y + ", " + z + ")."); + } + } + + public override void Help(Player p) { Player.SendMessage(p, "/explode - Satisfying all your exploding needs :)"); Player.SendMessage(p, "/explode me - Explodes at your location"); Player.SendMessage(p, "/explode [Player] - Explode the specified player"); Player.SendMessage(p, "/explode [X] [Y] [Z] - Explode at the specified co-ordinates"); - - } - public override void Use(Player p, string message) - { - if (message == "") { Help(p); return; } - int number = message.Split(' ').Length; - if (number > 3) { Player.SendMessage(p, "What are you on about?"); return; } - if (message == "me") - { - if (p.level.physics <3) - { - Player.SendMessage(p, "The physics on this level are not sufficient for exploding!"); - return; - } - Command.all.Find("explode").Use(p, p.name); - return; - } - if (number == 1) - { - if (p != null) - { - if (p.level.physics < 3) - { - Player.SendMessage(p, "The physics on this level are not sufficient for exploding!"); - return; - } - Player who = Player.Find(message); - ushort x = (ushort)(who.pos[0] / 32); - ushort y = (ushort)(who.pos[1] / 32); - ushort z = (ushort)(who.pos[2] / 32); - p.level.MakeExplosion(x, y, z, 1); - Player.SendMessage(p, who.color + who.DisplayName + Server.DefaultColor + " has been exploded!"); - return; - } - Player.SendMessage(p, "The specified player does not exist!"); - return; - } - if (number == 3) - { - { - byte b = Block.Zero; - ushort x = 0; ushort y = 0; ushort z = 0; - - x = (ushort)(p.pos[0] / 32); - y = (ushort)((p.pos[1] / 32) - 1); - z = (ushort)(p.pos[2] / 32); - - try - { - switch (message.Split(' ').Length) - { - case 0: b = Block.rock; break; - case 1: b = Block.Byte(message); break; - case 3: - x = Convert.ToUInt16(message.Split(' ')[0]); - y = Convert.ToUInt16(message.Split(' ')[1]); - z = Convert.ToUInt16(message.Split(' ')[2]); - break; - case 4: - b = Block.Byte(message.Split(' ')[0]); - x = Convert.ToUInt16(message.Split(' ')[1]); - y = Convert.ToUInt16(message.Split(' ')[2]); - z = Convert.ToUInt16(message.Split(' ')[3]); - break; - default: Player.SendMessage(p, "Invalid parameters"); return; - } - } - catch { Player.SendMessage(p, "Invalid parameters"); return; } - - Level level = p.level; - - if (y >= p.level.Height) y = (ushort)(p.level.Height - 1); - - if (p.level.physics < 3) - { - Player.SendMessage(p, "The physics on this level are not sufficient for exploding!"); - return; - } - p.level.MakeExplosion(x, y, z, 1); - Player.SendMessage(p, "An explosion was made at (" + x + ", " + y + ", " + z + ")."); - } - } } } } diff --git a/Commands/Moderation/CmdQueue.cs b/Commands/Moderation/CmdQueue.cs deleted file mode 100644 index 465c94dd0..000000000 --- a/Commands/Moderation/CmdQueue.cs +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright 2010 MCLawl Team - Written by Valek (Modified for use with 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.osedu.org/licenses/ECL-2.0 - 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.IO; -namespace MCGalaxy.Commands -{ - public sealed class CmdQueue : Command - { - public override string name { get { return "queue"; } } - public override string shortcut { get { return "qz"; } } - public override string type { get { return CommandTypes.Moderation; } } - public override bool museumUsable { get { return true; } } - public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - public CmdQueue() { } - - public override void Use(Player p, string message) - { - int number = message.Split(' ').Length; - if (number > 2) { Help(p); return; } - if (number == 2) - { - Server.s.Log(message); - string t = message.Split(' ')[0]; - string s = message.Split(' ')[1]; - if (t == "zombie") - { - bool asdfasdf = false; - Player.players.ForEach(delegate(Player player) - { - if (player.name == s) - { - p.SendMessage(s + " was queued."); - Server.queZombie = true; - Server.nextZombie = s; - asdfasdf = true; - return; - } - }); - if (!asdfasdf) - { - p.SendMessage(s + " is not online."); - return; - } - } - else if (t == "level") - { - bool yes = false; - DirectoryInfo di = new DirectoryInfo("levels/"); - FileInfo[] fi = di.GetFiles("*.lvl"); - foreach (FileInfo file in fi) - { - if (file.Name.Replace(".lvl", "").ToLower().Equals(s.ToLower())) - { - yes = true; - } - } - if (yes) - { - p.SendMessage(s + " was queued."); - Server.queLevel = true; - Server.nextLevel = s.ToLower(); - return; - } - else - { - p.SendMessage("Level does not exist."); - return; - } - } - else - { - p.SendMessage("You did not enter a valid option."); - } - } - } - - public override void Help(Player p) - { - Player.SendMessage(p, "/queue zombie [name] - Next round [name] will be infected"); - Player.SendMessage(p, "/queue level [name] - Next round [name] will be the round loaded"); - } - } -} diff --git a/Commands/other/CmdMissile.cs b/Commands/other/CmdMissile.cs index 0d6e49025..07aab5ea2 100644 --- a/Commands/other/CmdMissile.cs +++ b/Commands/other/CmdMissile.cs @@ -176,21 +176,18 @@ namespace MCGalaxy.Commands Thread gunThread = new Thread(new ThreadStart(delegate { - ushort startX = (ushort)(p.pos[0] / 32); - ushort startY = (ushort)(p.pos[1] / 32); - ushort startZ = (ushort)(p.pos[2] / 32); - pos.x = startX; - pos.y = startY; - pos.z = startZ; + pos.x = (ushort)(p.pos[0] / 32); + pos.y = (ushort)(p.pos[1] / 32); + pos.z = (ushort)(p.pos[2] / 32); int total = 0; List buffer = new List(2); while (true) { - startX = (ushort)(p.pos[0] / 32); - startY = (ushort)(p.pos[1] / 32); - startZ = (ushort)(p.pos[2] / 32); + ushort startX = (ushort)(p.pos[0] / 32); + ushort startY = (ushort)(p.pos[1] / 32); + ushort startZ = (ushort)(p.pos[2] / 32); total++; double a = Math.Sin(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI); @@ -348,7 +345,7 @@ namespace MCGalaxy.Commands if (previous.Count > 12) { p.level.Blockchange(previous[0].x, previous[0].y, previous[0].z, Block.air); - previous.Remove(previous[0]); + previous.RemoveAt(0); } Thread.Sleep(100); } diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index 300264330..223904902 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -170,6 +170,7 @@ + @@ -178,6 +179,7 @@ + @@ -219,7 +221,6 @@ - @@ -264,7 +265,6 @@ -