diff --git a/MCGalaxy/Commands/Bots/CmdBotSet.cs b/MCGalaxy/Commands/Bots/CmdBotSet.cs index a5c2bddcb..33cc1e1d9 100644 --- a/MCGalaxy/Commands/Bots/CmdBotSet.cs +++ b/MCGalaxy/Commands/Bots/CmdBotSet.cs @@ -32,7 +32,7 @@ namespace MCGalaxy.Commands { public override void Use(Player p, string message) { if (message == "") { Help(p); return; } string[] args = message.SplitSpaces(); - PlayerBot bot = PlayerBot.FindMatchesPreferLevel(p, args[0]); + PlayerBot bot = Matcher.FindBotsInLevel(p, args[0]); if (bot == null) return; if (p != null && !bot.level.BuildAccess.CheckDetailed(p)) { diff --git a/MCGalaxy/Commands/Bots/CmdBots.cs b/MCGalaxy/Commands/Bots/CmdBots.cs index e94646c68..00801f7c3 100644 --- a/MCGalaxy/Commands/Bots/CmdBots.cs +++ b/MCGalaxy/Commands/Bots/CmdBots.cs @@ -26,29 +26,32 @@ namespace MCGalaxy.Commands { public override LevelPermission defaultRank { get { return LevelPermission.Builder; } } public CmdBots() { } - public override void Use(Player p, string message) { - PlayerBot[] bots = PlayerBot.Bots.Items; - Level lvl = null; + public override void Use(Player p, string message) { + Level lvl = p.level; string[] args = message.SplitSpaces(2); + int ignored; - if (!(message == "" || args[0].CaselessEq("all"))) { + if (!(message == "" || args[0].CaselessEq("all") || int.TryParse(args[0], out ignored))) { lvl = Matcher.FindLevels(p, args[0]); if (lvl == null) return; } + PlayerBot[] bots = PlayerBot.Bots.Items; List inScope = new List(); foreach (PlayerBot bot in bots) { - if (lvl != null && bot.level != lvl) continue; + if (bot.level != lvl) continue; inScope.Add(bot); } - string cmd = lvl == null ? "bots all" : "bots " + lvl.name; + string cmd = lvl == p.level ? "bots" : "bots " + lvl.name; string modifier = args.Length > 1 ? args[1] : ""; + Player.Message(p, "Bots in {0}:", lvl.ColoredName); MultiPageOutput.Output(p, inScope, FormatBot, cmd, "bots", modifier, false); } static string FormatBot(PlayerBot bot) { - string desc = bot.name + "(" + bot.level.name + ")"; + string desc = bot.DisplayName; + if (bot.DisplayName != bot.name) desc += "%S(" + bot.name + ")"; if (bot.AIName != "") desc += "[" + bot.AIName + "]"; else if (bot.hunt) desc += "[Hunt]"; @@ -57,8 +60,8 @@ namespace MCGalaxy.Commands { } public override void Help(Player p) { - Player.Message(p, "%T/bots %H- Shows a list of bots, their AIs and levels"); - Player.Message(p, "%T/bots [level] %H- Only shows bots on the given level"); + Player.Message(p, "%T/bots %H- Shows a list of bots on your level, and their AIs and levels"); + Player.Message(p, "%T/bots [level] %H- Shows bots on the given level"); } } } diff --git a/MCGalaxy/Commands/CPE/CmdEnvironment.cs b/MCGalaxy/Commands/CPE/CmdEnvironment.cs index e12facf8e..4122c4aff 100644 --- a/MCGalaxy/Commands/CPE/CmdEnvironment.cs +++ b/MCGalaxy/Commands/CPE/CmdEnvironment.cs @@ -83,11 +83,11 @@ namespace MCGalaxy.Commands { case "level": LevelEnv.SetShort(p, value, EnvProp.EdgeLevel, "water level", (short)(lvl.Height / 2), ref lvl.EdgeLevel); break; - case "bedrocklevel": - case "sideslevel": - case "sidelevel": - LevelEnv.SetShort(p, value, EnvProp.SidesLevel, - "bedrock level", (short)(lvl.Height / 2 - 2), ref lvl.SidesLevel); break; + case "bedrockoffset": + case "sidesoffset": + case "sideoffset": + LevelEnv.SetShort(p, value, EnvProp.SidesOffset, + "bedrock offset", -2, ref lvl.SidesOffset); break; case "maxfogdistance": case "maxfog": case "fogdistance": @@ -136,8 +136,8 @@ namespace MCGalaxy.Commands { LevelEnv.SetShort(p, "normal", EnvProp.EdgeLevel, "water level", (short)(lvl.Height / 2), ref lvl.EdgeLevel); - LevelEnv.SetShort(p, "normal", EnvProp.EdgeLevel, - "bedrock level", (short)(lvl.Height / 2 - 2), ref lvl.SidesLevel); + LevelEnv.SetShort(p, "normal", EnvProp.SidesOffset, + "bedrock offset", -2, ref lvl.SidesOffset); LevelEnv.SetShort(p, "normal", EnvProp.CloudsLevel, "clouds height", (short)(lvl.Height + 2), ref lvl.CloudsHeight); } @@ -211,7 +211,7 @@ namespace MCGalaxy.Commands { Player.Message(p, "%T/env [variable] [value]"); Player.Message(p, "%HVariables: fog, cloud, sky, sun, shadow, weather, level"); Player.Message(p, "%H horizon, border, preset, maxfog, cloudsheight"); - Player.Message(p, "%H cloudspeed, weatherspeed, weatherfade, expfog, sideslevel"); + Player.Message(p, "%H cloudspeed, weatherspeed, weatherfade, expfog, sidesoffset"); Player.Message(p, "%HUsing 'normal' as a value will reset the variable"); Player.Message(p, "%T/env normal %H- resets all variables"); } diff --git a/MCGalaxy/Commands/EntityPropertyCmd.cs b/MCGalaxy/Commands/EntityPropertyCmd.cs index a7279096f..7e0850bb8 100644 --- a/MCGalaxy/Commands/EntityPropertyCmd.cs +++ b/MCGalaxy/Commands/EntityPropertyCmd.cs @@ -28,7 +28,7 @@ namespace MCGalaxy.Commands { Player who = null; PlayerBot bot = null; - if (isBot) bot = PlayerBot.FindMatchesPreferLevel(p, args[1]); + if (isBot) bot = Matcher.FindBotsInLevel(p, args[1]); else who = PlayerInfo.FindMatches(p, args[0]); if (bot == null && who == null) return; diff --git a/MCGalaxy/Commands/Information/CmdMapInfo.cs b/MCGalaxy/Commands/Information/CmdMapInfo.cs index 585b9ed2e..45832ea03 100644 --- a/MCGalaxy/Commands/Information/CmdMapInfo.cs +++ b/MCGalaxy/Commands/Information/CmdMapInfo.cs @@ -199,8 +199,8 @@ namespace MCGalaxy.Commands { Player.Message(p, format, Color(data.Fog), Color(data.Sky), Color(data.Clouds), Color(data.Light), Color(data.Shadow)); - Player.Message(p, "Water level: &b{0}%S, Bedrock level: &b{1}%S, Clouds height: &b{2}%S, Max fog distance: &b{3}", - data.EdgeLevel, data.SidesLevel, data.CloudsHeight, data.MaxFog); + Player.Message(p, "Water level: &b{0}%S, Bedrock offset: &b{1}%S, Clouds height: &b{2}%S, Max fog distance: &b{3}", + data.EdgeLevel, data.SidesOffset, data.CloudsHeight, data.MaxFog); Player.Message(p, "Edge Block: &b{0}%S, Horizon Block: &b{1}", data.EdgeBlock, data.HorizonBlock); Player.Message(p, "Clouds speed: &b{0}%%S, Weather speed: &b{1}%", (data.CloudsSpeed / 256f).ToString("F2"), @@ -220,7 +220,7 @@ namespace MCGalaxy.Commands { // Env data public string TerrainUrl, TextureUrl; public string Fog, Sky, Clouds, Light, Shadow; - public int EdgeLevel, SidesLevel, CloudsHeight, MaxFog; + public int EdgeLevel, SidesOffset = -2, CloudsHeight, MaxFog; public int CloudsSpeed = 256, WeatherSpeed = 256, WeatherFade = 128; public byte EdgeBlock = Block.blackrock, HorizonBlock = Block.water; public bool ExpFog; @@ -253,7 +253,7 @@ namespace MCGalaxy.Commands { Fog = lvl.FogColor; Sky = lvl.SkyColor; Clouds = lvl.CloudColor; Light = lvl.LightColor; Shadow = lvl.ShadowColor; - EdgeLevel = lvl.EdgeLevel; SidesLevel = lvl.SidesLevel; CloudsHeight = lvl.CloudsHeight; + EdgeLevel = lvl.EdgeLevel; SidesOffset = lvl.SidesOffset; CloudsHeight = lvl.CloudsHeight; MaxFog = lvl.MaxFogDistance; ExpFog = lvl.ExpFog; CloudsSpeed = lvl.CloudsSpeed; WeatherSpeed = lvl.WeatherSpeed; EdgeBlock = (byte)lvl.EdgeBlock; HorizonBlock = (byte)lvl.HorizonBlock; @@ -275,16 +275,14 @@ namespace MCGalaxy.Commands { Vec3U16 dims = IMapImporter.Formats[0].ReadDimensions(path); Width = dims.X; Height = dims.Y; Length = dims.Z; - EdgeLevel = Height / 2; - SidesLevel = int.MinValue; - CloudsHeight = Height + 2; + EdgeLevel = Height / 2; CloudsHeight = Height + 2; BlockDBEntries = BlockDBFile.CountEntries(name); path = LevelInfo.FindPropertiesFile(name); if (path != null) PropertiesFile.Read(path, ParseProperty, '='); if (Authors == null) Authors = ""; - if (SidesLevel == int.MinValue) SidesLevel = EdgeLevel - 2; + if (SidesOffset == int.MinValue) SidesOffset = EdgeLevel - 2; } void ParseProperty(string key, string value) { @@ -317,7 +315,7 @@ namespace MCGalaxy.Commands { case "edgeblock": EdgeBlock = byte.Parse(value); break; case "edgelevel": EdgeLevel = short.Parse(value); break; - case "sideslevel": SidesLevel = short.Parse(value); break; + case "sidesoffset": SidesOffset = short.Parse(value); break; case "horizonblock": HorizonBlock = byte.Parse(value); break; case "cloudsheight": CloudsHeight = short.Parse(value); break; case "maxfog": MaxFog = short.Parse(value); break; diff --git a/MCGalaxy/Generator/SimpleGen.cs b/MCGalaxy/Generator/SimpleGen.cs index 203ed591c..74df053a6 100644 --- a/MCGalaxy/Generator/SimpleGen.cs +++ b/MCGalaxy/Generator/SimpleGen.cs @@ -39,10 +39,8 @@ namespace MCGalaxy.Generator { Level lvl = args.Level; int grassHeight = lvl.Height / 2; if (args.UseSeed && args.Seed >= 0 && args.Seed < lvl.Height) - grassHeight = args.Seed; - + grassHeight = args.Seed; lvl.EdgeLevel = grassHeight + 1; - lvl.SidesLevel = lvl.EdgeLevel - 2; fixed (byte* ptr = lvl.blocks) { if (grassHeight > 0) diff --git a/MCGalaxy/Levels/IO/Importers/BinVoxImporter.cs b/MCGalaxy/Levels/IO/Importers/BinVoxImporter.cs index 2062b6bae..6227e2ba8 100644 --- a/MCGalaxy/Levels/IO/Importers/BinVoxImporter.cs +++ b/MCGalaxy/Levels/IO/Importers/BinVoxImporter.cs @@ -36,7 +36,6 @@ namespace MCGalaxy.Levels.IO { Vec3U16 dims = ReadHeader(reader); Level lvl = new Level(name, dims.X, dims.Y, dims.Z); lvl.EdgeLevel = 0; - lvl.SidesLevel = lvl.EdgeLevel - 2; byte[] blocks = lvl.blocks; int size = dims.X * dims.Y * dims.Z, i = 0; diff --git a/MCGalaxy/Levels/IO/Importers/CwImporter.cs b/MCGalaxy/Levels/IO/Importers/CwImporter.cs index 690830810..3bf0c6b9f 100644 --- a/MCGalaxy/Levels/IO/Importers/CwImporter.cs +++ b/MCGalaxy/Levels/IO/Importers/CwImporter.cs @@ -84,8 +84,7 @@ namespace MCGalaxy.Levels.IO { lvl.EdgeLevel = comp["SideLevel"].ShortValue; if (lvl.EdgeLevel == -1) - lvl.EdgeLevel = (short)(lvl.Height / 2); - lvl.SidesLevel = lvl.EdgeLevel - 2; + lvl.EdgeLevel = (short)(lvl.Height / 2); if (!comp.Contains("TextureURL")) return; string url = comp["TextureURL"].StringValue; diff --git a/MCGalaxy/Levels/Level.Fields.cs b/MCGalaxy/Levels/Level.Fields.cs index 354fedbd3..54994bd24 100644 --- a/MCGalaxy/Levels/Level.Fields.cs +++ b/MCGalaxy/Levels/Level.Fields.cs @@ -127,9 +127,9 @@ namespace MCGalaxy { /// Elevation of the "ocean" that surrounds maps. Default is map height / 2. [ConfigInt("EdgeLevel", "Env", null, -1, short.MinValue, short.MaxValue)] public int EdgeLevel; - /// Elevation of the "bedrock" that surrounds map sides. Default is (map height / 2) - 2. - [ConfigInt("SidesLevel", "Env", null, -1, short.MinValue, short.MaxValue)] - public int SidesLevel; + /// Offset of the "bedrock" that surrounds map sides from edge level. Default is -2. + [ConfigInt("SidesOffset", "Env", null, -2, short.MinValue, short.MaxValue)] + public int SidesOffset = -2; /// Elevation of the clouds. Default is map height + 2. [ConfigInt("CloudsHeight", "Env", null, -1, short.MinValue, short.MaxValue)] public int CloudsHeight; diff --git a/MCGalaxy/Levels/Level.cs b/MCGalaxy/Levels/Level.cs index 60fe60b55..c98123d4e 100644 --- a/MCGalaxy/Levels/Level.cs +++ b/MCGalaxy/Levels/Level.cs @@ -77,7 +77,6 @@ namespace MCGalaxy { name = n; MapName = n.ToLower(); BlockDB = new BlockDB(this); EdgeLevel = (short)(y / 2); - SidesLevel = (short)(y / 2 - 2); CloudsHeight = (short)(y + 2); blocks = new byte[Width * Height * Length]; @@ -382,7 +381,6 @@ namespace MCGalaxy { } public static void LoadMetadata(Level lvl) { - lvl.SidesLevel = int.MinValue; try { string propsPath = LevelInfo.FindPropertiesFile(lvl.MapName); if (propsPath != null) { @@ -396,9 +394,6 @@ namespace MCGalaxy { } catch (Exception e) { Server.ErrorLog(e); } - - // backwards compatibility: old properties files don't have this field - if (lvl.SidesLevel == int.MinValue) lvl.SidesLevel = lvl.EdgeLevel - 2; lvl.BlockDB.Cache.Enabled = lvl.UseBlockDB; BlockDefinition[] defs = BlockDefinition.Load(false, lvl); diff --git a/MCGalaxy/Player/Player.CPE.cs b/MCGalaxy/Player/Player.CPE.cs index aee4706f8..85e513ea0 100644 --- a/MCGalaxy/Player/Player.CPE.cs +++ b/MCGalaxy/Player/Player.CPE.cs @@ -141,7 +141,7 @@ namespace MCGalaxy { Send(Packet.EnvMapProperty(EnvProp.EdgeBlock, edge)); Send(Packet.EnvMapProperty(EnvProp.EdgeLevel, level.EdgeLevel)); - Send(Packet.EnvMapProperty(EnvProp.SidesLevel, level.SidesLevel)); + Send(Packet.EnvMapProperty(EnvProp.SidesOffset, level.SidesOffset)); Send(Packet.EnvMapProperty(EnvProp.CloudsLevel, level.CloudsHeight)); Send(Packet.EnvMapProperty(EnvProp.MaxFog, level.MaxFogDistance)); @@ -264,7 +264,7 @@ namespace MCGalaxy { SidesBlock = 0, EdgeBlock = 1, EdgeLevel = 2, CloudsLevel = 3, MaxFog = 4, CloudsSpeed = 5, WeatherSpeed = 6, WeatherFade = 7, ExpFog = 8, - SidesLevel = 9, + SidesOffset = 9, } public enum EntityProp : byte {