Bot commands only match against your levels, /bots output bot display name, update /env sidesheight to be /env sidesoffset instead

This commit is contained in:
UnknownShadow200 2017-04-16 15:28:03 +10:00
parent c01c2ab67a
commit 9aad601f2e
11 changed files with 36 additions and 44 deletions

View File

@ -32,7 +32,7 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) { public override void Use(Player p, string message) {
if (message == "") { Help(p); return; } if (message == "") { Help(p); return; }
string[] args = message.SplitSpaces(); string[] args = message.SplitSpaces();
PlayerBot bot = PlayerBot.FindMatchesPreferLevel(p, args[0]); PlayerBot bot = Matcher.FindBotsInLevel(p, args[0]);
if (bot == null) return; if (bot == null) return;
if (p != null && !bot.level.BuildAccess.CheckDetailed(p)) { if (p != null && !bot.level.BuildAccess.CheckDetailed(p)) {

View File

@ -26,29 +26,32 @@ namespace MCGalaxy.Commands {
public override LevelPermission defaultRank { get { return LevelPermission.Builder; } } public override LevelPermission defaultRank { get { return LevelPermission.Builder; } }
public CmdBots() { } public CmdBots() { }
public override void Use(Player p, string message) { public override void Use(Player p, string message) {
PlayerBot[] bots = PlayerBot.Bots.Items; Level lvl = p.level;
Level lvl = null;
string[] args = message.SplitSpaces(2); 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]); lvl = Matcher.FindLevels(p, args[0]);
if (lvl == null) return; if (lvl == null) return;
} }
PlayerBot[] bots = PlayerBot.Bots.Items;
List<PlayerBot> inScope = new List<PlayerBot>(); List<PlayerBot> inScope = new List<PlayerBot>();
foreach (PlayerBot bot in bots) { foreach (PlayerBot bot in bots) {
if (lvl != null && bot.level != lvl) continue; if (bot.level != lvl) continue;
inScope.Add(bot); 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] : ""; string modifier = args.Length > 1 ? args[1] : "";
Player.Message(p, "Bots in {0}:", lvl.ColoredName);
MultiPageOutput.Output(p, inScope, FormatBot, cmd, "bots", modifier, false); MultiPageOutput.Output(p, inScope, FormatBot, cmd, "bots", modifier, false);
} }
static string FormatBot(PlayerBot bot) { 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 + "]"; if (bot.AIName != "") desc += "[" + bot.AIName + "]";
else if (bot.hunt) desc += "[Hunt]"; else if (bot.hunt) desc += "[Hunt]";
@ -57,8 +60,8 @@ namespace MCGalaxy.Commands {
} }
public override void Help(Player p) { 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 %H- Shows a list of bots on your level, and their AIs and levels");
Player.Message(p, "%T/bots [level] %H- Only shows bots on the given level"); Player.Message(p, "%T/bots [level] %H- Shows bots on the given level");
} }
} }
} }

View File

@ -83,11 +83,11 @@ namespace MCGalaxy.Commands {
case "level": case "level":
LevelEnv.SetShort(p, value, EnvProp.EdgeLevel, LevelEnv.SetShort(p, value, EnvProp.EdgeLevel,
"water level", (short)(lvl.Height / 2), ref lvl.EdgeLevel); break; "water level", (short)(lvl.Height / 2), ref lvl.EdgeLevel); break;
case "bedrocklevel": case "bedrockoffset":
case "sideslevel": case "sidesoffset":
case "sidelevel": case "sideoffset":
LevelEnv.SetShort(p, value, EnvProp.SidesLevel, LevelEnv.SetShort(p, value, EnvProp.SidesOffset,
"bedrock level", (short)(lvl.Height / 2 - 2), ref lvl.SidesLevel); break; "bedrock offset", -2, ref lvl.SidesOffset); break;
case "maxfogdistance": case "maxfogdistance":
case "maxfog": case "maxfog":
case "fogdistance": case "fogdistance":
@ -136,8 +136,8 @@ namespace MCGalaxy.Commands {
LevelEnv.SetShort(p, "normal", EnvProp.EdgeLevel, LevelEnv.SetShort(p, "normal", EnvProp.EdgeLevel,
"water level", (short)(lvl.Height / 2), ref lvl.EdgeLevel); "water level", (short)(lvl.Height / 2), ref lvl.EdgeLevel);
LevelEnv.SetShort(p, "normal", EnvProp.EdgeLevel, LevelEnv.SetShort(p, "normal", EnvProp.SidesOffset,
"bedrock level", (short)(lvl.Height / 2 - 2), ref lvl.SidesLevel); "bedrock offset", -2, ref lvl.SidesOffset);
LevelEnv.SetShort(p, "normal", EnvProp.CloudsLevel, LevelEnv.SetShort(p, "normal", EnvProp.CloudsLevel,
"clouds height", (short)(lvl.Height + 2), ref lvl.CloudsHeight); "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, "%T/env [variable] [value]");
Player.Message(p, "%HVariables: fog, cloud, sky, sun, shadow, weather, level"); Player.Message(p, "%HVariables: fog, cloud, sky, sun, shadow, weather, level");
Player.Message(p, "%H horizon, border, preset, maxfog, cloudsheight"); 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, "%HUsing 'normal' as a value will reset the variable");
Player.Message(p, "%T/env normal %H- resets all variables"); Player.Message(p, "%T/env normal %H- resets all variables");
} }

View File

@ -28,7 +28,7 @@ namespace MCGalaxy.Commands {
Player who = null; Player who = null;
PlayerBot bot = 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]); else who = PlayerInfo.FindMatches(p, args[0]);
if (bot == null && who == null) return; if (bot == null && who == null) return;

View File

@ -199,8 +199,8 @@ namespace MCGalaxy.Commands {
Player.Message(p, format, Color(data.Fog), Color(data.Sky), Color(data.Clouds), Player.Message(p, format, Color(data.Fog), Color(data.Sky), Color(data.Clouds),
Color(data.Light), Color(data.Shadow)); 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}", 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.SidesLevel, data.CloudsHeight, data.MaxFog); 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, "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}%", Player.Message(p, "Clouds speed: &b{0}%%S, Weather speed: &b{1}%",
(data.CloudsSpeed / 256f).ToString("F2"), (data.CloudsSpeed / 256f).ToString("F2"),
@ -220,7 +220,7 @@ namespace MCGalaxy.Commands {
// Env data // Env data
public string TerrainUrl, TextureUrl; public string TerrainUrl, TextureUrl;
public string Fog, Sky, Clouds, Light, Shadow; 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 int CloudsSpeed = 256, WeatherSpeed = 256, WeatherFade = 128;
public byte EdgeBlock = Block.blackrock, HorizonBlock = Block.water; public byte EdgeBlock = Block.blackrock, HorizonBlock = Block.water;
public bool ExpFog; public bool ExpFog;
@ -253,7 +253,7 @@ namespace MCGalaxy.Commands {
Fog = lvl.FogColor; Sky = lvl.SkyColor; Clouds = lvl.CloudColor; Fog = lvl.FogColor; Sky = lvl.SkyColor; Clouds = lvl.CloudColor;
Light = lvl.LightColor; Shadow = lvl.ShadowColor; 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; MaxFog = lvl.MaxFogDistance; ExpFog = lvl.ExpFog;
CloudsSpeed = lvl.CloudsSpeed; WeatherSpeed = lvl.WeatherSpeed; CloudsSpeed = lvl.CloudsSpeed; WeatherSpeed = lvl.WeatherSpeed;
EdgeBlock = (byte)lvl.EdgeBlock; HorizonBlock = (byte)lvl.HorizonBlock; EdgeBlock = (byte)lvl.EdgeBlock; HorizonBlock = (byte)lvl.HorizonBlock;
@ -275,16 +275,14 @@ namespace MCGalaxy.Commands {
Vec3U16 dims = IMapImporter.Formats[0].ReadDimensions(path); Vec3U16 dims = IMapImporter.Formats[0].ReadDimensions(path);
Width = dims.X; Height = dims.Y; Length = dims.Z; Width = dims.X; Height = dims.Y; Length = dims.Z;
EdgeLevel = Height / 2; EdgeLevel = Height / 2; CloudsHeight = Height + 2;
SidesLevel = int.MinValue;
CloudsHeight = Height + 2;
BlockDBEntries = BlockDBFile.CountEntries(name); BlockDBEntries = BlockDBFile.CountEntries(name);
path = LevelInfo.FindPropertiesFile(name); path = LevelInfo.FindPropertiesFile(name);
if (path != null) if (path != null)
PropertiesFile.Read(path, ParseProperty, '='); PropertiesFile.Read(path, ParseProperty, '=');
if (Authors == null) Authors = ""; if (Authors == null) Authors = "";
if (SidesLevel == int.MinValue) SidesLevel = EdgeLevel - 2; if (SidesOffset == int.MinValue) SidesOffset = EdgeLevel - 2;
} }
void ParseProperty(string key, string value) { void ParseProperty(string key, string value) {
@ -317,7 +315,7 @@ namespace MCGalaxy.Commands {
case "edgeblock": EdgeBlock = byte.Parse(value); break; case "edgeblock": EdgeBlock = byte.Parse(value); break;
case "edgelevel": EdgeLevel = short.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 "horizonblock": HorizonBlock = byte.Parse(value); break;
case "cloudsheight": CloudsHeight = short.Parse(value); break; case "cloudsheight": CloudsHeight = short.Parse(value); break;
case "maxfog": MaxFog = short.Parse(value); break; case "maxfog": MaxFog = short.Parse(value); break;

View File

@ -39,10 +39,8 @@ namespace MCGalaxy.Generator {
Level lvl = args.Level; Level lvl = args.Level;
int grassHeight = lvl.Height / 2; int grassHeight = lvl.Height / 2;
if (args.UseSeed && args.Seed >= 0 && args.Seed < lvl.Height) if (args.UseSeed && args.Seed >= 0 && args.Seed < lvl.Height)
grassHeight = args.Seed; grassHeight = args.Seed;
lvl.EdgeLevel = grassHeight + 1; lvl.EdgeLevel = grassHeight + 1;
lvl.SidesLevel = lvl.EdgeLevel - 2;
fixed (byte* ptr = lvl.blocks) { fixed (byte* ptr = lvl.blocks) {
if (grassHeight > 0) if (grassHeight > 0)

View File

@ -36,7 +36,6 @@ namespace MCGalaxy.Levels.IO {
Vec3U16 dims = ReadHeader(reader); Vec3U16 dims = ReadHeader(reader);
Level lvl = new Level(name, dims.X, dims.Y, dims.Z); Level lvl = new Level(name, dims.X, dims.Y, dims.Z);
lvl.EdgeLevel = 0; lvl.EdgeLevel = 0;
lvl.SidesLevel = lvl.EdgeLevel - 2;
byte[] blocks = lvl.blocks; byte[] blocks = lvl.blocks;
int size = dims.X * dims.Y * dims.Z, i = 0; int size = dims.X * dims.Y * dims.Z, i = 0;

View File

@ -84,8 +84,7 @@ namespace MCGalaxy.Levels.IO {
lvl.EdgeLevel = comp["SideLevel"].ShortValue; lvl.EdgeLevel = comp["SideLevel"].ShortValue;
if (lvl.EdgeLevel == -1) if (lvl.EdgeLevel == -1)
lvl.EdgeLevel = (short)(lvl.Height / 2); lvl.EdgeLevel = (short)(lvl.Height / 2);
lvl.SidesLevel = lvl.EdgeLevel - 2;
if (!comp.Contains("TextureURL")) return; if (!comp.Contains("TextureURL")) return;
string url = comp["TextureURL"].StringValue; string url = comp["TextureURL"].StringValue;

View File

@ -127,9 +127,9 @@ namespace MCGalaxy {
/// <summary> Elevation of the "ocean" that surrounds maps. Default is map height / 2. </summary> /// <summary> Elevation of the "ocean" that surrounds maps. Default is map height / 2. </summary>
[ConfigInt("EdgeLevel", "Env", null, -1, short.MinValue, short.MaxValue)] [ConfigInt("EdgeLevel", "Env", null, -1, short.MinValue, short.MaxValue)]
public int EdgeLevel; public int EdgeLevel;
/// <summary> Elevation of the "bedrock" that surrounds map sides. Default is (map height / 2) - 2. </summary> /// <summary> Offset of the "bedrock" that surrounds map sides from edge level. Default is -2. </summary>
[ConfigInt("SidesLevel", "Env", null, -1, short.MinValue, short.MaxValue)] [ConfigInt("SidesOffset", "Env", null, -2, short.MinValue, short.MaxValue)]
public int SidesLevel; public int SidesOffset = -2;
/// <summary> Elevation of the clouds. Default is map height + 2. </summary> /// <summary> Elevation of the clouds. Default is map height + 2. </summary>
[ConfigInt("CloudsHeight", "Env", null, -1, short.MinValue, short.MaxValue)] [ConfigInt("CloudsHeight", "Env", null, -1, short.MinValue, short.MaxValue)]
public int CloudsHeight; public int CloudsHeight;

View File

@ -77,7 +77,6 @@ namespace MCGalaxy {
name = n; MapName = n.ToLower(); name = n; MapName = n.ToLower();
BlockDB = new BlockDB(this); BlockDB = new BlockDB(this);
EdgeLevel = (short)(y / 2); EdgeLevel = (short)(y / 2);
SidesLevel = (short)(y / 2 - 2);
CloudsHeight = (short)(y + 2); CloudsHeight = (short)(y + 2);
blocks = new byte[Width * Height * Length]; blocks = new byte[Width * Height * Length];
@ -382,7 +381,6 @@ namespace MCGalaxy {
} }
public static void LoadMetadata(Level lvl) { public static void LoadMetadata(Level lvl) {
lvl.SidesLevel = int.MinValue;
try { try {
string propsPath = LevelInfo.FindPropertiesFile(lvl.MapName); string propsPath = LevelInfo.FindPropertiesFile(lvl.MapName);
if (propsPath != null) { if (propsPath != null) {
@ -396,9 +394,6 @@ namespace MCGalaxy {
} catch (Exception e) { } catch (Exception e) {
Server.ErrorLog(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; lvl.BlockDB.Cache.Enabled = lvl.UseBlockDB;
BlockDefinition[] defs = BlockDefinition.Load(false, lvl); BlockDefinition[] defs = BlockDefinition.Load(false, lvl);

View File

@ -141,7 +141,7 @@ namespace MCGalaxy {
Send(Packet.EnvMapProperty(EnvProp.EdgeBlock, edge)); Send(Packet.EnvMapProperty(EnvProp.EdgeBlock, edge));
Send(Packet.EnvMapProperty(EnvProp.EdgeLevel, level.EdgeLevel)); 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.CloudsLevel, level.CloudsHeight));
Send(Packet.EnvMapProperty(EnvProp.MaxFog, level.MaxFogDistance)); Send(Packet.EnvMapProperty(EnvProp.MaxFog, level.MaxFogDistance));
@ -264,7 +264,7 @@ namespace MCGalaxy {
SidesBlock = 0, EdgeBlock = 1, EdgeLevel = 2, SidesBlock = 0, EdgeBlock = 1, EdgeLevel = 2,
CloudsLevel = 3, MaxFog = 4, CloudsSpeed = 5, CloudsLevel = 3, MaxFog = 4, CloudsSpeed = 5,
WeatherSpeed = 6, WeatherFade = 7, ExpFog = 8, WeatherSpeed = 6, WeatherFade = 7, ExpFog = 8,
SidesLevel = 9, SidesOffset = 9,
} }
public enum EntityProp : byte { public enum EntityProp : byte {