mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-27 15:30:58 -04:00
Allow generating non-standard size countdown maps, also /reload without arguments should resend the map to the client. (Thanks FabTheZen)
This commit is contained in:
parent
7d7c405504
commit
6e64532ecb
@ -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();
|
||||
}
|
||||
|
@ -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<OtherPerms> list = new List<OtherPerms>();
|
||||
|
@ -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");
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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":
|
||||
|
@ -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...");
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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";
|
||||
|
@ -600,7 +600,7 @@ namespace MCGalaxy
|
||||
{
|
||||
levels = new List<Level>(maps);
|
||||
|
||||
if (File.Exists("levels/" + level + ".lvl"))
|
||||
if (LevelInfo.ExistsOffline(level))
|
||||
{
|
||||
mainLevel = Level.Load(level);
|
||||
mainLevel.unload = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user