aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
authorDan Lake2012-03-27 12:51:58 -0700
committerDan Lake2012-03-27 12:51:58 -0700
commit971d32fda3cf8384987a6709cd2242afecce13ab (patch)
tree2607c27fad429ff0036fe7b7d275ddf717397282 /OpenSim/Region/OptionalModules
parentWhen loading objects from DB, first add to scene, then call TriggerOnSceneObj... (diff)
parentHG: beginning of a more restrictive inventory access procedure (optional). Ex... (diff)
downloadopensim-SC-971d32fda3cf8384987a6709cd2242afecce13ab.zip
opensim-SC-971d32fda3cf8384987a6709cd2242afecce13ab.tar.gz
opensim-SC-971d32fda3cf8384987a6709cd2242afecce13ab.tar.bz2
opensim-SC-971d32fda3cf8384987a6709cd2242afecce13ab.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs5
-rw-r--r--OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs14
-rw-r--r--OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs10
-rwxr-xr-xOpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs34
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs15
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs174
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs8
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs20
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs149
11 files changed, 317 insertions, 118 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index d3c96e2..5cf478a 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -1203,11 +1203,6 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1203 1203
1204 } 1204 }
1205 1205
1206 public UUID GetDefaultAnimation(string name)
1207 {
1208 return UUID.Zero;
1209 }
1210
1211 public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, byte[] charterMember, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID) 1206 public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, byte[] charterMember, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID)
1212 { 1207 {
1213 1208
diff --git a/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs
index 439096a..c897aa5 100644
--- a/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs
@@ -92,7 +92,7 @@ namespace OpenSim.Region.OptionalModules.Agent.TextureSender
92 m_scene = scene; 92 m_scene = scene;
93 93
94 MainConsole.Instance.Commands.AddCommand( 94 MainConsole.Instance.Commands.AddCommand(
95 "j2k", 95 "Assets",
96 false, 96 false,
97 "j2k decode", 97 "j2k decode",
98 "j2k decode <ID>", 98 "j2k decode <ID>",
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
index 261029c..a7ebecc 100644
--- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
@@ -82,19 +82,19 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
82 m_scenes[scene.RegionInfo.RegionID] = scene; 82 m_scenes[scene.RegionInfo.RegionID] = scene;
83 83
84 scene.AddCommand( 84 scene.AddCommand(
85 this, "image queues clear", 85 "Comms", this, "image queues clear",
86 "image queues clear <first-name> <last-name>", 86 "image queues clear <first-name> <last-name>",
87 "Clear the image queues (textures downloaded via UDP) for a particular client.", 87 "Clear the image queues (textures downloaded via UDP) for a particular client.",
88 (mod, cmd) => MainConsole.Instance.Output(HandleImageQueuesClear(cmd))); 88 (mod, cmd) => MainConsole.Instance.Output(HandleImageQueuesClear(cmd)));
89 89
90 scene.AddCommand( 90 scene.AddCommand(
91 this, "image queues show", 91 "Comms", this, "image queues show",
92 "image queues show <first-name> <last-name>", 92 "image queues show <first-name> <last-name>",
93 "Show the image queues (textures downloaded via UDP) for a particular client.", 93 "Show the image queues (textures downloaded via UDP) for a particular client.",
94 (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd))); 94 (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd)));
95 95
96 scene.AddCommand( 96 scene.AddCommand(
97 this, "show pqueues", 97 "Comms", this, "show pqueues",
98 "show pqueues [full]", 98 "show pqueues [full]",
99 "Show priority queue data for each client", 99 "Show priority queue data for each client",
100 "Without the 'full' option, only root agents are shown." 100 "Without the 'full' option, only root agents are shown."
@@ -102,7 +102,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
102 (mod, cmd) => MainConsole.Instance.Output(GetPQueuesReport(cmd))); 102 (mod, cmd) => MainConsole.Instance.Output(GetPQueuesReport(cmd)));
103 103
104 scene.AddCommand( 104 scene.AddCommand(
105 this, "show queues", 105 "Comms", this, "show queues",
106 "show queues [full]", 106 "show queues [full]",
107 "Show queue data for each client", 107 "Show queue data for each client",
108 "Without the 'full' option, only root agents are shown." 108 "Without the 'full' option, only root agents are shown."
@@ -110,13 +110,13 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
110 (mod, cmd) => MainConsole.Instance.Output(GetQueuesReport(cmd))); 110 (mod, cmd) => MainConsole.Instance.Output(GetQueuesReport(cmd)));
111 111
112 scene.AddCommand( 112 scene.AddCommand(
113 this, "show image queues", 113 "Comms", this, "show image queues",
114 "show image queues <first-name> <last-name>", 114 "show image queues <first-name> <last-name>",
115 "Show the image queues (textures downloaded via UDP) for a particular client.", 115 "Show the image queues (textures downloaded via UDP) for a particular client.",
116 (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd))); 116 (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd)));
117 117
118 scene.AddCommand( 118 scene.AddCommand(
119 this, "show throttles", 119 "Comms", this, "show throttles",
120 "show throttles [full]", 120 "show throttles [full]",
121 "Show throttle settings for each client and for the server overall", 121 "Show throttle settings for each client and for the server overall",
122 "Without the 'full' option, only root agents are shown." 122 "Without the 'full' option, only root agents are shown."
@@ -124,7 +124,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
124 (mod, cmd) => MainConsole.Instance.Output(GetThrottlesReport(cmd))); 124 (mod, cmd) => MainConsole.Instance.Output(GetThrottlesReport(cmd)));
125 125
126 scene.AddCommand( 126 scene.AddCommand(
127 this, "emergency-monitoring", 127 "Comms", this, "emergency-monitoring",
128 "emergency-monitoring", 128 "emergency-monitoring",
129 "Go on/off emergency monitoring mode", 129 "Go on/off emergency monitoring mode",
130 "Go on/off emergency monitoring mode", 130 "Go on/off emergency monitoring mode",
diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
index a5207eb..41ec14f 100644
--- a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
@@ -88,7 +88,7 @@ namespace OpenSim.Region.OptionalModules.Asset
88 m_scene = scene; 88 m_scene = scene;
89 89
90 MainConsole.Instance.Commands.AddCommand( 90 MainConsole.Instance.Commands.AddCommand(
91 "asset", 91 "Assets",
92 false, 92 false,
93 "show asset", 93 "show asset",
94 "show asset <ID>", 94 "show asset <ID>",
@@ -96,7 +96,7 @@ namespace OpenSim.Region.OptionalModules.Asset
96 HandleShowAsset); 96 HandleShowAsset);
97 97
98 MainConsole.Instance.Commands.AddCommand( 98 MainConsole.Instance.Commands.AddCommand(
99 "asset", false, "dump asset", 99 "Assets", false, "dump asset",
100 "dump asset <id>", 100 "dump asset <id>",
101 "Dump an asset", 101 "Dump an asset",
102 HandleDumpAsset); 102 HandleDumpAsset);
diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
index 2369d94..6bb6729 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
@@ -94,13 +94,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
94 m_scenes[scene.RegionInfo.RegionID] = scene; 94 m_scenes[scene.RegionInfo.RegionID] = scene;
95 95
96 scene.AddCommand( 96 scene.AddCommand(
97 this, "show appearance", 97 "Users", this, "show appearance",
98 "show appearance [<first-name> <last-name>]", 98 "show appearance [<first-name> <last-name>]",
99 "Synonym for 'appearance show'", 99 "Synonym for 'appearance show'",
100 HandleShowAppearanceCommand); 100 HandleShowAppearanceCommand);
101 101
102 scene.AddCommand( 102 scene.AddCommand(
103 this, "appearance show", 103 "Users", this, "appearance show",
104 "appearance show [<first-name> <last-name>]", 104 "appearance show [<first-name> <last-name>]",
105 "Show appearance information for each avatar in the simulator.", 105 "Show appearance information for each avatar in the simulator.",
106 "This command checks whether the simulator has all the baked textures required to display an avatar to other viewers. " 106 "This command checks whether the simulator has all the baked textures required to display an avatar to other viewers. "
@@ -110,14 +110,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
110 HandleShowAppearanceCommand); 110 HandleShowAppearanceCommand);
111 111
112 scene.AddCommand( 112 scene.AddCommand(
113 this, "appearance send", 113 "Users", this, "appearance send",
114 "appearance send [<first-name> <last-name>]", 114 "appearance send [<first-name> <last-name>]",
115 "Send appearance data for each avatar in the simulator to other viewers.", 115 "Send appearance data for each avatar in the simulator to other viewers.",
116 "Optionally, you can specify that only a particular avatar's appearance data is sent.", 116 "Optionally, you can specify that only a particular avatar's appearance data is sent.",
117 HandleSendAppearanceCommand); 117 HandleSendAppearanceCommand);
118 118
119 scene.AddCommand( 119 scene.AddCommand(
120 this, "appearance rebake", 120 "Users", this, "appearance rebake",
121 "appearance rebake <first-name> <last-name>", 121 "appearance rebake <first-name> <last-name>",
122 "Send a request to the user's viewer for it to rebake and reupload its appearance textures.", 122 "Send a request to the user's viewer for it to rebake and reupload its appearance textures.",
123 "This is currently done for all baked texture references previously received, whether the simulator can find the asset or not." 123 "This is currently done for all baked texture references previously received, whether the simulator can find the asset or not."
@@ -127,7 +127,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
127 HandleRebakeAppearanceCommand); 127 HandleRebakeAppearanceCommand);
128 128
129 scene.AddCommand( 129 scene.AddCommand(
130 this, "appearance find", 130 "Users", this, "appearance find",
131 "appearance find <uuid-or-start-of-uuid>", 131 "appearance find <uuid-or-start-of-uuid>",
132 "Find out which avatar uses the given asset as a baked texture, if any.", 132 "Find out which avatar uses the given asset as a baked texture, if any.",
133 "You can specify just the beginning of the uuid, e.g. 2008a8d. A longer UUID must be in dashed format.", 133 "You can specify just the beginning of the uuid, e.g. 2008a8d. A longer UUID must be in dashed format.",
diff --git a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
index 23ef757..e452124 100755
--- a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
+++ b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
@@ -100,22 +100,22 @@ namespace OpenSim.Region.OptionalModules.PhysicsParameters
100 { 100 {
101 if (!m_commandsLoaded) 101 if (!m_commandsLoaded)
102 { 102 {
103 MainConsole.Instance.Commands.AddCommand("Physics", false, "physics set", 103 MainConsole.Instance.Commands.AddCommand(
104 "physics set", 104 "Regions", false, "physics set",
105 "Set physics parameter from currently selected region" + Environment.NewLine 105 setInvocation,
106 + "Invocation: " + setInvocation, 106 "Set physics parameter from currently selected region",
107 ProcessPhysicsSet); 107 ProcessPhysicsSet);
108 108
109 MainConsole.Instance.Commands.AddCommand("Physics", false, "physics get", 109 MainConsole.Instance.Commands.AddCommand(
110 "physics get", 110 "Regions", false, "physics get",
111 "Get physics parameter from currently selected region" + Environment.NewLine 111 getInvocation,
112 + "Invocation: " + getInvocation, 112 "Get physics parameter from currently selected region",
113 ProcessPhysicsGet); 113 ProcessPhysicsGet);
114 114
115 MainConsole.Instance.Commands.AddCommand("Physics", false, "physics list", 115 MainConsole.Instance.Commands.AddCommand(
116 "physics list", 116 "Regions", false, "physics list",
117 "List settable physics parameters" + Environment.NewLine 117 listInvocation,
118 + "Invocation: " + listInvocation, 118 "List settable physics parameters",
119 ProcessPhysicsList); 119 ProcessPhysicsList);
120 120
121 m_commandsLoaded = true; 121 m_commandsLoaded = true;
@@ -264,14 +264,14 @@ namespace OpenSim.Region.OptionalModules.PhysicsParameters
264 264
265 private void WriteOut(string msg, params object[] args) 265 private void WriteOut(string msg, params object[] args)
266 { 266 {
267 m_log.InfoFormat(msg, args); 267 // m_log.InfoFormat(msg, args);
268 // MainConsole.Instance.OutputFormat(msg, args); 268 MainConsole.Instance.OutputFormat(msg, args);
269 } 269 }
270 270
271 private void WriteError(string msg, params object[] args) 271 private void WriteError(string msg, params object[] args)
272 { 272 {
273 m_log.ErrorFormat(msg, args); 273 // m_log.ErrorFormat(msg, args);
274 // MainConsole.Instance.OutputFormat(msg, args); 274 MainConsole.Instance.OutputFormat(msg, args);
275 } 275 }
276 } 276 }
277} \ No newline at end of file 277}
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index d0142a4..0b9f875 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -70,8 +70,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
70 70
71 public void Initialise(IConfigSource config) 71 public void Initialise(IConfigSource config)
72 { 72 {
73 //m_log.Info("[RegionReady] Initialising");
74
75 m_config = config.Configs["RegionReady"]; 73 m_config = config.Configs["RegionReady"];
76 if (m_config != null) 74 if (m_config != null)
77 { 75 {
@@ -84,9 +82,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
84 m_uri = m_config.GetString("alert_uri",string.Empty); 82 m_uri = m_config.GetString("alert_uri",string.Empty);
85 } 83 }
86 } 84 }
87
88// if (!m_enabled)
89// m_log.Info("[RegionReady] disabled.");
90 } 85 }
91 86
92 public void AddRegion(Scene scene) 87 public void AddRegion(Scene scene)
@@ -113,7 +108,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
113 { 108 {
114 scene.LoginLock = true; 109 scene.LoginLock = true;
115 scene.LoginsDisabled = true; 110 scene.LoginsDisabled = true;
116 m_log.InfoFormat("[RegionReady]: Logins disabled for {0}",m_scene.RegionInfo.RegionName); 111 m_log.InfoFormat("[RegionReady]: Region {0} - logins disabled during initialization.",m_scene.RegionInfo.RegionName);
117 112
118 if(m_uri != string.Empty) 113 if(m_uri != string.Empty)
119 { 114 {
@@ -167,7 +162,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
167 162
168 void OnEmptyScriptCompileQueue(int numScriptsFailed, string message) 163 void OnEmptyScriptCompileQueue(int numScriptsFailed, string message)
169 { 164 {
170 m_log.InfoFormat("[RegionReady]: Script compile queue empty!"); 165 m_log.DebugFormat("[RegionReady]: Script compile queue empty!");
171 166
172 if (m_firstEmptyCompileQueue || m_oarFileLoading) 167 if (m_firstEmptyCompileQueue || m_oarFileLoading)
173 { 168 {
@@ -194,7 +189,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
194 c.SenderUUID = UUID.Zero; 189 c.SenderUUID = UUID.Zero;
195 c.Scene = m_scene; 190 c.Scene = m_scene;
196 191
197 m_log.InfoFormat("[RegionReady]: Region \"{0}\" is ready: \"{1}\" on channel {2}", 192 m_log.DebugFormat("[RegionReady]: Region \"{0}\" is ready: \"{1}\" on channel {2}",
198 m_scene.RegionInfo.RegionName, c.Message, m_channelNotify); 193 m_scene.RegionInfo.RegionName, c.Message, m_channelNotify);
199 194
200 m_scene.EventManager.TriggerOnChatBroadcast(this, c); 195 m_scene.EventManager.TriggerOnChatBroadcast(this, c);
@@ -210,7 +205,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
210 { 205 {
211 m_lastOarLoadedOk = true; 206 m_lastOarLoadedOk = true;
212 } else { 207 } else {
213 m_log.InfoFormat("[RegionReady]: Oar file load errors: {0}", message); 208 m_log.WarnFormat("[RegionReady]: Oar file load errors: {0}", message);
214 m_lastOarLoadedOk = false; 209 m_lastOarLoadedOk = false;
215 } 210 }
216 } 211 }
@@ -233,7 +228,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
233 // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", 228 // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}",
234 // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); 229 // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString());
235 230
236 m_log.InfoFormat("[RegionReady]: Logins enabled for {0}", m_scene.RegionInfo.RegionName); 231 m_log.InfoFormat("[RegionReady]: Initialization complete - logins enabled for {0}", m_scene.RegionInfo.RegionName);
237 232
238 if ( m_uri != string.Empty ) 233 if ( m_uri != string.Empty )
239 { 234 {
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 44c9ada..cab30de 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Collections.Generic;
30using Nini.Config; 31using Nini.Config;
31using log4net; 32using log4net;
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -34,8 +35,10 @@ using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
35using Mono.Addins; 36using Mono.Addins;
36using OpenMetaverse; 37using OpenMetaverse;
38using System.Linq;
39using System.Linq.Expressions;
37 40
38namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms 41namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
39{ 42{
40 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] 43 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")]
41 class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms 44 class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms
@@ -43,10 +46,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
43 private static readonly ILog m_log = 46 private static readonly ILog m_log =
44 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 48
46 private IScriptModule m_scriptModule = null; 49#region ScriptInvocation
50 protected class ScriptInvocationData
51 {
52 public Delegate ScriptInvocationDelegate { get; private set; }
53 public string FunctionName { get; private set; }
54 public Type[] TypeSignature { get; private set; }
55 public Type ReturnType { get; private set; }
56
57 public ScriptInvocationData(string fname, Delegate fn, Type[] callsig, Type returnsig)
58 {
59 FunctionName = fname;
60 ScriptInvocationDelegate = fn;
61 TypeSignature = callsig;
62 ReturnType = returnsig;
63 }
64 }
65
66 private Dictionary<string,ScriptInvocationData> m_scriptInvocation = new Dictionary<string,ScriptInvocationData>();
67#endregion
47 68
69 private IScriptModule m_scriptModule = null;
48 public event ScriptCommand OnScriptCommand; 70 public event ScriptCommand OnScriptCommand;
49 71
72#region RegionModuleInterface
50 public void Initialise(IConfigSource config) 73 public void Initialise(IConfigSource config)
51 { 74 {
52 } 75 }
@@ -81,6 +104,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
81 public void Close() 104 public void Close()
82 { 105 {
83 } 106 }
107#endregion
108
109#region ScriptModuleComms
84 110
85 public void RaiseEvent(UUID script, string id, string module, string command, string k) 111 public void RaiseEvent(UUID script, string id, string module, string command, string k)
86 { 112 {
@@ -101,5 +127,149 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
101 127
102 m_scriptModule.PostScriptEvent(script, "link_message", args); 128 m_scriptModule.PostScriptEvent(script, "link_message", args);
103 } 129 }
130
131 public void RegisterScriptInvocation(object target, string meth)
132 {
133 MethodInfo mi = target.GetType().GetMethod(meth,
134 BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
135 if (mi == null)
136 {
137 m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth);
138 return;
139 }
140
141 RegisterScriptInvocation(target, mi);
142 }
143
144 public void RegisterScriptInvocation(object target, string[] meth)
145 {
146 foreach (string m in meth)
147 RegisterScriptInvocation(target, m);
148 }
149
150 public void RegisterScriptInvocation(object target, MethodInfo mi)
151 {
152 m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}", mi.Name, target.GetType().Name);
153
154 Type delegateType;
155 var typeArgs = mi.GetParameters()
156 .Select(p => p.ParameterType)
157 .ToList();
158
159 if (mi.ReturnType == typeof(void))
160 {
161 delegateType = Expression.GetActionType(typeArgs.ToArray());
162 }
163 else
164 {
165 typeArgs.Add(mi.ReturnType);
166 delegateType = Expression.GetFuncType(typeArgs.ToArray());
167 }
168
169 Delegate fcall = Delegate.CreateDelegate(delegateType, target, mi);
170
171 lock (m_scriptInvocation)
172 {
173 ParameterInfo[] parameters = fcall.Method.GetParameters ();
174 if (parameters.Length < 2) // Must have two UUID params
175 return;
176
177 // Hide the first two parameters
178 Type[] parmTypes = new Type[parameters.Length - 2];
179 for (int i = 2 ; i < parameters.Length ; i++)
180 parmTypes[i - 2] = parameters[i].ParameterType;
181 m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType);
182 }
183 }
184
185 public Delegate[] GetScriptInvocationList()
186 {
187 List<Delegate> ret = new List<Delegate>();
188
189 lock (m_scriptInvocation)
190 {
191 foreach (ScriptInvocationData d in m_scriptInvocation.Values)
192 ret.Add(d.ScriptInvocationDelegate);
193 }
194 return ret.ToArray();
195 }
196
197 public string LookupModInvocation(string fname)
198 {
199 lock (m_scriptInvocation)
200 {
201 ScriptInvocationData sid;
202 if (m_scriptInvocation.TryGetValue(fname,out sid))
203 {
204 if (sid.ReturnType == typeof(string))
205 return "modInvokeS";
206 else if (sid.ReturnType == typeof(int))
207 return "modInvokeI";
208 else if (sid.ReturnType == typeof(float))
209 return "modInvokeF";
210 else if (sid.ReturnType == typeof(UUID))
211 return "modInvokeK";
212 else if (sid.ReturnType == typeof(OpenMetaverse.Vector3))
213 return "modInvokeV";
214 else if (sid.ReturnType == typeof(OpenMetaverse.Quaternion))
215 return "modInvokeR";
216 else if (sid.ReturnType == typeof(object[]))
217 return "modInvokeL";
218
219 m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name);
220 }
221 }
222
223 return null;
224 }
225
226 public Delegate LookupScriptInvocation(string fname)
227 {
228 lock (m_scriptInvocation)
229 {
230 ScriptInvocationData sid;
231 if (m_scriptInvocation.TryGetValue(fname,out sid))
232 return sid.ScriptInvocationDelegate;
233 }
234
235 return null;
236 }
237
238 public Type[] LookupTypeSignature(string fname)
239 {
240 lock (m_scriptInvocation)
241 {
242 ScriptInvocationData sid;
243 if (m_scriptInvocation.TryGetValue(fname,out sid))
244 return sid.TypeSignature;
245 }
246
247 return null;
248 }
249
250 public Type LookupReturnType(string fname)
251 {
252 lock (m_scriptInvocation)
253 {
254 ScriptInvocationData sid;
255 if (m_scriptInvocation.TryGetValue(fname,out sid))
256 return sid.ReturnType;
257 }
258
259 return null;
260 }
261
262 public object InvokeOperation(UUID hostid, UUID scriptid, string fname, params object[] parms)
263 {
264 List<object> olist = new List<object>();
265 olist.Add(hostid);
266 olist.Add(scriptid);
267 foreach (object o in parms)
268 olist.Add(o);
269 Delegate fn = LookupScriptInvocation(fname);
270 return fn.DynamicInvoke(olist.ToArray());
271 }
272#endregion
273
104 } 274 }
105} 275}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index be0d56e..16ec34f 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -34,6 +34,9 @@ using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.CoreModules.World.Estate; 36using OpenSim.Region.CoreModules.World.Estate;
37using log4net;
38using System.Reflection;
39using System.Xml;
37 40
38namespace OpenSim.Region.OptionalModules.World.NPC 41namespace OpenSim.Region.OptionalModules.World.NPC
39{ 42{
@@ -130,11 +133,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC
130 133
131 } 134 }
132 135
133 public UUID GetDefaultAnimation(string name)
134 {
135 return UUID.Zero;
136 }
137
138 public Vector3 Position 136 public Vector3 Position
139 { 137 {
140 get { return m_scene.Entities[m_uuid].AbsolutePosition; } 138 get { return m_scene.Entities[m_uuid].AbsolutePosition; }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 2052cdb..2b8379d 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -88,22 +88,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC
88 88
89 public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) 89 public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene)
90 { 90 {
91 ScenePresence sp = scene.GetScenePresence(agentId); 91 ScenePresence npc = scene.GetScenePresence(agentId);
92 if (sp == null || sp.IsChildAgent) 92 if (npc == null || npc.IsChildAgent)
93 return false; 93 return false;
94 94
95 lock (m_avatars) 95 lock (m_avatars)
96 if (!m_avatars.ContainsKey(agentId)) 96 if (!m_avatars.ContainsKey(agentId))
97 return false; 97 return false;
98 98
99 // Delete existing sp attachments 99 // Delete existing npc attachments
100 scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); 100 scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false);
101 101
102 // Set new sp appearance. Also sends to clients. 102 // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments
103 scene.RequestModuleInterface<IAvatarFactoryModule>().SetAppearance(sp, new AvatarAppearance(appearance, true)); 103 AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
104 npc.Appearance = npcAppearance;
104 105
105 // Rez needed sp attachments 106 // Rez needed npc attachments
106 scene.AttachmentsModule.RezAttachments(sp); 107 scene.AttachmentsModule.RezAttachments(npc);
108
109 IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>();
110 module.SendAppearance(npc.UUID);
107 111
108 return true; 112 return true;
109 } 113 }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index d507822..eea0b2e 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -50,10 +50,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
50 [TestFixture] 50 [TestFixture]
51 public class NPCModuleTests 51 public class NPCModuleTests
52 { 52 {
53 private TestScene scene; 53 private TestScene m_scene;
54 private AvatarFactoryModule afm; 54 private AvatarFactoryModule m_afMod;
55 private UserManagementModule umm; 55 private UserManagementModule m_umMod;
56 private AttachmentsModule am; 56 private AttachmentsModule m_attMod;
57 private NPCModule m_npcMod;
57 58
58 [TestFixtureSetUp] 59 [TestFixtureSetUp]
59 public void FixtureInit() 60 public void FixtureInit()
@@ -79,12 +80,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
79 config.AddConfig("Modules"); 80 config.AddConfig("Modules");
80 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); 81 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
81 82
82 afm = new AvatarFactoryModule(); 83 m_afMod = new AvatarFactoryModule();
83 umm = new UserManagementModule(); 84 m_umMod = new UserManagementModule();
84 am = new AttachmentsModule(); 85 m_attMod = new AttachmentsModule();
86 m_npcMod = new NPCModule();
85 87
86 scene = SceneHelpers.SetupScene(); 88 m_scene = SceneHelpers.SetupScene();
87 SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule()); 89 SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule());
88 } 90 }
89 91
90 [Test] 92 [Test]
@@ -93,7 +95,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
93 TestHelpers.InMethod(); 95 TestHelpers.InMethod();
94// log4net.Config.XmlConfigurator.Configure(); 96// log4net.Config.XmlConfigurator.Configure();
95 97
96 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 98 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
97// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); 99// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
98 100
99 // 8 is the index of the first baked texture in AvatarAppearance 101 // 8 is the index of the first baked texture in AvatarAppearance
@@ -104,18 +106,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
104 106
105 // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell 107 // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
106 // ScenePresence.SendInitialData() to reset our entire appearance. 108 // ScenePresence.SendInitialData() to reset our entire appearance.
107 scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); 109 m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
108 110
109 afm.SetAppearance(sp, originalTe, null); 111 m_afMod.SetAppearance(sp, originalTe, null);
110 112
111 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 113 UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);
112 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance);
113 114
114 ScenePresence npc = scene.GetScenePresence(npcId); 115 ScenePresence npc = m_scene.GetScenePresence(npcId);
115 116
116 Assert.That(npc, Is.Not.Null); 117 Assert.That(npc, Is.Not.Null);
117 Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); 118 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 Assert.That(m_umMod.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
119 } 120 }
120 121
121 [Test] 122 [Test]
@@ -124,42 +125,83 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
124 TestHelpers.InMethod(); 125 TestHelpers.InMethod();
125// log4net.Config.XmlConfigurator.Configure(); 126// log4net.Config.XmlConfigurator.Configure();
126 127
127 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 128 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
128// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); 129// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
129 130
130 Vector3 startPos = new Vector3(128, 128, 30); 131 Vector3 startPos = new Vector3(128, 128, 30);
131 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 132 UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance);
132 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
133 133
134 npcModule.DeleteNPC(npcId, scene); 134 m_npcMod.DeleteNPC(npcId, m_scene);
135 135
136 ScenePresence deletedNpc = scene.GetScenePresence(npcId); 136 ScenePresence deletedNpc = m_scene.GetScenePresence(npcId);
137 137
138 Assert.That(deletedNpc, Is.Null); 138 Assert.That(deletedNpc, Is.Null);
139 } 139 }
140 140
141 [Test] 141 [Test]
142 public void TestAttachments() 142 public void TestCreateWithAttachments()
143 { 143 {
144 TestHelpers.InMethod(); 144 TestHelpers.InMethod();
145// log4net.Config.XmlConfigurator.Configure(); 145// log4net.Config.XmlConfigurator.Configure();
146 146
147 UUID userId = TestHelpers.ParseTail(0x1); 147 UUID userId = TestHelpers.ParseTail(0x1);
148 UserAccountHelpers.CreateUserWithInventory(scene, userId); 148 UserAccountHelpers.CreateUserWithInventory(m_scene, userId);
149 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); 149 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
150 150
151 UUID attItemId = TestHelpers.ParseTail(0x2); 151 UUID attItemId = TestHelpers.ParseTail(0x2);
152 UUID attAssetId = TestHelpers.ParseTail(0x3); 152 UUID attAssetId = TestHelpers.ParseTail(0x3);
153 string attName = "att"; 153 string attName = "att";
154 154
155 UserInventoryHelpers.CreateInventoryItem(scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object); 155 UserInventoryHelpers.CreateInventoryItem(m_scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
156 156
157 am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest); 157 m_attMod.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);
158 158
159 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 159 UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);
160 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance);
161 160
162 ScenePresence npc = scene.GetScenePresence(npcId); 161 ScenePresence npc = m_scene.GetScenePresence(npcId);
162
163 // Check scene presence status
164 Assert.That(npc.HasAttachments(), Is.True);
165 List<SceneObjectGroup> attachments = npc.GetAttachments();
166 Assert.That(attachments.Count, Is.EqualTo(1));
167 SceneObjectGroup attSo = attachments[0];
168
169 // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
170 // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
171// Assert.That(attSo.Name, Is.EqualTo(attName));
172
173 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
174 Assert.That(attSo.IsAttachment);
175 Assert.That(attSo.UsesPhysics, Is.False);
176 Assert.That(attSo.IsTemporary, Is.False);
177 Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
178 }
179
180 [Test]
181 public void TestLoadAppearance()
182 {
183 TestHelpers.InMethod();
184// log4net.Config.XmlConfigurator.Configure();
185
186 UUID userId = TestHelpers.ParseTail(0x1);
187 UserAccountHelpers.CreateUserWithInventory(m_scene, userId);
188 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
189
190 UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);
191
192 // Now add the attachment to the original avatar and use that to load a new appearance
193 // TODO: Could also run tests loading from a notecard though this isn't much different for our purposes here
194 UUID attItemId = TestHelpers.ParseTail(0x2);
195 UUID attAssetId = TestHelpers.ParseTail(0x3);
196 string attName = "att";
197
198 UserInventoryHelpers.CreateInventoryItem(m_scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
199
200 m_attMod.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);
201
202 m_npcMod.SetNPCAppearance(npcId, sp.Appearance, m_scene);
203
204 ScenePresence npc = m_scene.GetScenePresence(npcId);
163 205
164 // Check scene presence status 206 // Check scene presence status
165 Assert.That(npc.HasAttachments(), Is.True); 207 Assert.That(npc.HasAttachments(), Is.True);
@@ -184,31 +226,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
184 TestHelpers.InMethod(); 226 TestHelpers.InMethod();
185// log4net.Config.XmlConfigurator.Configure(); 227// log4net.Config.XmlConfigurator.Configure();
186 228
187 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 229 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
188// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); 230// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
189 231
190 Vector3 startPos = new Vector3(128, 128, 30); 232 Vector3 startPos = new Vector3(128, 128, 30);
191 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 233 UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance);
192 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
193 234
194 ScenePresence npc = scene.GetScenePresence(npcId); 235 ScenePresence npc = m_scene.GetScenePresence(npcId);
195 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); 236 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
196 237
197 // For now, we'll make the scene presence fly to simplify this test, but this needs to change. 238 // For now, we'll make the scene presence fly to simplify this test, but this needs to change.
198 npc.Flying = true; 239 npc.Flying = true;
199 240
200 scene.Update(); 241 m_scene.Update(1);
201 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); 242 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
202 243
203 Vector3 targetPos = startPos + new Vector3(0, 10, 0); 244 Vector3 targetPos = startPos + new Vector3(0, 10, 0);
204 npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false); 245 m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false);
205 246
206 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); 247 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
207 //Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0.7071068f, 0.7071068f))); 248 //Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0.7071068f, 0.7071068f)));
208 Assert.That( 249 Assert.That(
209 npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0.7071068f, 0.7071068f), 0.000001)); 250 npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0.7071068f, 0.7071068f), 0.000001));
210 251
211 scene.Update(); 252 m_scene.Update(1);
212 253
213 // We should really check the exact figure. 254 // We should really check the exact figure.
214 Assert.That(npc.AbsolutePosition.X, Is.EqualTo(startPos.X)); 255 Assert.That(npc.AbsolutePosition.X, Is.EqualTo(startPos.X));
@@ -216,8 +257,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
216 Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z)); 257 Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z));
217 Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.X)); 258 Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.X));
218 259
219 for (int i = 0; i < 10; i++) 260 m_scene.Update(10);
220 scene.Update();
221 261
222 double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); 262 double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
223 Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); 263 Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move");
@@ -227,14 +267,14 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
227 // Try a second movement 267 // Try a second movement
228 startPos = npc.AbsolutePosition; 268 startPos = npc.AbsolutePosition;
229 targetPos = startPos + new Vector3(10, 0, 0); 269 targetPos = startPos + new Vector3(10, 0, 0);
230 npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false); 270 m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false);
231 271
232 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); 272 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
233// Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0, 1))); 273// Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0, 1)));
234 Assert.That( 274 Assert.That(
235 npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0, 1), 0.000001)); 275 npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0, 1), 0.000001));
236 276
237 scene.Update(); 277 m_scene.Update(1);
238 278
239 // We should really check the exact figure. 279 // We should really check the exact figure.
240 Assert.That(npc.AbsolutePosition.X, Is.GreaterThan(startPos.X)); 280 Assert.That(npc.AbsolutePosition.X, Is.GreaterThan(startPos.X));
@@ -242,8 +282,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
242 Assert.That(npc.AbsolutePosition.Y, Is.EqualTo(startPos.Y)); 282 Assert.That(npc.AbsolutePosition.Y, Is.EqualTo(startPos.Y));
243 Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z)); 283 Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z));
244 284
245 for (int i = 0; i < 10; i++) 285 m_scene.Update(10);
246 scene.Update();
247 286
248 distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); 287 distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
249 Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move"); 288 Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move");
@@ -256,17 +295,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
256 TestHelpers.InMethod(); 295 TestHelpers.InMethod();
257// log4net.Config.XmlConfigurator.Configure(); 296// log4net.Config.XmlConfigurator.Configure();
258 297
259 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 298 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
260 299
261 Vector3 startPos = new Vector3(128, 128, 30); 300 Vector3 startPos = new Vector3(128, 128, 30);
262 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 301 UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance);
263 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
264 302
265 ScenePresence npc = scene.GetScenePresence(npcId); 303 ScenePresence npc = m_scene.GetScenePresence(npcId);
266 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 304 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
267 305
268 part.SitTargetPosition = new Vector3(0, 0, 1); 306 part.SitTargetPosition = new Vector3(0, 0, 1);
269 npcModule.Sit(npc.UUID, part.UUID, scene); 307 m_npcMod.Sit(npc.UUID, part.UUID, m_scene);
270 308
271 Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId)); 309 Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId));
272 Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); 310 Assert.That(npc.ParentID, Is.EqualTo(part.LocalId));
@@ -274,7 +312,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
274 npc.AbsolutePosition, 312 npc.AbsolutePosition,
275 Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); 313 Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT));
276 314
277 npcModule.Stand(npc.UUID, scene); 315 m_npcMod.Stand(npc.UUID, m_scene);
278 316
279 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); 317 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
280 Assert.That(npc.ParentID, Is.EqualTo(0)); 318 Assert.That(npc.ParentID, Is.EqualTo(0));
@@ -286,19 +324,18 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
286 TestHelpers.InMethod(); 324 TestHelpers.InMethod();
287// log4net.Config.XmlConfigurator.Configure(); 325// log4net.Config.XmlConfigurator.Configure();
288 326
289 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 327 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
290 328
291 // FIXME: To get this to work for now, we are going to place the npc right next to the target so that 329 // FIXME: To get this to work for now, we are going to place the npc right next to the target so that
292 // the autopilot doesn't trigger 330 // the autopilot doesn't trigger
293 Vector3 startPos = new Vector3(1, 1, 1); 331 Vector3 startPos = new Vector3(1, 1, 1);
294 332
295 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 333 UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance);
296 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
297 334
298 ScenePresence npc = scene.GetScenePresence(npcId); 335 ScenePresence npc = m_scene.GetScenePresence(npcId);
299 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 336 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
300 337
301 npcModule.Sit(npc.UUID, part.UUID, scene); 338 m_npcMod.Sit(npc.UUID, part.UUID, m_scene);
302 339
303 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); 340 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
304 Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); 341 Assert.That(npc.ParentID, Is.EqualTo(part.LocalId));
@@ -311,7 +348,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
311 npc.AbsolutePosition, 348 npc.AbsolutePosition,
312 Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f))); 349 Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f)));
313 350
314 npcModule.Stand(npc.UUID, scene); 351 m_npcMod.Stand(npc.UUID, m_scene);
315 352
316 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); 353 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
317 Assert.That(npc.ParentID, Is.EqualTo(0)); 354 Assert.That(npc.ParentID, Is.EqualTo(0));