From d1f55f70d94157f3fbc9286a0ea1d784eed77f38 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 16 Jan 2021 23:28:44 +1100 Subject: [PATCH] Remember current speed for bots when saved to disc (Thanks Scav) --- MCGalaxy/Bots/BotsFile.cs | 5 ++++- MCGalaxy/Config/JSON.cs | 14 ++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/MCGalaxy/Bots/BotsFile.cs b/MCGalaxy/Bots/BotsFile.cs index 8f389cd64..58838a59b 100644 --- a/MCGalaxy/Bots/BotsFile.cs +++ b/MCGalaxy/Bots/BotsFile.cs @@ -132,6 +132,7 @@ public sealed class BotProperties { [ConfigBool] public bool Hunt; [ConfigInt] public int CurInstruction; [ConfigInt] public int CurJump; + [ConfigInt] public int CurSpeed; [ConfigInt] public int X; [ConfigInt] public int Y; @@ -152,7 +153,7 @@ public void FromBot(PlayerBot bot) { Model = bot.Model; Color = bot.color; Kill = bot.kill; Hunt = bot.hunt; DisplayName = bot.DisplayName; - CurInstruction = bot.cur; CurJump = bot.curJump; + CurInstruction = bot.cur; CurJump = bot.curJump; CurSpeed = bot.movementSpeed; ClickedOnText = bot.ClickedOnText; DeathMessage = bot.DeathMessage; X = bot.Pos.X; Y = bot.Pos.Y; Z = bot.Pos.Z; @@ -174,6 +175,8 @@ public void ApplyTo(PlayerBot bot) { bot.DisplayName = DisplayName; bot.cur = CurInstruction; bot.curJump = CurJump; + // NOTE: This field wasn't in old json + if (CurSpeed != 0) bot.movementSpeed = CurSpeed; bot.ClickedOnText = ClickedOnText; bot.DeathMessage = DeathMessage; bot.ScaleX = ScaleX; bot.ScaleY = ScaleY; bot.ScaleZ = ScaleZ; } diff --git a/MCGalaxy/Config/JSON.cs b/MCGalaxy/Config/JSON.cs index 79c211a92..88ee03a12 100644 --- a/MCGalaxy/Config/JSON.cs +++ b/MCGalaxy/Config/JSON.cs @@ -20,15 +20,17 @@ public void Deserialise(ConfigElement[] elems, object instance) { } } + public sealed class JsonContext { + public string Val; public bool Success; + + internal int Idx; + internal char Cur { get { return Val[Idx]; } } + internal StringBuilder strBuffer = new StringBuilder(96); + } + public static class Json { const int T_NONE = 0, T_NUM = 1, T_TRUE = 2, T_FALSE = 3, T_NULL = 4; - sealed class JsonContext { - public string Val; public int Idx; public bool Success; - public char Cur { get { return Val[Idx]; } } - internal StringBuilder strBuffer = new StringBuilder(96); - } - static bool IsWhitespace(char c) { return c == '\r' || c == '\n' || c == '\t' || c == ' '; }