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 files0.7.6-extended
parent
e311f902ff
commit
5933f9448d
|
@ -63,11 +63,6 @@ namespace pCampBot
|
|||
/// </summary>
|
||||
public BotManager Manager { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Bot config, passed from BotManager.
|
||||
/// </summary>
|
||||
private IConfig startupConfig;
|
||||
|
||||
/// <summary>
|
||||
/// Behaviours implemented by this bot.
|
||||
/// </summary>
|
||||
|
@ -153,9 +148,6 @@ namespace pCampBot
|
|||
LoginUri = loginUri;
|
||||
|
||||
Manager = bm;
|
||||
startupConfig = bm.Config;
|
||||
readconfig();
|
||||
|
||||
Behaviours = behaviours;
|
||||
}
|
||||
|
||||
|
@ -176,14 +168,6 @@ namespace pCampBot
|
|||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read the Nini config and initialize
|
||||
/// </summary>
|
||||
public void readconfig()
|
||||
{
|
||||
wear = startupConfig.GetString("wear", "no");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes.
|
||||
/// </summary>
|
||||
|
@ -207,6 +191,7 @@ namespace pCampBot
|
|||
Client.Settings.AVATAR_TRACKING = false;
|
||||
Client.Settings.OBJECT_TRACKING = false;
|
||||
Client.Settings.SEND_AGENT_THROTTLE = true;
|
||||
Client.Settings.SEND_AGENT_UPDATES = false;
|
||||
Client.Settings.SEND_PINGS = true;
|
||||
Client.Settings.STORE_LAND_PATCHES = false;
|
||||
Client.Settings.USE_ASSET_CACHE = false;
|
||||
|
@ -481,9 +466,6 @@ namespace pCampBot
|
|||
|
||||
public void Objects_NewPrim(object sender, PrimEventArgs args)
|
||||
{
|
||||
// if (Name.EndsWith("4"))
|
||||
// throw new Exception("Aaargh");
|
||||
|
||||
Primitive prim = args.Prim;
|
||||
|
||||
if (prim != null)
|
||||
|
|
|
@ -62,6 +62,11 @@ namespace pCampBot
|
|||
/// </summary>
|
||||
protected CommandConsole m_console;
|
||||
|
||||
/// <summary>
|
||||
/// Controls whether bots start out sending agent updates on connection.
|
||||
/// </summary>
|
||||
public bool BotsInitSendAgentUpdates { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Created bots, whether active or inactive.
|
||||
/// </summary>
|
||||
|
@ -72,11 +77,6 @@ namespace pCampBot
|
|||
/// </summary>
|
||||
public Random Rng { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Overall configuration.
|
||||
/// </summary>
|
||||
public IConfig Config { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Track the assets we have and have not received so we don't endlessly repeat requests.
|
||||
/// </summary>
|
||||
|
@ -92,6 +92,8 @@ namespace pCampBot
|
|||
/// </summary>
|
||||
public BotManager()
|
||||
{
|
||||
BotsInitSendAgentUpdates = true;
|
||||
|
||||
LoginDelay = DefaultLoginDelay;
|
||||
|
||||
Rng = new Random(Environment.TickCount);
|
||||
|
@ -148,18 +150,17 @@ namespace pCampBot
|
|||
/// </summary>
|
||||
/// <param name="botcount">How many bots to start up</param>
|
||||
/// <param name="cs">The configuration for the bots to use</param>
|
||||
public void dobotStartup(int botcount, IConfig cs)
|
||||
public void dobotStartup(int botcount, IConfig startupConfig)
|
||||
{
|
||||
Config = cs;
|
||||
|
||||
string firstName = cs.GetString("firstname");
|
||||
string lastNameStem = cs.GetString("lastname");
|
||||
string password = cs.GetString("password");
|
||||
string loginUri = cs.GetString("loginuri");
|
||||
string firstName = startupConfig.GetString("firstname");
|
||||
string lastNameStem = startupConfig.GetString("lastname");
|
||||
string password = startupConfig.GetString("password");
|
||||
string loginUri = startupConfig.GetString("loginuri");
|
||||
string wearSetting = startupConfig.GetString("wear", "no");
|
||||
|
||||
HashSet<string> behaviourSwitches = new HashSet<string>();
|
||||
Array.ForEach<string>(
|
||||
cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
|
||||
startupConfig.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
|
||||
|
||||
MainConsole.Instance.OutputFormat(
|
||||
"[BOT MANAGER]: Starting {0} bots connecting to {1}, named {2} {3}_<n>",
|
||||
|
@ -169,6 +170,7 @@ namespace pCampBot
|
|||
lastNameStem);
|
||||
|
||||
MainConsole.Instance.OutputFormat("[BOT MANAGER]: Delay between logins is {0}ms", LoginDelay);
|
||||
MainConsole.Instance.OutputFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", BotsInitSendAgentUpdates);
|
||||
|
||||
for (int i = 0; i < botcount; i++)
|
||||
{
|
||||
|
@ -193,7 +195,7 @@ namespace pCampBot
|
|||
if (behaviourSwitches.Contains("t"))
|
||||
behaviours.Add(new TeleportBehaviour());
|
||||
|
||||
StartBot(this, behaviours, firstName, lastName, password, loginUri);
|
||||
StartBot(this, behaviours, firstName, lastName, password, loginUri, wearSetting);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,15 +228,18 @@ namespace pCampBot
|
|||
/// <param name="lastName">Last name</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <param name="loginUri">Login URI</param>
|
||||
/// <param name="wearSetting"></param>
|
||||
public void StartBot(
|
||||
BotManager bm, List<IBehaviour> behaviours,
|
||||
string firstName, string lastName, string password, string loginUri)
|
||||
string firstName, string lastName, string password, string loginUri, string wearSetting)
|
||||
{
|
||||
MainConsole.Instance.OutputFormat(
|
||||
"[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}",
|
||||
firstName, lastName, string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray()));
|
||||
|
||||
Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);
|
||||
pb.wear = wearSetting;
|
||||
pb.Client.Settings.SEND_AGENT_UPDATES = BotsInitSendAgentUpdates;
|
||||
|
||||
pb.OnConnected += handlebotEvent;
|
||||
pb.OnDisconnected += handlebotEvent;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
; This is the example config file for pCampbot
|
||||
; To use it, copy this file to pCampbot.ini and change settings if required
|
||||
|
||||
[Bot]
|
||||
; Control whether bots should regularly send agent updates
|
||||
; Not sending agent updates will reduce CPU requirements for pCampbot but greatly
|
||||
; reduce the realism compared to viewers which are constantly sending AgentUpdates UDP packets
|
||||
; Defaults to true.
|
||||
SendAgentUpdates = true
|
Loading…
Reference in New Issue