diff --git a/Commands/CmdOverseer.cs b/Commands/CmdOverseer.cs index 37559d88a..79ae31e63 100644 --- a/Commands/CmdOverseer.cs +++ b/Commands/CmdOverseer.cs @@ -175,8 +175,7 @@ namespace MCGalaxy.Commands string level = p.name.ToLower(); if ((File.Exists("levels/" + level + ".lvl")) || (File.Exists("levels/" + level + "00.lvl"))) { for (int i = 2; i < p.group.OverseerMaps + 2; i++) { - if (File.Exists("levels/" + p.name.ToLower() + i + ".lvl")) - continue; + if (LevelInfo.ExistsOffline(p.name.ToLower() + i)) continue; if(i > p.group.OverseerMaps) { p.SendMessage("You have reached the limit for your overseer maps."); return; } @@ -377,7 +376,7 @@ namespace MCGalaxy.Commands * both map names (UserName and UserName00) * I need to figure out how to add a system to do this with the players second map. */ - if (File.Exists("levels/" + p.name.ToLower() + "00.lvl")) + if (LevelInfo.ExistsOffline(p.name.ToLower() + "00")) return p.name.ToLower() + "00"; return p.name.ToLower(); } diff --git a/Commands/CommandOtherPerms.cs b/Commands/CommandOtherPerms.cs index 4d82bf6c2..2cced23df 100644 --- a/Commands/CommandOtherPerms.cs +++ b/Commands/CommandOtherPerms.cs @@ -69,6 +69,7 @@ namespace MCGalaxy Add(Command.all.Find("draw"), (int)Command.all.Find("draw").defaultRank, "The lowest rank that can use spheres with /draw", 3); Add(Command.all.Find("draw"), (int)Command.all.Find("draw").defaultRank, "The lowest rank that can use volcanos with /draw", 4); Add(Command.core.Find("tntwars"), (int)LevelPermission.Operator, "The lowest rank that can use admin commands for tntwars", 1); + Add(Command.core.Find("reload"), (int)LevelPermission.Operator, "The lowest rank that can reload the maps for others", 1); } public static List list = new List(); diff --git a/Commands/Fun/CmdCountdown.cs b/Commands/Fun/CmdCountdown.cs index 105199149..a2d46c399 100644 --- a/Commands/Fun/CmdCountdown.cs +++ b/Commands/Fun/CmdCountdown.cs @@ -37,9 +37,10 @@ namespace MCGalaxy.Commands { if (p == null) { MessageInGameOnly(p); return; } string[] args = message.ToLower().Split(' '); - string cmd = args[0], arg1 = "", arg2 = ""; + string cmd = args[0], arg1 = "", arg2 = "", arg3 = ""; if (args.Length > 1) arg1 = args[1]; if (args.Length > 2) arg2 = args[2]; + if (args.Length > 3) arg3 = args[3]; switch (cmd) { case "help": @@ -62,7 +63,7 @@ namespace MCGalaxy.Commands { switch (cmd) { case "download": case "generate": - HandleGenerate(p); return; + HandleGenerate(p, arg1, arg2, arg3); return; case "enable": HandleEnable(p); return; case "disable": @@ -210,14 +211,29 @@ namespace MCGalaxy.Commands { } } - void HandleGenerate(Player p) { - Level lvl = CountdownMapGen.Generate(32, 32, 32); + void HandleGenerate(Player p, string arg1, string arg2, string arg3) { + int width, height, length; + if(!int.TryParse(arg1, out width) || !int.TryParse(arg2, out height) || !int.TryParse(arg3, out length)) { + width = 32; height = 32; length = 32; + } + if (width < 32 || !MapGen.OkayAxis(width)) width = 32; + if (height < 32 || !MapGen.OkayAxis(height)) height = 32; + if (length < 32 || !MapGen.OkayAxis(length)) length = 32; + + Level oldLevel = LevelInfo.FindExact("countdown"); + if (oldLevel != null) { + oldLevel.permissionbuild = LevelPermission.Guest; + Command.all.Find("deletelvl").Use(p, "countdown"); + } + Level lvl = CountdownMapGen.Generate(width, height, length); lvl.Save(); - Player.SendMessage(p, "Downloaded map, now loading map and sending you to it."); + if (Server.Countdown.gamestatus != CountdownGameStatus.Disabled) + Server.Countdown.mapon = lvl; + + const string format = "Generated map ({0}x{1}x{2}), sending you to it.."; + Player.SendMessage(p, String.Format(format, width, height, length)); Command.all.Find("load").Use(p, "countdown"); Command.all.Find("goto").Use(p, "countdown"); - Thread.Sleep(1000); - // Sleep for a bit while they load p.level.permissionbuild = LevelPermission.Nobody; p.level.motd = "Welcome to the Countdown map!!!! -hax"; @@ -233,7 +249,7 @@ namespace MCGalaxy.Commands { Server.Countdown.mapon = LevelInfo.FindExact("countdown"); if (Server.Countdown.mapon == null ) { Player.SendMessage(p, "countdown level not found, generating.."); - HandleGenerate(p); + HandleGenerate(p, "", "", ""); Server.Countdown.mapon = LevelInfo.FindExact("countdown"); } @@ -344,7 +360,7 @@ namespace MCGalaxy.Commands { p.SendMessage("/cd rules - view the rules of countdown"); if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { - p.SendMessage("/cd generate - generates the countdown map"); + p.SendMessage("/cd generate [width] [height] [length] - generates the countdown map (default size is 32x32x32)"); p.SendMessage("/cd enable - enable the game"); p.SendMessage("/cd disable - disable the game"); p.SendMessage("/cd cancel - cancels a game"); diff --git a/Commands/Moderation/CmdRenameLvl.cs b/Commands/Moderation/CmdRenameLvl.cs index 8adea92de..6b2c57db7 100644 --- a/Commands/Moderation/CmdRenameLvl.cs +++ b/Commands/Moderation/CmdRenameLvl.cs @@ -41,7 +41,7 @@ namespace MCGalaxy.Commands string newName = message.Split(' ')[1]; - if (File.Exists("levels/" + newName + ".lvl")) { Player.SendMessage(p, "Level already exists."); return; } + if (LevelInfo.ExistsOffline(newName)) { Player.SendMessage(p, "Level already exists."); return; } if (foundLevel == Server.mainLevel) { Player.SendMessage(p, "Cannot rename the main level."); return; } foundLevel.Unload(); diff --git a/Commands/World/CmdDeleteLvl.cs b/Commands/World/CmdDeleteLvl.cs index 81f5a2875..403a1db8e 100644 --- a/Commands/World/CmdDeleteLvl.cs +++ b/Commands/World/CmdDeleteLvl.cs @@ -44,7 +44,7 @@ namespace MCGalaxy.Commands { if (foundLevel == Server.mainLevel) { Player.SendMessage(p, "Cannot delete the main level."); return; } if (!Directory.Exists("levels/deleted")) Directory.CreateDirectory("levels/deleted"); - if (!File.Exists("levels/" + message + ".lvl")) { + if (!LevelInfo.ExistsOffline(message)) { Player.SendMessage(p, "Could not find specified level."); return; } diff --git a/Commands/World/CmdEnvironment.cs b/Commands/World/CmdEnvironment.cs index 42ef45b1a..a32ed42e5 100644 --- a/Commands/World/CmdEnvironment.cs +++ b/Commands/World/CmdEnvironment.cs @@ -72,11 +72,11 @@ namespace MCGalaxy.Commands { SetEnvWeather(p, value, ref lvl.weather); break; case "cloudsheight": case "cloudheight": - SetEnvMapAppearanceS(p, value, "clouds height", (short)(lvl.height + 2), ref lvl.CloudsHeight); break; + SetEnvMapAppearanceS(p, value, "clouds height", (short)(lvl.Height + 2), ref lvl.CloudsHeight); break; case "waterlevel": case "edgelevel": case "level": - SetEnvMapAppearanceS(p, value, "water level", (short)(lvl.height / 2), ref lvl.EdgeLevel); break; + SetEnvMapAppearanceS(p, value, "water level", (short)(lvl.Height / 2), ref lvl.EdgeLevel); break; case "maxfogdistance": case "maxfog": case "fogdistance": diff --git a/Commands/World/CmdGoto.cs b/Commands/World/CmdGoto.cs index 05202ee57..c9cad3c58 100644 --- a/Commands/World/CmdGoto.cs +++ b/Commands/World/CmdGoto.cs @@ -48,7 +48,7 @@ namespace MCGalaxy.Commands { if (lvl != null) { GoToLevel(p, lvl, message); } else if (Server.AutoLoad) { - if (!File.Exists("levels/" + message + ".lvl")) { + if (!LevelInfo.ExistsOffline(message)) { lvl = LevelInfo.Find(message); if (lvl == null) { Player.SendMessage(p, "Level \"" + message + "\" doesn't exist! Did you mean..."); diff --git a/Commands/World/CmdLoad.cs b/Commands/World/CmdLoad.cs index 203481ccf..33d487d92 100644 --- a/Commands/World/CmdLoad.cs +++ b/Commands/World/CmdLoad.cs @@ -71,8 +71,7 @@ namespace MCGalaxy.Commands } } - if (!File.Exists("levels/" + message + ".lvl")) - { + if (!LevelInfo.ExistsOffline(message)) { Player.SendMessage(p, "Level \"" + message + "\" doesn't exist!"); return; } @@ -82,7 +81,7 @@ namespace MCGalaxy.Commands { if (File.Exists("levels/" + message + ".lvl.backup")) { - if (File.Exists("levels/" + message + ".lvl")) + if (LevelInfo.ExistsOffline(message)) { Server.s.Log(message + ".lvl file is corrupt. Deleting and replacing with " + message + ".lvl.backup file."); File.Delete("levels/" + message + ".lvl"); diff --git a/Commands/World/CmdNewLvl.cs b/Commands/World/CmdNewLvl.cs index 80150c72e..0833d214b 100644 --- a/Commands/World/CmdNewLvl.cs +++ b/Commands/World/CmdNewLvl.cs @@ -55,7 +55,7 @@ namespace MCGalaxy.Commands if (!Player.ValidName(name)) { Player.SendMessage(p, "Invalid name!"); return; } - if (File.Exists("levels/" + name + ".lvl")) { + if (LevelInfo.ExistsOffline(message)) { Player.SendMessage(p, "Level \"" + name + "\" already exists!"); return; } diff --git a/Commands/World/CmdReload.cs b/Commands/World/CmdReload.cs index bc0691b61..8b911c28e 100644 --- a/Commands/World/CmdReload.cs +++ b/Commands/World/CmdReload.cs @@ -19,44 +19,46 @@ using System.Collections.Generic; using System.IO; namespace MCGalaxy.Commands { - + public sealed class CmdReload : Command { - + public override string name { get { return "reload"; } } public override string shortcut { get { return "rd"; } } public override string type { get { return CommandTypes.World; } } public override bool museumUsable { get { return false; } } - public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } + public override LevelPermission defaultRank { get { return LevelPermission.Guest; } } public CmdReload() { } public override void Use(Player p, string message) { if (p == null && message == "") { - Player.SendMessage(p, "You must give a level name when running the command from console."); return; - } + Player.SendMessage(p, "You must give a level name when using the command from console."); return; + } + if (message == "") { CmdReveal.ReloadMap(p, p, false); return; } - string name = message == "" ? p.level.name : message; - if (!File.Exists("levels/" + name + ".lvl")) { - Player.SendMessage(p, "The given level \"" + name + "\" does not exist."); return; - } - if (Server.mainLevel.name == name) { - Player.SendMessage(p, "You cannot reload the main level."); return; - } + int minPerm = CommandOtherPerms.GetPerm(this, 1); + if (p != null && (int)p.group.Permission < minPerm) { + Player.SendMessage(p, "%HYou need to be at least %T" + Group.findPermInt(minPerm).name + " %Hto reload maps."); return; + } + if (!LevelInfo.ExistsOffline(message)) { + Player.SendMessage(p, "The given level \"" + message + "\" does not exist."); return; + } foreach (Player pl in PlayerInfo.players) { - if (pl.level.name.ToLower() != name.ToLower()) continue; + if (pl.level.name.ToLower() != message.ToLower()) continue; CmdReveal.ReloadMap(p, pl, false); - } - - Player.GlobalMessage("&cThe map, " + name + " has been reloaded!"); - Server.IRC.Say("The map, " + name + " has been reloaded."); + } + Player.GlobalMessage("&cThe map, " + message + " has been reloaded!"); + Server.IRC.Say("The map, " + message + " has been reloaded."); string src = p == null ? "the console" : p.name; - Server.s.Log("The map " + name + " was reloaded by " + src); + Server.s.Log("The map " + message + " was reloaded by " + src); } public override void Help(Player p) { - Player.SendMessage(p, "%T/reload [map]"); - Player.SendMessage(p, "%HReloads the given map. " + - "If no map is specified, reloads the current map you are in."); + Player.SendMessage(p, "%T/reload [map]"); + Player.SendMessage(p, "%HReloads the given map for all players in that map."); + Player.SendMessage(p, "%HIf no map is specified, reloads the map you are in just for you."); + int minPerm = CommandOtherPerms.GetPerm(this, 1); + Player.SendMessage(p, "%T" + Group.findPermInt(minPerm).name + " %H or above can reload maps for all players."); } } } diff --git a/Games/Countdown/CountdownGame.Game.cs b/Games/Countdown/CountdownGame.Game.cs index 51e9f9f66..bf7c8438e 100644 --- a/Games/Countdown/CountdownGame.Game.cs +++ b/Games/Countdown/CountdownGame.Game.cs @@ -70,8 +70,8 @@ namespace MCGalaxy { x = p.countdowntempx; z = p.countdowntempz; p.SendPos(0xFF, x, (ushort)(y - 22), z, rotX, rotY); } - p.pos = new ushort[3] { x, y, z }; - p.rot = new byte[2] { rotX, rotY }; + p.pos[0] = x; p.pos[1] = y; p.pos[2] = z; + p.rot[0] = rotX; p.rot[1] = rotY; return true; } } diff --git a/Games/Countdown/CountdownGame.cs b/Games/Countdown/CountdownGame.cs index 6c1b6d08b..42a1286e6 100644 --- a/Games/Countdown/CountdownGame.cs +++ b/Games/Countdown/CountdownGame.cs @@ -57,15 +57,13 @@ namespace MCGalaxy { mapon.permissionbuild = LevelPermission.Nobody; int midX = mapon.Width / 2, midY = mapon.Height / 2, midZ = mapon.Length / 2; ushort x1 = (ushort)(midX * 32 + 16); - ushort y1 = (ushort)((mapon.height - 2) * 32); + ushort y1 = (ushort)((mapon.Height - 2) * 32); ushort z1 = (ushort)(midZ * 32 + 16); foreach (Player player in players) { if (player.level != mapon) { player.SendMessage("Sending you to the correct map."); Command.all.Find("goto").Use(player, mapon.name); - Thread.Sleep(1000); - // Sleep for a bit while they load } player.SendSpawn(0xFF, player.name, x1, y1, z1, (byte)0, (byte)0); } @@ -84,11 +82,11 @@ namespace MCGalaxy { Thread.Sleep(2000); mapon.ChatLevel("-----&b5%S-----"); - Cuboid(midX, midY, midZ, midX + 1, midY, midZ + 1, Block.air, mapon); + Cuboid(midX - 1, midY, midZ - 1, midX, midY, midZ, Block.air, mapon); Thread.Sleep(1000); mapon.ChatLevel("-----&b4%S-----"); Thread.Sleep(1000); mapon.ChatLevel("-----&b3%S-----"); Thread.Sleep(1000); - Cuboid(midX, mapon.Height - 5, midZ, midX + 1, mapon.Height - 5, midZ + 1, Block.air, mapon); + Cuboid(midX, mapon.Height - 5, midZ, midX + 1, mapon.Height - 5, midZ + 1, Block.air, mapon); mapon.ChatLevel("-----&b2%S-----"); Thread.Sleep(1000); mapon.ChatLevel("-----&b1%S-----"); Thread.Sleep(1000); mapon.ChatLevel("GO!!!!!!!"); @@ -357,7 +355,7 @@ namespace MCGalaxy { Cuboid(midX - 1, midY + 1, midZ + 1, midX, midY + 2, midZ + 1, block, mapon); Cuboid(midX - 2, midY + 1, midZ - 1, midX - 2, midY + 2, midZ, block, mapon); Cuboid(midX + 1, midY + 1, midZ - 1, midX + 1, midY + 2, midZ, block, mapon); - Cuboid(midX, midY, midZ, midX + 1, midY, midZ + 1, floorBlock, mapon); + Cuboid(midX - 1, midY, midZ - 1, midX, midY, midZ, floorBlock, mapon); } public void MessageAll(string message) { diff --git a/Levels/Generator/RealisticMapGen.cs b/Levels/Generator/RealisticMapGen.cs index 3c4cbdbe7..def6a0438 100644 --- a/Levels/Generator/RealisticMapGen.cs +++ b/Levels/Generator/RealisticMapGen.cs @@ -49,7 +49,7 @@ namespace MCGalaxy { terrain = new float[Lvl.Width * Lvl.Length]; overlay = new float[Lvl.Width * Lvl.Length]; if (genParams.GenTrees) overlay2 = new float[Lvl.Width * Lvl.Length]; - LiquidLevel = genParams.GetLiquidLevel(Lvl.height); + LiquidLevel = genParams.GetLiquidLevel(Lvl.Height); GenerateFault(terrain, Lvl, rand); FilterAverage(Lvl); diff --git a/Levels/Level.cs b/Levels/Level.cs index 7487cdd47..a5fbb8328 100644 --- a/Levels/Level.cs +++ b/Levels/Level.cs @@ -104,10 +104,10 @@ namespace MCGalaxy public ushort Width, Height, Length; // NOTE: These are for legacy matching only, you should use upper case Width/Height/Length // as these correctly map Y to beinh Height - public ushort width { get { return Width; } } - public ushort height { get { return Length; } } - public ushort depth { get { return Height; } } - public ushort length { get { return Length; } } + [Obsolete] public ushort width { get { return Width; } } + [Obsolete] public ushort height { get { return Length; } } + [Obsolete] public ushort depth { get { return Height; } } + [Obsolete] public ushort length { get { return Length; } } public int drown = 70; public bool edgeWater; diff --git a/Levels/LevelInfo.cs b/Levels/LevelInfo.cs index 869798b67..1acc6a944 100644 --- a/Levels/LevelInfo.cs +++ b/Levels/LevelInfo.cs @@ -44,6 +44,10 @@ namespace MCGalaxy { } return null; } + + public static bool ExistsOffline(string name) { + return File.Exists("levels/" + name.ToLower() + ".lvl"); + } public static string FindOfflineProperty(string name, string propKey) { string file = "levels/level properties/" + name + ".properties"; diff --git a/Server/Server.cs b/Server/Server.cs index ebe2b1171..19cd7ae58 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -600,7 +600,7 @@ namespace MCGalaxy { levels = new List(maps); - if (File.Exists("levels/" + level + ".lvl")) + if (LevelInfo.ExistsOffline(level)) { mainLevel = Level.Load(level); mainLevel.unload = false;