aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorubit2013-04-28 20:40:11 +0200
committerubit2013-04-28 20:40:11 +0200
commit61ea7ee5a94e5e3d33fc77c1c316318850309c42 (patch)
tree1e589fc3b448b580d1cc25b52215ef5ce2d7ae78 /OpenSim/Region/Framework
parentMerge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork (diff)
parentController module for dynamic floaters (WIP) (diff)
downloadopensim-SC-61ea7ee5a94e5e3d33fc77c1c316318850309c42.zip
opensim-SC-61ea7ee5a94e5e3d33fc77c1c316318850309c42.tar.gz
opensim-SC-61ea7ee5a94e5e3d33fc77c1c316318850309c42.tar.bz2
opensim-SC-61ea7ee5a94e5e3d33fc77c1c316318850309c42.tar.xz
Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork
Conflicts: bin/Regions/Regions.ini.example
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/IDynamicFloaterModule.cs (renamed from OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs)27
-rw-r--r--OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs (renamed from OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs)74
-rw-r--r--OpenSim/Region/Framework/Interfaces/IHttpRequests.cs3
-rw-r--r--OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs30
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISceneCommandsModule.cs (renamed from OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineInterface.cs)21
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs11
-rw-r--r--OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs1
-rw-r--r--OpenSim/Region/Framework/Properties/AssemblyInfo.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs57
-rw-r--r--OpenSim/Region/Framework/Scenes/Border.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/EntityManager.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs124
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs89
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs562
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs32
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs65
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs229
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs230
-rw-r--r--OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineLoader.cs119
-rw-r--r--OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs107
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs22
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs101
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs83
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs43
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs103
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs162
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs137
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs10
48 files changed, 1571 insertions, 971 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index eaaf7a3..3c1247f 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -54,6 +54,10 @@ namespace OpenSim.Region.Framework.Interfaces
54 /// RezAttachments. This should only be called upon login on the first region. 54 /// RezAttachments. This should only be called upon login on the first region.
55 /// Attachment rezzings on crossings and TPs are done in a different way. 55 /// Attachment rezzings on crossings and TPs are done in a different way.
56 /// </summary> 56 /// </summary>
57 /// <remarks>
58 /// This is only actually necessary for viewers which do not have a current outfit folder (these viewers make
59 /// their own attachment calls on login) and agents which have attachments but no viewer (e.g. NPCs).
60 /// </remarks>
57 /// <param name="sp"></param> 61 /// <param name="sp"></param>
58 void RezAttachments(IScenePresence sp); 62 void RezAttachments(IScenePresence sp);
59 63
@@ -77,14 +81,16 @@ namespace OpenSim.Region.Framework.Interfaces
77 void DeleteAttachmentsFromScene(IScenePresence sp, bool silent); 81 void DeleteAttachmentsFromScene(IScenePresence sp, bool silent);
78 82
79 /// <summary> 83 /// <summary>
80 /// Attach an object to an avatar 84 /// Attach an object to an avatar.
81 /// </summary> 85 /// </summary>
82 /// <param name="sp"></param> 86 /// <param name="sp"></param>
83 /// <param name="grp"></param> 87 /// <param name="grp"></param>
84 /// <param name="AttachmentPt"></param> 88 /// <param name="AttachmentPt"></param>
85 /// <param name="silent"></param> 89 /// <param name="silent"></param>
90 /// <param name="addToInventory">If true then add object to user inventory</param>
91 /// <param name="append">Append to attachment point rather than replace.</param>
86 /// <returns>true if the object was successfully attached, false otherwise</returns> 92 /// <returns>true if the object was successfully attached, false otherwise</returns>
87 bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool useAttachmentInfo, bool temp, bool append); 93 bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool useAttachmentInfo, bool addToInventory, bool append);
88 94
89 /// <summary> 95 /// <summary>
90 /// Rez an attachment from user inventory and change inventory status to match. 96 /// Rez an attachment from user inventory and change inventory status to match.
diff --git a/OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs b/OpenSim/Region/Framework/Interfaces/IDynamicFloaterModule.cs
index f3be028..5e633e6 100644
--- a/OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs
+++ b/OpenSim/Region/Framework/Interfaces/IDynamicFloaterModule.cs
@@ -25,22 +25,27 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic;
28using OpenMetaverse; 29using OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes;
29 32
30namespace OpenSim.Region.Framework.Scenes.Scripting 33namespace OpenSim.Region.Framework.Interfaces
31{ 34{
32 public interface IScriptHost 35 public delegate bool HandlerDelegate(IClientAPI client, FloaterData data, string[] msg);
36
37 public abstract class FloaterData
33 { 38 {
34 string Name { get; set; } 39 public abstract int Channel { get; }
35 string Description { get; set; } 40 public abstract string FloaterName { get; }
41 public virtual string XmlName { get; set; }
42 public virtual HandlerDelegate Handler { get; set; }
43 }
36 44
37 UUID UUID { get; }
38 UUID OwnerID { get; }
39 UUID CreatorID { get; }
40 Vector3 AbsolutePosition { get; }
41 45
42 string SitName { get; set; } 46 public interface IDynamicFloaterModule
43 string TouchName { get; set; } 47 {
44 void SetText(string text, Vector3 color, double alpha); 48 void DoUserFloater(UUID agentID, FloaterData dialogData, string configuration);
49 void FloaterControl(ScenePresence sp, FloaterData d, string msg);
45 } 50 }
46} 51}
diff --git a/OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs b/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs
index d7198f0..08b71e4 100644
--- a/OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs
+++ b/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs
@@ -25,67 +25,33 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System.Collections.Generic;
29using OpenMetaverse; 29using OpenMetaverse;
30using log4net;
31using System.Reflection;
32using OpenSim.Framework; 30using OpenSim.Framework;
33 31
34namespace OpenSim.Region.Framework.Scenes.Scripting 32namespace OpenSim.Region.Framework.Interfaces
35{ 33{
36 public class NullScriptHost : IScriptHost 34 public enum InsertLocation : int
37 { 35 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 36 Agent = 1,
39 37 World = 2,
40 private Vector3 m_pos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 30); 38 Tools = 3,
41 39 Advanced = 4,
42 public string Name 40 Admin = 5
43 { 41 }
44 get { return "Object"; }
45 set { }
46 }
47
48 public string SitName
49 {
50 get { return String.Empty; }
51 set { }
52 }
53
54 public string TouchName
55 {
56 get { return String.Empty; }
57 set { }
58 }
59
60 public string Description
61 {
62 get { return String.Empty; }
63 set { }
64 }
65
66 public UUID UUID
67 {
68 get { return UUID.Zero; }
69 }
70
71 public UUID OwnerID
72 {
73 get { return UUID.Zero; }
74 }
75 42
76 public UUID CreatorID 43 public enum UserMode : int
77 { 44 {
78 get { return UUID.Zero; } 45 Normal = 0,
79 } 46 God = 3
47 }
80 48
81 public Vector3 AbsolutePosition 49 public delegate void CustomMenuHandler(string action, UUID agentID, List<uint> selection);
82 {
83 get { return m_pos; }
84 }
85 50
86 public void SetText(string text, Vector3 color, double alpha) 51 public interface IDynamicMenuModule
87 { 52 {
88 m_log.Warn("Tried to SetText "+text+" on NullScriptHost"); 53 void AddMenuItem(UUID agentID, string title, InsertLocation location, UserMode mode, CustomMenuHandler handler);
89 } 54 void AddMenuItem(string title, InsertLocation location, UserMode mode, CustomMenuHandler handler);
55 void RemoveMenuItem(string action);
90 } 56 }
91} 57}
diff --git a/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs b/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs
index de0f2a3..eb6c5ac 100644
--- a/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs
+++ b/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs
@@ -36,6 +36,9 @@ namespace OpenSim.Region.Framework.Interfaces
36 HTTP_MIMETYPE = 1, 36 HTTP_MIMETYPE = 1,
37 HTTP_BODY_MAXLENGTH = 2, 37 HTTP_BODY_MAXLENGTH = 2,
38 HTTP_VERIFY_CERT = 3, 38 HTTP_VERIFY_CERT = 3,
39 HTTP_VERBOSE_THROTTLE = 4,
40 HTTP_CUSTOM_HEADER = 5,
41 HTTP_PRAGMA_NO_CACHE = 6
39 } 42 }
40 43
41 public interface IHttpRequestModule 44 public interface IHttpRequestModule
diff --git a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs
index da39e95..b67312e 100644
--- a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs
@@ -31,18 +31,46 @@ using OpenMetaverse;
31 31
32namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Region.Framework.Interfaces
33{ 33{
34 // these could be expanded at some point to provide more type information
35 // for now value accounts for all base types
36 public enum JsonStoreNodeType
37 {
38 Undefined = 0,
39 Object = 1,
40 Array = 2,
41 Value = 3
42 }
43
44 public enum JsonStoreValueType
45 {
46 Undefined = 0,
47 Boolean = 1,
48 Integer = 2,
49 Float = 3,
50 String = 4,
51 UUID = 5
52 }
53
34 public delegate void TakeValueCallback(string s); 54 public delegate void TakeValueCallback(string s);
35 55
36 public interface IJsonStoreModule 56 public interface IJsonStoreModule
37 { 57 {
58 bool AttachObjectStore(UUID objectID);
38 bool CreateStore(string value, ref UUID result); 59 bool CreateStore(string value, ref UUID result);
39 bool DestroyStore(UUID storeID); 60 bool DestroyStore(UUID storeID);
40 bool TestPath(UUID storeID, string path, bool useJson); 61
62 JsonStoreNodeType GetNodeType(UUID storeID, string path);
63 JsonStoreValueType GetValueType(UUID storeID, string path);
64
65 bool TestStore(UUID storeID);
66
41 bool SetValue(UUID storeID, string path, string value, bool useJson); 67 bool SetValue(UUID storeID, string path, string value, bool useJson);
42 bool RemoveValue(UUID storeID, string path); 68 bool RemoveValue(UUID storeID, string path);
43 bool GetValue(UUID storeID, string path, bool useJson, out string value); 69 bool GetValue(UUID storeID, string path, bool useJson, out string value);
44 70
45 void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); 71 void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback);
46 void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); 72 void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback);
73
74 int GetArrayLength(UUID storeID, string path);
47 } 75 }
48} 76}
diff --git a/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineInterface.cs b/OpenSim/Region/Framework/Interfaces/ISceneCommandsModule.cs
index 812a21c..c5e678b 100644
--- a/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineInterface.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISceneCommandsModule.cs
@@ -9,7 +9,7 @@
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
@@ -25,14 +25,19 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28//TODO: WHERE TO PLACE THIS? 28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
29 33
30namespace OpenSim.Region.Framework.Scenes.Scripting 34namespace OpenSim.Region.Framework.Interfaces
31{ 35{
32 public interface ScriptEngineInterface 36 public interface ISceneCommandsModule
33 { 37 {
34 void InitializeEngine(Scene Sceneworld); 38 /// <summary>
35 void Shutdown(); 39 /// Sets the scene debug options.
36// void StartScript(string ScriptID, IScriptHost ObjectID); 40 /// </summary>
41 void SetSceneDebugOptions(Dictionary<string, string> options);
37 } 42 }
38} 43} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index 143af48..ced4e91 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -52,7 +52,18 @@ namespace OpenSim.Region.Framework.Interfaces
52 string GetXMLState(UUID itemID); 52 string GetXMLState(UUID itemID);
53 bool SetXMLState(UUID itemID, string xml); 53 bool SetXMLState(UUID itemID, string xml);
54 54
55 /// <summary>
56 /// Post a script event to a single script.
57 /// </summary>
58 /// <returns>true if the post suceeded, false if it did not</returns>
59 /// <param name='itemID'>The item ID of the script.</param>
60 /// <param name='name'>The name of the event.</param>
61 /// <param name='args'>
62 /// The arguments of the event. These are in the order in which they appear.
63 /// e.g. for http_request this will be an object array of key request_id, string method, string body
64 /// </param>
55 bool PostScriptEvent(UUID itemID, string name, Object[] args); 65 bool PostScriptEvent(UUID itemID, string name, Object[] args);
66
56 bool PostObjectEvent(UUID itemID, string name, Object[] args); 67 bool PostObjectEvent(UUID itemID, string name, Object[] args);
57 68
58 /// <summary> 69 /// <summary>
diff --git a/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs b/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs
index 6db6674..093d3f0 100644
--- a/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs
+++ b/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs
@@ -34,5 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces
34 void RegisterNewReceiver(IScriptModule scriptEngine, UUID channelID, UUID objectID, UUID itemID, string url); 34 void RegisterNewReceiver(IScriptModule scriptEngine, UUID channelID, UUID objectID, UUID itemID, string url);
35 void ScriptRemoved(UUID itemID); 35 void ScriptRemoved(UUID itemID);
36 void ObjectRemoved(UUID objectID); 36 void ObjectRemoved(UUID objectID);
37 void UnRegisterReceiver(string channelID, UUID itemID);
37 } 38 }
38} 39}
diff --git a/OpenSim/Region/Framework/Properties/AssemblyInfo.cs b/OpenSim/Region/Framework/Properties/AssemblyInfo.cs
index 9b504c0..167c248 100644
--- a/OpenSim/Region/Framework/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/Framework/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.7.5.*")] 32[assembly: AssemblyVersion("0.7.6.*")]
33[assembly: AssemblyFileVersion("1.0.0.0")] 33
diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
index 65ae445..66edfed 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
@@ -87,13 +87,24 @@ namespace OpenSim.Region.Framework.Scenes.Animation
87 return false; 87 return false;
88 } 88 }
89 89
90 public bool Remove(UUID animID) 90 /// <summary>
91 /// Remove the specified animation
92 /// </summary>
93 /// <param name='animID'></param>
94 /// <param name='allowNoDefault'>
95 /// If true, then the default animation can be entirely removed.
96 /// If false, then removing the default animation will reset it to the simulator default (currently STAND).
97 /// </param>
98 public bool Remove(UUID animID, bool allowNoDefault)
91 { 99 {
92 lock (m_animations) 100 lock (m_animations)
93 { 101 {
94 if (m_defaultAnimation.AnimID == animID) 102 if (m_defaultAnimation.AnimID == animID)
95 { 103 {
96 m_defaultAnimation = new OpenSim.Framework.Animation(UUID.Zero, 1, UUID.Zero); 104 if (allowNoDefault)
105 m_defaultAnimation = new OpenSim.Framework.Animation(UUID.Zero, 1, UUID.Zero);
106 else
107 ResetDefaultAnimation();
97 } 108 }
98 else if (HasAnimation(animID)) 109 else if (HasAnimation(animID))
99 { 110 {
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index 9458079..65c279e 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -26,9 +26,10 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Threading;
30using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection; 31using System.Reflection;
32using System.Threading;
32using log4net; 33using log4net;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenSim.Framework; 35using OpenSim.Framework;
@@ -86,6 +87,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
86 return; 87 return;
87 88
88 // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); 89 // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name);
90 if (m_scenePresence.Scene.DebugAnimations)
91 m_log.DebugFormat(
92 "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}",
93 GetAnimName(animID), animID, m_scenePresence.Name);
89 94
90 if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) 95 if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID))
91 SendAnimPack(); 96 SendAnimPack();
@@ -108,12 +113,25 @@ namespace OpenSim.Region.Framework.Scenes.Animation
108 AddAnimation(animID, objectID); 113 AddAnimation(animID, objectID);
109 } 114 }
110 115
111 public void RemoveAnimation(UUID animID) 116 /// <summary>
117 /// Remove the specified animation
118 /// </summary>
119 /// <param name='animID'></param>
120 /// <param name='allowNoDefault'>
121 /// If true, then the default animation can be entirely removed.
122 /// If false, then removing the default animation will reset it to the simulator default (currently STAND).
123 /// </param>
124 public void RemoveAnimation(UUID animID, bool allowNoDefault)
112 { 125 {
113 if (m_scenePresence.IsChildAgent) 126 if (m_scenePresence.IsChildAgent)
114 return; 127 return;
115 128
116 if (m_animations.Remove(animID)) 129 if (m_scenePresence.Scene.DebugAnimations)
130 m_log.DebugFormat(
131 "[SCENE PRESENCE ANIMATOR]: Removing animation {0} {1} for {2}",
132 GetAnimName(animID), animID, m_scenePresence.Name);
133
134 if (m_animations.Remove(animID, allowNoDefault))
117 SendAnimPack(); 135 SendAnimPack();
118 } 136 }
119 137
@@ -127,7 +145,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
127 if (addRemove) 145 if (addRemove)
128 m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero); 146 m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero);
129 else 147 else
130 m_animations.Remove(animID); 148 m_animations.Remove(animID, true);
131 } 149 }
132 if(sendPack) 150 if(sendPack)
133 SendAnimPack(); 151 SendAnimPack();
@@ -145,14 +163,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation
145 if (animID == UUID.Zero) 163 if (animID == UUID.Zero)
146 return; 164 return;
147 165
148 RemoveAnimation(animID); 166 RemoveAnimation(animID, true);
149 } 167 }
150 168
151 public void ResetAnimations() 169 public void ResetAnimations()
152 { 170 {
153// m_log.DebugFormat( 171 if (m_scenePresence.Scene.DebugAnimations)
154// "[SCENE PRESENCE ANIMATOR]: Resetting animations for {0} in {1}", 172 m_log.DebugFormat(
155// m_scenePresence.Name, m_scenePresence.Scene.RegionInfo.RegionName); 173 "[SCENE PRESENCE ANIMATOR]: Resetting animations for {0} in {1}",
174 m_scenePresence.Name, m_scenePresence.Scene.RegionInfo.RegionName);
156 175
157 m_animations.Clear(); 176 m_animations.Clear();
158 } 177 }
@@ -519,6 +538,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation
519 if (m_scenePresence.IsChildAgent) 538 if (m_scenePresence.IsChildAgent)
520 return; 539 return;
521 540
541// m_log.DebugFormat(
542// "[SCENE PRESENCE ANIMATOR]: Sending anim pack with animations '{0}', sequence '{1}', uuids '{2}'",
543// string.Join(",", Array.ConvertAll<UUID, string>(animations, a => a.ToString())),
544// string.Join(",", Array.ConvertAll<int, string>(seqs, s => s.ToString())),
545// string.Join(",", Array.ConvertAll<UUID, string>(objectIDs, o => o.ToString())));
546
522 m_scenePresence.Scene.ForEachClient( 547 m_scenePresence.Scene.ForEachClient(
523 delegate(IClientAPI client) 548 delegate(IClientAPI client)
524 { 549 {
@@ -557,5 +582,21 @@ namespace OpenSim.Region.Framework.Scenes.Animation
557 582
558 SendAnimPack(animIDs, sequenceNums, objectIDs); 583 SendAnimPack(animIDs, sequenceNums, objectIDs);
559 } 584 }
585
586 public string GetAnimName(UUID animId)
587 {
588 string animName;
589
590 if (!DefaultAvatarAnimations.AnimsNames.TryGetValue(animId, out animName))
591 {
592 AssetMetadata amd = m_scenePresence.Scene.AssetService.GetMetadata(animId.ToString());
593 if (amd != null)
594 animName = amd.Name;
595 else
596 animName = "Unknown";
597 }
598
599 return animName;
600 }
560 } 601 }
561} 602}
diff --git a/OpenSim/Region/Framework/Scenes/Border.cs b/OpenSim/Region/Framework/Scenes/Border.cs
index c6a6511..08c0c31 100644
--- a/OpenSim/Region/Framework/Scenes/Border.cs
+++ b/OpenSim/Region/Framework/Scenes/Border.cs
@@ -33,8 +33,7 @@ using OpenMetaverse;
33namespace OpenSim.Region.Framework.Scenes 33namespace OpenSim.Region.Framework.Scenes
34{ 34{
35 public class Border 35 public class Border
36 { 36 {
37
38 /// <summary> 37 /// <summary>
39 /// Line perpendicular to the Direction Cardinal. Z value is the 38 /// Line perpendicular to the Direction Cardinal. Z value is the
40 /// </summary> 39 /// </summary>
@@ -81,6 +80,10 @@ namespace OpenSim.Region.Framework.Scenes
81 TriggerRegionY = triggerRegionY; 80 TriggerRegionY = triggerRegionY;
82 } 81 }
83 82
83 /// <summary>
84 /// Tests to see if the given position would cross this border.
85 /// </summary>
86 /// <returns></returns>
84 public bool TestCross(Vector3 position) 87 public bool TestCross(Vector3 position)
85 { 88 {
86 bool result = false; 89 bool result = false;
diff --git a/OpenSim/Region/Framework/Scenes/EntityManager.cs b/OpenSim/Region/Framework/Scenes/EntityManager.cs
index b788a3c..7181313 100644
--- a/OpenSim/Region/Framework/Scenes/EntityManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EntityManager.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using log4net; 32using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework;
34 35
35namespace OpenSim.Region.Framework.Scenes 36namespace OpenSim.Region.Framework.Scenes
36{ 37{
@@ -38,7 +39,8 @@ namespace OpenSim.Region.Framework.Scenes
38 { 39 {
39// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 40// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 41
41 private readonly DoubleDictionary<UUID, uint, EntityBase> m_entities = new DoubleDictionary<UUID, uint, EntityBase>(); 42 private readonly DoubleDictionaryThreadAbortSafe<UUID, uint, EntityBase> m_entities
43 = new DoubleDictionaryThreadAbortSafe<UUID, uint, EntityBase>();
42 44
43 public int Count 45 public int Count
44 { 46 {
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 5b1c9f4..4733547 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -550,6 +550,20 @@ namespace OpenSim.Region.Framework.Scenes
550 /// </remarks> 550 /// </remarks>
551 public event ScriptControlEvent OnScriptControlEvent; 551 public event ScriptControlEvent OnScriptControlEvent;
552 552
553 public delegate void ScriptMovingStartEvent(uint localID);
554
555 /// <summary>
556 /// TODO: Should be triggered when a physics object starts moving.
557 /// </summary>
558 public event ScriptMovingStartEvent OnScriptMovingStartEvent;
559
560 public delegate void ScriptMovingEndEvent(uint localID);
561
562 /// <summary>
563 /// TODO: Should be triggered when a physics object stops moving.
564 /// </summary>
565 public event ScriptMovingEndEvent OnScriptMovingEndEvent;
566
553 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); 567 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
554 568
555 /// <summary> 569 /// <summary>
@@ -755,7 +769,7 @@ namespace OpenSim.Region.Framework.Scenes
755 public event ScriptTimerEvent OnScriptTimerEvent; 769 public event ScriptTimerEvent OnScriptTimerEvent;
756 */ 770 */
757 771
758 public delegate void EstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour); 772 public delegate void EstateToolsSunUpdate(ulong regionHandle);
759 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID); 773 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID);
760 774
761 public event EstateToolsSunUpdate OnEstateToolsSunUpdate; 775 public event EstateToolsSunUpdate OnEstateToolsSunUpdate;
@@ -778,6 +792,19 @@ namespace OpenSim.Region.Framework.Scenes
778 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); 792 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
779 793
780 /// <summary> 794 /// <summary>
795 /// Triggered when an object is placed into the physical scene (PhysicsActor created).
796 /// </summary>
797 public event Action<SceneObjectPart> OnObjectAddedToPhysicalScene;
798 /// <summary>
799 /// Triggered when an object is removed from the physical scene (PhysicsActor destroyed).
800 /// </summary>
801 /// <remarks>
802 /// Note: this is triggered just before the PhysicsActor is removed from the
803 /// physics engine so the receiver can do any necessary cleanup before its destruction.
804 /// </remarks>
805 public event Action<SceneObjectPart> OnObjectRemovedFromPhysicalScene;
806
807 /// <summary>
781 /// Triggered when an object is removed from the scene. 808 /// Triggered when an object is removed from the scene.
782 /// </summary> 809 /// </summary>
783 /// <remarks> 810 /// <remarks>
@@ -1527,6 +1554,48 @@ namespace OpenSim.Region.Framework.Scenes
1527 } 1554 }
1528 } 1555 }
1529 1556
1557 public void TriggerObjectAddedToPhysicalScene(SceneObjectPart obj)
1558 {
1559 Action<SceneObjectPart> handler = OnObjectAddedToPhysicalScene;
1560 if (handler != null)
1561 {
1562 foreach (Action<SceneObjectPart> d in handler.GetInvocationList())
1563 {
1564 try
1565 {
1566 d(obj);
1567 }
1568 catch (Exception e)
1569 {
1570 m_log.ErrorFormat(
1571 "[EVENT MANAGER]: Delegate for TriggerObjectAddedToPhysicalScene failed - continuing. {0} {1}",
1572 e.Message, e.StackTrace);
1573 }
1574 }
1575 }
1576 }
1577
1578 public void TriggerObjectRemovedFromPhysicalScene(SceneObjectPart obj)
1579 {
1580 Action<SceneObjectPart> handler = OnObjectRemovedFromPhysicalScene;
1581 if (handler != null)
1582 {
1583 foreach (Action<SceneObjectPart> d in handler.GetInvocationList())
1584 {
1585 try
1586 {
1587 d(obj);
1588 }
1589 catch (Exception e)
1590 {
1591 m_log.ErrorFormat(
1592 "[EVENT MANAGER]: Delegate for TriggerObjectRemovedFromPhysicalScene failed - continuing. {0} {1}",
1593 e.Message, e.StackTrace);
1594 }
1595 }
1596 }
1597 }
1598
1530 public void TriggerShutdown() 1599 public void TriggerShutdown()
1531 { 1600 {
1532 Action handlerShutdown = OnShutdown; 1601 Action handlerShutdown = OnShutdown;
@@ -2238,6 +2307,48 @@ namespace OpenSim.Region.Framework.Scenes
2238 } 2307 }
2239 } 2308 }
2240 2309
2310 public void TriggerMovingStartEvent(uint localID)
2311 {
2312 ScriptMovingStartEvent handlerScriptMovingStartEvent = OnScriptMovingStartEvent;
2313 if (handlerScriptMovingStartEvent != null)
2314 {
2315 foreach (ScriptMovingStartEvent d in handlerScriptMovingStartEvent.GetInvocationList())
2316 {
2317 try
2318 {
2319 d(localID);
2320 }
2321 catch (Exception e)
2322 {
2323 m_log.ErrorFormat(
2324 "[EVENT MANAGER]: Delegate for TriggerMovingStartEvent failed - continuing. {0} {1}",
2325 e.Message, e.StackTrace);
2326 }
2327 }
2328 }
2329 }
2330
2331 public void TriggerMovingEndEvent(uint localID)
2332 {
2333 ScriptMovingEndEvent handlerScriptMovingEndEvent = OnScriptMovingEndEvent;
2334 if (handlerScriptMovingEndEvent != null)
2335 {
2336 foreach (ScriptMovingEndEvent d in handlerScriptMovingEndEvent.GetInvocationList())
2337 {
2338 try
2339 {
2340 d(localID);
2341 }
2342 catch (Exception e)
2343 {
2344 m_log.ErrorFormat(
2345 "[EVENT MANAGER]: Delegate for TriggerMovingEndEvent failed - continuing. {0} {1}",
2346 e.Message, e.StackTrace);
2347 }
2348 }
2349 }
2350 }
2351
2241 public void TriggerRequestChangeWaterHeight(float height) 2352 public void TriggerRequestChangeWaterHeight(float height)
2242 { 2353 {
2243 if (height < 0) 2354 if (height < 0)
@@ -2536,13 +2647,10 @@ namespace OpenSim.Region.Framework.Scenes
2536 } 2647 }
2537 2648
2538 /// <summary> 2649 /// <summary>
2539 /// Updates the system as to how the position of the sun should be handled. 2650 /// Called when the sun's position parameters have changed in the Region and/or Estate
2540 /// </summary> 2651 /// </summary>
2541 /// <param name="regionHandle"></param> 2652 /// <param name="regionHandle">The region that changed</param>
2542 /// <param name="FixedTime">True if the Sun Position is fixed</param> 2653 public void TriggerEstateToolsSunUpdate(ulong regionHandle)
2543 /// <param name="useEstateTime">True if the Estate Settings should be used instead of region</param>
2544 /// <param name="FixedSunHour">The hour 0.0 <= FixedSunHour <= 24.0 at which the sun is fixed at. Sun Hour 0 is sun-rise, when Day/Night ratio is 1:1</param>
2545 public void TriggerEstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool useEstateTime, float FixedSunHour)
2546 { 2654 {
2547 EstateToolsSunUpdate handlerEstateToolsSunUpdate = OnEstateToolsSunUpdate; 2655 EstateToolsSunUpdate handlerEstateToolsSunUpdate = OnEstateToolsSunUpdate;
2548 if (handlerEstateToolsSunUpdate != null) 2656 if (handlerEstateToolsSunUpdate != null)
@@ -2551,7 +2659,7 @@ namespace OpenSim.Region.Framework.Scenes
2551 { 2659 {
2552 try 2660 try
2553 { 2661 {
2554 d(regionHandle, FixedTime, useEstateTime, FixedSunHour); 2662 d(regionHandle);
2555 } 2663 }
2556 catch (Exception e) 2664 catch (Exception e)
2557 { 2665 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 4130029..d2e41f8 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -39,6 +39,7 @@ using OpenSim.Region.Framework;
39using OpenSim.Framework.Client; 39using OpenSim.Framework.Client;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes.Serialization; 41using OpenSim.Region.Framework.Scenes.Serialization;
42using PermissionMask = OpenSim.Framework.PermissionMask;
42 43
43namespace OpenSim.Region.Framework.Scenes 44namespace OpenSim.Region.Framework.Scenes
44{ 45{
@@ -412,18 +413,57 @@ namespace OpenSim.Region.Framework.Scenes
412 413
413 if (itemUpd.NextPermissions != 0) // Use this to determine validity. Can never be 0 if valid 414 if (itemUpd.NextPermissions != 0) // Use this to determine validity. Can never be 0 if valid
414 { 415 {
416 // Create a set of base permissions that will not include export if the user
417 // is not allowed to change the export flag.
418 bool denyExportChange = false;
419
420 m_log.InfoFormat("[XXX]: B: {0} O: {1} E: {2}", itemUpd.BasePermissions, itemUpd.CurrentPermissions, itemUpd.EveryOnePermissions);
421
422 // If the user is not the creator or doesn't have "E" in both "B" and "O", deny setting export
423 if ((item.BasePermissions & (uint)(PermissionMask.All | PermissionMask.Export)) != (uint)(PermissionMask.All | PermissionMask.Export) || (item.CurrentPermissions & (uint)PermissionMask.Export) == 0 || item.CreatorIdAsUuid != item.Owner)
424 denyExportChange = true;
425
426 m_log.InfoFormat("[XXX]: Deny Export Update {0}", denyExportChange);
427
428 // If it is already set, force it set and also force full perm
429 // else prevent setting it. It can and should never be set unless
430 // set in base, so the condition above is valid
431 if (denyExportChange)
432 {
433 // If we are not allowed to change it, then force it to the
434 // original item's setting and if it was on, also force full perm
435 if ((item.EveryOnePermissions & (uint)PermissionMask.Export) != 0)
436 {
437 itemUpd.NextPermissions = (uint)(PermissionMask.All);
438 itemUpd.EveryOnePermissions |= (uint)PermissionMask.Export;
439 }
440 else
441 {
442 itemUpd.EveryOnePermissions &= ~(uint)PermissionMask.Export;
443 }
444 }
445 else
446 {
447 // If the new state is exportable, force full perm
448 if ((itemUpd.EveryOnePermissions & (uint)PermissionMask.Export) != 0)
449 {
450 m_log.InfoFormat("[XXX]: Force full perm");
451 itemUpd.NextPermissions = (uint)(PermissionMask.All);
452 }
453 }
454
415 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) 455 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions))
416 item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; 456 item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner;
417 item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions; 457 item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions;
458
418 if (item.EveryOnePermissions != (itemUpd.EveryOnePermissions & item.BasePermissions)) 459 if (item.EveryOnePermissions != (itemUpd.EveryOnePermissions & item.BasePermissions))
419 item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; 460 item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone;
420 item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions; 461 item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions;
462
421 if (item.GroupPermissions != (itemUpd.GroupPermissions & item.BasePermissions)) 463 if (item.GroupPermissions != (itemUpd.GroupPermissions & item.BasePermissions))
422 item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup; 464 item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup;
423
424// m_log.DebugFormat("[USER INVENTORY]: item.Flags {0}", item.Flags);
425
426 item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions; 465 item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions;
466
427 item.GroupID = itemUpd.GroupID; 467 item.GroupID = itemUpd.GroupID;
428 item.GroupOwned = itemUpd.GroupOwned; 468 item.GroupOwned = itemUpd.GroupOwned;
429 item.CreationDate = itemUpd.CreationDate; 469 item.CreationDate = itemUpd.CreationDate;
@@ -445,6 +485,7 @@ namespace OpenSim.Region.Framework.Scenes
445 item.SaleType = itemUpd.SaleType; 485 item.SaleType = itemUpd.SaleType;
446 486
447 InventoryService.UpdateItem(item); 487 InventoryService.UpdateItem(item);
488 remoteClient.SendBulkUpdateInventory(item);
448 } 489 }
449 490
450 if (UUID.Zero != transactionID) 491 if (UUID.Zero != transactionID)
@@ -684,12 +725,10 @@ namespace OpenSim.Region.Framework.Scenes
684 itemCopy.SalePrice = item.SalePrice; 725 itemCopy.SalePrice = item.SalePrice;
685 itemCopy.SaleType = item.SaleType; 726 itemCopy.SaleType = item.SaleType;
686 727
687 if (AddInventoryItem(itemCopy)) 728 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
688 { 729 if (invAccess != null)
689 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); 730 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
690 if (invAccess != null) 731 AddInventoryItem(itemCopy);
691 Util.FireAndForget(delegate { invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); });
692 }
693 732
694 if (!Permissions.BypassPermissions()) 733 if (!Permissions.BypassPermissions())
695 { 734 {
@@ -909,7 +948,7 @@ namespace OpenSim.Region.Framework.Scenes
909 { 948 {
910 CreateNewInventoryItem( 949 CreateNewInventoryItem(
911 remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, 950 remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType,
912 (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate, transationID); 951 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate, transationID);
913 } 952 }
914 953
915 954
@@ -1038,8 +1077,8 @@ namespace OpenSim.Region.Framework.Scenes
1038 CreateNewInventoryItem( 1077 CreateNewInventoryItem(
1039 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, 1078 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
1040 name, description, 0, callbackID, asset, invType, 1079 name, description, 0, callbackID, asset, invType,
1041 (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, 1080 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All,
1042 (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); 1081 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch());
1043 } 1082 }
1044 else 1083 else
1045 { 1084 {
@@ -1786,6 +1825,21 @@ namespace OpenSim.Region.Framework.Scenes
1786 /// <returns>The part where the script was rezzed if successful. False otherwise.</returns> 1825 /// <returns>The part where the script was rezzed if successful. False otherwise.</returns>
1787 public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase) 1826 public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase)
1788 { 1827 {
1828 return RezNewScript(
1829 agentID,
1830 itemBase,
1831 "default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}");
1832 }
1833
1834 /// <summary>
1835 /// Rez a new script from nothing with given script text.
1836 /// </summary>
1837 /// <param name="remoteClient"></param>
1838 /// <param name="itemBase">Template item.</param>
1839 /// <param name="scriptText"></param>
1840 /// <returns>The part where the script was rezzed if successful. False otherwise.</returns>
1841 public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase, string scriptText)
1842 {
1789 // The part ID is the folder ID! 1843 // The part ID is the folder ID!
1790 SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); 1844 SceneObjectPart part = GetSceneObjectPart(itemBase.Folder);
1791 if (part == null) 1845 if (part == null)
@@ -1805,9 +1859,14 @@ namespace OpenSim.Region.Framework.Scenes
1805 return null; 1859 return null;
1806 } 1860 }
1807 1861
1808 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1862 AssetBase asset
1809 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), 1863 = CreateAsset(
1810 agentID); 1864 itemBase.Name,
1865 itemBase.Description,
1866 (sbyte)itemBase.AssetType,
1867 Encoding.ASCII.GetBytes(scriptText),
1868 agentID);
1869
1811 AssetService.Store(asset); 1870 AssetService.Store(asset);
1812 1871
1813 TaskInventoryItem taskItem = new TaskInventoryItem(); 1872 TaskInventoryItem taskItem = new TaskInventoryItem();
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2e64819..28fce53 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -51,6 +51,7 @@ using OpenSim.Region.Physics.Manager;
51using Timer=System.Timers.Timer; 51using Timer=System.Timers.Timer;
52using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 52using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
53using GridRegion = OpenSim.Services.Interfaces.GridRegion; 53using GridRegion = OpenSim.Services.Interfaces.GridRegion;
54using PermissionMask = OpenSim.Framework.PermissionMask;
54 55
55namespace OpenSim.Region.Framework.Scenes 56namespace OpenSim.Region.Framework.Scenes
56{ 57{
@@ -68,14 +69,84 @@ namespace OpenSim.Region.Framework.Scenes
68 public bool EmergencyMonitoring = false; 69 public bool EmergencyMonitoring = false;
69 70
70 /// <summary> 71 /// <summary>
72 /// Show debug information about animations.
73 /// </summary>
74 public bool DebugAnimations { get; set; }
75
76 /// <summary>
71 /// Show debug information about teleports. 77 /// Show debug information about teleports.
72 /// </summary> 78 /// </summary>
73 public bool DebugTeleporting { get; private set; } 79 public bool DebugTeleporting { get; set; }
74 80
75 /// <summary> 81 /// <summary>
76 /// Show debug information about the scene loop. 82 /// Show debug information about the scene loop.
77 /// </summary> 83 /// </summary>
78 public bool DebugUpdates { get; private set; } 84 public bool DebugUpdates { get; set; }
85
86 /// <summary>
87 /// If true then the scene is saved to persistent storage periodically, every m_update_backup frames and
88 /// if objects meet required conditions (m_dontPersistBefore and m_dontPersistAfter).
89 /// </summary>
90 /// <remarks>
91 /// Even if false, the scene will still be saved on clean shutdown.
92 /// FIXME: Currently, setting this to false will mean that objects are not periodically returned from parcels.
93 /// This needs to be fixed.
94 /// </remarks>
95 public bool PeriodicBackup { get; set; }
96
97 /// <summary>
98 /// If false then the scene is never saved to persistence storage even if PeriodicBackup == true and even
99 /// if the scene is being shut down for the final time.
100 /// </summary>
101 public bool UseBackup { get; set; }
102
103 /// <summary>
104 /// If false then physical objects are disabled, though collisions will continue as normal.
105 /// </summary>
106 public bool PhysicsEnabled { get; set; }
107
108 /// <summary>
109 /// If false then scripts are not enabled on the smiulator
110 /// </summary>
111 public bool ScriptsEnabled
112 {
113 get { return m_scripts_enabled; }
114 set
115 {
116 if (m_scripts_enabled != value)
117 {
118 if (!value)
119 {
120 m_log.Info("Stopping all Scripts in Scene");
121
122 EntityBase[] entities = Entities.GetEntities();
123 foreach (EntityBase ent in entities)
124 {
125 if (ent is SceneObjectGroup)
126 ((SceneObjectGroup)ent).RemoveScriptInstances(false);
127 }
128 }
129 else
130 {
131 m_log.Info("Starting all Scripts in Scene");
132
133 EntityBase[] entities = Entities.GetEntities();
134 foreach (EntityBase ent in entities)
135 {
136 if (ent is SceneObjectGroup)
137 {
138 SceneObjectGroup sog = (SceneObjectGroup)ent;
139 sog.CreateScriptInstances(0, false, DefaultScriptEngine, 0);
140 sog.ResumeScripts();
141 }
142 }
143 }
144
145 m_scripts_enabled = value;
146 }
147 }
148 }
149 private bool m_scripts_enabled;
79 150
80 public SynchronizeSceneHandler SynchronizeScene; 151 public SynchronizeSceneHandler SynchronizeScene;
81 152
@@ -284,8 +355,6 @@ namespace OpenSim.Region.Framework.Scenes
284 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 355 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
285 private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); 356 private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>();
286 357
287 private bool m_physics_enabled = true;
288 private bool m_scripts_enabled = true;
289 private string m_defaultScriptEngine; 358 private string m_defaultScriptEngine;
290 359
291 /// <summary> 360 /// <summary>
@@ -348,7 +417,6 @@ namespace OpenSim.Region.Framework.Scenes
348 417
349 private Timer m_mapGenerationTimer = new Timer(); 418 private Timer m_mapGenerationTimer = new Timer();
350 private bool m_generateMaptiles; 419 private bool m_generateMaptiles;
351 private bool m_useBackup = true;
352 420
353 #endregion Fields 421 #endregion Fields
354 422
@@ -614,11 +682,6 @@ namespace OpenSim.Region.Framework.Scenes
614 get { return m_authenticateHandler; } 682 get { return m_authenticateHandler; }
615 } 683 }
616 684
617 public bool UseBackup
618 {
619 get { return m_useBackup; }
620 }
621
622 // an instance to the physics plugin's Scene object. 685 // an instance to the physics plugin's Scene object.
623 public PhysicsScene PhysicsScene 686 public PhysicsScene PhysicsScene
624 { 687 {
@@ -678,7 +741,6 @@ namespace OpenSim.Region.Framework.Scenes
678 public Scene(RegionInfo regInfo, AgentCircuitManager authen, 741 public Scene(RegionInfo regInfo, AgentCircuitManager authen,
679 SceneCommunicationService sceneGridService, 742 SceneCommunicationService sceneGridService,
680 ISimulationDataService simDataService, IEstateDataService estateDataService, 743 ISimulationDataService simDataService, IEstateDataService estateDataService,
681 bool dumpAssetsToFile,
682 IConfigSource config, string simulatorVersion) 744 IConfigSource config, string simulatorVersion)
683 : this(regInfo) 745 : this(regInfo)
684 { 746 {
@@ -762,15 +824,20 @@ namespace OpenSim.Region.Framework.Scenes
762 // 824 //
763 // Out of memory 825 // Out of memory
764 // Operating system has killed the plugin 826 // Operating system has killed the plugin
765 m_sceneGraph.UnRecoverableError += RestartNow; 827 m_sceneGraph.UnRecoverableError
828 += () =>
829 {
830 m_log.ErrorFormat("[SCENE]: Restarting region {0} due to unrecoverable physics crash", Name);
831 RestartNow();
832 };
766 833
767 RegisterDefaultSceneEvents(); 834 RegisterDefaultSceneEvents();
768 835
769 DumpAssetsToFile = dumpAssetsToFile; 836 // XXX: Don't set the public property since we don't want to activate here. This needs to be handled
770 837 // better in the future.
771 m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; 838 m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;
772 839
773 m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; 840 PhysicsEnabled = !RegionInfo.RegionSettings.DisablePhysics;
774 841
775 m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; 842 m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")";
776 843
@@ -778,141 +845,154 @@ namespace OpenSim.Region.Framework.Scenes
778 845
779 // Region config overrides global config 846 // Region config overrides global config
780 // 847 //
781 try 848 if (m_config.Configs["Startup"] != null)
782 { 849 {
783 if (m_config.Configs["Startup"] != null) 850 IConfig startupConfig = m_config.Configs["Startup"];
851
852 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
853
854 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
855 UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup);
856 if (!UseBackup)
857 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
858
859 //Animation states
860 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
861
862 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
863 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
864
865 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
866 if (RegionInfo.NonphysPrimMin > 0)
784 { 867 {
785 IConfig startupConfig = m_config.Configs["Startup"]; 868 m_minNonphys = RegionInfo.NonphysPrimMin;
869 }
786 870
787 StartDisabled = startupConfig.GetBoolean("StartDisabled", false); 871 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
872 if (RegionInfo.NonphysPrimMax > 0)
873 {
874 m_maxNonphys = RegionInfo.NonphysPrimMax;
875 }
788 876
789 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); 877 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
790 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); 878 if (RegionInfo.PhysPrimMin > 0)
791 if (!m_useBackup) 879 {
792 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); 880 m_minPhys = RegionInfo.PhysPrimMin;
793 881 }
794 //Animation states
795 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
796 882
797 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); 883 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
798 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
799 884
800 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); 885 if (RegionInfo.PhysPrimMax > 0)
801 if (RegionInfo.NonphysPrimMin > 0) 886 {
802 { 887 m_maxPhys = RegionInfo.PhysPrimMax;
803 m_minNonphys = RegionInfo.NonphysPrimMin; 888 }
804 }
805 889
806 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 890 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity);
807 if (RegionInfo.NonphysPrimMax > 0) 891 if (RegionInfo.LinksetCapacity > 0)
808 { 892 {
809 m_maxNonphys = RegionInfo.NonphysPrimMax; 893 m_linksetCapacity = RegionInfo.LinksetCapacity;
810 } 894 }
811 895
812 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); 896 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
813 if (RegionInfo.PhysPrimMin > 0) 897 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
814 {
815 m_minPhys = RegionInfo.PhysPrimMin;
816 }
817 898
818 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 899 // Here, if clamping is requested in either global or
900 // local config, it will be used
901 //
902 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
903 if (RegionInfo.ClampPrimSize)
904 {
905 m_clampPrimSize = true;
906 }
819 907
820 if (RegionInfo.PhysPrimMax > 0) 908 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
821 { 909 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
822 m_maxPhys = RegionInfo.PhysPrimMax; 910 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
823 } 911 m_dontPersistBefore =
912 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
913 m_dontPersistBefore *= 10000000;
914 m_persistAfter =
915 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
916 m_persistAfter *= 10000000;
824 917
825 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); 918 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
826 if (RegionInfo.LinksetCapacity > 0) 919 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
827 {
828 m_linksetCapacity = RegionInfo.LinksetCapacity;
829 }
830 920
831 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); 921 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
832 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); 922 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
923 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
833 924
834 // Here, if clamping is requested in either global or 925 string[] possibleMapConfigSections = new string[] { "Map", "Startup" };
835 // local config, it will be used 926
836 // 927 m_generateMaptiles
837 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); 928 = Util.GetConfigVarFromSections<bool>(config, "GenerateMaptiles", possibleMapConfigSections, true);
838 if (RegionInfo.ClampPrimSize) 929
930 if (m_generateMaptiles)
931 {
932 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
933 if (maptileRefresh != 0)
839 { 934 {
840 m_clampPrimSize = true; 935 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
936 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
937 m_mapGenerationTimer.AutoReset = true;
938 m_mapGenerationTimer.Start();
841 } 939 }
940 }
941 else
942 {
943 string tile
944 = Util.GetConfigVarFromSections<string>(
945 config, "MaptileStaticUUID", possibleMapConfigSections, UUID.Zero.ToString());
946
947 UUID tileID;
842 948
843 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); 949 if (tile != UUID.Zero.ToString() && UUID.TryParse(tile, out tileID))
844 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
845 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
846 m_dontPersistBefore =
847 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
848 m_dontPersistBefore *= 10000000;
849 m_persistAfter =
850 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
851 m_persistAfter *= 10000000;
852
853 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
854 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
855
856 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
857 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
858 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
859
860 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
861 if (m_generateMaptiles)
862 { 950 {
863 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); 951 RegionInfo.RegionSettings.TerrainImageID = tileID;
864 if (maptileRefresh != 0)
865 {
866 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
867 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
868 m_mapGenerationTimer.AutoReset = true;
869 m_mapGenerationTimer.Start();
870 }
871 } 952 }
872 else 953 else
873 { 954 {
874 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); 955 RegionInfo.RegionSettings.TerrainImageID = RegionInfo.MaptileStaticUUID;
875 UUID tileID; 956 m_log.InfoFormat("[SCENE]: Region {0}, maptile set to {1}", RegionInfo.RegionName, RegionInfo.MaptileStaticUUID.ToString());
876
877 if (UUID.TryParse(tile, out tileID))
878 {
879 RegionInfo.RegionSettings.TerrainImageID = tileID;
880 }
881 } 957 }
958 }
959
960 string[] possibleAccessControlConfigSections = new string[] { "AccessControl", "Startup" };
961
962 string grant
963 = Util.GetConfigVarFromSections<string>(
964 config, "AllowedClients", possibleAccessControlConfigSections, "");
882 965
883 string grant = startupConfig.GetString("AllowedClients", String.Empty); 966 if (grant.Length > 0)
884 if (grant.Length > 0) 967 {
968 foreach (string viewer in grant.Split(','))
885 { 969 {
886 foreach (string viewer in grant.Split(',')) 970 m_AllowedViewers.Add(viewer.Trim().ToLower());
887 {
888 m_AllowedViewers.Add(viewer.Trim().ToLower());
889 }
890 } 971 }
972 }
891 973
892 grant = startupConfig.GetString("BannedClients", String.Empty); 974 grant
893 if (grant.Length > 0) 975 = Util.GetConfigVarFromSections<string>(
976 config, "BannedClients", possibleAccessControlConfigSections, "");
977
978 if (grant.Length > 0)
979 {
980 foreach (string viewer in grant.Split(','))
894 { 981 {
895 foreach (string viewer in grant.Split(',')) 982 m_BannedViewers.Add(viewer.Trim().ToLower());
896 {
897 m_BannedViewers.Add(viewer.Trim().ToLower());
898 }
899 } 983 }
900
901 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
902 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
903 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
904 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
905 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
906 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
907 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
908 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
909 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
910 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
911 } 984 }
912 } 985
913 catch (Exception e) 986 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
914 { 987 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
915 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); 988 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
989 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
990 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
991 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
992 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
993 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
994 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
995 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
916 } 996 }
917 997
918 // FIXME: Ultimately this should be in a module. 998 // FIXME: Ultimately this should be in a module.
@@ -965,6 +1045,10 @@ namespace OpenSim.Region.Framework.Scenes
965 { 1045 {
966 PhysicalPrims = true; 1046 PhysicalPrims = true;
967 CollidablePrims = true; 1047 CollidablePrims = true;
1048 PhysicsEnabled = true;
1049
1050 PeriodicBackup = true;
1051 UseBackup = true;
968 1052
969 BordersLocked = true; 1053 BordersLocked = true;
970 Border northBorder = new Border(); 1054 Border northBorder = new Border();
@@ -1207,83 +1291,6 @@ namespace OpenSim.Region.Framework.Scenes
1207 } 1291 }
1208 } 1292 }
1209 1293
1210 public void SetSceneCoreDebug(Dictionary<string, string> options)
1211 {
1212 if (options.ContainsKey("active"))
1213 {
1214 bool active;
1215
1216 if (bool.TryParse(options["active"], out active))
1217 Active = active;
1218 }
1219
1220 if (options.ContainsKey("scripting"))
1221 {
1222 bool enableScripts = true;
1223 if (bool.TryParse(options["scripting"], out enableScripts) && m_scripts_enabled != enableScripts)
1224 {
1225 if (!enableScripts)
1226 {
1227 m_log.Info("Stopping all Scripts in Scene");
1228
1229 EntityBase[] entities = Entities.GetEntities();
1230 foreach (EntityBase ent in entities)
1231 {
1232 if (ent is SceneObjectGroup)
1233 ((SceneObjectGroup)ent).RemoveScriptInstances(false);
1234 }
1235 }
1236 else
1237 {
1238 m_log.Info("Starting all Scripts in Scene");
1239
1240 EntityBase[] entities = Entities.GetEntities();
1241 foreach (EntityBase ent in entities)
1242 {
1243 if (ent is SceneObjectGroup)
1244 {
1245 SceneObjectGroup sog = (SceneObjectGroup)ent;
1246 sog.CreateScriptInstances(0, false, DefaultScriptEngine, 0);
1247 sog.ResumeScripts();
1248 }
1249 }
1250 }
1251
1252 m_scripts_enabled = enableScripts;
1253 }
1254 }
1255
1256 if (options.ContainsKey("physics"))
1257 {
1258 bool enablePhysics;
1259 if (bool.TryParse(options["physics"], out enablePhysics))
1260 m_physics_enabled = enablePhysics;
1261 }
1262
1263// if (options.ContainsKey("collisions"))
1264// {
1265// // TODO: Implement. If false, should stop objects colliding, though possibly should still allow
1266// // the avatar themselves to collide with the ground.
1267// }
1268
1269 if (options.ContainsKey("teleport"))
1270 {
1271 bool enableTeleportDebugging;
1272 if (bool.TryParse(options["teleport"], out enableTeleportDebugging))
1273 DebugTeleporting = enableTeleportDebugging;
1274 }
1275
1276 if (options.ContainsKey("updates"))
1277 {
1278 bool enableUpdateDebugging;
1279 if (bool.TryParse(options["updates"], out enableUpdateDebugging))
1280 {
1281 DebugUpdates = enableUpdateDebugging;
1282 GcNotify.Enabled = DebugUpdates;
1283 }
1284 }
1285 }
1286
1287 public int GetInaccurateNeighborCount() 1294 public int GetInaccurateNeighborCount()
1288 { 1295 {
1289 return m_neighbours.Count; 1296 return m_neighbours.Count;
@@ -1332,16 +1339,7 @@ namespace OpenSim.Region.Framework.Scenes
1332 1339
1333 m_log.Debug("[SCENE]: Persisting changed objects"); 1340 m_log.Debug("[SCENE]: Persisting changed objects");
1334 1341
1335 EntityBase[] entities = GetEntities(); 1342 Backup(false);
1336 foreach (EntityBase entity in entities)
1337 {
1338 if (!entity.IsDeleted && entity is SceneObjectGroup && ((SceneObjectGroup)entity).HasGroupChanged)
1339 {
1340 ((SceneObjectGroup)entity).ProcessBackup(SimulationDataService, false);
1341 }
1342 }
1343
1344 m_log.Debug("[SCENE]: Graph close");
1345 m_sceneGraph.Close(); 1343 m_sceneGraph.Close();
1346 1344
1347 if (!GridService.DeregisterRegion(RegionInfo.RegionID)) 1345 if (!GridService.DeregisterRegion(RegionInfo.RegionID))
@@ -1568,7 +1566,7 @@ namespace OpenSim.Region.Framework.Scenes
1568 } 1566 }
1569 1567
1570 tmpMS = Util.EnvironmentTickCount(); 1568 tmpMS = Util.EnvironmentTickCount();
1571 if ((Frame % m_update_physics == 0) && m_physics_enabled) 1569 if (PhysicsEnabled && Frame % m_update_physics == 0)
1572 m_sceneGraph.UpdatePreparePhysics(); 1570 m_sceneGraph.UpdatePreparePhysics();
1573 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); 1571 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1574 1572
@@ -1583,7 +1581,7 @@ namespace OpenSim.Region.Framework.Scenes
1583 tmpMS = Util.EnvironmentTickCount(); 1581 tmpMS = Util.EnvironmentTickCount();
1584 if (Frame % m_update_physics == 0) 1582 if (Frame % m_update_physics == 0)
1585 { 1583 {
1586 if (m_physics_enabled) 1584 if (PhysicsEnabled)
1587 physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime); 1585 physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime);
1588 1586
1589 if (SynchronizeScene != null) 1587 if (SynchronizeScene != null)
@@ -1625,7 +1623,7 @@ namespace OpenSim.Region.Framework.Scenes
1625 eventMS = Util.EnvironmentTickCountSubtract(tmpMS); 1623 eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
1626 } 1624 }
1627 1625
1628 if (Frame % m_update_backup == 0) 1626 if (PeriodicBackup && Frame % m_update_backup == 0)
1629 { 1627 {
1630 tmpMS = Util.EnvironmentTickCount(); 1628 tmpMS = Util.EnvironmentTickCount();
1631 UpdateStorageBackup(); 1629 UpdateStorageBackup();
@@ -2646,7 +2644,6 @@ namespace OpenSim.Region.Framework.Scenes
2646 2644
2647 } 2645 }
2648 } 2646 }
2649
2650 2647
2651 return null; 2648 return null;
2652 } 2649 }
@@ -2864,7 +2861,10 @@ namespace OpenSim.Region.Framework.Scenes
2864// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2861// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2865 2862
2866 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2863 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2867 2864
2865 // We must currently not resume scripts at this stage since AttachmentsModule does not have the
2866 // information that this is due to a teleport/border cross rather than an ordinary attachment.
2867 // We currently do this in Scene.MakeRootAgent() instead.
2868 if (AttachmentsModule != null) 2868 if (AttachmentsModule != null)
2869 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true); 2869 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true);
2870 } 2870 }
@@ -2981,21 +2981,6 @@ namespace OpenSim.Region.Framework.Scenes
2981 m_eventManager.TriggerOnNewPresence(sp); 2981 m_eventManager.TriggerOnNewPresence(sp);
2982 2982
2983 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; 2983 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
2984
2985 // The first agent upon login is a root agent by design.
2986 // For this agent we will have to rez the attachments.
2987 // All other AddNewClient calls find aCircuit.child to be true.
2988 if (aCircuit.child == false)
2989 {
2990 // We have to set SP to be a root agent here so that SP.MakeRootAgent() will later not try to
2991 // start the scripts again (since this is done in RezAttachments()).
2992 // XXX: This is convoluted.
2993 sp.IsChildAgent = false;
2994 sp.IsLoggingIn = true;
2995
2996 if (AttachmentsModule != null)
2997 Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); });
2998 }
2999 } 2984 }
3000 else 2985 else
3001 { 2986 {
@@ -4332,33 +4317,33 @@ namespace OpenSim.Region.Framework.Scenes
4332// } 4317// }
4333// } 4318// }
4334 4319
4335 /// <summary> 4320// /// <summary>
4336 /// Triggered when an agent crosses into this sim. Also happens on initial login. 4321// /// Triggered when an agent crosses into this sim. Also happens on initial login.
4337 /// </summary> 4322// /// </summary>
4338 /// <param name="agentID"></param> 4323// /// <param name="agentID"></param>
4339 /// <param name="position"></param> 4324// /// <param name="position"></param>
4340 /// <param name="isFlying"></param> 4325// /// <param name="isFlying"></param>
4341 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 4326// public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
4342 { 4327// {
4343 ScenePresence presence = GetScenePresence(agentID); 4328// ScenePresence presence = GetScenePresence(agentID);
4344 if (presence != null) 4329// if (presence != null)
4345 { 4330// {
4346 try 4331// try
4347 { 4332// {
4348 presence.MakeRootAgent(position, isFlying); 4333// presence.MakeRootAgent(position, isFlying);
4349 } 4334// }
4350 catch (Exception e) 4335// catch (Exception e)
4351 { 4336// {
4352 m_log.ErrorFormat("[SCENE]: Unable to do agent crossing, exception {0}{1}", e.Message, e.StackTrace); 4337// m_log.ErrorFormat("[SCENE]: Unable to do agent crossing, exception {0}{1}", e.Message, e.StackTrace);
4353 } 4338// }
4354 } 4339// }
4355 else 4340// else
4356 { 4341// {
4357 m_log.ErrorFormat( 4342// m_log.ErrorFormat(
4358 "[SCENE]: Could not find presence for agent {0} crossing into scene {1}", 4343// "[SCENE]: Could not find presence for agent {0} crossing into scene {1}",
4359 agentID, RegionInfo.RegionName); 4344// agentID, RegionInfo.RegionName);
4360 } 4345// }
4361 } 4346// }
4362 4347
4363 /// <summary> 4348 /// <summary>
4364 /// We've got an update about an agent that sees into this region, 4349 /// We've got an update about an agent that sees into this region,
@@ -4728,19 +4713,6 @@ namespace OpenSim.Region.Framework.Scenes
4728 4713
4729 #region Script Engine 4714 #region Script Engine
4730 4715
4731 private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>();
4732 public bool DumpAssetsToFile;
4733
4734 /// <summary>
4735 ///
4736 /// </summary>
4737 /// <param name="scriptEngine"></param>
4738 public void AddScriptEngine(ScriptEngineInterface scriptEngine)
4739 {
4740 ScriptEngines.Add(scriptEngine);
4741 scriptEngine.InitializeEngine(this);
4742 }
4743
4744 private bool ScriptDanger(SceneObjectPart part,Vector3 pos) 4716 private bool ScriptDanger(SceneObjectPart part,Vector3 pos)
4745 { 4717 {
4746 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); 4718 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
@@ -5647,33 +5619,7 @@ Environment.Exit(1);
5647 5619
5648 public void TriggerEstateSunUpdate() 5620 public void TriggerEstateSunUpdate()
5649 { 5621 {
5650 float sun; 5622 EventManager.TriggerEstateToolsSunUpdate(RegionInfo.RegionHandle);
5651 if (RegionInfo.RegionSettings.UseEstateSun)
5652 {
5653 sun = (float)RegionInfo.EstateSettings.SunPosition;
5654 if (RegionInfo.EstateSettings.UseGlobalTime)
5655 {
5656 sun = EventManager.GetCurrentTimeAsSunLindenHour() - 6.0f;
5657 }
5658
5659 //
5660 EventManager.TriggerEstateToolsSunUpdate(
5661 RegionInfo.RegionHandle,
5662 RegionInfo.EstateSettings.FixedSun,
5663 RegionInfo.RegionSettings.UseEstateSun,
5664 sun);
5665 }
5666 else
5667 {
5668 // Use the Sun Position from the Region Settings
5669 sun = (float)RegionInfo.RegionSettings.SunPosition - 6.0f;
5670
5671 EventManager.TriggerEstateToolsSunUpdate(
5672 RegionInfo.RegionHandle,
5673 RegionInfo.RegionSettings.FixedSun,
5674 RegionInfo.RegionSettings.UseEstateSun,
5675 sun);
5676 }
5677 } 5623 }
5678 5624
5679 private void HandleReloadEstate(string module, string[] cmd) 5625 private void HandleReloadEstate(string module, string[] cmd)
@@ -5941,8 +5887,13 @@ Environment.Exit(1);
5941 5887
5942 if (banned) 5888 if (banned)
5943 { 5889 {
5944 reason = "No suitable landing point found"; 5890 if(Permissions.IsAdministrator(agentID) == false || Permissions.IsGridGod(agentID) == false)
5945 return false; 5891 {
5892 reason = "No suitable landing point found";
5893 return false;
5894 }
5895 reason = "Administrative access only";
5896 return true;
5946 } 5897 }
5947 } 5898 }
5948 } 5899 }
@@ -6069,10 +6020,17 @@ Environment.Exit(1);
6069 GC.Collect(); 6020 GC.Collect();
6070 } 6021 }
6071 6022
6072 // Wrappers to get physics modules retrieve assets. Has to be done this way 6023 /// <summary>
6073 // because we can't assign the asset service to physics directly - at the 6024 /// Wrappers to get physics modules retrieve assets.
6074 // time physics are instantiated it's not registered but it will be by 6025 /// </summary>
6075 // the time the first prim exists. 6026 /// <remarks>
6027 /// Has to be done this way
6028 /// because we can't assign the asset service to physics directly - at the
6029 /// time physics are instantiated it's not registered but it will be by
6030 /// the time the first prim exists.
6031 /// </remarks>
6032 /// <param name="assetID"></param>
6033 /// <param name="callback"></param>
6076 public void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback) 6034 public void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback)
6077 { 6035 {
6078 AssetService.Get(assetID.ToString(), callback, PhysicsAssetReceived); 6036 AssetService.Get(assetID.ToString(), callback, PhysicsAssetReceived);
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index 0e0b6c3..c70342f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -100,7 +100,6 @@ namespace OpenSim.Region.Framework.Scenes
100 } 100 }
101 101
102 private readonly DoubleDictionary<UUID, string, Scene> m_localScenes = new DoubleDictionary<UUID, string, Scene>(); 102 private readonly DoubleDictionary<UUID, string, Scene> m_localScenes = new DoubleDictionary<UUID, string, Scene>();
103 private Scene m_currentScene = null;
104 103
105 public List<Scene> Scenes 104 public List<Scene> Scenes
106 { 105 {
@@ -313,35 +312,30 @@ namespace OpenSim.Region.Framework.Scenes
313 312
314 public void SendCommandToPluginModules(string[] cmdparams) 313 public void SendCommandToPluginModules(string[] cmdparams)
315 { 314 {
316 ForEachCurrentScene(delegate(Scene scene) { scene.SendCommandToPlugins(cmdparams); }); 315 ForEachSelectedScene(delegate(Scene scene) { scene.SendCommandToPlugins(cmdparams); });
317 } 316 }
318 317
319 public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions) 318 public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions)
320 { 319 {
321 ForEachCurrentScene(delegate(Scene scene) { scene.Permissions.SetBypassPermissions(bypassPermissions); }); 320 ForEachSelectedScene(delegate(Scene scene) { scene.Permissions.SetBypassPermissions(bypassPermissions); });
322 } 321 }
323 322
324 private void ForEachCurrentScene(Action<Scene> func) 323 public void ForEachSelectedScene(Action<Scene> func)
325 { 324 {
326 if (CurrentScene == null) 325 if (CurrentScene == null)
327 { 326 ForEachScene(func);
328 List<Scene> sceneList = Scenes;
329 sceneList.ForEach(func);
330 }
331 else 327 else
332 {
333 func(CurrentScene); 328 func(CurrentScene);
334 }
335 } 329 }
336 330
337 public void RestartCurrentScene() 331 public void RestartCurrentScene()
338 { 332 {
339 ForEachCurrentScene(delegate(Scene scene) { scene.RestartNow(); }); 333 ForEachSelectedScene(delegate(Scene scene) { scene.RestartNow(); });
340 } 334 }
341 335
342 public void BackupCurrentScene() 336 public void BackupCurrentScene()
343 { 337 {
344 ForEachCurrentScene(delegate(Scene scene) { scene.Backup(true); }); 338 ForEachSelectedScene(delegate(Scene scene) { scene.Backup(true); });
345 } 339 }
346 340
347 public bool TrySetCurrentScene(string regionName) 341 public bool TrySetCurrentScene(string regionName)
@@ -359,7 +353,7 @@ namespace OpenSim.Region.Framework.Scenes
359 353
360 if (m_localScenes.TryGetValue(regionName, out s)) 354 if (m_localScenes.TryGetValue(regionName, out s))
361 { 355 {
362 m_currentScene = s; 356 CurrentScene = s;
363 return true; 357 return true;
364 } 358 }
365 359
@@ -375,7 +369,7 @@ namespace OpenSim.Region.Framework.Scenes
375 369
376 if (m_localScenes.TryGetValue(regionID, out s)) 370 if (m_localScenes.TryGetValue(regionID, out s))
377 { 371 {
378 m_currentScene = s; 372 CurrentScene = s;
379 return true; 373 return true;
380 } 374 }
381 375
@@ -434,7 +428,7 @@ namespace OpenSim.Region.Framework.Scenes
434 /// <param name="name">Name of avatar to debug</param> 428 /// <param name="name">Name of avatar to debug</param>
435 public void SetDebugPacketLevelOnCurrentScene(int newDebug, string name) 429 public void SetDebugPacketLevelOnCurrentScene(int newDebug, string name)
436 { 430 {
437 ForEachCurrentScene(scene => 431 ForEachSelectedScene(scene =>
438 scene.ForEachScenePresence(sp => 432 scene.ForEachScenePresence(sp =>
439 { 433 {
440 if (name == null || sp.Name == name) 434 if (name == null || sp.Name == name)
@@ -453,7 +447,7 @@ namespace OpenSim.Region.Framework.Scenes
453 { 447 {
454 List<ScenePresence> avatars = new List<ScenePresence>(); 448 List<ScenePresence> avatars = new List<ScenePresence>();
455 449
456 ForEachCurrentScene( 450 ForEachSelectedScene(
457 delegate(Scene scene) 451 delegate(Scene scene)
458 { 452 {
459 scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) 453 scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence)
@@ -470,7 +464,7 @@ namespace OpenSim.Region.Framework.Scenes
470 { 464 {
471 List<ScenePresence> presences = new List<ScenePresence>(); 465 List<ScenePresence> presences = new List<ScenePresence>();
472 466
473 ForEachCurrentScene(delegate(Scene scene) 467 ForEachSelectedScene(delegate(Scene scene)
474 { 468 {
475 scene.ForEachScenePresence(delegate(ScenePresence sp) 469 scene.ForEachScenePresence(delegate(ScenePresence sp)
476 { 470 {
@@ -494,12 +488,12 @@ namespace OpenSim.Region.Framework.Scenes
494 488
495 public void ForceCurrentSceneClientUpdate() 489 public void ForceCurrentSceneClientUpdate()
496 { 490 {
497 ForEachCurrentScene(delegate(Scene scene) { scene.ForceClientUpdate(); }); 491 ForEachSelectedScene(delegate(Scene scene) { scene.ForceClientUpdate(); });
498 } 492 }
499 493
500 public void HandleEditCommandOnCurrentScene(string[] cmdparams) 494 public void HandleEditCommandOnCurrentScene(string[] cmdparams)
501 { 495 {
502 ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); }); 496 ForEachSelectedScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
503 } 497 }
504 498
505 public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) 499 public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 26524fb..f8624e7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -34,6 +34,7 @@ using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
35using System.Collections.Generic; 35using System.Collections.Generic;
36using System.Xml; 36using System.Xml;
37using PermissionMask = OpenSim.Framework.PermissionMask;
37 38
38namespace OpenSim.Region.Framework.Scenes 39namespace OpenSim.Region.Framework.Scenes
39{ 40{
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index ed1bbd8..69fb6df 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Physics.Manager; 42using OpenSim.Region.Physics.Manager;
43using OpenSim.Region.Framework.Scenes.Serialization; 43using OpenSim.Region.Framework.Scenes.Serialization;
44using PermissionMask = OpenSim.Framework.PermissionMask;
44 45
45namespace OpenSim.Region.Framework.Scenes 46namespace OpenSim.Region.Framework.Scenes
46{ 47{
@@ -101,6 +102,15 @@ namespace OpenSim.Region.Framework.Scenes
101 /// </summary> 102 /// </summary>
102 public partial class SceneObjectGroup : EntityBase, ISceneObject 103 public partial class SceneObjectGroup : EntityBase, ISceneObject
103 { 104 {
105 // Axis selection bitmask used by SetAxisRotation()
106 // Just happen to be the same bits used by llSetStatus() and defined in ScriptBaseClass.
107 public enum axisSelect : int
108 {
109 STATUS_ROTATE_X = 0x002,
110 STATUS_ROTATE_Y = 0x004,
111 STATUS_ROTATE_Z = 0x008,
112 }
113
104 // private PrimCountTaintedDelegate handlerPrimCountTainted = null; 114 // private PrimCountTaintedDelegate handlerPrimCountTainted = null;
105 115
106 /// <summary> 116 /// <summary>
@@ -512,11 +522,19 @@ namespace OpenSim.Region.Framework.Scenes
512 522
513 if (Scene != null) 523 if (Scene != null)
514 { 524 {
515 // if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) 525 if (
516 // || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) 526 // (Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E)
517 // && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) 527 // || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W)
518 if ((Scene.TestBorderCross(val, Cardinals.E) || Scene.TestBorderCross(val, Cardinals.W) 528 // || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N)
519 || Scene.TestBorderCross(val, Cardinals.N) || Scene.TestBorderCross(val, Cardinals.S)) 529 // || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S))
530 // Experimental change for better border crossings.
531 // The commented out original lines above would, it seems, trigger
532 // a border crossing a little early or late depending on which
533 // direction the object was moving.
534 (Scene.TestBorderCross(val, Cardinals.E)
535 || Scene.TestBorderCross(val, Cardinals.W)
536 || Scene.TestBorderCross(val, Cardinals.N)
537 || Scene.TestBorderCross(val, Cardinals.S))
520 && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) 538 && !IsAttachmentCheckFull() && (!Scene.LoadingPrims))
521 { 539 {
522 IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); 540 IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
@@ -935,6 +953,18 @@ namespace OpenSim.Region.Framework.Scenes
935 /// </remarks> 953 /// </remarks>
936 public UUID FromFolderID { get; set; } 954 public UUID FromFolderID { get; set; }
937 955
956 /// <summary>
957 /// IDs of all avatars sat on this scene object.
958 /// </summary>
959 /// <remarks>
960 /// We need this so that we can maintain a linkset wide ordering of avatars sat on different parts.
961 /// This must be locked before it is read or written.
962 /// SceneObjectPart sitting avatar add/remove code also locks on this object to avoid race conditions.
963 /// No avatar should appear more than once in this list.
964 /// Do not manipulate this list directly - use the Add/Remove sitting avatar methods on SceneObjectPart.
965 /// </remarks>
966 protected internal List<UUID> m_sittingAvatars = new List<UUID>();
967
938 #endregion 968 #endregion
939 969
940// ~SceneObjectGroup() 970// ~SceneObjectGroup()
@@ -3438,7 +3468,7 @@ namespace OpenSim.Region.Framework.Scenes
3438 3468
3439 public void AdjustChildPrimPermissions() 3469 public void AdjustChildPrimPermissions()
3440 { 3470 {
3441 uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits 3471 uint newOwnerMask = (uint)(PermissionMask.All | PermissionMask.Export) & 0xfffffff8; // Mask folded bits
3442 uint foldedPerms = RootPart.OwnerMask & 3; 3472 uint foldedPerms = RootPart.OwnerMask & 3;
3443 3473
3444 ForEachPart(part => 3474 ForEachPart(part =>
@@ -4509,17 +4539,28 @@ namespace OpenSim.Region.Framework.Scenes
4509 } 4539 }
4510 4540
4511 /// <summary> 4541 /// <summary>
4542 /// Get a copy of the list of sitting avatars on all prims of this object.
4543 /// </summary>
4544 /// <remarks>
4545 /// This is sorted by the order in which avatars sat down. If an avatar stands up then all avatars that sat
4546 /// down after it move one place down the list.
4547 /// </remarks>
4548 /// <returns>A list of the sitting avatars. Returns an empty list if there are no sitting avatars.</returns>
4549 public List<UUID> GetSittingAvatars()
4550 {
4551 lock (m_sittingAvatars)
4552 return new List<UUID>(m_sittingAvatars);
4553 }
4554
4555 /// <summary>
4512 /// Gets the number of sitting avatars. 4556 /// Gets the number of sitting avatars.
4513 /// </summary> 4557 /// </summary>
4514 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks> 4558 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
4515 /// <returns></returns> 4559 /// <returns></returns>
4516 public int GetSittingAvatarsCount() 4560 public int GetSittingAvatarsCount()
4517 { 4561 {
4518 int count = 0; 4562 lock (m_sittingAvatars)
4519 4563 return m_sittingAvatars.Count;
4520 Array.ForEach<SceneObjectPart>(m_parts.GetArray(), p => count += p.GetSittingAvatarsCount());
4521
4522 return count;
4523 } 4564 }
4524 4565
4525 public override string ToString() 4566 public override string ToString()
@@ -4528,7 +4569,7 @@ namespace OpenSim.Region.Framework.Scenes
4528 } 4569 }
4529 4570
4530 #region ISceneObject 4571 #region ISceneObject
4531 4572
4532 public virtual ISceneObject CloneForNewScene() 4573 public virtual ISceneObject CloneForNewScene()
4533 { 4574 {
4534 SceneObjectGroup sog = Copy(false); 4575 SceneObjectGroup sog = Copy(false);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 20a6626..42644dc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -37,11 +37,13 @@ using System.Xml.Serialization;
37using log4net; 37using log4net;
38using OpenMetaverse; 38using OpenMetaverse;
39using OpenMetaverse.Packets; 39using OpenMetaverse.Packets;
40using OpenMetaverse.StructuredData;
40using OpenSim.Framework; 41using OpenSim.Framework;
41using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes.Scripting; 43using OpenSim.Region.Framework.Scenes.Scripting;
43using OpenSim.Region.Framework.Scenes.Serialization; 44using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Region.Physics.Manager; 45using OpenSim.Region.Physics.Manager;
46using PermissionMask = OpenSim.Framework.PermissionMask;
45 47
46namespace OpenSim.Region.Framework.Scenes 48namespace OpenSim.Region.Framework.Scenes
47{ 49{
@@ -116,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes
116 118
117 #endregion Enumerations 119 #endregion Enumerations
118 120
119 public class SceneObjectPart : IScriptHost, ISceneEntity 121 public class SceneObjectPart : ISceneEntity
120 { 122 {
121 /// <value> 123 /// <value>
122 /// Denote all sides of the prim 124 /// Denote all sides of the prim
@@ -136,6 +138,32 @@ namespace OpenSim.Region.Framework.Scenes
136 138
137 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 139 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
138 140
141 /// <summary>
142 /// Dynamic attributes can be created and deleted as required.
143 /// </summary>
144 public DAMap DynAttrs { get; set; }
145
146 private DOMap m_dynObjs;
147
148 /// <summary>
149 /// Dynamic objects that can be created and deleted as required.
150 /// </summary>
151 public DOMap DynObjs
152 {
153 get
154 {
155 if (m_dynObjs == null)
156 m_dynObjs = new DOMap();
157
158 return m_dynObjs;
159 }
160
161 set
162 {
163 m_dynObjs = value;
164 }
165 }
166
139 /// <value> 167 /// <value>
140 /// Is this a root part? 168 /// Is this a root part?
141 /// </value> 169 /// </value>
@@ -386,6 +414,7 @@ namespace OpenSim.Region.Framework.Scenes
386 m_particleSystem = Utils.EmptyBytes; 414 m_particleSystem = Utils.EmptyBytes;
387 Rezzed = DateTime.UtcNow; 415 Rezzed = DateTime.UtcNow;
388 Description = String.Empty; 416 Description = String.Empty;
417 DynAttrs = new DAMap();
389 418
390 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, 419 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
391 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from 420 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
@@ -441,8 +470,8 @@ namespace OpenSim.Region.Framework.Scenes
441 private uint _category; 470 private uint _category;
442 private Int32 _creationDate; 471 private Int32 _creationDate;
443 private uint _parentID = 0; 472 private uint _parentID = 0;
444 private uint _baseMask = (uint)PermissionMask.All; 473 private uint _baseMask = (uint)(PermissionMask.All | PermissionMask.Export);
445 private uint _ownerMask = (uint)PermissionMask.All; 474 private uint _ownerMask = (uint)(PermissionMask.All | PermissionMask.Export);
446 private uint _groupMask = (uint)PermissionMask.None; 475 private uint _groupMask = (uint)PermissionMask.None;
447 private uint _everyoneMask = (uint)PermissionMask.None; 476 private uint _everyoneMask = (uint)PermissionMask.None;
448 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); 477 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
@@ -1342,7 +1371,7 @@ namespace OpenSim.Region.Framework.Scenes
1342 public UUID SitTargetAvatar { get; set; } 1371 public UUID SitTargetAvatar { get; set; }
1343 1372
1344 /// <summary> 1373 /// <summary>
1345 /// IDs of all avatars start on this object part. 1374 /// IDs of all avatars sat on this part.
1346 /// </summary> 1375 /// </summary>
1347 /// <remarks> 1376 /// <remarks>
1348 /// We need to track this so that we can stop sat upon prims from being attached. 1377 /// We need to track this so that we can stop sat upon prims from being attached.
@@ -2133,6 +2162,8 @@ namespace OpenSim.Region.Framework.Scenes
2133 // safeguard actual copy is done in sog.copy 2162 // safeguard actual copy is done in sog.copy
2134 dupe.KeyframeMotion = null; 2163 dupe.KeyframeMotion = null;
2135 2164
2165 dupe.DynAttrs.CopyFrom(DynAttrs);
2166
2136 if (userExposed) 2167 if (userExposed)
2137 { 2168 {
2138/* 2169/*
@@ -2446,11 +2477,11 @@ namespace OpenSim.Region.Framework.Scenes
2446 public int GetAxisRotation(int axis) 2477 public int GetAxisRotation(int axis)
2447 { 2478 {
2448 //Cannot use ScriptBaseClass constants as no referance to it currently. 2479 //Cannot use ScriptBaseClass constants as no referance to it currently.
2449 if (axis == 2)//STATUS_ROTATE_X 2480 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_X)
2450 return STATUS_ROTATE_X; 2481 return STATUS_ROTATE_X;
2451 if (axis == 4)//STATUS_ROTATE_Y 2482 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y)
2452 return STATUS_ROTATE_Y; 2483 return STATUS_ROTATE_Y;
2453 if (axis == 8)//STATUS_ROTATE_Z 2484 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z)
2454 return STATUS_ROTATE_Z; 2485 return STATUS_ROTATE_Z;
2455 2486
2456 return 0; 2487 return 0;
@@ -2485,18 +2516,6 @@ namespace OpenSim.Region.Framework.Scenes
2485 return new Vector3(0, 0, 0); 2516 return new Vector3(0, 0, 0);
2486 2517
2487 return ParentGroup.GetGeometricCenter(); 2518 return ParentGroup.GetGeometricCenter();
2488
2489 /*
2490 PhysicsActor pa = PhysActor;
2491
2492 if (pa != null)
2493 {
2494 Vector3 vtmp = pa.CenterOfMass;
2495 return vtmp;
2496 }
2497 else
2498 return new Vector3(0, 0, 0);
2499 */
2500 } 2519 }
2501 2520
2502 public float GetMass() 2521 public float GetMass()
@@ -2910,11 +2929,14 @@ namespace OpenSim.Region.Framework.Scenes
2910 2929
2911 public void PhysicsOutOfBounds(Vector3 pos) 2930 public void PhysicsOutOfBounds(Vector3 pos)
2912 { 2931 {
2913 m_log.Error("[PHYSICS]: Physical Object went out of bounds."); 2932 // Note: This is only being called on the root prim at this time.
2933
2934 m_log.ErrorFormat(
2935 "[SCENE OBJECT PART]: Physical object {0}, localID {1} went out of bounds at {2} in {3}. Stopping at {4} and making non-physical.",
2936 Name, LocalId, pos, ParentGroup.Scene.Name, AbsolutePosition);
2914 2937
2915 RemFlag(PrimFlags.Physics); 2938 RemFlag(PrimFlags.Physics);
2916 DoPhysicsPropertyUpdate(false, true); 2939 DoPhysicsPropertyUpdate(false, true);
2917 //ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
2918 } 2940 }
2919 2941
2920 public void PhysicsRequestingTerseUpdate() 2942 public void PhysicsRequestingTerseUpdate()
@@ -3337,13 +3359,13 @@ namespace OpenSim.Region.Framework.Scenes
3337 ParentGroup.SetAxisRotation(axis, rotate); 3359 ParentGroup.SetAxisRotation(axis, rotate);
3338 3360
3339 //Cannot use ScriptBaseClass constants as no referance to it currently. 3361 //Cannot use ScriptBaseClass constants as no referance to it currently.
3340 if (axis == 2)//STATUS_ROTATE_X 3362 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_X) != 0)
3341 STATUS_ROTATE_X = rotate; 3363 STATUS_ROTATE_X = rotate;
3342 3364
3343 if (axis == 4)//STATUS_ROTATE_Y 3365 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y) != 0)
3344 STATUS_ROTATE_Y = rotate; 3366 STATUS_ROTATE_Y = rotate;
3345 3367
3346 if (axis == 8)//STATUS_ROTATE_Z 3368 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) != 0)
3347 STATUS_ROTATE_Z = rotate; 3369 STATUS_ROTATE_Z = rotate;
3348 } 3370 }
3349 3371
@@ -3721,6 +3743,10 @@ namespace OpenSim.Region.Framework.Scenes
3721 /// <param name="events"></param> 3743 /// <param name="events"></param>
3722 public void SetScriptEvents(UUID scriptid, int events) 3744 public void SetScriptEvents(UUID scriptid, int events)
3723 { 3745 {
3746// m_log.DebugFormat(
3747// "[SCENE OBJECT PART]: Set script events for script with id {0} on {1}/{2} to {3} in {4}",
3748// scriptid, Name, ParentGroup.Name, events, ParentGroup.Scene.Name);
3749
3724 // scriptEvents oldparts; 3750 // scriptEvents oldparts;
3725 lock (m_scriptEvents) 3751 lock (m_scriptEvents)
3726 { 3752 {
@@ -4250,6 +4276,7 @@ namespace OpenSim.Region.Framework.Scenes
4250 result.distance = distance2; 4276 result.distance = distance2;
4251 result.HitTF = true; 4277 result.HitTF = true;
4252 result.ipoint = q; 4278 result.ipoint = q;
4279 result.face = i;
4253 //m_log.Info("[FACE]:" + i.ToString()); 4280 //m_log.Info("[FACE]:" + i.ToString());
4254 //m_log.Info("[POINT]: " + q.ToString()); 4281 //m_log.Info("[POINT]: " + q.ToString());
4255 //m_log.Info("[DIST]: " + distance2.ToString()); 4282 //m_log.Info("[DIST]: " + distance2.ToString());
@@ -4296,10 +4323,10 @@ namespace OpenSim.Region.Framework.Scenes
4296 4323
4297 public void TrimPermissions() 4324 public void TrimPermissions()
4298 { 4325 {
4299 BaseMask &= (uint)PermissionMask.All; 4326 BaseMask &= (uint)(PermissionMask.All | PermissionMask.Export);
4300 OwnerMask &= (uint)PermissionMask.All; 4327 OwnerMask &= (uint)(PermissionMask.All | PermissionMask.Export);
4301 GroupMask &= (uint)PermissionMask.All; 4328 GroupMask &= (uint)PermissionMask.All;
4302 EveryoneMask &= (uint)PermissionMask.All; 4329 EveryoneMask &= (uint)(PermissionMask.All | PermissionMask.Export);
4303 NextOwnerMask &= (uint)PermissionMask.All; 4330 NextOwnerMask &= (uint)PermissionMask.All;
4304 } 4331 }
4305 4332
@@ -4402,10 +4429,22 @@ namespace OpenSim.Region.Framework.Scenes
4402 baseMask; 4429 baseMask;
4403 break; 4430 break;
4404 case 8: 4431 case 8:
4432 // Trying to set export permissions - extra checks
4433 if (set && (mask & (uint)PermissionMask.Export) != 0)
4434 {
4435 if ((OwnerMask & (uint)PermissionMask.Export) == 0 || (BaseMask & (uint)PermissionMask.Export) == 0 || (NextOwnerMask & (uint)PermissionMask.All) != (uint)PermissionMask.All)
4436 mask &= ~(uint)PermissionMask.Export;
4437 }
4405 EveryoneMask = ApplyMask(EveryoneMask, set, mask) & 4438 EveryoneMask = ApplyMask(EveryoneMask, set, mask) &
4406 baseMask; 4439 baseMask;
4407 break; 4440 break;
4408 case 16: 4441 case 16:
4442 // Force full perm if export
4443 if ((EveryoneMask & (uint)PermissionMask.Export) != 0)
4444 {
4445 NextOwnerMask = (uint)PermissionMask.All;
4446 break;
4447 }
4409 NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & 4448 NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) &
4410 baseMask; 4449 baseMask;
4411 // Prevent the client from creating no copy, no transfer 4450 // Prevent the client from creating no copy, no transfer
@@ -4573,7 +4612,8 @@ namespace OpenSim.Region.Framework.Scenes
4573 if (ParentGroup.RootPart == this) 4612 if (ParentGroup.RootPart == this)
4574 AngularVelocity = new Vector3(0, 0, 0); 4613 AngularVelocity = new Vector3(0, 0, 0);
4575 } 4614 }
4576 else 4615
4616 else
4577 { 4617 {
4578 if (ParentGroup.Scene.CollidablePrims) 4618 if (ParentGroup.Scene.CollidablePrims)
4579 { 4619 {
@@ -4619,9 +4659,31 @@ namespace OpenSim.Region.Framework.Scenes
4619 UpdatePhysicsSubscribedEvents(); 4659 UpdatePhysicsSubscribedEvents();
4620 } 4660 }
4621 } 4661 }
4622 4662 if (SetVD)
4663 {
4664 // If the above logic worked (this is urgent candidate to unit tests!)
4665 // we now have a physicsactor.
4666 // Defensive programming calls for a check here.
4667 // Better would be throwing an exception that could be catched by a unit test as the internal
4668 // logic should make sure, this Physactor is always here.
4669 if (pa != null)
4670 {
4671 pa.SetVolumeDetect(1);
4672 AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
4673 VolumeDetectActive = true;
4674 }
4623 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 4675 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
4676 }
4677 else if (SetVD != wasVD)
4678 {
4679 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
4680 // (mumbles, well, at least if you have infinte CPU powers :-))
4681 if (pa != null)
4682 pa.SetVolumeDetect(0);
4624 4683
4684 RemFlag(PrimFlags.Phantom);
4685 VolumeDetectActive = false;
4686 }
4625 // and last in case we have a new actor and not building 4687 // and last in case we have a new actor and not building
4626 4688
4627 if (ParentGroup != null) 4689 if (ParentGroup != null)
@@ -4661,9 +4723,9 @@ namespace OpenSim.Region.Framework.Scenes
4661 PhysicsShapeType, 4723 PhysicsShapeType,
4662 m_localId); 4724 m_localId);
4663 } 4725 }
4664 catch (Exception ex) 4726 catch (Exception e)
4665 { 4727 {
4666 m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message); 4728 m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e);
4667 pa = null; 4729 pa = null;
4668 } 4730 }
4669 4731
@@ -4737,7 +4799,9 @@ namespace OpenSim.Region.Framework.Scenes
4737 } 4799 }
4738 4800
4739 PhysActor = pa; 4801 PhysActor = pa;
4740 } 4802
4803 ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this);
4804 }
4741 4805
4742 /// <summary> 4806 /// <summary>
4743 /// This removes the part from the physics scene. 4807 /// This removes the part from the physics scene.
@@ -4756,6 +4820,8 @@ namespace OpenSim.Region.Framework.Scenes
4756 pa.OnOutOfBounds -= PhysicsOutOfBounds; 4820 pa.OnOutOfBounds -= PhysicsOutOfBounds;
4757 4821
4758 ParentGroup.Scene.PhysicsScene.RemovePrim(pa); 4822 ParentGroup.Scene.PhysicsScene.RemovePrim(pa);
4823
4824 ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this);
4759 } 4825 }
4760 PhysActor = null; 4826 PhysActor = null;
4761 } 4827 }
@@ -4931,8 +4997,25 @@ namespace OpenSim.Region.Framework.Scenes
4931 4997
4932 Changed changeFlags = 0; 4998 Changed changeFlags = 0;
4933 4999
5000 Primitive.TextureEntryFace fallbackNewFace = newTex.DefaultTexture;
5001 Primitive.TextureEntryFace fallbackOldFace = oldTex.DefaultTexture;
5002
5003 // On Incoming packets, sometimes newText.DefaultTexture is null. The assumption is that all
5004 // other prim-sides are set, but apparently that's not always the case. Lets assume packet/data corruption at this point.
5005 if (fallbackNewFace == null)
5006 {
5007 fallbackNewFace = new Primitive.TextureEntry(Util.BLANK_TEXTURE_UUID).CreateFace(0);
5008 newTex.DefaultTexture = fallbackNewFace;
5009 }
5010 if (fallbackOldFace == null)
5011 {
5012 fallbackOldFace = new Primitive.TextureEntry(Util.BLANK_TEXTURE_UUID).CreateFace(0);
5013 oldTex.DefaultTexture = fallbackOldFace;
5014 }
5015
4934 for (int i = 0 ; i < GetNumberOfSides(); i++) 5016 for (int i = 0 ; i < GetNumberOfSides(); i++)
4935 { 5017 {
5018
4936 Primitive.TextureEntryFace newFace = newTex.DefaultTexture; 5019 Primitive.TextureEntryFace newFace = newTex.DefaultTexture;
4937 Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture; 5020 Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture;
4938 5021
@@ -5158,9 +5241,12 @@ namespace OpenSim.Region.Framework.Scenes
5158 5241
5159 public void ApplyNextOwnerPermissions() 5242 public void ApplyNextOwnerPermissions()
5160 { 5243 {
5161 BaseMask &= NextOwnerMask; 5244 // Export needs to be preserved in the base and everyone
5245 // mask, but removed in the owner mask as a next owner
5246 // can never change the export status
5247 BaseMask &= NextOwnerMask | (uint)PermissionMask.Export;
5162 OwnerMask &= NextOwnerMask; 5248 OwnerMask &= NextOwnerMask;
5163 EveryoneMask &= NextOwnerMask; 5249 EveryoneMask &= NextOwnerMask | (uint)PermissionMask.Export;
5164 5250
5165 Inventory.ApplyNextOwnerPermissions(); 5251 Inventory.ApplyNextOwnerPermissions();
5166 } 5252 }
@@ -5222,18 +5308,22 @@ namespace OpenSim.Region.Framework.Scenes
5222 /// <param name='avatarId'></param> 5308 /// <param name='avatarId'></param>
5223 protected internal bool AddSittingAvatar(UUID avatarId) 5309 protected internal bool AddSittingAvatar(UUID avatarId)
5224 { 5310 {
5225 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero) 5311 lock (ParentGroup.m_sittingAvatars)
5226 SitTargetAvatar = avatarId; 5312 {
5313 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
5314 SitTargetAvatar = avatarId;
5227 5315
5228 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5316 if (m_sittingAvatars == null)
5317 m_sittingAvatars = new HashSet<UUID>();
5229 5318
5230 if (sittingAvatars == null) 5319 if (m_sittingAvatars.Add(avatarId))
5231 sittingAvatars = new HashSet<UUID>(); 5320 {
5321 ParentGroup.m_sittingAvatars.Add(avatarId);
5232 5322
5233 lock (sittingAvatars) 5323 return true;
5234 { 5324 }
5235 m_sittingAvatars = sittingAvatars; 5325
5236 return m_sittingAvatars.Add(avatarId); 5326 return false;
5237 } 5327 }
5238 } 5328 }
5239 5329
@@ -5247,27 +5337,26 @@ namespace OpenSim.Region.Framework.Scenes
5247 /// <param name='avatarId'></param> 5337 /// <param name='avatarId'></param>
5248 protected internal bool RemoveSittingAvatar(UUID avatarId) 5338 protected internal bool RemoveSittingAvatar(UUID avatarId)
5249 { 5339 {
5250 if (SitTargetAvatar == avatarId) 5340 lock (ParentGroup.m_sittingAvatars)
5251 SitTargetAvatar = UUID.Zero; 5341 {
5252 5342 if (SitTargetAvatar == avatarId)
5253 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5343 SitTargetAvatar = UUID.Zero;
5254 5344
5255 // This can occur under a race condition where another thread 5345 if (m_sittingAvatars == null)
5256 if (sittingAvatars == null) 5346 return false;
5257 return false;
5258 5347
5259 lock (sittingAvatars) 5348 if (m_sittingAvatars.Remove(avatarId))
5260 {
5261 if (sittingAvatars.Remove(avatarId))
5262 { 5349 {
5263 if (sittingAvatars.Count == 0) 5350 if (m_sittingAvatars.Count == 0)
5264 m_sittingAvatars = null; 5351 m_sittingAvatars = null;
5265 5352
5353 ParentGroup.m_sittingAvatars.Remove(avatarId);
5354
5266 return true; 5355 return true;
5267 } 5356 }
5268 }
5269 5357
5270 return false; 5358 return false;
5359 }
5271 } 5360 }
5272 5361
5273 /// <summary> 5362 /// <summary>
@@ -5277,16 +5366,12 @@ namespace OpenSim.Region.Framework.Scenes
5277 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns> 5366 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
5278 public HashSet<UUID> GetSittingAvatars() 5367 public HashSet<UUID> GetSittingAvatars()
5279 { 5368 {
5280 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5369 lock (ParentGroup.m_sittingAvatars)
5281
5282 if (sittingAvatars == null)
5283 { 5370 {
5284 return null; 5371 if (m_sittingAvatars == null)
5285 } 5372 return null;
5286 else 5373 else
5287 { 5374 return new HashSet<UUID>(m_sittingAvatars);
5288 lock (sittingAvatars)
5289 return new HashSet<UUID>(sittingAvatars);
5290 } 5375 }
5291 } 5376 }
5292 5377
@@ -5297,13 +5382,13 @@ namespace OpenSim.Region.Framework.Scenes
5297 /// <returns></returns> 5382 /// <returns></returns>
5298 public int GetSittingAvatarsCount() 5383 public int GetSittingAvatarsCount()
5299 { 5384 {
5300 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5385 lock (ParentGroup.m_sittingAvatars)
5301 5386 {
5302 if (sittingAvatars == null) 5387 if (m_sittingAvatars == null)
5303 return 0; 5388 return 0;
5304 5389 else
5305 lock (sittingAvatars) 5390 return m_sittingAvatars.Count;
5306 return sittingAvatars.Count; 5391 }
5307 } 5392 }
5308 } 5393 }
5309} 5394}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 3a9a146..d04d87b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -38,6 +38,7 @@ using OpenSim.Framework;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes.Scripting; 39using OpenSim.Region.Framework.Scenes.Scripting;
40using OpenSim.Region.Framework.Scenes.Serialization; 40using OpenSim.Region.Framework.Scenes.Serialization;
41using PermissionMask = OpenSim.Framework.PermissionMask;
41 42
42namespace OpenSim.Region.Framework.Scenes 43namespace OpenSim.Region.Framework.Scenes
43{ 44{
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 230cb23..0ab267a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -221,8 +221,6 @@ namespace OpenSim.Region.Framework.Scenes
221 221
222 private Quaternion m_headrotation = Quaternion.Identity; 222 private Quaternion m_headrotation = Quaternion.Identity;
223 223
224 private string m_nextSitAnimation = String.Empty;
225
226 //PauPaw:Proper PID Controler for autopilot************ 224 //PauPaw:Proper PID Controler for autopilot************
227 public bool MovingToTarget { get; private set; } 225 public bool MovingToTarget { get; private set; }
228 public Vector3 MoveToPositionTarget { get; private set; } 226 public Vector3 MoveToPositionTarget { get; private set; }
@@ -458,9 +456,9 @@ namespace OpenSim.Region.Framework.Scenes
458 { 456 {
459 m_pos = PhysicsActor.Position; 457 m_pos = PhysicsActor.Position;
460 458
461 //m_log.DebugFormat( 459// m_log.DebugFormat(
462 // "[SCENE PRESENCE]: Set position {0} for {1} in {2} via getting AbsolutePosition!", 460// "[SCENE PRESENCE]: Set position of {0} in {1} to {2} via getting AbsolutePosition!",
463 // m_pos, Name, Scene.RegionInfo.RegionName); 461// Name, Scene.Name, m_pos);
464 } 462 }
465 else 463 else
466 { 464 {
@@ -487,6 +485,9 @@ namespace OpenSim.Region.Framework.Scenes
487 } 485 }
488 set 486 set
489 { 487 {
488// m_log.DebugFormat("[SCENE PRESENCE]: Setting position of {0} in {1} to {2}", Name, Scene.Name, value);
489// Util.PrintCallStack();
490
490 if (PhysicsActor != null) 491 if (PhysicsActor != null)
491 { 492 {
492 try 493 try
@@ -592,24 +593,37 @@ namespace OpenSim.Region.Framework.Scenes
592*/ 593*/
593 private Quaternion m_bodyRot = Quaternion.Identity; 594 private Quaternion m_bodyRot = Quaternion.Identity;
594 595
596 /// <summary>
597 /// The rotation of the avatar.
598 /// </summary>
599 /// <remarks>
600 /// If the avatar is not sitting, this is with respect to the world
601 /// If the avatar is sitting, this is a with respect to the part that it's sitting upon (a local rotation).
602 /// If you always want the world rotation, use GetWorldRotation()
603 /// </remarks>
595 public Quaternion Rotation 604 public Quaternion Rotation
596 { 605 {
597 get { return m_bodyRot; } 606 get
607 {
608 return m_bodyRot;
609 }
610
598 set 611 set
599 { 612 {
600 m_bodyRot = value; 613 m_bodyRot = value;
601 // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); 614
602 if (PhysicsActor != null) 615 if (PhysicsActor != null)
603 { 616 {
604 try 617 try
605 { 618 {
606 PhysicsActor.Orientation = value; 619 PhysicsActor.Orientation = m_bodyRot;
607 } 620 }
608 catch (Exception e) 621 catch (Exception e)
609 { 622 {
610 m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); 623 m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message);
611 } 624 }
612 } 625 }
626// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot);
613 } 627 }
614 } 628 }
615 629
@@ -656,6 +670,26 @@ namespace OpenSim.Region.Framework.Scenes
656 set { m_health = value; } 670 set { m_health = value; }
657 } 671 }
658 672
673 /// <summary>
674 /// Gets the world rotation of this presence.
675 /// </summary>
676 /// <remarks>
677 /// Unlike Rotation, this returns the world rotation no matter whether the avatar is sitting on a prim or not.
678 /// </remarks>
679 /// <returns></returns>
680 public Quaternion GetWorldRotation()
681 {
682 if (IsSatOnObject)
683 {
684 SceneObjectPart sitPart = ParentPart;
685
686 if (sitPart != null)
687 return sitPart.GetWorldRotation() * Rotation;
688 }
689
690 return Rotation;
691 }
692
659 public void AdjustKnownSeeds() 693 public void AdjustKnownSeeds()
660 { 694 {
661 Dictionary<ulong, string> seeds; 695 Dictionary<ulong, string> seeds;
@@ -705,6 +739,12 @@ namespace OpenSim.Region.Framework.Scenes
705 739
706 private bool m_inTransit; 740 private bool m_inTransit;
707 741
742 /// <summary>
743 /// This signals whether the presence is in transit between neighbouring regions.
744 /// </summary>
745 /// <remarks>
746 /// It is not set when the presence is teleporting or logging in/out directly to a region.
747 /// </remarks>
708 public bool IsInTransit 748 public bool IsInTransit
709 { 749 {
710 get { return m_inTransit; } 750 get { return m_inTransit; }
@@ -751,8 +791,6 @@ namespace OpenSim.Region.Framework.Scenes
751 791
752 #endregion 792 #endregion
753 793
754
755
756 #region Constructor(s) 794 #region Constructor(s)
757 795
758 public ScenePresence( 796 public ScenePresence(
@@ -903,8 +941,6 @@ namespace OpenSim.Region.Framework.Scenes
903 "[SCENE]: Upgrading child to root agent for {0} in {1}", 941 "[SCENE]: Upgrading child to root agent for {0} in {1}",
904 Name, m_scene.RegionInfo.RegionName); 942 Name, m_scene.RegionInfo.RegionName);
905 943
906 bool wasChild = IsChildAgent;
907
908 if (ParentUUID != UUID.Zero) 944 if (ParentUUID != UUID.Zero)
909 { 945 {
910 m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); 946 m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID);
@@ -937,6 +973,9 @@ namespace OpenSim.Region.Framework.Scenes
937 IsLoggingIn = false; 973 IsLoggingIn = false;
938 } 974 }
939 975
976 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
977
978 IsChildAgent = false;
940 979
941 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 980 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
942 if (gm != null) 981 if (gm != null)
@@ -1030,6 +1069,13 @@ namespace OpenSim.Region.Framework.Scenes
1030 else 1069 else
1031 AddToPhysicalScene(isFlying); 1070 AddToPhysicalScene(isFlying);
1032 1071
1072 // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a
1073 // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it
1074 // since it requires a physics actor to be present. If it is left any later, then physics appears to reset
1075 // the value to a negative position which does not trigger the border cross.
1076 // This may not be the best location for this.
1077 CheckForBorderCrossing();
1078
1033 if (ForceFly) 1079 if (ForceFly)
1034 { 1080 {
1035 Flying = true; 1081 Flying = true;
@@ -1050,22 +1096,43 @@ namespace OpenSim.Region.Framework.Scenes
1050 // and it has already rezzed the attachments and started their scripts. 1096 // and it has already rezzed the attachments and started their scripts.
1051 // We do the following only for non-login agents, because their scripts 1097 // We do the following only for non-login agents, because their scripts
1052 // haven't started yet. 1098 // haven't started yet.
1053 lock (m_attachments) 1099 if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
1100 {
1101 // Viewers which have a current outfit folder will actually rez their own attachments. However,
1102 // viewers without (e.g. v1 viewers) will not, so we still need to make this call.
1103 if (Scene.AttachmentsModule != null)
1104 Util.FireAndForget(
1105 o =>
1106 {
1107// if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None)
1108// System.Threading.Thread.Sleep(7000);
1109
1110 Scene.AttachmentsModule.RezAttachments(this);
1111 });
1112 }
1113 else
1054 { 1114 {
1055 if (wasChild && HasAttachments()) 1115 // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT
1116 // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently
1117 // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are
1118 // not transporting the required data.
1119 lock (m_attachments)
1056 { 1120 {
1057 m_log.DebugFormat( 1121 if (HasAttachments())
1058 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); 1122 {
1059 1123 m_log.DebugFormat(
1060 // Resume scripts 1124 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
1061 Util.FireAndForget(delegate(object x) { 1125
1062 foreach (SceneObjectGroup sog in m_attachments) 1126 // Resume scripts
1063 { 1127 Util.FireAndForget(delegate(object x) {
1064 sog.ScheduleGroupForFullUpdate(); 1128 foreach (SceneObjectGroup sog in m_attachments)
1065 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 1129 {
1066 sog.ResumeScripts(); 1130 sog.ScheduleGroupForFullUpdate();
1067 } 1131 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
1068 }); 1132 sog.ResumeScripts();
1133 }
1134 });
1135 }
1069 } 1136 }
1070 } 1137 }
1071 1138
@@ -1494,6 +1561,15 @@ namespace OpenSim.Region.Framework.Scenes
1494 1561
1495 } 1562 }
1496 1563
1564 // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region
1565 // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work.
1566 // This may be due to viewer code or it may be something we're not doing properly simulator side.
1567 lock (m_attachments)
1568 {
1569 foreach (SceneObjectGroup sog in m_attachments)
1570 sog.ScheduleGroupForFullUpdate();
1571 }
1572
1497// m_log.DebugFormat( 1573// m_log.DebugFormat(
1498// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", 1574// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
1499// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); 1575// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
@@ -1862,32 +1938,28 @@ namespace OpenSim.Region.Framework.Scenes
1862 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || 1938 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
1863 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1939 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
1864 1940
1865
1866 //m_log.Debug("[CONTROL]: " +flags); 1941 //m_log.Debug("[CONTROL]: " +flags);
1867 // Applies a satisfying roll effect to the avatar when flying. 1942 // Applies a satisfying roll effect to the avatar when flying.
1868 if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)) 1943 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
1869 { 1944 {
1870 1945 ApplyFlyingRoll(
1871 ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); 1946 FLY_ROLL_RADIANS_PER_UPDATE,
1872 1947 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
1873 1948 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
1874 } 1949 }
1875 else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) && 1950 else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 &&
1876 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)) 1951 (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
1877 { 1952 {
1878 ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); 1953 ApplyFlyingRoll(
1879 1954 -FLY_ROLL_RADIANS_PER_UPDATE,
1880 1955 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
1956 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
1881 } 1957 }
1882 else 1958 else
1883 { 1959 {
1884 if (m_AngularVelocity.Z != 0) 1960 if (m_AngularVelocity.Z != 0)
1885 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); 1961 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE);
1886 1962 }
1887 }
1888
1889
1890
1891 1963
1892 if (Flying && IsColliding && controlland) 1964 if (Flying && IsColliding && controlland)
1893 { 1965 {
@@ -2102,7 +2174,11 @@ namespace OpenSim.Region.Framework.Scenes
2102 // Get terrain height for sub-region in a megaregion if necessary 2174 // Get terrain height for sub-region in a megaregion if necessary
2103 int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); 2175 int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X);
2104 int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); 2176 int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y);
2105 UUID target_regionID = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y).RegionID; 2177 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y);
2178 // If X and Y is NaN, target_region will be null
2179 if (target_region == null)
2180 return;
2181 UUID target_regionID = target_region.RegionID;
2106 Scene targetScene = m_scene; 2182 Scene targetScene = m_scene;
2107 2183
2108 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) 2184 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene))
@@ -2347,28 +2423,16 @@ namespace OpenSim.Region.Framework.Scenes
2347 2423
2348 if (ParentID != 0) 2424 if (ParentID != 0)
2349 { 2425 {
2426 if (ParentPart.UUID == targetID)
2427 return; // already sitting here, ignore
2428
2350 StandUp(); 2429 StandUp();
2351 } 2430 }
2352 2431
2353// if (!String.IsNullOrEmpty(sitAnimation))
2354// {
2355// m_nextSitAnimation = sitAnimation;
2356// }
2357// else
2358// {
2359 m_nextSitAnimation = "SIT";
2360// }
2361
2362 //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
2363 SceneObjectPart part = FindNextAvailableSitTarget(targetID); 2432 SceneObjectPart part = FindNextAvailableSitTarget(targetID);
2364 2433
2365 if (part != null) 2434 if (part != null)
2366 { 2435 {
2367 if (!String.IsNullOrEmpty(part.SitAnimation))
2368 {
2369 m_nextSitAnimation = part.SitAnimation;
2370 }
2371
2372 m_requestedSitTargetID = part.LocalId; 2436 m_requestedSitTargetID = part.LocalId;
2373 m_requestedSitTargetUUID = targetID; 2437 m_requestedSitTargetUUID = targetID;
2374 2438
@@ -2489,18 +2553,6 @@ namespace OpenSim.Region.Framework.Scenes
2489 2553
2490 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) 2554 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
2491 { 2555 {
2492 if (!String.IsNullOrEmpty(m_nextSitAnimation))
2493 {
2494 HandleAgentSit(remoteClient, agentID, m_nextSitAnimation);
2495 }
2496 else
2497 {
2498 HandleAgentSit(remoteClient, agentID, "SIT");
2499 }
2500 }
2501
2502 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation)
2503 {
2504 SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); 2556 SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
2505 2557
2506 if (part != null) 2558 if (part != null)
@@ -2570,10 +2622,15 @@ namespace OpenSim.Region.Framework.Scenes
2570 2622
2571 ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID); 2623 ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
2572 ParentID = m_requestedSitTargetID; 2624 ParentID = m_requestedSitTargetID;
2573 2625 m_AngularVelocity = Vector3.Zero;
2574 Velocity = Vector3.Zero; 2626 Velocity = Vector3.Zero;
2575 RemoveFromPhysicalScene(); 2627 RemoveFromPhysicalScene();
2576 2628
2629 String sitAnimation = "SIT";
2630 if (!String.IsNullOrEmpty(part.SitAnimation))
2631 {
2632 sitAnimation = part.SitAnimation;
2633 }
2577 Animator.TrySetMovementAnimation(sitAnimation); 2634 Animator.TrySetMovementAnimation(sitAnimation);
2578 SendAvatarDataToAllAgents(); 2635 SendAvatarDataToAllAgents();
2579 } 2636 }
@@ -2581,7 +2638,8 @@ namespace OpenSim.Region.Framework.Scenes
2581 2638
2582 public void HandleAgentSitOnGround() 2639 public void HandleAgentSitOnGround()
2583 { 2640 {
2584// m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. 2641// m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick..
2642 m_AngularVelocity = Vector3.Zero;
2585 Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); 2643 Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
2586 SitGround = true; 2644 SitGround = true;
2587 RemoveFromPhysicalScene(); 2645 RemoveFromPhysicalScene();
@@ -2603,7 +2661,7 @@ namespace OpenSim.Region.Framework.Scenes
2603 2661
2604 public void HandleStopAnim(IClientAPI remoteClient, UUID animID) 2662 public void HandleStopAnim(IClientAPI remoteClient, UUID animID)
2605 { 2663 {
2606 Animator.RemoveAnimation(animID); 2664 Animator.RemoveAnimation(animID, false);
2607 } 2665 }
2608 2666
2609 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) 2667 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack)
@@ -2619,7 +2677,8 @@ namespace OpenSim.Region.Framework.Scenes
2619 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> 2677 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param>
2620 public void AddNewMovement(Vector3 vec) 2678 public void AddNewMovement(Vector3 vec)
2621 { 2679 {
2622// m_log.DebugFormat("[SCENE PRESENCE]: Adding new movement {0} for {1}", vec, Name); 2680// m_log.DebugFormat(
2681// "[SCENE PRESENCE]: Adding new movement {0} with rotation {1} for {2}", vec, Rotation, Name);
2623 2682
2624 Vector3 direc = vec * Rotation; 2683 Vector3 direc = vec * Rotation;
2625 direc.Normalize(); 2684 direc.Normalize();
@@ -2639,6 +2698,8 @@ namespace OpenSim.Region.Framework.Scenes
2639 2698
2640 direc *= 0.03f * 128f * SpeedModifier; 2699 direc *= 0.03f * 128f * SpeedModifier;
2641 2700
2701// m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name);
2702
2642 if (PhysicsActor != null) 2703 if (PhysicsActor != null)
2643 { 2704 {
2644 if (Flying) 2705 if (Flying)
@@ -2672,6 +2733,8 @@ namespace OpenSim.Region.Framework.Scenes
2672 } 2733 }
2673 } 2734 }
2674 2735
2736// m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name);
2737
2675 // TODO: Add the force instead of only setting it to support multiple forces per frame? 2738 // TODO: Add the force instead of only setting it to support multiple forces per frame?
2676 m_forceToApply = direc; 2739 m_forceToApply = direc;
2677 Animator.UpdateMovementAnimations(); 2740 Animator.UpdateMovementAnimations();
@@ -3090,6 +3153,10 @@ namespace OpenSim.Region.Framework.Scenes
3090 3153
3091 if (!IsInTransit) 3154 if (!IsInTransit)
3092 { 3155 {
3156// m_log.DebugFormat(
3157// "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}",
3158// pos2, Name, Scene.Name);
3159
3093 // Checks if where it's headed exists a region 3160 // Checks if where it's headed exists a region
3094 bool needsTransit = false; 3161 bool needsTransit = false;
3095 if (m_scene.TestBorderCross(pos2, Cardinals.W)) 3162 if (m_scene.TestBorderCross(pos2, Cardinals.W))
@@ -4314,6 +4381,7 @@ namespace OpenSim.Region.Framework.Scenes
4314 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4381 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4315 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0) 4382 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
4316 { 4383 {
4384
4317 if (GodLevel < 200 && 4385 if (GodLevel < 200 &&
4318 ((!m_scene.Permissions.IsGod(m_uuid) && 4386 ((!m_scene.Permissions.IsGod(m_uuid) &&
4319 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || 4387 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
@@ -4322,7 +4390,14 @@ namespace OpenSim.Region.Framework.Scenes
4322 { 4390 {
4323 SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray(); 4391 SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray();
4324 if (spawnPoints.Length == 0) 4392 if (spawnPoints.Length == 0)
4393 {
4394 if(m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid))
4395 {
4396 pos.X = 128.0f;
4397 pos.Y = 128.0f;
4398 }
4325 return; 4399 return;
4400 }
4326 4401
4327 int index; 4402 int index;
4328 bool selected = false; 4403 bool selected = false;
@@ -4331,6 +4406,8 @@ namespace OpenSim.Region.Framework.Scenes
4331 { 4406 {
4332 case "random": 4407 case "random":
4333 4408
4409 if (spawnPoints.Length == 0)
4410 return;
4334 do 4411 do
4335 { 4412 {
4336 index = Util.RandomClass.Next(spawnPoints.Length - 1); 4413 index = Util.RandomClass.Next(spawnPoints.Length - 1);
@@ -4342,6 +4419,7 @@ namespace OpenSim.Region.Framework.Scenes
4342 // SpawnPoint sp = spawnPoints[index]; 4419 // SpawnPoint sp = spawnPoints[index];
4343 4420
4344 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y); 4421 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4422
4345 if (land == null || land.IsEitherBannedOrRestricted(UUID)) 4423 if (land == null || land.IsEitherBannedOrRestricted(UUID))
4346 selected = false; 4424 selected = false;
4347 else 4425 else
diff --git a/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineLoader.cs
deleted file mode 100644
index c58ccc5..0000000
--- a/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineLoader.cs
+++ /dev/null
@@ -1,119 +0,0 @@
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
28/* Original code: Tedd Hansen */
29using System;
30using System.IO;
31using System.Reflection;
32using log4net;
33
34namespace OpenSim.Region.Framework.Scenes.Scripting
35{
36 public class ScriptEngineLoader
37 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39
40 public ScriptEngineInterface LoadScriptEngine(string EngineName)
41 {
42 ScriptEngineInterface ret = null;
43 try
44 {
45 ret =
46 LoadAndInitAssembly(
47 Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"),
48 "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine");
49 }
50 catch (Exception e)
51 {
52 m_log.Error("[ScriptEngine]: " +
53 "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " +
54 e.StackTrace.ToString());
55 }
56 return ret;
57 }
58
59 /// <summary>
60 /// Does actual loading and initialization of script Assembly
61 /// </summary>
62 /// <param name="FreeAppDomain">AppDomain to load script into</param>
63 /// <param name="FileName">FileName of script assembly (.dll)</param>
64 /// <returns></returns>
65 private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace)
66 {
67 //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName);
68 // Load .Net Assembly (.dll)
69 // Initialize and return it
70
71 // TODO: Add error handling
72
73 Assembly a;
74 //try
75 //{
76
77
78 // Load to default appdomain (temporary)
79 a = Assembly.LoadFrom(FileName);
80 // Load to specified appdomain
81 // TODO: Insert security
82 //a = FreeAppDomain.Load(FileName);
83 //}
84 //catch (Exception e)
85 //{
86 // m_log.Error("[ScriptEngine]: Error loading assembly \String.Empty + FileName + "\": " + e.ToString());
87 //}
88
89
90 //m_log.Debug("Loading: " + FileName);
91 //foreach (Type _t in a.GetTypes())
92 //{
93 // m_log.Debug("Type: " + _t.ToString());
94 //}
95
96 Type t;
97 //try
98 //{
99 t = a.GetType(NameSpace, true);
100 //}
101 //catch (Exception e)
102 //{
103 // m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString());
104 //}
105
106 ScriptEngineInterface ret;
107 //try
108 //{
109 ret = (ScriptEngineInterface) Activator.CreateInstance(t);
110 //}
111 //catch (Exception e)
112 //{
113 // m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString());
114 //}
115
116 return ret;
117 }
118 }
119}
diff --git a/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs b/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs
new file mode 100644
index 0000000..f08ba59
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs
@@ -0,0 +1,107 @@
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 OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Region.Framework.Scenes.Scripting
34{
35 /// <summary>
36 /// Utility functions for use by scripts manipulating the scene.
37 /// </summary>
38 public static class ScriptUtils
39 {
40 /// <summary>
41 /// Get an asset id given an item name and an item type.
42 /// </summary>
43 /// <returns>UUID.Zero if the name and type did not match any item.</returns>
44 /// <param name='part'></param>
45 /// <param name='name'></param>
46 /// <param name='type'></param>
47 public static UUID GetAssetIdFromItemName(SceneObjectPart part, string name, int type)
48 {
49 TaskInventoryItem item = part.Inventory.GetInventoryItem(name);
50
51 if (item != null && item.Type == type)
52 return item.AssetID;
53 else
54 return UUID.Zero;
55 }
56
57 /// <summary>
58 /// accepts a valid UUID, -or- a name of an inventory item.
59 /// Returns a valid UUID or UUID.Zero if key invalid and item not found
60 /// in prim inventory.
61 /// </summary>
62 /// <param name="part">Scene object part to search for inventory item</param>
63 /// <param name="key"></param>
64 /// <returns></returns>
65 public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier)
66 {
67 UUID key;
68
69 // if we can parse the string as a key, use it.
70 // else try to locate the name in inventory of object. found returns key,
71 // not found returns UUID.Zero
72 if (!UUID.TryParse(identifier, out key))
73 {
74 TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
75
76 if (item != null)
77 key = item.AssetID;
78 else
79 key = UUID.Zero;
80 }
81
82 return key;
83 }
84
85 /// <summary>
86 /// Return the UUID of the asset matching the specified key or name
87 /// and asset type.
88 /// </summary>
89 /// <param name="part">Scene object part to search for inventory item</param>
90 /// <param name="identifier"></param>
91 /// <param name="type"></param>
92 /// <returns></returns>
93 public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier, AssetType type)
94 {
95 UUID key;
96
97 if (!UUID.TryParse(identifier, out key))
98 {
99 TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
100 if (item != null && item.Type == (int)type)
101 key = item.AssetID;
102 }
103
104 return key;
105 }
106 }
107} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
index a4f730d..5cb271d 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
@@ -42,9 +42,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
42 /// <summary> 42 /// <summary>
43 /// Serialize and deserialize coalesced scene objects. 43 /// Serialize and deserialize coalesced scene objects.
44 /// </summary> 44 /// </summary>
45 /// <remarks>
46 /// Deserialization not yet here.
47 /// </remarks>
48 public class CoalescedSceneObjectsSerializer 45 public class CoalescedSceneObjectsSerializer
49 { 46 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -128,6 +125,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
128// m_log.DebugFormat("[COALESCED SCENE OBJECTS SERIALIZER]: TryFromXml() deserializing {0}", xml); 125// m_log.DebugFormat("[COALESCED SCENE OBJECTS SERIALIZER]: TryFromXml() deserializing {0}", xml);
129 126
130 coa = null; 127 coa = null;
128 int i = 0;
131 129
132 using (StringReader sr = new StringReader(xml)) 130 using (StringReader sr = new StringReader(xml))
133 { 131 {
@@ -153,7 +151,23 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
153 if (reader.Name == "SceneObjectGroup") 151 if (reader.Name == "SceneObjectGroup")
154 { 152 {
155 string soXml = reader.ReadOuterXml(); 153 string soXml = reader.ReadOuterXml();
156 coa.Add(SceneObjectSerializer.FromOriginalXmlFormat(soXml)); 154
155 SceneObjectGroup so = SceneObjectSerializer.FromOriginalXmlFormat(soXml);
156
157 if (so != null)
158 {
159 coa.Add(so);
160 }
161 else
162 {
163 // XXX: Possibly we should fail outright here rather than continuing if a particular component of the
164 // coalesced object fails to load.
165 m_log.WarnFormat(
166 "[COALESCED SCENE OBJECTS SERIALIZER]: Deserialization of xml for component {0} failed. Continuing.",
167 i);
168 }
169
170 i++;
157 } 171 }
158 } 172 }
159 173
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 2984782..ce4fb40 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -365,6 +365,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
365 m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound); 365 m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound);
366 m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume); 366 m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume);
367 m_SOPXmlProcessors.Add("MediaUrl", ProcessMediaUrl); 367 m_SOPXmlProcessors.Add("MediaUrl", ProcessMediaUrl);
368 m_SOPXmlProcessors.Add("DynAttrs", ProcessDynAttrs);
368 m_SOPXmlProcessors.Add("TextureAnimation", ProcessTextureAnimation); 369 m_SOPXmlProcessors.Add("TextureAnimation", ProcessTextureAnimation);
369 m_SOPXmlProcessors.Add("ParticleSystem", ProcessParticleSystem); 370 m_SOPXmlProcessors.Add("ParticleSystem", ProcessParticleSystem);
370 m_SOPXmlProcessors.Add("PayPrice0", ProcessPayPrice0); 371 m_SOPXmlProcessors.Add("PayPrice0", ProcessPayPrice0);
@@ -797,6 +798,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
797 obj.MediaUrl = reader.ReadElementContentAsString("MediaUrl", String.Empty); 798 obj.MediaUrl = reader.ReadElementContentAsString("MediaUrl", String.Empty);
798 } 799 }
799 800
801 private static void ProcessDynAttrs(SceneObjectPart obj, XmlTextReader reader)
802 {
803 obj.DynAttrs.ReadXml(reader);
804 }
805
800 private static void ProcessTextureAnimation(SceneObjectPart obj, XmlTextReader reader) 806 private static void ProcessTextureAnimation(SceneObjectPart obj, XmlTextReader reader)
801 { 807 {
802 obj.TextureAnimation = Convert.FromBase64String(reader.ReadElementContentAsString("TextureAnimation", String.Empty)); 808 obj.TextureAnimation = Convert.FromBase64String(reader.ReadElementContentAsString("TextureAnimation", String.Empty));
@@ -1339,6 +1345,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1339 writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); 1345 writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString());
1340 if (sop.MediaUrl != null) 1346 if (sop.MediaUrl != null)
1341 writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); 1347 writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString());
1348
1349 if (sop.DynAttrs.Count > 0)
1350 {
1351 writer.WriteStartElement("DynAttrs");
1352 sop.DynAttrs.WriteXml(writer);
1353 writer.WriteEndElement();
1354 }
1355
1342 WriteBytes(writer, "TextureAnimation", sop.TextureAnimation); 1356 WriteBytes(writer, "TextureAnimation", sop.TextureAnimation);
1343 WriteBytes(writer, "ParticleSystem", sop.ParticleSystem); 1357 WriteBytes(writer, "ParticleSystem", sop.ParticleSystem);
1344 writer.WriteElementString("PayPrice0", sop.PayPrice[0].ToString()); 1358 writer.WriteElementString("PayPrice0", sop.PayPrice[0].ToString());
diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
index 4a21dc9..e209221 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
@@ -37,7 +37,7 @@ using OpenSim.Tests.Common;
37namespace OpenSim.Region.Framework.Scenes.Tests 37namespace OpenSim.Region.Framework.Scenes.Tests
38{ 38{
39 [TestFixture] 39 [TestFixture]
40 public class BorderTests 40 public class BorderTests : OpenSimTestCase
41 { 41 {
42 [Test] 42 [Test]
43 public void TestCross() 43 public void TestCross()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
index ea9fc93..766ce83 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
@@ -41,7 +41,7 @@ using OpenSim.Tests.Common;
41namespace OpenSim.Region.Framework.Scenes.Tests 41namespace OpenSim.Region.Framework.Scenes.Tests
42{ 42{
43 [TestFixture, LongRunning] 43 [TestFixture, LongRunning]
44 public class EntityManagerTests 44 public class EntityManagerTests : OpenSimTestCase
45 { 45 {
46 static public Random random; 46 static public Random random;
47 SceneObjectGroup found; 47 SceneObjectGroup found;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
index d23c965..575a081 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
@@ -40,7 +40,7 @@ using OpenSim.Tests.Common.Mock;
40namespace OpenSim.Region.Framework.Scenes.Tests 40namespace OpenSim.Region.Framework.Scenes.Tests
41{ 41{
42 [TestFixture] 42 [TestFixture]
43 public class SceneGraphTests 43 public class SceneGraphTests : OpenSimTestCase
44 { 44 {
45 [Test] 45 [Test]
46 public void TestDuplicateObject() 46 public void TestDuplicateObject()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs
index ab56f4e..2d831fa 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs
@@ -41,7 +41,7 @@ using OpenSim.Tests.Common.Mock;
41namespace OpenSim.Region.Framework.Scenes.Tests 41namespace OpenSim.Region.Framework.Scenes.Tests
42{ 42{
43 [TestFixture] 43 [TestFixture]
44 public class SceneManagerTests 44 public class SceneManagerTests : OpenSimTestCase
45 { 45 {
46 [Test] 46 [Test]
47 public void TestClose() 47 public void TestClose()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 5b334c6..a07d64c 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Threading; 31using System.Threading;
32using Nini.Config;
32using NUnit.Framework; 33using NUnit.Framework;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenSim.Framework; 35using OpenSim.Framework;
@@ -182,6 +183,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
182 /// <summary> 183 /// <summary>
183 /// Test deleting an object from a scene. 184 /// Test deleting an object from a scene.
184 /// </summary> 185 /// </summary>
186 /// <remarks>
187 /// This is the most basic form of delete. For all more sophisticated forms of derez (done asynchrnously
188 /// and where object can be taken to user inventory, etc.), see SceneObjectDeRezTests.
189 /// </remarks>
185 [Test] 190 [Test]
186 public void TestDeleteSceneObject() 191 public void TestDeleteSceneObject()
187 { 192 {
@@ -201,100 +206,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
201 } 206 }
202 207
203 /// <summary> 208 /// <summary>
204 /// Test deleting an object asynchronously
205 /// </summary>
206 [Test]
207 public void TestDeleteSceneObjectAsync()
208 {
209 TestHelpers.InMethod();
210 //log4net.Config.XmlConfigurator.Configure();
211
212 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
213
214 TestScene scene = new SceneHelpers().SetupScene();
215
216 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
217 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
218 sogd.Enabled = false;
219
220 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene);
221
222 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
223 scene.DeRezObjects(client, new System.Collections.Generic.List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero);
224
225 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
226
227 Assert.That(retrievedPart, Is.Not.Null);
228
229 Assert.That(so.IsDeleted, Is.False);
230
231 sogd.InventoryDeQueueAndDelete();
232
233 Assert.That(so.IsDeleted, Is.True);
234
235 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
236 Assert.That(retrievedPart2, Is.Null);
237 }
238
239 /// <summary>
240 /// Test deleting an object asynchronously to user inventory.
241 /// </summary>
242// [Test]
243 public void TestDeleteSceneObjectAsyncToUserInventory()
244 {
245 TestHelpers.InMethod();
246 TestHelpers.EnableLogging();
247
248 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
249 string myObjectName = "Fred";
250
251 TestScene scene = new SceneHelpers().SetupScene();
252
253 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
254 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
255 sogd.Enabled = false;
256
257 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId);
258
259// Assert.That(
260// scene.CommsManager.UserAdminService.AddUser(
261// "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId),
262// Is.EqualTo(agentId));
263
264 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId);
265 InventoryFolderBase folder1
266 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1");
267
268 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
269 scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID);
270
271 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
272
273 Assert.That(retrievedPart, Is.Not.Null);
274 Assert.That(so.IsDeleted, Is.False);
275
276 sogd.InventoryDeQueueAndDelete();
277
278 Assert.That(so.IsDeleted, Is.True);
279
280 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
281 Assert.That(retrievedPart2, Is.Null);
282
283// SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client);
284
285 InventoryItemBase retrievedItem
286 = UserInventoryHelpers.GetInventoryItem(
287 scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName);
288
289 // Check that we now have the taken part in our inventory
290 Assert.That(retrievedItem, Is.Not.Null);
291
292 // Check that the taken part has actually disappeared
293// SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
294// Assert.That(retrievedPart, Is.Null);
295 }
296
297 /// <summary>
298 /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not 209 /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not
299 /// in a scene and is useful if one wants to supply a UUID directly rather than use the one generated by 210 /// in a scene and is useful if one wants to supply a UUID directly rather than use the one generated by
300 /// OpenSim. 211 /// OpenSim.
@@ -329,4 +240,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests
329 Assert.That(sog.Parts.Length, Is.EqualTo(2)); 240 Assert.That(sog.Parts.Length, Is.EqualTo(2));
330 } 241 }
331 } 242 }
332} 243} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
index 0076f41..52ad538 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
@@ -33,22 +33,24 @@ using NUnit.Framework;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Region.CoreModules.Framework.InventoryAccess;
36using OpenSim.Region.CoreModules.World.Permissions; 37using OpenSim.Region.CoreModules.World.Permissions;
37using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces;
38using OpenSim.Tests.Common; 40using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 41using OpenSim.Tests.Common.Mock;
40 42
41namespace OpenSim.Region.Framework.Scenes.Tests 43namespace OpenSim.Region.Framework.Scenes.Tests
42{ 44{
43 /// <summary> 45 /// <summary>
44 /// Tests derez of scene objects by users. 46 /// Tests derez of scene objects.
45 /// </summary> 47 /// </summary>
46 /// <remarks> 48 /// <remarks>
47 /// This is at a level above the SceneObjectBasicTests, which act on the scene directly. 49 /// This is at a level above the SceneObjectBasicTests, which act on the scene directly.
48 /// TODO: These tests are very incomplete - they only test for a few conditions. 50 /// TODO: These tests are incomplete - need to test more kinds of derez (e.g. return object).
49 /// </remarks> 51 /// </remarks>
50 [TestFixture] 52 [TestFixture]
51 public class SceneObjectDeRezTests 53 public class SceneObjectDeRezTests : OpenSimTestCase
52 { 54 {
53 /// <summary> 55 /// <summary>
54 /// Test deleting an object from a scene. 56 /// Test deleting an object from a scene.
@@ -76,14 +78,20 @@ namespace OpenSim.Region.Framework.Scenes.Tests
76 = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); 78 = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
77 part.Name = "obj1"; 79 part.Name = "obj1";
78 scene.AddNewSceneObject(new SceneObjectGroup(part), false); 80 scene.AddNewSceneObject(new SceneObjectGroup(part), false);
81
79 List<uint> localIds = new List<uint>(); 82 List<uint> localIds = new List<uint>();
80 localIds.Add(part.LocalId); 83 localIds.Add(part.LocalId);
81
82 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero); 84 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
85
86 // Check that object isn't deleted until we crank the sogd handle.
87 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
88 Assert.That(retrievedPart, Is.Not.Null);
89 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);
90
83 sogd.InventoryDeQueueAndDelete(); 91 sogd.InventoryDeQueueAndDelete();
84 92
85 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 93 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
86 Assert.That(retrievedPart, Is.Null); 94 Assert.That(retrievedPart2, Is.Null);
87 } 95 }
88 96
89 /// <summary> 97 /// <summary>
@@ -124,6 +132,67 @@ namespace OpenSim.Region.Framework.Scenes.Tests
124 // Object should still be in the scene. 132 // Object should still be in the scene.
125 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 133 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
126 Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID)); 134 Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID));
127 } 135 }
136
137 /// <summary>
138 /// Test deleting an object asynchronously to user inventory.
139 /// </summary>
140 [Test]
141 public void TestDeleteSceneObjectAsyncToUserInventory()
142 {
143 TestHelpers.InMethod();
144// TestHelpers.EnableLogging();
145
146 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
147 string myObjectName = "Fred";
148
149 TestScene scene = new SceneHelpers().SetupScene();
150
151 IConfigSource configSource = new IniConfigSource();
152 IConfig config = configSource.AddConfig("Modules");
153 config.Set("InventoryAccessModule", "BasicInventoryAccessModule");
154 SceneHelpers.SetupSceneModules(
155 scene, configSource, new object[] { new BasicInventoryAccessModule() });
156
157 SceneHelpers.SetupSceneModules(scene, new object[] { });
158
159 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
160 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
161 sogd.Enabled = false;
162
163 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId);
164
165 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId);
166 InventoryFolderBase folder1
167 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1", false);
168
169 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
170 scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID);
171
172 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
173
174 Assert.That(retrievedPart, Is.Not.Null);
175 Assert.That(so.IsDeleted, Is.False);
176
177 sogd.InventoryDeQueueAndDelete();
178
179 Assert.That(so.IsDeleted, Is.True);
180
181 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
182 Assert.That(retrievedPart2, Is.Null);
183
184// SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client);
185
186 InventoryItemBase retrievedItem
187 = UserInventoryHelpers.GetInventoryItem(
188 scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName);
189
190 // Check that we now have the taken part in our inventory
191 Assert.That(retrievedItem, Is.Not.Null);
192
193 // Check that the taken part has actually disappeared
194// SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
195// Assert.That(retrievedPart, Is.Null);
196 }
128 } 197 }
129} \ No newline at end of file 198} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index 0e525c9..9378e20 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -40,7 +40,7 @@ using log4net;
40namespace OpenSim.Region.Framework.Scenes.Tests 40namespace OpenSim.Region.Framework.Scenes.Tests
41{ 41{
42 [TestFixture] 42 [TestFixture]
43 public class SceneObjectLinkingTests 43 public class SceneObjectLinkingTests : OpenSimTestCase
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
index e931859..1182c96 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
41 /// Basic scene object resize tests 41 /// Basic scene object resize tests
42 /// </summary> 42 /// </summary>
43 [TestFixture] 43 [TestFixture]
44 public class SceneObjectResizeTests 44 public class SceneObjectResizeTests : OpenSimTestCase
45 { 45 {
46 /// <summary> 46 /// <summary>
47 /// Test resizing an object 47 /// Test resizing an object
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
index d2361f8..a58e735 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
@@ -40,7 +40,7 @@ using OpenSim.Tests.Common.Mock;
40namespace OpenSim.Region.Framework.Scenes.Tests 40namespace OpenSim.Region.Framework.Scenes.Tests
41{ 41{
42 [TestFixture] 42 [TestFixture]
43 public class SceneObjectScriptTests 43 public class SceneObjectScriptTests : OpenSimTestCase
44 { 44 {
45 [Test] 45 [Test]
46 public void TestAddScript() 46 public void TestAddScript()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
index 6d255aa..abaa1d1 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
@@ -42,14 +42,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests
42 /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.) 42 /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.)
43 /// </summary> 43 /// </summary>
44 [TestFixture] 44 [TestFixture]
45 public class SceneObjectSpatialTests 45 public class SceneObjectSpatialTests : OpenSimTestCase
46 { 46 {
47 TestScene m_scene; 47 TestScene m_scene;
48 UUID m_ownerId = TestHelpers.ParseTail(0x1); 48 UUID m_ownerId = TestHelpers.ParseTail(0x1);
49 49
50 [SetUp] 50 [SetUp]
51 public void SetUp() 51 public override void SetUp()
52 { 52 {
53 base.SetUp();
54
53 m_scene = new SceneHelpers().SetupScene(); 55 m_scene = new SceneHelpers().SetupScene();
54 } 56 }
55 57
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
index 742c769..8eb3191 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
42 /// Basic scene object status tests 42 /// Basic scene object status tests
43 /// </summary> 43 /// </summary>
44 [TestFixture] 44 [TestFixture]
45 public class SceneObjectStatusTests 45 public class SceneObjectStatusTests : OpenSimTestCase
46 { 46 {
47 private TestScene m_scene; 47 private TestScene m_scene;
48 private UUID m_ownerId = TestHelpers.ParseTail(0x1); 48 private UUID m_ownerId = TestHelpers.ParseTail(0x1);
@@ -78,6 +78,26 @@ namespace OpenSim.Region.Framework.Scenes.Tests
78 } 78 }
79 79
80 [Test] 80 [Test]
81 public void TestSetNonPhysicsVolumeDetectSinglePrim()
82 {
83 TestHelpers.InMethod();
84
85 m_scene.AddSceneObject(m_so1);
86
87 SceneObjectPart rootPart = m_so1.RootPart;
88 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
89
90 m_so1.ScriptSetVolumeDetect(true);
91
92// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
93 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
94
95 m_so1.ScriptSetVolumeDetect(false);
96
97 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
98 }
99
100 [Test]
81 public void TestSetPhysicsSinglePrim() 101 public void TestSetPhysicsSinglePrim()
82 { 102 {
83 TestHelpers.InMethod(); 103 TestHelpers.InMethod();
@@ -89,13 +109,32 @@ namespace OpenSim.Region.Framework.Scenes.Tests
89 109
90 m_so1.ScriptSetPhysicsStatus(true); 110 m_so1.ScriptSetPhysicsStatus(true);
91 111
92// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
93 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics)); 112 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
94 113
95 m_so1.ScriptSetPhysicsStatus(false); 114 m_so1.ScriptSetPhysicsStatus(false);
96 115
97 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); 116 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
98 } 117 }
118
119 [Test]
120 public void TestSetPhysicsVolumeDetectSinglePrim()
121 {
122 TestHelpers.InMethod();
123
124 m_scene.AddSceneObject(m_so1);
125
126 SceneObjectPart rootPart = m_so1.RootPart;
127 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
128
129 m_so1.ScriptSetPhysicsStatus(true);
130 m_so1.ScriptSetVolumeDetect(true);
131
132 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom | PrimFlags.Physics));
133
134 m_so1.ScriptSetVolumeDetect(false);
135
136 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
137 }
99 138
100 [Test] 139 [Test]
101 public void TestSetPhysicsLinkset() 140 public void TestSetPhysicsLinkset()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index 5faf131..bbfbbfc 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -289,108 +289,5 @@ namespace OpenSim.Region.Framework.Scenes.Tests
289// 289//
290// Assert.That(presence, Is.Null, "presence is not null"); 290// Assert.That(presence, Is.Null, "presence is not null");
291// } 291// }
292
293 // I'm commenting this test because it does not represent
294 // crossings. The Thread.Sleep's in here are not meaningful mocks,
295 // and they sometimes fail in panda.
296 // We need to talk in order to develop a test
297 // that really tests region crossings. There are 3 async components,
298 // but things are synchronous among them. So there should be
299 // 3 threads in here.
300 //[Test]
301// public void T021_TestCrossToNewRegion()
302// {
303// TestHelpers.InMethod();
304//
305// scene.RegisterRegionWithGrid();
306// scene2.RegisterRegionWithGrid();
307//
308// // Adding child agent to region 1001
309// string reason;
310// scene2.NewUserConnection(acd1,0, out reason);
311// scene2.AddNewClient(testclient, PresenceType.User);
312//
313// ScenePresence presence = scene.GetScenePresence(agent1);
314// presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true);
315//
316// ScenePresence presence2 = scene2.GetScenePresence(agent1);
317//
318// // Adding neighbour region caps info to presence2
319//
320// string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
321// presence2.AddNeighbourRegion(region1, cap);
322//
323// Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region.");
324// Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region.");
325//
326// // Cross to x+1
327// presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100);
328// presence.Update();
329//
330// EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
331//
332// // Mimicking communication between client and server, by waiting OK from client
333// // sent by TestClient.CrossRegion call. Originally, this is network comm.
334// if (!wh.WaitOne(5000,false))
335// {
336// presence.Update();
337// if (!wh.WaitOne(8000,false))
338// throw new ArgumentException("1 - Timeout waiting for signal/variable.");
339// }
340//
341// // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which
342// // would normally be fired after receiving the reply packet from comm. done on the last line.
343// testclient.CompleteMovement();
344//
345// // Crossings are asynchronous
346// int timer = 10;
347//
348// // Make sure cross hasn't already finished
349// if (!presence.IsInTransit && !presence.IsChildAgent)
350// {
351// // If not and not in transit yet, give it some more time
352// Thread.Sleep(5000);
353// }
354//
355// // Enough time, should at least be in transit by now.
356// while (presence.IsInTransit && timer > 0)
357// {
358// Thread.Sleep(1000);
359// timer-=1;
360// }
361//
362// Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 2->1.");
363// Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected.");
364// Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent.");
365//
366// // Cross Back
367// presence2.AbsolutePosition = new Vector3(-10, 3, 100);
368// presence2.Update();
369//
370// if (!wh.WaitOne(5000,false))
371// {
372// presence2.Update();
373// if (!wh.WaitOne(8000,false))
374// throw new ArgumentException("2 - Timeout waiting for signal/variable.");
375// }
376// testclient.CompleteMovement();
377//
378// if (!presence2.IsInTransit && !presence2.IsChildAgent)
379// {
380// // If not and not in transit yet, give it some more time
381// Thread.Sleep(5000);
382// }
383//
384// // Enough time, should at least be in transit by now.
385// while (presence2.IsInTransit && timer > 0)
386// {
387// Thread.Sleep(1000);
388// timer-=1;
389// }
390//
391// Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 1->2.");
392// Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
393// Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
394// }
395 } 292 }
396} \ No newline at end of file 293} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
index 646e5fa..1cd8ae9 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
51 /// Scene presence animation tests 51 /// Scene presence animation tests
52 /// </summary> 52 /// </summary>
53 [TestFixture] 53 [TestFixture]
54 public class ScenePresenceAnimationTests 54 public class ScenePresenceAnimationTests : OpenSimTestCase
55 { 55 {
56 [Test] 56 [Test]
57 public void TestFlyingAnimation() 57 public void TestFlyingAnimation()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
index 1d1ff88..d80afd3 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
@@ -42,7 +42,7 @@ using OpenSim.Tests.Common.Mock;
42namespace OpenSim.Region.Framework.Scenes.Tests 42namespace OpenSim.Region.Framework.Scenes.Tests
43{ 43{
44 [TestFixture] 44 [TestFixture]
45 public class ScenePresenceAutopilotTests 45 public class ScenePresenceAutopilotTests : OpenSimTestCase
46 { 46 {
47 private TestScene m_scene; 47 private TestScene m_scene;
48 48
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
new file mode 100644
index 0000000..8775949
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
@@ -0,0 +1,162 @@
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.Reflection;
31using Nini.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.CoreModules.Framework;
39using OpenSim.Region.CoreModules.Framework.EntityTransfer;
40using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
41using OpenSim.Tests.Common;
42using OpenSim.Tests.Common.Mock;
43
44namespace OpenSim.Region.Framework.Scenes.Tests
45{
46 [TestFixture]
47 public class ScenePresenceCrossingTests : OpenSimTestCase
48 {
49 [TestFixtureSetUp]
50 public void FixtureInit()
51 {
52 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
53 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
54 }
55
56 [TestFixtureTearDown]
57 public void TearDown()
58 {
59 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
60 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
61 // tests really shouldn't).
62 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
63 }
64
65 [Test]
66 public void TestCrossOnSameSimulator()
67 {
68 TestHelpers.InMethod();
69// TestHelpers.EnableLogging();
70
71 UUID userId = TestHelpers.ParseTail(0x1);
72
73// TestEventQueueGetModule eqmA = new TestEventQueueGetModule();
74 EntityTransferModule etmA = new EntityTransferModule();
75 EntityTransferModule etmB = new EntityTransferModule();
76 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
77
78 IConfigSource config = new IniConfigSource();
79 IConfig modulesConfig = config.AddConfig("Modules");
80 modulesConfig.Set("EntityTransferModule", etmA.Name);
81 modulesConfig.Set("SimulationServices", lscm.Name);
82// IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
83
84 // In order to run a single threaded regression test we do not want the entity transfer module waiting
85 // for a callback from the destination scene before removing its avatar data.
86// entityTransferConfig.Set("wait_for_callback", false);
87
88 SceneHelpers sh = new SceneHelpers();
89 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
90 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
91
92 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
93 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
94// SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, eqmA);
95 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
96
97 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
98 TestClient tc = new TestClient(acd, sceneA, sh.SceneManager);
99 List<TestClient> destinationTestClients = new List<TestClient>();
100 EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients);
101
102 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd, sh.SceneManager);
103 originalSp.AbsolutePosition = new Vector3(128, 32, 10);
104
105// originalSp.Flying = true;
106
107// Console.WriteLine("First pos {0}", originalSp.AbsolutePosition);
108
109// eqmA.ClearEvents();
110
111 AgentUpdateArgs moveArgs = new AgentUpdateArgs();
112 //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
113 moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
114 moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
115
116 originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);
117
118 sceneA.Update(1);
119
120// Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);
121
122 // FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
123 // But really we want to do this in a more robust way.
124 for (int i = 0; i < 100; i++)
125 {
126 sceneA.Update(1);
127// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
128 }
129
130 // Need to sort processing of EnableSimulator message on adding scene presences before we can test eqm
131 // messages
132// Dictionary<UUID, List<TestEventQueueGetModule.Event>> eqmEvents = eqmA.Events;
133//
134// Assert.That(eqmEvents.Count, Is.EqualTo(1));
135// Assert.That(eqmEvents.ContainsKey(originalSp.UUID), Is.True);
136//
137// List<TestEventQueueGetModule.Event> spEqmEvents = eqmEvents[originalSp.UUID];
138//
139// Assert.That(spEqmEvents.Count, Is.EqualTo(1));
140// Assert.That(spEqmEvents[0].Name, Is.EqualTo("CrossRegion"));
141
142 // sceneA should now only have a child agent
143 ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
144 Assert.That(spAfterCrossSceneA.IsChildAgent, Is.True);
145
146 ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);
147
148 // Agent remains a child until the client triggers complete movement
149 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
150
151 TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);
152
153 int agentMovementCompleteReceived = 0;
154 sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;
155
156 sceneBTc.CompleteMovement();
157
158 Assert.That(agentMovementCompleteReceived, Is.EqualTo(1));
159 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False);
160 }
161 }
162} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
index 493ab70..acaeb90 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
@@ -43,7 +43,7 @@ using System.Threading;
43namespace OpenSim.Region.Framework.Scenes.Tests 43namespace OpenSim.Region.Framework.Scenes.Tests
44{ 44{
45 [TestFixture] 45 [TestFixture]
46 public class ScenePresenceSitTests 46 public class ScenePresenceSitTests : OpenSimTestCase
47 { 47 {
48 private TestScene m_scene; 48 private TestScene m_scene;
49 private ScenePresence m_sp; 49 private ScenePresence m_sp;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
index 37b5184..de4458d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -26,7 +26,10 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Text;
30using Nini.Config; 33using Nini.Config;
31using NUnit.Framework; 34using NUnit.Framework;
32using OpenMetaverse; 35using OpenMetaverse;
@@ -40,8 +43,6 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
40using OpenSim.Region.CoreModules.World.Permissions; 43using OpenSim.Region.CoreModules.World.Permissions;
41using OpenSim.Tests.Common; 44using OpenSim.Tests.Common;
42using OpenSim.Tests.Common.Mock; 45using OpenSim.Tests.Common.Mock;
43using System.IO;
44using System.Text;
45 46
46namespace OpenSim.Region.Framework.Scenes.Tests 47namespace OpenSim.Region.Framework.Scenes.Tests
47{ 48{
@@ -49,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
49 /// Teleport tests in a standalone OpenSim 50 /// Teleport tests in a standalone OpenSim
50 /// </summary> 51 /// </summary>
51 [TestFixture] 52 [TestFixture]
52 public class ScenePresenceTeleportTests 53 public class ScenePresenceTeleportTests : OpenSimTestCase
53 { 54 {
54 [TestFixtureSetUp] 55 [TestFixtureSetUp]
55 public void FixtureInit() 56 public void FixtureInit()
@@ -68,7 +69,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
68 } 69 }
69 70
70 [Test] 71 [Test]
71 public void TestSameRegionTeleport() 72 public void TestSameRegion()
72 { 73 {
73 TestHelpers.InMethod(); 74 TestHelpers.InMethod();
74// log4net.Config.XmlConfigurator.Configure(); 75// log4net.Config.XmlConfigurator.Configure();
@@ -106,10 +107,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
106 } 107 }
107 108
108 [Test] 109 [Test]
109 public void TestSameSimulatorSeparatedRegionsTeleport() 110 public void TestSameSimulatorIsolatedRegions()
110 { 111 {
111 TestHelpers.InMethod(); 112 TestHelpers.InMethod();
112// log4net.Config.XmlConfigurator.Configure(); 113// TestHelpers.EnableLogging();
113 114
114 UUID userId = TestHelpers.ParseTail(0x1); 115 UUID userId = TestHelpers.ParseTail(0x1);
115 116
@@ -141,9 +142,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
141 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); 142 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
142 sp.AbsolutePosition = new Vector3(30, 31, 32); 143 sp.AbsolutePosition = new Vector3(30, 31, 32);
143 144
144 // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole 145 List<TestClient> destinationTestClients = new List<TestClient>();
145 // UDP stack (?) 146 EntityTransferHelpers.SetUpInformClientOfNeighbour((TestClient)sp.ControllingClient, destinationTestClients);
146// ((TestClient)sp.ControllingClient).TeleportTargetScene = sceneB;
147 147
148 sceneA.RequestTeleportLocation( 148 sceneA.RequestTeleportLocation(
149 sp.ControllingClient, 149 sp.ControllingClient,
@@ -152,7 +152,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
152 teleportLookAt, 152 teleportLookAt,
153 (uint)TeleportFlags.ViaLocation); 153 (uint)TeleportFlags.ViaLocation);
154 154
155 ((TestClient)sp.ControllingClient).CompleteTeleportClientSide(); 155 // SetupInformClientOfNeighbour() will have handled the callback into the target scene to setup the child
156 // agent. This call will now complete the movement of the user into the destination and upgrade the agent
157 // from child to root.
158 destinationTestClients[0].CompleteMovement();
156 159
157 Assert.That(sceneA.GetScenePresence(userId), Is.Null); 160 Assert.That(sceneA.GetScenePresence(userId), Is.Null);
158 161
@@ -177,7 +180,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
177 /// Test teleport procedures when the target simulator returns false when queried about access. 180 /// Test teleport procedures when the target simulator returns false when queried about access.
178 /// </summary> 181 /// </summary>
179 [Test] 182 [Test]
180 public void TestSameSimulatorSeparatedRegionsQueryAccessFails() 183 public void TestSameSimulatorIsolatedRegions_DeniedOnQueryAccess()
181 { 184 {
182 TestHelpers.InMethod(); 185 TestHelpers.InMethod();
183// TestHelpers.EnableLogging(); 186// TestHelpers.EnableLogging();
@@ -261,7 +264,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
261 /// Test teleport procedures when the target simulator create agent step is refused. 264 /// Test teleport procedures when the target simulator create agent step is refused.
262 /// </summary> 265 /// </summary>
263 [Test] 266 [Test]
264 public void TestSameSimulatorSeparatedRegionsCreateAgentFails() 267 public void TestSameSimulatorIsolatedRegions_DeniedOnCreateAgent()
265 { 268 {
266 TestHelpers.InMethod(); 269 TestHelpers.InMethod();
267// TestHelpers.EnableLogging(); 270// TestHelpers.EnableLogging();
@@ -333,13 +336,101 @@ namespace OpenSim.Region.Framework.Scenes.Tests
333// TestHelpers.DisableLogging(); 336// TestHelpers.DisableLogging();
334 } 337 }
335 338
339 /// <summary>
340 /// Test teleport when the destination region does not process (or does not receive) the connection attempt
341 /// from the viewer.
342 /// </summary>
343 /// <remarks>
344 /// This could be quite a common case where the source region can connect to a remove destination region
345 /// (for CreateAgent) but the viewer cannot reach the destination region due to network issues.
346 /// </remarks>
336 [Test] 347 [Test]
337 public void TestSameSimulatorNeighbouringRegionsTeleport() 348 public void TestSameSimulatorIsolatedRegions_DestinationDidNotProcessViewerConnection()
338 { 349 {
339 TestHelpers.InMethod(); 350 TestHelpers.InMethod();
340// TestHelpers.EnableLogging(); 351// TestHelpers.EnableLogging();
341 352
342 UUID userId = TestHelpers.ParseTail(0x1); 353 UUID userId = TestHelpers.ParseTail(0x1);
354 Vector3 preTeleportPosition = new Vector3(30, 31, 32);
355
356 EntityTransferModule etmA = new EntityTransferModule();
357 EntityTransferModule etmB = new EntityTransferModule();
358
359 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
360
361 IConfigSource config = new IniConfigSource();
362 config.AddConfig("Modules");
363 config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
364 config.Configs["Modules"].Set("SimulationServices", lscm.Name);
365
366 config.AddConfig("EntityTransfer");
367
368 // In order to run a single threaded regression test we do not want the entity transfer module waiting
369 // for a callback from the destination scene before removing its avatar data.
370 config.Configs["EntityTransfer"].Set("wait_for_callback", false);
371
372// config.AddConfig("Startup");
373// config.Configs["Startup"].Set("serverside_object_permissions", true);
374
375 SceneHelpers sh = new SceneHelpers();
376 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
377 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
378
379 SceneHelpers.SetupSceneModules(sceneA, config, etmA );
380
381 // We need to set up the permisions module on scene B so that our later use of agent limit to deny
382 // QueryAccess won't succeed anyway because administrators are always allowed in and the default
383 // IsAdministrator if no permissions module is present is true.
384 SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB });
385
386 // Shared scene modules
387 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
388
389 Vector3 teleportPosition = new Vector3(10, 11, 12);
390 Vector3 teleportLookAt = new Vector3(20, 21, 22);
391
392 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
393 sp.AbsolutePosition = preTeleportPosition;
394
395 sceneA.RequestTeleportLocation(
396 sp.ControllingClient,
397 sceneB.RegionInfo.RegionHandle,
398 teleportPosition,
399 teleportLookAt,
400 (uint)TeleportFlags.ViaLocation);
401
402 // FIXME: Not setting up InformClientOfNeighbour on the TestClient means that it does not initiate
403 // communication with the destination region. But this is a very non-obvious way of doing it - really we
404 // should be forced to expicitly set this up.
405
406 Assert.That(sceneB.GetScenePresence(userId), Is.Null);
407
408 ScenePresence sceneASp = sceneA.GetScenePresence(userId);
409 Assert.That(sceneASp, Is.Not.Null);
410 Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
411 Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));
412
413 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
414 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
415 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
416 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
417
418 // TODO: Add assertions to check correct circuit details in both scenes.
419
420 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
421 // position instead).
422// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
423
424// TestHelpers.DisableLogging();
425 }
426
427 [Test]
428 public void TestSameSimulatorNeighbouringRegions()
429 {
430 TestHelpers.InMethod();
431 TestHelpers.EnableLogging();
432
433 UUID userId = TestHelpers.ParseTail(0x1);
343 434
344 EntityTransferModule etmA = new EntityTransferModule(); 435 EntityTransferModule etmA = new EntityTransferModule();
345 EntityTransferModule etmB = new EntityTransferModule(); 436 EntityTransferModule etmB = new EntityTransferModule();
@@ -366,10 +457,14 @@ namespace OpenSim.Region.Framework.Scenes.Tests
366 Vector3 teleportPosition = new Vector3(10, 11, 12); 457 Vector3 teleportPosition = new Vector3(10, 11, 12);
367 Vector3 teleportLookAt = new Vector3(20, 21, 22); 458 Vector3 teleportLookAt = new Vector3(20, 21, 22);
368 459
369 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); 460 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
370 originalSp.AbsolutePosition = new Vector3(30, 31, 32); 461 TestClient tc = new TestClient(acd, sceneA, sh.SceneManager);
462 List<TestClient> destinationTestClients = new List<TestClient>();
463 EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients);
464
465 ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd, sh.SceneManager);
466 beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);
371 467
372 ScenePresence beforeSceneASp = sceneA.GetScenePresence(userId);
373 Assert.That(beforeSceneASp, Is.Not.Null); 468 Assert.That(beforeSceneASp, Is.Not.Null);
374 Assert.That(beforeSceneASp.IsChildAgent, Is.False); 469 Assert.That(beforeSceneASp.IsChildAgent, Is.False);
375 470
@@ -377,10 +472,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
377 Assert.That(beforeSceneBSp, Is.Not.Null); 472 Assert.That(beforeSceneBSp, Is.Not.Null);
378 Assert.That(beforeSceneBSp.IsChildAgent, Is.True); 473 Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
379 474
380 // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole 475 // In this case, we will not receieve a second InformClientOfNeighbour since the viewer already knows
381 // UDP stack (?) 476 // about the neighbour region it is teleporting to.
382// ((TestClient)beforeSceneASp.ControllingClient).TeleportTargetScene = sceneB;
383
384 sceneA.RequestTeleportLocation( 477 sceneA.RequestTeleportLocation(
385 beforeSceneASp.ControllingClient, 478 beforeSceneASp.ControllingClient,
386 sceneB.RegionInfo.RegionHandle, 479 sceneB.RegionInfo.RegionHandle,
@@ -388,7 +481,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
388 teleportLookAt, 481 teleportLookAt,
389 (uint)TeleportFlags.ViaLocation); 482 (uint)TeleportFlags.ViaLocation);
390 483
391 ((TestClient)beforeSceneASp.ControllingClient).CompleteTeleportClientSide(); 484 destinationTestClients[0].CompleteMovement();
392 485
393 ScenePresence afterSceneASp = sceneA.GetScenePresence(userId); 486 ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
394 Assert.That(afterSceneASp, Is.Not.Null); 487 Assert.That(afterSceneASp, Is.Not.Null);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index ac3da1e..9d8eb0b 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
50 /// Scene presence tests 50 /// Scene presence tests
51 /// </summary> 51 /// </summary>
52 [TestFixture] 52 [TestFixture]
53 public class SceneTests 53 public class SceneTests : OpenSimTestCase
54 { 54 {
55 /// <summary> 55 /// <summary>
56 /// Very basic scene update test. Should become more elaborate with time. 56 /// Very basic scene update test. Should become more elaborate with time.
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
index a51e4e3..6e0ea7d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
@@ -50,7 +50,7 @@ using OpenSim.Tests.Common.Mock;
50namespace OpenSim.Region.Framework.Tests 50namespace OpenSim.Region.Framework.Tests
51{ 51{
52 [TestFixture] 52 [TestFixture]
53 public class TaskInventoryTests 53 public class TaskInventoryTests : OpenSimTestCase
54 { 54 {
55 [Test] 55 [Test]
56 public void TestAddTaskInventoryItem() 56 public void TestAddTaskInventoryItem()
@@ -130,10 +130,10 @@ namespace OpenSim.Region.Framework.Tests
130 SceneObjectPart sop1 = sog1.RootPart; 130 SceneObjectPart sop1 = sog1.RootPart;
131 TaskInventoryItem sopItem1 131 TaskInventoryItem sopItem1
132 = TaskInventoryHelpers.AddNotecard( 132 = TaskInventoryHelpers.AddNotecard(
133 scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); 133 scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!");
134 134
135 InventoryFolderBase folder 135 InventoryFolderBase folder
136 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; 136 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0];
137 137
138 // Perform test 138 // Perform test
139 scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID); 139 scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID);
@@ -162,7 +162,7 @@ namespace OpenSim.Region.Framework.Tests
162 SceneObjectPart sop1 = sog1.RootPart; 162 SceneObjectPart sop1 = sog1.RootPart;
163 TaskInventoryItem sopItem1 163 TaskInventoryItem sopItem1
164 = TaskInventoryHelpers.AddNotecard( 164 = TaskInventoryHelpers.AddNotecard(
165 scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); 165 scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!");
166 166
167 // Perform test 167 // Perform test
168 scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); 168 scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
index 9457ebb..e50b4da 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Tests
64 Scene scene = new SceneHelpers().SetupScene(); 64 Scene scene = new SceneHelpers().SetupScene();
65 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); 65 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
66 66
67 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName); 67 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName, false);
68 68
69 List<InventoryFolderBase> oneFolder 69 List<InventoryFolderBase> oneFolder
70 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName); 70 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName);
@@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Tests
73 InventoryFolderBase firstRetrievedFolder = oneFolder[0]; 73 InventoryFolderBase firstRetrievedFolder = oneFolder[0];
74 Assert.That(firstRetrievedFolder.Name, Is.EqualTo(foldersName)); 74 Assert.That(firstRetrievedFolder.Name, Is.EqualTo(foldersName));
75 75
76 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName); 76 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName, false);
77 77
78 List<InventoryFolderBase> twoFolders 78 List<InventoryFolderBase> twoFolders
79 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName); 79 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName);
@@ -121,7 +121,7 @@ namespace OpenSim.Region.Framework.Tests
121 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); 121 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
122 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); 122 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
123 InventoryFolderBase folder1 123 InventoryFolderBase folder1
124 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1"); 124 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false);
125 125
126 scene.GiveInventoryFolder(user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero); 126 scene.GiveInventoryFolder(user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero);
127 127
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index 198e487..dd27294 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -38,7 +38,7 @@ using OpenSim.Tests.Common.Mock;
38namespace OpenSim.Region.Framework.Scenes.Tests 38namespace OpenSim.Region.Framework.Scenes.Tests
39{ 39{
40 [TestFixture] 40 [TestFixture]
41 public class UuidGathererTests 41 public class UuidGathererTests : OpenSimTestCase
42 { 42 {
43 protected IAssetService m_assetService; 43 protected IAssetService m_assetService;
44 protected UuidGatherer m_uuidGatherer; 44 protected UuidGatherer m_uuidGatherer;
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 2279e62..b09ae39 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -127,7 +127,10 @@ namespace OpenSim.Region.Framework.Scenes
127 /// within this object). 127 /// within this object).
128 /// </remarks> 128 /// </remarks>
129 /// <param name="sceneObject">The scene object for which to gather assets</param> 129 /// <param name="sceneObject">The scene object for which to gather assets</param>
130 /// <param name="assetUuids">The assets gathered</param> 130 /// <param name="assetUuids">
131 /// A dictionary which is populated with the asset UUIDs gathered and the type of that asset.
132 /// For assets where the type is not clear (e.g. UUIDs extracted from LSL and notecards), the type is Unknown.
133 /// </param>
131 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids) 134 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids)
132 { 135 {
133// m_log.DebugFormat( 136// m_log.DebugFormat(
@@ -257,8 +260,9 @@ namespace OpenSim.Region.Framework.Scenes
257 UUID uuid = new UUID(uuidMatch.Value); 260 UUID uuid = new UUID(uuidMatch.Value);
258// m_log.DebugFormat("[ARCHIVER]: Recording {0} in text", uuid); 261// m_log.DebugFormat("[ARCHIVER]: Recording {0} in text", uuid);
259 262
260 // Assume AssetIDs embedded are textures. 263 // Embedded asset references (if not false positives) could be for many types of asset, so we will
261 assetUuids[uuid] = AssetType.Texture; 264 // label these as unknown.
265 assetUuids[uuid] = AssetType.Unknown;
262 } 266 }
263 } 267 }
264 } 268 }