aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Application/OpenSim.cs13
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs37
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneViewer.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs19
-rw-r--r--OpenSim/TestSuite/BotManager.cs170
-rw-r--r--OpenSim/TestSuite/Main.cs98
-rw-r--r--OpenSim/TestSuite/PhysicsBot.cs196
-rw-r--r--OpenSim/TestSuite/README.txt25
-rw-r--r--OpenSim/TestSuite/Util.cs81
-rw-r--r--OpenSim/Tools/pCampBot/BotManager.cs169
-rw-r--r--OpenSim/Tools/pCampBot/PhysicsBot.cs171
-rw-r--r--OpenSim/Tools/pCampBot/README.txt25
-rw-r--r--OpenSim/Tools/pCampBot/pCampBot.cs6
16 files changed, 255 insertions, 786 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 5ff9a38..ae4aad3 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -1045,6 +1045,19 @@ namespace OpenSim
1045 MainConsole.Instance.Output("Shared Module: " + module.Name); 1045 MainConsole.Instance.Output("Shared Module: " + module.Name);
1046 } 1046 }
1047 1047
1048 m_sceneManager.ForEachScene(
1049 delegate(Scene scene)
1050 {
1051 m_log.Error("The currently loaded modules in " + scene.RegionInfo.RegionName + " are:");
1052 foreach (IRegionModule module in scene.Modules.Values)
1053 {
1054 if (!module.IsSharedModule)
1055 {
1056 m_log.Error("Region Module: " + module.Name);
1057 }
1058 }
1059 });
1060
1048 MainConsole.Instance.Output(""); 1061 MainConsole.Instance.Output("");
1049 break; 1062 break;
1050 1063
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 0fb346a..b49f23c 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -1180,7 +1180,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1180 else 1180 else
1181 { 1181 {
1182 OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount()); 1182 OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount());
1183 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 1183 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
1184 { 1184 {
1185 OSDMap responsemapdata = new OSDMap(); 1185 OSDMap responsemapdata = new OSDMap();
1186 responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X)); 1186 responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X));
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0360942..c162519 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -86,7 +86,6 @@ namespace OpenSim.Region.Framework.Scenes
86 public bool m_allowScriptCrossings; 86 public bool m_allowScriptCrossings;
87 public bool m_useFlySlow; 87 public bool m_useFlySlow;
88 public bool m_usePreJump; 88 public bool m_usePreJump;
89 public bool m_seeIntoRegionFromNeighbor;
90 89
91 protected float m_defaultDrawDistance = 255.0f; 90 protected float m_defaultDrawDistance = 255.0f;
92 public float DefaultDrawDistance 91 public float DefaultDrawDistance
@@ -660,14 +659,6 @@ namespace OpenSim.Region.Framework.Scenes
660 659
661 m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; 660 m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics;
662 661
663 // Old
664 /*
665 m_simulatorVersion = simulatorVersion
666 + " (OS " + Util.GetOperatingSystemInformation() + ")"
667 + " ChilTasks:" + m_seeIntoRegionFromNeighbor.ToString()
668 + " PhysPrim:" + m_physicalPrim.ToString();
669 */
670
671 m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; 662 m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")";
672 663
673 #region Region Config 664 #region Region Config
@@ -714,7 +705,6 @@ namespace OpenSim.Region.Framework.Scenes
714 m_clampPrimSize = true; 705 m_clampPrimSize = true;
715 } 706 }
716 707
717 m_seeIntoRegionFromNeighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor", true);
718 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 708 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
719 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 709 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
720 m_dontPersistBefore = 710 m_dontPersistBefore =
@@ -4201,33 +4191,6 @@ namespace OpenSim.Region.Framework.Scenes
4201 } 4191 }
4202 } 4192 }
4203 4193
4204 public override void Show(string[] showParams)
4205 {
4206 base.Show(showParams);
4207
4208 switch (showParams[0])
4209 {
4210 case "users":
4211 m_log.Error("Current Region: " + RegionInfo.RegionName);
4212 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname",
4213 "Agent ID", "Session ID", "Circuit", "IP", "World");
4214
4215 ForEachScenePresence(delegate(ScenePresence sp)
4216 {
4217 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}",
4218 sp.Firstname,
4219 sp.Lastname,
4220 sp.UUID,
4221 sp.ControllingClient.AgentId,
4222 "Unknown",
4223 "Unknown",
4224 RegionInfo.RegionName);
4225 });
4226
4227 break;
4228 }
4229 }
4230
4231 #region Script Handling Methods 4194 #region Script Handling Methods
4232 4195
4233 /// <summary> 4196 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index bf861b8..73e9392 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -458,27 +458,6 @@ namespace OpenSim.Region.Framework.Scenes
458 #endregion 458 #endregion
459 459
460 /// <summary> 460 /// <summary>
461 /// Shows various details about the sim based on the parameters supplied by the console command in openSimMain.
462 /// </summary>
463 /// <param name="showParams">What to show</param>
464 public virtual void Show(string[] showParams)
465 {
466 switch (showParams[0])
467 {
468 case "modules":
469 m_log.Error("The currently loaded modules in " + RegionInfo.RegionName + " are:");
470 foreach (IRegionModule module in Modules.Values)
471 {
472 if (!module.IsSharedModule)
473 {
474 m_log.Error("Region Module: " + module.Name);
475 }
476 }
477 break;
478 }
479 }
480
481 /// <summary>
482 /// Call this from a region module to add a command to the OpenSim console. 461 /// Call this from a region module to add a command to the OpenSim console.
483 /// </summary> 462 /// </summary>
484 /// <param name="mod"></param> 463 /// <param name="mod"></param>
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index d8939fc..bba746f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2927,7 +2927,7 @@ namespace OpenSim.Region.Framework.Scenes
2927 // only send update from root agents to other clients; children are only "listening posts" 2927 // only send update from root agents to other clients; children are only "listening posts"
2928 if (IsChildAgent) 2928 if (IsChildAgent)
2929 { 2929 {
2930 m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent"); 2930 m_log.Warn("[SCENE PRESENCE]: Attempt to send avatar data from a child agent");
2931 return; 2931 return;
2932 } 2932 }
2933 2933
@@ -2984,10 +2984,10 @@ namespace OpenSim.Region.Framework.Scenes
2984 // only send update from root agents to other clients; children are only "listening posts" 2984 // only send update from root agents to other clients; children are only "listening posts"
2985 if (IsChildAgent) 2985 if (IsChildAgent)
2986 { 2986 {
2987 m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent"); 2987 m_log.Warn("[SCENE PRESENCE]: Attempt to send avatar data from a child agent");
2988 return; 2988 return;
2989 } 2989 }
2990 2990
2991 int count = 0; 2991 int count = 0;
2992 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2992 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2993 { 2993 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
index 8a0d288..092b76e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Region.Framework.Scenes
84 { 84 {
85 if (m_pendingObjects == null) 85 if (m_pendingObjects == null)
86 { 86 {
87 if (!m_presence.IsChildAgent || (m_presence.Scene.m_seeIntoRegionFromNeighbor)) 87 if (!m_presence.IsChildAgent)
88 { 88 {
89 m_pendingObjects = new Queue<SceneObjectGroup>(); 89 m_pendingObjects = new Queue<SceneObjectGroup>();
90 90
diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
index 2cef8a9..f8120aa 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
@@ -98,7 +98,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
98 "Show appearance information for each avatar in the simulator.", 98 "Show appearance information for each avatar in the simulator.",
99 "At the moment this actually just checks that we have all the required baked textures. If not, then appearance is 'corrupt' and other avatars will continue to see a cloud.", 99 "At the moment this actually just checks that we have all the required baked textures. If not, then appearance is 'corrupt' and other avatars will continue to see a cloud.",
100 ShowAppearanceInfo); 100 ShowAppearanceInfo);
101 } 101
102 scene.AddCommand(
103 this, "appearance send",
104 "appearance send",
105 "Send appearance data for each avatar in the simulator to viewers.",
106 SendAppearance);
107 }
108
109 private void SendAppearance(string module, string[] cmd)
110 {
111 lock (m_scenes)
112 {
113 foreach (Scene scene in m_scenes.Values)
114 {
115 scene.ForEachRootScenePresence(sp => scene.AvatarFactory.SendAppearance(sp.UUID));
116 }
117 }
118 }
102 119
103 protected void ShowAppearanceInfo(string module, string[] cmd) 120 protected void ShowAppearanceInfo(string module, string[] cmd)
104 { 121 {
diff --git a/OpenSim/TestSuite/BotManager.cs b/OpenSim/TestSuite/BotManager.cs
deleted file mode 100644
index 55ba687..0000000
--- a/OpenSim/TestSuite/BotManager.cs
+++ /dev/null
@@ -1,170 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using OpenMetaverse;
33using log4net;
34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Framework.Console;
37
38namespace OpenSim.TestSuite
39{
40 /// <summary>
41 /// Thread/Bot manager for the application
42 /// </summary>
43 public class BotManager
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 protected CommandConsole m_console;
48 protected List<PhysicsBot> m_lBot;
49 protected Thread[] m_td;
50 protected bool m_verbose = true;
51 protected Random somthing = new Random(Environment.TickCount);
52 protected int numbots = 0;
53 protected IConfig Previous_config;
54
55 /// <summary>
56 /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data
57 /// </summary>
58 public BotManager()
59 {
60 m_log.Info("In bot manager");
61 m_lBot = new List<PhysicsBot>();
62 }
63
64 /// <summary>
65 /// Startup number of bots specified in the starting arguments
66 /// </summary>
67 /// <param name="botcount">How many bots to start up</param>
68 /// <param name="cs">The configuration for the bots to use</param>
69 public void dobotStartup(int botcount, IConfig cs)
70 {
71 Previous_config = cs;
72 m_td = new Thread[botcount];
73 for (int i = 0; i < botcount; i++)
74 {
75 startupBot(i, cs);
76 }
77 }
78
79 /// <summary>
80 /// Add additional bots (and threads) to our bot pool
81 /// </summary>
82 /// <param name="botcount">How Many of them to add</param>
83 public void addbots(int botcount)
84 {
85 int len = m_td.Length;
86 Thread[] m_td2 = new Thread[len + botcount];
87 for (int i = 0; i < len; i++)
88 {
89 m_td2[i] = m_td[i];
90 }
91 m_td = m_td2;
92 int newlen = len + botcount;
93 for (int i = len; i < newlen; i++)
94 {
95 startupBot(i, Previous_config);
96 }
97 }
98
99 /// <summary>
100 /// This starts up the bot and stores the thread for the bot in the thread array
101 /// </summary>
102 /// <param name="pos">The position in the thread array to stick the bot's thread</param>
103 /// <param name="cs">Configuration of the bot</param>
104 public void startupBot(int pos, IConfig cs)
105 {
106 PhysicsBot pb = new PhysicsBot(cs);
107
108 pb.OnConnected += handlebotEvent;
109 pb.OnDisconnected += handlebotEvent;
110 if (cs.GetString("firstname", "random") == "random") pb.firstname = CreateRandomName();
111 if (cs.GetString("lastname", "random") == "random") pb.lastname = CreateRandomName();
112
113 m_td[pos] = new Thread(pb.startup);
114 m_td[pos].Name = "CampBot_" + pos;
115 m_td[pos].IsBackground = true;
116 m_td[pos].Start();
117 m_lBot.Add(pb);
118 }
119
120 /// <summary>
121 /// Creates a random name for the bot
122 /// </summary>
123 /// <returns></returns>
124 private string CreateRandomName()
125 {
126 string returnstring = "";
127 string chars = "abcdefghijklmnopqrstuvwxyz0123456789";
128
129 for (int i = 0; i < 7; i++)
130 {
131 returnstring += chars.Substring(somthing.Next(chars.Length),1);
132 }
133 return returnstring;
134 }
135
136 /// <summary>
137 /// High level connnected/disconnected events so we can keep track of our threads by proxy
138 /// </summary>
139 /// <param name="callbot"></param>
140 /// <param name="eventt"></param>
141 public void handlebotEvent(PhysicsBot callbot, EventType eventt)
142 {
143 switch (eventt)
144 {
145 case EventType.CONNECTED:
146 m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Connected");
147 numbots++;
148 break;
149 case EventType.DISCONNECTED:
150 m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Disconnected");
151 m_td[m_lBot.IndexOf(callbot)].Abort();
152 numbots--;
153 if (numbots > 1)
154 Environment.Exit(0);
155 break;
156 }
157 }
158
159 /// <summary>
160 /// Shutting down all bots
161 /// </summary>
162 public void doBotShutdown()
163 {
164 foreach (PhysicsBot pb in m_lBot)
165 {
166 pb.shutdown();
167 }
168 }
169 }
170}
diff --git a/OpenSim/TestSuite/Main.cs b/OpenSim/TestSuite/Main.cs
deleted file mode 100644
index ee75bf5..0000000
--- a/OpenSim/TestSuite/Main.cs
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using Nini.Config;
30
31namespace OpenSim.TestSuite
32{
33 /// <summary>
34 /// Event Types from the BOT. Add new events here
35 /// </summary>
36 public enum EventType : int
37 {
38 NONE = 0,
39 CONNECTED = 1,
40 DISCONNECTED = 2
41 }
42
43 public class TestSuite
44 {
45 public static void Main(string[] args)
46 {
47 // TODO: config parser
48
49 // TODO: load tests from addings
50
51 // TODO: create base bot cloud for use in tests
52
53 IConfig config = ParseConfig(args);
54 if (config.Get("help") != null || config.Get("loginuri") == null)
55 {
56 Help();
57 }
58 else
59 {
60 // TODO: unused: int botcount = config.GetInt("botcount", 1);
61
62 // BotManager bm = new BotManager();
63
64 Utils.TestPass("Completed Startup");
65 }
66 }
67
68 private static IConfig ParseConfig(String[] args)
69 {
70 //Set up our nifty config.. thanks to nini
71 ArgvConfigSource cs = new ArgvConfigSource(args);
72
73 // TODO: unused: cs.AddSwitch("Startup", "botcount","n");
74 cs.AddSwitch("Startup", "loginuri","l");
75 cs.AddSwitch("Startup", "firstname");
76 cs.AddSwitch("Startup", "lastname");
77 cs.AddSwitch("Startup", "password");
78 cs.AddSwitch("Startup", "help","h");
79
80 IConfig ol = cs.Configs["Startup"];
81 return ol;
82 }
83
84 private static void Help()
85 {
86 Console.WriteLine(
87 "usage: pCampBot <-loginuri loginuri> [OPTIONS]\n" +
88 "Spawns a set of bots to test an OpenSim region\n\n" +
89 " -l, -loginuri loginuri for sim to log into (required)\n" +
90 // TODO: unused: " -n, -botcount number of bots to start (default: 1)\n" +
91 " -firstname first name for the bot(s) (default: random string)\n" +
92 " -lastname lastname for the bot(s) (default: random string)\n" +
93 " -password password for the bots(s) (default: random string)\n" +
94 " -h, -help show this message"
95 );
96 }
97 }
98}
diff --git a/OpenSim/TestSuite/PhysicsBot.cs b/OpenSim/TestSuite/PhysicsBot.cs
deleted file mode 100644
index fac4275..0000000
--- a/OpenSim/TestSuite/PhysicsBot.cs
+++ /dev/null
@@ -1,196 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Threading;
31using System.Timers;
32using OpenMetaverse;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using Timer=System.Timers.Timer;
37
38namespace OpenSim.TestSuite
39{
40 public class PhysicsBot
41 {
42 public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events
43 public IConfig startupConfig; // bot config, passed from BotManager
44
45 public string firstname;
46 public string lastname;
47 public string password;
48 public string loginURI;
49
50 public event AnEvent OnConnected;
51 public event AnEvent OnDisconnected;
52
53 protected Timer m_action; // Action Timer
54
55 protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here
56
57 //New instance of a SecondLife client
58 public GridClient client = new GridClient();
59
60 protected string[] talkarray;
61 /// <summary>
62 ///
63 /// </summary>
64 /// <param name="bsconfig">nini config for the bot</param>
65 public PhysicsBot(IConfig bsconfig)
66 {
67 startupConfig = bsconfig;
68 readconfig();
69 talkarray = readexcuses();
70 }
71
72 //We do our actions here. This is where one would
73 //add additional steps and/or things the bot should do
74
75 void m_action_Elapsed(object sender, ElapsedEventArgs e)
76 {
77 //client.Throttle.Task = 500000f;
78 //client.Throttle.Set();
79 int walkorrun = somthing.Next(4); // Randomize between walking and running. The greater this number,
80 // the greater the bot's chances to walk instead of run.
81 if (walkorrun == 0)
82 {
83 client.Self.Movement.AlwaysRun = true;
84 }
85 else
86 {
87 client.Self.Movement.AlwaysRun = false;
88 }
89
90 // TODO: unused: Vector3 pos = client.Self.SimPosition;
91 Vector3 newpos = new Vector3(somthing.Next(255), somthing.Next(255), somthing.Next(255));
92 client.Self.Movement.TurnToward(newpos);
93
94 for (int i = 0; i < 2000; i++)
95 {
96 client.Self.Movement.AtPos = true;
97 Thread.Sleep(somthing.Next(25, 75)); // Makes sure the bots keep walking for this time.
98 }
99 client.Self.Jump(true);
100
101 string randomf = talkarray[somthing.Next(talkarray.Length)];
102 if (talkarray.Length > 1 && randomf.Length > 1)
103 client.Self.Chat(randomf, 0, ChatType.Normal);
104
105 //Thread.Sleep(somthing.Next(1, 10)); // Apparently its better without it right now.
106 }
107
108 /// <summary>
109 /// Read the Nini config and initialize
110 /// </summary>
111 public void readconfig()
112 {
113 firstname = startupConfig.GetString("firstname", "random");
114 lastname = startupConfig.GetString("lastname", "random");
115 password = startupConfig.GetString("password", "12345");
116 loginURI = startupConfig.GetString("loginuri");
117 }
118
119 /// <summary>
120 /// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes.
121 /// </summary>
122 public void shutdown()
123 {
124 client.Network.Logout();
125 }
126
127 /// <summary>
128 /// This is the bot startup loop.
129 /// </summary>
130 public void startup()
131 {
132 client.Settings.LOGIN_SERVER = loginURI;
133 client.Network.LoginProgress += this.Network_LoginProgress;
134 client.Network.SimConnected += this.Network_SimConnected;
135 client.Network.Disconnected += this.Network_OnDisconnected;
136 if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name"))
137 {
138
139 if (OnConnected != null)
140 {
141 m_action = new Timer(somthing.Next(1000, 10000));
142 m_action.Elapsed += new ElapsedEventHandler(m_action_Elapsed);
143 m_action.Start();
144 OnConnected(this, EventType.CONNECTED);
145 client.Self.Jump(true);
146 }
147 }
148 else
149 {
150 MainConsole.Instance.Output(firstname + " " + lastname + "Can't login: " + client.Network.LoginMessage);
151 if (OnDisconnected != null)
152 {
153 OnDisconnected(this, EventType.DISCONNECTED);
154 }
155 }
156 }
157
158 public void Network_LoginProgress(object sender, LoginProgressEventArgs args)
159 {
160 if (args.Status == LoginStatus.Success)
161 {
162 if (OnConnected != null)
163 {
164 OnConnected(this, EventType.CONNECTED);
165 }
166 }
167 }
168
169 public void Network_SimConnected(object sender, SimConnectedEventArgs args)
170 {
171 }
172
173 public void Network_OnDisconnected(object sender, DisconnectedEventArgs args)
174 {
175 if (OnDisconnected != null)
176 {
177 OnDisconnected(this, EventType.DISCONNECTED);
178 }
179 }
180
181 public string[] readexcuses()
182 {
183 string allexcuses = "";
184
185 string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt");
186 if (File.Exists(file))
187 {
188 StreamReader csr = File.OpenText(file);
189 allexcuses = csr.ReadToEnd();
190 csr.Close();
191 }
192
193 return allexcuses.Split(Environment.NewLine.ToCharArray());
194 }
195 }
196}
diff --git a/OpenSim/TestSuite/README.txt b/OpenSim/TestSuite/README.txt
deleted file mode 100644
index cdfa4a7..0000000
--- a/OpenSim/TestSuite/README.txt
+++ /dev/null
@@ -1,25 +0,0 @@
1OpenSim Test Suite
2------------------------------------------------------------
3
4The eventual goal of the OpenSim Test Suite is to provide a framework
5and a set of tests to do system level regression testing of OpenSim.
6In short:
7
8OpenSim Test Suite will have Test Modules (Mono Addins?) that will
9verify certain paths in the code. Some early modules may be (subject
10to change):
11
12 * Login Tests
13 - Attempt to Log in 1, 5, 20 bots.
14 * Basic Walk Tests
15 - Attempt to Log in and move about in well known tracks
16 - Repeat with 5, 20 bots
17 * Basic Construct Tests
18 - Construct Simple Objects in World
19 - Ensure bots can see other objects constructed
20 * Basic Asset Tests
21 - Construct Simple Objects in World with Textures
22 - Pull Objects and Textures
23
24
25 \ No newline at end of file
diff --git a/OpenSim/TestSuite/Util.cs b/OpenSim/TestSuite/Util.cs
deleted file mode 100644
index e050c07..0000000
--- a/OpenSim/TestSuite/Util.cs
+++ /dev/null
@@ -1,81 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29
30namespace OpenSim.TestSuite
31{
32 public class Utils
33 {
34 enum Result
35 {
36 Fail = 0,
37 Pass = 1,
38 Skip = 3
39 }
40
41 private static String ResultToString(Result r)
42 {
43 if (r == Result.Pass)
44 {
45 return "PASS";
46 }
47 else if (r == Result.Fail)
48 {
49 return "FAIL";
50 }
51 else if (r == Result.Skip)
52 {
53 return "SKIP";
54 }
55 else
56 {
57 return "UNKNOWN";
58 }
59 }
60
61 private static void TestResult(Result r, String msg)
62 {
63 Console.WriteLine("[{0}]: {1}", ResultToString(r), msg);
64 }
65
66 public static void TestFail(String msg)
67 {
68 TestResult(Result.Fail, msg);
69 }
70
71 public static void TestPass(String msg)
72 {
73 TestResult(Result.Pass, msg);
74 }
75
76 public static void TestSkip(String msg)
77 {
78 TestResult(Result.Skip, msg);
79 }
80 }
81}
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index 614b350..b05bd6d 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -49,17 +49,22 @@ namespace pCampBot
49 49
50 protected CommandConsole m_console; 50 protected CommandConsole m_console;
51 protected List<PhysicsBot> m_lBot; 51 protected List<PhysicsBot> m_lBot;
52 protected Thread[] m_td;
53 protected bool m_verbose = true;
54 protected Random somthing = new Random(Environment.TickCount); 52 protected Random somthing = new Random(Environment.TickCount);
55 protected int numbots = 0; 53 protected int numbots = 0;
56 protected IConfig Previous_config; 54 public IConfig Config { get; private set; }
55
56 /// <summary>
57 /// Track the assets we have and have not received so we don't endlessly repeat requests.
58 /// </summary>
59 public Dictionary<UUID, bool> AssetsReceived { get; private set; }
57 60
58 /// <summary> 61 /// <summary>
59 /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data 62 /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data
60 /// </summary> 63 /// </summary>
61 public BotManager() 64 public BotManager()
62 { 65 {
66 AssetsReceived = new Dictionary<UUID, bool>();
67
63 m_console = CreateConsole(); 68 m_console = CreateConsole();
64 MainConsole.Instance = m_console; 69 MainConsole.Instance = m_console;
65 70
@@ -81,16 +86,21 @@ namespace pCampBot
81 86
82 m_console.Commands.AddCommand("bot", false, "shutdown", 87 m_console.Commands.AddCommand("bot", false, "shutdown",
83 "shutdown", 88 "shutdown",
84 "Gracefully shut down bots", HandleShutdown); 89 "Shutdown bots and exit", HandleShutdown);
85 90
86 m_console.Commands.AddCommand("bot", false, "quit", 91 m_console.Commands.AddCommand("bot", false, "quit",
87 "quit", 92 "quit",
88 "Force quit (DANGEROUS, try shutdown first)", 93 "Shutdown bots and exit",
89 HandleShutdown); 94 HandleShutdown);
90 95
91 m_console.Commands.AddCommand("bot", false, "add bots", 96 m_console.Commands.AddCommand("bot", false, "show status",
92 "add bots <number>", 97 "show status",
93 "Add more bots", HandleAddBots); 98 "Shows the status of all bots",
99 HandleShowStatus);
100
101// m_console.Commands.AddCommand("bot", false, "add bots",
102// "add bots <number>",
103// "Add more bots", HandleAddBots);
94 104
95 m_lBot = new List<PhysicsBot>(); 105 m_lBot = new List<PhysicsBot>();
96 } 106 }
@@ -102,69 +112,63 @@ namespace pCampBot
102 /// <param name="cs">The configuration for the bots to use</param> 112 /// <param name="cs">The configuration for the bots to use</param>
103 public void dobotStartup(int botcount, IConfig cs) 113 public void dobotStartup(int botcount, IConfig cs)
104 { 114 {
105 Previous_config = cs; 115 Config = cs;
106 m_td = new Thread[botcount]; 116
117 string firstName = cs.GetString("firstname");
118 string lastNameStem = cs.GetString("lastname");
119 string password = cs.GetString("password");
120 string loginUri = cs.GetString("loginuri");
121
107 for (int i = 0; i < botcount; i++) 122 for (int i = 0; i < botcount; i++)
108 { 123 {
109 startupBot(i, cs); 124 string lastName = string.Format("{0}_{1}", lastNameStem, i);
125 startupBot(i, this, firstName, lastName, password, loginUri);
110 } 126 }
111 } 127 }
112 128
113 /// <summary> 129// /// <summary>
114 /// Add additional bots (and threads) to our bot pool 130// /// Add additional bots (and threads) to our bot pool
115 /// </summary> 131// /// </summary>
116 /// <param name="botcount">How Many of them to add</param> 132// /// <param name="botcount">How Many of them to add</param>
117 public void addbots(int botcount) 133// public void addbots(int botcount)
118 { 134// {
119 int len = m_td.Length; 135// int len = m_td.Length;
120 Thread[] m_td2 = new Thread[len + botcount]; 136// Thread[] m_td2 = new Thread[len + botcount];
121 for (int i = 0; i < len; i++) 137// for (int i = 0; i < len; i++)
122 { 138// {
123 m_td2[i] = m_td[i]; 139// m_td2[i] = m_td[i];
124 } 140// }
125 m_td = m_td2; 141// m_td = m_td2;
126 int newlen = len + botcount; 142// int newlen = len + botcount;
127 for (int i = len; i < newlen; i++) 143// for (int i = len; i < newlen; i++)
128 { 144// {
129 startupBot(i, Previous_config); 145// startupBot(i, Config);
130 } 146// }
131 } 147// }
132 148
133 /// <summary> 149 /// <summary>
134 /// This starts up the bot and stores the thread for the bot in the thread array 150 /// This starts up the bot and stores the thread for the bot in the thread array
135 /// </summary> 151 /// </summary>
136 /// <param name="pos">The position in the thread array to stick the bot's thread</param> 152 /// <param name="pos">The position in the thread array to stick the bot's thread</param>
137 /// <param name="cs">Configuration of the bot</param> 153 /// <param name="cs">Configuration of the bot</param>
138 public void startupBot(int pos, IConfig cs) 154 /// <param name="firstName">First name</param>
155 /// <param name="lastName">Last name</param>
156 /// <param name="password">Password</param>
157 /// <param name="loginUri">Login URI</param>
158 public void startupBot(int pos, BotManager bm, string firstName, string lastName, string password, string loginUri)
139 { 159 {
140 PhysicsBot pb = new PhysicsBot(cs); 160 PhysicsBot pb = new PhysicsBot(bm, firstName, lastName, password, loginUri);
141 161
142 pb.OnConnected += handlebotEvent; 162 pb.OnConnected += handlebotEvent;
143 pb.OnDisconnected += handlebotEvent; 163 pb.OnDisconnected += handlebotEvent;
144 if (cs.GetString("firstname", "random") == "random") pb.firstname = CreateRandomName();
145 if (cs.GetString("lastname", "random") == "random") pb.lastname = CreateRandomName();
146
147 m_td[pos] = new Thread(pb.startup);
148 m_td[pos].Name = "CampBot_" + pos;
149 m_td[pos].IsBackground = true;
150 m_td[pos].Start();
151 m_lBot.Add(pb);
152 }
153 164
154 /// <summary> 165 lock (m_lBot)
155 /// Creates a random name for the bot 166 m_lBot.Add(pb);
156 /// </summary>
157 /// <returns></returns>
158 private string CreateRandomName()
159 {
160 string returnstring = "";
161 string chars = "abcdefghijklmnopqrstuvwxyz0123456789";
162 167
163 for (int i = 0; i < 7; i++) 168 Thread pbThread = new Thread(pb.startup);
164 { 169 pbThread.Name = pb.Name;
165 returnstring += chars.Substring(somthing.Next(chars.Length),1); 170 pbThread.IsBackground = true;
166 } 171 pbThread.Start();
167 return returnstring;
168 } 172 }
169 173
170 /// <summary> 174 /// <summary>
@@ -172,19 +176,20 @@ namespace pCampBot
172 /// </summary> 176 /// </summary>
173 /// <param name="callbot"></param> 177 /// <param name="callbot"></param>
174 /// <param name="eventt"></param> 178 /// <param name="eventt"></param>
175 public void handlebotEvent(PhysicsBot callbot, EventType eventt) 179 private void handlebotEvent(PhysicsBot callbot, EventType eventt)
176 { 180 {
177 switch (eventt) 181 switch (eventt)
178 { 182 {
179 case EventType.CONNECTED: 183 case EventType.CONNECTED:
180 m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Connected"); 184 m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected");
181 numbots++; 185 numbots++;
186// m_log.InfoFormat("NUMBOTS {0}", numbots);
182 break; 187 break;
183 case EventType.DISCONNECTED: 188 case EventType.DISCONNECTED:
184 m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Disconnected"); 189 m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected");
185 m_td[m_lBot.IndexOf(callbot)].Abort();
186 numbots--; 190 numbots--;
187 if (numbots >1) 191// m_log.InfoFormat("NUMBOTS {0}", numbots);
192 if (numbots <= 0)
188 Environment.Exit(0); 193 Environment.Exit(0);
189 break; 194 break;
190 } 195 }
@@ -195,10 +200,9 @@ namespace pCampBot
195 /// </summary> 200 /// </summary>
196 public void doBotShutdown() 201 public void doBotShutdown()
197 { 202 {
198 foreach (PhysicsBot pb in m_lBot) 203 lock (m_lBot)
199 { 204 foreach (PhysicsBot pb in m_lBot)
200 pb.shutdown(); 205 pb.shutdown();
201 }
202 } 206 }
203 207
204 /// <summary> 208 /// <summary>
@@ -216,6 +220,21 @@ namespace pCampBot
216 doBotShutdown(); 220 doBotShutdown();
217 } 221 }
218 222
223 private void HandleShowStatus(string module, string[] cmd)
224 {
225 string outputFormat = "{0,-30} {1,-14}";
226 MainConsole.Instance.OutputFormat(outputFormat, "Name", "Status");
227
228 lock (m_lBot)
229 {
230 foreach (PhysicsBot pb in m_lBot)
231 {
232 MainConsole.Instance.OutputFormat(
233 outputFormat, pb.Name, (pb.IsConnected ? "Connected" : "Disconnected"));
234 }
235 }
236 }
237
219 /* 238 /*
220 private void HandleQuit(string module, string[] cmd) 239 private void HandleQuit(string module, string[] cmd)
221 { 240 {
@@ -223,17 +242,17 @@ namespace pCampBot
223 Environment.Exit(0); 242 Environment.Exit(0);
224 } 243 }
225 */ 244 */
226 245//
227 private void HandleAddBots(string module, string[] cmd) 246// private void HandleAddBots(string module, string[] cmd)
228 { 247// {
229 int newbots = 0; 248// int newbots = 0;
230 249//
231 if (cmd.Length > 2) 250// if (cmd.Length > 2)
232 { 251// {
233 Int32.TryParse(cmd[2], out newbots); 252// Int32.TryParse(cmd[2], out newbots);
234 } 253// }
235 if (newbots > 0) 254// if (newbots > 0)
236 addbots(newbots); 255// addbots(newbots);
237 } 256// }
238 } 257 }
239} 258}
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs
index 5d4af31..a8b2426 100644
--- a/OpenSim/Tools/pCampBot/PhysicsBot.cs
+++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs
@@ -29,56 +29,85 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using System.IO; 31using System.IO;
32using System.Reflection;
32using System.Threading; 33using System.Threading;
33using System.Timers; 34using System.Timers;
35using log4net;
34using OpenMetaverse; 36using OpenMetaverse;
35using OpenMetaverse.Assets; 37using OpenMetaverse.Assets;
36using Nini.Config; 38using Nini.Config;
37using OpenSim.Framework; 39using OpenSim.Framework;
38using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
39using Timer=System.Timers.Timer; 41using Timer = System.Timers.Timer;
40 42
41namespace pCampBot 43namespace pCampBot
42{ 44{
43 public class PhysicsBot 45 public class PhysicsBot
44 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
45 public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events 49 public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events
46 public IConfig startupConfig; // bot config, passed from BotManager
47 50
48 public string firstname; 51 public BotManager BotManager { get; private set; }
49 public string lastname; 52 private IConfig startupConfig; // bot config, passed from BotManager
50 public string password; 53
51 public string loginURI; 54 /// <summary>
55 /// Is this bot connected to the grid?
56 /// </summary>
57 public bool IsConnected { get; private set; }
58
59 public string FirstName { get; private set; }
60 public string LastName { get; private set; }
61 public string Name { get; private set; }
62 public string Password { get; private set; }
63 public string LoginUri { get; private set; }
52 public string saveDir; 64 public string saveDir;
53 public string wear; 65 public string wear;
54 66
55 public event AnEvent OnConnected; 67 public event AnEvent OnConnected;
56 public event AnEvent OnDisconnected; 68 public event AnEvent OnDisconnected;
57 69
58 protected Timer m_action; // Action Timer 70 /// <summary>
71 /// Keep a track of the continuously acting thread so that we can abort it.
72 /// </summary>
73 private Thread m_actionThread;
74
59 protected List<uint> objectIDs = new List<uint>(); 75 protected List<uint> objectIDs = new List<uint>();
60 76
61 protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here 77 protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here
62 78
63 //New instance of a SecondLife client 79 /// <summary>
80 /// New instance of a SecondLife client
81 /// </summary>
64 public GridClient client = new GridClient(); 82 public GridClient client = new GridClient();
65 83
66 protected string[] talkarray; 84 protected string[] talkarray;
85
67 /// <summary> 86 /// <summary>
68 /// 87 /// Constructor
69 /// </summary> 88 /// </summary>
70 /// <param name="bsconfig">nini config for the bot</param> 89 /// <param name="bm"></param>
71 public PhysicsBot(IConfig bsconfig) 90 /// <param name="firstName"></param>
91 /// <param name="lastName"></param>
92 /// <param name="password"></param>
93 /// <param name="loginUri"></param>
94 public PhysicsBot(BotManager bm, string firstName, string lastName, string password, string loginUri)
72 { 95 {
73 startupConfig = bsconfig; 96 FirstName = firstName;
97 LastName = lastName;
98 Name = string.Format("{0} {1}", FirstName, LastName);
99 Password = password;
100 LoginUri = loginUri;
101
102 BotManager = bm;
103 startupConfig = bm.Config;
74 readconfig(); 104 readconfig();
75 talkarray = readexcuses(); 105 talkarray = readexcuses();
76 } 106 }
77 107
78 //We do our actions here. This is where one would 108 //We do our actions here. This is where one would
79 //add additional steps and/or things the bot should do 109 //add additional steps and/or things the bot should do
80 110 private void Action()
81 void m_action_Elapsed(object sender, ElapsedEventArgs e)
82 { 111 {
83 while (true) 112 while (true)
84 { 113 {
@@ -95,11 +124,11 @@ namespace pCampBot
95 } 124 }
96 125
97 // TODO: unused: Vector3 pos = client.Self.SimPosition; 126 // TODO: unused: Vector3 pos = client.Self.SimPosition;
98 Vector3 newpos = new Vector3(somthing.Next(255), somthing.Next(255), somthing.Next(255)); 127 Vector3 newpos = new Vector3(somthing.Next(1, 254), somthing.Next(1, 254), somthing.Next(1, 254));
99 client.Self.Movement.TurnToward(newpos); 128 client.Self.Movement.TurnToward(newpos);
100 129
101 client.Self.Movement.AtPos = true; 130 client.Self.Movement.AtPos = true;
102 Thread.Sleep(somthing.Next(3000,13000)); 131 Thread.Sleep(somthing.Next(3000, 13000));
103 client.Self.Movement.AtPos = false; 132 client.Self.Movement.AtPos = false;
104 client.Self.Jump(true); 133 client.Self.Jump(true);
105 134
@@ -116,10 +145,6 @@ namespace pCampBot
116 /// </summary> 145 /// </summary>
117 public void readconfig() 146 public void readconfig()
118 { 147 {
119 firstname = startupConfig.GetString("firstname", "random");
120 lastname = startupConfig.GetString("lastname", "random");
121 password = startupConfig.GetString("password", "12345");
122 loginURI = startupConfig.GetString("loginuri");
123 wear = startupConfig.GetString("wear","no"); 148 wear = startupConfig.GetString("wear","no");
124 } 149 }
125 150
@@ -128,6 +153,9 @@ namespace pCampBot
128 /// </summary> 153 /// </summary>
129 public void shutdown() 154 public void shutdown()
130 { 155 {
156 if (m_actionThread != null)
157 m_actionThread.Abort();
158
131 client.Network.Logout(); 159 client.Network.Logout();
132 } 160 }
133 161
@@ -136,7 +164,7 @@ namespace pCampBot
136 /// </summary> 164 /// </summary>
137 public void startup() 165 public void startup()
138 { 166 {
139 client.Settings.LOGIN_SERVER = loginURI; 167 client.Settings.LOGIN_SERVER = LoginUri;
140 client.Settings.ALWAYS_DECODE_OBJECTS = false; 168 client.Settings.ALWAYS_DECODE_OBJECTS = false;
141 client.Settings.AVATAR_TRACKING = false; 169 client.Settings.AVATAR_TRACKING = false;
142 client.Settings.OBJECT_TRACKING = false; 170 client.Settings.OBJECT_TRACKING = false;
@@ -155,32 +183,32 @@ namespace pCampBot
155 client.Network.SimConnected += this.Network_SimConnected; 183 client.Network.SimConnected += this.Network_SimConnected;
156 client.Network.Disconnected += this.Network_OnDisconnected; 184 client.Network.Disconnected += this.Network_OnDisconnected;
157 client.Objects.ObjectUpdate += Objects_NewPrim; 185 client.Objects.ObjectUpdate += Objects_NewPrim;
158 //client.Assets.OnAssetReceived += Asset_ReceivedCallback; 186
159 if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name")) 187 if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name"))
160 { 188 {
161 if (OnConnected != null) 189 IsConnected = true;
190
191 Thread.Sleep(somthing.Next(1000, 10000));
192 m_actionThread = new Thread(Action);
193 m_actionThread.Start();
194
195// OnConnected(this, EventType.CONNECTED);
196 if (wear == "save")
162 { 197 {
163 m_action = new Timer(somthing.Next(1000, 10000)); 198 client.Appearance.SetPreviousAppearance();
164 m_action.Enabled = true; 199 SaveDefaultAppearance();
165 m_action.AutoReset = false; 200 }
166 m_action.Elapsed += new ElapsedEventHandler(m_action_Elapsed); 201 else if (wear != "no")
167 m_action.Start(); 202 {
168 OnConnected(this, EventType.CONNECTED); 203 MakeDefaultAppearance(wear);
169 if (wear == "save")
170 {
171 client.Appearance.SetPreviousAppearance();
172 SaveDefaultAppearance();
173 }
174 else if (wear != "no")
175 {
176 MakeDefaultAppearance(wear);
177 }
178 client.Self.Jump(true);
179 } 204 }
205 client.Self.Jump(true);
180 } 206 }
181 else 207 else
182 { 208 {
183 MainConsole.Instance.Output(firstname + " " + lastname + " Can't login: " + client.Network.LoginMessage); 209 MainConsole.Instance.OutputFormat(
210 "{0} {1} cannot login: {2}", FirstName, LastName, client.Network.LoginMessage);
211
184 if (OnDisconnected != null) 212 if (OnDisconnected != null)
185 { 213 {
186 OnDisconnected(this, EventType.DISCONNECTED); 214 OnDisconnected(this, EventType.DISCONNECTED);
@@ -190,7 +218,7 @@ namespace pCampBot
190 218
191 public void SaveDefaultAppearance() 219 public void SaveDefaultAppearance()
192 { 220 {
193 saveDir = "MyAppearance/" + firstname + "_" + lastname; 221 saveDir = "MyAppearance/" + FirstName + "_" + LastName;
194 if (!Directory.Exists(saveDir)) 222 if (!Directory.Exists(saveDir))
195 { 223 {
196 Directory.CreateDirectory(saveDir); 224 Directory.CreateDirectory(saveDir);
@@ -216,7 +244,7 @@ namespace pCampBot
216 { 244 {
217 if (asset.Decode()) 245 if (asset.Decode())
218 { 246 {
219 File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}", 247 File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}",
220 asset.AssetType.ToString().ToLower(), 248 asset.AssetType.ToString().ToLower(),
221 asset.WearableType)), asset.AssetData); 249 asset.WearableType)), asset.AssetData);
222 } 250 }
@@ -366,8 +394,21 @@ namespace pCampBot
366 394
367 public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) 395 public void Network_OnDisconnected(object sender, DisconnectedEventArgs args)
368 { 396 {
369 if (OnDisconnected != null) 397// m_log.ErrorFormat("Fired Network_OnDisconnected");
398
399// if (
400// (args.Reason == NetworkManager.DisconnectType.SimShutdown
401// || args.Reason == NetworkManager.DisconnectType.NetworkTimeout)
402// && OnDisconnected != null)
403
404 if (
405 (args.Reason == NetworkManager.DisconnectType.ClientInitiated
406 || args.Reason == NetworkManager.DisconnectType.ServerInitiated
407 || args.Reason == NetworkManager.DisconnectType.NetworkTimeout)
408 && OnDisconnected != null)
409// if (OnDisconnected != null)
370 { 410 {
411 IsConnected = false;
371 OnDisconnected(this, EventType.DISCONNECTED); 412 OnDisconnected(this, EventType.DISCONNECTED);
372 } 413 }
373 } 414 }
@@ -382,39 +423,55 @@ namespace pCampBot
382 { 423 {
383 if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) 424 if (prim.Textures.DefaultTexture.TextureID != UUID.Zero)
384 { 425 {
385 client.Assets.RequestImage(prim.Textures.DefaultTexture.TextureID, ImageType.Normal, Asset_TextureCallback_Texture); 426 GetTexture(prim.Textures.DefaultTexture.TextureID);
386 } 427 }
428
387 for (int i = 0; i < prim.Textures.FaceTextures.Length; i++) 429 for (int i = 0; i < prim.Textures.FaceTextures.Length; i++)
388 { 430 {
389 if (prim.Textures.FaceTextures[i] != null) 431 UUID textureID = prim.Textures.FaceTextures[i].TextureID;
390 {
391 if (prim.Textures.FaceTextures[i].TextureID != UUID.Zero)
392 {
393 client.Assets.RequestImage(prim.Textures.FaceTextures[i].TextureID, ImageType.Normal, Asset_TextureCallback_Texture);
394 }
395 432
433 if (textureID != null && textureID != UUID.Zero)
434 {
435 GetTexture(textureID);
396 } 436 }
397 } 437 }
398 } 438 }
439
399 if (prim.Sculpt.SculptTexture != UUID.Zero) 440 if (prim.Sculpt.SculptTexture != UUID.Zero)
400 { 441 {
401 client.Assets.RequestImage(prim.Sculpt.SculptTexture, ImageType.Normal, Asset_TextureCallback_Texture); 442 GetTexture(prim.Sculpt.SculptTexture);
402 } 443 }
403 } 444 }
404 } 445 }
405 446
447 private void GetTexture(UUID textureID)
448 {
449 lock (BotManager.AssetsReceived)
450 {
451 // Don't request assets more than once.
452 if (BotManager.AssetsReceived.ContainsKey(textureID))
453 return;
454
455 BotManager.AssetsReceived[textureID] = false;
456 client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture);
457 }
458 }
459
406 460
407 public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture) 461 public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture)
408 { 462 {
409 //TODO: Implement texture saving and applying 463 //TODO: Implement texture saving and applying
410 } 464 }
411 465
412 public void Asset_ReceivedCallback(AssetDownload transfer,Asset asset) 466 public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset)
413 { 467 {
414 if (wear == "save") 468 lock (BotManager.AssetsReceived)
415 { 469 BotManager.AssetsReceived[asset.AssetID] = true;
416 SaveAsset((AssetWearable) asset); 470
417 } 471// if (wear == "save")
472// {
473// SaveAsset((AssetWearable) asset);
474// }
418 } 475 }
419 476
420 public string[] readexcuses() 477 public string[] readexcuses()
diff --git a/OpenSim/Tools/pCampBot/README.txt b/OpenSim/Tools/pCampBot/README.txt
index 7ecbde1..c4fcf33 100644
--- a/OpenSim/Tools/pCampBot/README.txt
+++ b/OpenSim/Tools/pCampBot/README.txt
@@ -1,10 +1,13 @@
1This is the PhysicsCamperbot libslBot tester. 1This is the PhysicsCamperbot libslBot tester.
2 2
3This is designed to be run in standalone mode with authorize accounts 3This is designed to stress test the simulator. It creates <N>
4turned off as a way to stress test the simulator. It creates <N> 4clients that log in, randomly jump/walk around, and can say excuses from
5clients that log in, randomly jump/walk around, and say excuses from
6the BOFH. 5the BOFH.
7 6
7Bots must have accounts already created. Each bot will have the same firstname and password
8but their lastname will be appended with _<bot-number> starting from 0. So if you have two bots called ima bot, their
9first names will be ima_bot_0 and ima_bot_1.
10
8*** WARNING *** 11*** WARNING ***
9Using this bot on a public grid could get you banned permanently, so 12Using this bot on a public grid could get you banned permanently, so
10just say No! to griefing! 13just say No! to griefing!
@@ -21,19 +24,8 @@ pCampBot.exe will end up in the regular opensim/bin folder
21 24
22----- Running the bot ----- 25----- Running the bot -----
23 26
24windows: pCampBot.exe -botcount <N> -loginuri <URI> 27windows: pCampBot.exe -botcount <N> -loginuri <URI> -firstname <bot-first-name> -lastname <bot-last-name-stem> -password <bot-password>
25*nix: mono pCampBot.exe -botcount <N> -loginuri <URI> 28*nix: mono pCampBot.exe -botcount <N> -loginuri <URI> -firstname <bot-first-name> -lastname <bot-last-name-stem> -password <bot-password>
26
27The names it produces are random by default, however, you can specify
28either a firstname or a lastname in the command line also.
29
30ex: pCampBot.exe -botcount <N> -loginuri <URI> -lastname <lastname>
31
32If you specify both a firstname *and* a lastname, you'll likely run
33into trouble unless you're only running a single bot. In that case,
34there's also a password option.
35
36pCampBot.exe -botcount 1 -loginuri http://somegrid.com:8002 -firstname SomeDude -lastname SomeDude -password GobbleDeGook
37 29
38----- Commands ----- 30----- Commands -----
39 31
@@ -41,4 +33,3 @@ The bot has console commands:
41 help - lists the console commands and what they do 33 help - lists the console commands and what they do
42 shutdown - gracefully shuts down the bots 34 shutdown - gracefully shuts down the bots
43 quit - forcefully shuts things down leaving stuff unclean 35 quit - forcefully shuts things down leaving stuff unclean
44 addbots N - adds N number of random bots. (replace 'N' with a number)
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs
index 77110bf..a69fbf0 100644
--- a/OpenSim/Tools/pCampBot/pCampBot.cs
+++ b/OpenSim/Tools/pCampBot/pCampBot.cs
@@ -95,9 +95,9 @@ namespace pCampBot
95 "Spawns a set of bots to test an OpenSim region\n\n" + 95 "Spawns a set of bots to test an OpenSim region\n\n" +
96 " -l, -loginuri loginuri for sim to log into (required)\n" + 96 " -l, -loginuri loginuri for sim to log into (required)\n" +
97 " -n, -botcount number of bots to start (default: 1)\n" + 97 " -n, -botcount number of bots to start (default: 1)\n" +
98 " -firstname first name for the bot(s) (default: random string)\n" + 98 " -firstname first name for the bots\n" +
99 " -lastname lastname for the bot(s) (default: random string)\n" + 99 " -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" +
100 " -password password for the bots(s) (default: random string)\n" + 100 " -password password for the bots\n" +
101 " -wear set appearance folder to load from (default: no)\n" + 101 " -wear set appearance folder to load from (default: no)\n" +
102 " -h, -help show this message" 102 " -h, -help show this message"
103 ); 103 );