aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs20
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs236
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs22
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs60
7 files changed, 305 insertions, 43 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 83beff4..f7e3a59 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -149,7 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
149 } 149 }
150 } 150 }
151 151
152 public void SaveChangedAttachments(IScenePresence sp) 152 public void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted)
153 { 153 {
154// m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name); 154// m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);
155 155
@@ -158,13 +158,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
158 158
159 foreach (SceneObjectGroup grp in sp.GetAttachments()) 159 foreach (SceneObjectGroup grp in sp.GetAttachments())
160 { 160 {
161// if (grp.HasGroupChanged) // Resizer scripts? 161 grp.IsAttachment = false;
162// { 162 grp.AbsolutePosition = grp.RootPart.AttachedPos;
163 grp.IsAttachment = false; 163 UpdateKnownItem(sp, grp, saveAllScripted);
164 grp.AbsolutePosition = grp.RootPart.AttachedPos; 164 grp.IsAttachment = true;
165 UpdateKnownItem(sp, grp);
166 grp.IsAttachment = true;
167// }
168 } 165 }
169 } 166 }
170 167
@@ -466,7 +463,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
466 /// </remarks> 463 /// </remarks>
467 /// <param name="sp"></param> 464 /// <param name="sp"></param>
468 /// <param name="grp"></param> 465 /// <param name="grp"></param>
469 private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp) 466 private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted)
470 { 467 {
471 // Saving attachments for NPCs messes them up for the real owner! 468 // Saving attachments for NPCs messes them up for the real owner!
472 INPCModule module = m_scene.RequestModuleInterface<INPCModule>(); 469 INPCModule module = m_scene.RequestModuleInterface<INPCModule>();
@@ -476,7 +473,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
476 return; 473 return;
477 } 474 }
478 475
479 if (grp.HasGroupChanged || grp.ContainsScripts()) 476 if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts()))
480 { 477 {
481 m_log.DebugFormat( 478 m_log.DebugFormat(
482 "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", 479 "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
@@ -509,6 +506,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
509 if (sp.ControllingClient != null) 506 if (sp.ControllingClient != null)
510 sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0); 507 sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
511 } 508 }
509 grp.HasGroupChanged = false; // Prevent it being saved over and over
512 } 510 }
513 else 511 else
514 { 512 {
@@ -702,7 +700,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
702 group.IsAttachment = false; 700 group.IsAttachment = false;
703 group.AbsolutePosition = group.RootPart.AttachedPos; 701 group.AbsolutePosition = group.RootPart.AttachedPos;
704 702
705 UpdateKnownItem(sp, group); 703 UpdateKnownItem(sp, group, true);
706 m_scene.DeleteSceneObject(group, false); 704 m_scene.DeleteSceneObject(group, false);
707 705
708 return; 706 return;
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index b16d0d3..5c7ca22 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -353,7 +353,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
353 353
354 region.ExternalHostName = uri.Host; 354 region.ExternalHostName = uri.Host;
355 region.HttpPort = (uint)uri.Port; 355 region.HttpPort = (uint)uri.Port;
356 region.ServerURI = uri.ToString(); 356 region.ServerURI = aCircuit.ServiceURLs["HomeURI"].ToString();
357 region.RegionName = string.Empty; 357 region.RegionName = string.Empty;
358 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); 358 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0);
359 return region; 359 return region;
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index 57c109e..e3d04cd 100644
--- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
50// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 private Scene m_scene; 52 private Scene m_scene;
53 private ICommandConsole m_console;
53 54
54 public string Name { get { return "Object Commands Module"; } } 55 public string Name { get { return "Object Commands Module"; } }
55 56
@@ -75,6 +76,51 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
75// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); 76// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
76 77
77 m_scene = scene; 78 m_scene = scene;
79 m_console = MainConsole.Instance;
80
81 m_console.Commands.AddCommand("region", false, "delete object owner",
82 "delete object owner <UUID>",
83 "Delete a scene object by owner", HandleDeleteObject);
84 m_console.Commands.AddCommand("region", false, "delete object creator",
85 "delete object creator <UUID>",
86 "Delete a scene object by creator", HandleDeleteObject);
87 m_console.Commands.AddCommand("region", false, "delete object uuid",
88 "delete object uuid <UUID>",
89 "Delete a scene object by uuid", HandleDeleteObject);
90 m_console.Commands.AddCommand("region", false, "delete object name",
91 "delete object name <name>",
92 "Delete a scene object by name", HandleDeleteObject);
93 m_console.Commands.AddCommand("region", false, "delete object outside",
94 "delete object outside",
95 "Delete all scene objects outside region boundaries", HandleDeleteObject);
96
97 m_console.Commands.AddCommand(
98 "region",
99 false,
100 "show object uuid",
101 "show object uuid <UUID>",
102 "Show details of a scene object with the given UUID", HandleShowObjectByUuid);
103
104 m_console.Commands.AddCommand(
105 "region",
106 false,
107 "show object name",
108 "show object name <name>",
109 "Show details of scene objects with the given name", HandleShowObjectByName);
110
111 m_console.Commands.AddCommand(
112 "region",
113 false,
114 "show part uuid",
115 "show part uuid <UUID>",
116 "Show details of a scene object parts with the given UUID", HandleShowPartByUuid);
117
118 m_console.Commands.AddCommand(
119 "region",
120 false,
121 "show part name",
122 "show part name <name>",
123 "Show details of scene object parts with the given name", HandleShowPartByName);
78 } 124 }
79 125
80 public void RemoveRegion(Scene scene) 126 public void RemoveRegion(Scene scene)
@@ -85,26 +131,167 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
85 public void RegionLoaded(Scene scene) 131 public void RegionLoaded(Scene scene)
86 { 132 {
87// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); 133// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
134 }
88 135
89 MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner", 136 private void HandleShowObjectByUuid(string module, string[] cmd)
90 "delete object owner <UUID>", 137 {
91 "Delete object by owner", HandleDeleteObject); 138 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
92 MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator", 139 return;
93 "delete object creator <UUID>", 140
94 "Delete object by creator", HandleDeleteObject); 141 if (cmd.Length < 4)
95 MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid", 142 {
96 "delete object uuid <UUID>", 143 m_console.OutputFormat("Usage: show object uuid <uuid>");
97 "Delete object by uuid", HandleDeleteObject); 144 return;
98 MainConsole.Instance.Commands.AddCommand("region", false, "delete object name", 145 }
99 "delete object name <name>", 146
100 "Delete object by name", HandleDeleteObject); 147 UUID objectUuid;
101 MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside", 148 if (!UUID.TryParse(cmd[3], out objectUuid))
102 "delete object outside", 149 {
103 "Delete all objects outside boundaries", HandleDeleteObject); 150 m_console.OutputFormat("{0} is not a valid uuid", cmd[3]);
151 return;
152 }
153
154 SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid);
155
156 if (so == null)
157 {
158// m_console.OutputFormat("No part found with uuid {0}", objectUuid);
159 return;
160 }
161
162 StringBuilder sb = new StringBuilder();
163 AddSceneObjectReport(sb, so);
164
165 m_console.OutputFormat(sb.ToString());
166 }
167
168 private void HandleShowObjectByName(string module, string[] cmd)
169 {
170 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
171 return;
172
173 if (cmd.Length < 4)
174 {
175 m_console.OutputFormat("Usage: show object name <name>");
176 return;
177 }
178
179 string name = cmd[3];
180
181 List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
182
183 m_scene.ForEachSOG(so => { if (so.Name == name) { sceneObjects.Add(so); }});
184
185 if (sceneObjects.Count == 0)
186 {
187 m_console.OutputFormat("No objects with name {0} found in {1}", name, m_scene.RegionInfo.RegionName);
188 return;
189 }
190
191 StringBuilder sb = new StringBuilder();
192
193 foreach (SceneObjectGroup so in sceneObjects)
194 {
195 AddSceneObjectReport(sb, so);
196 sb.Append("\n");
197 }
198
199 m_console.OutputFormat(sb.ToString());
200 }
201
202 private void HandleShowPartByUuid(string module, string[] cmd)
203 {
204 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
205 return;
206
207 if (cmd.Length < 4)
208 {
209 m_console.OutputFormat("Usage: show part uuid <uuid>");
210 return;
211 }
212
213 UUID objectUuid;
214 if (!UUID.TryParse(cmd[3], out objectUuid))
215 {
216 m_console.OutputFormat("{0} is not a valid uuid", cmd[3]);
217 return;
218 }
219
220 SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid);
221
222 if (sop == null)
223 {
224// m_console.OutputFormat("No part found with uuid {0}", objectUuid);
225 return;
226 }
227
228 StringBuilder sb = new StringBuilder();
229 AddScenePartReport(sb, sop);
230
231 m_console.OutputFormat(sb.ToString());
232 }
233
234 private void HandleShowPartByName(string module, string[] cmd)
235 {
236 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
237 return;
238
239 if (cmd.Length < 4)
240 {
241 m_console.OutputFormat("Usage: show part name <name>");
242 return;
243 }
244
245 string name = cmd[3];
246
247 List<SceneObjectPart> parts = new List<SceneObjectPart>();
248
249 m_scene.ForEachSOG(so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } }));
250
251 if (parts.Count == 0)
252 {
253 m_console.OutputFormat("No parts with name {0} found in {1}", name, m_scene.RegionInfo.RegionName);
254 return;
255 }
256
257 StringBuilder sb = new StringBuilder();
258
259 foreach (SceneObjectPart part in parts)
260 {
261 AddScenePartReport(sb, part);
262 sb.Append("\n");
263 }
264
265 m_console.OutputFormat(sb.ToString());
266 }
267
268 private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so)
269 {
270 sb.AppendFormat("Name: {0}\n", so.Name);
271 sb.AppendFormat("Description: {0}\n", so.Description);
272 sb.AppendFormat("Location: {0} @ {1}\n", so.AbsolutePosition, so.Scene.RegionInfo.RegionName);
273 sb.AppendFormat("Parts: {0}\n", so.PrimCount);
274
275 return sb;
276 }
277
278 private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop)
279 {
280 sb.AppendFormat("Name: {0}\n", sop.Name);
281 sb.AppendFormat("Description: {0}\n", sop.Description);
282 sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName);
283 sb.AppendFormat("Parent: {0}",
284 sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID));
285 sb.AppendFormat("Parts: {0}\n", !sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());;
286
287 return sb;
104 } 288 }
105 289
106 private void HandleDeleteObject(string module, string[] cmd) 290 private void HandleDeleteObject(string module, string[] cmd)
107 { 291 {
292 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
293 return;
294
108 if (cmd.Length < 3) 295 if (cmd.Length < 3)
109 return; 296 return;
110 297
@@ -135,6 +322,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
135 deletes.Add(g); 322 deletes.Add(g);
136 }); 323 });
137 324
325// if (deletes.Count == 0)
326// m_console.OutputFormat("No objects were found with owner {0}", match);
327
138 break; 328 break;
139 329
140 case "creator": 330 case "creator":
@@ -147,6 +337,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
147 deletes.Add(g); 337 deletes.Add(g);
148 }); 338 });
149 339
340// if (deletes.Count == 0)
341// m_console.OutputFormat("No objects were found with creator {0}", match);
342
150 break; 343 break;
151 344
152 case "uuid": 345 case "uuid":
@@ -159,6 +352,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
159 deletes.Add(g); 352 deletes.Add(g);
160 }); 353 });
161 354
355// if (deletes.Count == 0)
356// m_console.OutputFormat("No objects were found with uuid {0}", match);
357
162 break; 358 break;
163 359
164 case "name": 360 case "name":
@@ -168,6 +364,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
168 deletes.Add(g); 364 deletes.Add(g);
169 }); 365 });
170 366
367// if (deletes.Count == 0)
368// m_console.OutputFormat("No objects were found with name {0}", o);
369
171 break; 370 break;
172 371
173 case "outside": 372 case "outside":
@@ -193,12 +392,17 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
193 deletes.Add(g); 392 deletes.Add(g);
194 }); 393 });
195 394
395// if (deletes.Count == 0)
396// m_console.OutputFormat("No objects were found outside region bounds");
397
196 break; 398 break;
197 } 399 }
198 400
401 m_console.OutputFormat("Deleting {0} objects in {1}", deletes.Count, m_scene.RegionInfo.RegionName);
402
199 foreach (SceneObjectGroup g in deletes) 403 foreach (SceneObjectGroup g in deletes)
200 { 404 {
201 MainConsole.Instance.OutputFormat("Deleting object {0}", g.UUID); 405 m_console.OutputFormat("Deleting object {0} {1}", g.UUID, g.Name);
202 m_scene.DeleteSceneObject(g, false); 406 m_scene.DeleteSceneObject(g, false);
203 } 407 }
204 } 408 }
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index a7770ad..69ce967 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Framework.Interfaces
47 /// Save the attachments that have change on this presence. 47 /// Save the attachments that have change on this presence.
48 /// </summary> 48 /// </summary>
49 /// <param name="sp"></param> 49 /// <param name="sp"></param>
50 void SaveChangedAttachments(IScenePresence sp); 50 void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted);
51 51
52 /// <summary> 52 /// <summary>
53 /// Delete all the presence's attachments from the scene 53 /// Delete all the presence's attachments from the scene
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 273d8bd..b37df82 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3191,11 +3191,11 @@ namespace OpenSim.Region.Framework.Scenes
3191 public override void RemoveClient(UUID agentID, bool closeChildAgents) 3191 public override void RemoveClient(UUID agentID, bool closeChildAgents)
3192 { 3192 {
3193 CheckHeartbeat(); 3193 CheckHeartbeat();
3194 bool childagentYN = false; 3194 bool isChildAgent = false;
3195 ScenePresence avatar = GetScenePresence(agentID); 3195 ScenePresence avatar = GetScenePresence(agentID);
3196 if (avatar != null) 3196 if (avatar != null)
3197 { 3197 {
3198 childagentYN = avatar.IsChildAgent; 3198 isChildAgent = avatar.IsChildAgent;
3199 3199
3200 if (avatar.ParentID != 0) 3200 if (avatar.ParentID != 0)
3201 { 3201 {
@@ -3206,9 +3206,9 @@ namespace OpenSim.Region.Framework.Scenes
3206 { 3206 {
3207 m_log.DebugFormat( 3207 m_log.DebugFormat(
3208 "[SCENE]: Removing {0} agent {1} from region {2}", 3208 "[SCENE]: Removing {0} agent {1} from region {2}",
3209 (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); 3209 (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName);
3210 3210
3211 m_sceneGraph.removeUserCount(!childagentYN); 3211 m_sceneGraph.removeUserCount(!isChildAgent);
3212 3212
3213 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop 3213 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
3214 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI 3214 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
@@ -3239,8 +3239,18 @@ namespace OpenSim.Region.Framework.Scenes
3239 { 3239 {
3240 m_eventManager.TriggerOnRemovePresence(agentID); 3240 m_eventManager.TriggerOnRemovePresence(agentID);
3241 3241
3242 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) 3242 if (AttachmentsModule != null && !isChildAgent && avatar.PresenceType != PresenceType.Npc)
3243 AttachmentsModule.SaveChangedAttachments(avatar); 3243 {
3244 IUserManagement uMan = RequestModuleInterface<IUserManagement>();
3245 // Don't save attachments for HG visitors, it
3246 // messes up their inventory. When a HG visitor logs
3247 // out on a foreign grid, their attachments will be
3248 // reloaded in the state they were in when they left
3249 // the home grid. This is best anyway as the visited
3250 // grid may use an incompatible script engine.
3251 if (uMan == null || uMan.IsLocalGridUser(avatar.UUID))
3252 AttachmentsModule.SaveChangedAttachments(avatar, false);
3253 }
3244 3254
3245 ForEachClient( 3255 ForEachClient(
3246 delegate(IClientAPI client) 3256 delegate(IClientAPI client)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index cf7bf16..c31cbab 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -327,6 +327,12 @@ namespace OpenSim.Region.Framework.Scenes
327 set { RootPart.Name = value; } 327 set { RootPart.Name = value; }
328 } 328 }
329 329
330 public string Description
331 {
332 get { return RootPart.Description; }
333 set { RootPart.Description = value; }
334 }
335
330 /// <summary> 336 /// <summary>
331 /// Added because the Parcel code seems to use it 337 /// Added because the Parcel code seems to use it
332 /// but not sure a object should have this 338 /// but not sure a object should have this
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 23531a9..084ef48 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -26,15 +26,16 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO;
30using System.Threading;
31using System.Collections; 29using System.Collections;
32using System.Collections.Generic; 30using System.Collections.Generic;
33using System.Diagnostics; //for [DebuggerNonUserCode] 31using System.Diagnostics; //for [DebuggerNonUserCode]
32using System.Globalization;
33using System.IO;
34using System.Reflection;
34using System.Security; 35using System.Security;
35using System.Security.Policy; 36using System.Security.Policy;
36using System.Reflection; 37using System.Text;
37using System.Globalization; 38using System.Threading;
38using System.Xml; 39using System.Xml;
39using OpenMetaverse; 40using OpenMetaverse;
40using OpenMetaverse.StructuredData; 41using OpenMetaverse.StructuredData;
@@ -341,6 +342,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
341 } 342 }
342 343
343 MainConsole.Instance.Commands.AddCommand( 344 MainConsole.Instance.Commands.AddCommand(
345 "scripts", false, "xengine status", "xengine status", "Show status information",
346 "Show status information on the script engine.",
347 HandleShowStatus);
348
349 MainConsole.Instance.Commands.AddCommand(
344 "scripts", false, "scripts show", "scripts show [<script-item-uuid>]", "Show script information", 350 "scripts", false, "scripts show", "scripts show [<script-item-uuid>]", "Show script information",
345 "Show information on all scripts known to the script engine." 351 "Show information on all scripts known to the script engine."
346 + "If a <script-item-uuid> is given then only information on that script will be shown.", 352 + "If a <script-item-uuid> is given then only information on that script will be shown.",
@@ -386,6 +392,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
386 /// <returns>true if we're okay to proceed, false if not.</returns> 392 /// <returns>true if we're okay to proceed, false if not.</returns>
387 private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action) 393 private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action)
388 { 394 {
395 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene))
396 return;
397
389 lock (m_Scripts) 398 lock (m_Scripts)
390 { 399 {
391 string rawItemId; 400 string rawItemId;
@@ -427,8 +436,32 @@ namespace OpenSim.Region.ScriptEngine.XEngine
427 } 436 }
428 } 437 }
429 438
439 private void HandleShowStatus(string module, string[] cmdparams)
440 {
441 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene))
442 return;
443
444 StringBuilder sb = new StringBuilder();
445 sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName);
446
447 lock (m_Scripts)
448 sb.AppendFormat("Scripts loaded : {0}\n", m_Scripts.Count);
449
450 sb.AppendFormat("Unique scripts : {0}\n", m_uniqueScripts.Count);
451 sb.AppendFormat("Scripts waiting for load : {0}\n", m_CompileQueue.Count);
452 sb.AppendFormat("Allocated threads : {0}\n", m_ThreadPool.ActiveThreads);
453 sb.AppendFormat("In use threads : {0}\n", m_ThreadPool.InUseThreads);
454 sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks);
455// sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count);
456
457 MainConsole.Instance.OutputFormat(sb.ToString());
458 }
459
430 public void HandleShowScripts(string module, string[] cmdparams) 460 public void HandleShowScripts(string module, string[] cmdparams)
431 { 461 {
462 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene))
463 return;
464
432 if (cmdparams.Length == 2) 465 if (cmdparams.Length == 2)
433 { 466 {
434 lock (m_Scripts) 467 lock (m_Scripts)
@@ -463,10 +496,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
463 status = "running"; 496 status = "running";
464 } 497 }
465 498
466 MainConsole.Instance.OutputFormat( 499 StringBuilder sb = new StringBuilder();
467 "{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})", 500 Queue eq = instance.EventQueue;
468 instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, 501
469 sop.AbsolutePosition, status); 502 sb.AppendFormat("Script name : {0}\n", instance.ScriptName);
503 sb.AppendFormat("Status : {0}\n", status);
504
505 lock (eq)
506 sb.AppendFormat("Queued events : {0}\n", eq.Count);
507
508 sb.AppendFormat("Item UUID : {0}\n", instance.ItemID);
509 sb.AppendFormat("Containing part name: {0}\n", instance.PrimName);
510 sb.AppendFormat("Containing part UUID: {0}\n", instance.ObjectID);
511 sb.AppendFormat("Position : {0}\n", sop.AbsolutePosition);
512
513 MainConsole.Instance.OutputFormat(sb.ToString());
470 } 514 }
471 515
472 private void HandleSuspendScript(IScriptInstance instance) 516 private void HandleSuspendScript(IScriptInstance instance)