Allow "show bots" pCampbot console command to quickly report status by not locking entire bot list for almost 100% of connection time.

0.8-extended
Justin Clark-Casey (justincc) 2014-08-05 01:06:22 +01:00 committed by Justin Clark-Casey
parent 588a3b91c5
commit 9fe282f902
1 changed files with 22 additions and 20 deletions

View File

@ -333,11 +333,21 @@ namespace pCampBot
MainConsole.Instance.OutputFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", InitBotSendAgentUpdates);
MainConsole.Instance.OutputFormat("[BOT MANAGER]: InitBotRequestObjectTextures is {0}", InitBotRequestObjectTextures);
int connectedBots = 0;
List<Bot> botsToConnect = new List<Bot>();
for (int i = 0; i < m_bots.Count; i++)
{
lock (m_bots)
{
foreach (Bot bot in m_bots)
{
if (bot.ConnectionState == ConnectionState.Disconnected)
botsToConnect.Add(bot);
if (botsToConnect.Count >= botCount)
break;
}
}
foreach (Bot bot in botsToConnect)
{
if (DisconnectingBots)
{
@ -346,19 +356,11 @@ namespace pCampBot
break;
}
if (m_bots[i].ConnectionState == ConnectionState.Disconnected)
{
m_bots[i].Connect();
connectedBots++;
if (connectedBots >= botCount)
break;
bot.Connect();
// Stagger logins
Thread.Sleep(LoginDelay);
}
}
}
ConnectingBots = false;
}