From de455d17a8768536de00a50f057d4fbbabc80a07 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 6 Feb 2017 11:50:53 +1100 Subject: [PATCH] add expfog to /env --- GUI/Program.cs | 13 ------------- MCGalaxy/Commands/CPE/CmdEnvironment.cs | 5 ++++- MCGalaxy/Commands/Chat/MessageCmd.cs | 2 +- MCGalaxy/Levels/IO/Importers/LvlImporter.cs | 4 ++-- MCGalaxy/Levels/Level.Fields.cs | 3 +++ MCGalaxy/Levels/LevelEnv.cs | 19 +++++++++++++++++++ MCGalaxy/Player/Player.CPE.cs | 3 ++- 7 files changed, 31 insertions(+), 18 deletions(-) diff --git a/GUI/Program.cs b/GUI/Program.cs index 811bcfc6f..c10d7405e 100644 --- a/GUI/Program.cs +++ b/GUI/Program.cs @@ -55,8 +55,6 @@ namespace MCGalaxy.Gui { } DateTime startTime = DateTime.UtcNow; - CheckDuplicateProcesses(); - Logger.Init(); AppDomain.CurrentDomain.UnhandledException += GlobalExHandler; Application.ThreadException += ThreadExHandler; @@ -160,17 +158,6 @@ namespace MCGalaxy.Gui { if (Server.restartOnError) App.ExitProgram(true); } - - static void CheckDuplicateProcesses() { - Process[] duplicates = Process.GetProcessesByName("MCGalaxy"); - if (duplicates.Length == 1) return; - - Process proc = Process.GetCurrentProcess(); - foreach (Process pr in duplicates) { - if (pr.MainModule.BaseAddress == proc.MainModule.BaseAddress) - if (pr.Id != proc.Id) pr.Kill(); - } - } } } diff --git a/MCGalaxy/Commands/CPE/CmdEnvironment.cs b/MCGalaxy/Commands/CPE/CmdEnvironment.cs index 571c51874..66d168f0f 100644 --- a/MCGalaxy/Commands/CPE/CmdEnvironment.cs +++ b/MCGalaxy/Commands/CPE/CmdEnvironment.cs @@ -109,6 +109,9 @@ namespace MCGalaxy.Commands { case "bedrock": LevelEnv.SetBlock(p, value, EnvProp.SidesBlock, "sides block", Block.blackrock, ref lvl.EdgeBlock); break; + case "expfog": + LevelEnv.SetBool(p, value, EnvProp.ExpFog, + "exp fog", false, ref lvl.ExpFog); break; default: return false; } @@ -201,7 +204,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"); + Player.Message(p, "%H cloudspeed, weatherspeed, weatherfade, expfog"); 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/Chat/MessageCmd.cs b/MCGalaxy/Commands/Chat/MessageCmd.cs index 1f0ed7527..26fb4ba8e 100644 --- a/MCGalaxy/Commands/Chat/MessageCmd.cs +++ b/MCGalaxy/Commands/Chat/MessageCmd.cs @@ -58,7 +58,7 @@ namespace MCGalaxy.Commands { Player.Message(p, "Cannot use %T/{0} %Swhile muted.", cmd); return false; } if (Server.chatmod && !p.voice) { - Player.Message(p, "Cannot use %T/{0} %Swhile chat moderation is on.", cmd); return false; + Player.Message(p, "Cannot use %T/{0} %Swhile chat moderation is on without %T/voice%S.", cmd); return false; } return true; } diff --git a/MCGalaxy/Levels/IO/Importers/LvlImporter.cs b/MCGalaxy/Levels/IO/Importers/LvlImporter.cs index 9273da96c..a26cce14c 100644 --- a/MCGalaxy/Levels/IO/Importers/LvlImporter.cs +++ b/MCGalaxy/Levels/IO/Importers/LvlImporter.cs @@ -49,7 +49,7 @@ namespace MCGalaxy.Levels.IO { lvl.roty = header[offset + 11]; gs.Read(lvl.blocks, 0, lvl.blocks.Length); - ReadBlockDefsSection(lvl, gs); + ReadCustomBlocksSection(lvl, gs); if (!metadata) return lvl; ReadPhysicsSection(lvl, gs); @@ -76,7 +76,7 @@ namespace MCGalaxy.Levels.IO { return dims; } - static void ReadBlockDefsSection(Level lvl, Stream gs) { + static void ReadCustomBlocksSection(Level lvl, Stream gs) { if (gs.ReadByte() != 0xBD) return; int index = 0; diff --git a/MCGalaxy/Levels/Level.Fields.cs b/MCGalaxy/Levels/Level.Fields.cs index e05ad26f4..0738f2979 100644 --- a/MCGalaxy/Levels/Level.Fields.cs +++ b/MCGalaxy/Levels/Level.Fields.cs @@ -144,6 +144,9 @@ namespace MCGalaxy { /// The block which will be displayed on the edge of the map. [ConfigInt("EdgeBlock", "Env", null, Block.blackrock, 0, 255)] public int EdgeBlock = Block.blackrock; + /// Whether exponential fog mode is used client-side. + [ConfigBool("ExpFog", "Env", null, false)] + public bool ExpFog = false; // Permission settings diff --git a/MCGalaxy/Levels/LevelEnv.cs b/MCGalaxy/Levels/LevelEnv.cs index 291c4674d..ed43ff2cd 100644 --- a/MCGalaxy/Levels/LevelEnv.cs +++ b/MCGalaxy/Levels/LevelEnv.cs @@ -93,6 +93,25 @@ namespace MCGalaxy { UpdateEnvColor(p, envType, value); } + public static void SetBool(Player p, string value, EnvProp prop, + string variable, bool defValue, ref bool target) { + if (IsResetString(value)) { + Player.Message(p, "Reset {0} for {1} %Sto normal", variable, p.level.ColoredName); + target = defValue; + } else if (value.CaselessEq("yes") || value.CaselessEq("on")) { + Player.Message(p, "Set {0} for {1} %Sto &aON", variable, p.level.ColoredName); + target = true; + } else if (value.CaselessEq("no") || value.CaselessEq("off")) { + Player.Message(p, "Set {0} for {1} %Sto &cOFF", variable, p.level.ColoredName); + target = false; + } else { + Player.Message(p, "Env: \"{0}\" is not a valid boolean.", value); + return; + } + SendCurrentMapAppearance(p.level, prop, target ? 1 : 0); + } + + static bool CheckBlock(Player p, string value, string variable, ref int modify) { byte extBlock = 0; byte block = (byte)DrawCmd.GetBlock(p, value, out extBlock); diff --git a/MCGalaxy/Player/Player.CPE.cs b/MCGalaxy/Player/Player.CPE.cs index 28488fe82..01192fedb 100644 --- a/MCGalaxy/Player/Player.CPE.cs +++ b/MCGalaxy/Player/Player.CPE.cs @@ -179,6 +179,7 @@ namespace MCGalaxy { Send(Packet.EnvMapProperty(EnvProp.MaxFog, level.MaxFogDistance)); Send(Packet.EnvMapProperty(EnvProp.CloudsSpeed, level.CloudsSpeed)); Send(Packet.EnvMapProperty(EnvProp.WeatherSpeed, level.WeatherSpeed)); + Send(Packet.EnvMapProperty(EnvProp.ExpFog, level.ExpFog ? 1 : 0)); } else if (HasCpeExt(CpeExt.EnvMapAppearance, 2)) { string url = GetTextureUrl(); // reset all other textures back to client default. @@ -293,6 +294,6 @@ namespace MCGalaxy { public enum EnvProp : byte { SidesBlock = 0, EdgeBlock = 1, EdgeLevel = 2, CloudsLevel = 3, MaxFog = 4, CloudsSpeed = 5, - WeatherSpeed = 6, WeatherFade = 7, + WeatherSpeed = 6, WeatherFade = 7, ExpFog = 8, } } \ No newline at end of file