aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorDan Lake2012-02-01 16:25:35 -0800
committerDan Lake2012-02-01 16:25:35 -0800
commitc10193c72b1f029a958f04d2f5d7ee384e693aaa (patch)
tree052ec7e973c15b158310511197affad14eb9c64f /OpenSim/Region/Framework
parentTrigger event when prims are scheduled for an update. This gives modules earl... (diff)
parentSmall optimization to last commit (diff)
downloadopensim-SC_OLD-c10193c72b1f029a958f04d2f5d7ee384e693aaa.zip
opensim-SC_OLD-c10193c72b1f029a958f04d2f5d7ee384e693aaa.tar.gz
opensim-SC_OLD-c10193c72b1f029a958f04d2f5d7ee384e693aaa.tar.bz2
opensim-SC_OLD-c10193c72b1f029a958f04d2f5d7ee384e693aaa.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs25
-rw-r--r--OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs19
-rw-r--r--OpenSim/Region/Framework/Interfaces/INPCModule.cs49
-rw-r--r--OpenSim/Region/Framework/Interfaces/IProfileModule.cs37
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs38
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs13
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISearchModule.cs36
-rw-r--r--OpenSim/Region/Framework/Interfaces/IUserManagement.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs36
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs281
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs163
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs45
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs18
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs103
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs155
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs30
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs76
19 files changed, 792 insertions, 354 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index e668dae..eb07165 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Region.Framework.Interfaces
46 /// Save the attachments that have change on this presence. 46 /// Save the attachments that have change on this presence.
47 /// </summary> 47 /// </summary>
48 /// <param name="sp"></param> 48 /// <param name="sp"></param>
49 void SaveChangedAttachments(IScenePresence sp); 49 void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted);
50 50
51 /// <summary> 51 /// <summary>
52 /// Delete all the presence's attachments from the scene 52 /// Delete all the presence's attachments from the scene
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
index 8670229..39a760c 100644
--- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
@@ -61,7 +61,32 @@ namespace OpenSim.Region.Framework.Interfaces
61 /// <returns>true if a valid agent was found, false otherwise</returns> 61 /// <returns>true if a valid agent was found, false otherwise</returns>
62 bool SaveBakedTextures(UUID agentId); 62 bool SaveBakedTextures(UUID agentId);
63 63
64 /// <summary>
65 /// Validate that OpenSim can find the baked textures need to display a given avatar
66 /// </summary>
67 /// <param name="client"></param>
68 /// <param name="checkonly"></param>
69 /// <returns>
70 /// true if all the baked textures referenced by the texture IDs exist or the appearance is only using default textures. false otherwise.
71 /// </returns>
64 bool ValidateBakedTextureCache(IScenePresence sp); 72 bool ValidateBakedTextureCache(IScenePresence sp);
73
74 /// <summary>
75 /// Request a rebake of textures for an avatar.
76 /// </summary>
77 /// <remarks>
78 /// This will send the request to the viewer, since it's there that the rebake is done.
79 /// </remarks>
80 /// <param name="sp">Avatar to rebake.</param>
81 /// <param name="missingTexturesOnly">
82 /// If true, only request a rebake for the textures that are missing.
83 /// If false then we request a rebake of all textures for which we already have references.
84 /// </param>
85 /// <returns>
86 /// Number of rebake requests made. This will depend upon whether we've previously received texture IDs.
87 /// </returns>
88 int RequestRebake(IScenePresence sp, bool missingTexturesOnly);
89
65 void QueueAppearanceSend(UUID agentid); 90 void QueueAppearanceSend(UUID agentid);
66 void QueueAppearanceSave(UUID agentid); 91 void QueueAppearanceSave(UUID agentid);
67 92
diff --git a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs
index 856eb11..46d03b3 100644
--- a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs
+++ b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs
@@ -35,6 +35,23 @@ namespace OpenSim.Region.Framework.Interfaces
35 public interface IJ2KDecoder 35 public interface IJ2KDecoder
36 { 36 {
37 void BeginDecode(UUID assetID, byte[] j2kData, DecodedCallback callback); 37 void BeginDecode(UUID assetID, byte[] j2kData, DecodedCallback callback);
38 void Decode(UUID assetID, byte[] j2kData); 38
39 /// <summary>
40 /// Provides a synchronous decode so that caller can be assured that this executes before the next line
41 /// </summary>
42 /// <param name="assetID"></param>
43 /// <param name="j2kData"></param>
44 /// <returns>true if decode was successful. false otherwise.</returns>
45 bool Decode(UUID assetID, byte[] j2kData);
46
47 /// <summary>
48 /// Provides a synchronous decode so that caller can be assured that this executes before the next line
49 /// </summary>
50 /// <param name="assetID"></param>
51 /// <param name="j2kData"></param>
52 /// <param name="layers">layer data</param>
53 /// <param name="components">number of components</param>
54 /// <returns>true if decode was successful. false otherwise.</returns>
55 bool Decode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components);
39 } 56 }
40} 57}
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
index b65f82c..2731291 100644
--- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
@@ -31,6 +31,19 @@ using OpenSim.Region.Framework.Scenes;
31 31
32namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Region.Framework.Interfaces
33{ 33{
34 /// <summary>
35 /// Temporary interface. More methods to come at some point to make NPCs more object oriented rather than
36 /// controlling purely through module level interface calls (e.g. sit/stand).
37 /// </summary>
38 public interface INPC
39 {
40 /// <summary>
41 /// Should this NPC be sensed by LSL sensors as an 'agent' (interpreted here to mean a normal user)
42 /// rather than an OpenSim specific NPC extension?
43 /// </summary>
44 bool SenseAsAgent { get; }
45 }
46
34 public interface INPCModule 47 public interface INPCModule
35 { 48 {
36 /// <summary> 49 /// <summary>
@@ -39,10 +52,21 @@ namespace OpenSim.Region.Framework.Interfaces
39 /// <param name="firstname"></param> 52 /// <param name="firstname"></param>
40 /// <param name="lastname"></param> 53 /// <param name="lastname"></param>
41 /// <param name="position"></param> 54 /// <param name="position"></param>
55 /// <param name="senseAsAgent">
56 /// Make the NPC show up as an agent on LSL sensors. The default is that they
57 /// show up as the NPC type instead, but this is currently an OpenSim-only extension.
58 /// </param>
42 /// <param name="scene"></param> 59 /// <param name="scene"></param>
43 /// <param name="appearance">The avatar appearance to use for the new NPC.</param> 60 /// <param name="appearance">The avatar appearance to use for the new NPC.</param>
44 /// <returns>The UUID of the ScenePresence created.</returns> 61 /// <returns>The UUID of the ScenePresence created.</returns>
45 UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance); 62 UUID CreateNPC(
63 string firstname,
64 string lastname,
65 Vector3 position,
66 UUID owner,
67 bool senseAsAgent,
68 Scene scene,
69 AvatarAppearance appearance);
46 70
47 /// <summary> 71 /// <summary>
48 /// Check if the agent is an NPC. 72 /// Check if the agent is an NPC.
@@ -53,6 +77,22 @@ namespace OpenSim.Region.Framework.Interfaces
53 bool IsNPC(UUID agentID, Scene scene); 77 bool IsNPC(UUID agentID, Scene scene);
54 78
55 /// <summary> 79 /// <summary>
80 /// Get the NPC. This is not currently complete - manipulation of NPCs still occurs through the region interface
81 /// </summary>
82 /// <param name="agentID"></param>
83 /// <param name="scene"></param>
84 /// <returns>The NPC. null if it does not exist.</returns>
85 INPC GetNPC(UUID agentID, Scene scene);
86
87 /// <summary>
88 /// Check if the caller has permission to manipulate the given NPC.
89 /// </summary>
90 /// <param name="npcID"></param>
91 /// <param name="callerID"></param>
92 /// <returns>true if they do, false if they don't or if there's no NPC with the given ID.</returns>
93 bool CheckPermissions(UUID npcID, UUID callerID);
94
95 /// <summary>
56 /// Set the appearance for an NPC. 96 /// Set the appearance for an NPC.
57 /// </summary> 97 /// </summary>
58 /// <param name="agentID"></param> 98 /// <param name="agentID"></param>
@@ -118,5 +158,12 @@ namespace OpenSim.Region.Framework.Interfaces
118 /// <param name="scene"></param> 158 /// <param name="scene"></param>
119 /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> 159 /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
120 bool DeleteNPC(UUID agentID, Scene scene); 160 bool DeleteNPC(UUID agentID, Scene scene);
161
162 /// <summary>
163 /// Get the owner of a NPC
164 /// </summary>
165 /// <param name="agentID">The UUID of the NPC</param>
166 /// <returns>UUID of owner if the NPC exists, UUID.Zero if there was no such agent, the agent is unowned or the agent was not an NPC</returns>
167 UUID GetOwner(UUID agentID);
121 } 168 }
122} \ No newline at end of file 169} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IProfileModule.cs b/OpenSim/Region/Framework/Interfaces/IProfileModule.cs
new file mode 100644
index 0000000..ef03d4a
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IProfileModule.cs
@@ -0,0 +1,37 @@
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.Framework
31{
32 public interface IProfileModule
33 {
34 void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID);
35
36 }
37}
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs
new file mode 100644
index 0000000..aa4a757
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs
@@ -0,0 +1,38 @@
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
29using System;
30
31namespace OpenSim.Region.Framework.Interfaces
32{
33 public interface IRegionReadyModule
34 {
35 void OarLoadingAlert(string msg);
36 }
37}
38
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index 950e4b0..18c45dd 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -31,8 +31,21 @@ using OpenMetaverse;
31 31
32namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Region.Framework.Interfaces
33{ 33{
34 public delegate void ScriptRemoved(UUID script);
35 public delegate void ObjectRemoved(UUID prim);
36
34 public interface IScriptModule: INonSharedRegionModule 37 public interface IScriptModule: INonSharedRegionModule
35 { 38 {
39 /// <summary>
40 /// Triggered when a script is removed from the script module.
41 /// </summary>
42 event ScriptRemoved OnScriptRemoved;
43
44 /// <summary>
45 /// Triggered when an object is removed via the script module.
46 /// </summary>
47 event ObjectRemoved OnObjectRemoved;
48
36 string ScriptEngineName { get; } 49 string ScriptEngineName { get; }
37 50
38 string GetXMLState(UUID itemID); 51 string GetXMLState(UUID itemID);
diff --git a/OpenSim/Region/Framework/Interfaces/ISearchModule.cs b/OpenSim/Region/Framework/Interfaces/ISearchModule.cs
new file mode 100644
index 0000000..64bf72c
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/ISearchModule.cs
@@ -0,0 +1,36 @@
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.Framework
31{
32 public interface ISearchModule
33 {
34
35 }
36}
diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
index 54dfaf4..bfb8369 100644
--- a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
+++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
@@ -14,9 +14,6 @@ namespace OpenSim.Region.Framework.Interfaces
14 string GetUserHomeURL(UUID uuid); 14 string GetUserHomeURL(UUID uuid);
15 string GetUserUUI(UUID uuid); 15 string GetUserUUI(UUID uuid);
16 string GetUserServerURL(UUID uuid, string serverType); 16 string GetUserServerURL(UUID uuid, string serverType);
17 int GetUserFlags(UUID userID);
18 int GetUserCreated(UUID userID);
19 string GetUserTitle(UUID userID);
20 17
21 /// <summary> 18 /// <summary>
22 /// Add a user. 19 /// Add a user.
@@ -50,7 +47,7 @@ namespace OpenSim.Region.Framework.Interfaces
50 /// <param name="uuid"></param> 47 /// <param name="uuid"></param>
51 /// <param name="firstName"></param> 48 /// <param name="firstName"></param>
52 /// <param name="profileURL"></param> 49 /// <param name="profileURL"></param>
53 void AddUser(UUID uuid, string firstName, string lastName, string profileURL); 50 void AddUser(UUID uuid, string firstName, string lastName, string homeURL);
54 51
55 bool IsLocalGridUser(UUID uuid); 52 bool IsLocalGridUser(UUID uuid);
56 } 53 }
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index eda085f..3584cda 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -61,11 +61,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation
61 public bool m_jumping = false; 61 public bool m_jumping = false;
62 public float m_jumpVelocity = 0f; 62 public float m_jumpVelocity = 0f;
63// private int m_landing = 0; 63// private int m_landing = 0;
64 public bool Falling 64
65 { 65 /// <summary>
66 get { return m_falling; } 66 /// Is the avatar falling?
67 } 67 /// </summary>
68 private bool m_falling = false; 68 public bool Falling { get; private set; }
69
69 private float m_fallHeight; 70 private float m_fallHeight;
70 71
71 /// <value> 72 /// <value>
@@ -223,7 +224,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
223 m_animTickFall = 0; 224 m_animTickFall = 0;
224 m_animTickJump = 0; 225 m_animTickJump = 0;
225 m_jumping = false; 226 m_jumping = false;
226 m_falling = true; 227 Falling = false;
227 m_jumpVelocity = 0f; 228 m_jumpVelocity = 0f;
228 actor.Selected = false; 229 actor.Selected = false;
229 m_fallHeight = actor.Position.Z; // save latest flying height 230 m_fallHeight = actor.Position.Z; // save latest flying height
@@ -238,10 +239,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
238 } 239 }
239 else if (move.Z < 0f) 240 else if (move.Z < 0f)
240 { 241 {
241 if (actor != null && actor.IsColliding) 242 if (actor != null && actor.IsColliding)
242 {
243 return "LAND"; 243 return "LAND";
244 }
245 else 244 else
246 return "HOVER_DOWN"; 245 return "HOVER_DOWN";
247 } 246 }
@@ -260,7 +259,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
260 float fallElapsed = (float)(Environment.TickCount - m_animTickFall); 259 float fallElapsed = (float)(Environment.TickCount - m_animTickFall);
261 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; 260 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f;
262 261
263 if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; 262 if (!m_jumping && (fallVelocity < -3.0f))
263 Falling = true;
264 264
265 if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) 265 if (m_animTickFall == 0 || (fallVelocity >= 0.0f))
266 { 266 {
@@ -290,20 +290,20 @@ namespace OpenSim.Region.Framework.Scenes.Animation
290 // Start jumping, prejump 290 // Start jumping, prejump
291 m_animTickFall = 0; 291 m_animTickFall = 0;
292 m_jumping = true; 292 m_jumping = true;
293 m_falling = false; 293 Falling = false;
294 actor.Selected = true; // borrowed for jumping flag 294 actor.Selected = true; // borrowed for jumping flag
295 m_animTickJump = Environment.TickCount; 295 m_animTickJump = Environment.TickCount;
296 m_jumpVelocity = 0.35f; 296 m_jumpVelocity = 0.35f;
297 return "PREJUMP"; 297 return "PREJUMP";
298 } 298 }
299 299
300 if(m_jumping) 300 if (m_jumping)
301 { 301 {
302 if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) 302 if ((jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding)
303 { 303 {
304 // end jumping 304 // end jumping
305 m_jumping = false; 305 m_jumping = false;
306 m_falling = false; 306 Falling = false;
307 actor.Selected = false; // borrowed for jumping flag 307 actor.Selected = false; // borrowed for jumping flag
308 m_jumpVelocity = 0f; 308 m_jumpVelocity = 0f;
309 m_animTickFall = Environment.TickCount; 309 m_animTickFall = Environment.TickCount;
@@ -330,7 +330,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
330 330
331 if (CurrentMovementAnimation == "FALLDOWN") 331 if (CurrentMovementAnimation == "FALLDOWN")
332 { 332 {
333 m_falling = false; 333 Falling = false;
334 m_animTickFall = Environment.TickCount; 334 m_animTickFall = Environment.TickCount;
335 // TODO: SOFT_LAND support 335 // TODO: SOFT_LAND support
336 float fallHeight = m_fallHeight - actor.Position.Z; 336 float fallHeight = m_fallHeight - actor.Position.Z;
@@ -364,7 +364,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
364 if (move.X != 0f || move.Y != 0f) 364 if (move.X != 0f || move.Y != 0f)
365 { 365 {
366 m_fallHeight = actor.Position.Z; // save latest flying height 366 m_fallHeight = actor.Position.Z; // save latest flying height
367 m_falling = false; 367 Falling = false;
368 // Walking / crouchwalking / running 368 // Walking / crouchwalking / running
369 if (move.Z < 0f) 369 if (move.Z < 0f)
370 return "CROUCHWALK"; 370 return "CROUCHWALK";
@@ -375,7 +375,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
375 } 375 }
376 else if (!m_jumping) 376 else if (!m_jumping)
377 { 377 {
378 m_falling = false; 378 Falling = false;
379 // Not walking 379 // Not walking
380 if (move.Z < 0) 380 if (move.Z < 0)
381 return "CROUCH"; 381 return "CROUCH";
@@ -388,7 +388,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
388 } 388 }
389 #endregion Ground Movement 389 #endregion Ground Movement
390 390
391 m_falling = false; 391 Falling = false;
392 392
393 return CurrentMovementAnimation; 393 return CurrentMovementAnimation;
394 } 394 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index b62023b..dd3208a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -979,25 +979,40 @@ namespace OpenSim.Region.Framework.Scenes
979 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) 979 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
980 { 980 {
981 SceneObjectPart part = GetSceneObjectPart(localID); 981 SceneObjectPart part = GetSceneObjectPart(localID);
982 if (part == null) 982 SceneObjectGroup group = null;
983 return; 983 if (part != null)
984 {
985 group = part.ParentGroup;
986 }
987 if (part != null && group != null)
988 {
989 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
990 return;
984 991
985 SceneObjectGroup group = part.ParentGroup; 992 TaskInventoryItem item = group.GetInventoryItem(localID, itemID);
986 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) 993 if (item == null)
987 return; 994 return;
988
989 TaskInventoryItem item = group.GetInventoryItem(localID, itemID);
990 if (item == null)
991 return;
992 995
993 if (item.Type == 10) 996 InventoryFolderBase destFolder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder);
994 { 997
995 part.RemoveScriptEvents(itemID); 998 // Move the item to trash. If this is a copiable item, only
996 EventManager.TriggerRemoveScript(localID, itemID); 999 // a copy will be moved and we will still need to delete
1000 // the item from the prim. If it was no copy, is will be
1001 // deleted by this method.
1002 MoveTaskInventoryItem(remoteClient, destFolder.ID, part, itemID);
1003
1004 if (group.GetInventoryItem(localID, itemID) != null)
1005 {
1006 if (item.Type == 10)
1007 {
1008 part.RemoveScriptEvents(itemID);
1009 EventManager.TriggerRemoveScript(localID, itemID);
1010 }
1011
1012 group.RemoveInventoryItem(localID, itemID);
1013 }
1014 part.SendPropertiesToClient(remoteClient);
997 } 1015 }
998
999 group.RemoveInventoryItem(localID, itemID);
1000 part.SendPropertiesToClient(remoteClient);
1001 } 1016 }
1002 1017
1003 private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) 1018 private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId)
@@ -1058,7 +1073,15 @@ namespace OpenSim.Region.Framework.Scenes
1058 if (!Permissions.BypassPermissions()) 1073 if (!Permissions.BypassPermissions())
1059 { 1074 {
1060 if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1075 if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
1076 {
1077 if (taskItem.Type == 10)
1078 {
1079 part.RemoveScriptEvents(itemId);
1080 EventManager.TriggerRemoveScript(part.LocalId, itemId);
1081 }
1082
1061 part.Inventory.RemoveInventoryItem(itemId); 1083 part.Inventory.RemoveInventoryItem(itemId);
1084 }
1062 } 1085 }
1063 1086
1064 return agentItem; 1087 return agentItem;
@@ -1421,7 +1444,7 @@ namespace OpenSim.Region.Framework.Scenes
1421 // If we've found the item in the user's inventory or in the library 1444 // If we've found the item in the user's inventory or in the library
1422 if (item != null) 1445 if (item != null)
1423 { 1446 {
1424 part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); 1447 part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID);
1425 m_log.InfoFormat( 1448 m_log.InfoFormat(
1426 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", 1449 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
1427 item.Name, primLocalID, remoteClient.Name); 1450 item.Name, primLocalID, remoteClient.Name);
@@ -1449,20 +1472,27 @@ namespace OpenSim.Region.Framework.Scenes
1449// m_log.DebugFormat( 1472// m_log.DebugFormat(
1450// "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", 1473// "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()",
1451// currentItem.Name, part.Name); 1474// currentItem.Name, part.Name);
1452
1453 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
1454 if (agentTransactions != null)
1455 {
1456 agentTransactions.HandleTaskItemUpdateFromTransaction(
1457 remoteClient, part, transactionID, currentItem);
1458 1475
1459 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) 1476 // Viewers from at least Linden Lab 1.23 onwards use a capability to update script contents rather
1460 remoteClient.SendAgentAlertMessage("Notecard saved", false); 1477 // than UDP. With viewers from at least 1.23 onwards, changing properties on scripts (e.g. renaming) causes
1461 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) 1478 // this to spew spurious errors and "thing saved" messages.
1462 remoteClient.SendAgentAlertMessage("Script saved", false); 1479 // Rather than retaining complexity in the code and removing useful error messages, I'm going to
1463 else 1480 // comment this section out. If this was still working for very old viewers and there is
1464 remoteClient.SendAgentAlertMessage("Item saved", false); 1481 // a large population using them which cannot upgrade to 1.23 or derivatives then we can revisit
1465 } 1482 // this - justincc
1483// IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
1484// if (agentTransactions != null)
1485// {
1486// agentTransactions.HandleTaskItemUpdateFromTransaction(
1487// remoteClient, part, transactionID, currentItem);
1488//
1489// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1490// remoteClient.SendAgentAlertMessage("Notecard saved", false);
1491// else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1492// remoteClient.SendAgentAlertMessage("Script saved", false);
1493// else
1494// remoteClient.SendAgentAlertMessage("Item saved", false);
1495// }
1466 1496
1467 // Base ALWAYS has move 1497 // Base ALWAYS has move
1468 currentItem.BasePermissions |= (uint)PermissionMask.Move; 1498 currentItem.BasePermissions |= (uint)PermissionMask.Move;
@@ -1537,104 +1567,141 @@ namespace OpenSim.Region.Framework.Scenes
1537 /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory 1567 /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory
1538 /// </summary> 1568 /// </summary>
1539 /// <param name="remoteClient"></param> 1569 /// <param name="remoteClient"></param>
1540 /// <param name="itemID"> </param> 1570 /// <param name="itemBase"> </param>
1571 /// <param name="transactionID"></param>
1541 /// <param name="localID"></param> 1572 /// <param name="localID"></param>
1542 public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) 1573 public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID)
1543 { 1574 {
1544 UUID itemID = itemBase.ID; 1575 SceneObjectPart partWhereRezzed;
1576
1577 if (itemBase.ID != UUID.Zero)
1578 partWhereRezzed = RezScriptFromAgentInventory(remoteClient.AgentId, itemBase.ID, localID);
1579 else
1580 partWhereRezzed = RezNewScript(remoteClient.AgentId, itemBase);
1581
1582 if (partWhereRezzed != null)
1583 partWhereRezzed.SendPropertiesToClient(remoteClient);
1584 }
1585
1586 /// <summary>
1587 /// Rez a script into a prim from an agent inventory.
1588 /// </summary>
1589 /// <param name="agentID"></param>
1590 /// <param name="fromItemID"></param>
1591 /// <param name="localID"></param>
1592 /// <returns>The part where the script was rezzed if successful. False otherwise.</returns>
1593 public SceneObjectPart RezScriptFromAgentInventory(UUID agentID, UUID fromItemID, uint localID)
1594 {
1545 UUID copyID = UUID.Random(); 1595 UUID copyID = UUID.Random();
1596 InventoryItemBase item = new InventoryItemBase(fromItemID, agentID);
1597 item = InventoryService.GetItem(item);
1546 1598
1547 if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory 1599 // Try library
1600 // XXX clumsy, possibly should be one call
1601 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1548 { 1602 {
1549 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 1603 item = LibraryService.LibraryRootFolder.FindItem(fromItemID);
1550 item = InventoryService.GetItem(item); 1604 }
1551 1605
1552 // Try library 1606 if (item != null)
1553 // XXX clumsy, possibly should be one call 1607 {
1554 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) 1608 SceneObjectPart part = GetSceneObjectPart(localID);
1609 if (part != null)
1555 { 1610 {
1556 item = LibraryService.LibraryRootFolder.FindItem(itemID); 1611 if (!Permissions.CanEditObjectInventory(part.UUID, agentID))
1557 } 1612 return null;
1558 1613
1559 if (item != null) 1614 part.ParentGroup.AddInventoryItem(agentID, localID, item, copyID);
1560 { 1615 // TODO: switch to posting on_rez here when scripts
1561 SceneObjectPart part = GetSceneObjectPart(localID); 1616 // have state in inventory
1562 if (part != null) 1617 part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0);
1563 {
1564 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
1565 return;
1566 1618
1567 part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); 1619 // m_log.InfoFormat("[PRIMINVENTORY]: " +
1568 // TODO: switch to posting on_rez here when scripts 1620 // "Rezzed script {0} into prim local ID {1} for user {2}",
1569 // have state in inventory 1621 // item.inventoryName, localID, remoteClient.Name);
1570 part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); 1622 part.ParentGroup.ResumeScripts();
1571 1623
1572 // m_log.InfoFormat("[PRIMINVENTORY]: " + 1624 return part;
1573 // "Rezzed script {0} into prim local ID {1} for user {2}",
1574 // item.inventoryName, localID, remoteClient.Name);
1575 part.SendPropertiesToClient(remoteClient);
1576 part.ParentGroup.ResumeScripts();
1577 }
1578 else
1579 {
1580 m_log.ErrorFormat(
1581 "[PRIM INVENTORY]: " +
1582 "Could not rez script {0} into prim local ID {1} for user {2}"
1583 + " because the prim could not be found in the region!",
1584 item.Name, localID, remoteClient.Name);
1585 }
1586 } 1625 }
1587 else 1626 else
1588 { 1627 {
1589 m_log.ErrorFormat( 1628 m_log.ErrorFormat(
1590 "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", 1629 "[PRIM INVENTORY]: " +
1591 itemID, remoteClient.Name); 1630 "Could not rez script {0} into prim local ID {1} for user {2}"
1631 + " because the prim could not be found in the region!",
1632 item.Name, localID, agentID);
1592 } 1633 }
1593 } 1634 }
1594 else // script has been rezzed directly into a prim's inventory 1635 else
1595 { 1636 {
1596 SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); 1637 m_log.ErrorFormat(
1597 if (part == null) 1638 "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!",
1598 return; 1639 fromItemID, agentID);
1640 }
1599 1641
1600 if (!Permissions.CanCreateObjectInventory( 1642 return null;
1601 itemBase.InvType, part.UUID, remoteClient.AgentId)) 1643 }
1602 return;
1603 1644
1604 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1645 /// <summary>
1605 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1646 /// Rez a new script from nothing.
1606 remoteClient.AgentId); 1647 /// </summary>
1607 AssetService.Store(asset); 1648 /// <param name="remoteClient"></param>
1608 1649 /// <param name="itemBase"></param>
1609 TaskInventoryItem taskItem = new TaskInventoryItem(); 1650 /// <returns>The part where the script was rezzed if successful. False otherwise.</returns>
1610 1651 public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase)
1611 taskItem.ResetIDs(itemBase.Folder); 1652 {
1612 taskItem.ParentID = itemBase.Folder; 1653 // The part ID is the folder ID!
1613 taskItem.CreationDate = (uint)itemBase.CreationDate; 1654 SceneObjectPart part = GetSceneObjectPart(itemBase.Folder);
1614 taskItem.Name = itemBase.Name; 1655 if (part == null)
1615 taskItem.Description = itemBase.Description; 1656 {
1616 taskItem.Type = itemBase.AssetType; 1657// m_log.DebugFormat(
1617 taskItem.InvType = itemBase.InvType; 1658// "[SCENE INVENTORY]: Could not find part with id {0} for {1} to rez new script",
1618 taskItem.OwnerID = itemBase.Owner; 1659// itemBase.Folder, agentID);
1619 taskItem.CreatorID = itemBase.CreatorIdAsUuid;
1620 taskItem.BasePermissions = itemBase.BasePermissions;
1621 taskItem.CurrentPermissions = itemBase.CurrentPermissions;
1622 taskItem.EveryonePermissions = itemBase.EveryOnePermissions;
1623 taskItem.GroupPermissions = itemBase.GroupPermissions;
1624 taskItem.NextPermissions = itemBase.NextPermissions;
1625 taskItem.GroupID = itemBase.GroupID;
1626 taskItem.GroupPermissions = 0;
1627 taskItem.Flags = itemBase.Flags;
1628 taskItem.PermsGranter = UUID.Zero;
1629 taskItem.PermsMask = 0;
1630 taskItem.AssetID = asset.FullID;
1631
1632 part.Inventory.AddInventoryItem(taskItem, false);
1633 part.SendPropertiesToClient(remoteClient);
1634 1660
1635 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); 1661 return null;
1636 part.ParentGroup.ResumeScripts(); 1662 }
1663
1664 if (!Permissions.CanCreateObjectInventory(itemBase.InvType, part.UUID, agentID))
1665 {
1666// m_log.DebugFormat(
1667// "[SCENE INVENTORY]: No permission to create new script in {0} for {1}", part.Name, agentID);
1668
1669 return null;
1637 } 1670 }
1671
1672 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1673 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"),
1674 agentID);
1675 AssetService.Store(asset);
1676
1677 TaskInventoryItem taskItem = new TaskInventoryItem();
1678
1679 taskItem.ResetIDs(itemBase.Folder);
1680 taskItem.ParentID = itemBase.Folder;
1681 taskItem.CreationDate = (uint)itemBase.CreationDate;
1682 taskItem.Name = itemBase.Name;
1683 taskItem.Description = itemBase.Description;
1684 taskItem.Type = itemBase.AssetType;
1685 taskItem.InvType = itemBase.InvType;
1686 taskItem.OwnerID = itemBase.Owner;
1687 taskItem.CreatorID = itemBase.CreatorIdAsUuid;
1688 taskItem.BasePermissions = itemBase.BasePermissions;
1689 taskItem.CurrentPermissions = itemBase.CurrentPermissions;
1690 taskItem.EveryonePermissions = itemBase.EveryOnePermissions;
1691 taskItem.GroupPermissions = itemBase.GroupPermissions;
1692 taskItem.NextPermissions = itemBase.NextPermissions;
1693 taskItem.GroupID = itemBase.GroupID;
1694 taskItem.GroupPermissions = 0;
1695 taskItem.Flags = itemBase.Flags;
1696 taskItem.PermsGranter = UUID.Zero;
1697 taskItem.PermsMask = 0;
1698 taskItem.AssetID = asset.FullID;
1699
1700 part.Inventory.AddInventoryItem(taskItem, false);
1701 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
1702 part.ParentGroup.ResumeScripts();
1703
1704 return part;
1638 } 1705 }
1639 1706
1640 /// <summary> 1707 /// <summary>
@@ -1643,7 +1710,7 @@ namespace OpenSim.Region.Framework.Scenes
1643 /// <param name="remoteClient"></param> 1710 /// <param name="remoteClient"></param>
1644 /// <param name="itemID"> </param> 1711 /// <param name="itemID"> </param>
1645 /// <param name="localID"></param> 1712 /// <param name="localID"></param>
1646 public void RezScript(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) 1713 public void RezScriptFromPrim(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param)
1647 { 1714 {
1648 TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId); 1715 TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId);
1649 1716
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 3d8c714..bfe8d2c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -65,6 +65,7 @@ namespace OpenSim.Region.Framework.Scenes
65 #region Fields 65 #region Fields
66 66
67 public bool EmergencyMonitoring = false; 67 public bool EmergencyMonitoring = false;
68 public bool DEBUG = false;
68 69
69 public SynchronizeSceneHandler SynchronizeScene; 70 public SynchronizeSceneHandler SynchronizeScene;
70 public SimStatsReporter StatsReporter; 71 public SimStatsReporter StatsReporter;
@@ -599,23 +600,6 @@ namespace OpenSim.Region.Framework.Scenes
599 "reload estate", 600 "reload estate",
600 "Reload the estate data", HandleReloadEstate); 601 "Reload the estate data", HandleReloadEstate);
601 602
602 MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner",
603 "delete object owner <UUID>",
604 "Delete object by owner", HandleDeleteObject);
605 MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator",
606 "delete object creator <UUID>",
607 "Delete object by creator", HandleDeleteObject);
608 MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid",
609 "delete object uuid <UUID>",
610 "Delete object by uuid", HandleDeleteObject);
611 MainConsole.Instance.Commands.AddCommand("region", false, "delete object name",
612 "delete object name <name>",
613 "Delete object by name", HandleDeleteObject);
614
615 MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside",
616 "delete object outside",
617 "Delete all objects outside boundaries", HandleDeleteObject);
618
619 //Bind Storage Manager functions to some land manager functions for this scene 603 //Bind Storage Manager functions to some land manager functions for this scene
620 EventManager.OnLandObjectAdded += 604 EventManager.OnLandObjectAdded +=
621 new EventManager.LandObjectAdded(simDataService.StoreLandObject); 605 new EventManager.LandObjectAdded(simDataService.StoreLandObject);
@@ -1942,6 +1926,7 @@ namespace OpenSim.Region.Framework.Scenes
1942 /// If true, the object is made persistent into the scene. 1926 /// If true, the object is made persistent into the scene.
1943 /// If false, the object will not persist over server restarts 1927 /// If false, the object will not persist over server restarts
1944 /// </param> 1928 /// </param>
1929 /// <returns>true if the object was added. false if not</returns>
1945 public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) 1930 public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
1946 { 1931 {
1947 return AddNewSceneObject(sceneObject, attachToBackup, true); 1932 return AddNewSceneObject(sceneObject, attachToBackup, true);
@@ -1959,6 +1944,7 @@ namespace OpenSim.Region.Framework.Scenes
1959 /// If true, updates for the new scene object are sent to all viewers in range. 1944 /// If true, updates for the new scene object are sent to all viewers in range.
1960 /// If false, it is left to the caller to schedule the update 1945 /// If false, it is left to the caller to schedule the update
1961 /// </param> 1946 /// </param>
1947 /// <returns>true if the object was added. false if not</returns>
1962 public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) 1948 public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
1963 { 1949 {
1964 if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates)) 1950 if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates))
@@ -2528,7 +2514,7 @@ namespace OpenSim.Region.Framework.Scenes
2528 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); 2514 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
2529 m_eventManager.TriggerOnNewPresence(sp); 2515 m_eventManager.TriggerOnNewPresence(sp);
2530 2516
2531 sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags; 2517 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
2532 2518
2533 // The first agent upon login is a root agent by design. 2519 // The first agent upon login is a root agent by design.
2534 // For this agent we will have to rez the attachments. 2520 // For this agent we will have to rez the attachments.
@@ -3070,11 +3056,11 @@ namespace OpenSim.Region.Framework.Scenes
3070 public override void RemoveClient(UUID agentID, bool closeChildAgents) 3056 public override void RemoveClient(UUID agentID, bool closeChildAgents)
3071 { 3057 {
3072 CheckHeartbeat(); 3058 CheckHeartbeat();
3073 bool childagentYN = false; 3059 bool isChildAgent = false;
3074 ScenePresence avatar = GetScenePresence(agentID); 3060 ScenePresence avatar = GetScenePresence(agentID);
3075 if (avatar != null) 3061 if (avatar != null)
3076 { 3062 {
3077 childagentYN = avatar.IsChildAgent; 3063 isChildAgent = avatar.IsChildAgent;
3078 3064
3079 if (avatar.ParentID != 0) 3065 if (avatar.ParentID != 0)
3080 { 3066 {
@@ -3085,9 +3071,9 @@ namespace OpenSim.Region.Framework.Scenes
3085 { 3071 {
3086 m_log.DebugFormat( 3072 m_log.DebugFormat(
3087 "[SCENE]: Removing {0} agent {1} from region {2}", 3073 "[SCENE]: Removing {0} agent {1} from region {2}",
3088 (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); 3074 (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName);
3089 3075
3090 m_sceneGraph.removeUserCount(!childagentYN); 3076 m_sceneGraph.removeUserCount(!isChildAgent);
3091 3077
3092 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop 3078 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
3093 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI 3079 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
@@ -3117,8 +3103,18 @@ namespace OpenSim.Region.Framework.Scenes
3117 { 3103 {
3118 m_eventManager.TriggerOnRemovePresence(agentID); 3104 m_eventManager.TriggerOnRemovePresence(agentID);
3119 3105
3120 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) 3106 if (AttachmentsModule != null && !isChildAgent && avatar.PresenceType != PresenceType.Npc)
3121 AttachmentsModule.SaveChangedAttachments(avatar); 3107 {
3108 IUserManagement uMan = RequestModuleInterface<IUserManagement>();
3109 // Don't save attachments for HG visitors, it
3110 // messes up their inventory. When a HG visitor logs
3111 // out on a foreign grid, their attachments will be
3112 // reloaded in the state they were in when they left
3113 // the home grid. This is best anyway as the visited
3114 // grid may use an incompatible script engine.
3115 if (uMan == null || uMan.IsLocalGridUser(avatar.UUID))
3116 AttachmentsModule.SaveChangedAttachments(avatar, false);
3117 }
3122 3118
3123 ForEachClient( 3119 ForEachClient(
3124 delegate(IClientAPI client) 3120 delegate(IClientAPI client)
@@ -3333,7 +3329,7 @@ namespace OpenSim.Region.Framework.Scenes
3333 { 3329 {
3334 // Let the SP know how we got here. This has a lot of interesting 3330 // Let the SP know how we got here. This has a lot of interesting
3335 // uses down the line. 3331 // uses down the line.
3336 sp.TeleportFlags = (TeleportFlags)teleportFlags; 3332 sp.TeleportFlags = (TPFlags)teleportFlags;
3337 3333
3338 if (sp.IsChildAgent) 3334 if (sp.IsChildAgent)
3339 { 3335 {
@@ -4867,93 +4863,6 @@ namespace OpenSim.Region.Framework.Scenes
4867 } 4863 }
4868 } 4864 }
4869 4865
4870 private void HandleDeleteObject(string module, string[] cmd)
4871 {
4872 if (cmd.Length < 3)
4873 return;
4874
4875 string mode = cmd[2];
4876 string o = "";
4877
4878 if (mode != "outside")
4879 {
4880 if (cmd.Length < 4)
4881 return;
4882
4883 o = cmd[3];
4884 }
4885
4886 List<SceneObjectGroup> deletes = new List<SceneObjectGroup>();
4887
4888 UUID match;
4889
4890 switch (mode)
4891 {
4892 case "owner":
4893 if (!UUID.TryParse(o, out match))
4894 return;
4895 ForEachSOG(delegate (SceneObjectGroup g)
4896 {
4897 if (g.OwnerID == match && !g.IsAttachment)
4898 deletes.Add(g);
4899 });
4900 break;
4901 case "creator":
4902 if (!UUID.TryParse(o, out match))
4903 return;
4904 ForEachSOG(delegate (SceneObjectGroup g)
4905 {
4906 if (g.RootPart.CreatorID == match && !g.IsAttachment)
4907 deletes.Add(g);
4908 });
4909 break;
4910 case "uuid":
4911 if (!UUID.TryParse(o, out match))
4912 return;
4913 ForEachSOG(delegate (SceneObjectGroup g)
4914 {
4915 if (g.UUID == match && !g.IsAttachment)
4916 deletes.Add(g);
4917 });
4918 break;
4919 case "name":
4920 ForEachSOG(delegate (SceneObjectGroup g)
4921 {
4922 if (g.RootPart.Name == o && !g.IsAttachment)
4923 deletes.Add(g);
4924 });
4925 break;
4926 case "outside":
4927 ForEachSOG(delegate (SceneObjectGroup g)
4928 {
4929 SceneObjectPart rootPart = g.RootPart;
4930 bool delete = false;
4931
4932 if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0)
4933 {
4934 delete = true;
4935 }
4936 else
4937 {
4938 ILandObject parcel = LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y);
4939
4940 if (parcel == null || parcel.LandData.Name == "NO LAND")
4941 delete = true;
4942 }
4943
4944 if (delete && !g.IsAttachment && !deletes.Contains(g))
4945 deletes.Add(g);
4946 });
4947 break;
4948 }
4949
4950 foreach (SceneObjectGroup g in deletes)
4951 {
4952 m_log.InfoFormat("[SCENE]: Deleting object {0}", g.UUID);
4953 DeleteSceneObject(g, false);
4954 }
4955 }
4956
4957 private void HandleReloadEstate(string module, string[] cmd) 4866 private void HandleReloadEstate(string module, string[] cmd)
4958 { 4867 {
4959 if (MainConsole.Instance.ConsoleScene == null || 4868 if (MainConsole.Instance.ConsoleScene == null ||
@@ -5076,6 +4985,36 @@ namespace OpenSim.Region.Framework.Scenes
5076 } 4985 }
5077 } 4986 }
5078 4987
4988 if (position == Vector3.Zero) // Teleport
4989 {
4990 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
4991 {
4992 SceneObjectGroup telehub;
4993 if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject)) != null)
4994 {
4995 List<SpawnPoint> spawnPoints = RegionInfo.RegionSettings.SpawnPoints();
4996 bool banned = true;
4997 foreach (SpawnPoint sp in spawnPoints)
4998 {
4999 Vector3 spawnPoint = sp.GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
5000 ILandObject land = LandChannel.GetLandObject(spawnPoint.X, spawnPoint.Y);
5001 if (land == null)
5002 continue;
5003 if (land.IsEitherBannedOrRestricted(agentID))
5004 continue;
5005 banned = false;
5006 break;
5007 }
5008
5009 if (banned)
5010 {
5011 reason = "No suitable landing point found";
5012 return false;
5013 }
5014 }
5015 }
5016 }
5017
5079 reason = String.Empty; 5018 reason = String.Empty;
5080 return true; 5019 return true;
5081 } 5020 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index f481e72..1487fac 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -41,12 +41,6 @@ namespace OpenSim.Region.Framework.Scenes
41{ 41{
42 public delegate void PhysicsCrash(); 42 public delegate void PhysicsCrash();
43 43
44 public delegate void ObjectDuplicateDelegate(EntityBase original, EntityBase clone);
45
46 public delegate void ObjectCreateDelegate(EntityBase obj);
47
48 public delegate void ObjectDeleteDelegate(EntityBase obj);
49
50 /// <summary> 44 /// <summary>
51 /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components 45 /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components
52 /// should be migrated out over time. 46 /// should be migrated out over time.
@@ -60,10 +54,6 @@ namespace OpenSim.Region.Framework.Scenes
60 protected internal event PhysicsCrash UnRecoverableError; 54 protected internal event PhysicsCrash UnRecoverableError;
61 private PhysicsCrash handlerPhysicsCrash = null; 55 private PhysicsCrash handlerPhysicsCrash = null;
62 56
63 public event ObjectDuplicateDelegate OnObjectDuplicate;
64 public event ObjectCreateDelegate OnObjectCreate;
65 public event ObjectDeleteDelegate OnObjectRemove;
66
67 #endregion 57 #endregion
68 58
69 #region Fields 59 #region Fields
@@ -364,11 +354,23 @@ namespace OpenSim.Region.Framework.Scenes
364 /// </returns> 354 /// </returns>
365 protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) 355 protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
366 { 356 {
367 if (sceneObject == null || sceneObject.RootPart.UUID == UUID.Zero) 357 if (sceneObject.UUID == UUID.Zero)
358 {
359 m_log.ErrorFormat(
360 "[SCENEGRAPH]: Tried to add scene object {0} to {1} with illegal UUID of {2}",
361 sceneObject.Name, m_parentScene.RegionInfo.RegionName, UUID.Zero);
362
368 return false; 363 return false;
364 }
369 365
370 if (Entities.ContainsKey(sceneObject.UUID)) 366 if (Entities.ContainsKey(sceneObject.UUID))
367 {
368// m_log.DebugFormat(
369// "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()",
370// m_parentScene.RegionInfo.RegionName, sceneObject.UUID);
371
371 return false; 372 return false;
373 }
372 374
373// m_log.DebugFormat( 375// m_log.DebugFormat(
374// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}", 376// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}",
@@ -405,9 +407,6 @@ namespace OpenSim.Region.Framework.Scenes
405 if (attachToBackup) 407 if (attachToBackup)
406 sceneObject.AttachToBackup(); 408 sceneObject.AttachToBackup();
407 409
408 if (OnObjectCreate != null)
409 OnObjectCreate(sceneObject);
410
411 lock (SceneObjectGroupsByFullID) 410 lock (SceneObjectGroupsByFullID)
412 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; 411 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
413 412
@@ -456,9 +455,6 @@ namespace OpenSim.Region.Framework.Scenes
456 if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) 455 if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics)
457 RemovePhysicalPrim(grp.PrimCount); 456 RemovePhysicalPrim(grp.PrimCount);
458 } 457 }
459
460 if (OnObjectRemove != null)
461 OnObjectRemove(Entities[uuid]);
462 458
463 lock (SceneObjectGroupsByFullID) 459 lock (SceneObjectGroupsByFullID)
464 SceneObjectGroupsByFullID.Remove(grp.UUID); 460 SceneObjectGroupsByFullID.Remove(grp.UUID);
@@ -1154,8 +1150,10 @@ namespace OpenSim.Region.Framework.Scenes
1154 /// <param name="action"></param> 1150 /// <param name="action"></param>
1155 protected internal void ForEachSOG(Action<SceneObjectGroup> action) 1151 protected internal void ForEachSOG(Action<SceneObjectGroup> action)
1156 { 1152 {
1157 // FIXME: Need to lock here, really. 1153 List<SceneObjectGroup> objlist;
1158 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); 1154 lock (SceneObjectGroupsByFullID)
1155 objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
1156
1159 foreach (SceneObjectGroup obj in objlist) 1157 foreach (SceneObjectGroup obj in objlist)
1160 { 1158 {
1161 try 1159 try
@@ -1164,7 +1162,7 @@ namespace OpenSim.Region.Framework.Scenes
1164 } 1162 }
1165 catch (Exception e) 1163 catch (Exception e)
1166 { 1164 {
1167 // Catch it and move on. This includes situations where splist has inconsistent info 1165 // Catch it and move on. This includes situations where objlist has inconsistent info
1168 m_log.WarnFormat( 1166 m_log.WarnFormat(
1169 "[SCENEGRAPH]: Problem processing action in ForEachSOG: {0} {1}", e.Message, e.StackTrace); 1167 "[SCENEGRAPH]: Problem processing action in ForEachSOG: {0} {1}", e.Message, e.StackTrace);
1170 } 1168 }
@@ -1399,10 +1397,10 @@ namespace OpenSim.Region.Framework.Scenes
1399 /// <summary> 1397 /// <summary>
1400 /// Update the texture entry of the given prim. 1398 /// Update the texture entry of the given prim.
1401 /// </summary> 1399 /// </summary>
1402 /// 1400 /// <remarks>
1403 /// A texture entry is an object that contains details of all the textures of the prim's face. In this case, 1401 /// A texture entry is an object that contains details of all the textures of the prim's face. In this case,
1404 /// the texture is given in its byte serialized form. 1402 /// the texture is given in its byte serialized form.
1405 /// 1403 /// </remarks>
1406 /// <param name="localID"></param> 1404 /// <param name="localID"></param>
1407 /// <param name="texture"></param> 1405 /// <param name="texture"></param>
1408 /// <param name="remoteClient"></param> 1406 /// <param name="remoteClient"></param>
@@ -1980,9 +1978,6 @@ namespace OpenSim.Region.Framework.Scenes
1980 // required for physics to update it's position 1978 // required for physics to update it's position
1981 copy.AbsolutePosition = copy.AbsolutePosition; 1979 copy.AbsolutePosition = copy.AbsolutePosition;
1982 1980
1983 if (OnObjectDuplicate != null)
1984 OnObjectDuplicate(original, copy);
1985
1986 return copy; 1981 return copy;
1987 } 1982 }
1988 } 1983 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 905ecc9..f173c95 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -83,13 +83,12 @@ namespace OpenSim.Region.Framework.Scenes
83 /// <summary> 83 /// <summary>
84 /// Add an inventory item from a user's inventory to a prim in this scene object. 84 /// Add an inventory item from a user's inventory to a prim in this scene object.
85 /// </summary> 85 /// </summary>
86 /// <param name="remoteClient">The client adding the item.</param> 86 /// <param name="agentID">The agent adding the item.</param>
87 /// <param name="localID">The local ID of the part receiving the add.</param> 87 /// <param name="localID">The local ID of the part receiving the add.</param>
88 /// <param name="item">The user inventory item being added.</param> 88 /// <param name="item">The user inventory item being added.</param>
89 /// <param name="copyItemID">The item UUID that should be used by the new item.</param> 89 /// <param name="copyItemID">The item UUID that should be used by the new item.</param>
90 /// <returns></returns> 90 /// <returns></returns>
91 public bool AddInventoryItem(IClientAPI remoteClient, uint localID, 91 public bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID)
92 InventoryItemBase item, UUID copyItemID)
93 { 92 {
94// m_log.DebugFormat( 93// m_log.DebugFormat(
95// "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}", 94// "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}",
@@ -111,9 +110,7 @@ namespace OpenSim.Region.Framework.Scenes
111 taskItem.Type = item.AssetType; 110 taskItem.Type = item.AssetType;
112 taskItem.InvType = item.InvType; 111 taskItem.InvType = item.InvType;
113 112
114 if (remoteClient != null && 113 if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions())
115 remoteClient.AgentId != part.OwnerID &&
116 m_scene.Permissions.PropagatePermissions())
117 { 114 {
118 taskItem.BasePermissions = item.BasePermissions & 115 taskItem.BasePermissions = item.BasePermissions &
119 item.NextPermissions; 116 item.NextPermissions;
@@ -148,11 +145,7 @@ namespace OpenSim.Region.Framework.Scenes
148// taskItem.SaleType = item.SaleType; 145// taskItem.SaleType = item.SaleType;
149 taskItem.CreationDate = (uint)item.CreationDate; 146 taskItem.CreationDate = (uint)item.CreationDate;
150 147
151 bool addFromAllowedDrop = false; 148 bool addFromAllowedDrop = agentID != part.OwnerID;
152 if (remoteClient != null)
153 {
154 addFromAllowedDrop = remoteClient.AgentId != part.OwnerID;
155 }
156 149
157 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); 150 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop);
158 151
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 8860764..e7f2fdb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -264,6 +264,12 @@ namespace OpenSim.Region.Framework.Scenes
264 set { RootPart.Name = value; } 264 set { RootPart.Name = value; }
265 } 265 }
266 266
267 public string Description
268 {
269 get { return RootPart.Description; }
270 set { RootPart.Description = value; }
271 }
272
267 /// <summary> 273 /// <summary>
268 /// Added because the Parcel code seems to use it 274 /// Added because the Parcel code seems to use it
269 /// but not sure a object should have this 275 /// but not sure a object should have this
@@ -441,6 +447,12 @@ namespace OpenSim.Region.Framework.Scenes
441 } 447 }
442 } 448 }
443 449
450 public UUID LastOwnerID
451 {
452 get { return m_rootPart.LastOwnerID; }
453 set { m_rootPart.LastOwnerID = value; }
454 }
455
444 public UUID OwnerID 456 public UUID OwnerID
445 { 457 {
446 get { return m_rootPart.OwnerID; } 458 get { return m_rootPart.OwnerID; }
@@ -1613,12 +1625,6 @@ namespace OpenSim.Region.Framework.Scenes
1613 RootPart.PhysActor.PIDActive = false; 1625 RootPart.PhysActor.PIDActive = false;
1614 } 1626 }
1615 1627
1616 public void stopLookAt()
1617 {
1618 if (RootPart.PhysActor != null)
1619 RootPart.PhysActor.APIDActive = false;
1620 }
1621
1622 /// <summary> 1628 /// <summary>
1623 /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. 1629 /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds.
1624 /// </summary> 1630 /// </summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 8e59abf..9b660b6 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -217,11 +217,10 @@ namespace OpenSim.Region.Framework.Scenes
217 217
218 public Quaternion SpinOldOrientation = Quaternion.Identity; 218 public Quaternion SpinOldOrientation = Quaternion.Identity;
219 219
220 public Quaternion m_APIDTarget = Quaternion.Identity; 220 protected int m_APIDIterations = 0;
221 221 protected Quaternion m_APIDTarget = Quaternion.Identity;
222 public float m_APIDDamp = 0; 222 protected float m_APIDDamp = 0;
223 223 protected float m_APIDStrength = 0;
224 public float m_APIDStrength = 0;
225 224
226 /// <summary> 225 /// <summary>
227 /// This part's inventory 226 /// This part's inventory
@@ -394,7 +393,7 @@ namespace OpenSim.Region.Framework.Scenes
394 393
395 private string m_creatorData = string.Empty; 394 private string m_creatorData = string.Empty;
396 /// <summary> 395 /// <summary>
397 /// Data about the creator in the form profile_url;name 396 /// Data about the creator in the form home_url;name
398 /// </summary> 397 /// </summary>
399 public string CreatorData 398 public string CreatorData
400 { 399 {
@@ -405,7 +404,7 @@ namespace OpenSim.Region.Framework.Scenes
405 /// <summary> 404 /// <summary>
406 /// Used by the DB layer to retrieve / store the entire user identification. 405 /// Used by the DB layer to retrieve / store the entire user identification.
407 /// The identification can either be a simple UUID or a string of the form 406 /// The identification can either be a simple UUID or a string of the form
408 /// uuid[;profile_url[;name]] 407 /// uuid[;home_url[;name]]
409 /// </summary> 408 /// </summary>
410 public string CreatorIdentification 409 public string CreatorIdentification
411 { 410 {
@@ -563,22 +562,21 @@ namespace OpenSim.Region.Framework.Scenes
563 } 562 }
564 } 563 }
565 564
566 565 protected Quaternion APIDTarget
567 public Quaternion APIDTarget
568 { 566 {
569 get { return m_APIDTarget; } 567 get { return m_APIDTarget; }
570 set { m_APIDTarget = value; } 568 set { m_APIDTarget = value; }
571 } 569 }
572 570
573 571
574 public float APIDDamp 572 protected float APIDDamp
575 { 573 {
576 get { return m_APIDDamp; } 574 get { return m_APIDDamp; }
577 set { m_APIDDamp = value; } 575 set { m_APIDDamp = value; }
578 } 576 }
579 577
580 578
581 public float APIDStrength 579 protected float APIDStrength
582 { 580 {
583 get { return m_APIDStrength; } 581 get { return m_APIDStrength; }
584 set { m_APIDStrength = value; } 582 set { m_APIDStrength = value; }
@@ -1946,19 +1944,13 @@ namespace OpenSim.Region.Framework.Scenes
1946 public Vector3 GetWorldPosition() 1944 public Vector3 GetWorldPosition()
1947 { 1945 {
1948 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 1946 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
1949
1950 Vector3 axPos = OffsetPosition; 1947 Vector3 axPos = OffsetPosition;
1951
1952 axPos *= parentRot; 1948 axPos *= parentRot;
1953 Vector3 translationOffsetPosition = axPos; 1949 Vector3 translationOffsetPosition = axPos;
1954 1950 if(_parentID == 0)
1955// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 1951 return GroupPosition;
1956 1952 else
1957 Vector3 worldPos = GroupPosition + translationOffsetPosition; 1953 return ParentGroup.AbsolutePosition + translationOffsetPosition;
1958
1959// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name);
1960
1961 return worldPos;
1962 } 1954 }
1963 1955
1964 /// <summary> 1956 /// <summary>
@@ -2689,11 +2681,6 @@ namespace OpenSim.Region.Framework.Scenes
2689 2681
2690 public void RotLookAt(Quaternion target, float strength, float damping) 2682 public void RotLookAt(Quaternion target, float strength, float damping)
2691 { 2683 {
2692 rotLookAt(target, strength, damping);
2693 }
2694
2695 public void rotLookAt(Quaternion target, float strength, float damping)
2696 {
2697 if (ParentGroup.IsAttachment) 2684 if (ParentGroup.IsAttachment)
2698 { 2685 {
2699 /* 2686 /*
@@ -2708,17 +2695,26 @@ namespace OpenSim.Region.Framework.Scenes
2708 APIDDamp = damping; 2695 APIDDamp = damping;
2709 APIDStrength = strength; 2696 APIDStrength = strength;
2710 APIDTarget = target; 2697 APIDTarget = target;
2698
2699 if (APIDStrength <= 0)
2700 {
2701 m_log.WarnFormat("[SceneObjectPart] Invalid rotation strength {0}",APIDStrength);
2702 return;
2703 }
2704
2705 m_APIDIterations = 1 + (int)(Math.PI * APIDStrength);
2711 } 2706 }
2707
2708 // Necessary to get the lookat deltas applied
2709 ParentGroup.QueueForUpdateCheck();
2712 } 2710 }
2713 2711
2714 public void startLookAt(Quaternion rot, float damp, float strength) 2712 public void StartLookAt(Quaternion target, float strength, float damping)
2715 { 2713 {
2716 APIDDamp = damp; 2714 RotLookAt(target,strength,damping);
2717 APIDStrength = strength;
2718 APIDTarget = rot;
2719 } 2715 }
2720 2716
2721 public void stopLookAt() 2717 public void StopLookAt()
2722 { 2718 {
2723 APIDTarget = Quaternion.Identity; 2719 APIDTarget = Quaternion.Identity;
2724 } 2720 }
@@ -3413,13 +3409,6 @@ namespace OpenSim.Region.Framework.Scenes
3413 } 3409 }
3414 } 3410 }
3415 3411
3416 public void StopLookAt()
3417 {
3418 ParentGroup.stopLookAt();
3419
3420 ParentGroup.ScheduleGroupForTerseUpdate();
3421 }
3422
3423 /// <summary> 3412 /// <summary>
3424 /// Set the text displayed for this part. 3413 /// Set the text displayed for this part.
3425 /// </summary> 3414 /// </summary>
@@ -4521,10 +4510,18 @@ namespace OpenSim.Region.Framework.Scenes
4521 /// <summary> 4510 /// <summary>
4522 /// Update the texture entry for this part. 4511 /// Update the texture entry for this part.
4523 /// </summary> 4512 /// </summary>
4524 /// <param name="textureEntry"></param> 4513 /// <param name="serializedTextureEntry"></param>
4525 public void UpdateTextureEntry(byte[] textureEntry) 4514 public void UpdateTextureEntry(byte[] serializedTextureEntry)
4515 {
4516 UpdateTextureEntry(new Primitive.TextureEntry(serializedTextureEntry, 0, serializedTextureEntry.Length));
4517 }
4518
4519 /// <summary>
4520 /// Update the texture entry for this part.
4521 /// </summary>
4522 /// <param name="newTex"></param>
4523 public void UpdateTextureEntry(Primitive.TextureEntry newTex)
4526 { 4524 {
4527 Primitive.TextureEntry newTex = new Primitive.TextureEntry(textureEntry, 0, textureEntry.Length);
4528 Primitive.TextureEntry oldTex = Shape.Textures; 4525 Primitive.TextureEntry oldTex = Shape.Textures;
4529 4526
4530 Changed changeFlags = 0; 4527 Changed changeFlags = 0;
@@ -4556,7 +4553,7 @@ namespace OpenSim.Region.Framework.Scenes
4556 break; 4553 break;
4557 } 4554 }
4558 4555
4559 m_shape.TextureEntry = textureEntry; 4556 m_shape.TextureEntry = newTex.GetBytes();
4560 if (changeFlags != 0) 4557 if (changeFlags != 0)
4561 TriggerScriptChangedEvent(changeFlags); 4558 TriggerScriptChangedEvent(changeFlags);
4562 UpdateFlag = UpdateRequired.FULL; 4559 UpdateFlag = UpdateRequired.FULL;
@@ -4727,24 +4724,20 @@ namespace OpenSim.Region.Framework.Scenes
4727 { 4724 {
4728 if (APIDTarget != Quaternion.Identity) 4725 if (APIDTarget != Quaternion.Identity)
4729 { 4726 {
4730 if (Single.IsNaN(APIDTarget.W) == true) 4727 if (m_APIDIterations <= 1)
4731 { 4728 {
4729 UpdateRotation(APIDTarget);
4732 APIDTarget = Quaternion.Identity; 4730 APIDTarget = Quaternion.Identity;
4733 return; 4731 return;
4734 } 4732 }
4735 Quaternion rot = RotationOffset; 4733
4736 Quaternion dir = (rot - APIDTarget); 4734 Quaternion rot = Quaternion.Slerp(RotationOffset,APIDTarget,1.0f/(float)m_APIDIterations);
4737 float speed = ((APIDStrength / APIDDamp) * (float)(Math.PI / 180.0f));
4738 if (dir.Z > speed)
4739 {
4740 rot.Z -= speed;
4741 }
4742 if (dir.Z < -speed)
4743 {
4744 rot.Z += speed;
4745 }
4746 rot.Normalize();
4747 UpdateRotation(rot); 4735 UpdateRotation(rot);
4736
4737 m_APIDIterations--;
4738
4739 // This ensures that we'll check this object on the next iteration
4740 ParentGroup.QueueForUpdateCheck();
4748 } 4741 }
4749 } 4742 }
4750 catch (Exception ex) 4743 catch (Exception ex)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 42cd4be..5c56150 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -40,6 +40,7 @@ using OpenSim.Region.Framework.Scenes.Types;
40using OpenSim.Region.Physics.Manager; 40using OpenSim.Region.Physics.Manager;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags;
43 44
44namespace OpenSim.Region.Framework.Scenes 45namespace OpenSim.Region.Framework.Scenes
45{ 46{
@@ -892,6 +893,8 @@ namespace OpenSim.Region.Framework.Scenes
892 pos.Y = crossedBorder.BorderLine.Z - 1; 893 pos.Y = crossedBorder.BorderLine.Z - 1;
893 } 894 }
894 895
896 CheckAndAdjustLandingPoint(ref pos);
897
895 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 898 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
896 { 899 {
897 m_log.WarnFormat( 900 m_log.WarnFormat(
@@ -1056,6 +1059,7 @@ namespace OpenSim.Region.Framework.Scenes
1056 bool isFlying = Flying; 1059 bool isFlying = Flying;
1057 RemoveFromPhysicalScene(); 1060 RemoveFromPhysicalScene();
1058 Velocity = Vector3.Zero; 1061 Velocity = Vector3.Zero;
1062 CheckLandingPoint(ref pos);
1059 AbsolutePosition = pos; 1063 AbsolutePosition = pos;
1060 AddToPhysicalScene(isFlying); 1064 AddToPhysicalScene(isFlying);
1061 1065
@@ -1066,6 +1070,7 @@ namespace OpenSim.Region.Framework.Scenes
1066 { 1070 {
1067 bool isFlying = Flying; 1071 bool isFlying = Flying;
1068 RemoveFromPhysicalScene(); 1072 RemoveFromPhysicalScene();
1073 CheckLandingPoint(ref pos);
1069 AbsolutePosition = pos; 1074 AbsolutePosition = pos;
1070 AddToPhysicalScene(isFlying); 1075 AddToPhysicalScene(isFlying);
1071 1076
@@ -1180,6 +1185,7 @@ namespace OpenSim.Region.Framework.Scenes
1180 client.Name, Scene.RegionInfo.RegionName, AbsolutePosition); 1185 client.Name, Scene.RegionInfo.RegionName, AbsolutePosition);
1181 1186
1182 Vector3 look = Velocity; 1187 Vector3 look = Velocity;
1188
1183 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1189 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1184 { 1190 {
1185 look = new Vector3(0.99f, 0.042f, 0); 1191 look = new Vector3(0.99f, 0.042f, 0);
@@ -1206,7 +1212,7 @@ namespace OpenSim.Region.Framework.Scenes
1206 m_callbackURI = null; 1212 m_callbackURI = null;
1207 } 1213 }
1208 1214
1209 //m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); 1215// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1210 1216
1211 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 1217 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1212 ValidateAndSendAppearanceAndAgentData(); 1218 ValidateAndSendAppearanceAndAgentData();
@@ -1274,8 +1280,8 @@ namespace OpenSim.Region.Framework.Scenes
1274 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 1280 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
1275 { 1281 {
1276// m_log.DebugFormat( 1282// m_log.DebugFormat(
1277// "[SCENE PRESENCE]: In {0} received agent update from {1}", 1283// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
1278// Scene.RegionInfo.RegionName, remoteClient.Name); 1284// Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags);
1279 1285
1280 if (IsChildAgent) 1286 if (IsChildAgent)
1281 { 1287 {
@@ -2312,6 +2318,8 @@ namespace OpenSim.Region.Framework.Scenes
2312 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> 2318 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param>
2313 public void AddNewMovement(Vector3 vec) 2319 public void AddNewMovement(Vector3 vec)
2314 { 2320 {
2321// m_log.DebugFormat("[SCENE PRESENCE]: Adding new movement {0} for {1}", vec, Name);
2322
2315 Vector3 direc = vec * Rotation; 2323 Vector3 direc = vec * Rotation;
2316 direc.Normalize(); 2324 direc.Normalize();
2317 2325
@@ -3801,5 +3809,146 @@ namespace OpenSim.Region.Framework.Scenes
3801 m_reprioritization_called = false; 3809 m_reprioritization_called = false;
3802 } 3810 }
3803 } 3811 }
3812
3813 private void CheckLandingPoint(ref Vector3 pos)
3814 {
3815 // Never constrain lures
3816 if ((TeleportFlags & TeleportFlags.ViaLure) != 0)
3817 return;
3818
3819 if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
3820 return;
3821
3822 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3823
3824 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3825 land.LandData.UserLocation != Vector3.Zero &&
3826 land.LandData.OwnerID != m_uuid &&
3827 (!m_scene.Permissions.IsGod(m_uuid)) &&
3828 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)))
3829 {
3830 float curr = Vector3.Distance(AbsolutePosition, pos);
3831 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
3832 pos = land.LandData.UserLocation;
3833 else
3834 ControllingClient.SendAlertMessage("Can't teleport closer to destination");
3835 }
3836 }
3837
3838 private void CheckAndAdjustTelehub(SceneObjectGroup telehub, ref Vector3 pos)
3839 {
3840 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) ==
3841 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
3842 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
3843 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
3844 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
3845 {
3846 if (GodLevel < 200 &&
3847 ((!m_scene.Permissions.IsGod(m_uuid) &&
3848 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) ||
3849 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
3850 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
3851 {
3852 SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray();
3853 if (spawnPoints.Length == 0)
3854 return;
3855
3856 float distance = 9999;
3857 int closest = -1;
3858
3859 for (int i = 0 ; i < spawnPoints.Length ; i++)
3860 {
3861 Vector3 spawnPosition = spawnPoints[i].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
3862 Vector3 offset = spawnPosition - pos;
3863 float d = Vector3.Mag(offset);
3864 if (d >= distance)
3865 continue;
3866 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
3867 if (land == null)
3868 continue;
3869 if (land.IsEitherBannedOrRestricted(UUID))
3870 continue;
3871 distance = d;
3872 closest = i;
3873 }
3874 if (closest == -1)
3875 return;
3876
3877 pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
3878 }
3879 }
3880 }
3881
3882 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3883 {
3884 SceneObjectGroup telehub = null;
3885 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null)
3886 {
3887 if (!m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
3888 {
3889 CheckAndAdjustTelehub(telehub, ref pos);
3890 return;
3891 }
3892 }
3893
3894 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3895 if (land != null)
3896 {
3897 if (Scene.DEBUG)
3898 TeleportFlagsDebug();
3899
3900 // If we come in via login, landmark or map, we want to
3901 // honor landing points. If we come in via Lure, we want
3902 // to ignore them.
3903 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) ==
3904 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
3905 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
3906 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
3907 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
3908 {
3909 // Don't restrict gods, estate managers, or land owners to
3910 // the TP point. This behaviour mimics agni.
3911 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3912 land.LandData.UserLocation != Vector3.Zero &&
3913 GodLevel < 200 &&
3914 ((land.LandData.OwnerID != m_uuid &&
3915 !m_scene.Permissions.IsGod(m_uuid) &&
3916 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) ||
3917 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
3918 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
3919 {
3920 pos = land.LandData.UserLocation;
3921 }
3922 }
3923
3924 land.SendLandUpdateToClient(ControllingClient);
3925 }
3926 }
3927
3928 private void TeleportFlagsDebug() {
3929
3930 // Some temporary debugging help to show all the TeleportFlags we have...
3931 bool HG = false;
3932 if((m_teleportFlags & TeleportFlags.ViaHGLogin) == TeleportFlags.ViaHGLogin)
3933 HG = true;
3934
3935 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
3936
3937 uint i = 0u;
3938 for (int x = 0; x <= 30 ; x++, i = 1u << x)
3939 {
3940 i = 1u << x;
3941
3942 if((m_teleportFlags & (TeleportFlags)i) == (TeleportFlags)i)
3943 if (HG == false)
3944 m_log.InfoFormat("[SCENE PRESENCE]: Teleport Flags include {0}", ((TeleportFlags) i).ToString());
3945 else
3946 m_log.InfoFormat("[SCENE PRESENCE]: HG Teleport Flags include {0}", ((TeleportFlags)i).ToString());
3947 }
3948
3949 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
3950
3951 }
3952
3804 } 3953 }
3805} 3954}
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index bca49f7..3a08271 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
54 /// Deserialize a scene object from the original xml format 54 /// Deserialize a scene object from the original xml format
55 /// </summary> 55 /// </summary>
56 /// <param name="xmlData"></param> 56 /// <param name="xmlData"></param>
57 /// <returns></returns> 57 /// <returns>The scene object deserialized. Null on failure.</returns>
58 public static SceneObjectGroup FromOriginalXmlFormat(string xmlData) 58 public static SceneObjectGroup FromOriginalXmlFormat(string xmlData)
59 { 59 {
60 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 60 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
@@ -1134,12 +1134,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1134 1134
1135 if (sop.CreatorData != null && sop.CreatorData != string.Empty) 1135 if (sop.CreatorData != null && sop.CreatorData != string.Empty)
1136 writer.WriteElementString("CreatorData", sop.CreatorData); 1136 writer.WriteElementString("CreatorData", sop.CreatorData);
1137 else if (options.ContainsKey("profile")) 1137 else if (options.ContainsKey("home"))
1138 { 1138 {
1139 if (m_UserManagement == null) 1139 if (m_UserManagement == null)
1140 m_UserManagement = sop.ParentGroup.Scene.RequestModuleInterface<IUserManagement>(); 1140 m_UserManagement = sop.ParentGroup.Scene.RequestModuleInterface<IUserManagement>();
1141 string name = m_UserManagement.GetUserName(sop.CreatorID); 1141 string name = m_UserManagement.GetUserName(sop.CreatorID);
1142 writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + sop.CreatorID + ";" + name); 1142 writer.WriteElementString("CreatorData", (string)options["home"] + ";" + name);
1143 } 1143 }
1144 1144
1145 WriteUUID(writer, "FolderID", sop.FolderID, options); 1145 WriteUUID(writer, "FolderID", sop.FolderID, options);
@@ -1192,8 +1192,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1192 writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString()); 1192 writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString());
1193 writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString()); 1193 writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString());
1194 WriteUUID(writer, "GroupID", sop.GroupID, options); 1194 WriteUUID(writer, "GroupID", sop.GroupID, options);
1195 WriteUUID(writer, "OwnerID", sop.OwnerID, options); 1195
1196 WriteUUID(writer, "LastOwnerID", sop.LastOwnerID, options); 1196 UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.OwnerID;
1197 WriteUUID(writer, "OwnerID", ownerID, options);
1198
1199 UUID lastOwnerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.LastOwnerID;
1200 WriteUUID(writer, "LastOwnerID", lastOwnerID, options);
1201
1197 writer.WriteElementString("BaseMask", sop.BaseMask.ToString()); 1202 writer.WriteElementString("BaseMask", sop.BaseMask.ToString());
1198 writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString()); 1203 writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString());
1199 writer.WriteElementString("GroupMask", sop.GroupMask.ToString()); 1204 writer.WriteElementString("GroupMask", sop.GroupMask.ToString());
@@ -1277,17 +1282,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1277 writer.WriteElementString("BasePermissions", item.BasePermissions.ToString()); 1282 writer.WriteElementString("BasePermissions", item.BasePermissions.ToString());
1278 writer.WriteElementString("CreationDate", item.CreationDate.ToString()); 1283 writer.WriteElementString("CreationDate", item.CreationDate.ToString());
1279 1284
1280
1281 WriteUUID(writer, "CreatorID", item.CreatorID, options); 1285 WriteUUID(writer, "CreatorID", item.CreatorID, options);
1282 1286
1283 if (item.CreatorData != null && item.CreatorData != string.Empty) 1287 if (item.CreatorData != null && item.CreatorData != string.Empty)
1284 writer.WriteElementString("CreatorData", item.CreatorData); 1288 writer.WriteElementString("CreatorData", item.CreatorData);
1285 else if (options.ContainsKey("profile")) 1289 else if (options.ContainsKey("home"))
1286 { 1290 {
1287 if (m_UserManagement == null) 1291 if (m_UserManagement == null)
1288 m_UserManagement = scene.RequestModuleInterface<IUserManagement>(); 1292 m_UserManagement = scene.RequestModuleInterface<IUserManagement>();
1289 string name = m_UserManagement.GetUserName(item.CreatorID); 1293 string name = m_UserManagement.GetUserName(item.CreatorID);
1290 writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + item.CreatorID + ";" + name); 1294 writer.WriteElementString("CreatorData", (string)options["home"] + ";" + name);
1291 } 1295 }
1292 1296
1293 writer.WriteElementString("Description", item.Description); 1297 writer.WriteElementString("Description", item.Description);
@@ -1298,10 +1302,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1298 writer.WriteElementString("InvType", item.InvType.ToString()); 1302 writer.WriteElementString("InvType", item.InvType.ToString());
1299 WriteUUID(writer, "ItemID", item.ItemID, options); 1303 WriteUUID(writer, "ItemID", item.ItemID, options);
1300 WriteUUID(writer, "OldItemID", item.OldItemID, options); 1304 WriteUUID(writer, "OldItemID", item.OldItemID, options);
1301 WriteUUID(writer, "LastOwnerID", item.LastOwnerID, options); 1305
1306 UUID lastOwnerID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.LastOwnerID;
1307 WriteUUID(writer, "LastOwnerID", lastOwnerID, options);
1308
1302 writer.WriteElementString("Name", item.Name); 1309 writer.WriteElementString("Name", item.Name);
1303 writer.WriteElementString("NextPermissions", item.NextPermissions.ToString()); 1310 writer.WriteElementString("NextPermissions", item.NextPermissions.ToString());
1304 WriteUUID(writer, "OwnerID", item.OwnerID, options); 1311
1312 UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.OwnerID;
1313 WriteUUID(writer, "OwnerID", ownerID, options);
1314
1305 writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString()); 1315 writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString());
1306 WriteUUID(writer, "ParentID", item.ParentID, options); 1316 WriteUUID(writer, "ParentID", item.ParentID, options);
1307 WriteUUID(writer, "ParentPartID", item.ParentPartID, options); 1317 WriteUUID(writer, "ParentPartID", item.ParentPartID, options);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
new file mode 100644
index 0000000..6f99abd
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
@@ -0,0 +1,76 @@
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 NUnit.Framework;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Tests.Common;
38using OpenSim.Tests.Common.Mock;
39
40namespace OpenSim.Region.Framework.Scenes.Tests
41{
42 [TestFixture]
43 public class SceneObjectScriptTests
44 {
45 [Test]
46 public void TestAddScript()
47 {
48 TestHelpers.InMethod();
49// log4net.Config.XmlConfigurator.Configure();
50
51 UUID userId = TestHelpers.ParseTail(0x1);
52 UUID itemId = TestHelpers.ParseTail(0x2);
53 string itemName = "Test Script Item";
54
55 Scene scene = SceneHelpers.SetupScene();
56 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
57 scene.AddNewSceneObject(so, true);
58
59 InventoryItemBase itemTemplate = new InventoryItemBase();
60 itemTemplate.Name = itemName;
61 itemTemplate.Folder = so.UUID;
62 itemTemplate.InvType = (int)InventoryType.LSL;
63
64 SceneObjectPart partWhereScriptAdded = scene.RezNewScript(userId, itemTemplate);
65
66 Assert.That(partWhereScriptAdded, Is.Not.Null);
67
68 IEntityInventory primInventory = partWhereScriptAdded.Inventory;
69 Assert.That(primInventory.GetInventoryList().Count, Is.EqualTo(1));
70 Assert.That(primInventory.ContainsScripts(), Is.True);
71
72 IList<TaskInventoryItem> primItems = primInventory.GetInventoryItems(itemName);
73 Assert.That(primItems.Count, Is.EqualTo(1));
74 }
75 }
76} \ No newline at end of file