Use IsConnected status to determine whether all pCampBots have disconnected, rather than maintaining a separate count
Checking IsConnected is more reliable.remove-scene-viewer
parent
674b521fdd
commit
bbab7b6b4d
|
@ -222,7 +222,7 @@ namespace pCampBot
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainConsole.Instance.OutputFormat(
|
m_log.ErrorFormat(
|
||||||
"{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage);
|
"{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage);
|
||||||
|
|
||||||
if (OnDisconnected != null)
|
if (OnDisconnected != null)
|
||||||
|
@ -266,12 +266,12 @@ namespace pCampBot
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output(String.Format("Failed to decode {0} asset {1}", asset.AssetType, asset.AssetID));
|
m_log.WarnFormat("Failed to decode {0} asset {1}", asset.AssetType, asset.AssetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output(String.Format("Exception: {0}",e.ToString()));
|
m_log.ErrorFormat("Exception: {0}{1}", e.Message, e.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ namespace pCampBot
|
||||||
if (wear == "yes")
|
if (wear == "yes")
|
||||||
{
|
{
|
||||||
//TODO: Implement random outfit picking
|
//TODO: Implement random outfit picking
|
||||||
MainConsole.Instance.Output("Picks a random outfit. Not yet implemented.");
|
m_log.DebugFormat("Picks a random outfit. Not yet implemented.");
|
||||||
}
|
}
|
||||||
else if (wear != "save")
|
else if (wear != "save")
|
||||||
saveDir = "MyAppearance/" + wear;
|
saveDir = "MyAppearance/" + wear;
|
||||||
|
@ -334,7 +334,9 @@ namespace pCampBot
|
||||||
listwearables.Add(item);
|
listwearables.Add(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
MainConsole.Instance.Output(String.Format("Failed to create item {0}",item.Name));
|
{
|
||||||
|
m_log.WarnFormat("Failed to create item {0}", item.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -356,7 +358,9 @@ namespace pCampBot
|
||||||
listwearables.Add(item);
|
listwearables.Add(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
MainConsole.Instance.Output(String.Format("Failed to create item {0}",item.Name));
|
{
|
||||||
|
m_log.WarnFormat("Failed to create item {0}", item.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -364,10 +368,12 @@ namespace pCampBot
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
if (listwearables == null || listwearables.Count == 0)
|
if (listwearables == null || listwearables.Count == 0)
|
||||||
MainConsole.Instance.Output("Nothing to send on this folder!");
|
{
|
||||||
|
m_log.DebugFormat("Nothing to send on this folder!");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output(String.Format("Sending {0} wearables...",listwearables.Count));
|
m_log.DebugFormat("Sending {0} wearables...", listwearables.Count);
|
||||||
Client.Appearance.WearOutfit(listwearables, false);
|
Client.Appearance.WearOutfit(listwearables, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ namespace pCampBot
|
||||||
protected CommandConsole m_console;
|
protected CommandConsole m_console;
|
||||||
protected List<Bot> m_lBot;
|
protected List<Bot> m_lBot;
|
||||||
protected Random somthing = new Random(Environment.TickCount);
|
protected Random somthing = new Random(Environment.TickCount);
|
||||||
protected int numbots = 0;
|
|
||||||
public IConfig Config { get; private set; }
|
public IConfig Config { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -200,18 +199,19 @@ namespace pCampBot
|
||||||
{
|
{
|
||||||
case EventType.CONNECTED:
|
case EventType.CONNECTED:
|
||||||
m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected");
|
m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected");
|
||||||
numbots++;
|
|
||||||
// m_log.InfoFormat("NUMBOTS {0}", numbots);
|
|
||||||
break;
|
break;
|
||||||
case EventType.DISCONNECTED:
|
case EventType.DISCONNECTED:
|
||||||
m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected");
|
m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected");
|
||||||
numbots--;
|
|
||||||
// m_log.InfoFormat("NUMBOTS {0}", numbots);
|
lock (m_lBot)
|
||||||
if (numbots <= 0)
|
{
|
||||||
|
if (m_lBot.TrueForAll(b => !b.IsConnected))
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shutting down all bots
|
/// Shutting down all bots
|
||||||
|
|
Loading…
Reference in New Issue