aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs8
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs119
-rwxr-xr-xOpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs277
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs5
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs202
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs16
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs187
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs176
-rw-r--r--OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs1
11 files changed, 843 insertions, 158 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 26934e8..00b1c1e 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -677,7 +677,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
677 public event DeRezObject OnDeRezObject; 677 public event DeRezObject OnDeRezObject;
678 public event Action<IClientAPI> OnRegionHandShakeReply; 678 public event Action<IClientAPI> OnRegionHandShakeReply;
679 public event GenericCall1 OnRequestWearables; 679 public event GenericCall1 OnRequestWearables;
680 public event GenericCall1 OnCompleteMovementToRegion; 680 public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
681 public event UpdateAgent OnPreAgentUpdate; 681 public event UpdateAgent OnPreAgentUpdate;
682 public event UpdateAgent OnAgentUpdate; 682 public event UpdateAgent OnAgentUpdate;
683 public event AgentRequestSit OnAgentRequestSit; 683 public event AgentRequestSit OnAgentRequestSit;
@@ -806,7 +806,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
806 public event ScriptReset OnScriptReset; 806 public event ScriptReset OnScriptReset;
807 public event GetScriptRunning OnGetScriptRunning; 807 public event GetScriptRunning OnGetScriptRunning;
808 public event SetScriptRunning OnSetScriptRunning; 808 public event SetScriptRunning OnSetScriptRunning;
809 public event UpdateVector OnAutoPilotGo; 809 public event Action<Vector3, bool> OnAutoPilotGo;
810 public event TerrainUnacked OnUnackedTerrain; 810 public event TerrainUnacked OnUnackedTerrain;
811 public event ActivateGesture OnActivateGesture; 811 public event ActivateGesture OnActivateGesture;
812 public event DeactivateGesture OnDeactivateGesture; 812 public event DeactivateGesture OnDeactivateGesture;
@@ -899,7 +899,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
899 899
900 public void Start() 900 public void Start()
901 { 901 {
902 Scene.AddNewClient(this); 902 Scene.AddNewClient(this, PresenceType.User);
903 903
904 // Mimicking LLClientView which gets always set appearance from client. 904 // Mimicking LLClientView which gets always set appearance from client.
905 Scene scene = (Scene)Scene; 905 Scene scene = (Scene)Scene;
@@ -919,7 +919,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
919 919
920 if (OnCompleteMovementToRegion != null) 920 if (OnCompleteMovementToRegion != null)
921 { 921 {
922 OnCompleteMovementToRegion(this); 922 OnCompleteMovementToRegion(this, true);
923 } 923 }
924 } 924 }
925 925
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
index ee52a39..d2f6327 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
@@ -47,16 +47,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
47 [Test] 47 [Test]
48 public void TestBasic() 48 public void TestBasic()
49 { 49 {
50 TestHelper.InMethod(); 50 TestHelpers.InMethod();
51// log4net.Config.XmlConfigurator.Configure(); 51// log4net.Config.XmlConfigurator.Configure();
52 52
53 TestScene scene = SceneSetupHelpers.SetupScene(); 53 TestScene scene = SceneHelpers.SetupScene();
54 IConfigSource configSource = new IniConfigSource(); 54 IConfigSource configSource = new IniConfigSource();
55 IConfig config = configSource.AddConfig("Groups"); 55 IConfig config = configSource.AddConfig("Groups");
56 config.Set("Enabled", true); 56 config.Set("Enabled", true);
57 config.Set("Module", "GroupsModule"); 57 config.Set("Module", "GroupsModule");
58 config.Set("DebugEnabled", true); 58 config.Set("DebugEnabled", true);
59 SceneSetupHelpers.SetupSceneModules( 59 SceneHelpers.SetupSceneModules(
60 scene, configSource, new object[] { new MockGroupsServicesConnector() }); 60 scene, configSource, new object[] { new MockGroupsServicesConnector() });
61 } 61 }
62 } 62 }
diff --git a/OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs b/OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs
new file mode 100644
index 0000000..a25e034
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs
@@ -0,0 +1,119 @@
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.Reflection;
30using System.Text;
31using log4net;
32using Mono.Addins;
33using Nini.Config;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Console;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39
40namespace OpenSim.Region.OptionalModules.Framework.Monitoring
41{
42 /// <summary>
43 /// An experimental module to return data on services used by the simulator.
44 /// </summary>
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MonitorServicesModule")]
46 public class MonitorServicesModule : ISharedRegionModule
47 {
48 protected Scene m_scene;
49
50// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 public string Name { get { return "Services Health Monitoring Module"; } }
53
54 public Type ReplaceableInterface { get { return null; } }
55
56 public void Initialise(IConfigSource source)
57 {
58 }
59
60 public void PostInitialise()
61 {
62 }
63
64 public void Close()
65 {
66 }
67
68 public void AddRegion(Scene scene)
69 {
70 if (m_scene == null)
71 {
72 m_scene = scene;
73
74// m_scene.AddCommand(this, "monitor services",
75// "monitor services",
76// "Returns the status of services used by the simulator. Experimental.",
77// HandleMonitorServices);
78 }
79 }
80
81 public void RemoveRegion(Scene scene)
82 {
83 }
84
85 public void RegionLoaded(Scene scene)
86 {
87 }
88
89 protected void HandleMonitorServices(string module, string[] args)
90 {
91 MainConsole.Instance.Output(GenerateServicesReport());
92 }
93
94 protected string GenerateServicesReport()
95 {
96 StringBuilder sb = new StringBuilder();
97 sb.Append("This is an experimental module. Please don't rely on these results\n");
98 sb.Append("Asset service: ");
99
100 try
101 {
102 CheckAssetService();
103 sb.Append("OK");
104 }
105 catch (Exception e)
106 {
107 sb.AppendFormat("FAIL ({0})", e.Message);
108 }
109
110 return sb.ToString();
111 }
112
113 protected void CheckAssetService()
114 {
115 // Try to fetch an asset that will not exist (and hence avoid hitting cache)
116 m_scene.AssetService.Get(UUID.Random().ToString());
117 }
118 }
119} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
new file mode 100755
index 0000000..2a44360
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
@@ -0,0 +1,277 @@
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.Reflection;
30using System.Collections.Generic;
31using log4net;
32using Mono.Addins;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Physics.Manager;
40
41namespace OpenSim.Region.OptionalModules.PhysicsParameters
42{
43 /// <summary>
44 /// </summary>
45 /// <remarks>
46 /// </remarks>
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "PhysicsParameters")]
48 public class PhysicsParameters : ISharedRegionModule
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 private static string LogHeader = "[PHYSICS PARAMETERS]";
52
53 private List<Scene> m_scenes = new List<Scene>();
54 private static bool m_commandsLoaded = false;
55
56 #region ISharedRegionModule
57 public string Name { get { return "Runtime Physics Parameter Module"; } }
58
59 public Type ReplaceableInterface { get { return null; } }
60
61 public void Initialise(IConfigSource source)
62 {
63 // m_log.DebugFormat("{0}: INITIALIZED MODULE", LogHeader);
64 }
65
66 public void PostInitialise()
67 {
68 // m_log.DebugFormat("[{0}: POST INITIALIZED MODULE", LogHeader);
69 InstallInterfaces();
70 }
71
72 public void Close()
73 {
74 // m_log.DebugFormat("{0}: CLOSED MODULE", LogHeader);
75 }
76
77 public void AddRegion(Scene scene)
78 {
79 // m_log.DebugFormat("{0}: REGION {1} ADDED", LogHeader, scene.RegionInfo.RegionName);
80 m_scenes.Add(scene);
81 }
82
83 public void RemoveRegion(Scene scene)
84 {
85 // m_log.DebugFormat("{0}: REGION {1} REMOVED", LogHeader, scene.RegionInfo.RegionName);
86 if (m_scenes.Contains(scene))
87 m_scenes.Remove(scene);
88 }
89
90 public void RegionLoaded(Scene scene)
91 {
92 // m_log.DebugFormat("{0}: REGION {1} LOADED", LogHeader, scene.RegionInfo.RegionName);
93 }
94 #endregion INonSharedRegionModule
95
96 private const string getInvocation = "physics get [<param>|ALL]";
97 private const string setInvocation = "physics set <param> [<value>|TRUE|FALSE] [localID|ALL]";
98 private const string listInvocation = "physics list";
99 private void InstallInterfaces()
100 {
101 if (!m_commandsLoaded)
102 {
103 MainConsole.Instance.Commands.AddCommand("Physics", false, "physics set",
104 "physics set",
105 "Set physics parameter from currently selected region" + Environment.NewLine
106 + "Invocation: " + setInvocation,
107 ProcessPhysicsSet);
108
109 MainConsole.Instance.Commands.AddCommand("Physics", false, "physics get",
110 "physics get",
111 "Get physics parameter from currently selected region" + Environment.NewLine
112 + "Invocation: " + getInvocation,
113 ProcessPhysicsGet);
114
115 MainConsole.Instance.Commands.AddCommand("Physics", false, "physics list",
116 "physics list",
117 "List settable physics parameters" + Environment.NewLine
118 + "Invocation: " + listInvocation,
119 ProcessPhysicsList);
120
121 m_commandsLoaded = true;
122 }
123 }
124
125 // TODO: extend get so you can get a value from an individual localID
126 private void ProcessPhysicsGet(string module, string[] cmdparms)
127 {
128 if (cmdparms.Length != 3)
129 {
130 WriteError("Parameter count error. Invocation: " + getInvocation);
131 return;
132 }
133 string parm = cmdparms[2];
134
135 if (SceneManager.Instance == null || SceneManager.Instance.CurrentScene == null)
136 {
137 WriteError("Error: no region selected. Use 'change region' to select a region.");
138 return;
139 }
140
141 Scene scene = SceneManager.Instance.CurrentScene;
142 IPhysicsParameters physScene = scene.PhysicsScene as IPhysicsParameters;
143 if (physScene != null)
144 {
145 if (parm.ToLower() == "all")
146 {
147 foreach (PhysParameterEntry ppe in physScene.GetParameterList())
148 {
149 float val = 0.0f;
150 if (physScene.GetPhysicsParameter(ppe.name, out val))
151 {
152 WriteOut(" {0}/{1} = {2}", scene.RegionInfo.RegionName, ppe.name, val);
153 }
154 else
155 {
156 WriteOut(" {0}/{1} = {2}", scene.RegionInfo.RegionName, ppe.name, "unknown");
157 }
158 }
159 }
160 else
161 {
162 float val = 0.0f;
163 if (physScene.GetPhysicsParameter(parm, out val))
164 {
165 WriteOut(" {0}/{1} = {2}", scene.RegionInfo.RegionName, parm, val);
166 }
167 else
168 {
169 WriteError("Failed fetch of parameter '{0}' from region '{1}'", parm, scene.RegionInfo.RegionName);
170 }
171 }
172 }
173 else
174 {
175 WriteError("Region '{0}' physics engine has no gettable physics parameters", scene.RegionInfo.RegionName);
176 }
177 return;
178 }
179
180 private void ProcessPhysicsSet(string module, string[] cmdparms)
181 {
182 if (cmdparms.Length < 4 || cmdparms.Length > 5)
183 {
184 WriteError("Parameter count error. Invocation: " + getInvocation);
185 return;
186 }
187 string parm = "xxx";
188 float val = 0f;
189 uint localID = (uint)PhysParameterEntry.APPLY_TO_NONE; // set default value
190 try
191 {
192 parm = cmdparms[2];
193 string valparm = cmdparms[3].ToLower();
194 if (valparm == "true")
195 val = PhysParameterEntry.NUMERIC_TRUE;
196 else
197 {
198 if (valparm == "false")
199 val = PhysParameterEntry.NUMERIC_FALSE;
200 else
201 val = float.Parse(valparm, Culture.NumberFormatInfo);
202 }
203 if (cmdparms.Length > 4)
204 {
205 if (cmdparms[4].ToLower() == "all")
206 localID = (uint)PhysParameterEntry.APPLY_TO_ALL;
207 else
208 localID = uint.Parse(cmdparms[2], Culture.NumberFormatInfo);
209 }
210 }
211 catch
212 {
213 WriteError(" Error parsing parameters. Invocation: " + setInvocation);
214 return;
215 }
216
217 if (SceneManager.Instance == null || SceneManager.Instance.CurrentScene == null)
218 {
219 WriteError("Error: no region selected. Use 'change region' to select a region.");
220 return;
221 }
222
223 Scene scene = SceneManager.Instance.CurrentScene;
224 IPhysicsParameters physScene = scene.PhysicsScene as IPhysicsParameters;
225 if (physScene != null)
226 {
227 if (!physScene.SetPhysicsParameter(parm, val, localID))
228 {
229 WriteError("Failed set of parameter '{0}' for region '{1}'", parm, scene.RegionInfo.RegionName);
230 }
231 }
232 else
233 {
234 WriteOut("Region '{0}'s physics engine has no settable physics parameters", scene.RegionInfo.RegionName);
235 }
236 return;
237 }
238
239 private void ProcessPhysicsList(string module, string[] cmdparms)
240 {
241 if (SceneManager.Instance == null || SceneManager.Instance.CurrentScene == null)
242 {
243 WriteError("Error: no region selected. Use 'change region' to select a region.");
244 return;
245 }
246 Scene scene = SceneManager.Instance.CurrentScene;
247
248 IPhysicsParameters physScene = scene.PhysicsScene as IPhysicsParameters;
249 if (physScene != null)
250 {
251 WriteOut("Available physics parameters:");
252 PhysParameterEntry[] parms = physScene.GetParameterList();
253 foreach (PhysParameterEntry ent in parms)
254 {
255 WriteOut(" {0}: {1}", ent.name, ent.desc);
256 }
257 }
258 else
259 {
260 WriteError("Current regions's physics engine has no settable physics parameters");
261 }
262 return;
263 }
264
265 private void WriteOut(string msg, params object[] args)
266 {
267 m_log.InfoFormat(msg, args);
268 // MainConsole.Instance.OutputFormat(msg, args);
269 }
270
271 private void WriteError(string msg, params object[] args)
272 {
273 m_log.ErrorFormat(msg, args);
274 // MainConsole.Instance.OutputFormat(msg, args);
275 }
276 }
277} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index 05c729a..963d1e2 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -126,6 +126,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
126 m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; 126 m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
127 m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; 127 m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded;
128 128
129 if(m_uri != string.Empty)
130 {
131 RRAlert("shutdown");
132 }
133
129 m_scene = null; 134 m_scene = null;
130 } 135 }
131 136
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
index d18ac0a..2187449 100644
--- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
106 info.channel = channel; 106 info.channel = channel;
107 info.uri = uri; 107 info.uri = uri;
108 108
109 bool success = SynchronousRestObjectPoster.BeginPostObject<XmlRpcInfo, bool>( 109 bool success = SynchronousRestObjectRequester.MakeRequest<XmlRpcInfo, bool>(
110 "POST", m_ServerURI+"/RegisterChannel/", info); 110 "POST", m_ServerURI+"/RegisterChannel/", info);
111 111
112 if (!success) 112 if (!success)
@@ -125,7 +125,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
125 125
126 if (m_Channels.ContainsKey(itemID)) 126 if (m_Channels.ContainsKey(itemID))
127 { 127 {
128 bool success = SynchronousRestObjectPoster.BeginPostObject<UUID, bool>( 128 bool success = SynchronousRestObjectRequester.MakeRequest<UUID, bool>(
129 "POST", m_ServerURI+"/RemoveChannel/", m_Channels[itemID]); 129 "POST", m_ServerURI+"/RemoveChannel/", m_Channels[itemID]);
130 130
131 if (!success) 131 if (!success)
diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
index 2db718c..f9e118b 100644
--- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
+++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
@@ -23,104 +23,104 @@
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31 31
32namespace OpenSim.Region.OptionalModules.World.AutoBackup 32namespace OpenSim.Region.OptionalModules.World.AutoBackup
33{ 33{
34 /// <summary>AutoBackupModuleState: Auto-Backup state for one region (scene). 34 /// <summary>AutoBackupModuleState: Auto-Backup state for one region (scene).
35 /// If you use this class in any way outside of AutoBackupModule, you should treat the class as opaque. 35 /// If you use this class in any way outside of AutoBackupModule, you should treat the class as opaque.
36 /// Since it is not part of the framework, you really should not rely upon it outside of the AutoBackupModule implementation. 36 /// Since it is not part of the framework, you really should not rely upon it outside of the AutoBackupModule implementation.
37 /// </summary> 37 /// </summary>
38 /// 38 ///
39 public class AutoBackupModuleState 39 public class AutoBackupModuleState
40 { 40 {
41 private Dictionary<Guid, string> m_liveRequests = null; 41 private Dictionary<Guid, string> m_liveRequests = null;
42 42
43 public AutoBackupModuleState() 43 public AutoBackupModuleState()
44 { 44 {
45 this.Enabled = false; 45 this.Enabled = false;
46 this.BackupDir = "."; 46 this.BackupDir = ".";
47 this.BusyCheck = true; 47 this.BusyCheck = true;
48 this.Timer = null; 48 this.Timer = null;
49 this.NamingType = NamingType.Time; 49 this.NamingType = NamingType.Time;
50 this.Script = null; 50 this.Script = null;
51 } 51 }
52 52
53 public Dictionary<Guid, string> LiveRequests 53 public Dictionary<Guid, string> LiveRequests
54 { 54 {
55 get { 55 get {
56 return this.m_liveRequests ?? 56 return this.m_liveRequests ??
57 (this.m_liveRequests = new Dictionary<Guid, string>(1)); 57 (this.m_liveRequests = new Dictionary<Guid, string>(1));
58 } 58 }
59 } 59 }
60 60
61 public bool Enabled 61 public bool Enabled
62 { 62 {
63 get; 63 get;
64 set; 64 set;
65 } 65 }
66 66
67 public System.Timers.Timer Timer 67 public System.Timers.Timer Timer
68 { 68 {
69 get; 69 get;
70 set; 70 set;
71 } 71 }
72 72
73 public double IntervalMinutes 73 public double IntervalMinutes
74 { 74 {
75 get 75 get
76 { 76 {
77 if (this.Timer == null) 77 if (this.Timer == null)
78 { 78 {
79 return -1.0; 79 return -1.0;
80 } 80 }
81 else 81 else
82 { 82 {
83 return this.Timer.Interval / 60000.0; 83 return this.Timer.Interval / 60000.0;
84 } 84 }
85 } 85 }
86 } 86 }
87 87
88 public bool BusyCheck 88 public bool BusyCheck
89 { 89 {
90 get; 90 get;
91 set; 91 set;
92 } 92 }
93 93
94 public string Script 94 public string Script
95 { 95 {
96 get; 96 get;
97 set; 97 set;
98 } 98 }
99 99
100 public string BackupDir 100 public string BackupDir
101 { 101 {
102 get; 102 get;
103 set; 103 set;
104 } 104 }
105 105
106 public NamingType NamingType 106 public NamingType NamingType
107 { 107 {
108 get; 108 get;
109 set; 109 set;
110 } 110 }
111 111
112 public new string ToString() 112 public new string ToString()
113 { 113 {
114 string retval = ""; 114 string retval = "";
115 115
116 retval += "[AUTO BACKUP]: AutoBackup: " + (Enabled ? "ENABLED" : "DISABLED") + "\n"; 116 retval += "[AUTO BACKUP]: AutoBackup: " + (Enabled ? "ENABLED" : "DISABLED") + "\n";
117 retval += "[AUTO BACKUP]: Interval: " + IntervalMinutes + " minutes" + "\n"; 117 retval += "[AUTO BACKUP]: Interval: " + IntervalMinutes + " minutes" + "\n";
118 retval += "[AUTO BACKUP]: Do Busy Check: " + (BusyCheck ? "Yes" : "No") + "\n"; 118 retval += "[AUTO BACKUP]: Do Busy Check: " + (BusyCheck ? "Yes" : "No") + "\n";
119 retval += "[AUTO BACKUP]: Naming Type: " + NamingType.ToString() + "\n"; 119 retval += "[AUTO BACKUP]: Naming Type: " + NamingType.ToString() + "\n";
120 retval += "[AUTO BACKUP]: Backup Dir: " + BackupDir + "\n"; 120 retval += "[AUTO BACKUP]: Backup Dir: " + BackupDir + "\n";
121 retval += "[AUTO BACKUP]: Script: " + Script + "\n"; 121 retval += "[AUTO BACKUP]: Script: " + Script + "\n";
122 return retval; 122 return retval;
123 } 123 }
124 } 124 }
125} 125}
126 126
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 69d6261..4f831a4 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -37,6 +37,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
37{ 37{
38 public class NPCAvatar : IClientAPI 38 public class NPCAvatar : IClientAPI
39 { 39 {
40 /// <summary>
41 /// Signal whether the avatar should land when it reaches a move target
42 /// </summary>
43 public bool LandAtTarget { get; set; }
44
40 private readonly string m_firstname; 45 private readonly string m_firstname;
41 private readonly string m_lastname; 46 private readonly string m_lastname;
42 private readonly Vector3 m_startPos; 47 private readonly Vector3 m_startPos;
@@ -99,6 +104,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
99 { 104 {
100 105
101 } 106 }
107
102 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, 108 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
103 Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) 109 Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
104 { 110 {
@@ -189,7 +195,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
189 public event DeRezObject OnDeRezObject; 195 public event DeRezObject OnDeRezObject;
190 public event Action<IClientAPI> OnRegionHandShakeReply; 196 public event Action<IClientAPI> OnRegionHandShakeReply;
191 public event GenericCall1 OnRequestWearables; 197 public event GenericCall1 OnRequestWearables;
192 public event GenericCall1 OnCompleteMovementToRegion; 198 public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
193 public event UpdateAgent OnPreAgentUpdate; 199 public event UpdateAgent OnPreAgentUpdate;
194 public event UpdateAgent OnAgentUpdate; 200 public event UpdateAgent OnAgentUpdate;
195 public event AgentRequestSit OnAgentRequestSit; 201 public event AgentRequestSit OnAgentRequestSit;
@@ -327,7 +333,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
327 public event ScriptReset OnScriptReset; 333 public event ScriptReset OnScriptReset;
328 public event GetScriptRunning OnGetScriptRunning; 334 public event GetScriptRunning OnGetScriptRunning;
329 public event SetScriptRunning OnSetScriptRunning; 335 public event SetScriptRunning OnSetScriptRunning;
330 public event UpdateVector OnAutoPilotGo; 336 public event Action<Vector3, bool> OnAutoPilotGo;
331 337
332 public event TerrainUnacked OnUnackedTerrain; 338 public event TerrainUnacked OnUnackedTerrain;
333 339
@@ -744,12 +750,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
744 { 750 {
745 OnRegionHandShakeReply(this); 751 OnRegionHandShakeReply(this);
746 } 752 }
747
748 if (OnCompleteMovementToRegion != null)
749 {
750 OnCompleteMovementToRegion(this);
751 }
752 } 753 }
754
753 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) 755 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
754 { 756 {
755 } 757 }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 3cdd06d..2fdeeab 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -44,32 +44,119 @@ namespace OpenSim.Region.OptionalModules.World.NPC
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 // private const bool m_enabled = false; 47 private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
48
49 private Dictionary<UUID,NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
50 private Dictionary<UUID,AvatarAppearance> m_appearanceCache = new Dictionary<UUID, AvatarAppearance>();
51 48
52 public void Initialise(Scene scene, IConfigSource source) 49 public void Initialise(Scene scene, IConfigSource source)
53 { 50 {
54 scene.RegisterModuleInterface<INPCModule>(this); 51 IConfig config = source.Configs["NPC"];
52
53 if (config != null && config.GetBoolean("Enabled", false))
54 {
55 scene.RegisterModuleInterface<INPCModule>(this);
56 scene.EventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement;
57 }
55 } 58 }
56 59
57 private AvatarAppearance GetAppearance(UUID target, Scene scene) 60 public void HandleOnSignificantClientMovement(ScenePresence presence)
58 { 61 {
59 if (m_appearanceCache.ContainsKey(target)) 62 lock (m_avatars)
60 return m_appearanceCache[target];
61
62 AvatarAppearance appearance = scene.AvatarService.GetAppearance(target);
63 if (appearance != null)
64 { 63 {
65 m_appearanceCache.Add(target, appearance); 64 if (m_avatars.ContainsKey(presence.UUID) && presence.MovingToTarget)
66 return appearance; 65 {
66 double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget);
67// m_log.DebugFormat(
68// "[NPC MODULE]: Abs pos of {0} is {1}, target {2}, distance {3}",
69// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget);
70
71 // Check the error term of the current position in relation to the target position
72 if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT)
73 {
74 // We are close enough to the target
75 m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name);
76
77 presence.Velocity = Vector3.Zero;
78 presence.AbsolutePosition = presence.MoveToPositionTarget;
79 presence.ResetMoveToTarget();
80
81 if (presence.PhysicsActor.Flying)
82 {
83 // A horrible hack to stop the NPC dead in its tracks rather than having them overshoot
84 // the target if flying.
85 // We really need to be more subtle (slow the avatar as it approaches the target) or at
86 // least be able to set collision status once, rather than 5 times to give it enough
87 // weighting so that that PhysicsActor thinks it really is colliding.
88 for (int i = 0; i < 5; i++)
89 presence.PhysicsActor.IsColliding = true;
90
91// Vector3 targetPos = presence.MoveToPositionTarget;
92 if (m_avatars[presence.UUID].LandAtTarget)
93 presence.PhysicsActor.Flying = false;
94
95// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
96// if (targetPos.Z - terrainHeight < 0.2)
97// {
98// presence.PhysicsActor.Flying = false;
99// }
100 }
101
102// m_log.DebugFormat(
103// "[NPC MODULE]: AgentControlFlags {0}, MovementFlag {1} for {2}",
104// presence.AgentControlFlags, presence.MovementFlag, presence.Name);
105 }
106 else
107 {
108// m_log.DebugFormat(
109// "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}",
110// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget);
111
112 Vector3 agent_control_v3 = new Vector3();
113 presence.HandleMoveToTargetUpdate(ref agent_control_v3);
114 presence.AddNewMovement(agent_control_v3);
115 }
116//
117//// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null);
118
119//
120//
121
122 }
67 } 123 }
124 }
125
126 public bool IsNPC(UUID agentId, Scene scene)
127 {
128 ScenePresence sp = scene.GetScenePresence(agentId);
129 if (sp == null || sp.IsChildAgent)
130 return false;
68 131
69 return new AvatarAppearance(); 132 lock (m_avatars)
133 return m_avatars.ContainsKey(agentId);
70 } 134 }
71 135
72 public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) 136 public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene)
137 {
138 ScenePresence sp = scene.GetScenePresence(agentId);
139 if (sp == null || sp.IsChildAgent)
140 return false;
141
142 lock (m_avatars)
143 if (!m_avatars.ContainsKey(agentId))
144 return false;
145
146 scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false);
147
148 AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
149 sp.Appearance = npcAppearance;
150 scene.AttachmentsModule.RezAttachments(sp);
151
152 IAvatarFactory module = scene.RequestModuleInterface<IAvatarFactory>();
153 module.SendAppearance(sp.UUID);
154
155 return true;
156 }
157
158 public UUID CreateNPC(
159 string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance)
73 { 160 {
74 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); 161 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene);
75 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); 162 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
@@ -84,12 +171,18 @@ namespace OpenSim.Region.OptionalModules.World.NPC
84 acd.lastname = lastname; 171 acd.lastname = lastname;
85 acd.ServiceURLs = new Dictionary<string, object>(); 172 acd.ServiceURLs = new Dictionary<string, object>();
86 173
87 AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene); 174 AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
88 AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true);
89 acd.Appearance = npcAppearance; 175 acd.Appearance = npcAppearance;
90 176
177// for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++)
178// {
179// m_log.DebugFormat(
180// "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
181// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
182// }
183
91 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); 184 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
92 scene.AddNewClient(npcAvatar); 185 scene.AddNewClient(npcAvatar, PresenceType.Npc);
93 186
94 ScenePresence sp; 187 ScenePresence sp;
95 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) 188 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
@@ -97,13 +190,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
97 m_log.DebugFormat( 190 m_log.DebugFormat(
98 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); 191 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
99 192
100 // Shouldn't call this - temporary. 193 sp.CompleteMovement(npcAvatar, false);
101 sp.CompleteMovement(npcAvatar);
102
103// sp.SendAppearanceToAllOtherAgents();
104//
105// // Send animations back to the avatar as well
106// sp.Animator.SendAnimPack();
107 } 194 }
108 else 195 else
109 { 196 {
@@ -118,7 +205,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC
118 return npcAvatar.AgentId; 205 return npcAvatar.AgentId;
119 } 206 }
120 207
121 public void Autopilot(UUID agentID, Scene scene, Vector3 pos) 208 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget)
209 {
210 lock (m_avatars)
211 {
212 if (m_avatars.ContainsKey(agentID))
213 {
214 ScenePresence sp;
215 scene.TryGetScenePresence(agentID, out sp);
216
217 m_log.DebugFormat(
218 "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
219 sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget);
220
221 m_avatars[agentID].LandAtTarget = landAtTarget;
222 sp.MoveToTarget(pos, noFly);
223
224 return true;
225 }
226 }
227
228 return false;
229 }
230
231 public bool StopMoveToTarget(UUID agentID, Scene scene)
122 { 232 {
123 lock (m_avatars) 233 lock (m_avatars)
124 { 234 {
@@ -126,32 +236,49 @@ namespace OpenSim.Region.OptionalModules.World.NPC
126 { 236 {
127 ScenePresence sp; 237 ScenePresence sp;
128 scene.TryGetScenePresence(agentID, out sp); 238 scene.TryGetScenePresence(agentID, out sp);
129 sp.DoAutoPilot(0, pos, m_avatars[agentID]); 239
240 sp.Velocity = Vector3.Zero;
241 sp.ResetMoveToTarget();
242
243 return true;
130 } 244 }
131 } 245 }
246
247 return false;
132 } 248 }
133 249
134 public void Say(UUID agentID, Scene scene, string text) 250 public bool Say(UUID agentID, Scene scene, string text)
135 { 251 {
136 lock (m_avatars) 252 lock (m_avatars)
137 { 253 {
138 if (m_avatars.ContainsKey(agentID)) 254 if (m_avatars.ContainsKey(agentID))
139 { 255 {
256 ScenePresence sp;
257 scene.TryGetScenePresence(agentID, out sp);
258
140 m_avatars[agentID].Say(text); 259 m_avatars[agentID].Say(text);
260
261 return true;
141 } 262 }
142 } 263 }
264
265 return false;
143 } 266 }
144 267
145 public void DeleteNPC(UUID agentID, Scene scene) 268 public bool DeleteNPC(UUID agentID, Scene scene)
146 { 269 {
147 lock (m_avatars) 270 lock (m_avatars)
148 { 271 {
149 if (m_avatars.ContainsKey(agentID)) 272 if (m_avatars.ContainsKey(agentID))
150 { 273 {
151 scene.RemoveClient(agentID); 274 scene.RemoveClient(agentID, false);
152 m_avatars.Remove(agentID); 275 m_avatars.Remove(agentID);
276
277 return true;
153 } 278 }
154 } 279 }
280
281 return false;
155 } 282 }
156 283
157 public void PostInitialise() 284 public void PostInitialise()
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 899e721..246bc34 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -26,12 +26,18 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
31using log4net;
30using Nini.Config; 32using Nini.Config;
31using NUnit.Framework; 33using NUnit.Framework;
32using OpenMetaverse; 34using OpenMetaverse;
33using OpenSim.Framework; 35using OpenSim.Framework;
34using OpenSim.Framework.Communications; 36using OpenSim.Framework.Communications;
37using OpenSim.Region.CoreModules.Avatar.Attachments;
38using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
39using OpenSim.Region.CoreModules.Framework.InventoryAccess;
40using OpenSim.Region.CoreModules.Framework.UserManagement;
35using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; 41using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
36using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
@@ -44,28 +50,178 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
44 [TestFixture] 50 [TestFixture]
45 public class NPCModuleTests 51 public class NPCModuleTests
46 { 52 {
53 private TestScene scene;
54 private AvatarFactoryModule afm;
55 private UserManagementModule umm;
56 private AttachmentsModule am;
57
58 [TestFixtureSetUp]
59 public void FixtureInit()
60 {
61 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
62 Util.FireAndForgetMethod = FireAndForgetMethod.None;
63 }
64
65 [TestFixtureTearDown]
66 public void TearDown()
67 {
68 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
69 // threads. Possibly, later tests should be rewritten not to worry about such things.
70 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
71 }
72
73 [SetUp]
74 public void Init()
75 {
76 IConfigSource config = new IniConfigSource();
77 config.AddConfig("NPC");
78 config.Configs["NPC"].Set("Enabled", "true");
79 config.AddConfig("Modules");
80 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
81
82 afm = new AvatarFactoryModule();
83 umm = new UserManagementModule();
84 am = new AttachmentsModule();
85
86 scene = SceneHelpers.SetupScene();
87 SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule());
88 }
89
47 [Test] 90 [Test]
48 public void TestCreate() 91 public void TestCreate()
49 { 92 {
50 TestHelper.InMethod(); 93 TestHelpers.InMethod();
51// log4net.Config.XmlConfigurator.Configure(); 94// log4net.Config.XmlConfigurator.Configure();
52 95
53 IConfigSource config = new IniConfigSource(); 96 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
97// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
54 98
55 config.AddConfig("Modules"); 99 // 8 is the index of the first baked texture in AvatarAppearance
56 config.Configs["Modules"].Set("AvatarServices", "LocalAvatarServicesConnector"); 100 UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
57 config.AddConfig("AvatarService"); 101 Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
58 config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService"); 102 Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
59 config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); 103 originalTef.TextureID = originalFace8TextureId;
104
105 // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
106 // ScenePresence.SendInitialData() to reset our entire appearance.
107 scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId));
60 108
61 TestScene scene = SceneSetupHelpers.SetupScene(); 109 afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null);
62 SceneSetupHelpers.SetupSceneModules(scene, config, new NPCModule(), new LocalAvatarServicesConnector());
63 110
64 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 111 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
65 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, UUID.Zero); 112 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);
66 113
67 ScenePresence npc = scene.GetScenePresence(npcId); 114 ScenePresence npc = scene.GetScenePresence(npcId);
115
68 Assert.That(npc, Is.Not.Null); 116 Assert.That(npc, Is.Not.Null);
117 Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
118 Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
119 }
120
121 [Test]
122 public void TestAttachments()
123 {
124 TestHelpers.InMethod();
125// log4net.Config.XmlConfigurator.Configure();
126
127 UUID userId = TestHelpers.ParseTail(0x1);
128 UserAccountHelpers.CreateUserWithInventory(scene, userId);
129 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
130
131 UUID attItemId = TestHelpers.ParseTail(0x2);
132 UUID attAssetId = TestHelpers.ParseTail(0x3);
133 string attName = "att";
134
135 UserInventoryHelpers.CreateInventoryItem(
136 scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
137
138 am.RezSingleAttachmentFromInventory(
139 sp.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
140
141 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
142 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);
143
144 ScenePresence npc = scene.GetScenePresence(npcId);
145
146 // Check scene presence status
147 Assert.That(npc.HasAttachments(), Is.True);
148 List<SceneObjectGroup> attachments = npc.GetAttachments();
149 Assert.That(attachments.Count, Is.EqualTo(1));
150 SceneObjectGroup attSo = attachments[0];
151
152 // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
153 // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
154// Assert.That(attSo.Name, Is.EqualTo(attName));
155
156 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
157 Assert.That(attSo.IsAttachment);
158 Assert.That(attSo.UsesPhysics, Is.False);
159 Assert.That(attSo.IsTemporary, Is.False);
160 Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
161 }
162
163 [Test]
164 public void TestMove()
165 {
166 TestHelpers.InMethod();
167// log4net.Config.XmlConfigurator.Configure();
168
169 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
170// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
171
172 Vector3 startPos = new Vector3(128, 128, 30);
173 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
174 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance);
175
176 ScenePresence npc = scene.GetScenePresence(npcId);
177 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
178
179 // For now, we'll make the scene presence fly to simplify this test, but this needs to change.
180 npc.PhysicsActor.Flying = true;
181
182 scene.Update();
183 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
184
185 Vector3 targetPos = startPos + new Vector3(0, 0, 10);
186 npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false);
187
188 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
189
190 scene.Update();
191
192 // We should really check the exact figure.
193 Assert.That(npc.AbsolutePosition.X, Is.EqualTo(startPos.X));
194 Assert.That(npc.AbsolutePosition.Y, Is.EqualTo(startPos.Y));
195 Assert.That(npc.AbsolutePosition.Z, Is.GreaterThan(startPos.Z));
196 Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.Z));
197
198 for (int i = 0; i < 10; i++)
199 scene.Update();
200
201 double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
202 Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move");
203 Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
204 Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE));
205
206 // Try a second movement
207 startPos = npc.AbsolutePosition;
208 targetPos = startPos + new Vector3(10, 0, 0);
209 npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false);
210
211 scene.Update();
212
213 // We should really check the exact figure.
214 Assert.That(npc.AbsolutePosition.X, Is.GreaterThan(startPos.X));
215 Assert.That(npc.AbsolutePosition.X, Is.LessThan(targetPos.X));
216 Assert.That(npc.AbsolutePosition.Y, Is.EqualTo(startPos.Y));
217 Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z));
218
219 for (int i = 0; i < 10; i++)
220 scene.Update();
221
222 distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
223 Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move");
224 Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
69 } 225 }
70 } 226 }
71} \ No newline at end of file 227} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
index 2563361..38c2f7b 100644
--- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
+++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
@@ -381,7 +381,6 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
381 { 381 {
382 SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; 382 SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
383 383
384
385 m_scene.DeleteSceneObject(selectedTree.ParentGroup, false); 384 m_scene.DeleteSceneObject(selectedTree.ParentGroup, false);
386 m_scene.ForEachClient(delegate(IClientAPI controller) 385 m_scene.ForEachClient(delegate(IClientAPI controller)
387 { 386 {