aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-08-13 23:54:50 +0100
committerJustin Clark-Casey (justincc)2013-08-13 23:54:50 +0100
commit5933f9448d839b9f6db391dedc493bb5cc951d66 (patch)
tree158049869953786cdf7741e52444380dbce6da89
parentminor: Eliminate one of the duplicate 'have's in the HG message telling the u... (diff)
downloadopensim-SC-5933f9448d839b9f6db391dedc493bb5cc951d66.zip
opensim-SC-5933f9448d839b9f6db391dedc493bb5cc951d66.tar.gz
opensim-SC-5933f9448d839b9f6db391dedc493bb5cc951d66.tar.bz2
opensim-SC-5933f9448d839b9f6db391dedc493bb5cc951d66.tar.xz
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
-rw-r--r--OpenSim/Tools/pCampBot/Bot.cs20
-rw-r--r--OpenSim/Tools/pCampBot/BotManager.cs35
-rw-r--r--OpenSim/Tools/pCampBot/pCampBot.cs35
-rw-r--r--bin/pCampbot.ini.example9
4 files changed, 59 insertions, 40 deletions
diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs
index 9821180..c56d29b 100644
--- a/OpenSim/Tools/pCampBot/Bot.cs
+++ b/OpenSim/Tools/pCampBot/Bot.cs
@@ -64,11 +64,6 @@ namespace pCampBot
64 public BotManager Manager { get; private set; } 64 public BotManager Manager { get; private set; }
65 65
66 /// <summary> 66 /// <summary>
67 /// Bot config, passed from BotManager.
68 /// </summary>
69 private IConfig startupConfig;
70
71 /// <summary>
72 /// Behaviours implemented by this bot. 67 /// Behaviours implemented by this bot.
73 /// </summary> 68 /// </summary>
74 /// <remarks> 69 /// <remarks>
@@ -153,9 +148,6 @@ namespace pCampBot
153 LoginUri = loginUri; 148 LoginUri = loginUri;
154 149
155 Manager = bm; 150 Manager = bm;
156 startupConfig = bm.Config;
157 readconfig();
158
159 Behaviours = behaviours; 151 Behaviours = behaviours;
160 } 152 }
161 153
@@ -177,14 +169,6 @@ namespace pCampBot
177 } 169 }
178 170
179 /// <summary> 171 /// <summary>
180 /// Read the Nini config and initialize
181 /// </summary>
182 public void readconfig()
183 {
184 wear = startupConfig.GetString("wear", "no");
185 }
186
187 /// <summary>
188 /// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes. 172 /// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes.
189 /// </summary> 173 /// </summary>
190 public void shutdown() 174 public void shutdown()
@@ -207,6 +191,7 @@ namespace pCampBot
207 Client.Settings.AVATAR_TRACKING = false; 191 Client.Settings.AVATAR_TRACKING = false;
208 Client.Settings.OBJECT_TRACKING = false; 192 Client.Settings.OBJECT_TRACKING = false;
209 Client.Settings.SEND_AGENT_THROTTLE = true; 193 Client.Settings.SEND_AGENT_THROTTLE = true;
194 Client.Settings.SEND_AGENT_UPDATES = false;
210 Client.Settings.SEND_PINGS = true; 195 Client.Settings.SEND_PINGS = true;
211 Client.Settings.STORE_LAND_PATCHES = false; 196 Client.Settings.STORE_LAND_PATCHES = false;
212 Client.Settings.USE_ASSET_CACHE = false; 197 Client.Settings.USE_ASSET_CACHE = false;
@@ -481,9 +466,6 @@ namespace pCampBot
481 466
482 public void Objects_NewPrim(object sender, PrimEventArgs args) 467 public void Objects_NewPrim(object sender, PrimEventArgs args)
483 { 468 {
484// if (Name.EndsWith("4"))
485// throw new Exception("Aaargh");
486
487 Primitive prim = args.Prim; 469 Primitive prim = args.Prim;
488 470
489 if (prim != null) 471 if (prim != null)
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index 74bd36a..16b02b9 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -63,6 +63,11 @@ namespace pCampBot
63 protected CommandConsole m_console; 63 protected CommandConsole m_console;
64 64
65 /// <summary> 65 /// <summary>
66 /// Controls whether bots start out sending agent updates on connection.
67 /// </summary>
68 public bool BotsInitSendAgentUpdates { get; set; }
69
70 /// <summary>
66 /// Created bots, whether active or inactive. 71 /// Created bots, whether active or inactive.
67 /// </summary> 72 /// </summary>
68 protected List<Bot> m_lBot; 73 protected List<Bot> m_lBot;
@@ -73,11 +78,6 @@ namespace pCampBot
73 public Random Rng { get; private set; } 78 public Random Rng { get; private set; }
74 79
75 /// <summary> 80 /// <summary>
76 /// Overall configuration.
77 /// </summary>
78 public IConfig Config { get; private set; }
79
80 /// <summary>
81 /// Track the assets we have and have not received so we don't endlessly repeat requests. 81 /// Track the assets we have and have not received so we don't endlessly repeat requests.
82 /// </summary> 82 /// </summary>
83 public Dictionary<UUID, bool> AssetsReceived { get; private set; } 83 public Dictionary<UUID, bool> AssetsReceived { get; private set; }
@@ -92,6 +92,8 @@ namespace pCampBot
92 /// </summary> 92 /// </summary>
93 public BotManager() 93 public BotManager()
94 { 94 {
95 BotsInitSendAgentUpdates = true;
96
95 LoginDelay = DefaultLoginDelay; 97 LoginDelay = DefaultLoginDelay;
96 98
97 Rng = new Random(Environment.TickCount); 99 Rng = new Random(Environment.TickCount);
@@ -148,18 +150,17 @@ namespace pCampBot
148 /// </summary> 150 /// </summary>
149 /// <param name="botcount">How many bots to start up</param> 151 /// <param name="botcount">How many bots to start up</param>
150 /// <param name="cs">The configuration for the bots to use</param> 152 /// <param name="cs">The configuration for the bots to use</param>
151 public void dobotStartup(int botcount, IConfig cs) 153 public void dobotStartup(int botcount, IConfig startupConfig)
152 { 154 {
153 Config = cs; 155 string firstName = startupConfig.GetString("firstname");
154 156 string lastNameStem = startupConfig.GetString("lastname");
155 string firstName = cs.GetString("firstname"); 157 string password = startupConfig.GetString("password");
156 string lastNameStem = cs.GetString("lastname"); 158 string loginUri = startupConfig.GetString("loginuri");
157 string password = cs.GetString("password"); 159 string wearSetting = startupConfig.GetString("wear", "no");
158 string loginUri = cs.GetString("loginuri");
159 160
160 HashSet<string> behaviourSwitches = new HashSet<string>(); 161 HashSet<string> behaviourSwitches = new HashSet<string>();
161 Array.ForEach<string>( 162 Array.ForEach<string>(
162 cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b)); 163 startupConfig.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
163 164
164 MainConsole.Instance.OutputFormat( 165 MainConsole.Instance.OutputFormat(
165 "[BOT MANAGER]: Starting {0} bots connecting to {1}, named {2} {3}_<n>", 166 "[BOT MANAGER]: Starting {0} bots connecting to {1}, named {2} {3}_<n>",
@@ -169,6 +170,7 @@ namespace pCampBot
169 lastNameStem); 170 lastNameStem);
170 171
171 MainConsole.Instance.OutputFormat("[BOT MANAGER]: Delay between logins is {0}ms", LoginDelay); 172 MainConsole.Instance.OutputFormat("[BOT MANAGER]: Delay between logins is {0}ms", LoginDelay);
173 MainConsole.Instance.OutputFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", BotsInitSendAgentUpdates);
172 174
173 for (int i = 0; i < botcount; i++) 175 for (int i = 0; i < botcount; i++)
174 { 176 {
@@ -193,7 +195,7 @@ namespace pCampBot
193 if (behaviourSwitches.Contains("t")) 195 if (behaviourSwitches.Contains("t"))
194 behaviours.Add(new TeleportBehaviour()); 196 behaviours.Add(new TeleportBehaviour());
195 197
196 StartBot(this, behaviours, firstName, lastName, password, loginUri); 198 StartBot(this, behaviours, firstName, lastName, password, loginUri, wearSetting);
197 } 199 }
198 } 200 }
199 201
@@ -226,15 +228,18 @@ namespace pCampBot
226 /// <param name="lastName">Last name</param> 228 /// <param name="lastName">Last name</param>
227 /// <param name="password">Password</param> 229 /// <param name="password">Password</param>
228 /// <param name="loginUri">Login URI</param> 230 /// <param name="loginUri">Login URI</param>
231 /// <param name="wearSetting"></param>
229 public void StartBot( 232 public void StartBot(
230 BotManager bm, List<IBehaviour> behaviours, 233 BotManager bm, List<IBehaviour> behaviours,
231 string firstName, string lastName, string password, string loginUri) 234 string firstName, string lastName, string password, string loginUri, string wearSetting)
232 { 235 {
233 MainConsole.Instance.OutputFormat( 236 MainConsole.Instance.OutputFormat(
234 "[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}", 237 "[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}",
235 firstName, lastName, string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray())); 238 firstName, lastName, string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray()));
236 239
237 Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri); 240 Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);
241 pb.wear = wearSetting;
242 pb.Client.Settings.SEND_AGENT_UPDATES = BotsInitSendAgentUpdates;
238 243
239 pb.OnConnected += handlebotEvent; 244 pb.OnConnected += handlebotEvent;
240 pb.OnDisconnected += handlebotEvent; 245 pb.OnDisconnected += handlebotEvent;
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs
index 2707a49..e43037d 100644
--- a/OpenSim/Tools/pCampBot/pCampBot.cs
+++ b/OpenSim/Tools/pCampBot/pCampBot.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO;
29using System.Reflection; 30using System.Reflection;
30using System.Threading; 31using System.Threading;
31using log4net; 32using log4net;
@@ -50,28 +51,50 @@ namespace pCampBot
50 { 51 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 53
54 public const string ConfigFileName = "pCampbot.ini";
55
53 [STAThread] 56 [STAThread]
54 public static void Main(string[] args) 57 public static void Main(string[] args)
55 { 58 {
56 XmlConfigurator.Configure(); 59 XmlConfigurator.Configure();
57 60
58 IConfig config = ParseConfig(args); 61 IConfig commandLineConfig = ParseConfig(args);
59 if (config.Get("help") != null || config.Get("loginuri") == null) 62 if (commandLineConfig.Get("help") != null || commandLineConfig.Get("loginuri") == null)
60 { 63 {
61 Help(); 64 Help();
62 } 65 }
63 else if (config.Get("firstname") == null || config.Get("lastname") == null || config.Get("password") == null) 66 else if (
67 commandLineConfig.Get("firstname") == null
68 || commandLineConfig.Get("lastname") == null
69 || commandLineConfig.Get("password") == null)
64 { 70 {
65 Console.WriteLine("ERROR: You must supply a firstname, lastname and password for the bots."); 71 Console.WriteLine("ERROR: You must supply a firstname, lastname and password for the bots.");
66 } 72 }
67 else 73 else
68 { 74 {
69 int botcount = config.GetInt("botcount", 1);
70
71 BotManager bm = new BotManager(); 75 BotManager bm = new BotManager();
72 76
77 string iniFilePath = Path.GetFullPath(Path.Combine(Util.configDir(), ConfigFileName));
78
79 if (File.Exists(iniFilePath))
80 {
81 m_log.InfoFormat("[PCAMPBOT]: Reading configuration settings from {0}", iniFilePath);
82
83 IConfigSource configSource = new IniConfigSource(iniFilePath);
84
85 IConfig botConfig = configSource.Configs["Bot"];
86
87 if (botConfig != null)
88 {
89 bm.BotsInitSendAgentUpdates
90 = botConfig.GetBoolean("SendAgentUpdates", bm.BotsInitSendAgentUpdates);
91 }
92 }
93
94 int botcount = commandLineConfig.GetInt("botcount", 1);
95
73 //startup specified number of bots. 1 is the default 96 //startup specified number of bots. 1 is the default
74 Thread startBotThread = new Thread(o => bm.dobotStartup(botcount, config)); 97 Thread startBotThread = new Thread(o => bm.dobotStartup(botcount, commandLineConfig));
75 startBotThread.Name = "Initial start bots thread"; 98 startBotThread.Name = "Initial start bots thread";
76 startBotThread.Start(); 99 startBotThread.Start();
77 100
diff --git a/bin/pCampbot.ini.example b/bin/pCampbot.ini.example
new file mode 100644
index 0000000..81cdcf4
--- /dev/null
+++ b/bin/pCampbot.ini.example
@@ -0,0 +1,9 @@
1; This is the example config file for pCampbot
2; To use it, copy this file to pCampbot.ini and change settings if required
3
4[Bot]
5 ; Control whether bots should regularly send agent updates
6 ; Not sending agent updates will reduce CPU requirements for pCampbot but greatly
7 ; reduce the realism compared to viewers which are constantly sending AgentUpdates UDP packets
8 ; Defaults to true.
9 SendAgentUpdates = true