Skip to content

Commit

Permalink
Remember current speed for bots when saved to disc (Thanks Scav)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Jan 16, 2021
1 parent 37afa67 commit d1f55f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 4 additions & 1 deletion MCGalaxy/Bots/BotsFile.cs
Expand Up @@ -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;
Expand All @@ -152,7 +153,7 @@ public sealed class BotProperties {
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;
Expand All @@ -174,6 +175,8 @@ public sealed class BotProperties {
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;
}
Expand Down
14 changes: 8 additions & 6 deletions MCGalaxy/Config/JSON.cs
Expand Up @@ -20,15 +20,17 @@ public sealed class JsonObject {
}
}

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 == ' ';
}
Expand Down

0 comments on commit d1f55f7

Please sign in to comment.