aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-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/KeyframeMotion.cs513
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs102
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs628
-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.cs255
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs362
-rw-r--r--OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs46
-rw-r--r--OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs91
-rw-r--r--OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineInterface.cs38
-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.cs20
-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
43 files changed, 1973 insertions, 1319 deletions
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/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
index 5cfba39..b102e48 100644
--- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
+++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
@@ -22,6 +22,115 @@ using log4net;
22 22
23namespace OpenSim.Region.Framework.Scenes 23namespace OpenSim.Region.Framework.Scenes
24{ 24{
25 public class KeyframeTimer
26 {
27 private static Dictionary<Scene, KeyframeTimer>m_timers =
28 new Dictionary<Scene, KeyframeTimer>();
29
30 private Timer m_timer;
31 private Dictionary<KeyframeMotion, object> m_motions = new Dictionary<KeyframeMotion, object>();
32 private object m_lockObject = new object();
33 private object m_timerLock = new object();
34 private const double m_tickDuration = 50.0;
35 private Scene m_scene;
36
37 public double TickDuration
38 {
39 get { return m_tickDuration; }
40 }
41
42 public KeyframeTimer(Scene scene)
43 {
44 m_timer = new Timer();
45 m_timer.Interval = TickDuration;
46 m_timer.AutoReset = true;
47 m_timer.Elapsed += OnTimer;
48
49 m_scene = scene;
50
51 m_timer.Start();
52 }
53
54 private void OnTimer(object sender, ElapsedEventArgs ea)
55 {
56 if (!Monitor.TryEnter(m_timerLock))
57 return;
58
59 try
60 {
61 List<KeyframeMotion> motions;
62
63 lock (m_lockObject)
64 {
65 motions = new List<KeyframeMotion>(m_motions.Keys);
66 }
67
68 foreach (KeyframeMotion m in motions)
69 {
70 try
71 {
72 m.OnTimer(TickDuration);
73 }
74 catch (Exception inner)
75 {
76 // Don't stop processing
77 }
78 }
79 }
80 catch (Exception e)
81 {
82 // Keep running no matter what
83 }
84 finally
85 {
86 Monitor.Exit(m_timerLock);
87 }
88 }
89
90 public static void Add(KeyframeMotion motion)
91 {
92 KeyframeTimer timer;
93
94 if (motion.Scene == null)
95 return;
96
97 lock (m_timers)
98 {
99 if (!m_timers.TryGetValue(motion.Scene, out timer))
100 {
101 timer = new KeyframeTimer(motion.Scene);
102 m_timers[motion.Scene] = timer;
103 }
104 }
105
106 lock (timer.m_lockObject)
107 {
108 timer.m_motions[motion] = null;
109 }
110 }
111
112 public static void Remove(KeyframeMotion motion)
113 {
114 KeyframeTimer timer;
115
116 if (motion.Scene == null)
117 return;
118
119 lock (m_timers)
120 {
121 if (!m_timers.TryGetValue(motion.Scene, out timer))
122 {
123 return;
124 }
125 }
126
127 lock (timer.m_lockObject)
128 {
129 timer.m_motions.Remove(motion);
130 }
131 }
132 }
133
25 [Serializable] 134 [Serializable]
26 public class KeyframeMotion 135 public class KeyframeMotion
27 { 136 {
@@ -63,18 +172,6 @@ namespace OpenSim.Region.Framework.Scenes
63 172
64 private Keyframe[] m_keyframes; 173 private Keyframe[] m_keyframes;
65 174
66 [NonSerialized()]
67 protected Timer m_timer = null;
68
69 // timer lock
70 [NonSerialized()]
71 private object m_onTimerLock;
72
73 // timer overrun detect
74 // prevents overlap or timer events threads frozen on the lock
75 [NonSerialized()]
76 private bool m_inOnTimer;
77
78 // skip timer events. 175 // skip timer events.
79 //timer.stop doesn't assure there aren't event threads still being fired 176 //timer.stop doesn't assure there aren't event threads still being fired
80 [NonSerialized()] 177 [NonSerialized()]
@@ -97,12 +194,21 @@ namespace OpenSim.Region.Framework.Scenes
97 private DataFormat m_data = DataFormat.Translation | DataFormat.Rotation; 194 private DataFormat m_data = DataFormat.Translation | DataFormat.Rotation;
98 195
99 private bool m_running = false; 196 private bool m_running = false;
197
100 [NonSerialized()] 198 [NonSerialized()]
101 private bool m_selected = false; 199 private bool m_selected = false;
102 200
103 private int m_iterations = 0; 201 private int m_iterations = 0;
104 202
105 private const double timerInterval = 50.0; 203 private int m_skipLoops = 0;
204
205 [NonSerialized()]
206 private Scene m_scene;
207
208 public Scene Scene
209 {
210 get { return m_scene; }
211 }
106 212
107 public DataFormat Data 213 public DataFormat Data
108 { 214 {
@@ -139,31 +245,16 @@ namespace OpenSim.Region.Framework.Scenes
139 245
140 private void StartTimer() 246 private void StartTimer()
141 { 247 {
142 if (m_timer == null) 248 KeyframeTimer.Add(this);
143 return;
144 m_timerStopped = false; 249 m_timerStopped = false;
145 m_timer.Start();
146 } 250 }
147 251
148 private void StopTimer() 252 private void StopTimer()
149 { 253 {
150 if (m_timer == null || m_timerStopped)
151 return;
152 m_timerStopped = true;
153 m_timer.Stop();
154 }
155
156 private void RemoveTimer()
157 {
158 if (m_timer == null)
159 return;
160 m_timerStopped = true; 254 m_timerStopped = true;
161 m_timer.Stop(); 255 KeyframeTimer.Remove(this);
162 m_timer.Elapsed -= OnTimer;
163 m_timer = null;
164 } 256 }
165 257
166
167 public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) 258 public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data)
168 { 259 {
169 KeyframeMotion newMotion = null; 260 KeyframeMotion newMotion = null;
@@ -177,12 +268,15 @@ namespace OpenSim.Region.Framework.Scenes
177 268
178 newMotion.m_group = grp; 269 newMotion.m_group = grp;
179 270
180 if (grp != null && grp.IsSelected) 271 if (grp != null)
181 newMotion.m_selected = true; 272 {
273 newMotion.m_scene = grp.Scene;
274 if (grp.IsSelected)
275 newMotion.m_selected = true;
276 }
182 277
183 newMotion.m_onTimerLock = new object();
184 newMotion.m_timerStopped = false; 278 newMotion.m_timerStopped = false;
185 newMotion.m_inOnTimer = false; 279 newMotion.m_running = true;
186 newMotion.m_isCrossing = false; 280 newMotion.m_isCrossing = false;
187 newMotion.m_waitingCrossing = false; 281 newMotion.m_waitingCrossing = false;
188 } 282 }
@@ -196,37 +290,36 @@ namespace OpenSim.Region.Framework.Scenes
196 290
197 public void UpdateSceneObject(SceneObjectGroup grp) 291 public void UpdateSceneObject(SceneObjectGroup grp)
198 { 292 {
199// lock (m_onTimerLock) 293 m_isCrossing = false;
200 { 294 m_waitingCrossing = false;
201 m_isCrossing = false; 295 StopTimer();
202 m_waitingCrossing = false;
203 StopTimer();
204 296
205 if (grp == null) 297 if (grp == null)
206 return; 298 return;
207 299
208 m_group = grp; 300 m_group = grp;
209 Vector3 grppos = grp.AbsolutePosition; 301 m_scene = grp.Scene;
210 Vector3 offset = grppos - m_serializedPosition;
211 // avoid doing it more than once
212 // current this will happen draging a prim to other region
213 m_serializedPosition = grppos;
214 302
215 m_basePosition += offset; 303 Vector3 grppos = grp.AbsolutePosition;
216 m_currentFrame.Position += offset; 304 Vector3 offset = grppos - m_serializedPosition;
305 // avoid doing it more than once
306 // current this will happen draging a prim to other region
307 m_serializedPosition = grppos;
217 308
218 m_nextPosition += offset; 309 m_basePosition += offset;
310 m_currentFrame.Position += offset;
219 311
220 for (int i = 0; i < m_frames.Count; i++) 312 m_nextPosition += offset;
221 {
222 Keyframe k = m_frames[i];
223 k.Position += offset;
224 m_frames[i]=k;
225 }
226 313
227 if (m_running) 314 for (int i = 0; i < m_frames.Count; i++)
228 Start(); 315 {
316 Keyframe k = m_frames[i];
317 k.Position += offset;
318 m_frames[i]=k;
229 } 319 }
320
321 if (m_running)
322 Start();
230 } 323 }
231 324
232 public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data) 325 public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data)
@@ -239,11 +332,10 @@ namespace OpenSim.Region.Framework.Scenes
239 { 332 {
240 m_basePosition = grp.AbsolutePosition; 333 m_basePosition = grp.AbsolutePosition;
241 m_baseRotation = grp.GroupRotation; 334 m_baseRotation = grp.GroupRotation;
335 m_scene = grp.Scene;
242 } 336 }
243 337
244 m_onTimerLock = new object();
245 m_timerStopped = true; 338 m_timerStopped = true;
246 m_inOnTimer = false;
247 m_isCrossing = false; 339 m_isCrossing = false;
248 m_waitingCrossing = false; 340 m_waitingCrossing = false;
249 } 341 }
@@ -260,6 +352,7 @@ namespace OpenSim.Region.Framework.Scenes
260 KeyframeMotion newmotion = new KeyframeMotion(null, m_mode, m_data); 352 KeyframeMotion newmotion = new KeyframeMotion(null, m_mode, m_data);
261 353
262 newmotion.m_group = newgrp; 354 newmotion.m_group = newgrp;
355 newmotion.m_scene = newgrp.Scene;
263 356
264 if (m_keyframes != null) 357 if (m_keyframes != null)
265 { 358 {
@@ -296,7 +389,7 @@ namespace OpenSim.Region.Framework.Scenes
296 public void Delete() 389 public void Delete()
297 { 390 {
298 m_running = false; 391 m_running = false;
299 RemoveTimer(); 392 StopTimer();
300 m_isCrossing = false; 393 m_isCrossing = false;
301 m_waitingCrossing = false; 394 m_waitingCrossing = false;
302 m_frames.Clear(); 395 m_frames.Clear();
@@ -309,27 +402,13 @@ namespace OpenSim.Region.Framework.Scenes
309 m_waitingCrossing = false; 402 m_waitingCrossing = false;
310 if (m_keyframes != null && m_group != null && m_keyframes.Length > 0) 403 if (m_keyframes != null && m_group != null && m_keyframes.Length > 0)
311 { 404 {
312 if (m_timer == null)
313 {
314 m_timer = new Timer();
315 m_timer.Interval = timerInterval;
316 m_timer.AutoReset = true;
317 m_timer.Elapsed += OnTimer;
318 }
319 else
320 {
321 StopTimer();
322 m_timer.Interval = timerInterval;
323 }
324
325 m_inOnTimer = false;
326 StartTimer(); 405 StartTimer();
327 m_running = true; 406 m_running = true;
328 } 407 }
329 else 408 else
330 { 409 {
331 m_running = false; 410 m_running = false;
332 RemoveTimer(); 411 StopTimer();
333 } 412 }
334 } 413 }
335 414
@@ -339,7 +418,7 @@ namespace OpenSim.Region.Framework.Scenes
339 m_isCrossing = false; 418 m_isCrossing = false;
340 m_waitingCrossing = false; 419 m_waitingCrossing = false;
341 420
342 RemoveTimer(); 421 StopTimer();
343 422
344 m_basePosition = m_group.AbsolutePosition; 423 m_basePosition = m_group.AbsolutePosition;
345 m_baseRotation = m_group.GroupRotation; 424 m_baseRotation = m_group.GroupRotation;
@@ -354,7 +433,7 @@ namespace OpenSim.Region.Framework.Scenes
354 public void Pause() 433 public void Pause()
355 { 434 {
356 m_running = false; 435 m_running = false;
357 RemoveTimer(); 436 StopTimer();
358 437
359 m_group.RootPart.Velocity = Vector3.Zero; 438 m_group.RootPart.Velocity = Vector3.Zero;
360 m_group.RootPart.AngularVelocity = Vector3.Zero; 439 m_group.RootPart.AngularVelocity = Vector3.Zero;
@@ -377,15 +456,11 @@ namespace OpenSim.Region.Framework.Scenes
377 456
378 int start = 0; 457 int start = 0;
379 int end = m_keyframes.Length; 458 int end = m_keyframes.Length;
380// if (m_mode == PlayMode.PingPong && m_keyframes.Length > 1)
381// end = m_keyframes.Length - 1;
382 459
383 if (direction < 0) 460 if (direction < 0)
384 { 461 {
385 start = m_keyframes.Length - 1; 462 start = m_keyframes.Length - 1;
386 end = -1; 463 end = -1;
387// if (m_mode == PlayMode.PingPong && m_keyframes.Length > 1)
388// end = 0;
389 } 464 }
390 465
391 for (int i = start; i != end ; i += direction) 466 for (int i = start; i != end ; i += direction)
@@ -463,189 +538,172 @@ namespace OpenSim.Region.Framework.Scenes
463 } 538 }
464 } 539 }
465 540
466 protected void OnTimer(object sender, ElapsedEventArgs e) 541 public void OnTimer(double tickDuration)
467 { 542 {
468 if (m_timerStopped) // trap events still in air even after a timer.stop 543 if (m_skipLoops > 0)
469 return;
470
471 if (m_inOnTimer) // don't let overruns to happen
472 { 544 {
473 m_log.Warn("[KeyFrame]: timer overrun"); 545 m_skipLoops--;
474 return; 546 return;
475 } 547 }
476 548
549 if (m_timerStopped) // trap events still in air even after a timer.stop
550 return;
551
477 if (m_group == null) 552 if (m_group == null)
478 return; 553 return;
479 554
480 lock (m_onTimerLock) 555 bool update = false;
481 {
482 556
483 m_inOnTimer = true; 557 if (m_selected)
558 {
559 if (m_group.RootPart.Velocity != Vector3.Zero)
560 {
561 m_group.RootPart.Velocity = Vector3.Zero;
562 m_group.SendGroupRootTerseUpdate();
484 563
485 bool update = false; 564 }
565 return;
566 }
486 567
487 try 568 if (m_isCrossing)
569 {
570 // if crossing and timer running then cross failed
571 // wait some time then
572 // retry to set the position that evtually caused the outbound
573 // if still outside region this will call startCrossing below
574 m_isCrossing = false;
575 m_group.AbsolutePosition = m_nextPosition;
576 if (!m_isCrossing)
488 { 577 {
489 if (m_selected) 578 StopTimer();
490 { 579 StartTimer();
491 if (m_group.RootPart.Velocity != Vector3.Zero) 580 }
492 { 581 return;
493 m_group.RootPart.Velocity = Vector3.Zero; 582 }
494 m_group.SendGroupRootTerseUpdate();
495// m_group.RootPart.ScheduleTerseUpdate();
496 583
497 } 584 if (m_frames.Count == 0)
498 m_inOnTimer = false; 585 {
499 return; 586 GetNextList();
500 }
501 587
502 if (m_isCrossing) 588 if (m_frames.Count == 0)
503 { 589 {
504 // if crossing and timer running then cross failed 590 Stop();
505 // wait some time then 591 Scene scene = m_group.Scene;
506 // retry to set the position that evtually caused the outbound
507 // if still outside region this will call startCrossing below
508 m_isCrossing = false;
509 m_group.AbsolutePosition = m_nextPosition;
510 if (!m_isCrossing)
511 {
512 StopTimer();
513 m_timer.Interval = timerInterval;
514 StartTimer();
515 }
516 m_inOnTimer = false;
517 return;
518 }
519 592
520 if (m_frames.Count == 0) 593 IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
594 foreach (IScriptModule m in scriptModules)
521 { 595 {
522 GetNextList(); 596 if (m == null)
597 continue;
598 m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]);
599 }
523 600
524 if (m_frames.Count == 0) 601 return;
525 { 602 }
526 Stop();
527 m_inOnTimer = false;
528 return;
529 }
530 603
531 m_currentFrame = m_frames[0]; 604 m_currentFrame = m_frames[0];
532 m_currentFrame.TimeMS += (int)timerInterval; 605 m_currentFrame.TimeMS += (int)tickDuration;
533 606
534 //force a update on a keyframe transition 607 //force a update on a keyframe transition
535 update = true; 608 update = true;
536 } 609 }
537 610
538 m_currentFrame.TimeMS -= (int)timerInterval; 611 m_currentFrame.TimeMS -= (int)tickDuration;
539 612
540 // Do the frame processing 613 // Do the frame processing
541 double steps = (double)m_currentFrame.TimeMS / timerInterval; 614 double steps = (double)m_currentFrame.TimeMS / tickDuration;
542 615
543 if (steps <= 0.0) 616 if (steps <= 0.0)
544 { 617 {
545 m_group.RootPart.Velocity = Vector3.Zero; 618 m_group.RootPart.Velocity = Vector3.Zero;
546 m_group.RootPart.AngularVelocity = Vector3.Zero; 619 m_group.RootPart.AngularVelocity = Vector3.Zero;
547 620
548 m_nextPosition = (Vector3)m_currentFrame.Position; 621 m_nextPosition = (Vector3)m_currentFrame.Position;
549 m_group.AbsolutePosition = m_nextPosition; 622 m_group.AbsolutePosition = m_nextPosition;
550 623
551 // we are sending imediate updates, no doing force a extra terseUpdate 624 // we are sending imediate updates, no doing force a extra terseUpdate
552// m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); 625 // m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
553 626
554 m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; 627 m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation;
555 m_frames.RemoveAt(0); 628 m_frames.RemoveAt(0);
556 if (m_frames.Count > 0) 629 if (m_frames.Count > 0)
557 m_currentFrame = m_frames[0]; 630 m_currentFrame = m_frames[0];
558 631
559 update = true; 632 update = true;
560 } 633 }
561 else 634 else
562 { 635 {
563 float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; 636 float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal;
564 637
565 Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition; 638 Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition;
566 Vector3 motionThisFrame = v / (float)steps; 639 Vector3 motionThisFrame = v / (float)steps;
567 v = v * 1000 / m_currentFrame.TimeMS; 640 v = v * 1000 / m_currentFrame.TimeMS;
568 641
569 if (Vector3.Mag(motionThisFrame) >= 0.05f) 642 if (Vector3.Mag(motionThisFrame) >= 0.05f)
570 { 643 {
571 // m_group.AbsolutePosition += motionThisFrame; 644 // m_group.AbsolutePosition += motionThisFrame;
572 m_nextPosition = m_group.AbsolutePosition + motionThisFrame; 645 m_nextPosition = m_group.AbsolutePosition + motionThisFrame;
573 m_group.AbsolutePosition = m_nextPosition; 646 m_group.AbsolutePosition = m_nextPosition;
574 647
575 m_group.RootPart.Velocity = v; 648 m_group.RootPart.Velocity = v;
576 update = true; 649 update = true;
577 } 650 }
578 651
579 if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation) 652 if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation)
580 { 653 {
581 Quaternion current = m_group.GroupRotation; 654 Quaternion current = m_group.GroupRotation;
582 655
583 Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); 656 Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete);
584 step.Normalize(); 657 step.Normalize();
585/* use simpler change detection 658/* use simpler change detection
586 * float angle = 0; 659* float angle = 0;
587
588 float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W;
589 float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W;
590 float aa_bb = aa * bb;
591
592 if (aa_bb == 0)
593 {
594 angle = 0;
595 }
596 else
597 {
598 float ab = current.X * step.X +
599 current.Y * step.Y +
600 current.Z * step.Z +
601 current.W * step.W;
602 float q = (ab * ab) / aa_bb;
603
604 if (q > 1.0f)
605 {
606 angle = 0;
607 }
608 else
609 {
610 angle = (float)Math.Acos(2 * q - 1);
611 }
612 }
613
614 if (angle > 0.01f)
615 */
616 if(Math.Abs(step.X - current.X) > 0.001f
617 || Math.Abs(step.Y - current.Y) > 0.001f
618 || Math.Abs(step.Z - current.Z) > 0.001f)
619 // assuming w is a dependente var
620 660
621 { 661 float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W;
622// m_group.UpdateGroupRotationR(step); 662 float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W;
623 m_group.RootPart.RotationOffset = step; 663 float aa_bb = aa * bb;
624 664
625 //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); 665 if (aa_bb == 0)
626 update = true; 666 {
627 } 667 angle = 0;
668 }
669 else
670 {
671 float ab = current.X * step.X +
672 current.Y * step.Y +
673 current.Z * step.Z +
674 current.W * step.W;
675 float q = (ab * ab) / aa_bb;
676
677 if (q > 1.0f)
678 {
679 angle = 0;
680 }
681 else
682 {
683 angle = (float)Math.Acos(2 * q - 1);
628 } 684 }
629 } 685 }
630 686
631 if (update) 687 if (angle > 0.01f)
632 m_group.SendGroupRootTerseUpdate(); 688*/
633// m_group.RootPart.ScheduleTerseUpdate(); 689 if(Math.Abs(step.X - current.X) > 0.001f
690 || Math.Abs(step.Y - current.Y) > 0.001f
691 || Math.Abs(step.Z - current.Z) > 0.001f)
692 // assuming w is a dependente var
634 693
694 {
695// m_group.UpdateGroupRotationR(step);
696 m_group.RootPart.RotationOffset = step;
635 697
698 //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
699 update = true;
700 }
636 } 701 }
637 catch ( Exception ex) 702 }
638 {
639 // still happening sometimes
640 // lets try to see where
641 m_log.Warn("[KeyFrame]: timer overrun" + ex.Message);
642 }
643 703
644 finally 704 if (update)
645 { 705 {
646 // make sure we do not let this frozen 706 m_group.SendGroupRootTerseUpdate();
647 m_inOnTimer = false;
648 }
649 } 707 }
650 } 708 }
651 709
@@ -677,7 +735,7 @@ namespace OpenSim.Region.Framework.Scenes
677 m_isCrossing = true; 735 m_isCrossing = true;
678 m_waitingCrossing = true; 736 m_waitingCrossing = true;
679 737
680// to remove / retune to smoth crossings 738 // to remove / retune to smoth crossings
681 if (m_group.RootPart.Velocity != Vector3.Zero) 739 if (m_group.RootPart.Velocity != Vector3.Zero)
682 { 740 {
683 m_group.RootPart.Velocity = Vector3.Zero; 741 m_group.RootPart.Velocity = Vector3.Zero;
@@ -696,9 +754,10 @@ namespace OpenSim.Region.Framework.Scenes
696 m_group.SendGroupRootTerseUpdate(); 754 m_group.SendGroupRootTerseUpdate();
697// m_group.RootPart.ScheduleTerseUpdate(); 755// m_group.RootPart.ScheduleTerseUpdate();
698 756
699 if (m_running && m_timer != null) 757 if (m_running)
700 { 758 {
701 m_timer.Interval = 60000; 759 StopTimer();
760 m_skipLoops = 1200; // 60 seconds
702 StartTimer(); 761 StartTimer();
703 } 762 }
704 } 763 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index c9d1205..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{
@@ -401,29 +402,68 @@ namespace OpenSim.Region.Framework.Scenes
401 if (item.Owner != remoteClient.AgentId) 402 if (item.Owner != remoteClient.AgentId)
402 return; 403 return;
403 404
404 if (UUID.Zero == transactionID) 405 item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255);
405 { 406 item.Name = itemUpd.Name;
406 item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); 407 item.Description = itemUpd.Description;
407 item.Name = itemUpd.Name;
408 item.Description = itemUpd.Description;
409 408
410// m_log.DebugFormat( 409// m_log.DebugFormat(
411// "[USER INVENTORY]: itemUpd {0} {1} {2} {3}, item {4} {5} {6} {7}", 410// "[USER INVENTORY]: itemUpd {0} {1} {2} {3}, item {4} {5} {6} {7}",
412// itemUpd.NextPermissions, itemUpd.GroupPermissions, itemUpd.EveryOnePermissions, item.Flags, 411// itemUpd.NextPermissions, itemUpd.GroupPermissions, itemUpd.EveryOnePermissions, item.Flags,
413// item.NextPermissions, item.GroupPermissions, item.EveryOnePermissions, item.CurrentPermissions); 412// item.NextPermissions, item.GroupPermissions, item.EveryOnePermissions, item.CurrentPermissions);
414 413
414 if (itemUpd.NextPermissions != 0) // Use this to determine validity. Can never be 0 if valid
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,8 +485,10 @@ 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 else 490
491 if (UUID.Zero != transactionID)
450 { 492 {
451 if (AgentTransactionsModule != null) 493 if (AgentTransactionsModule != null)
452 { 494 {
@@ -683,12 +725,10 @@ namespace OpenSim.Region.Framework.Scenes
683 itemCopy.SalePrice = item.SalePrice; 725 itemCopy.SalePrice = item.SalePrice;
684 itemCopy.SaleType = item.SaleType; 726 itemCopy.SaleType = item.SaleType;
685 727
686 if (AddInventoryItem(itemCopy)) 728 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
687 { 729 if (invAccess != null)
688 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); 730 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
689 if (invAccess != null) 731 AddInventoryItem(itemCopy);
690 Util.FireAndForget(delegate { invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); });
691 }
692 732
693 if (!Permissions.BypassPermissions()) 733 if (!Permissions.BypassPermissions())
694 { 734 {
@@ -908,7 +948,7 @@ namespace OpenSim.Region.Framework.Scenes
908 { 948 {
909 CreateNewInventoryItem( 949 CreateNewInventoryItem(
910 remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, 950 remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType,
911 (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);
912 } 952 }
913 953
914 954
@@ -1037,8 +1077,8 @@ namespace OpenSim.Region.Framework.Scenes
1037 CreateNewInventoryItem( 1077 CreateNewInventoryItem(
1038 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, 1078 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
1039 name, description, 0, callbackID, asset, invType, 1079 name, description, 0, callbackID, asset, invType,
1040 (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,
1041 (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); 1081 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch());
1042 } 1082 }
1043 else 1083 else
1044 { 1084 {
@@ -1785,6 +1825,21 @@ namespace OpenSim.Region.Framework.Scenes
1785 /// <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>
1786 public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase) 1826 public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase)
1787 { 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 {
1788 // The part ID is the folder ID! 1843 // The part ID is the folder ID!
1789 SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); 1844 SceneObjectPart part = GetSceneObjectPart(itemBase.Folder);
1790 if (part == null) 1845 if (part == null)
@@ -1804,9 +1859,14 @@ namespace OpenSim.Region.Framework.Scenes
1804 return null; 1859 return null;
1805 } 1860 }
1806 1861
1807 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1862 AssetBase asset
1808 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(
1809 agentID); 1864 itemBase.Name,
1865 itemBase.Description,
1866 (sbyte)itemBase.AssetType,
1867 Encoding.ASCII.GetBytes(scriptText),
1868 agentID);
1869
1810 AssetService.Store(asset); 1870 AssetService.Store(asset);
1811 1871
1812 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 e3bc8c7..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());
842 946
843 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); 947 UUID tileID;
844 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 948
845 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 949 if (tile != UUID.Zero.ToString() && UUID.TryParse(tile, out tileID))
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" };
882 961
883 string grant = startupConfig.GetString("AllowedClients", String.Empty); 962 string grant
884 if (grant.Length > 0) 963 = Util.GetConfigVarFromSections<string>(
964 config, "AllowedClients", possibleAccessControlConfigSections, "");
965
966 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 }
973
974 grant
975 = Util.GetConfigVarFromSections<string>(
976 config, "BannedClients", possibleAccessControlConfigSections, "");
891 977
892 grant = startupConfig.GetString("BannedClients", String.Empty); 978 if (grant.Length > 0)
893 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 }
@@ -2769,8 +2766,6 @@ namespace OpenSim.Region.Framework.Scenes
2769 2766
2770 if (newPosition != Vector3.Zero) 2767 if (newPosition != Vector3.Zero)
2771 newObject.RootPart.GroupPosition = newPosition; 2768 newObject.RootPart.GroupPosition = newPosition;
2772 if (newObject.RootPart.KeyframeMotion != null)
2773 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2774 2769
2775 if (!AddSceneObject(newObject)) 2770 if (!AddSceneObject(newObject))
2776 { 2771 {
@@ -2798,6 +2793,9 @@ namespace OpenSim.Region.Framework.Scenes
2798 // before we restart the scripts, or else some functions won't work. 2793 // before we restart the scripts, or else some functions won't work.
2799 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); 2794 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
2800 newObject.ResumeScripts(); 2795 newObject.ResumeScripts();
2796
2797 if (newObject.RootPart.KeyframeMotion != null)
2798 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2801 } 2799 }
2802 2800
2803 // Do this as late as possible so that listeners have full access to the incoming object 2801 // Do this as late as possible so that listeners have full access to the incoming object
@@ -2863,9 +2861,12 @@ namespace OpenSim.Region.Framework.Scenes
2863// "[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);
2864 2862
2865 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2863 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2866 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.
2867 if (AttachmentsModule != null) 2868 if (AttachmentsModule != null)
2868 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false); 2869 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true);
2869 } 2870 }
2870 else 2871 else
2871 { 2872 {
@@ -2970,24 +2971,16 @@ namespace OpenSim.Region.Framework.Scenes
2970 SubscribeToClientEvents(client); 2971 SubscribeToClientEvents(client);
2971 2972
2972 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); 2973 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
2974 InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46);
2975 if (cof == null)
2976 sp.COF = UUID.Zero;
2977 else
2978 sp.COF = cof.ID;
2979
2980 m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF);
2973 m_eventManager.TriggerOnNewPresence(sp); 2981 m_eventManager.TriggerOnNewPresence(sp);
2974 2982
2975 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; 2983 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
2976
2977 // The first agent upon login is a root agent by design.
2978 // For this agent we will have to rez the attachments.
2979 // All other AddNewClient calls find aCircuit.child to be true.
2980 if (aCircuit.child == false)
2981 {
2982 // We have to set SP to be a root agent here so that SP.MakeRootAgent() will later not try to
2983 // start the scripts again (since this is done in RezAttachments()).
2984 // XXX: This is convoluted.
2985 sp.IsChildAgent = false;
2986 sp.IsLoggingIn = true;
2987
2988 if (AttachmentsModule != null)
2989 Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); });
2990 }
2991 } 2984 }
2992 else 2985 else
2993 { 2986 {
@@ -3615,7 +3608,7 @@ namespace OpenSim.Region.Framework.Scenes
3615 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop 3608 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
3616 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI 3609 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
3617 if (closeChildAgents && CapsModule != null) 3610 if (closeChildAgents && CapsModule != null)
3618 CapsModule.RemoveCaps(agentID); 3611 CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode);
3619 3612
3620// // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever 3613// // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3621// // this method is doing is HORRIBLE!!! 3614// // this method is doing is HORRIBLE!!!
@@ -3846,20 +3839,36 @@ namespace OpenSim.Region.Framework.Scenes
3846 return false; 3839 return false;
3847 } 3840 }
3848 3841
3849
3850 ScenePresence sp = GetScenePresence(agent.AgentID); 3842 ScenePresence sp = GetScenePresence(agent.AgentID);
3851 3843
3852 if (sp != null && !sp.IsChildAgent) 3844 // If we have noo presence here or if that presence is a zombie root
3845 // presence that will be kicled, we need a new CAPS object.
3846 if (sp == null || (sp != null && !sp.IsChildAgent))
3853 { 3847 {
3854 // We have a zombie from a crashed session. 3848 if (CapsModule != null)
3855 // Or the same user is trying to be root twice here, won't work. 3849 {
3856 // Kill it. 3850 lock (agent)
3857 m_log.WarnFormat( 3851 {
3858 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", 3852 CapsModule.SetAgentCapsSeeds(agent);
3859 sp.Name, sp.UUID, RegionInfo.RegionName); 3853 CapsModule.CreateCaps(agent.AgentID, agent.circuitcode);
3854 }
3855 }
3856 }
3860 3857
3861 sp.ControllingClient.Close(true, true); 3858 if (sp != null)
3862 sp = null; 3859 {
3860 if (!sp.IsChildAgent)
3861 {
3862 // We have a zombie from a crashed session.
3863 // Or the same user is trying to be root twice here, won't work.
3864 // Kill it.
3865 m_log.WarnFormat(
3866 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3867 sp.Name, sp.UUID, RegionInfo.RegionName);
3868
3869 sp.ControllingClient.Close(true, true);
3870 sp = null;
3871 }
3863 } 3872 }
3864 3873
3865 lock (agent) 3874 lock (agent)
@@ -3900,7 +3909,9 @@ namespace OpenSim.Region.Framework.Scenes
3900 if (vialogin || (!m_seeIntoBannedRegion)) 3909 if (vialogin || (!m_seeIntoBannedRegion))
3901 { 3910 {
3902 if (!AuthorizeUser(agent, out reason)) 3911 if (!AuthorizeUser(agent, out reason))
3912 {
3903 return false; 3913 return false;
3914 }
3904 } 3915 }
3905 } 3916 }
3906 catch (Exception e) 3917 catch (Exception e)
@@ -3915,11 +3926,6 @@ namespace OpenSim.Region.Framework.Scenes
3915 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3926 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
3916 agent.AgentID, agent.circuitcode); 3927 agent.AgentID, agent.circuitcode);
3917 3928
3918 if (CapsModule != null)
3919 {
3920 CapsModule.SetAgentCapsSeeds(agent);
3921 CapsModule.CreateCaps(agent.AgentID);
3922 }
3923 } 3929 }
3924 else 3930 else
3925 { 3931 {
@@ -3945,6 +3951,11 @@ namespace OpenSim.Region.Framework.Scenes
3945 agent.teleportFlags = teleportFlags; 3951 agent.teleportFlags = teleportFlags;
3946 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3952 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3947 3953
3954 if (CapsModule != null)
3955 {
3956 CapsModule.ActivateCaps(agent.circuitcode);
3957 }
3958
3948 if (vialogin) 3959 if (vialogin)
3949 { 3960 {
3950// CleanDroppedAttachments(); 3961// CleanDroppedAttachments();
@@ -4306,33 +4317,33 @@ namespace OpenSim.Region.Framework.Scenes
4306// } 4317// }
4307// } 4318// }
4308 4319
4309 /// <summary> 4320// /// <summary>
4310 /// 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.
4311 /// </summary> 4322// /// </summary>
4312 /// <param name="agentID"></param> 4323// /// <param name="agentID"></param>
4313 /// <param name="position"></param> 4324// /// <param name="position"></param>
4314 /// <param name="isFlying"></param> 4325// /// <param name="isFlying"></param>
4315 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 4326// public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
4316 { 4327// {
4317 ScenePresence presence = GetScenePresence(agentID); 4328// ScenePresence presence = GetScenePresence(agentID);
4318 if (presence != null) 4329// if (presence != null)
4319 { 4330// {
4320 try 4331// try
4321 { 4332// {
4322 presence.MakeRootAgent(position, isFlying); 4333// presence.MakeRootAgent(position, isFlying);
4323 } 4334// }
4324 catch (Exception e) 4335// catch (Exception e)
4325 { 4336// {
4326 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);
4327 } 4338// }
4328 } 4339// }
4329 else 4340// else
4330 { 4341// {
4331 m_log.ErrorFormat( 4342// m_log.ErrorFormat(
4332 "[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}",
4333 agentID, RegionInfo.RegionName); 4344// agentID, RegionInfo.RegionName);
4334 } 4345// }
4335 } 4346// }
4336 4347
4337 /// <summary> 4348 /// <summary>
4338 /// 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,
@@ -4702,19 +4713,6 @@ namespace OpenSim.Region.Framework.Scenes
4702 4713
4703 #region Script Engine 4714 #region Script Engine
4704 4715
4705 private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>();
4706 public bool DumpAssetsToFile;
4707
4708 /// <summary>
4709 ///
4710 /// </summary>
4711 /// <param name="scriptEngine"></param>
4712 public void AddScriptEngine(ScriptEngineInterface scriptEngine)
4713 {
4714 ScriptEngines.Add(scriptEngine);
4715 scriptEngine.InitializeEngine(this);
4716 }
4717
4718 private bool ScriptDanger(SceneObjectPart part,Vector3 pos) 4716 private bool ScriptDanger(SceneObjectPart part,Vector3 pos)
4719 { 4717 {
4720 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); 4718 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
@@ -5122,7 +5120,7 @@ namespace OpenSim.Region.Framework.Scenes
5122 { 5120 {
5123 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) 5121 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
5124 { 5122 {
5125 if (grp.RootPart.Expires <= DateTime.Now) 5123 if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now)
5126 DeleteSceneObject(grp, false); 5124 DeleteSceneObject(grp, false);
5127 } 5125 }
5128 } 5126 }
@@ -5621,33 +5619,7 @@ Environment.Exit(1);
5621 5619
5622 public void TriggerEstateSunUpdate() 5620 public void TriggerEstateSunUpdate()
5623 { 5621 {
5624 float sun; 5622 EventManager.TriggerEstateToolsSunUpdate(RegionInfo.RegionHandle);
5625 if (RegionInfo.RegionSettings.UseEstateSun)
5626 {
5627 sun = (float)RegionInfo.EstateSettings.SunPosition;
5628 if (RegionInfo.EstateSettings.UseGlobalTime)
5629 {
5630 sun = EventManager.GetCurrentTimeAsSunLindenHour() - 6.0f;
5631 }
5632
5633 //
5634 EventManager.TriggerEstateToolsSunUpdate(
5635 RegionInfo.RegionHandle,
5636 RegionInfo.EstateSettings.FixedSun,
5637 RegionInfo.RegionSettings.UseEstateSun,
5638 sun);
5639 }
5640 else
5641 {
5642 // Use the Sun Position from the Region Settings
5643 sun = (float)RegionInfo.RegionSettings.SunPosition - 6.0f;
5644
5645 EventManager.TriggerEstateToolsSunUpdate(
5646 RegionInfo.RegionHandle,
5647 RegionInfo.RegionSettings.FixedSun,
5648 RegionInfo.RegionSettings.UseEstateSun,
5649 sun);
5650 }
5651 } 5623 }
5652 5624
5653 private void HandleReloadEstate(string module, string[] cmd) 5625 private void HandleReloadEstate(string module, string[] cmd)
@@ -5915,8 +5887,13 @@ Environment.Exit(1);
5915 5887
5916 if (banned) 5888 if (banned)
5917 { 5889 {
5918 reason = "No suitable landing point found"; 5890 if(Permissions.IsAdministrator(agentID) == false || Permissions.IsGridGod(agentID) == false)
5919 return false; 5891 {
5892 reason = "No suitable landing point found";
5893 return false;
5894 }
5895 reason = "Administrative access only";
5896 return true;
5920 } 5897 }
5921 } 5898 }
5922 } 5899 }
@@ -6043,10 +6020,17 @@ Environment.Exit(1);
6043 GC.Collect(); 6020 GC.Collect();
6044 } 6021 }
6045 6022
6046 // Wrappers to get physics modules retrieve assets. Has to be done this way 6023 /// <summary>
6047 // because we can't assign the asset service to physics directly - at the 6024 /// Wrappers to get physics modules retrieve assets.
6048 // time physics are instantiated it's not registered but it will be by 6025 /// </summary>
6049 // 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>
6050 public void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback) 6034 public void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback)
6051 { 6035 {
6052 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 8528edc..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.
@@ -1689,6 +1718,10 @@ namespace OpenSim.Region.Framework.Scenes
1689 1718
1690 if (ParentGroup != null) 1719 if (ParentGroup != null)
1691 ParentGroup.HasGroupChanged = true; 1720 ParentGroup.HasGroupChanged = true;
1721
1722 PhysicsActor pa = PhysActor;
1723 if (pa != null)
1724 pa.Density = Density;
1692 } 1725 }
1693 } 1726 }
1694 1727
@@ -1708,6 +1741,9 @@ namespace OpenSim.Region.Framework.Scenes
1708 if (ParentGroup != null) 1741 if (ParentGroup != null)
1709 ParentGroup.HasGroupChanged = true; 1742 ParentGroup.HasGroupChanged = true;
1710 1743
1744 PhysicsActor pa = PhysActor;
1745 if (pa != null)
1746 pa.GravModifier = GravityModifier;
1711 } 1747 }
1712 } 1748 }
1713 1749
@@ -1726,10 +1762,14 @@ namespace OpenSim.Region.Framework.Scenes
1726 1762
1727 if (ParentGroup != null) 1763 if (ParentGroup != null)
1728 ParentGroup.HasGroupChanged = true; 1764 ParentGroup.HasGroupChanged = true;
1765
1766 PhysicsActor pa = PhysActor;
1767 if (pa != null)
1768 pa.Friction = Friction;
1729 } 1769 }
1730 } 1770 }
1731 1771
1732 public float Bounciness 1772 public float Restitution
1733 { 1773 {
1734 get { return m_bounce; } 1774 get { return m_bounce; }
1735 set 1775 set
@@ -1744,6 +1784,10 @@ namespace OpenSim.Region.Framework.Scenes
1744 1784
1745 if (ParentGroup != null) 1785 if (ParentGroup != null)
1746 ParentGroup.HasGroupChanged = true; 1786 ParentGroup.HasGroupChanged = true;
1787
1788 PhysicsActor pa = PhysActor;
1789 if (pa != null)
1790 pa.Restitution = Restitution;
1747 } 1791 }
1748 } 1792 }
1749 1793
@@ -2118,6 +2162,8 @@ namespace OpenSim.Region.Framework.Scenes
2118 // safeguard actual copy is done in sog.copy 2162 // safeguard actual copy is done in sog.copy
2119 dupe.KeyframeMotion = null; 2163 dupe.KeyframeMotion = null;
2120 2164
2165 dupe.DynAttrs.CopyFrom(DynAttrs);
2166
2121 if (userExposed) 2167 if (userExposed)
2122 { 2168 {
2123/* 2169/*
@@ -2431,11 +2477,11 @@ namespace OpenSim.Region.Framework.Scenes
2431 public int GetAxisRotation(int axis) 2477 public int GetAxisRotation(int axis)
2432 { 2478 {
2433 //Cannot use ScriptBaseClass constants as no referance to it currently. 2479 //Cannot use ScriptBaseClass constants as no referance to it currently.
2434 if (axis == 2)//STATUS_ROTATE_X 2480 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_X)
2435 return STATUS_ROTATE_X; 2481 return STATUS_ROTATE_X;
2436 if (axis == 4)//STATUS_ROTATE_Y 2482 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y)
2437 return STATUS_ROTATE_Y; 2483 return STATUS_ROTATE_Y;
2438 if (axis == 8)//STATUS_ROTATE_Z 2484 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z)
2439 return STATUS_ROTATE_Z; 2485 return STATUS_ROTATE_Z;
2440 2486
2441 return 0; 2487 return 0;
@@ -2470,18 +2516,6 @@ namespace OpenSim.Region.Framework.Scenes
2470 return new Vector3(0, 0, 0); 2516 return new Vector3(0, 0, 0);
2471 2517
2472 return ParentGroup.GetGeometricCenter(); 2518 return ParentGroup.GetGeometricCenter();
2473
2474 /*
2475 PhysicsActor pa = PhysActor;
2476
2477 if (pa != null)
2478 {
2479 Vector3 vtmp = pa.CenterOfMass;
2480 return vtmp;
2481 }
2482 else
2483 return new Vector3(0, 0, 0);
2484 */
2485 } 2519 }
2486 2520
2487 public float GetMass() 2521 public float GetMass()
@@ -2895,11 +2929,14 @@ namespace OpenSim.Region.Framework.Scenes
2895 2929
2896 public void PhysicsOutOfBounds(Vector3 pos) 2930 public void PhysicsOutOfBounds(Vector3 pos)
2897 { 2931 {
2898 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);
2899 2937
2900 RemFlag(PrimFlags.Physics); 2938 RemFlag(PrimFlags.Physics);
2901 DoPhysicsPropertyUpdate(false, true); 2939 DoPhysicsPropertyUpdate(false, true);
2902 //ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
2903 } 2940 }
2904 2941
2905 public void PhysicsRequestingTerseUpdate() 2942 public void PhysicsRequestingTerseUpdate()
@@ -3322,13 +3359,13 @@ namespace OpenSim.Region.Framework.Scenes
3322 ParentGroup.SetAxisRotation(axis, rotate); 3359 ParentGroup.SetAxisRotation(axis, rotate);
3323 3360
3324 //Cannot use ScriptBaseClass constants as no referance to it currently. 3361 //Cannot use ScriptBaseClass constants as no referance to it currently.
3325 if (axis == 2)//STATUS_ROTATE_X 3362 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_X) != 0)
3326 STATUS_ROTATE_X = rotate; 3363 STATUS_ROTATE_X = rotate;
3327 3364
3328 if (axis == 4)//STATUS_ROTATE_Y 3365 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y) != 0)
3329 STATUS_ROTATE_Y = rotate; 3366 STATUS_ROTATE_Y = rotate;
3330 3367
3331 if (axis == 8)//STATUS_ROTATE_Z 3368 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) != 0)
3332 STATUS_ROTATE_Z = rotate; 3369 STATUS_ROTATE_Z = rotate;
3333 } 3370 }
3334 3371
@@ -3706,6 +3743,10 @@ namespace OpenSim.Region.Framework.Scenes
3706 /// <param name="events"></param> 3743 /// <param name="events"></param>
3707 public void SetScriptEvents(UUID scriptid, int events) 3744 public void SetScriptEvents(UUID scriptid, int events)
3708 { 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
3709 // scriptEvents oldparts; 3750 // scriptEvents oldparts;
3710 lock (m_scriptEvents) 3751 lock (m_scriptEvents)
3711 { 3752 {
@@ -4235,6 +4276,7 @@ namespace OpenSim.Region.Framework.Scenes
4235 result.distance = distance2; 4276 result.distance = distance2;
4236 result.HitTF = true; 4277 result.HitTF = true;
4237 result.ipoint = q; 4278 result.ipoint = q;
4279 result.face = i;
4238 //m_log.Info("[FACE]:" + i.ToString()); 4280 //m_log.Info("[FACE]:" + i.ToString());
4239 //m_log.Info("[POINT]: " + q.ToString()); 4281 //m_log.Info("[POINT]: " + q.ToString());
4240 //m_log.Info("[DIST]: " + distance2.ToString()); 4282 //m_log.Info("[DIST]: " + distance2.ToString());
@@ -4281,10 +4323,10 @@ namespace OpenSim.Region.Framework.Scenes
4281 4323
4282 public void TrimPermissions() 4324 public void TrimPermissions()
4283 { 4325 {
4284 BaseMask &= (uint)PermissionMask.All; 4326 BaseMask &= (uint)(PermissionMask.All | PermissionMask.Export);
4285 OwnerMask &= (uint)PermissionMask.All; 4327 OwnerMask &= (uint)(PermissionMask.All | PermissionMask.Export);
4286 GroupMask &= (uint)PermissionMask.All; 4328 GroupMask &= (uint)PermissionMask.All;
4287 EveryoneMask &= (uint)PermissionMask.All; 4329 EveryoneMask &= (uint)(PermissionMask.All | PermissionMask.Export);
4288 NextOwnerMask &= (uint)PermissionMask.All; 4330 NextOwnerMask &= (uint)PermissionMask.All;
4289 } 4331 }
4290 4332
@@ -4387,10 +4429,22 @@ namespace OpenSim.Region.Framework.Scenes
4387 baseMask; 4429 baseMask;
4388 break; 4430 break;
4389 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 }
4390 EveryoneMask = ApplyMask(EveryoneMask, set, mask) & 4438 EveryoneMask = ApplyMask(EveryoneMask, set, mask) &
4391 baseMask; 4439 baseMask;
4392 break; 4440 break;
4393 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 }
4394 NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & 4448 NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) &
4395 baseMask; 4449 baseMask;
4396 // Prevent the client from creating no copy, no transfer 4450 // Prevent the client from creating no copy, no transfer
@@ -4493,8 +4547,8 @@ namespace OpenSim.Region.Framework.Scenes
4493 GravityModifier = physdata.GravitationModifier; 4547 GravityModifier = physdata.GravitationModifier;
4494 if(Friction != physdata.Friction) 4548 if(Friction != physdata.Friction)
4495 Friction = physdata.Friction; 4549 Friction = physdata.Friction;
4496 if(Bounciness != physdata.Bounce) 4550 if(Restitution != physdata.Bounce)
4497 Bounciness = physdata.Bounce; 4551 Restitution = physdata.Bounce;
4498 } 4552 }
4499 /// <summary> 4553 /// <summary>
4500 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. 4554 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary.
@@ -4558,7 +4612,8 @@ namespace OpenSim.Region.Framework.Scenes
4558 if (ParentGroup.RootPart == this) 4612 if (ParentGroup.RootPart == this)
4559 AngularVelocity = new Vector3(0, 0, 0); 4613 AngularVelocity = new Vector3(0, 0, 0);
4560 } 4614 }
4561 else 4615
4616 else
4562 { 4617 {
4563 if (ParentGroup.Scene.CollidablePrims) 4618 if (ParentGroup.Scene.CollidablePrims)
4564 { 4619 {
@@ -4604,9 +4659,31 @@ namespace OpenSim.Region.Framework.Scenes
4604 UpdatePhysicsSubscribedEvents(); 4659 UpdatePhysicsSubscribedEvents();
4605 } 4660 }
4606 } 4661 }
4607 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 }
4608 // 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);
4609 4683
4684 RemFlag(PrimFlags.Phantom);
4685 VolumeDetectActive = false;
4686 }
4610 // 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
4611 4688
4612 if (ParentGroup != null) 4689 if (ParentGroup != null)
@@ -4646,9 +4723,9 @@ namespace OpenSim.Region.Framework.Scenes
4646 PhysicsShapeType, 4723 PhysicsShapeType,
4647 m_localId); 4724 m_localId);
4648 } 4725 }
4649 catch (Exception ex) 4726 catch (Exception e)
4650 { 4727 {
4651 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);
4652 pa = null; 4729 pa = null;
4653 } 4730 }
4654 4731
@@ -4657,6 +4734,11 @@ namespace OpenSim.Region.Framework.Scenes
4657 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info 4734 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
4658 pa.SetMaterial(Material); 4735 pa.SetMaterial(Material);
4659 4736
4737 pa.Density = Density;
4738 pa.GravModifier = GravityModifier;
4739 pa.Friction = Friction;
4740 pa.Restitution = Restitution;
4741
4660 if (VolumeDetectActive) // change if not the default only 4742 if (VolumeDetectActive) // change if not the default only
4661 pa.SetVolumeDetect(1); 4743 pa.SetVolumeDetect(1);
4662 4744
@@ -4717,7 +4799,9 @@ namespace OpenSim.Region.Framework.Scenes
4717 } 4799 }
4718 4800
4719 PhysActor = pa; 4801 PhysActor = pa;
4720 } 4802
4803 ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this);
4804 }
4721 4805
4722 /// <summary> 4806 /// <summary>
4723 /// This removes the part from the physics scene. 4807 /// This removes the part from the physics scene.
@@ -4736,6 +4820,8 @@ namespace OpenSim.Region.Framework.Scenes
4736 pa.OnOutOfBounds -= PhysicsOutOfBounds; 4820 pa.OnOutOfBounds -= PhysicsOutOfBounds;
4737 4821
4738 ParentGroup.Scene.PhysicsScene.RemovePrim(pa); 4822 ParentGroup.Scene.PhysicsScene.RemovePrim(pa);
4823
4824 ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this);
4739 } 4825 }
4740 PhysActor = null; 4826 PhysActor = null;
4741 } 4827 }
@@ -4911,8 +4997,25 @@ namespace OpenSim.Region.Framework.Scenes
4911 4997
4912 Changed changeFlags = 0; 4998 Changed changeFlags = 0;
4913 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
4914 for (int i = 0 ; i < GetNumberOfSides(); i++) 5016 for (int i = 0 ; i < GetNumberOfSides(); i++)
4915 { 5017 {
5018
4916 Primitive.TextureEntryFace newFace = newTex.DefaultTexture; 5019 Primitive.TextureEntryFace newFace = newTex.DefaultTexture;
4917 Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture; 5020 Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture;
4918 5021
@@ -5138,9 +5241,12 @@ namespace OpenSim.Region.Framework.Scenes
5138 5241
5139 public void ApplyNextOwnerPermissions() 5242 public void ApplyNextOwnerPermissions()
5140 { 5243 {
5141 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;
5142 OwnerMask &= NextOwnerMask; 5248 OwnerMask &= NextOwnerMask;
5143 EveryoneMask &= NextOwnerMask; 5249 EveryoneMask &= NextOwnerMask | (uint)PermissionMask.Export;
5144 5250
5145 Inventory.ApplyNextOwnerPermissions(); 5251 Inventory.ApplyNextOwnerPermissions();
5146 } 5252 }
@@ -5202,18 +5308,22 @@ namespace OpenSim.Region.Framework.Scenes
5202 /// <param name='avatarId'></param> 5308 /// <param name='avatarId'></param>
5203 protected internal bool AddSittingAvatar(UUID avatarId) 5309 protected internal bool AddSittingAvatar(UUID avatarId)
5204 { 5310 {
5205 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero) 5311 lock (ParentGroup.m_sittingAvatars)
5206 SitTargetAvatar = avatarId; 5312 {
5313 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
5314 SitTargetAvatar = avatarId;
5207 5315
5208 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5316 if (m_sittingAvatars == null)
5317 m_sittingAvatars = new HashSet<UUID>();
5209 5318
5210 if (sittingAvatars == null) 5319 if (m_sittingAvatars.Add(avatarId))
5211 sittingAvatars = new HashSet<UUID>(); 5320 {
5321 ParentGroup.m_sittingAvatars.Add(avatarId);
5212 5322
5213 lock (sittingAvatars) 5323 return true;
5214 { 5324 }
5215 m_sittingAvatars = sittingAvatars; 5325
5216 return m_sittingAvatars.Add(avatarId); 5326 return false;
5217 } 5327 }
5218 } 5328 }
5219 5329
@@ -5227,27 +5337,26 @@ namespace OpenSim.Region.Framework.Scenes
5227 /// <param name='avatarId'></param> 5337 /// <param name='avatarId'></param>
5228 protected internal bool RemoveSittingAvatar(UUID avatarId) 5338 protected internal bool RemoveSittingAvatar(UUID avatarId)
5229 { 5339 {
5230 if (SitTargetAvatar == avatarId) 5340 lock (ParentGroup.m_sittingAvatars)
5231 SitTargetAvatar = UUID.Zero; 5341 {
5232 5342 if (SitTargetAvatar == avatarId)
5233 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5343 SitTargetAvatar = UUID.Zero;
5234 5344
5235 // This can occur under a race condition where another thread 5345 if (m_sittingAvatars == null)
5236 if (sittingAvatars == null) 5346 return false;
5237 return false;
5238 5347
5239 lock (sittingAvatars) 5348 if (m_sittingAvatars.Remove(avatarId))
5240 {
5241 if (sittingAvatars.Remove(avatarId))
5242 { 5349 {
5243 if (sittingAvatars.Count == 0) 5350 if (m_sittingAvatars.Count == 0)
5244 m_sittingAvatars = null; 5351 m_sittingAvatars = null;
5245 5352
5353 ParentGroup.m_sittingAvatars.Remove(avatarId);
5354
5246 return true; 5355 return true;
5247 } 5356 }
5248 }
5249 5357
5250 return false; 5358 return false;
5359 }
5251 } 5360 }
5252 5361
5253 /// <summary> 5362 /// <summary>
@@ -5257,16 +5366,12 @@ namespace OpenSim.Region.Framework.Scenes
5257 /// <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>
5258 public HashSet<UUID> GetSittingAvatars() 5367 public HashSet<UUID> GetSittingAvatars()
5259 { 5368 {
5260 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5369 lock (ParentGroup.m_sittingAvatars)
5261
5262 if (sittingAvatars == null)
5263 {
5264 return null;
5265 }
5266 else
5267 { 5370 {
5268 lock (sittingAvatars) 5371 if (m_sittingAvatars == null)
5269 return new HashSet<UUID>(sittingAvatars); 5372 return null;
5373 else
5374 return new HashSet<UUID>(m_sittingAvatars);
5270 } 5375 }
5271 } 5376 }
5272 5377
@@ -5277,13 +5382,13 @@ namespace OpenSim.Region.Framework.Scenes
5277 /// <returns></returns> 5382 /// <returns></returns>
5278 public int GetSittingAvatarsCount() 5383 public int GetSittingAvatarsCount()
5279 { 5384 {
5280 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5385 lock (ParentGroup.m_sittingAvatars)
5281 5386 {
5282 if (sittingAvatars == null) 5387 if (m_sittingAvatars == null)
5283 return 0; 5388 return 0;
5284 5389 else
5285 lock (sittingAvatars) 5390 return m_sittingAvatars.Count;
5286 return sittingAvatars.Count; 5391 }
5287 } 5392 }
5288 } 5393 }
5289} 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 a9195f7..0ab267a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -204,6 +204,11 @@ namespace OpenSim.Region.Framework.Scenes
204 204
205 private const int LAND_VELOCITYMAG_MAX = 12; 205 private const int LAND_VELOCITYMAG_MAX = 12;
206 206
207 private const float FLY_ROLL_MAX_RADIANS = 1.1f;
208
209 private const float FLY_ROLL_RADIANS_PER_UPDATE = 0.06f;
210 private const float FLY_ROLL_RESET_RADIANS_PER_UPDATE = 0.02f;
211
207 private float m_health = 100f; 212 private float m_health = 100f;
208 213
209 protected ulong crossingFromRegion; 214 protected ulong crossingFromRegion;
@@ -216,8 +221,6 @@ namespace OpenSim.Region.Framework.Scenes
216 221
217 private Quaternion m_headrotation = Quaternion.Identity; 222 private Quaternion m_headrotation = Quaternion.Identity;
218 223
219 private string m_nextSitAnimation = String.Empty;
220
221 //PauPaw:Proper PID Controler for autopilot************ 224 //PauPaw:Proper PID Controler for autopilot************
222 public bool MovingToTarget { get; private set; } 225 public bool MovingToTarget { get; private set; }
223 public Vector3 MoveToPositionTarget { get; private set; } 226 public Vector3 MoveToPositionTarget { get; private set; }
@@ -438,6 +441,8 @@ namespace OpenSim.Region.Framework.Scenes
438 get { return (IClientCore)ControllingClient; } 441 get { return (IClientCore)ControllingClient; }
439 } 442 }
440 443
444 public UUID COF { get; set; }
445
441// public Vector3 ParentPosition { get; set; } 446// public Vector3 ParentPosition { get; set; }
442 447
443 /// <summary> 448 /// <summary>
@@ -451,9 +456,9 @@ namespace OpenSim.Region.Framework.Scenes
451 { 456 {
452 m_pos = PhysicsActor.Position; 457 m_pos = PhysicsActor.Position;
453 458
454 //m_log.DebugFormat( 459// m_log.DebugFormat(
455 // "[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!",
456 // m_pos, Name, Scene.RegionInfo.RegionName); 461// Name, Scene.Name, m_pos);
457 } 462 }
458 else 463 else
459 { 464 {
@@ -480,6 +485,9 @@ namespace OpenSim.Region.Framework.Scenes
480 } 485 }
481 set 486 set
482 { 487 {
488// m_log.DebugFormat("[SCENE PRESENCE]: Setting position of {0} in {1} to {2}", Name, Scene.Name, value);
489// Util.PrintCallStack();
490
483 if (PhysicsActor != null) 491 if (PhysicsActor != null)
484 { 492 {
485 try 493 try
@@ -585,27 +593,48 @@ namespace OpenSim.Region.Framework.Scenes
585*/ 593*/
586 private Quaternion m_bodyRot = Quaternion.Identity; 594 private Quaternion m_bodyRot = Quaternion.Identity;
587 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>
588 public Quaternion Rotation 604 public Quaternion Rotation
589 { 605 {
590 get { return m_bodyRot; } 606 get
607 {
608 return m_bodyRot;
609 }
610
591 set 611 set
592 { 612 {
593 m_bodyRot = value; 613 m_bodyRot = value;
594 // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); 614
595 if (PhysicsActor != null) 615 if (PhysicsActor != null)
596 { 616 {
597 try 617 try
598 { 618 {
599 PhysicsActor.Orientation = value; 619 PhysicsActor.Orientation = m_bodyRot;
600 } 620 }
601 catch (Exception e) 621 catch (Exception e)
602 { 622 {
603 m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); 623 m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message);
604 } 624 }
605 } 625 }
626// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot);
606 } 627 }
607 } 628 }
608 629
630 // Used for limited viewer 'fake' user rotations.
631 private Vector3 m_AngularVelocity = Vector3.Zero;
632
633 public Vector3 AngularVelocity
634 {
635 get { return m_AngularVelocity; }
636 }
637
609 public bool IsChildAgent { get; set; } 638 public bool IsChildAgent { get; set; }
610 public bool IsLoggingIn { get; set; } 639 public bool IsLoggingIn { get; set; }
611 640
@@ -641,6 +670,26 @@ namespace OpenSim.Region.Framework.Scenes
641 set { m_health = value; } 670 set { m_health = value; }
642 } 671 }
643 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
644 public void AdjustKnownSeeds() 693 public void AdjustKnownSeeds()
645 { 694 {
646 Dictionary<ulong, string> seeds; 695 Dictionary<ulong, string> seeds;
@@ -690,6 +739,12 @@ namespace OpenSim.Region.Framework.Scenes
690 739
691 private bool m_inTransit; 740 private bool m_inTransit;
692 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>
693 public bool IsInTransit 748 public bool IsInTransit
694 { 749 {
695 get { return m_inTransit; } 750 get { return m_inTransit; }
@@ -886,8 +941,6 @@ namespace OpenSim.Region.Framework.Scenes
886 "[SCENE]: Upgrading child to root agent for {0} in {1}", 941 "[SCENE]: Upgrading child to root agent for {0} in {1}",
887 Name, m_scene.RegionInfo.RegionName); 942 Name, m_scene.RegionInfo.RegionName);
888 943
889 bool wasChild = IsChildAgent;
890
891 if (ParentUUID != UUID.Zero) 944 if (ParentUUID != UUID.Zero)
892 { 945 {
893 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);
@@ -920,6 +973,9 @@ namespace OpenSim.Region.Framework.Scenes
920 IsLoggingIn = false; 973 IsLoggingIn = false;
921 } 974 }
922 975
976 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
977
978 IsChildAgent = false;
923 979
924 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 980 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
925 if (gm != null) 981 if (gm != null)
@@ -1013,6 +1069,13 @@ namespace OpenSim.Region.Framework.Scenes
1013 else 1069 else
1014 AddToPhysicalScene(isFlying); 1070 AddToPhysicalScene(isFlying);
1015 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
1016 if (ForceFly) 1079 if (ForceFly)
1017 { 1080 {
1018 Flying = true; 1081 Flying = true;
@@ -1033,22 +1096,43 @@ namespace OpenSim.Region.Framework.Scenes
1033 // and it has already rezzed the attachments and started their scripts. 1096 // and it has already rezzed the attachments and started their scripts.
1034 // 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
1035 // haven't started yet. 1098 // haven't started yet.
1036 lock (m_attachments) 1099 if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
1037 { 1100 {
1038 if (wasChild && HasAttachments()) 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
1114 {
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)
1039 { 1120 {
1040 m_log.DebugFormat( 1121 if (HasAttachments())
1041 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); 1122 {
1042 1123 m_log.DebugFormat(
1043 // Resume scripts 1124 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
1044 Util.FireAndForget(delegate(object x) { 1125
1045 foreach (SceneObjectGroup sog in m_attachments) 1126 // Resume scripts
1046 { 1127 Util.FireAndForget(delegate(object x) {
1047 sog.ScheduleGroupForFullUpdate(); 1128 foreach (SceneObjectGroup sog in m_attachments)
1048 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 1129 {
1049 sog.ResumeScripts(); 1130 sog.ScheduleGroupForFullUpdate();
1050 } 1131 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
1051 }); 1132 sog.ResumeScripts();
1133 }
1134 });
1135 }
1052 } 1136 }
1053 } 1137 }
1054 1138
@@ -1225,6 +1309,85 @@ namespace OpenSim.Region.Framework.Scenes
1225 ControllingClient.StopFlying(this); 1309 ControllingClient.StopFlying(this);
1226 } 1310 }
1227 1311
1312 /// <summary>
1313 /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect.
1314 /// </summary>
1315 /// <param name="amount">Postive or negative roll amount in radians</param>
1316 private void ApplyFlyingRoll(float amount, bool PressingUp, bool PressingDown)
1317 {
1318
1319 float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS);
1320 m_AngularVelocity.Z = rollAmount;
1321
1322 // APPLY EXTRA consideration for flying up and flying down during this time.
1323 // if we're turning left
1324 if (amount > 0)
1325 {
1326
1327 // If we're at the max roll and pressing up, we want to swing BACK a bit
1328 // Automatically adds noise
1329 if (PressingUp)
1330 {
1331 if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS - 0.04f)
1332 m_AngularVelocity.Z -= 0.9f;
1333 }
1334 // If we're at the max roll and pressing down, we want to swing MORE a bit
1335 if (PressingDown)
1336 {
1337 if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS && m_AngularVelocity.Z < FLY_ROLL_MAX_RADIANS + 0.6f)
1338 m_AngularVelocity.Z += 0.6f;
1339 }
1340 }
1341 else // we're turning right.
1342 {
1343 // If we're at the max roll and pressing up, we want to swing BACK a bit
1344 // Automatically adds noise
1345 if (PressingUp)
1346 {
1347 if (m_AngularVelocity.Z <= (-FLY_ROLL_MAX_RADIANS))
1348 m_AngularVelocity.Z += 0.6f;
1349 }
1350 // If we're at the max roll and pressing down, we want to swing MORE a bit
1351 if (PressingDown)
1352 {
1353 if (m_AngularVelocity.Z >= -FLY_ROLL_MAX_RADIANS - 0.6f)
1354 m_AngularVelocity.Z -= 0.6f;
1355 }
1356 }
1357 }
1358
1359 /// <summary>
1360 /// incrementally sets roll amount to zero
1361 /// </summary>
1362 /// <param name="amount">Positive roll amount in radians</param>
1363 /// <returns></returns>
1364 private float CalculateFlyingRollResetToZero(float amount)
1365 {
1366 const float rollMinRadians = 0f;
1367
1368 if (m_AngularVelocity.Z > 0)
1369 {
1370
1371 float leftOverToMin = m_AngularVelocity.Z - rollMinRadians;
1372 if (amount > leftOverToMin)
1373 return -leftOverToMin;
1374 else
1375 return -amount;
1376
1377 }
1378 else
1379 {
1380
1381 float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians;
1382 if (amount > leftOverToMin)
1383 return leftOverToMin;
1384 else
1385 return amount;
1386 }
1387 }
1388
1389
1390
1228 // neighbouring regions we have enabled a child agent in 1391 // neighbouring regions we have enabled a child agent in
1229 // holds the seed cap for the child agent in that region 1392 // holds the seed cap for the child agent in that region
1230 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); 1393 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>();
@@ -1398,6 +1561,15 @@ namespace OpenSim.Region.Framework.Scenes
1398 1561
1399 } 1562 }
1400 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
1401// m_log.DebugFormat( 1573// m_log.DebugFormat(
1402// "[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",
1403// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); 1575// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
@@ -1430,17 +1602,42 @@ namespace OpenSim.Region.Framework.Scenes
1430 m_doingCamRayCast = false; 1602 m_doingCamRayCast = false;
1431 if (hitYN && localid != LocalId) 1603 if (hitYN && localid != LocalId)
1432 { 1604 {
1433 CameraConstraintActive = true; 1605 SceneObjectGroup group = m_scene.GetGroupByPrim(localid);
1434 pNormal.X = (float)Math.Round(pNormal.X, 2); 1606 bool IsPrim = group != null;
1435 pNormal.Y = (float)Math.Round(pNormal.Y, 2); 1607 if (IsPrim)
1436 pNormal.Z = (float)Math.Round(pNormal.Z, 2); 1608 {
1437 pNormal.Normalize(); 1609 SceneObjectPart part = group.GetPart(localid);
1438 collisionPoint.X = (float)Math.Round(collisionPoint.X, 1); 1610 if (part != null && !part.VolumeDetectActive)
1439 collisionPoint.Y = (float)Math.Round(collisionPoint.Y, 1); 1611 {
1440 collisionPoint.Z = (float)Math.Round(collisionPoint.Z, 1); 1612 CameraConstraintActive = true;
1441 1613 pNormal.X = (float) Math.Round(pNormal.X, 2);
1442 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, Vector3.Dot(collisionPoint, pNormal)); 1614 pNormal.Y = (float) Math.Round(pNormal.Y, 2);
1443 UpdateCameraCollisionPlane(plane); 1615 pNormal.Z = (float) Math.Round(pNormal.Z, 2);
1616 pNormal.Normalize();
1617 collisionPoint.X = (float) Math.Round(collisionPoint.X, 1);
1618 collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1);
1619 collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1);
1620
1621 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z,
1622 Vector3.Dot(collisionPoint, pNormal));
1623 UpdateCameraCollisionPlane(plane);
1624 }
1625 }
1626 else
1627 {
1628 CameraConstraintActive = true;
1629 pNormal.X = (float) Math.Round(pNormal.X, 2);
1630 pNormal.Y = (float) Math.Round(pNormal.Y, 2);
1631 pNormal.Z = (float) Math.Round(pNormal.Z, 2);
1632 pNormal.Normalize();
1633 collisionPoint.X = (float) Math.Round(collisionPoint.X, 1);
1634 collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1);
1635 collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1);
1636
1637 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z,
1638 Vector3.Dot(collisionPoint, pNormal));
1639 UpdateCameraCollisionPlane(plane);
1640 }
1444 } 1641 }
1445 else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || 1642 else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
1446 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) 1643 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE))
@@ -1741,6 +1938,29 @@ namespace OpenSim.Region.Framework.Scenes
1741 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || 1938 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
1742 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1939 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
1743 1940
1941 //m_log.Debug("[CONTROL]: " +flags);
1942 // Applies a satisfying roll effect to the avatar when flying.
1943 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
1944 {
1945 ApplyFlyingRoll(
1946 FLY_ROLL_RADIANS_PER_UPDATE,
1947 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
1948 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
1949 }
1950 else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 &&
1951 (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
1952 {
1953 ApplyFlyingRoll(
1954 -FLY_ROLL_RADIANS_PER_UPDATE,
1955 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
1956 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
1957 }
1958 else
1959 {
1960 if (m_AngularVelocity.Z != 0)
1961 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE);
1962 }
1963
1744 if (Flying && IsColliding && controlland) 1964 if (Flying && IsColliding && controlland)
1745 { 1965 {
1746 // nesting this check because LengthSquared() is expensive and we don't 1966 // nesting this check because LengthSquared() is expensive and we don't
@@ -1954,7 +2174,11 @@ namespace OpenSim.Region.Framework.Scenes
1954 // Get terrain height for sub-region in a megaregion if necessary 2174 // Get terrain height for sub-region in a megaregion if necessary
1955 int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); 2175 int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X);
1956 int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); 2176 int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y);
1957 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;
1958 Scene targetScene = m_scene; 2182 Scene targetScene = m_scene;
1959 2183
1960 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) 2184 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene))
@@ -2199,28 +2423,16 @@ namespace OpenSim.Region.Framework.Scenes
2199 2423
2200 if (ParentID != 0) 2424 if (ParentID != 0)
2201 { 2425 {
2426 if (ParentPart.UUID == targetID)
2427 return; // already sitting here, ignore
2428
2202 StandUp(); 2429 StandUp();
2203 } 2430 }
2204 2431
2205// if (!String.IsNullOrEmpty(sitAnimation))
2206// {
2207// m_nextSitAnimation = sitAnimation;
2208// }
2209// else
2210// {
2211 m_nextSitAnimation = "SIT";
2212// }
2213
2214 //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
2215 SceneObjectPart part = FindNextAvailableSitTarget(targetID); 2432 SceneObjectPart part = FindNextAvailableSitTarget(targetID);
2216 2433
2217 if (part != null) 2434 if (part != null)
2218 { 2435 {
2219 if (!String.IsNullOrEmpty(part.SitAnimation))
2220 {
2221 m_nextSitAnimation = part.SitAnimation;
2222 }
2223
2224 m_requestedSitTargetID = part.LocalId; 2436 m_requestedSitTargetID = part.LocalId;
2225 m_requestedSitTargetUUID = targetID; 2437 m_requestedSitTargetUUID = targetID;
2226 2438
@@ -2341,18 +2553,6 @@ namespace OpenSim.Region.Framework.Scenes
2341 2553
2342 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) 2554 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
2343 { 2555 {
2344 if (!String.IsNullOrEmpty(m_nextSitAnimation))
2345 {
2346 HandleAgentSit(remoteClient, agentID, m_nextSitAnimation);
2347 }
2348 else
2349 {
2350 HandleAgentSit(remoteClient, agentID, "SIT");
2351 }
2352 }
2353
2354 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation)
2355 {
2356 SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); 2556 SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
2357 2557
2358 if (part != null) 2558 if (part != null)
@@ -2422,10 +2622,15 @@ namespace OpenSim.Region.Framework.Scenes
2422 2622
2423 ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID); 2623 ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
2424 ParentID = m_requestedSitTargetID; 2624 ParentID = m_requestedSitTargetID;
2425 2625 m_AngularVelocity = Vector3.Zero;
2426 Velocity = Vector3.Zero; 2626 Velocity = Vector3.Zero;
2427 RemoveFromPhysicalScene(); 2627 RemoveFromPhysicalScene();
2428 2628
2629 String sitAnimation = "SIT";
2630 if (!String.IsNullOrEmpty(part.SitAnimation))
2631 {
2632 sitAnimation = part.SitAnimation;
2633 }
2429 Animator.TrySetMovementAnimation(sitAnimation); 2634 Animator.TrySetMovementAnimation(sitAnimation);
2430 SendAvatarDataToAllAgents(); 2635 SendAvatarDataToAllAgents();
2431 } 2636 }
@@ -2433,7 +2638,8 @@ namespace OpenSim.Region.Framework.Scenes
2433 2638
2434 public void HandleAgentSitOnGround() 2639 public void HandleAgentSitOnGround()
2435 { 2640 {
2436// 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;
2437 Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); 2643 Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
2438 SitGround = true; 2644 SitGround = true;
2439 RemoveFromPhysicalScene(); 2645 RemoveFromPhysicalScene();
@@ -2455,7 +2661,7 @@ namespace OpenSim.Region.Framework.Scenes
2455 2661
2456 public void HandleStopAnim(IClientAPI remoteClient, UUID animID) 2662 public void HandleStopAnim(IClientAPI remoteClient, UUID animID)
2457 { 2663 {
2458 Animator.RemoveAnimation(animID); 2664 Animator.RemoveAnimation(animID, false);
2459 } 2665 }
2460 2666
2461 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) 2667 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack)
@@ -2471,7 +2677,8 @@ namespace OpenSim.Region.Framework.Scenes
2471 /// <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>
2472 public void AddNewMovement(Vector3 vec) 2678 public void AddNewMovement(Vector3 vec)
2473 { 2679 {
2474// 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);
2475 2682
2476 Vector3 direc = vec * Rotation; 2683 Vector3 direc = vec * Rotation;
2477 direc.Normalize(); 2684 direc.Normalize();
@@ -2491,6 +2698,8 @@ namespace OpenSim.Region.Framework.Scenes
2491 2698
2492 direc *= 0.03f * 128f * SpeedModifier; 2699 direc *= 0.03f * 128f * SpeedModifier;
2493 2700
2701// m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name);
2702
2494 if (PhysicsActor != null) 2703 if (PhysicsActor != null)
2495 { 2704 {
2496 if (Flying) 2705 if (Flying)
@@ -2524,6 +2733,8 @@ namespace OpenSim.Region.Framework.Scenes
2524 } 2733 }
2525 } 2734 }
2526 2735
2736// m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name);
2737
2527 // 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?
2528 m_forceToApply = direc; 2739 m_forceToApply = direc;
2529 Animator.UpdateMovementAnimations(); 2740 Animator.UpdateMovementAnimations();
@@ -2942,6 +3153,10 @@ namespace OpenSim.Region.Framework.Scenes
2942 3153
2943 if (!IsInTransit) 3154 if (!IsInTransit)
2944 { 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
2945 // Checks if where it's headed exists a region 3160 // Checks if where it's headed exists a region
2946 bool needsTransit = false; 3161 bool needsTransit = false;
2947 if (m_scene.TestBorderCross(pos2, Cardinals.W)) 3162 if (m_scene.TestBorderCross(pos2, Cardinals.W))
@@ -4166,6 +4381,7 @@ namespace OpenSim.Region.Framework.Scenes
4166 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4381 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4167 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0) 4382 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
4168 { 4383 {
4384
4169 if (GodLevel < 200 && 4385 if (GodLevel < 200 &&
4170 ((!m_scene.Permissions.IsGod(m_uuid) && 4386 ((!m_scene.Permissions.IsGod(m_uuid) &&
4171 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || 4387 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
@@ -4174,7 +4390,14 @@ namespace OpenSim.Region.Framework.Scenes
4174 { 4390 {
4175 SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray(); 4391 SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray();
4176 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 }
4177 return; 4399 return;
4400 }
4178 4401
4179 int index; 4402 int index;
4180 bool selected = false; 4403 bool selected = false;
@@ -4183,6 +4406,8 @@ namespace OpenSim.Region.Framework.Scenes
4183 { 4406 {
4184 case "random": 4407 case "random":
4185 4408
4409 if (spawnPoints.Length == 0)
4410 return;
4186 do 4411 do
4187 { 4412 {
4188 index = Util.RandomClass.Next(spawnPoints.Length - 1); 4413 index = Util.RandomClass.Next(spawnPoints.Length - 1);
@@ -4194,6 +4419,7 @@ namespace OpenSim.Region.Framework.Scenes
4194 // SpawnPoint sp = spawnPoints[index]; 4419 // SpawnPoint sp = spawnPoints[index];
4195 4420
4196 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y); 4421 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4422
4197 if (land == null || land.IsEitherBannedOrRestricted(UUID)) 4423 if (land == null || land.IsEitherBannedOrRestricted(UUID))
4198 selected = false; 4424 selected = false;
4199 else 4425 else
diff --git a/OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs b/OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs
deleted file mode 100644
index f3be028..0000000
--- a/OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs
+++ /dev/null
@@ -1,46 +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
28using OpenMetaverse;
29
30namespace OpenSim.Region.Framework.Scenes.Scripting
31{
32 public interface IScriptHost
33 {
34 string Name { get; set; }
35 string Description { get; set; }
36
37 UUID UUID { get; }
38 UUID OwnerID { get; }
39 UUID CreatorID { get; }
40 Vector3 AbsolutePosition { get; }
41
42 string SitName { get; set; }
43 string TouchName { get; set; }
44 void SetText(string text, Vector3 color, double alpha);
45 }
46}
diff --git a/OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs b/OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs
deleted file mode 100644
index d7198f0..0000000
--- a/OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs
+++ /dev/null
@@ -1,91 +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
28using System;
29using OpenMetaverse;
30using log4net;
31using System.Reflection;
32using OpenSim.Framework;
33
34namespace OpenSim.Region.Framework.Scenes.Scripting
35{
36 public class NullScriptHost : IScriptHost
37 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39
40 private Vector3 m_pos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 30);
41
42 public string Name
43 {
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
76 public UUID CreatorID
77 {
78 get { return UUID.Zero; }
79 }
80
81 public Vector3 AbsolutePosition
82 {
83 get { return m_pos; }
84 }
85
86 public void SetText(string text, Vector3 color, double alpha)
87 {
88 m_log.Warn("Tried to SetText "+text+" on NullScriptHost");
89 }
90 }
91}
diff --git a/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineInterface.cs b/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineInterface.cs
deleted file mode 100644
index 812a21c..0000000
--- a/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineInterface.cs
+++ /dev/null
@@ -1,38 +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//TODO: WHERE TO PLACE THIS?
29
30namespace OpenSim.Region.Framework.Scenes.Scripting
31{
32 public interface ScriptEngineInterface
33 {
34 void InitializeEngine(Scene Sceneworld);
35 void Shutdown();
36// void StartScript(string ScriptID, IScriptHost ObjectID);
37 }
38}
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 123c158..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);
@@ -633,7 +634,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
633 634
634 private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader) 635 private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader)
635 { 636 {
636 obj.Bounciness = reader.ReadElementContentAsFloat("Bounce", String.Empty); 637 obj.Restitution = reader.ReadElementContentAsFloat("Bounce", String.Empty);
637 } 638 }
638 639
639 private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader) 640 private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader)
@@ -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());
@@ -1363,8 +1377,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1363 writer.WriteElementString("Density", sop.Density.ToString().ToLower()); 1377 writer.WriteElementString("Density", sop.Density.ToString().ToLower());
1364 if (sop.Friction != 0.6f) 1378 if (sop.Friction != 0.6f)
1365 writer.WriteElementString("Friction", sop.Friction.ToString().ToLower()); 1379 writer.WriteElementString("Friction", sop.Friction.ToString().ToLower());
1366 if (sop.Bounciness != 0.5f) 1380 if (sop.Restitution != 0.5f)
1367 writer.WriteElementString("Bounce", sop.Bounciness.ToString().ToLower()); 1381 writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower());
1368 if (sop.GravityModifier != 1.0f) 1382 if (sop.GravityModifier != 1.0f)
1369 writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); 1383 writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower());
1370 WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); 1384 WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset());
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 }