diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index d0f6ab7c94..4a7c8b083b 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -70,7 +70,7 @@ namespace OpenSim
///
/// A configuration that gets passed to modules
public OpenSimConfigSource LoadConfigSettings(
- IConfigSource argvSource, out ConfigSettings configSettings,
+ IConfigSource argvSource, EnvConfigSource envConfigSource, out ConfigSettings configSettings,
out NetworkServersInfo networkInfo)
{
m_configSettings = configSettings = new ConfigSettings();
@@ -195,6 +195,24 @@ namespace OpenSim
// Make sure command line options take precedence
m_config.Source.Merge(argvSource);
+
+ IConfig enVars = m_config.Source.Configs["Environment"];
+
+ if( enVars != null )
+ {
+ string[] env_keys = enVars.GetKeys();
+
+ foreach ( string key in env_keys )
+ {
+ envConfigSource.AddEnv(key, string.Empty);
+ }
+
+ envConfigSource.LoadEnv();
+ m_config.Source.Merge(envConfigSource);
+ m_config.Source.ExpandKeyValues();
+ }
+
+
ReadConfigSettings();
return m_config;
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 553786b1f7..0a78df27ce 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -108,6 +108,13 @@ namespace OpenSim
get { return m_clientServers; }
}
+ protected EnvConfigSource m_EnvConfigSource = new EnvConfigSource();
+
+ public EnvConfigSource envConfigSource
+ {
+ get { return m_EnvConfigSource; }
+ }
+
protected List m_clientServers = new List();
public uint HttpServerPort
@@ -142,7 +149,7 @@ namespace OpenSim
protected virtual void LoadConfigSettings(IConfigSource configSource)
{
m_configLoader = new ConfigurationLoader();
- m_config = m_configLoader.LoadConfigSettings(configSource, out m_configSettings, out m_networkServersInfo);
+ m_config = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo);
ReadExtraConfigSettings();
}
diff --git a/OpenSim/Tests/ConfigurationLoaderTest.cs b/OpenSim/Tests/ConfigurationLoaderTest.cs
index c777acc0f1..067264d027 100644
--- a/OpenSim/Tests/ConfigurationLoaderTest.cs
+++ b/OpenSim/Tests/ConfigurationLoaderTest.cs
@@ -109,11 +109,13 @@ namespace OpenSim.Tests
// Prepare call to ConfigurationLoader.LoadConfigSettings()
ConfigurationLoader cl = new ConfigurationLoader();
IConfigSource argvSource = new IniConfigSource();
+ EnvConfigSource envConfigSource = new EnvConfigSource();
argvSource.AddConfig("Startup").Set("inifile", mainIniFile);
ConfigSettings configSettings;
NetworkServersInfo networkInfo;
- OpenSimConfigSource source = cl.LoadConfigSettings(argvSource, out configSettings, out networkInfo);
+ OpenSimConfigSource source = cl.LoadConfigSettings(argvSource, envConfigSource,
+ out configSettings, out networkInfo);
// Remove default config
config = source.Source.Configs["Startup"];
diff --git a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs
index 7084ab41de..0a6d5d2b97 100644
--- a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs
+++ b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs
@@ -41,6 +41,8 @@ namespace pCampBot
///
public class GrabbingBehaviour : IBehaviour
{
+ public string Name { get { return "Grabbing"; } }
+
public void Action(Bot bot)
{
Dictionary objects = bot.Objects;
diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs
index 3ce08bf617..f782bb507c 100644
--- a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs
+++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs
@@ -42,6 +42,8 @@ namespace pCampBot
///
public class PhysicsBehaviour : IBehaviour
{
+ public string Name { get { return "Physics"; } }
+
private string[] talkarray;
public PhysicsBehaviour()
diff --git a/OpenSim/Tools/pCampBot/Behaviours/TeleportBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/TeleportBehaviour.cs
new file mode 100644
index 0000000000..fc2ed2c92a
--- /dev/null
+++ b/OpenSim/Tools/pCampBot/Behaviours/TeleportBehaviour.cs
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using log4net;
+using OpenMetaverse;
+using pCampBot.Interfaces;
+
+namespace pCampBot
+{
+ ///
+ /// Teleport to a random region on the grid.
+ ///
+ public class TeleportBehaviour : IBehaviour
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ public string Name { get { return "Teleport"; } }
+
+ public void Action(Bot bot)
+ {
+ Random rng = bot.Manager.Rng;
+ GridRegion[] knownRegions;
+
+ lock (bot.Manager.RegionsKnown)
+ {
+ if (bot.Manager.RegionsKnown.Count == 0)
+ {
+ m_log.DebugFormat(
+ "[TELEPORT BEHAVIOUR]: Ignoring teleport action for {0} since no regions are known yet", bot.Name);
+ return;
+ }
+
+ knownRegions = bot.Manager.RegionsKnown.Values.ToArray();
+ }
+
+ Simulator sourceRegion = bot.Client.Network.CurrentSim;
+ GridRegion destRegion = knownRegions[rng.Next(knownRegions.Length)];
+ Vector3 destPosition = new Vector3(rng.Next(255), rng.Next(255), 50);
+
+ m_log.DebugFormat(
+ "[TELEPORT BEHAVIOUR]: Teleporting {0} from {1} {2} to {3} {4}",
+ bot.Name, sourceRegion.Name, bot.Client.Self.SimPosition, destRegion.Name, destPosition);
+
+ bot.Client.Self.Teleport(destRegion.RegionHandle, destPosition);
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs
index 7f941a497f..7a73e3f13a 100644
--- a/OpenSim/Tools/pCampBot/Bot.cs
+++ b/OpenSim/Tools/pCampBot/Bot.cs
@@ -49,8 +49,15 @@ namespace pCampBot
public delegate void AnEvent(Bot callbot, EventType someevent); // event delegate for bot events
- public BotManager BotManager { get; private set; }
- private IConfig startupConfig; // bot config, passed from BotManager
+ ///
+ /// Bot manager.
+ ///
+ public BotManager Manager { get; private set; }
+
+ ///
+ /// Bot config, passed from BotManager.
+ ///
+ private IConfig startupConfig;
///
/// Behaviours implemented by this bot.
@@ -132,7 +139,7 @@ namespace pCampBot
Password = password;
LoginUri = loginUri;
- BotManager = bm;
+ Manager = bm;
startupConfig = bm.Config;
readconfig();
@@ -218,7 +225,19 @@ namespace pCampBot
{
MakeDefaultAppearance(wear);
}
+
Client.Self.Jump(true);
+
+ // Extract nearby region information.
+ Client.Grid.GridRegion += Manager.Grid_GridRegion;
+ uint xUint, yUint;
+ Utils.LongToUInts(Client.Network.CurrentSim.Handle, out xUint, out yUint);
+ ushort minX, minY, maxX, maxY;
+ minX = (ushort)Math.Min(0, xUint - 5);
+ minY = (ushort)Math.Min(0, yUint - 5);
+ maxX = (ushort)(xUint + 5);
+ maxY = (ushort)(yUint + 5);
+ Client.Grid.RequestMapBlocks(GridLayerType.Terrain, minX, minY, maxX, maxY, false);
}
else
{
@@ -472,13 +491,13 @@ namespace pCampBot
private void GetTexture(UUID textureID)
{
- lock (BotManager.AssetsReceived)
+ lock (Manager.AssetsReceived)
{
// Don't request assets more than once.
- if (BotManager.AssetsReceived.ContainsKey(textureID))
+ if (Manager.AssetsReceived.ContainsKey(textureID))
return;
- BotManager.AssetsReceived[textureID] = false;
+ Manager.AssetsReceived[textureID] = false;
Client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture);
}
}
@@ -490,8 +509,8 @@ namespace pCampBot
public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset)
{
- lock (BotManager.AssetsReceived)
- BotManager.AssetsReceived[asset.AssetID] = true;
+ lock (Manager.AssetsReceived)
+ Manager.AssetsReceived[asset.AssetID] = true;
// if (wear == "save")
// {
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index f5dd5e0847..29cb1ba98c 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Reflection;
using System.Threading;
using OpenMetaverse;
@@ -48,9 +49,24 @@ namespace pCampBot
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ ///
+ /// Command console
+ ///
protected CommandConsole m_console;
+
+ ///
+ /// Created bots, whether active or inactive.
+ ///
protected List m_lBot;
- protected Random somthing = new Random(Environment.TickCount);
+
+ ///
+ /// Random number generator.
+ ///
+ public Random Rng { get; private set; }
+
+ ///
+ /// Overall configuration.
+ ///
public IConfig Config { get; private set; }
///
@@ -58,12 +74,19 @@ namespace pCampBot
///
public Dictionary AssetsReceived { get; private set; }
+ ///
+ /// The regions that we know about.
+ ///
+ public Dictionary RegionsKnown { get; private set; }
+
///
/// Constructor Creates MainConsole.Instance to take commands and provide the place to write data
///
public BotManager()
{
+ Rng = new Random(Environment.TickCount);
AssetsReceived = new Dictionary();
+ RegionsKnown = new Dictionary();
m_console = CreateConsole();
MainConsole.Instance = m_console;
@@ -93,8 +116,13 @@ namespace pCampBot
"Shutdown bots and exit",
HandleShutdown);
- m_console.Commands.AddCommand("bot", false, "show status",
- "show status",
+ m_console.Commands.AddCommand("bot", false, "show regions",
+ "show regions",
+ "Show regions known to bots",
+ HandleShowRegions);
+
+ m_console.Commands.AddCommand("bot", false, "show bots",
+ "show bots",
"Shows the status of all bots",
HandleShowStatus);
@@ -123,19 +151,26 @@ namespace pCampBot
Array.ForEach(
cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
+ List behaviours = new List();
+
+ // Hard-coded for now
+ if (behaviourSwitches.Contains("p"))
+ behaviours.Add(new PhysicsBehaviour());
+
+ if (behaviourSwitches.Contains("g"))
+ behaviours.Add(new GrabbingBehaviour());
+
+ if (behaviourSwitches.Contains("t"))
+ behaviours.Add(new TeleportBehaviour());
+
+ MainConsole.Instance.OutputFormat(
+ "[BOT MANAGER]: Bots configured for behaviours {0}",
+ string.Join(",", behaviours.ConvertAll(b => b.Name).ToArray()));
+
for (int i = 0; i < botcount; i++)
{
string lastName = string.Format("{0}_{1}", lastNameStem, i);
- List behaviours = new List();
-
- // Hard-coded for now
- if (behaviourSwitches.Contains("p"))
- behaviours.Add(new PhysicsBehaviour());
-
- if (behaviourSwitches.Contains("g"))
- behaviours.Add(new GrabbingBehaviour());
-
StartBot(this, behaviours, firstName, lastName, password, loginUri);
}
}
@@ -240,17 +275,33 @@ namespace pCampBot
});
}
+ private void HandleShowRegions(string module, string[] cmd)
+ {
+ string outputFormat = "{0,-30} {1, -20} {2, -5} {3, -5}";
+ MainConsole.Instance.OutputFormat(outputFormat, "Name", "Handle", "X", "Y");
+
+ lock (RegionsKnown)
+ {
+ foreach (GridRegion region in RegionsKnown.Values)
+ {
+ MainConsole.Instance.OutputFormat(
+ outputFormat, region.Name, region.RegionHandle, region.X, region.Y);
+ }
+ }
+ }
+
private void HandleShowStatus(string module, string[] cmd)
{
- string outputFormat = "{0,-30} {1,-14}";
- MainConsole.Instance.OutputFormat(outputFormat, "Name", "Status");
+ string outputFormat = "{0,-30} {1, -30} {2,-14}";
+ MainConsole.Instance.OutputFormat(outputFormat, "Name", "Region", "Status");
lock (m_lBot)
{
foreach (Bot pb in m_lBot)
{
MainConsole.Instance.OutputFormat(
- outputFormat, pb.Name, (pb.IsConnected ? "Connected" : "Disconnected"));
+ outputFormat,
+ pb.Name, pb.Client.Network.CurrentSim.Name, pb.IsConnected ? "Connected" : "Disconnected");
}
}
}
@@ -274,5 +325,24 @@ namespace pCampBot
// if (newbots > 0)
// addbots(newbots);
// }
+
+ internal void Grid_GridRegion(object o, GridRegionEventArgs args)
+ {
+ lock (RegionsKnown)
+ {
+ GridRegion newRegion = args.Region;
+
+ if (RegionsKnown.ContainsKey(newRegion.RegionHandle))
+ {
+ return;
+ }
+ else
+ {
+ m_log.DebugFormat(
+ "[BOT MANAGER]: Adding {0} {1} to known regions", newRegion.Name, newRegion.RegionHandle);
+ RegionsKnown[newRegion.RegionHandle] = newRegion;
+ }
+ }
+ }
}
}
diff --git a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs
index d4ae0f064b..912216f57a 100644
--- a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs
+++ b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs
@@ -31,6 +31,15 @@ namespace pCampBot.Interfaces
{
public interface IBehaviour
{
+ ///
+ /// Name of this behaviour.
+ ///
+ string Name { get; }
+
+ ///
+ /// Action to take when this behaviour is invoked.
+ ///
+ ///
void Action(Bot bot);
}
}
\ No newline at end of file
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs
index 4d3b06d5bf..e7288d53cf 100644
--- a/OpenSim/Tools/pCampBot/pCampBot.cs
+++ b/OpenSim/Tools/pCampBot/pCampBot.cs
@@ -111,7 +111,7 @@ namespace pCampBot
" -firstname first name for the bots\n" +
" -lastname lastname for the bots. Each lastname will have _ appended, e.g. Ima Bot_0\n" +
" -password password for the bots\n" +
- " -b, behaviours behaviours for bots. Current options p (physics), g (grab). Comma separated, e.g. p,g. Default is p",
+ " -b, behaviours behaviours for bots. Current options p (physics), g (grab), t (teleport). Comma separated, e.g. p,g. Default is p",
" -wear set appearance folder to load from (default: no)\n" +
" -h, -help show this message"
);
diff --git a/bin/Nini.dll b/bin/Nini.dll
index 745057c3f6..c421005ba3 100755
Binary files a/bin/Nini.dll and b/bin/Nini.dll differ