Add a SendAgentUpdates setting to a new pCampbot.ini.example file which can control whether bots send agent updates

pCampbot.ini.example is used by copying to pCampbot.ini, like other ini files
This commit is contained in:
Justin Clark-Casey (justincc)
2013-08-13 23:54:50 +01:00
parent e311f902ff
commit 5933f9448d
4 changed files with 59 additions and 40 deletions

View File

@@ -26,6 +26,7 @@
*/
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using log4net;
@@ -50,28 +51,50 @@ namespace pCampBot
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public const string ConfigFileName = "pCampbot.ini";
[STAThread]
public static void Main(string[] args)
{
XmlConfigurator.Configure();
IConfig config = ParseConfig(args);
if (config.Get("help") != null || config.Get("loginuri") == null)
IConfig commandLineConfig = ParseConfig(args);
if (commandLineConfig.Get("help") != null || commandLineConfig.Get("loginuri") == null)
{
Help();
}
else if (config.Get("firstname") == null || config.Get("lastname") == null || config.Get("password") == null)
else if (
commandLineConfig.Get("firstname") == null
|| commandLineConfig.Get("lastname") == null
|| commandLineConfig.Get("password") == null)
{
Console.WriteLine("ERROR: You must supply a firstname, lastname and password for the bots.");
}
else
{
int botcount = config.GetInt("botcount", 1);
BotManager bm = new BotManager();
string iniFilePath = Path.GetFullPath(Path.Combine(Util.configDir(), ConfigFileName));
if (File.Exists(iniFilePath))
{
m_log.InfoFormat("[PCAMPBOT]: Reading configuration settings from {0}", iniFilePath);
IConfigSource configSource = new IniConfigSource(iniFilePath);
IConfig botConfig = configSource.Configs["Bot"];
if (botConfig != null)
{
bm.BotsInitSendAgentUpdates
= botConfig.GetBoolean("SendAgentUpdates", bm.BotsInitSendAgentUpdates);
}
}
int botcount = commandLineConfig.GetInt("botcount", 1);
//startup specified number of bots. 1 is the default
Thread startBotThread = new Thread(o => bm.dobotStartup(botcount, config));
Thread startBotThread = new Thread(o => bm.dobotStartup(botcount, commandLineConfig));
startBotThread.Name = "Initial start bots thread";
startBotThread.Start();