Fixed IndexOutOfRangeException when bot is unloaded on update

This commit is contained in:
initsuj 2016-02-23 11:19:14 -07:00
parent c759c4d63e
commit aed891e3c8

View file

@ -477,18 +477,18 @@ namespace MinecraftClient
public void OnUpdate() public void OnUpdate()
{ {
for (int i = 0; i < bots.Count; i++) foreach (var bot in bots.ToArray())
{ {
try try
{ {
bots[i].Update(); bot.Update();
bots[i].ProcessQueuedText(); bot.ProcessQueuedText();
} }
catch (Exception e) catch (Exception e)
{ {
if (!(e is ThreadAbortException)) if (!(e is ThreadAbortException))
{ {
ConsoleIO.WriteLineFormatted("§8Update: Got error from " + bots[i].ToString() + ": " + e.ToString()); ConsoleIO.WriteLineFormatted("§8Update: Got error from " + bot.ToString() + ": " + e.ToString());
} }
else throw; //ThreadAbortException should not be caught else throw; //ThreadAbortException should not be caught
} }