aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorDan Lake2012-02-17 13:51:54 -0800
committerDan Lake2012-02-17 13:51:54 -0800
commitb313d16493b765c3981ef3d15b8919d376733df2 (patch)
treec1111d430dcf7ecbecc3fa82a01e4e9623c1b6bc /OpenSim/Region/Framework/Scenes
parentAdded the TriggerAvatarAppearanceChanged to EventManager. It's triggered by A... (diff)
parentAdd new and updated script events (diff)
downloadopensim-SC-b313d16493b765c3981ef3d15b8919d376733df2.zip
opensim-SC-b313d16493b765c3981ef3d15b8919d376733df2.tar.gz
opensim-SC-b313d16493b765c3981ef3d15b8919d376733df2.tar.bz2
opensim-SC-b313d16493b765c3981ef3d15b8919d376733df2.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs58
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs34
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs41
8 files changed, 159 insertions, 24 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 6586437..569c235 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -187,10 +187,62 @@ namespace OpenSim.Region.Framework.Scenes
187 187
188 public event ClientClosed OnClientClosed; 188 public event ClientClosed OnClientClosed;
189 189
190 // Fired when a script is created
191 // The indication that a new script exists in this region.
192 public delegate void NewScript(UUID clientID, SceneObjectPart part, UUID itemID);
193 public event NewScript OnNewScript;
194 public virtual void TriggerNewScript(UUID clientID, SceneObjectPart part, UUID itemID)
195 {
196 NewScript handlerNewScript = OnNewScript;
197 if (handlerNewScript != null)
198 {
199 foreach (NewScript d in handlerNewScript.GetInvocationList())
200 {
201 try
202 {
203 d(clientID, part, itemID);
204 }
205 catch (Exception e)
206 {
207 m_log.ErrorFormat(
208 "[EVENT MANAGER]: Delegate for TriggerNewScript failed - continuing. {0} {1}",
209 e.Message, e.StackTrace);
210 }
211 }
212 }
213 }
214
215 //TriggerUpdateScript: triggered after Scene receives client's upload of updated script and stores it as asset
216 // An indication that the script has changed.
217 public delegate void UpdateScript(UUID clientID, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID);
218 public event UpdateScript OnUpdateScript;
219 public virtual void TriggerUpdateScript(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID)
220 {
221 UpdateScript handlerUpdateScript = OnUpdateScript;
222 if (handlerUpdateScript != null)
223 {
224 foreach (UpdateScript d in handlerUpdateScript.GetInvocationList())
225 {
226 try
227 {
228 d(clientId, itemId, primId, isScriptRunning, newAssetID);
229 }
230 catch (Exception e)
231 {
232 m_log.ErrorFormat(
233 "[EVENT MANAGER]: Delegate for TriggerUpdateScript failed - continuing. {0} {1}",
234 e.Message, e.StackTrace);
235 }
236 }
237 }
238 }
239
190 /// <summary> 240 /// <summary>
191 /// This is fired when a scene object property that a script might be interested in (such as color, scale or 241 /// ScriptChangedEvent is fired when a scene object property that a script might be interested
192 /// inventory) changes. Only enough information is sent for the LSL changed event 242 /// in (such as color, scale or inventory) changes. Only enough information sent is for the LSL changed event.
193 /// (see http://lslwiki.net/lslwiki/wakka.php?wakka=changed) 243 /// This is not an indication that the script has changed (see OnUpdateScript for that).
244 /// This event is sent to a script to tell it that some property changed on
245 /// the object the script is in. See http://lslwiki.net/lslwiki/wakka.php?wakka=changed .
194 /// </summary> 246 /// </summary>
195 public event ScriptChangedEvent OnScriptChangedEvent; 247 public event ScriptChangedEvent OnScriptChangedEvent;
196 public delegate void ScriptChangedEvent(uint localID, uint change); 248 public delegate void ScriptChangedEvent(uint localID, uint change);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 5a5307c..6cc78b8 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -283,6 +283,10 @@ namespace OpenSim.Region.Framework.Scenes
283 { 283 {
284 remoteClient.SendAgentAlertMessage("Script saved", false); 284 remoteClient.SendAgentAlertMessage("Script saved", false);
285 } 285 }
286
287 // Tell anyone managing scripts that a script has been reloaded/changed
288 EventManager.TriggerUpdateScript(remoteClient.AgentId, itemId, primId, isScriptRunning, item.AssetID);
289
286 part.ParentGroup.ResumeScripts(); 290 part.ParentGroup.ResumeScripts();
287 return errors; 291 return errors;
288 } 292 }
@@ -1624,9 +1628,13 @@ namespace OpenSim.Region.Framework.Scenes
1624 // have state in inventory 1628 // have state in inventory
1625 part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); 1629 part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0);
1626 1630
1631 // tell anyone watching that there is a new script in town
1632 EventManager.TriggerNewScript(agentID, part, copyID);
1633
1627 // m_log.InfoFormat("[PRIMINVENTORY]: " + 1634 // m_log.InfoFormat("[PRIMINVENTORY]: " +
1628 // "Rezzed script {0} into prim local ID {1} for user {2}", 1635 // "Rezzed script {0} into prim local ID {1} for user {2}",
1629 // item.inventoryName, localID, remoteClient.Name); 1636 // item.inventoryName, localID, remoteClient.Name);
1637
1630 part.ParentGroup.ResumeScripts(); 1638 part.ParentGroup.ResumeScripts();
1631 1639
1632 return part; 1640 return part;
@@ -1707,6 +1715,10 @@ namespace OpenSim.Region.Framework.Scenes
1707 1715
1708 part.Inventory.AddInventoryItem(taskItem, false); 1716 part.Inventory.AddInventoryItem(taskItem, false);
1709 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); 1717 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
1718
1719 // tell anyone managing scripts that a new script exists
1720 EventManager.TriggerNewScript(agentID, part, taskItem.ItemID);
1721
1710 part.ParentGroup.ResumeScripts(); 1722 part.ParentGroup.ResumeScripts();
1711 1723
1712 return part; 1724 return part;
@@ -1926,7 +1938,7 @@ namespace OpenSim.Region.Framework.Scenes
1926 1938
1927 foreach (SceneObjectGroup g in deleteGroups) 1939 foreach (SceneObjectGroup g in deleteGroups)
1928 { 1940 {
1929 AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 1941 AddReturn(g.OwnerID == g.GroupID ? g.LastOwnerID : g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return");
1930 } 1942 }
1931 } 1943 }
1932 } 1944 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4c8e2d2..ecc553d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3427,6 +3427,27 @@ namespace OpenSim.Region.Framework.Scenes
3427 agent.startpos.Z = 720; 3427 agent.startpos.Z = 720;
3428 } 3428 }
3429 } 3429 }
3430
3431 // Honor Estate teleport routing via Telehubs
3432 if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero && RegionInfo.EstateSettings.AllowDirectTeleport == false)
3433 {
3434 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject);
3435 // Can have multiple SpawnPoints
3436 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints();
3437 if ( spawnpoints.Count > 1)
3438 {
3439 // We have multiple SpawnPoints, Route the agent to a random one
3440 agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count)].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
3441 }
3442 else
3443 {
3444 // We have a single SpawnPoint and will route the agent to it
3445 agent.startpos = spawnpoints[0].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
3446 }
3447
3448 return true;
3449 }
3450
3430 // Honor parcel landing type and position. 3451 // Honor parcel landing type and position.
3431 if (land != null) 3452 if (land != null)
3432 { 3453 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 693a79e..e66678a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -359,7 +359,7 @@ namespace OpenSim.Region.Framework.Scenes
359 m_log.ErrorFormat( 359 m_log.ErrorFormat(
360 "[SCENEGRAPH]: Tried to add scene object {0} to {1} with illegal UUID of {2}", 360 "[SCENEGRAPH]: Tried to add scene object {0} to {1} with illegal UUID of {2}",
361 sceneObject.Name, m_parentScene.RegionInfo.RegionName, UUID.Zero); 361 sceneObject.Name, m_parentScene.RegionInfo.RegionName, UUID.Zero);
362 362
363 return false; 363 return false;
364 } 364 }
365 365
@@ -368,12 +368,12 @@ namespace OpenSim.Region.Framework.Scenes
368// m_log.DebugFormat( 368// m_log.DebugFormat(
369// "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()", 369// "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()",
370// m_parentScene.RegionInfo.RegionName, sceneObject.UUID); 370// m_parentScene.RegionInfo.RegionName, sceneObject.UUID);
371 371
372 return false; 372 return false;
373 } 373 }
374 374
375// m_log.DebugFormat( 375// m_log.DebugFormat(
376// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}", 376// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}",
377// sceneObject.Name, sceneObject.UUID, sceneObject.Parts.Length, m_parentScene.RegionInfo.RegionName); 377// sceneObject.Name, sceneObject.UUID, sceneObject.Parts.Length, m_parentScene.RegionInfo.RegionName);
378 378
379 SceneObjectPart[] parts = sceneObject.Parts; 379 SceneObjectPart[] parts = sceneObject.Parts;
@@ -409,7 +409,7 @@ namespace OpenSim.Region.Framework.Scenes
409 409
410 lock (SceneObjectGroupsByFullID) 410 lock (SceneObjectGroupsByFullID)
411 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; 411 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
412 412
413 lock (SceneObjectGroupsByFullPartID) 413 lock (SceneObjectGroupsByFullPartID)
414 { 414 {
415 foreach (SceneObjectPart part in parts) 415 foreach (SceneObjectPart part in parts)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 5b838f8..878476e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1330,7 +1330,7 @@ namespace OpenSim.Region.Framework.Scenes
1330 m_log.DebugFormat( 1330 m_log.DebugFormat(
1331 "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn", 1331 "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn",
1332 RootPart.UUID); 1332 RootPart.UUID);
1333 m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel autoreturn"); 1333 m_scene.AddReturn(OwnerID == GroupID ? LastOwnerID : OwnerID, Name, AbsolutePosition, "parcel autoreturn");
1334 m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero, 1334 m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero,
1335 DeRezAction.Return, UUID.Zero); 1335 DeRezAction.Return, UUID.Zero);
1336 1336
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 4c339d9..b130bf7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -303,6 +303,9 @@ namespace OpenSim.Region.Framework.Scenes
303 303
304// ~SceneObjectPart() 304// ~SceneObjectPart()
305// { 305// {
306// Console.WriteLine(
307// "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}",
308// Name, LocalId, ParentGroup.Name, ParentGroup.LocalId);
306// m_log.DebugFormat( 309// m_log.DebugFormat(
307// "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}", 310// "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}",
308// Name, LocalId, ParentGroup.Name, ParentGroup.LocalId); 311// Name, LocalId, ParentGroup.Name, ParentGroup.LocalId);
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 0a32214..e6b88a3 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Drawing; 30using System.Drawing;
31using System.IO; 31using System.IO;
32using System.Linq;
32using System.Reflection; 33using System.Reflection;
33using System.Xml; 34using System.Xml;
34using log4net; 35using log4net;
@@ -570,13 +571,15 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
570 571
571 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) 572 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
572 { 573 {
573 bool errors = false; 574 List<string> errorNodeNames;
574 obj.Shape = ReadShape(reader, "Shape", out errors); 575 obj.Shape = ReadShape(reader, "Shape", out errorNodeNames);
575 576
576 if (errors) 577 if (errorNodeNames != null)
578 {
577 m_log.DebugFormat( 579 m_log.DebugFormat(
578 "[SceneObjectSerializer]: Parsing PrimitiveBaseShape for object part {0} {1} encountered errors. Please see earlier log entries.", 580 "[SceneObjectSerializer]: Parsing PrimitiveBaseShape for object part {0} {1} encountered errors in properties {2}.",
579 obj.Name, obj.UUID); 581 obj.Name, obj.UUID, string.Join(", ", errorNodeNames.ToArray()));
582 }
580 } 583 }
581 584
582 private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader) 585 private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader)
@@ -1519,37 +1522,44 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1519 /// </summary> 1522 /// </summary>
1520 /// <param name="reader"></param> 1523 /// <param name="reader"></param>
1521 /// <param name="name">The name of the xml element containing the shape</param> 1524 /// <param name="name">The name of the xml element containing the shape</param>
1522 /// <param name="errors">true if any errors were encountered during parsing, false otherwise</param> 1525 /// <param name="errors">a list containing the failing node names. If no failures then null.</param>
1523 /// <returns>The shape parsed</returns> 1526 /// <returns>The shape parsed</returns>
1524 public static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name, out bool errors) 1527 public static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name, out List<string> errorNodeNames)
1525 { 1528 {
1526 errors = false; 1529 List<string> internalErrorNodeNames = null;
1527 1530
1528 PrimitiveBaseShape shape = new PrimitiveBaseShape(); 1531 PrimitiveBaseShape shape = new PrimitiveBaseShape();
1529 1532
1530 if (reader.IsEmptyElement) 1533 if (reader.IsEmptyElement)
1531 { 1534 {
1532 reader.Read(); 1535 reader.Read();
1536 errorNodeNames = null;
1533 return shape; 1537 return shape;
1534 } 1538 }
1535 1539
1536 reader.ReadStartElement(name, String.Empty); // Shape 1540 reader.ReadStartElement(name, String.Empty); // Shape
1537 1541
1538 errors = ExternalRepresentationUtils.ExecuteReadProcessors( 1542 ExternalRepresentationUtils.ExecuteReadProcessors(
1539 shape, 1543 shape,
1540 m_ShapeXmlProcessors, 1544 m_ShapeXmlProcessors,
1541 reader, 1545 reader,
1542 (o, nodeName, e) 1546 (o, nodeName, e)
1543 => 1547 =>
1544 { 1548 {
1545 m_log.DebugFormat( 1549// m_log.DebugFormat(
1546 "[SceneObjectSerializer]: Exception while parsing Shape property {0}: {1}{2}", 1550// "[SceneObjectSerializer]: Exception while parsing Shape property {0}: {1}{2}",
1547 nodeName, e.Message, e.StackTrace); 1551// nodeName, e.Message, e.StackTrace);
1552 if (internalErrorNodeNames == null)
1553 internalErrorNodeNames = new List<string>();
1554
1555 internalErrorNodeNames.Add(nodeName);
1548 } 1556 }
1549 ); 1557 );
1550 1558
1551 reader.ReadEndElement(); // Shape 1559 reader.ReadEndElement(); // Shape
1552 1560
1561 errorNodeNames = internalErrorNodeNames;
1562
1553 return shape; 1563 return shape;
1554 } 1564 }
1555 1565
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 80f198d..7737d8e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Threading;
30using NUnit.Framework; 31using NUnit.Framework;
31using OpenMetaverse; 32using OpenMetaverse;
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -43,6 +44,42 @@ namespace OpenSim.Region.Framework.Scenes.Tests
43 [TestFixture] 44 [TestFixture]
44 public class SceneObjectBasicTests 45 public class SceneObjectBasicTests
45 { 46 {
47// [TearDown]
48// public void TearDown()
49// {
50// Console.WriteLine("TearDown");
51// GC.Collect();
52// Thread.Sleep(3000);
53// }
54
55// public class GcNotify
56// {
57// public static AutoResetEvent gcEvent = new AutoResetEvent(false);
58// private static bool _initialized = false;
59//
60// public static void Initialize()
61// {
62// if (!_initialized)
63// {
64// _initialized = true;
65// new GcNotify();
66// }
67// }
68//
69// private GcNotify(){}
70//
71// ~GcNotify()
72// {
73// if (!Environment.HasShutdownStarted &&
74// !AppDomain.CurrentDomain.IsFinalizingForUnload())
75// {
76// Console.WriteLine("GcNotify called");
77// gcEvent.Set();
78// new GcNotify();
79// }
80// }
81// }
82
46 /// <summary> 83 /// <summary>
47 /// Test adding an object to a scene. 84 /// Test adding an object to a scene.
48 /// </summary> 85 /// </summary>
@@ -147,11 +184,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
147 public void TestDeleteSceneObject() 184 public void TestDeleteSceneObject()
148 { 185 {
149 TestHelpers.InMethod(); 186 TestHelpers.InMethod();
150 187
151 TestScene scene = SceneHelpers.SetupScene(); 188 TestScene scene = SceneHelpers.SetupScene();
152 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 189 SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
153 scene.DeleteSceneObject(part.ParentGroup, false); 190 scene.DeleteSceneObject(part.ParentGroup, false);
154 191
155 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 192 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
156 Assert.That(retrievedPart, Is.Null); 193 Assert.That(retrievedPart, Is.Null);
157 } 194 }