aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs155
-rw-r--r--OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs151
-rw-r--r--OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs185
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs95
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs5
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs64
-rw-r--r--OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs21
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs87
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs30
12 files changed, 749 insertions, 56 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 32de85f..bbf3729 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -658,6 +658,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
658 public event ModifyTerrain OnModifyTerrain; 658 public event ModifyTerrain OnModifyTerrain;
659 public event BakeTerrain OnBakeTerrain; 659 public event BakeTerrain OnBakeTerrain;
660 public event EstateChangeInfo OnEstateChangeInfo; 660 public event EstateChangeInfo OnEstateChangeInfo;
661 public event EstateManageTelehub OnEstateManageTelehub;
661 public event SetAppearance OnSetAppearance; 662 public event SetAppearance OnSetAppearance;
662 public event AvatarNowWearing OnAvatarNowWearing; 663 public event AvatarNowWearing OnAvatarNowWearing;
663 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; 664 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
@@ -1530,6 +1531,11 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1530 1531
1531 } 1532 }
1532 1533
1534 public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
1535 {
1536
1537 }
1538
1533 public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags) 1539 public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
1534 { 1540 {
1535 1541
diff --git a/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs
new file mode 100644
index 0000000..439096a
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs
@@ -0,0 +1,155 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Text;
33using log4net;
34using Mono.Addins;
35using Nini.Config;
36using OpenMetaverse;
37using OpenMetaverse.Imaging;
38using OpenSim.Framework;
39using OpenSim.Framework.Console;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes;
42
43namespace OpenSim.Region.OptionalModules.Agent.TextureSender
44{
45 /// <summary>
46 /// Commands for the J2KDecoder module. For debugging purposes.
47 /// </summary>
48 /// <remarks>
49 /// Placed here so that they can be removed if not required and to keep the J2KDecoder module itself simple.
50 /// </remarks>
51 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "J2KDecoderCommandModule")]
52 public class J2KDecoderCommandModule : ISharedRegionModule
53 {
54// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 private Scene m_scene;
57
58 public string Name { get { return "Asset Information Module"; } }
59
60 public Type ReplaceableInterface { get { return null; } }
61
62 public void Initialise(IConfigSource source)
63 {
64// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: INITIALIZED MODULE");
65 }
66
67 public void PostInitialise()
68 {
69// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: POST INITIALIZED MODULE");
70 }
71
72 public void Close()
73 {
74// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: CLOSED MODULE");
75 }
76
77 public void AddRegion(Scene scene)
78 {
79// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
80 }
81
82 public void RemoveRegion(Scene scene)
83 {
84// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
85 }
86
87 public void RegionLoaded(Scene scene)
88 {
89// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
90
91 if (m_scene == null)
92 m_scene = scene;
93
94 MainConsole.Instance.Commands.AddCommand(
95 "j2k",
96 false,
97 "j2k decode",
98 "j2k decode <ID>",
99 "Do JPEG2000 decoding of an asset.",
100 "This is for debugging purposes. The asset id given must contain JPEG2000 data.",
101 HandleDecode);
102 }
103
104 void HandleDecode(string module, string[] args)
105 {
106 if (args.Length < 3)
107 {
108 MainConsole.Instance.Output("Usage is j2k decode <ID>");
109 return;
110 }
111
112 UUID assetId;
113 string rawAssetId = args[2];
114
115 if (!UUID.TryParse(rawAssetId, out assetId))
116 {
117 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
118 return;
119 }
120
121 AssetBase asset = m_scene.AssetService.Get(assetId.ToString());
122 if (asset == null)
123 {
124 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
125 return;
126 }
127
128 if (asset.Type != (sbyte)AssetType.Texture)
129 {
130 MainConsole.Instance.OutputFormat("ERROR: Asset {0} is not a texture type", assetId);
131 return;
132 }
133
134 IJ2KDecoder decoder = m_scene.RequestModuleInterface<IJ2KDecoder>();
135 if (decoder == null)
136 {
137 MainConsole.Instance.OutputFormat("ERROR: No IJ2KDecoder module available");
138 return;
139 }
140
141 OpenJPEG.J2KLayerInfo[] layers;
142 int components;
143 if (decoder.Decode(assetId, asset.Data, out layers, out components))
144 {
145 MainConsole.Instance.OutputFormat(
146 "Successfully decoded asset {0} with {1} layers and {2} components",
147 assetId, layers.Length, components);
148 }
149 else
150 {
151 MainConsole.Instance.OutputFormat("Decode of asset {0} failed", assetId);
152 }
153 }
154 }
155} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
index c754019..261029c 100644
--- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
@@ -79,7 +79,19 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
79// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); 79// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
80 80
81 lock (m_scenes) 81 lock (m_scenes)
82 m_scenes[scene.RegionInfo.RegionID] = scene; 82 m_scenes[scene.RegionInfo.RegionID] = scene;
83
84 scene.AddCommand(
85 this, "image queues clear",
86 "image queues clear <first-name> <last-name>",
87 "Clear the image queues (textures downloaded via UDP) for a particular client.",
88 (mod, cmd) => MainConsole.Instance.Output(HandleImageQueuesClear(cmd)));
89
90 scene.AddCommand(
91 this, "image queues show",
92 "image queues show <first-name> <last-name>",
93 "Show the image queues (textures downloaded via UDP) for a particular client.",
94 (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd)));
83 95
84 scene.AddCommand( 96 scene.AddCommand(
85 this, "show pqueues", 97 this, "show pqueues",
@@ -87,7 +99,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
87 "Show priority queue data for each client", 99 "Show priority queue data for each client",
88 "Without the 'full' option, only root agents are shown." 100 "Without the 'full' option, only root agents are shown."
89 + " With the 'full' option child agents are also shown.", 101 + " With the 'full' option child agents are also shown.",
90 ShowPQueuesReport); 102 (mod, cmd) => MainConsole.Instance.Output(GetPQueuesReport(cmd)));
91 103
92 scene.AddCommand( 104 scene.AddCommand(
93 this, "show queues", 105 this, "show queues",
@@ -95,7 +107,13 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
95 "Show queue data for each client", 107 "Show queue data for each client",
96 "Without the 'full' option, only root agents are shown." 108 "Without the 'full' option, only root agents are shown."
97 + " With the 'full' option child agents are also shown.", 109 + " With the 'full' option child agents are also shown.",
98 ShowQueuesReport); 110 (mod, cmd) => MainConsole.Instance.Output(GetQueuesReport(cmd)));
111
112 scene.AddCommand(
113 this, "show image queues",
114 "show image queues <first-name> <last-name>",
115 "Show the image queues (textures downloaded via UDP) for a particular client.",
116 (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd)));
99 117
100 scene.AddCommand( 118 scene.AddCommand(
101 this, "show throttles", 119 this, "show throttles",
@@ -103,14 +121,14 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
103 "Show throttle settings for each client and for the server overall", 121 "Show throttle settings for each client and for the server overall",
104 "Without the 'full' option, only root agents are shown." 122 "Without the 'full' option, only root agents are shown."
105 + " With the 'full' option child agents are also shown.", 123 + " With the 'full' option child agents are also shown.",
106 ShowThrottlesReport); 124 (mod, cmd) => MainConsole.Instance.Output(GetThrottlesReport(cmd)));
107 125
108 scene.AddCommand( 126 scene.AddCommand(
109 this, "emergency-monitoring", 127 this, "emergency-monitoring",
110 "emergency-monitoring", 128 "emergency-monitoring",
111 "Go on/off emergency monitoring mode", 129 "Go on/off emergency monitoring mode",
112 "Go on/off emergency monitoring mode", 130 "Go on/off emergency monitoring mode",
113 EmergencyMonitoring); 131 HandleEmergencyMonitoring);
114 } 132 }
115 133
116 public void RemoveRegion(Scene scene) 134 public void RemoveRegion(Scene scene)
@@ -124,24 +142,51 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
124 public void RegionLoaded(Scene scene) 142 public void RegionLoaded(Scene scene)
125 { 143 {
126// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); 144// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
127 }
128
129 protected void ShowPQueuesReport(string module, string[] cmd)
130 {
131 MainConsole.Instance.Output(GetPQueuesReport(cmd));
132 } 145 }
133 146
134 protected void ShowQueuesReport(string module, string[] cmd) 147 protected string HandleImageQueuesClear(string[] cmd)
135 {
136 MainConsole.Instance.Output(GetQueuesReport(cmd));
137 }
138
139 protected void ShowThrottlesReport(string module, string[] cmd)
140 { 148 {
141 MainConsole.Instance.Output(GetThrottlesReport(cmd)); 149 if (cmd.Length != 5)
150 return "Usage: image queues clear <first-name> <last-name>";
151
152 string firstName = cmd[3];
153 string lastName = cmd[4];
154
155 List<ScenePresence> foundAgents = new List<ScenePresence>();
156
157 lock (m_scenes)
158 {
159 foreach (Scene scene in m_scenes.Values)
160 {
161 ScenePresence sp = scene.GetScenePresence(firstName, lastName);
162 if (sp != null)
163 foundAgents.Add(sp);
164 }
165 }
166
167 if (foundAgents.Count == 0)
168 return string.Format("No agents found for {0} {1}", firstName, lastName);
169
170 StringBuilder report = new StringBuilder();
171
172 foreach (ScenePresence agent in foundAgents)
173 {
174 LLClientView client = agent.ControllingClient as LLClientView;
175
176 if (client == null)
177 return "This command is only supported for LLClientView";
178
179 int requestsDeleted = client.ImageManager.ClearImageQueue();
180
181 report.AppendFormat(
182 "In region {0} ({1} agent) cleared {2} requests\n",
183 agent.Scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root", requestsDeleted);
184 }
185
186 return report.ToString();
142 } 187 }
143 188
144 protected void EmergencyMonitoring(string module, string[] cmd) 189 protected void HandleEmergencyMonitoring(string module, string[] cmd)
145 { 190 {
146 bool mode = true; 191 bool mode = true;
147 if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on")) 192 if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on"))
@@ -166,7 +211,6 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
166 entry.Length > maxLength ? entry.Substring(0, maxLength) : entry, 211 entry.Length > maxLength ? entry.Substring(0, maxLength) : entry,
167 ""); 212 "");
168 } 213 }
169
170 214
171 /// <summary> 215 /// <summary>
172 /// Generate UDP Queue data report for each client 216 /// Generate UDP Queue data report for each client
@@ -240,6 +284,73 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
240 284
241 return report.ToString(); 285 return report.ToString();
242 } 286 }
287
288 /// <summary>
289 /// Generate an image queue report
290 /// </summary>
291 /// <param name="showParams"></param>
292 /// <returns></returns>
293 private string GetImageQueuesReport(string[] showParams)
294 {
295 if (showParams.Length < 5 || showParams.Length > 6)
296 return "Usage: image queues show <first-name> <last-name> [full]";
297
298 string firstName = showParams[3];
299 string lastName = showParams[4];
300
301 bool showChildAgents = showParams.Length == 6;
302
303 List<ScenePresence> foundAgents = new List<ScenePresence>();
304
305 lock (m_scenes)
306 {
307 foreach (Scene scene in m_scenes.Values)
308 {
309 ScenePresence sp = scene.GetScenePresence(firstName, lastName);
310 if (sp != null && (showChildAgents || !sp.IsChildAgent))
311 foundAgents.Add(sp);
312 }
313 }
314
315 if (foundAgents.Count == 0)
316 return string.Format("No agents found for {0} {1}", firstName, lastName);
317
318 StringBuilder report = new StringBuilder();
319
320 foreach (ScenePresence agent in foundAgents)
321 {
322 LLClientView client = agent.ControllingClient as LLClientView;
323
324 if (client == null)
325 return "This command is only supported for LLClientView";
326
327 J2KImage[] images = client.ImageManager.GetImages();
328
329 report.AppendFormat(
330 "In region {0} ({1} agent)\n",
331 agent.Scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root");
332 report.AppendFormat("Images in queue: {0}\n", images.Length);
333
334 if (images.Length > 0)
335 {
336 report.AppendFormat(
337 "{0,-36} {1,-8} {2,-10} {3,-9} {4,-9} {5,-7}\n",
338 "Texture ID",
339 "Last Seq",
340 "Priority",
341 "Start Pkt",
342 "Has Asset",
343 "Decoded");
344
345 foreach (J2KImage image in images)
346 report.AppendFormat(
347 "{0,36} {1,8} {2,10} {3,10} {4,9} {5,7}\n",
348 image.TextureID, image.LastSequence, image.Priority, image.StartPacket, image.HasAsset, image.IsDecoded);
349 }
350 }
351
352 return report.ToString();
353 }
243 354
244 /// <summary> 355 /// <summary>
245 /// Generate UDP Queue data report for each client 356 /// Generate UDP Queue data report for each client
diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
new file mode 100644
index 0000000..a5207eb
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
@@ -0,0 +1,185 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Text;
33using log4net;
34using Mono.Addins;
35using Nini.Config;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Console;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes;
41
42namespace OpenSim.Region.OptionalModules.Asset
43{
44 /// <summary>
45 /// A module that just holds commands for inspecting assets.
46 /// </summary>
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AssetInfoModule")]
48 public class AssetInfoModule : ISharedRegionModule
49 {
50// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 private Scene m_scene;
53
54 public string Name { get { return "Asset Information Module"; } }
55
56 public Type ReplaceableInterface { get { return null; } }
57
58 public void Initialise(IConfigSource source)
59 {
60// m_log.DebugFormat("[ASSET INFO MODULE]: INITIALIZED MODULE");
61 }
62
63 public void PostInitialise()
64 {
65// m_log.DebugFormat("[ASSET INFO MODULE]: POST INITIALIZED MODULE");
66 }
67
68 public void Close()
69 {
70// m_log.DebugFormat("[ASSET INFO MODULE]: CLOSED MODULE");
71 }
72
73 public void AddRegion(Scene scene)
74 {
75// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
76 }
77
78 public void RemoveRegion(Scene scene)
79 {
80// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
81 }
82
83 public void RegionLoaded(Scene scene)
84 {
85// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
86
87 if (m_scene == null)
88 m_scene = scene;
89
90 MainConsole.Instance.Commands.AddCommand(
91 "asset",
92 false,
93 "show asset",
94 "show asset <ID>",
95 "Show asset information",
96 HandleShowAsset);
97
98 MainConsole.Instance.Commands.AddCommand(
99 "asset", false, "dump asset",
100 "dump asset <id>",
101 "Dump an asset",
102 HandleDumpAsset);
103 }
104
105 void HandleDumpAsset(string module, string[] args)
106 {
107 if (args.Length < 3)
108 {
109 MainConsole.Instance.Output("Usage is dump asset <ID>");
110 return;
111 }
112
113 UUID assetId;
114 string rawAssetId = args[2];
115
116 if (!UUID.TryParse(rawAssetId, out assetId))
117 {
118 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
119 return;
120 }
121
122 AssetBase asset = m_scene.AssetService.Get(assetId.ToString());
123 if (asset == null)
124 {
125 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
126 return;
127 }
128
129 string fileName = rawAssetId;
130
131 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
132 {
133 using (BinaryWriter bw = new BinaryWriter(fs))
134 {
135 bw.Write(asset.Data);
136 }
137 }
138
139 MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName);
140 }
141
142 void HandleShowAsset(string module, string[] args)
143 {
144 if (args.Length < 3)
145 {
146 MainConsole.Instance.Output("Syntax: show asset <ID>");
147 return;
148 }
149
150 AssetBase asset = m_scene.AssetService.Get(args[2]);
151
152 if (asset == null || asset.Data.Length == 0)
153 {
154 MainConsole.Instance.Output("Asset not found");
155 return;
156 }
157
158 int i;
159
160 MainConsole.Instance.OutputFormat("Name: {0}", asset.Name);
161 MainConsole.Instance.OutputFormat("Description: {0}", asset.Description);
162 MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type);
163 MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType);
164 MainConsole.Instance.OutputFormat("Size: {0} bytes", asset.Data.Length);
165 MainConsole.Instance.OutputFormat("Temporary: {0}", asset.Temporary ? "yes" : "no");
166 MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags);
167
168 for (i = 0 ; i < 5 ; i++)
169 {
170 int off = i * 16;
171 if (asset.Data.Length <= off)
172 break;
173 int len = 16;
174 if (asset.Data.Length < off + len)
175 len = asset.Data.Length - off;
176
177 byte[] line = new byte[len];
178 Array.Copy(asset.Data, off, line, 0, len);
179
180 string text = BitConverter.ToString(line);
181 MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text));
182 }
183 }
184 }
185} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
index 1ce24f1..2369d94 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq;
30using System.Reflection; 31using System.Reflection;
31using System.Text; 32using System.Text;
32using log4net; 33using log4net;
@@ -114,6 +115,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
114 "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.",
115 "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.",
116 HandleSendAppearanceCommand); 117 HandleSendAppearanceCommand);
118
119 scene.AddCommand(
120 this, "appearance rebake",
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.",
123 "This is currently done for all baked texture references previously received, whether the simulator can find the asset or not."
124 + "\nThis will only work for texture ids that the viewer has already uploaded."
125 + "\nIf the viewer has not yet sent the server any texture ids then nothing will happen"
126 + "\nsince requests can only be made for ids that the client has already sent us",
127 HandleRebakeAppearanceCommand);
128
129 scene.AddCommand(
130 this, "appearance find",
131 "appearance find <uuid-or-start-of-uuid>",
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.",
134 HandleFindAppearanceCommand);
117 } 135 }
118 136
119 private void HandleSendAppearanceCommand(string module, string[] cmd) 137 private void HandleSendAppearanceCommand(string module, string[] cmd)
@@ -210,6 +228,81 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
210 } 228 }
211 } 229 }
212 } 230 }
213 } 231 }
232
233 private void HandleRebakeAppearanceCommand(string module, string[] cmd)
234 {
235 if (cmd.Length != 4)
236 {
237 MainConsole.Instance.OutputFormat("Usage: appearance rebake <first-name> <last-name>");
238 return;
239 }
240
241 string firstname = cmd[2];
242 string lastname = cmd[3];
243
244 lock (m_scenes)
245 {
246 foreach (Scene scene in m_scenes.Values)
247 {
248 ScenePresence sp = scene.GetScenePresence(firstname, lastname);
249 if (sp != null && !sp.IsChildAgent)
250 {
251 int rebakesRequested = scene.AvatarFactory.RequestRebake(sp, false);
252
253 if (rebakesRequested > 0)
254 MainConsole.Instance.OutputFormat(
255 "Requesting rebake of {0} uploaded textures for {1} in {2}",
256 rebakesRequested, sp.Name, scene.RegionInfo.RegionName);
257 else
258 MainConsole.Instance.OutputFormat(
259 "No texture IDs available for rebake request for {0} in {1}",
260 sp.Name, scene.RegionInfo.RegionName);
261 }
262 }
263 }
264 }
265
266 protected void HandleFindAppearanceCommand(string module, string[] cmd)
267 {
268 if (cmd.Length != 3)
269 {
270 MainConsole.Instance.OutputFormat("Usage: appearance find <uuid-or-start-of-uuid>");
271 return;
272 }
273
274 string rawUuid = cmd[2];
275
276 HashSet<ScenePresence> matchedAvatars = new HashSet<ScenePresence>();
277
278 lock (m_scenes)
279 {
280 foreach (Scene scene in m_scenes.Values)
281 {
282 scene.ForEachRootScenePresence(
283 sp =>
284 {
285 Dictionary<BakeType, Primitive.TextureEntryFace> bakedFaces = scene.AvatarFactory.GetBakedTextureFaces(sp.UUID);
286 foreach (Primitive.TextureEntryFace face in bakedFaces.Values)
287 {
288 if (face != null && face.TextureID.ToString().StartsWith(rawUuid))
289 matchedAvatars.Add(sp);
290 }
291 });
292 }
293 }
294
295 if (matchedAvatars.Count == 0)
296 {
297 MainConsole.Instance.OutputFormat("{0} did not match any baked avatar textures in use", rawUuid);
298 }
299 else
300 {
301 MainConsole.Instance.OutputFormat(
302 "{0} matched {1}",
303 rawUuid,
304 string.Join(", ", matchedAvatars.ToList().ConvertAll<string>(sp => sp.Name).ToArray()));
305 }
306 }
214 } 307 }
215} \ No newline at end of file 308} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 740dbdd..b60cd42 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -713,7 +713,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
713 if (money != null) 713 if (money != null)
714 { 714 {
715 // do the transaction, that is if the agent has got sufficient funds 715 // do the transaction, that is if the agent has got sufficient funds
716 if (!money.AmountCovered(remoteClient, money.GroupCreationCharge)) { 716 if (!money.AmountCovered(remoteClient.AgentId, money.GroupCreationCharge)) {
717 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); 717 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group.");
718 return UUID.Zero; 718 return UUID.Zero;
719 } 719 }
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs
index 16cd7e4..a8e545c 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs
@@ -30,8 +30,7 @@ using OpenMetaverse;
30using OpenMetaverse.Assets; 30using OpenMetaverse.Assets;
31 31
32namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 32namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
33{ 33{
34
35 /// <summary> 34 /// <summary>
36 /// This implements the methods needed to operate on individual inventory items. 35 /// This implements the methods needed to operate on individual inventory items.
37 /// </summary> 36 /// </summary>
@@ -39,6 +38,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
39 { 38 {
40 int Type { get; } 39 int Type { get; }
41 UUID AssetID { get; } 40 UUID AssetID { get; }
42 T RetrieveAsset<T>() where T : Asset, new(); 41 T RetrieveAsset<T>() where T : OpenMetaverse.Assets.Asset, new();
43 } 42 }
44} 43}
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index 4c4f5fb..d2810be 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -44,12 +44,13 @@ using OpenSim.Region.Framework.Scenes;
44 44
45namespace OpenSim.Region.OptionalModules.Scripting.RegionReady 45namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
46{ 46{
47 public class RegionReadyModule : INonSharedRegionModule 47 public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule
48 { 48 {
49 private static readonly ILog m_log = 49 private static readonly ILog m_log =
50 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 private IConfig m_config = null; 52 private IConfig m_config = null;
53 private bool m_ScriptRez;
53 private bool m_firstEmptyCompileQueue; 54 private bool m_firstEmptyCompileQueue;
54 private bool m_oarFileLoading; 55 private bool m_oarFileLoading;
55 private bool m_lastOarLoadedOk; 56 private bool m_lastOarLoadedOk;
@@ -93,14 +94,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
93 if (!m_enabled) 94 if (!m_enabled)
94 return; 95 return;
95 96
97 m_scene = scene;
98
99 m_scene.RegisterModuleInterface<IRegionReadyModule>(this);
100
101 m_ScriptRez = false;
96 m_firstEmptyCompileQueue = true; 102 m_firstEmptyCompileQueue = true;
97 m_oarFileLoading = false; 103 m_oarFileLoading = false;
98 m_lastOarLoadedOk = true; 104 m_lastOarLoadedOk = true;
99 105
100 m_scene = scene;
101
102 m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
103 m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; 106 m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded;
107 m_scene.EventManager.OnRezScript += OnRezScript;
104 m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; 108 m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
105 109
106 m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); 110 m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName);
@@ -118,6 +122,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
118 } 122 }
119 } 123 }
120 124
125 void OnRezScript (uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
126 {
127 if (!m_ScriptRez)
128 {
129 m_ScriptRez = true;
130 m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
131 m_scene.EventManager.OnRezScript -= OnRezScript;
132 }
133 }
134
121 public void RemoveRegion(Scene scene) 135 public void RemoveRegion(Scene scene)
122 { 136 {
123 if (!m_enabled) 137 if (!m_enabled)
@@ -125,6 +139,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
125 139
126 m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; 140 m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
127 m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; 141 m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded;
142 m_scene.EventManager.OnLoginsEnabled -= OnLoginsEnabled;
128 143
129 if(m_uri != string.Empty) 144 if(m_uri != string.Empty)
130 { 145 {
@@ -148,9 +163,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
148 } 163 }
149 164
150 #endregion 165 #endregion
151 166
167
152 void OnEmptyScriptCompileQueue(int numScriptsFailed, string message) 168 void OnEmptyScriptCompileQueue(int numScriptsFailed, string message)
153 { 169 {
170 m_log.InfoFormat("[RegionReady]: Script compile queue empty!");
171
154 if (m_firstEmptyCompileQueue || m_oarFileLoading) 172 if (m_firstEmptyCompileQueue || m_oarFileLoading)
155 { 173 {
156 OSChatMessage c = new OSChatMessage(); 174 OSChatMessage c = new OSChatMessage();
@@ -197,6 +215,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
197 } 215 }
198 } 216 }
199 217
218 // This will be triggerd by Scene if we have no scripts
219 // m_ScriptsRezzing will be false if there were none
220 // else it will be true and we should wait on the
221 // empty compile queue
200 void OnLoginsEnabled(string regionName) 222 void OnLoginsEnabled(string regionName)
201 { 223 {
202 if (m_disable_logins == true) 224 if (m_disable_logins == true)
@@ -205,7 +227,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
205 { 227 {
206 m_scene.LoginsDisabled = false; 228 m_scene.LoginsDisabled = false;
207 m_scene.LoginLock = false; 229 m_scene.LoginLock = false;
208 m_log.InfoFormat("[RegionReady]: Logins enabled for {0}", m_scene.RegionInfo.RegionName); 230
231 m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
232
233 m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}",
234 m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString());
235
209 if ( m_uri != string.Empty ) 236 if ( m_uri != string.Empty )
210 { 237 {
211 RRAlert("enabled"); 238 RRAlert("enabled");
@@ -214,6 +241,31 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
214 } 241 }
215 } 242 }
216 243
244 public void OarLoadingAlert(string msg)
245 {
246 // Let's bypass this for now until some better feedback can be established
247 //
248 return;
249
250 if (msg == "load")
251 {
252 m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
253 m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded;
254 m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
255 m_scene.EventManager.OnRezScript += OnRezScript;
256 m_oarFileLoading = true;
257 m_firstEmptyCompileQueue = true;
258
259 m_scene.LoginsDisabled = true;
260 m_scene.LoginLock = true;
261 if ( m_uri != string.Empty )
262 {
263 RRAlert("loading oar");
264 RRAlert("disabled");
265 }
266 }
267 }
268
217 public void RRAlert(string status) 269 public void RRAlert(string status)
218 { 270 {
219 string request_method = "POST"; 271 string request_method = "POST";
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
index 8fc50ff..9c838d0 100644
--- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
+++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
@@ -775,11 +775,11 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
775 // Please do not refactor these to be just one method 775 // Please do not refactor these to be just one method
776 // Existing implementations need the distinction 776 // Existing implementations need the distinction
777 // 777 //
778 public bool UploadCovered(IClientAPI client, int amount) 778 public bool UploadCovered(UUID agentID, int amount)
779 { 779 {
780 return true; 780 return true;
781 } 781 }
782 public bool AmountCovered(IClientAPI client, int amount) 782 public bool AmountCovered(UUID agentID, int amount)
783 { 783 {
784 return true; 784 return true;
785 } 785 }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 84055cc..6d40a92 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -31,24 +31,32 @@ using System.Net;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenMetaverse.Packets; 32using OpenMetaverse.Packets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.CoreModules.World.Estate;
35 37
36namespace OpenSim.Region.OptionalModules.World.NPC 38namespace OpenSim.Region.OptionalModules.World.NPC
37{ 39{
38 public class NPCAvatar : IClientAPI 40 public class NPCAvatar : IClientAPI, INPC
39 { 41 {
42 public bool SenseAsAgent { get; set; }
43
40 private readonly string m_firstname; 44 private readonly string m_firstname;
41 private readonly string m_lastname; 45 private readonly string m_lastname;
42 private readonly Vector3 m_startPos; 46 private readonly Vector3 m_startPos;
43 private readonly UUID m_uuid = UUID.Random(); 47 private readonly UUID m_uuid = UUID.Random();
44 private readonly Scene m_scene; 48 private readonly Scene m_scene;
49 private readonly UUID m_ownerID;
45 50
46 public NPCAvatar(string firstname, string lastname, Vector3 position, Scene scene) 51 public NPCAvatar(
52 string firstname, string lastname, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene)
47 { 53 {
48 m_firstname = firstname; 54 m_firstname = firstname;
49 m_lastname = lastname; 55 m_lastname = lastname;
50 m_startPos = position; 56 m_startPos = position;
51 m_scene = scene; 57 m_scene = scene;
58 m_ownerID = ownerID;
59 SenseAsAgent = senseAsAgent;
52 } 60 }
53 61
54 public IScene Scene 62 public IScene Scene
@@ -56,6 +64,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
56 get { return m_scene; } 64 get { return m_scene; }
57 } 65 }
58 66
67 public UUID OwnerID
68 {
69 get { return m_ownerID; }
70 }
71
59 public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } } 72 public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } }
60 73
61 public void Say(string message) 74 public void Say(string message)
@@ -327,6 +340,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
327 public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest; 340 public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
328 public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest; 341 public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
329 public event EstateChangeInfo OnEstateChangeInfo; 342 public event EstateChangeInfo OnEstateChangeInfo;
343 public event EstateManageTelehub OnEstateManageTelehub;
330 public event ScriptReset OnScriptReset; 344 public event ScriptReset OnScriptReset;
331 public event GetScriptRunning OnGetScriptRunning; 345 public event GetScriptRunning OnGetScriptRunning;
332 public event SetScriptRunning OnSetScriptRunning; 346 public event SetScriptRunning OnSetScriptRunning;
@@ -916,6 +930,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
916 public void SendEstateCovenantInformation(UUID covenant) 930 public void SendEstateCovenantInformation(UUID covenant)
917 { 931 {
918 } 932 }
933 public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
934 {
935 }
919 public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner) 936 public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner)
920 { 937 {
921 } 938 }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 56ff367..3831d7a 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -56,6 +56,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC
56 } 56 }
57 } 57 }
58 58
59 public void PostInitialise()
60 {
61 }
62
63 public void Close()
64 {
65 }
66
67 public string Name
68 {
69 get { return "NPCModule"; }
70 }
71
72 public bool IsSharedModule
73 {
74 get { return true; }
75 }
76
59 public bool IsNPC(UUID agentId, Scene scene) 77 public bool IsNPC(UUID agentId, Scene scene)
60 { 78 {
61 // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect 79 // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect
@@ -91,9 +109,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
91 } 109 }
92 110
93 public UUID CreateNPC( 111 public UUID CreateNPC(
94 string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance) 112 string firstname,
113 string lastname,
114 Vector3 position,
115 UUID owner,
116 bool senseAsAgent,
117 Scene scene,
118 AvatarAppearance appearance)
95 { 119 {
96 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); 120 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene);
97 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); 121 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
98 122
99 m_log.DebugFormat( 123 m_log.DebugFormat(
@@ -234,38 +258,69 @@ namespace OpenSim.Region.OptionalModules.World.NPC
234 return false; 258 return false;
235 } 259 }
236 260
237 public bool DeleteNPC(UUID agentID, Scene scene) 261 public UUID GetOwner(UUID agentID)
238 { 262 {
239 lock (m_avatars) 263 lock (m_avatars)
240 { 264 {
241 if (m_avatars.ContainsKey(agentID)) 265 NPCAvatar av;
266 if (m_avatars.TryGetValue(agentID, out av))
242 { 267 {
243 scene.RemoveClient(agentID, false); 268 return av.OwnerID;
244 m_avatars.Remove(agentID);
245
246 return true;
247 } 269 }
248 } 270 }
249 271
250 return false; 272 return UUID.Zero;
251 } 273 }
252 274
253 public void PostInitialise() 275 public INPC GetNPC(UUID agentID, Scene scene)
254 { 276 {
277 lock (m_avatars)
278 {
279 if (m_avatars.ContainsKey(agentID))
280 return m_avatars[agentID];
281 else
282 return null;
283 }
255 } 284 }
256 285
257 public void Close() 286 public bool DeleteNPC(UUID agentID, Scene scene)
258 { 287 {
288 lock (m_avatars)
289 {
290 NPCAvatar av;
291 if (m_avatars.TryGetValue(agentID, out av))
292 {
293 scene.RemoveClient(agentID, false);
294 m_avatars.Remove(agentID);
295
296 return true;
297 }
298 }
299
300 return false;
259 } 301 }
260 302
261 public string Name 303 public bool CheckPermissions(UUID npcID, UUID callerID)
262 { 304 {
263 get { return "NPCModule"; } 305 lock (m_avatars)
306 {
307 NPCAvatar av;
308 if (m_avatars.TryGetValue(npcID, out av))
309 return CheckPermissions(av, callerID);
310 else
311 return false;
312 }
264 } 313 }
265 314
266 public bool IsSharedModule 315 /// <summary>
316 /// Check if the caller has permission to manipulate the given NPC.
317 /// </summary>
318 /// <param name="av"></param>
319 /// <param name="callerID"></param>
320 /// <returns>true if they do, false if they don't.</returns>
321 private bool CheckPermissions(NPCAvatar av, UUID callerID)
267 { 322 {
268 get { return true; } 323 return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID;
269 } 324 }
270 } 325 }
271} \ No newline at end of file 326}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 9c66b25..d507822 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -109,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
109 afm.SetAppearance(sp, originalTe, null); 109 afm.SetAppearance(sp, originalTe, null);
110 110
111 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 111 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
112 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); 112 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance);
113 113
114 ScenePresence npc = scene.GetScenePresence(npcId); 114 ScenePresence npc = scene.GetScenePresence(npcId);
115 115
@@ -119,6 +119,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
119 } 119 }
120 120
121 [Test] 121 [Test]
122 public void TestRemove()
123 {
124 TestHelpers.InMethod();
125// log4net.Config.XmlConfigurator.Configure();
126
127 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
128// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
129
130 Vector3 startPos = new Vector3(128, 128, 30);
131 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
132 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
133
134 npcModule.DeleteNPC(npcId, scene);
135
136 ScenePresence deletedNpc = scene.GetScenePresence(npcId);
137
138 Assert.That(deletedNpc, Is.Null);
139 }
140
141 [Test]
122 public void TestAttachments() 142 public void TestAttachments()
123 { 143 {
124 TestHelpers.InMethod(); 144 TestHelpers.InMethod();
@@ -137,7 +157,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
137 am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest); 157 am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);
138 158
139 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 159 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
140 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); 160 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance);
141 161
142 ScenePresence npc = scene.GetScenePresence(npcId); 162 ScenePresence npc = scene.GetScenePresence(npcId);
143 163
@@ -169,7 +189,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
169 189
170 Vector3 startPos = new Vector3(128, 128, 30); 190 Vector3 startPos = new Vector3(128, 128, 30);
171 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 191 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
172 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); 192 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
173 193
174 ScenePresence npc = scene.GetScenePresence(npcId); 194 ScenePresence npc = scene.GetScenePresence(npcId);
175 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); 195 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
@@ -240,7 +260,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
240 260
241 Vector3 startPos = new Vector3(128, 128, 30); 261 Vector3 startPos = new Vector3(128, 128, 30);
242 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 262 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
243 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); 263 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
244 264
245 ScenePresence npc = scene.GetScenePresence(npcId); 265 ScenePresence npc = scene.GetScenePresence(npcId);
246 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 266 SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
@@ -273,7 +293,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
273 Vector3 startPos = new Vector3(1, 1, 1); 293 Vector3 startPos = new Vector3(1, 1, 1);
274 294
275 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 295 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
276 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); 296 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
277 297
278 ScenePresence npc = scene.GetScenePresence(npcId); 298 ScenePresence npc = scene.GetScenePresence(npcId);
279 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 299 SceneObjectPart part = SceneHelpers.AddSceneObject(scene);