Allow "show bots" pCampbot console command to quickly report status by not locking entire bot list for almost 100% of connection time.
parent
d6890d78ad
commit
e57e9e95d4
|
@ -333,11 +333,21 @@ namespace pCampBot
|
||||||
m_log.DebugFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", InitBotSendAgentUpdates);
|
m_log.DebugFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", InitBotSendAgentUpdates);
|
||||||
m_log.DebugFormat("[BOT MANAGER]: InitBotRequestObjectTextures is {0}", InitBotRequestObjectTextures);
|
m_log.DebugFormat("[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)
|
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)
|
if (DisconnectingBots)
|
||||||
{
|
{
|
||||||
|
@ -346,19 +356,11 @@ namespace pCampBot
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_bots[i].ConnectionState == ConnectionState.Disconnected)
|
bot.Connect();
|
||||||
{
|
|
||||||
m_bots[i].Connect();
|
|
||||||
connectedBots++;
|
|
||||||
|
|
||||||
if (connectedBots >= botCount)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Stagger logins
|
// Stagger logins
|
||||||
Thread.Sleep(LoginDelay);
|
Thread.Sleep(LoginDelay);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ConnectingBots = false;
|
ConnectingBots = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue