aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2017-04-25 17:59:53 +0100
committerUbitUmarov2017-04-25 17:59:53 +0100
commita680d8b8d700f78beb1a9eea98b52d59118efe2e (patch)
treedd084e74fb61400c704a14dcfa8689670acb9ec2 /OpenSim/Region
parentMerge branch 'master' into httptests (diff)
parentmove mesh pbs creation code out of mesh upload code into to PrimitiveBaseShap... (diff)
downloadopensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.zip
opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.gz
opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.bz2
opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.xz
fix merge
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/OpenSim.cs1
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs7
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs59
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs10
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs1
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs234
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs5
-rw-r--r--OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs10
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs46
-rw-r--r--OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs47
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs93
-rw-r--r--OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs94
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs58
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs26
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs8
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs23
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs26
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs22
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs17
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs35
-rw-r--r--OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs1889
-rw-r--r--OpenSim/Region/CoreModules/World/Region/RestartModule.cs43
-rw-r--r--OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs3
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEtcdModule.cs37
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/GodController.cs20
-rw-r--r--OpenSim/Region/Framework/Scenes/KeyframeMotion.cs133
-rw-r--r--OpenSim/Region/Framework/Scenes/Prioritizer.cs23
-rw-r--r--OpenSim/Region/Framework/Scenes/SOPMaterial.cs82
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs353
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs441
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs211
-rwxr-xr-xOpenSim/Region/Framework/Scenes/SceneGraph.cs138
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs297
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs645
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs149
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs35
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs110
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs28
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs37
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs7
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs25
-rw-r--r--OpenSim/Region/OptionalModules/Framework/Monitoring/EtcdMonitoringModule.cs195
-rw-r--r--OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs103
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs6
-rw-r--r--OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs4
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs18
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs487
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs79
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs320
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs310
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs35
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs13
73 files changed, 5007 insertions, 2220 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 8022b1e..58178bc 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -211,6 +211,7 @@ namespace OpenSim
211 if (managedStatsURI != String.Empty) 211 if (managedStatsURI != String.Empty)
212 { 212 {
213 string urlBase = String.Format("/{0}/", managedStatsURI); 213 string urlBase = String.Format("/{0}/", managedStatsURI);
214 StatsManager.StatsPassword = managedStatsPassword;
214 MainServer.Instance.AddHTTPHandler(urlBase, StatsManager.HandleStatsRequest); 215 MainServer.Instance.AddHTTPHandler(urlBase, StatsManager.HandleStatsRequest);
215 m_log.InfoFormat("[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase); 216 m_log.InfoFormat("[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase);
216 } 217 }
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 75dc741..079d733 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -88,6 +88,7 @@ namespace OpenSim
88 88
89 public string userStatsURI = String.Empty; 89 public string userStatsURI = String.Empty;
90 public string managedStatsURI = String.Empty; 90 public string managedStatsURI = String.Empty;
91 public string managedStatsPassword = String.Empty;
91 92
92 protected bool m_autoCreateClientStack = true; 93 protected bool m_autoCreateClientStack = true;
93 94
@@ -239,6 +240,7 @@ namespace OpenSim
239 m_permsModules = new List<string>(permissionModules.Split(',')); 240 m_permsModules = new List<string>(permissionModules.Split(','));
240 241
241 managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty); 242 managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty);
243 managedStatsPassword = startupConfig.GetString("ManagedStatsRemoteFetchPassword", String.Empty);
242 } 244 }
243 245
244 // Load the simulation data service 246 // Load the simulation data service
@@ -481,15 +483,14 @@ namespace OpenSim
481 while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) 483 while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
482 SetUpEstateOwner(scene); 484 SetUpEstateOwner(scene);
483 485
486 scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
487
484 // Prims have to be loaded after module configuration since some modules may be invoked during the load 488 // Prims have to be loaded after module configuration since some modules may be invoked during the load
485 scene.LoadPrimsFromStorage(regionInfo.originRegionID); 489 scene.LoadPrimsFromStorage(regionInfo.originRegionID);
486 490
487 // TODO : Try setting resource for region xstats here on scene 491 // TODO : Try setting resource for region xstats here on scene
488 MainServer.Instance.AddStreamHandler(new RegionStatsHandler(regionInfo)); 492 MainServer.Instance.AddStreamHandler(new RegionStatsHandler(regionInfo));
489 493
490 scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
491 scene.EventManager.TriggerParcelPrimCountUpdate();
492
493 if (scene.SnmpService != null) 494 if (scene.SnmpService != null)
494 { 495 {
495 scene.SnmpService.BootInfo("Grid Registration in progress", scene); 496 scene.SnmpService.BootInfo("Grid Registration in progress", scene);
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 58b7b00..e1b9e08 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -946,17 +946,26 @@ namespace OpenSim.Region.ClientStack.Linden
946 continue; 946 continue;
947 } 947 }
948 948
949 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); 949 OSDArray face_list = (OSDArray)inner_instance_list["face_list"];
950
951 PrimitiveBaseShape pbs = null;
952 if (inner_instance_list.ContainsKey("mesh")) // seems to happen always but ...
953 {
954 int meshindx = inner_instance_list["mesh"].AsInteger();
955 if (meshAssets.Count > meshindx)
956 pbs = PrimitiveBaseShape.CreateMesh(face_list.Count, meshAssets[meshindx]);
957 }
958 if(pbs == null) // fallback
959 pbs = PrimitiveBaseShape.CreateBox();
950 960
951 Primitive.TextureEntry textureEntry 961 Primitive.TextureEntry textureEntry
952 = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); 962 = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
953 963
954
955 OSDArray face_list = (OSDArray)inner_instance_list["face_list"];
956 for (uint face = 0; face < face_list.Count; face++) 964 for (uint face = 0; face < face_list.Count; face++)
957 { 965 {
958 OSDMap faceMap = (OSDMap)face_list[(int)face]; 966 OSDMap faceMap = (OSDMap)face_list[(int)face];
959 Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face); 967
968 Primitive.TextureEntryFace f = textureEntry.CreateFace(face); //clone the default
960 if (faceMap.ContainsKey("fullbright")) 969 if (faceMap.ContainsKey("fullbright"))
961 f.Fullbright = faceMap["fullbright"].AsBoolean(); 970 f.Fullbright = faceMap["fullbright"].AsBoolean();
962 if (faceMap.ContainsKey("diffuse_color")) 971 if (faceMap.ContainsKey("diffuse_color"))
@@ -986,51 +995,11 @@ namespace OpenSim.Region.ClientStack.Linden
986 995
987 if (textures.Count > textureNum) 996 if (textures.Count > textureNum)
988 f.TextureID = textures[textureNum]; 997 f.TextureID = textures[textureNum];
989 else 998
990 f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE;
991
992 textureEntry.FaceTextures[face] = f; 999 textureEntry.FaceTextures[face] = f;
993 } 1000 }
994
995 pbs.TextureEntry = textureEntry.GetBytes(); 1001 pbs.TextureEntry = textureEntry.GetBytes();
996 1002
997 if (inner_instance_list.ContainsKey("mesh")) // seems to happen always but ...
998 {
999 int meshindx = inner_instance_list["mesh"].AsInteger();
1000 if (meshAssets.Count > meshindx)
1001 {
1002 pbs.SculptEntry = true;
1003 pbs.SculptType = (byte)SculptType.Mesh;
1004 pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction
1005 // data will be requested from asset on rez (i hope)
1006 }
1007 }
1008
1009 // faces number to pbs shape
1010 switch(face_list.Count)
1011 {
1012 case 1:
1013 case 2:
1014 pbs.ProfileCurve = (byte)ProfileCurve.Circle;
1015 pbs.PathCurve = (byte)PathCurve.Circle;
1016 break;
1017
1018 case 3:
1019 case 4:
1020 pbs.ProfileCurve = (byte)ProfileCurve.Circle;
1021 pbs.PathCurve = (byte)PathCurve.Line;
1022 break;
1023 case 5:
1024 pbs.ProfileCurve = (byte)ProfileCurve.EqualTriangle;
1025 pbs.PathCurve = (byte)PathCurve.Line;
1026 break;
1027
1028 default:
1029 pbs.ProfileCurve = (byte)ProfileCurve.Square;
1030 pbs.PathCurve = (byte)PathCurve.Line;
1031 break;
1032 }
1033
1034 Vector3 position = inner_instance_list["position"].AsVector3(); 1003 Vector3 position = inner_instance_list["position"].AsVector3();
1035 Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); 1004 Quaternion rotation = inner_instance_list["rotation"].AsQuaternion();
1036 1005
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
index 189fa36..69fcb7d 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
@@ -121,6 +121,9 @@ namespace OpenSim.Region.ClientStack.Linden
121 121
122 122
123 OSD r = OSDParser.DeserializeLLSDXml((string)request["requestbody"]); 123 OSD r = OSDParser.DeserializeLLSDXml((string)request["requestbody"]);
124 if (r.Type != OSDType.Map) // not a proper req
125 return responsedata;
126
124 //UUID session_id = UUID.Zero; 127 //UUID session_id = UUID.Zero;
125 bool bypass_raycast = false; 128 bool bypass_raycast = false;
126 uint everyone_mask = 0; 129 uint everyone_mask = 0;
@@ -157,9 +160,6 @@ namespace OpenSim.Region.ClientStack.Linden
157 int state = 0; 160 int state = 0;
158 int lastattach = 0; 161 int lastattach = 0;
159 162
160 if (r.Type != OSDType.Map) // not a proper req
161 return responsedata;
162
163 OSDMap rm = (OSDMap)r; 163 OSDMap rm = (OSDMap)r;
164 164
165 if (rm.ContainsKey("ObjectData")) //v2 165 if (rm.ContainsKey("ObjectData")) //v2
@@ -307,8 +307,6 @@ namespace OpenSim.Region.ClientStack.Linden
307 } 307 }
308 } 308 }
309 309
310
311
312 Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false); 310 Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false);
313 311
314 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); 312 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
@@ -359,6 +357,8 @@ namespace OpenSim.Region.ClientStack.Linden
359 rootpart.NextOwnerMask = next_owner_mask; 357 rootpart.NextOwnerMask = next_owner_mask;
360 rootpart.Material = (byte)material; 358 rootpart.Material = (byte)material;
361 359
360 obj.AggregatePerms();
361
362 m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); 362 m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
363 363
364 responsedata["int_response_code"] = 200; //501; //410; //404; 364 responsedata["int_response_code"] = 200; //501; //410; //404;
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
index 6874662..116c51f 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
@@ -335,6 +335,7 @@ namespace OpenSim.Region.ClientStack.Linden
335 grp.AbsolutePosition = obj.Position; 335 grp.AbsolutePosition = obj.Position;
336 prim.RotationOffset = obj.Rotation; 336 prim.RotationOffset = obj.Rotation;
337 337
338
338 // Required for linking 339 // Required for linking
339 grp.RootPart.ClearUpdateSchedule(); 340 grp.RootPart.ClearUpdateSchedule();
340 341
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index df34668..cf96a8b 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -3950,24 +3950,68 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3950 /// <summary> 3950 /// <summary>
3951 /// Send an ObjectUpdate packet with information about an avatar 3951 /// Send an ObjectUpdate packet with information about an avatar
3952 /// </summary> 3952 /// </summary>
3953 public void SendAvatarDataImmediate(ISceneEntity avatar) 3953 public void SendEntityFullUpdateImmediate(ISceneEntity ent)
3954 { 3954 {
3955// m_log.DebugFormat( 3955// m_log.DebugFormat(
3956// "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}", 3956// "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
3957// avatar.Name, avatar.UUID, Name, AgentId); 3957// avatar.Name, avatar.UUID, Name, AgentId);
3958 3958
3959 ScenePresence presence = avatar as ScenePresence; 3959 if (ent == null)
3960 if (presence == null)
3961 return; 3960 return;
3962 3961
3963 ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate); 3962 ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
3964 objupdate.Header.Zerocoded = true; 3963 objupdate.Header.Zerocoded = true;
3965 3964
3966 objupdate.RegionData.RegionHandle = presence.RegionHandle;
3967// objupdate.RegionData.TimeDilation = ushort.MaxValue;
3968 objupdate.RegionData.TimeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f); 3965 objupdate.RegionData.TimeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
3969 objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 3966 objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
3970 objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence); 3967
3968 if(ent is ScenePresence)
3969 {
3970 ScenePresence presence = ent as ScenePresence;
3971 objupdate.RegionData.RegionHandle = presence.RegionHandle;
3972 objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
3973 }
3974 else if(ent is SceneObjectPart)
3975 {
3976 SceneObjectPart part = ent as SceneObjectPart;
3977 objupdate.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
3978 objupdate.ObjectData[0] = CreatePrimUpdateBlock(part, (ScenePresence)SceneAgent);
3979 }
3980
3981 OutPacket(objupdate, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
3982
3983 // We need to record the avatar local id since the root prim of an attachment points to this.
3984// m_attachmentsSent.Add(avatar.LocalId);
3985 }
3986
3987 public void SendEntityTerseUpdateImmediate(ISceneEntity ent)
3988 {
3989// m_log.DebugFormat(
3990// "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
3991// avatar.Name, avatar.UUID, Name, AgentId);
3992
3993 if (ent == null)
3994 return;
3995
3996 ImprovedTerseObjectUpdatePacket objupdate =
3997 (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
3998 objupdate.Header.Zerocoded = true;
3999
4000 objupdate.RegionData.TimeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
4001 objupdate.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
4002
4003 if(ent is ScenePresence)
4004 {
4005 ScenePresence presence = ent as ScenePresence;
4006 objupdate.RegionData.RegionHandle = presence.RegionHandle;
4007 objupdate.ObjectData[0] = CreateImprovedTerseBlock(ent, false);
4008 }
4009 else if(ent is SceneObjectPart)
4010 {
4011 SceneObjectPart part = ent as SceneObjectPart;
4012 objupdate.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
4013 objupdate.ObjectData[0] = CreateImprovedTerseBlock(ent, false);
4014 }
3971 4015
3972 OutPacket(objupdate, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority); 4016 OutPacket(objupdate, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
3973 4017
@@ -4021,7 +4065,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4021 4065
4022 #region Primitive Packet/Data Sending Methods 4066 #region Primitive Packet/Data Sending Methods
4023 4067
4024
4025 /// <summary> 4068 /// <summary>
4026 /// Generate one of the object update packets based on PrimUpdateFlags 4069 /// Generate one of the object update packets based on PrimUpdateFlags
4027 /// and broadcast the packet to clients 4070 /// and broadcast the packet to clients
@@ -4044,10 +4087,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4044*/ 4087*/
4045 if (entity is SceneObjectPart) 4088 if (entity is SceneObjectPart)
4046 { 4089 {
4047 SceneObjectPart e = (SceneObjectPart)entity; 4090 SceneObjectPart p = (SceneObjectPart)entity;
4048 SceneObjectGroup g = e.ParentGroup; 4091 SceneObjectGroup g = p.ParentGroup;
4049 if (g.HasPrivateAttachmentPoint && g.OwnerID != AgentId) 4092 if (g.HasPrivateAttachmentPoint && g.OwnerID != AgentId)
4050 return; // Don't send updates for other people's HUDs 4093 return; // Don't send updates for other people's HUDs
4094
4095 if((updateFlags ^ PrimUpdateFlags.SendInTransit) == 0)
4096 {
4097 List<uint> partIDs = (new List<uint> {p.LocalId});
4098 lock (m_entityProps.SyncRoot)
4099 m_entityProps.Remove(partIDs);
4100 lock (m_entityUpdates.SyncRoot)
4101 m_entityUpdates.Remove(partIDs);
4102 return;
4103 }
4051 } 4104 }
4052 4105
4053 //double priority = m_prioritizer.GetUpdatePriority(this, entity); 4106 //double priority = m_prioritizer.GetUpdatePriority(this, entity);
@@ -4126,14 +4179,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4126// Vector3 mycamera = Vector3.Zero; 4179// Vector3 mycamera = Vector3.Zero;
4127 Vector3 mypos = Vector3.Zero; 4180 Vector3 mypos = Vector3.Zero;
4128 ScenePresence mysp = (ScenePresence)SceneAgent; 4181 ScenePresence mysp = (ScenePresence)SceneAgent;
4129 if(mysp != null && !mysp.IsDeleted) 4182
4183 // we should have a presence
4184 if(mysp == null)
4185 return;
4186
4187 if(doCulling)
4130 { 4188 {
4131 cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f; 4189 cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f;
4132// mycamera = mysp.CameraPosition; 4190// mycamera = mysp.CameraPosition;
4133 mypos = mysp.AbsolutePosition; 4191 mypos = mysp.AbsolutePosition;
4134 } 4192 }
4135 else
4136 doCulling = false;
4137 4193
4138 while (maxUpdatesBytes > 0) 4194 while (maxUpdatesBytes > 0)
4139 { 4195 {
@@ -4154,9 +4210,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4154 { 4210 {
4155 SceneObjectPart part = (SceneObjectPart)update.Entity; 4211 SceneObjectPart part = (SceneObjectPart)update.Entity;
4156 SceneObjectGroup grp = part.ParentGroup; 4212 SceneObjectGroup grp = part.ParentGroup;
4157 if (grp.inTransit) 4213 if (grp.inTransit && !update.Flags.HasFlag(PrimUpdateFlags.SendInTransit))
4158 continue; 4214 continue;
4215/* debug
4216 if (update.Flags.HasFlag(PrimUpdateFlags.SendInTransit))
4217 {
4218
4159 4219
4220 }
4221*/
4160 if (grp.IsDeleted) 4222 if (grp.IsDeleted)
4161 { 4223 {
4162 // Don't send updates for objects that have been marked deleted. 4224 // Don't send updates for objects that have been marked deleted.
@@ -4213,14 +4275,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4213 { 4275 {
4214 part.Shape.LightEntry = false; 4276 part.Shape.LightEntry = false;
4215 } 4277 }
4216
4217 if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh))
4218 {
4219 // Ensure that mesh has at least 8 valid faces
4220 part.Shape.ProfileBegin = 12500;
4221 part.Shape.ProfileEnd = 0;
4222 part.Shape.ProfileHollow = 27500;
4223 }
4224 } 4278 }
4225 4279
4226 if(doCulling && !grp.IsAttachment) 4280 if(doCulling && !grp.IsAttachment)
@@ -4248,14 +4302,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4248 continue; 4302 continue;
4249 } 4303 }
4250 } 4304 }
4251
4252 if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh))
4253 {
4254 // Ensure that mesh has at least 8 valid faces
4255 part.Shape.ProfileBegin = 12500;
4256 part.Shape.ProfileEnd = 0;
4257 part.Shape.ProfileHollow = 27500;
4258 }
4259 } 4305 }
4260 else if (update.Entity is ScenePresence) 4306 else if (update.Entity is ScenePresence)
4261 { 4307 {
@@ -4330,7 +4376,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4330 if (update.Entity is ScenePresence) 4376 if (update.Entity is ScenePresence)
4331 ablock = CreateAvatarUpdateBlock((ScenePresence)update.Entity); 4377 ablock = CreateAvatarUpdateBlock((ScenePresence)update.Entity);
4332 else 4378 else
4333 ablock = CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId); 4379 ablock = CreatePrimUpdateBlock((SceneObjectPart)update.Entity, mysp);
4334 objectUpdateBlocks.Add(ablock); 4380 objectUpdateBlocks.Add(ablock);
4335 objectUpdates.Value.Add(update); 4381 objectUpdates.Value.Add(update);
4336 maxUpdatesBytes -= ablock.Length; 4382 maxUpdatesBytes -= ablock.Length;
@@ -4462,6 +4508,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4462 } 4508 }
4463 4509
4464 // hack.. dont use 4510 // hack.. dont use
4511/*
4465 public void SendPartFullUpdate(ISceneEntity ent, uint? parentID) 4512 public void SendPartFullUpdate(ISceneEntity ent, uint? parentID)
4466 { 4513 {
4467 if (ent is SceneObjectPart) 4514 if (ent is SceneObjectPart)
@@ -4472,7 +4519,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4472 packet.RegionData.TimeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f); 4519 packet.RegionData.TimeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
4473 packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 4520 packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
4474 4521
4475 ObjectUpdatePacket.ObjectDataBlock blk = CreatePrimUpdateBlock(part, this.m_agentId); 4522 ObjectUpdatePacket.ObjectDataBlock blk = CreatePrimUpdateBlock(part, mysp);
4476 if (parentID.HasValue) 4523 if (parentID.HasValue)
4477 { 4524 {
4478 blk.ParentID = parentID.Value; 4525 blk.ParentID = parentID.Value;
@@ -4488,7 +4535,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4488// updatesThisCall, Name, SceneAgent.IsChildAgent ? "child" : "root", Scene.Name); 4535// updatesThisCall, Name, SceneAgent.IsChildAgent ? "child" : "root", Scene.Name);
4489// 4536//
4490 } 4537 }
4491 4538*/
4492 public void ReprioritizeUpdates() 4539 public void ReprioritizeUpdates()
4493 { 4540 {
4494 lock (m_entityUpdates.SyncRoot) 4541 lock (m_entityUpdates.SyncRoot)
@@ -5726,28 +5773,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5726 return update; 5773 return update;
5727 } 5774 }
5728 5775
5729 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID) 5776// protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
5777 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart part, ScenePresence sp)
5730 { 5778 {
5731 byte[] objectData = new byte[60]; 5779 byte[] objectData = new byte[60];
5732 data.RelativePosition.ToBytes(objectData, 0); 5780 part.RelativePosition.ToBytes(objectData, 0);
5733 data.Velocity.ToBytes(objectData, 12); 5781 part.Velocity.ToBytes(objectData, 12);
5734 data.Acceleration.ToBytes(objectData, 24); 5782 part.Acceleration.ToBytes(objectData, 24);
5735 5783
5736 Quaternion rotation = data.RotationOffset; 5784 Quaternion rotation = part.RotationOffset;
5737 rotation.Normalize(); 5785 rotation.Normalize();
5738 rotation.ToBytes(objectData, 36); 5786 rotation.ToBytes(objectData, 36);
5739 data.AngularVelocity.ToBytes(objectData, 48); 5787 part.AngularVelocity.ToBytes(objectData, 48);
5740 5788
5741 ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock(); 5789 ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
5742 update.ClickAction = (byte)data.ClickAction; 5790 update.ClickAction = (byte)part.ClickAction;
5743 update.CRC = 0; 5791 update.CRC = 0;
5744 update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes; 5792 update.ExtraParams = part.Shape.ExtraParams ?? Utils.EmptyBytes;
5745 update.FullID = data.UUID; 5793 update.FullID = part.UUID;
5746 update.ID = data.LocalId; 5794 update.ID = part.LocalId;
5747 //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated 5795 //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
5748 //update.JointPivot = Vector3.Zero; 5796 //update.JointPivot = Vector3.Zero;
5749 //update.JointType = 0; 5797 //update.JointType = 0;
5750 update.Material = data.Material; 5798 update.Material = part.Material;
5751 update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim 5799 update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
5752/* 5800/*
5753 if (data.ParentGroup.IsAttachment) 5801 if (data.ParentGroup.IsAttachment)
@@ -5776,68 +5824,74 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5776 } 5824 }
5777*/ 5825*/
5778 5826
5779 if (data.ParentGroup.IsAttachment) 5827 if (part.ParentGroup.IsAttachment)
5780 { 5828 {
5781 if (data.IsRoot) 5829 if (part.IsRoot)
5782 { 5830 {
5783 update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID); 5831 update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + part.ParentGroup.FromItemID);
5784 } 5832 }
5785 else 5833 else
5786 update.NameValue = Utils.EmptyBytes; 5834 update.NameValue = Utils.EmptyBytes;
5787 5835
5788 int st = (int)data.ParentGroup.AttachmentPoint; 5836 int st = (int)part.ParentGroup.AttachmentPoint;
5789 update.State = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ; 5837 update.State = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ;
5790 } 5838 }
5791 else 5839 else
5792 { 5840 {
5793 update.NameValue = Utils.EmptyBytes; 5841 update.NameValue = Utils.EmptyBytes;
5794 update.State = data.Shape.State; // not sure about this 5842 update.State = part.Shape.State; // not sure about this
5795 } 5843 }
5796 5844
5797 5845
5798 update.ObjectData = objectData; 5846 update.ObjectData = objectData;
5799 update.ParentID = data.ParentID; 5847 update.ParentID = part.ParentID;
5800 update.PathBegin = data.Shape.PathBegin; 5848 update.PathBegin = part.Shape.PathBegin;
5801 update.PathCurve = data.Shape.PathCurve; 5849 update.PathCurve = part.Shape.PathCurve;
5802 update.PathEnd = data.Shape.PathEnd; 5850 update.PathEnd = part.Shape.PathEnd;
5803 update.PathRadiusOffset = data.Shape.PathRadiusOffset; 5851 update.PathRadiusOffset = part.Shape.PathRadiusOffset;
5804 update.PathRevolutions = data.Shape.PathRevolutions; 5852 update.PathRevolutions = part.Shape.PathRevolutions;
5805 update.PathScaleX = data.Shape.PathScaleX; 5853 update.PathScaleX = part.Shape.PathScaleX;
5806 update.PathScaleY = data.Shape.PathScaleY; 5854 update.PathScaleY = part.Shape.PathScaleY;
5807 update.PathShearX = data.Shape.PathShearX; 5855 update.PathShearX = part.Shape.PathShearX;
5808 update.PathShearY = data.Shape.PathShearY; 5856 update.PathShearY = part.Shape.PathShearY;
5809 update.PathSkew = data.Shape.PathSkew; 5857 update.PathSkew = part.Shape.PathSkew;
5810 update.PathTaperX = data.Shape.PathTaperX; 5858 update.PathTaperX = part.Shape.PathTaperX;
5811 update.PathTaperY = data.Shape.PathTaperY; 5859 update.PathTaperY = part.Shape.PathTaperY;
5812 update.PathTwist = data.Shape.PathTwist; 5860 update.PathTwist = part.Shape.PathTwist;
5813 update.PathTwistBegin = data.Shape.PathTwistBegin; 5861 update.PathTwistBegin = part.Shape.PathTwistBegin;
5814 update.PCode = data.Shape.PCode; 5862 update.PCode = part.Shape.PCode;
5815 update.ProfileBegin = data.Shape.ProfileBegin; 5863 update.ProfileBegin = part.Shape.ProfileBegin;
5816 update.ProfileCurve = data.Shape.ProfileCurve; 5864 update.ProfileCurve = part.Shape.ProfileCurve;
5817 update.ProfileEnd = data.Shape.ProfileEnd; 5865
5818 update.ProfileHollow = data.Shape.ProfileHollow; 5866 if(part.Shape.SculptType == (byte)SculptType.Mesh) // filter out hack
5819 update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes; 5867 update.ProfileCurve = (byte)(part.Shape.ProfileCurve & 0x0f);
5820 update.TextColor = data.GetTextColor().GetBytes(false); 5868 else
5821 update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes; 5869 update.ProfileCurve = part.Shape.ProfileCurve;
5822 update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes; 5870
5823 update.Scale = data.Shape.Scale; 5871 update.ProfileEnd = part.Shape.ProfileEnd;
5824 update.Text = Util.StringToBytes256(data.Text); 5872 update.ProfileHollow = part.Shape.ProfileHollow;
5825 update.MediaURL = Util.StringToBytes256(data.MediaUrl); 5873 update.PSBlock = part.ParticleSystem ?? Utils.EmptyBytes;
5874 update.TextColor = part.GetTextColor().GetBytes(false);
5875 update.TextureAnim = part.TextureAnimation ?? Utils.EmptyBytes;
5876 update.TextureEntry = part.Shape.TextureEntry ?? Utils.EmptyBytes;
5877 update.Scale = part.Shape.Scale;
5878 update.Text = Util.StringToBytes256(part.Text);
5879 update.MediaURL = Util.StringToBytes256(part.MediaUrl);
5826 5880
5827 #region PrimFlags 5881 #region PrimFlags
5828 5882
5829 PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID); 5883 PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(part, sp);
5830 5884
5831 // Don't send the CreateSelected flag to everyone 5885 // Don't send the CreateSelected flag to everyone
5832 flags &= ~PrimFlags.CreateSelected; 5886 flags &= ~PrimFlags.CreateSelected;
5833 5887
5834 if (recipientID == data.OwnerID) 5888 if (sp.UUID == part.OwnerID)
5835 { 5889 {
5836 if (data.CreateSelected) 5890 if (part.CreateSelected)
5837 { 5891 {
5838 // Only send this flag once, then unset it 5892 // Only send this flag once, then unset it
5839 flags |= PrimFlags.CreateSelected; 5893 flags |= PrimFlags.CreateSelected;
5840 data.CreateSelected = false; 5894 part.CreateSelected = false;
5841 } 5895 }
5842 } 5896 }
5843 5897
@@ -5849,21 +5903,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5849 5903
5850 #endregion PrimFlags 5904 #endregion PrimFlags
5851 5905
5852 if (data.Sound != UUID.Zero) 5906 if (part.Sound != UUID.Zero)
5853 { 5907 {
5854 update.Sound = data.Sound; 5908 update.Sound = part.Sound;
5855 update.OwnerID = data.OwnerID; 5909 update.OwnerID = part.OwnerID;
5856 update.Gain = (float)data.SoundGain; 5910 update.Gain = (float)part.SoundGain;
5857 update.Radius = (float)data.SoundRadius; 5911 update.Radius = (float)part.SoundRadius;
5858 update.Flags = data.SoundFlags; 5912 update.Flags = part.SoundFlags;
5859 } 5913 }
5860 5914
5861 switch ((PCode)data.Shape.PCode) 5915 switch ((PCode)part.Shape.PCode)
5862 { 5916 {
5863 case PCode.Grass: 5917 case PCode.Grass:
5864 case PCode.Tree: 5918 case PCode.Tree:
5865 case PCode.NewTree: 5919 case PCode.NewTree:
5866 update.Data = new byte[] { data.Shape.State }; 5920 update.Data = new byte[] { part.Shape.State };
5867 break; 5921 break;
5868 default: 5922 default:
5869 update.Data = Utils.EmptyBytes; 5923 update.Data = Utils.EmptyBytes;
@@ -7753,10 +7807,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7753 7807
7754 ObjectDuplicate handlerObjectDuplicate = null; 7808 ObjectDuplicate handlerObjectDuplicate = null;
7755 7809
7756 for (int i = 0; i < dupe.ObjectData.Length; i++) 7810 handlerObjectDuplicate = OnObjectDuplicate;
7811 if (handlerObjectDuplicate != null)
7757 { 7812 {
7758 handlerObjectDuplicate = OnObjectDuplicate; 7813 for (int i = 0; i < dupe.ObjectData.Length; i++)
7759 if (handlerObjectDuplicate != null)
7760 { 7814 {
7761 UUID rezGroupID = dupe.AgentData.GroupID; 7815 UUID rezGroupID = dupe.AgentData.GroupID;
7762 if(!IsGroupMember(rezGroupID)) 7816 if(!IsGroupMember(rezGroupID))
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index 2242e42..6e4a710 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -369,7 +369,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
369 else if (Cache != null) 369 else if (Cache != null)
370 { 370 {
371 string assetName = "j2kCache_" + AssetId.ToString(); 371 string assetName = "j2kCache_" + AssetId.ToString();
372 AssetBase layerDecodeAsset = Cache.Get(assetName); 372 AssetBase layerDecodeAsset;
373 Cache.Get(assetName, out layerDecodeAsset);
373 374
374 if (layerDecodeAsset != null) 375 if (layerDecodeAsset != null)
375 { 376 {
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
index 23c1f03..403236c 100644
--- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
@@ -260,10 +260,9 @@ namespace OpenSim.Region.CoreModules.Asset
260 /// Cache doesn't guarantee in any situation that asset is stored to it. 260 /// Cache doesn't guarantee in any situation that asset is stored to it.
261 /// </para> 261 /// </para>
262 /// </remarks> 262 /// </remarks>
263 public AssetBase Get(string id) 263 public bool Get(string id, out AssetBase assetBase)
264 { 264 {
265 m_getCount++; 265 m_getCount++;
266 AssetBase assetBase;
267 if (m_cache.TryGetValue(id, out assetBase)) 266 if (m_cache.TryGetValue(id, out assetBase))
268 m_hitCount++; 267 m_hitCount++;
269 268
@@ -284,7 +283,7 @@ namespace OpenSim.Region.CoreModules.Asset
284// if (null == assetBase) 283// if (null == assetBase)
285// m_log.DebugFormat("[CENOME ASSET CACHE]: Asset {0} not in cache", id); 284// m_log.DebugFormat("[CENOME ASSET CACHE]: Asset {0} not in cache", id);
286 285
287 return assetBase; 286 return true;
288 } 287 }
289 288
290 #endregion 289 #endregion
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
index 51fc3d1..10c0e85 100644
--- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
@@ -115,7 +115,10 @@ namespace OpenSim.Region.CoreModules.Asset
115 public bool Check(string id) 115 public bool Check(string id)
116 { 116 {
117 // XXX This is probably not an efficient implementation. 117 // XXX This is probably not an efficient implementation.
118 return Get(id) != null; 118 AssetBase asset;
119 if (!Get(id, out asset))
120 return false;
121 return asset != null;
119 } 122 }
120 123
121 public void Cache(AssetBase asset) 124 public void Cache(AssetBase asset)
@@ -129,9 +132,10 @@ namespace OpenSim.Region.CoreModules.Asset
129 // We don't do negative caching 132 // We don't do negative caching
130 } 133 }
131 134
132 public AssetBase Get(string id) 135 public bool Get(string id, out AssetBase asset)
133 { 136 {
134 return (AssetBase)m_Cache.Get(id); 137 asset = (AssetBase)m_Cache.Get(id);
138 return true;
135 } 139 }
136 140
137 public void Expire(string id) 141 public void Expire(string id)
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 187f090..610e279 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -474,6 +474,8 @@ namespace OpenSim.Region.CoreModules.Asset
474 { 474 {
475 using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) 475 using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
476 { 476 {
477 if (stream.Length == 0) // Empty file will trigger exception below
478 return null;
477 BinaryFormatter bformatter = new BinaryFormatter(); 479 BinaryFormatter bformatter = new BinaryFormatter();
478 480
479 asset = (AssetBase)bformatter.Deserialize(stream); 481 asset = (AssetBase)bformatter.Deserialize(stream);
@@ -531,15 +533,26 @@ namespace OpenSim.Region.CoreModules.Asset
531 return found; 533 return found;
532 } 534 }
533 535
536 // For IAssetService
534 public AssetBase Get(string id) 537 public AssetBase Get(string id)
535 { 538 {
539 AssetBase asset;
540 Get(id, out asset);
541 return asset;
542 }
543
544 public bool Get(string id, out AssetBase asset)
545 {
546 asset = null;
547
536 m_Requests++; 548 m_Requests++;
537 549
538 object dummy; 550 object dummy;
539 if (m_negativeCache.TryGetValue(id, out dummy)) 551 if (m_negativeCache.TryGetValue(id, out dummy))
540 return null; 552 {
553 return false;
554 }
541 555
542 AssetBase asset = null;
543 asset = GetFromWeakReference(id); 556 asset = GetFromWeakReference(id);
544 if (asset != null && m_updateFileTimeOnCacheHit) 557 if (asset != null && m_updateFileTimeOnCacheHit)
545 { 558 {
@@ -578,13 +591,7 @@ namespace OpenSim.Region.CoreModules.Asset
578 GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l)); 591 GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l));
579 } 592 }
580 593
581 if(asset == null) 594 return true;
582 {
583
584
585 }
586
587 return asset;
588 } 595 }
589 596
590 public bool Check(string id) 597 public bool Check(string id)
@@ -599,7 +606,9 @@ namespace OpenSim.Region.CoreModules.Asset
599 606
600 public AssetBase GetCached(string id) 607 public AssetBase GetCached(string id)
601 { 608 {
602 return Get(id); 609 AssetBase asset;
610 Get(id, out asset);
611 return asset;
603 } 612 }
604 613
605 public void Expire(string id) 614 public void Expire(string id)
@@ -797,6 +806,9 @@ namespace OpenSim.Region.CoreModules.Asset
797 806
798 return; 807 return;
799 } 808 }
809 catch (UnauthorizedAccessException e)
810 {
811 }
800 finally 812 finally
801 { 813 {
802 if (stream != null) 814 if (stream != null)
@@ -1227,19 +1239,23 @@ namespace OpenSim.Region.CoreModules.Asset
1227 1239
1228 public AssetMetadata GetMetadata(string id) 1240 public AssetMetadata GetMetadata(string id)
1229 { 1241 {
1230 AssetBase asset = Get(id); 1242 AssetBase asset;
1243 Get(id, out asset);
1231 return asset.Metadata; 1244 return asset.Metadata;
1232 } 1245 }
1233 1246
1234 public byte[] GetData(string id) 1247 public byte[] GetData(string id)
1235 { 1248 {
1236 AssetBase asset = Get(id); 1249 AssetBase asset;
1250 Get(id, out asset);
1237 return asset.Data; 1251 return asset.Data;
1238 } 1252 }
1239 1253
1240 public bool Get(string id, object sender, AssetRetrieved handler) 1254 public bool Get(string id, object sender, AssetRetrieved handler)
1241 { 1255 {
1242 AssetBase asset = Get(id); 1256 AssetBase asset;
1257 if (!Get(id, out asset))
1258 return false;
1243 handler(id, sender, asset); 1259 handler(id, sender, asset);
1244 return true; 1260 return true;
1245 } 1261 }
@@ -1270,7 +1286,9 @@ namespace OpenSim.Region.CoreModules.Asset
1270 1286
1271 public bool UpdateContent(string id, byte[] data) 1287 public bool UpdateContent(string id, byte[] data)
1272 { 1288 {
1273 AssetBase asset = Get(id); 1289 AssetBase asset;
1290 if (!Get(id, out asset))
1291 return false;
1274 asset.Data = data; 1292 asset.Data = data;
1275 Cache(asset); 1293 Cache(asset);
1276 return true; 1294 return true;
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
index 208963d..abe9b23 100644
--- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
@@ -131,14 +131,15 @@ namespace OpenSim.Region.CoreModules.Asset
131 // We don't do negative caching 131 // We don't do negative caching
132 } 132 }
133 133
134 public AssetBase Get(string id) 134 public bool Get(string id, out AssetBase asset)
135 { 135 {
136 Object asset = null; 136 Object a = null;
137 m_Cache.TryGet(id, out asset); 137 m_Cache.TryGet(id, out a);
138 138
139 Debug(asset); 139 Debug(a);
140 140
141 return (AssetBase)asset; 141 asset = (AssetBase)a;
142 return true;
142 } 143 }
143 144
144 public void Expire(string id) 145 public void Expire(string id)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 8b8ac20..cf188aa 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -481,14 +481,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
481// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", 481// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
482// group.Name, group.LocalId, sp.Name, attachmentPt, silent); 482// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
483 483
484 if (sp.GetAttachments().Contains(group))
485 {
486// m_log.WarnFormat(
487// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
488// group.Name, group.LocalId, sp.Name, AttachmentPt);
489
490 return false;
491 }
492 484
493 if (group.GetSittingAvatarsCount() != 0) 485 if (group.GetSittingAvatarsCount() != 0)
494 { 486 {
@@ -500,6 +492,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
500 return false; 492 return false;
501 } 493 }
502 494
495 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
496 if (attachments.Contains(group))
497 {
498// if (DebugLevel > 0)
499// m_log.WarnFormat(
500// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
501// group.Name, group.LocalId, sp.Name, attachmentPt);
502
503 return false;
504 }
505
503 Vector3 attachPos = group.AbsolutePosition; 506 Vector3 attachPos = group.AbsolutePosition;
504 507
505 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 508 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
@@ -533,7 +536,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
533 { 536 {
534 attachmentPt = (uint)group.RootPart.Shape.LastAttachPoint; 537 attachmentPt = (uint)group.RootPart.Shape.LastAttachPoint;
535 attachPos = group.RootPart.AttachedPos; 538 attachPos = group.RootPart.AttachedPos;
536 group.HasGroupChanged = true;
537 } 539 }
538 540
539 // if we still didn't find a suitable attachment point....... 541 // if we still didn't find a suitable attachment point.......
@@ -544,18 +546,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
544 attachPos = Vector3.Zero; 546 attachPos = Vector3.Zero;
545 } 547 }
546 548
547 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
548
549 if (attachments.Contains(group))
550 {
551 if (DebugLevel > 0)
552 m_log.WarnFormat(
553 "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
554 group.Name, group.LocalId, sp.Name, attachmentPt);
555
556 return false;
557 }
558
559 // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones 549 // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones
560 while (attachments.Count >= 5) 550 while (attachments.Count >= 5)
561 { 551 {
@@ -579,7 +569,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
579 lock (sp.AttachmentsSyncLock) 569 lock (sp.AttachmentsSyncLock)
580 { 570 {
581 group.AttachmentPoint = attachmentPt; 571 group.AttachmentPoint = attachmentPt;
582 group.AbsolutePosition = attachPos; 572 group.RootPart.AttachedPos = attachPos;
583 573
584 if (addToInventory && sp.PresenceType != PresenceType.Npc) 574 if (addToInventory && sp.PresenceType != PresenceType.Npc)
585 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append); 575 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append);
@@ -956,7 +946,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
956 m_scene.DeleteFromStorage(so.UUID); 946 m_scene.DeleteFromStorage(so.UUID);
957 m_scene.EventManager.TriggerParcelPrimCountTainted(); 947 m_scene.EventManager.TriggerParcelPrimCountTainted();
958 948
959 so.AttachedAvatar = sp.UUID;
960 949
961 foreach (SceneObjectPart part in so.Parts) 950 foreach (SceneObjectPart part in so.Parts)
962 { 951 {
@@ -969,11 +958,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
969 } 958 }
970 } 959 }
971 960
972 so.AbsolutePosition = attachOffset;
973 so.RootPart.AttachedPos = attachOffset;
974 so.IsAttachment = true;
975 so.RootPart.SetParentLocalId(sp.LocalId); 961 so.RootPart.SetParentLocalId(sp.LocalId);
962 so.AttachedAvatar = sp.UUID;
976 so.AttachmentPoint = attachmentpoint; 963 so.AttachmentPoint = attachmentpoint;
964 so.RootPart.AttachedPos = attachOffset;
965 so.AbsolutePosition = attachOffset;
966 so.IsAttachment = true;
977 967
978 sp.AddAttachment(so); 968 sp.AddAttachment(so);
979 969
@@ -1322,7 +1312,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1322 if (part == null) 1312 if (part == null)
1323 return; 1313 return;
1324 1314
1325 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) 1315 SceneObjectGroup group = part.ParentGroup;
1316
1317 if (!m_scene.Permissions.CanTakeObject(group, sp))
1326 { 1318 {
1327 remoteClient.SendAgentAlertMessage( 1319 remoteClient.SendAgentAlertMessage(
1328 "You don't have sufficient permissions to attach this object", false); 1320 "You don't have sufficient permissions to attach this object", false);
@@ -1334,7 +1326,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1334 AttachmentPt &= 0x7f; 1326 AttachmentPt &= 0x7f;
1335 1327
1336 // Calls attach with a Zero position 1328 // Calls attach with a Zero position
1337 SceneObjectGroup group = part.ParentGroup;
1338 if (AttachObject(sp, group , AttachmentPt, false, true, append)) 1329 if (AttachObject(sp, group , AttachmentPt, false, true, append))
1339 { 1330 {
1340 if (DebugLevel > 0) 1331 if (DebugLevel > 0)
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index fb408a4..535d946 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -299,7 +299,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
299 if (bakedTextureFace == null) 299 if (bakedTextureFace == null)
300 continue; 300 continue;
301 301
302 AssetBase asset = cache.Get(bakedTextureFace.TextureID.ToString()); 302 AssetBase asset;
303 cache.Get(bakedTextureFace.TextureID.ToString(), out asset);
303 304
304 if (asset != null && asset.Local) 305 if (asset != null && asset.Local)
305 { 306 {
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index d1f6054..315ce1b 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -52,6 +52,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 private bool enabled = true; 54 private bool enabled = true;
55 private bool m_UseNewAvnCode = false;
55 private List<Scene> m_SceneList = new List<Scene>(); 56 private List<Scene> m_SceneList = new List<Scene>();
56 private string m_RestURL = String.Empty; 57 private string m_RestURL = String.Empty;
57 IMessageTransferModule m_TransferModule = null; 58 IMessageTransferModule m_TransferModule = null;
@@ -82,6 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
82 } 83 }
83 84
84 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages); 85 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages);
86 m_UseNewAvnCode = cnf.GetBoolean("UseNewAvnCode", m_UseNewAvnCode);
85 } 87 }
86 88
87 public void AddRegion(Scene scene) 89 public void AddRegion(Scene scene)
@@ -244,68 +246,73 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
244 return; 246 return;
245 } 247 }
246 248
247 Scene scene = FindScene(new UUID(im.fromAgentID)); 249 if(m_UseNewAvnCode)
248 if (scene == null) 250 {
249 scene = m_SceneList[0]; 251 Scene scene = FindScene(new UUID(im.fromAgentID));
252 if (scene == null)
253 scene = m_SceneList[0];
250 254
251// Avination new code 255 UUID scopeID = scene.RegionInfo.ScopeID;
252// SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>( 256 SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>(
253// "POST", m_RestURL+"/SaveMessage/?scope=" + 257 "POST", m_RestURL+"/SaveMessage/?scope=" + scopeID.ToString(), im, 20000);
254// scene.RegionInfo.ScopeID.ToString(), im);
255 258
256// current opensim and osgrid compatible 259 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
257 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( 260 {
258 "POST", m_RestURL+"/SaveMessage/", im, 10000); 261 IClientAPI client = FindClient(new UUID(im.fromAgentID));
259// current opensim and osgrid compatible end 262 if (client == null)
263 return;
260 264
261 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 265 if (string.IsNullOrEmpty(reply.Message))
262 { 266 reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved");
263 IClientAPI client = FindClient(new UUID(im.fromAgentID));
264 if (client == null)
265 return;
266/* Avination new code
267 if (reply.Message == String.Empty)
268 reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved");
269 267
270 bool sendReply = true; 268 bool sendReply = true;
271 269
272 switch (reply.Disposition) 270 switch (reply.Disposition)
273 {
274 case 0: // Normal
275 break;
276 case 1: // Only once per user
277 if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID)))
278 { 271 {
279 sendReply = false; 272 case 0: // Normal
273 break;
274 case 1: // Only once per user
275 if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID)))
276 sendReply = false;
277 else
278 {
279 if (!m_repliesSent.ContainsKey(client))
280 m_repliesSent[client] = new List<UUID>();
281 m_repliesSent[client].Add(new UUID(im.toAgentID));
282 }
283 break;
280 } 284 }
281 else 285
286 if (sendReply)
282 { 287 {
283 if (!m_repliesSent.ContainsKey(client)) 288 client.SendInstantMessage(new GridInstantMessage(
284 m_repliesSent[client] = new List<UUID>(); 289 null, new UUID(im.toAgentID),
285 m_repliesSent[client].Add(new UUID(im.toAgentID)); 290 "System", new UUID(im.fromAgentID),
291 (byte)InstantMessageDialog.MessageFromAgent,
292 reply.Message,
293 false, new Vector3()));
286 } 294 }
287 break;
288 } 295 }
296 }
297 else
298 {
299 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
300 "POST", m_RestURL+"/SaveMessage/", im, 20000);
289 301
290 if (sendReply) 302 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
291 { 303 {
304 IClientAPI client = FindClient(new UUID(im.fromAgentID));
305 if (client == null)
306 return;
307
292 client.SendInstantMessage(new GridInstantMessage( 308 client.SendInstantMessage(new GridInstantMessage(
293 null, new UUID(im.toAgentID),
294 "System", new UUID(im.fromAgentID),
295 (byte)InstantMessageDialog.MessageFromAgent,
296 reply.Message,
297 false, new Vector3()));
298 }
299*/
300// current opensim and osgrid compatible
301 client.SendInstantMessage(new GridInstantMessage(
302 null, new UUID(im.toAgentID), 309 null, new UUID(im.toAgentID),
303 "System", new UUID(im.fromAgentID), 310 "System", new UUID(im.fromAgentID),
304 (byte)InstantMessageDialog.MessageFromAgent, 311 (byte)InstantMessageDialog.MessageFromAgent,
305 "User is not logged in. "+ 312 "User is not logged in. "+
306 (success ? "Message saved." : "Message not saved"), 313 (success ? "Message saved." : "Message not saved"),
307 false, new Vector3())); 314 false, new Vector3()));
308// current opensim and osgrid compatible end 315 }
309 } 316 }
310 } 317 }
311 } 318 }
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index bc8aeca..89e3020 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -149,7 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
149 149
150 if (profileConfig == null) 150 if (profileConfig == null)
151 { 151 {
152 m_log.Debug("[PROFILES]: UserProfiles disabled, no configuration"); 152 //m_log.Debug("[PROFILES]: UserProfiles disabled, no configuration");
153 Enabled = false; 153 Enabled = false;
154 return; 154 return;
155 } 155 }
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 6dc982b..87b76dc 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -1703,11 +1703,81 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1703 return agent; 1703 return agent;
1704 } 1704 }
1705 1705
1706 public bool CrossAgentCreateFarChild(ScenePresence agent, GridRegion neighbourRegion, Vector3 pos, EntityTransferContext ctx)
1707 {
1708 ulong regionhandler = neighbourRegion.RegionHandle;
1709
1710 if(agent.knowsNeighbourRegion(regionhandler))
1711 return true;
1712
1713 string reason;
1714 ulong currentRegionHandler = agent.Scene.RegionInfo.RegionHandle;
1715 GridRegion source = new GridRegion(agent.Scene.RegionInfo);
1716
1717 AgentCircuitData currentAgentCircuit =
1718 agent.Scene.AuthenticateHandler.GetAgentCircuitData(agent.ControllingClient.CircuitCode);
1719 AgentCircuitData agentCircuit = agent.ControllingClient.RequestClientInfo();
1720 agentCircuit.startpos = pos;
1721 agentCircuit.child = true;
1722
1723 agentCircuit.Appearance = new AvatarAppearance();
1724 agentCircuit.Appearance.AvatarHeight = agent.Appearance.AvatarHeight;
1725
1726 if (currentAgentCircuit != null)
1727 {
1728 agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs;
1729 agentCircuit.IPAddress = currentAgentCircuit.IPAddress;
1730 agentCircuit.Viewer = currentAgentCircuit.Viewer;
1731 agentCircuit.Channel = currentAgentCircuit.Channel;
1732 agentCircuit.Mac = currentAgentCircuit.Mac;
1733 agentCircuit.Id0 = currentAgentCircuit.Id0;
1734 }
1735
1736 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
1737 agent.AddNeighbourRegion(neighbourRegion, agentCircuit.CapsPath);
1738
1739 IPEndPoint endPoint = neighbourRegion.ExternalEndPoint;
1740 if (Scene.SimulationService.CreateAgent(source, neighbourRegion, agentCircuit, (int)TeleportFlags.Default, ctx, out reason))
1741 {
1742 string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
1743 int newSizeX = neighbourRegion.RegionSizeX;
1744 int newSizeY = neighbourRegion.RegionSizeY;
1745
1746 if (m_eqModule != null)
1747 {
1748 #region IP Translation for NAT
1749 IClientIPEndpoint ipepClient;
1750 if (agent.ClientView.TryGet(out ipepClient))
1751 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
1752
1753 m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " +
1754 "and EstablishAgentCommunication with seed cap {8}", LogHeader,
1755 source.RegionName, agent.Name,
1756 neighbourRegion.RegionName, neighbourRegion.RegionLocX, neighbourRegion.RegionLocY, newSizeX, newSizeY , capsPath);
1757
1758 m_eqModule.EnableSimulator(regionhandler,
1759 endPoint, agent.UUID, newSizeX, newSizeY);
1760 m_eqModule.EstablishAgentCommunication(agent.UUID, endPoint, capsPath,
1761 regionhandler, newSizeX, newSizeY);
1762 }
1763 else
1764 {
1765 agent.ControllingClient.InformClientOfNeighbour(regionhandler, endPoint);
1766 }
1767 return true;
1768 }
1769 agent.RemoveNeighbourRegion(regionhandler);
1770 return false;
1771 }
1772
1706 public bool CrossAgentIntoNewRegionMain(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, EntityTransferContext ctx) 1773 public bool CrossAgentIntoNewRegionMain(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, EntityTransferContext ctx)
1707 { 1774 {
1708 int ts = Util.EnvironmentTickCount(); 1775 int ts = Util.EnvironmentTickCount();
1776 bool sucess = true;
1777 string reason = String.Empty;
1709 try 1778 try
1710 { 1779 {
1780
1711 AgentData cAgent = new AgentData(); 1781 AgentData cAgent = new AgentData();
1712 agent.CopyTo(cAgent,true); 1782 agent.CopyTo(cAgent,true);
1713 1783
@@ -1725,18 +1795,26 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1725 // Beyond this point, extra cleanup is needed beyond removing transit state 1795 // Beyond this point, extra cleanup is needed beyond removing transit state
1726 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring); 1796 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring);
1727 1797
1728 if (!agent.Scene.SimulationService.UpdateAgent(neighbourRegion, cAgent, ctx)) 1798 if (sucess && !agent.Scene.SimulationService.UpdateAgent(neighbourRegion, cAgent, ctx))
1799 {
1800 sucess = false;
1801 reason = "agent update failed";
1802 }
1803
1804 if(!sucess)
1729 { 1805 {
1730 // region doesn't take it 1806 // region doesn't take it
1731 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); 1807 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
1732 1808
1733 m_log.WarnFormat( 1809 m_log.WarnFormat(
1734 "[ENTITY TRANSFER MODULE]: Region {0} would not accept update for agent {1} on cross attempt. Returning to original region.", 1810 "[ENTITY TRANSFER MODULE]: agent {0} crossing to {1} failed: {2}",
1735 neighbourRegion.RegionName, agent.Name); 1811 agent.Name, neighbourRegion.RegionName, reason);
1736 1812
1737 ReInstantiateScripts(agent); 1813 ReInstantiateScripts(agent);
1738 if(agent.ParentID == 0 && agent.ParentUUID == UUID.Zero) 1814 if(agent.ParentID == 0 && agent.ParentUUID == UUID.Zero)
1815 {
1739 agent.AddToPhysicalScene(isFlying); 1816 agent.AddToPhysicalScene(isFlying);
1817 }
1740 1818
1741 return false; 1819 return false;
1742 } 1820 }
@@ -1777,7 +1855,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1777 1855
1778 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); 1856 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
1779 1857
1780 Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0); 1858 Vector3 vel2 = Vector3.Zero;
1859 if((agent.crossingFlags & 2) != 0)
1860 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0);
1781 1861
1782 if (m_eqModule != null) 1862 if (m_eqModule != null)
1783 { 1863 {
@@ -1804,7 +1884,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1804 1884
1805 // this may need the attachments 1885 // this may need the attachments
1806 1886
1807 agent.HasMovedAway(true); 1887 agent.HasMovedAway((agent.crossingFlags & 8) == 0);
1808 1888
1809 agent.MakeChildAgent(neighbourRegion.RegionHandle); 1889 agent.MakeChildAgent(neighbourRegion.RegionHandle);
1810 1890
@@ -2135,7 +2215,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2135 sp.Scene.RegionInfo.WorldLocY - neighbour.RegionLocY, 2215 sp.Scene.RegionInfo.WorldLocY - neighbour.RegionLocY,
2136 0f); 2216 0f);
2137 } 2217 }
2138 2218 #endregion
2139 2219
2140 #region NotFoundLocationCache class 2220 #region NotFoundLocationCache class
2141 // A collection of not found locations to make future lookups 'not found' lookups quick. 2221 // A collection of not found locations to make future lookups 'not found' lookups quick.
@@ -2620,7 +2700,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2620 { 2700 {
2621 // FIXME: It would be better to never add the scene object at all rather than add it and then delete 2701 // FIXME: It would be better to never add the scene object at all rather than add it and then delete
2622 // it 2702 // it
2623 if (!Scene.Permissions.CanObjectEntry(so.UUID, true, so.AbsolutePosition)) 2703 if (!Scene.Permissions.CanObjectEntry(so, true, so.AbsolutePosition))
2624 { 2704 {
2625 // Deny non attachments based on parcel settings 2705 // Deny non attachments based on parcel settings
2626 // 2706 //
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 95e7456..ba3a7c9 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -541,16 +541,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
541 541
542 #region Permissions 542 #region Permissions
543 543
544 private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) 544 private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
545 { 545 {
546 if (m_bypassPermissions) return true; 546 if (m_bypassPermissions) return true;
547 547
548 if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(stealer)) 548 if(sp == null || sog == null)
549 return false;
550
551 if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(sp.UUID))
549 { 552 {
550 SceneObjectGroup sog = null; 553 if (sog.OwnerID == sp.UUID)
551 if (m_Scene.TryGetSceneObjectGroup(objectID, out sog) && sog.OwnerID == stealer)
552 return true; 554 return true;
553
554 return false; 555 return false;
555 } 556 }
556 557
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 0104823..67c847b 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -427,20 +427,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
427 originalRotations[objectGroup.UUID] = inventoryStoredRotation; 427 originalRotations[objectGroup.UUID] = inventoryStoredRotation;
428 428
429 // Restore attachment data after trip through the sim 429 // Restore attachment data after trip through the sim
430 if (objectGroup.RootPart.AttachPoint > 0) 430 if (objectGroup.AttachmentPoint > 0)
431 { 431 {
432 inventoryStoredPosition = objectGroup.RootPart.AttachedPos; 432 inventoryStoredPosition = objectGroup.RootPart.AttachedPos;
433 inventoryStoredRotation = objectGroup.RootPart.AttachRotation; 433 inventoryStoredRotation = objectGroup.RootPart.AttachRotation;
434 } 434 if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree &&
435 objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree)
436 objectGroup.RootPart.Shape.LastAttachPoint = (byte)objectGroup.AttachmentPoint;
435 437
436 // Trees could be attached and it's been done, but it makes
437 // no sense. State must be preserved because it's the tree type
438 if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree &&
439 objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree)
440 {
441 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
442 if (objectGroup.RootPart.AttachPoint > 0)
443 objectGroup.RootPart.Shape.LastAttachPoint = objectGroup.RootPart.AttachPoint;
444 } 438 }
445 439
446 objectGroup.AbsolutePosition = inventoryStoredPosition; 440 objectGroup.AbsolutePosition = inventoryStoredPosition;
@@ -605,15 +599,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
605 perms &= ~(uint)PermissionMask.Transfer; 599 perms &= ~(uint)PermissionMask.Transfer;
606 if ((nextPerms & (uint)PermissionMask.Modify) == 0) 600 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
607 perms &= ~(uint)PermissionMask.Modify; 601 perms &= ~(uint)PermissionMask.Modify;
608 602
609 item.BasePermissions = perms & so.RootPart.NextOwnerMask; 603// item.BasePermissions = perms & so.RootPart.NextOwnerMask;
604
605 uint nextp = so.RootPart.NextOwnerMask | (uint)PermissionMask.FoldedMask;
606 item.BasePermissions = perms & nextp;
610 item.CurrentPermissions = item.BasePermissions; 607 item.CurrentPermissions = item.BasePermissions;
611 item.NextPermissions = perms & so.RootPart.NextOwnerMask; 608 item.NextPermissions = perms & so.RootPart.NextOwnerMask;
612 item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; 609 item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask;
613 item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; 610 item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask;
614 611
615 // apply next owner perms on rez 612 // apply next owner perms on rez
616 item.CurrentPermissions |= SceneObjectGroup.SLAM; 613 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
617 } 614 }
618 else 615 else
619 { 616 {
@@ -1124,7 +1121,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1124// rootPart.OwnerID, item.Owner, item.CurrentPermissions); 1121// rootPart.OwnerID, item.Owner, item.CurrentPermissions);
1125 1122
1126 if ((rootPart.OwnerID != item.Owner) || 1123 if ((rootPart.OwnerID != item.Owner) ||
1127 (item.CurrentPermissions & 16) != 0 || 1124 (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 ||
1128 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) 1125 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
1129 { 1126 {
1130 //Need to kill the for sale here 1127 //Need to kill the for sale here
@@ -1136,32 +1133,48 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1136 foreach (SceneObjectPart part in so.Parts) 1133 foreach (SceneObjectPart part in so.Parts)
1137 { 1134 {
1138 part.GroupMask = 0; // DO NOT propagate here 1135 part.GroupMask = 0; // DO NOT propagate here
1139 1136 if( part.OwnerID != part.GroupID)
1140 part.LastOwnerID = part.OwnerID; 1137 part.LastOwnerID = part.OwnerID;
1141 part.OwnerID = item.Owner; 1138 part.OwnerID = item.Owner;
1142 part.RezzerID = item.Owner; 1139 part.RezzerID = item.Owner;
1143 part.Inventory.ChangeInventoryOwner(item.Owner); 1140 part.Inventory.ChangeInventoryOwner(item.Owner);
1144 1141
1145 // This applies the base mask from the item as the next 1142 // Reconstruct the original item's base permissions. They
1146 // permissions for the object. This is correct because the 1143 // can be found in the lower (folded) bits.
1147 // giver's base mask was masked by the giver's next owner 1144 if ((item.BasePermissions & (uint)PermissionMask.FoldedMask) != 0)
1148 // mask, so the base mask equals the original next owner mask. 1145 {
1149 part.NextOwnerMask = item.BasePermissions; 1146 // We have permissions stored there so use them
1147 part.NextOwnerMask = ((item.BasePermissions & 7) << 13);
1148 if ((item.BasePermissions & (uint)PermissionMask.FoldedExport) != 0)
1149 part.NextOwnerMask |= (uint)PermissionMask.Export;
1150 part.NextOwnerMask |= (uint)PermissionMask.Move;
1151 }
1152 else
1153 {
1154 // This is a legacy object and we can't avoid the issues that
1155 // caused perms loss or escalation before, treat it the legacy
1156 // way.
1157 part.NextOwnerMask = item.NextPermissions;
1158 }
1150 } 1159 }
1151 1160
1152 so.ApplyNextOwnerPermissions(); 1161 so.ApplyNextOwnerPermissions();
1153 1162
1154 // In case the user has changed flags on a received item 1163 // In case the user has changed flags on a received item
1155 // we have to apply those changes after the slam. Else we 1164 // we have to apply those changes after the slam. Else we
1156 // get a net loss of permissions 1165 // get a net loss of permissions.
1166 // On legacy objects, this opts for a loss of permissions rather
1167 // than the previous handling that allowed escalation.
1157 foreach (SceneObjectPart part in so.Parts) 1168 foreach (SceneObjectPart part in so.Parts)
1158 { 1169 {
1159 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) 1170 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
1160 { 1171 {
1172 part.GroupMask = item.GroupPermissions & part.BaseMask;
1161 part.EveryoneMask = item.EveryOnePermissions & part.BaseMask; 1173 part.EveryoneMask = item.EveryOnePermissions & part.BaseMask;
1162 part.NextOwnerMask = item.NextPermissions & part.BaseMask; 1174 part.NextOwnerMask = item.NextPermissions & part.BaseMask;
1163 } 1175 }
1164 } 1176 }
1177
1165 } 1178 }
1166 } 1179 }
1167 else 1180 else
@@ -1180,6 +1193,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1180 } 1193 }
1181 1194
1182 rootPart.TrimPermissions(); 1195 rootPart.TrimPermissions();
1196 so.AggregateDeepPerms();
1183 1197
1184 if (isAttachment) 1198 if (isAttachment)
1185 so.FromItemID = item.ID; 1199 so.FromItemID = item.ID;
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 51f973a..32cb5a3 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -957,9 +957,14 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
957 957
958 public virtual bool IsLocalGridUser(UUID uuid) 958 public virtual bool IsLocalGridUser(UUID uuid)
959 { 959 {
960 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); 960 lock (m_Scenes)
961 if (account == null || (account != null && !account.LocalToGrid)) 961 {
962 return false; 962 if (m_Scenes.Count == 0)
963 return true;
964 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid);
965 if (account == null || (account != null && !account.LocalToGrid))
966 return false;
967 }
963 968
964 return true; 969 return true;
965 } 970 }
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 3f332fa..290daa9 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -83,17 +83,17 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
83 LogManager.GetLogger( 83 LogManager.GetLogger(
84 MethodBase.GetCurrentMethod().DeclaringType); 84 MethodBase.GetCurrentMethod().DeclaringType);
85 85
86 private Dictionary<UUID, UrlData> m_RequestMap = 86 protected Dictionary<UUID, UrlData> m_RequestMap =
87 new Dictionary<UUID, UrlData>(); 87 new Dictionary<UUID, UrlData>();
88 88
89 private Dictionary<string, UrlData> m_UrlMap = 89 protected Dictionary<string, UrlData> m_UrlMap =
90 new Dictionary<string, UrlData>(); 90 new Dictionary<string, UrlData>();
91 91
92 private uint m_HttpsPort = 0; 92 protected uint m_HttpsPort = 0;
93 private IHttpServer m_HttpServer = null; 93 protected IHttpServer m_HttpServer = null;
94 private IHttpServer m_HttpsServer = null; 94 protected IHttpServer m_HttpsServer = null;
95 95
96 public string ExternalHostNameForLSL { get; private set; } 96 public string ExternalHostNameForLSL { get; protected set; }
97 97
98 /// <summary> 98 /// <summary>
99 /// The default maximum number of urls 99 /// The default maximum number of urls
@@ -107,7 +107,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
107 107
108 public Type ReplaceableInterface 108 public Type ReplaceableInterface
109 { 109 {
110 get { return null; } 110 get { return typeof(IUrlModule); }
111 } 111 }
112 112
113 public string Name 113 public string Name
@@ -453,7 +453,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
453 } 453 }
454 454
455 455
456 private void RemoveUrl(UrlData data) 456 protected void RemoveUrl(UrlData data)
457 { 457 {
458 if (data.isSsl) 458 if (data.isSsl)
459 m_HttpsServer.RemoveHTTPHandler("", "/lslhttps/"+data.urlcode.ToString()+"/"); 459 m_HttpsServer.RemoveHTTPHandler("", "/lslhttps/"+data.urlcode.ToString()+"/");
@@ -461,7 +461,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
461 m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); 461 m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/");
462 } 462 }
463 463
464 private Hashtable NoEvents(UUID requestID, UUID sessionID) 464 protected Hashtable NoEvents(UUID requestID, UUID sessionID)
465 { 465 {
466 Hashtable response = new Hashtable(); 466 Hashtable response = new Hashtable();
467 UrlData url; 467 UrlData url;
@@ -499,7 +499,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
499 return response; 499 return response;
500 } 500 }
501 501
502 private bool HasEvents(UUID requestID, UUID sessionID) 502 protected bool HasEvents(UUID requestID, UUID sessionID)
503 { 503 {
504 UrlData url=null; 504 UrlData url=null;
505 505
@@ -531,7 +531,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
531 } 531 }
532 } 532 }
533 533
534 private void Drop(UUID requestID, UUID sessionID) 534 protected void Drop(UUID requestID, UUID sessionID)
535 { 535 {
536 UrlData url = null; 536 UrlData url = null;
537 lock (m_RequestMap) 537 lock (m_RequestMap)
@@ -552,7 +552,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
552 } 552 }
553 } 553 }
554 554
555 private Hashtable GetEvents(UUID requestID, UUID sessionID) 555 protected Hashtable GetEvents(UUID requestID, UUID sessionID)
556 { 556 {
557 UrlData url = null; 557 UrlData url = null;
558 RequestData requestData = null; 558 RequestData requestData = null;
@@ -757,7 +757,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
757 } 757 }
758 } 758 }
759 759
760 private void OnScriptReset(uint localID, UUID itemID) 760 protected void OnScriptReset(uint localID, UUID itemID)
761 { 761 {
762 ScriptRemoved(itemID); 762 ScriptRemoved(itemID);
763 } 763 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs
index 9e75ee2..2e6f472 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs
@@ -85,12 +85,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Profile
85 85
86 public LocalUserProfilesServicesConnector() 86 public LocalUserProfilesServicesConnector()
87 { 87 {
88 m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector no params"); 88 //m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector no params");
89 } 89 }
90 90
91 public LocalUserProfilesServicesConnector(IConfigSource source) 91 public LocalUserProfilesServicesConnector(IConfigSource source)
92 { 92 {
93 m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector instantiated directly."); 93 //m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector instantiated directly.");
94 InitialiseService(source); 94 InitialiseService(source);
95 } 95 }
96 96
@@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Profile
104 IConfig config = source.Configs[ConfigName]; 104 IConfig config = source.Configs[ConfigName];
105 if (config == null) 105 if (config == null)
106 { 106 {
107 m_log.Error("[LOCAL USERPROFILES SERVICE CONNECTOR]: UserProfilesService missing from OpenSim.ini"); 107 //m_log.Error("[LOCAL USERPROFILES SERVICE CONNECTOR]: UserProfilesService missing from OpenSim.ini");
108 return; 108 return;
109 } 109 }
110 110
@@ -225,4 +225,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Profile
225 } 225 }
226 #endregion 226 #endregion
227 } 227 }
228} \ No newline at end of file 228}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
index f5aa971..92ae36f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
@@ -209,7 +209,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
209 209
210 if (m_Cache != null) 210 if (m_Cache != null)
211 { 211 {
212 asset = m_Cache.Get(id); 212 if (!m_Cache.Get(id, out asset))
213 return null;
213 214
214 if (asset != null) 215 if (asset != null)
215 return asset; 216 return asset;
@@ -238,10 +239,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
238 239
239 public AssetBase GetCached(string id) 240 public AssetBase GetCached(string id)
240 { 241 {
242 AssetBase asset = null;
241 if (m_Cache != null) 243 if (m_Cache != null)
242 return m_Cache.Get(id); 244 m_Cache.Get(id, out asset);
243 245
244 return null; 246 return asset;
245 } 247 }
246 248
247 public AssetMetadata GetMetadata(string id) 249 public AssetMetadata GetMetadata(string id)
@@ -250,8 +252,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
250 252
251 if (m_Cache != null) 253 if (m_Cache != null)
252 { 254 {
253 if (m_Cache != null) 255 if (!m_Cache.Get(id, out asset))
254 m_Cache.Get(id); 256 return null;
255 257
256 if (asset != null) 258 if (asset != null)
257 return asset.Metadata; 259 return asset.Metadata;
@@ -273,8 +275,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
273 275
274 if (m_Cache != null) 276 if (m_Cache != null)
275 { 277 {
276 if (m_Cache != null) 278 if (!m_Cache.Get(id, out asset))
277 m_Cache.Get(id); 279 return null;
278 280
279 if (asset != null) 281 if (asset != null)
280 return asset.Data; 282 return asset.Data;
@@ -292,7 +294,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
292 AssetBase asset = null; 294 AssetBase asset = null;
293 295
294 if (m_Cache != null) 296 if (m_Cache != null)
295 asset = m_Cache.Get(id); 297 {
298 if (!m_Cache.Get(id, out asset))
299 return false;
300 }
296 301
297 if (asset != null) 302 if (asset != null)
298 { 303 {
@@ -382,7 +387,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
382 AssetBase asset = null; 387 AssetBase asset = null;
383 388
384 if (m_Cache != null) 389 if (m_Cache != null)
385 asset = m_Cache.Get(id); 390 m_Cache.Get(id, out asset);
386 391
387 if (asset != null) 392 if (asset != null)
388 { 393 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
index 7190aa0..37a48bb 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
@@ -158,7 +158,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
158 158
159 AssetBase asset = null; 159 AssetBase asset = null;
160 if (m_Cache != null) 160 if (m_Cache != null)
161 asset = m_Cache.Get(id); 161 {
162 if (!m_Cache.Get(id, out asset))
163 return null;
164 }
162 165
163 if (asset == null) 166 if (asset == null)
164 { 167 {
@@ -177,17 +180,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
177 { 180 {
178// m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Cache request for {0}", id); 181// m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Cache request for {0}", id);
179 182
183 AssetBase asset = null;
180 if (m_Cache != null) 184 if (m_Cache != null)
181 return m_Cache.Get(id); 185 m_Cache.Get(id, out asset);
182 186
183 return null; 187 return asset;
184 } 188 }
185 189
186 public AssetMetadata GetMetadata(string id) 190 public AssetMetadata GetMetadata(string id)
187 { 191 {
188 AssetBase asset = null; 192 AssetBase asset = null;
189 if (m_Cache != null) 193 if (m_Cache != null)
190 asset = m_Cache.Get(id); 194 {
195 if (!m_Cache.Get(id, out asset))
196 return null;
197 }
191 198
192 if (asset != null) 199 if (asset != null)
193 return asset.Metadata; 200 return asset.Metadata;
@@ -210,7 +217,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
210 AssetBase asset = null; 217 AssetBase asset = null;
211 218
212 if (m_Cache != null) 219 if (m_Cache != null)
213 asset = m_Cache.Get(id); 220 {
221 if (!m_Cache.Get(id, out asset))
222 return null;
223 }
214 224
215 if (asset != null) 225 if (asset != null)
216 return asset.Data; 226 return asset.Data;
@@ -232,7 +242,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
232 242
233 if (m_Cache != null) 243 if (m_Cache != null)
234 { 244 {
235 AssetBase asset = m_Cache.Get(id); 245 AssetBase asset;
246 if (!m_Cache.Get(id, out asset))
247 return false;
236 248
237 if (asset != null) 249 if (asset != null)
238 { 250 {
@@ -287,7 +299,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
287 { 299 {
288 AssetBase asset = null; 300 AssetBase asset = null;
289 if (m_Cache != null) 301 if (m_Cache != null)
290 m_Cache.Get(id); 302 m_Cache.Get(id, out asset);
291 if (asset != null) 303 if (asset != null)
292 { 304 {
293 asset.Data = data; 305 asset.Data = data;
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 5d12f8b..53b9796 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -149,9 +149,11 @@ namespace OpenSim.Region.CoreModules.World.Land
149 parcelInfoCache.Size = 30; // the number of different parcel requests in this region to cache 149 parcelInfoCache.Size = 30; // the number of different parcel requests in this region to cache
150 parcelInfoCache.DefaultTTL = new TimeSpan(0, 5, 0); 150 parcelInfoCache.DefaultTTL = new TimeSpan(0, 5, 0);
151 151
152 m_scene.EventManager.OnObjectAddedToScene += EventManagerOnParcelPrimCountAdd;
152 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd; 153 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd;
153 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate; 154
154 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene; 155 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene;
156 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate;
155 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate; 157 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate;
156 158
157 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel; 159 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel;
@@ -287,8 +289,10 @@ namespace OpenSim.Region.CoreModules.World.Land
287 289
288 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, 290 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0,
289 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY)); 291 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY));
290 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 292 LandData ldata = fullSimParcel.LandData;
291 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 293 ldata.SimwideArea = ldata.Area;
294 ldata.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
295 ldata.ClaimDate = Util.UnixTimeSinceEpoch();
292 296
293 return AddLandObject(fullSimParcel); 297 return AddLandObject(fullSimParcel);
294 } 298 }
@@ -813,6 +817,9 @@ namespace OpenSim.Region.CoreModules.World.Land
813 throw new Exception("Error: Parcel not found at point " + x + ", " + y); 817 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
814 } 818 }
815 819
820 if(m_landList.Count == 0 || m_landIDList == null)
821 return null;
822
816 lock (m_landIDList) 823 lock (m_landIDList)
817 { 824 {
818 try 825 try
@@ -824,8 +831,6 @@ namespace OpenSim.Region.CoreModules.World.Land
824 return null; 831 return null;
825 } 832 }
826 } 833 }
827
828 return m_landList[m_landIDList[x / 4, y / 4]];
829 } 834 }
830 835
831 // Create a 'parcel is here' bitmap for the parcel identified by the passed landID 836 // Create a 'parcel is here' bitmap for the parcel identified by the passed landID
@@ -1576,6 +1581,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1576 } 1581 }
1577 } 1582 }
1578 } 1583 }
1584 FinalizeLandPrimCountUpdate(); // update simarea information
1579 } 1585 }
1580 } 1586 }
1581 1587
@@ -1640,9 +1646,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1640 foreach (HashSet<SceneObjectGroup> objs in returns.Values) 1646 foreach (HashSet<SceneObjectGroup> objs in returns.Values)
1641 { 1647 {
1642 List<SceneObjectGroup> objs2 = new List<SceneObjectGroup>(objs); 1648 List<SceneObjectGroup> objs2 = new List<SceneObjectGroup>(objs);
1643 if (m_scene.Permissions.CanReturnObjects(null, remoteClient.AgentId, objs2)) 1649 if (m_scene.Permissions.CanReturnObjects(null, remoteClient, objs2))
1644 { 1650 {
1645 m_scene.returnObjects(objs2.ToArray(), remoteClient.AgentId); 1651 m_scene.returnObjects(objs2.ToArray(), remoteClient);
1646 } 1652 }
1647 else 1653 else
1648 { 1654 {
@@ -2035,7 +2041,7 @@ namespace OpenSim.Region.CoreModules.World.Land
2035 { 2041 {
2036 SceneObjectGroup[] objs = new SceneObjectGroup[1]; 2042 SceneObjectGroup[] objs = new SceneObjectGroup[1];
2037 objs[0] = obj; 2043 objs[0] = obj;
2038 ((Scene)client.Scene).returnObjects(objs, client.AgentId); 2044 ((Scene)client.Scene).returnObjects(objs, client);
2039 } 2045 }
2040 2046
2041 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); 2047 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 73b4cb5..2b5cb31 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -356,6 +356,7 @@ namespace OpenSim.Region.CoreModules.World.Land
356 } 356 }
357 } 357 }
358 358
359 // the total prims a parcel owner can have on a region
359 public int GetSimulatorMaxPrimCount() 360 public int GetSimulatorMaxPrimCount()
360 { 361 {
361 if (overrideSimulatorMaxPrimCount != null) 362 if (overrideSimulatorMaxPrimCount != null)
@@ -370,7 +371,7 @@ namespace OpenSim.Region.CoreModules.World.Land
370 * (double)m_scene.RegionInfo.RegionSettings.ObjectBonus 371 * (double)m_scene.RegionInfo.RegionSettings.ObjectBonus
371 / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY) 372 / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY)
372 +0.5 ); 373 +0.5 );
373 374 // sanity check
374 if(simMax > m_scene.RegionInfo.ObjectCapacity) 375 if(simMax > m_scene.RegionInfo.ObjectCapacity)
375 simMax = m_scene.RegionInfo.ObjectCapacity; 376 simMax = m_scene.RegionInfo.ObjectCapacity;
376 //m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}, SimWidePrims {3}", 377 //m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}, SimWidePrims {3}",
@@ -1043,7 +1044,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1043 else 1044 else
1044 LandData.AABBMax = new Vector3(tx, ty, (float)m_scene.Heightmap[tx - 1, ty - 1]); 1045 LandData.AABBMax = new Vector3(tx, ty, (float)m_scene.Heightmap[tx - 1, ty - 1]);
1045 1046
1046 LandData.Area = tempArea * landUnit * landUnit; 1047 tempArea *= landUnit * landUnit;
1048 LandData.Area = tempArea;
1047 } 1049 }
1048 1050
1049 #endregion 1051 #endregion
@@ -1647,8 +1649,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1647 { 1649 {
1648 foreach (SceneObjectGroup obj in primsOverMe) 1650 foreach (SceneObjectGroup obj in primsOverMe)
1649 { 1651 {
1650 if (obj.OwnerID == previousOwner && obj.GroupID == UUID.Zero && 1652 if(m_scene.Permissions.CanSellObject(previousOwner,obj, (byte)SaleType.Original))
1651 (obj.GetEffectivePermissions() & (uint)(OpenSim.Framework.PermissionMask.Transfer)) != 0)
1652 m_BuySellModule.BuyObject(sp.ControllingClient, UUID.Zero, obj.LocalId, 1, 0); 1653 m_BuySellModule.BuyObject(sp.ControllingClient, UUID.Zero, obj.LocalId, 1, 0);
1653 } 1654 }
1654 } 1655 }
@@ -1662,7 +1663,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1662 { 1663 {
1663 SceneObjectGroup[] objs = new SceneObjectGroup[1]; 1664 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1664 objs[0] = obj; 1665 objs[0] = obj;
1665 m_scene.returnObjects(objs, obj.OwnerID); 1666 m_scene.returnObjects(objs, null);
1666 } 1667 }
1667 1668
1668 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client) 1669 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client)
@@ -1693,6 +1694,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1693 { 1694 {
1694 if (obj.GroupID == LandData.GroupID) 1695 if (obj.GroupID == LandData.GroupID)
1695 { 1696 {
1697 if (obj.OwnerID == LandData.OwnerID)
1698 continue;
1696 if (!returns.ContainsKey(obj.OwnerID)) 1699 if (!returns.ContainsKey(obj.OwnerID))
1697 returns[obj.OwnerID] = 1700 returns[obj.OwnerID] =
1698 new List<SceneObjectGroup>(); 1701 new List<SceneObjectGroup>();
@@ -1734,8 +1737,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1734 1737
1735 foreach (List<SceneObjectGroup> ol in returns.Values) 1738 foreach (List<SceneObjectGroup> ol in returns.Values)
1736 { 1739 {
1737 if (m_scene.Permissions.CanReturnObjects(this, remote_client.AgentId, ol)) 1740 if (m_scene.Permissions.CanReturnObjects(this, remote_client, ol))
1738 m_scene.returnObjects(ol.ToArray(), remote_client.AgentId); 1741 m_scene.returnObjects(ol.ToArray(), remote_client);
1739 } 1742 }
1740 } 1743 }
1741 1744
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 857f919..2a720db 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -92,10 +92,8 @@ namespace OpenSim.Region.CoreModules.World.Land
92 m_Scene.RegisterModuleInterface<IPrimCountModule>(this); 92 m_Scene.RegisterModuleInterface<IPrimCountModule>(this);
93 93
94 m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd; 94 m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd;
95 m_Scene.EventManager.OnObjectBeingRemovedFromScene += 95 m_Scene.EventManager.OnObjectBeingRemovedFromScene += OnObjectBeingRemovedFromScene;
96 OnObjectBeingRemovedFromScene; 96 m_Scene.EventManager.OnParcelPrimCountTainted += OnParcelPrimCountTainted;
97 m_Scene.EventManager.OnParcelPrimCountTainted +=
98 OnParcelPrimCountTainted;
99 m_Scene.EventManager.OnLandObjectAdded += delegate(ILandObject lo) { OnParcelPrimCountTainted(); }; 97 m_Scene.EventManager.OnLandObjectAdded += delegate(ILandObject lo) { OnParcelPrimCountTainted(); };
100 } 98 }
101 99
@@ -215,29 +213,15 @@ namespace OpenSim.Region.CoreModules.World.Land
215 else 213 else
216 parcelCounts.Users[obj.OwnerID] = partCount; 214 parcelCounts.Users[obj.OwnerID] = partCount;
217 215
218 if (obj.IsSelected) 216 if (obj.IsSelected || obj.GetSittingAvatarsCount() > 0)
219 {
220 parcelCounts.Selected += partCount; 217 parcelCounts.Selected += partCount;
221 } 218
219 if (obj.OwnerID == landData.OwnerID)
220 parcelCounts.Owner += partCount;
221 else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID)
222 parcelCounts.Group += partCount;
222 else 223 else
223 { 224 parcelCounts.Others += partCount;
224 if (landData.IsGroupOwned)
225 {
226 if (obj.OwnerID == landData.GroupID)
227 parcelCounts.Owner += partCount;
228 else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID)
229 parcelCounts.Group += partCount;
230 else
231 parcelCounts.Others += partCount;
232 }
233 else
234 {
235 if (obj.OwnerID == landData.OwnerID)
236 parcelCounts.Owner += partCount;
237 else
238 parcelCounts.Others += partCount;
239 }
240 }
241 } 225 }
242 } 226 }
243 227
@@ -393,7 +377,6 @@ namespace OpenSim.Region.CoreModules.World.Land
393 count = counts.Owner; 377 count = counts.Owner;
394 count += counts.Group; 378 count += counts.Group;
395 count += counts.Others; 379 count += counts.Others;
396 count += counts.Selected;
397 } 380 }
398 } 381 }
399 382
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
index 0d8ece7..a349aa1 100644
--- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
+++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
@@ -151,7 +151,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
151 151
152 SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); 152 SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
153 m_scene.AddNewSceneObject(sog, false); 153 m_scene.AddNewSceneObject(sog, false);
154 m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity); 154 m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, m_userId, UUID.Zero, Quaternion.Identity, false);
155 155
156 Assert.That(pc.Owner, Is.EqualTo(6)); 156 Assert.That(pc.Owner, Is.EqualTo(6));
157 Assert.That(pc.Group, Is.EqualTo(0)); 157 Assert.That(pc.Group, Is.EqualTo(0));
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 2837358..90d65c7 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -89,28 +89,23 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
89 if (part == null) 89 if (part == null)
90 return; 90 return;
91 91
92 if (part.ParentGroup.IsDeleted) 92 SceneObjectGroup sog = part.ParentGroup;
93 if (sog == null || sog.IsDeleted)
93 return; 94 return;
94 95
95 if (part.OwnerID != part.GroupID && part.OwnerID != client.AgentId && (!m_scene.Permissions.IsGod(client.AgentId))) 96 // Does the user have the power to put the object on sale?
96 return; 97 if (!m_scene.Permissions.CanSellObject(client, sog, saleType))
97
98 if (part.OwnerID == part.GroupID) // Group owned
99 { 98 {
100 // Does the user have the power to put the object on sale? 99 client.SendAgentAlertMessage("You don't have permission to set object on sale", false);
101 if (!m_scene.Permissions.CanSellGroupObject(client.AgentId, part.GroupID, m_scene)) 100 return;
102 {
103 client.SendAgentAlertMessage("You don't have permission to set group-owned objects on sale", false);
104 return;
105 }
106 } 101 }
107 102
108 part = part.ParentGroup.RootPart; 103 part = sog.RootPart;
109 104
110 part.ObjectSaleType = saleType; 105 part.ObjectSaleType = saleType;
111 part.SalePrice = salePrice; 106 part.SalePrice = salePrice;
112 107
113 part.ParentGroup.HasGroupChanged = true; 108 sog.HasGroupChanged = true;
114 109
115 part.SendPropertiesToClient(client); 110 part.SendPropertiesToClient(client);
116 } 111 }
@@ -127,7 +122,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
127 switch (saleType) 122 switch (saleType)
128 { 123 {
129 case 1: // Sell as original (in-place sale) 124 case 1: // Sell as original (in-place sale)
130 uint effectivePerms = group.GetEffectivePermissions(); 125 uint effectivePerms = group.EffectiveOwnerPerms;
131 126
132 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) 127 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
133 { 128 {
@@ -136,8 +131,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
136 return false; 131 return false;
137 } 132 }
138 133
139 group.SetOwnerId(remoteClient.AgentId); 134 group.SetOwner(remoteClient.AgentId, remoteClient.ActiveGroupId);
140 group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId);
141 135
142 if (m_scene.Permissions.PropagatePermissions()) 136 if (m_scene.Permissions.PropagatePermissions())
143 { 137 {
@@ -147,6 +141,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
147 child.TriggerScriptChangedEvent(Changed.OWNER); 141 child.TriggerScriptChangedEvent(Changed.OWNER);
148 child.ApplyNextOwnerPermissions(); 142 child.ApplyNextOwnerPermissions();
149 } 143 }
144 group.AggregatePerms();
150 } 145 }
151 146
152 part.ObjectSaleType = 0; 147 part.ObjectSaleType = 0;
@@ -174,7 +169,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
174 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group); 169 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
175 group.AbsolutePosition = originalPosition; 170 group.AbsolutePosition = originalPosition;
176 171
177 uint perms = group.GetEffectivePermissions(); 172 uint perms = group.EffectiveOwnerPerms;
178 173
179 if ((perms & (uint)PermissionMask.Transfer) == 0) 174 if ((perms & (uint)PermissionMask.Transfer) == 0)
180 { 175 {
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 75d90f3..8eee864 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -49,6 +49,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 protected Scene m_scene; 51 protected Scene m_scene;
52 protected ScenePermissions scenePermissions;
52 protected bool m_Enabled; 53 protected bool m_Enabled;
53 54
54 private InventoryFolderImpl m_libraryRootFolder; 55 private InventoryFolderImpl m_libraryRootFolder;
@@ -69,15 +70,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
69 } 70 }
70 71
71 #region Constants 72 #region Constants
72 // These are here for testing. They will be taken out
73
74 //private uint PERM_ALL = (uint)2147483647;
75 private uint PERM_COPY = (uint)32768;
76 //private uint PERM_MODIFY = (uint)16384;
77 private uint PERM_MOVE = (uint)524288;
78 private uint PERM_TRANS = (uint)8192;
79 private uint PERM_LOCKED = (uint)540672;
80
81 /// <value> 73 /// <value>
82 /// Different user set names that come in from the configuration file. 74 /// Different user set names that come in from the configuration file.
83 /// </value> 75 /// </value>
@@ -96,14 +88,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions
96 private bool m_bypassPermissionsValue = true; 88 private bool m_bypassPermissionsValue = true;
97 private bool m_propagatePermissions = false; 89 private bool m_propagatePermissions = false;
98 private bool m_debugPermissions = false; 90 private bool m_debugPermissions = false;
99 private bool m_allowGridGods = false; 91 private bool m_allowGridAdmins = false;
100 private bool m_RegionOwnerIsGod = false; 92 private bool m_RegionOwnerIsAdmin = false;
101 private bool m_RegionManagerIsGod = false; 93 private bool m_RegionManagerIsAdmin = false;
102 private bool m_forceGridGodsOnly; 94 private bool m_forceGridAdminsOnly;
103 private bool m_forceGodModeAlwaysOn; 95 private bool m_forceAdminModeAlwaysOn;
104 private bool m_allowGodActionsWithoutGodMode; 96 private bool m_allowAdminActionsWithoutGodMode;
105
106 private bool m_SimpleBuildPermissions = false;
107 97
108 /// <value> 98 /// <value>
109 /// The set of users that are allowed to create scripts. This is only active if permissions are not being 99 /// The set of users that are allowed to create scripts. This is only active if permissions are not being
@@ -172,25 +162,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
172 162
173 string[] sections = new string[] { "Startup", "Permissions" }; 163 string[] sections = new string[] { "Startup", "Permissions" };
174 164
175 m_allowGridGods = Util.GetConfigVarFromSections<bool>(config, "allow_grid_gods", sections, false); 165 m_allowGridAdmins = Util.GetConfigVarFromSections<bool>(config, "allow_grid_gods", sections, false);
176 m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(config, "serverside_object_permissions", sections, true); 166 m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(config, "serverside_object_permissions", sections, true);
177 m_propagatePermissions = Util.GetConfigVarFromSections<bool>(config, "propagate_permissions", sections, true); 167 m_propagatePermissions = Util.GetConfigVarFromSections<bool>(config, "propagate_permissions", sections, true);
178 168
179 m_forceGridGodsOnly = Util.GetConfigVarFromSections<bool>(config, "force_grid_gods_only", sections, false); 169 m_forceGridAdminsOnly = Util.GetConfigVarFromSections<bool>(config, "force_grid_gods_only", sections, false);
180 if(!m_forceGridGodsOnly) 170 if(!m_forceGridAdminsOnly)
181 { 171 {
182 m_RegionOwnerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_owner_is_god",sections, true); 172 m_RegionOwnerIsAdmin = Util.GetConfigVarFromSections<bool>(config, "region_owner_is_god",sections, true);
183 m_RegionManagerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_manager_is_god",sections, false); 173 m_RegionManagerIsAdmin = Util.GetConfigVarFromSections<bool>(config, "region_manager_is_god",sections, false);
184 } 174 }
185 else 175 else
186 m_allowGridGods = true; 176 m_allowGridAdmins = true;
187 177
188 m_forceGodModeAlwaysOn = Util.GetConfigVarFromSections<bool>(config, "automatic_gods", sections, false); 178 m_forceAdminModeAlwaysOn = Util.GetConfigVarFromSections<bool>(config, "automatic_gods", sections, false);
189 m_allowGodActionsWithoutGodMode = Util.GetConfigVarFromSections<bool>(config, "implicit_gods", sections, false); 179 m_allowAdminActionsWithoutGodMode = Util.GetConfigVarFromSections<bool>(config, "implicit_gods", sections, false);
190 if(m_allowGodActionsWithoutGodMode) 180 if(m_allowAdminActionsWithoutGodMode)
191 m_forceGodModeAlwaysOn = false; 181 m_forceAdminModeAlwaysOn = false;
192
193 m_SimpleBuildPermissions = Util.GetConfigVarFromSections<bool>(config, "simple_build_permissions",sections, false);
194 182
195 m_allowedScriptCreators 183 m_allowedScriptCreators
196 = ParseUserSetConfigSetting(config, "allowed_script_creators", m_allowedScriptCreators); 184 = ParseUserSetConfigSetting(config, "allowed_script_creators", m_allowedScriptCreators);
@@ -266,63 +254,78 @@ namespace OpenSim.Region.CoreModules.World.Permissions
266 m_scene = scene; 254 m_scene = scene;
267 255
268 scene.RegisterModuleInterface<IPermissionsModule>(this); 256 scene.RegisterModuleInterface<IPermissionsModule>(this);
257 scenePermissions = m_scene.Permissions;
269 258
270 //Register functions with Scene External Checks! 259 //Register functions with Scene External Checks!
271 m_scene.Permissions.OnBypassPermissions += BypassPermissions; 260 scenePermissions.OnBypassPermissions += BypassPermissions;
272 m_scene.Permissions.OnSetBypassPermissions += SetBypassPermissions; 261 scenePermissions.OnSetBypassPermissions += SetBypassPermissions;
273 m_scene.Permissions.OnPropagatePermissions += PropagatePermissions; 262 scenePermissions.OnPropagatePermissions += PropagatePermissions;
274 m_scene.Permissions.OnGenerateClientFlags += GenerateClientFlags; 263
275 m_scene.Permissions.OnAbandonParcel += CanAbandonParcel; 264 scenePermissions.OnIsGridGod += IsGridAdministrator;
276 m_scene.Permissions.OnReclaimParcel += CanReclaimParcel; 265 scenePermissions.OnIsAdministrator += IsAdministrator;
277 m_scene.Permissions.OnDeedParcel += CanDeedParcel; 266 scenePermissions.OnIsEstateManager += IsEstateManager;
278 m_scene.Permissions.OnDeedObject += CanDeedObject; 267
279 m_scene.Permissions.OnIsGod += IsGod; 268 scenePermissions.OnGenerateClientFlags += GenerateClientFlags;
280 m_scene.Permissions.OnIsGridGod += IsGridGod; 269
281 m_scene.Permissions.OnIsAdministrator += IsAdministrator; 270 scenePermissions.OnIssueEstateCommand += CanIssueEstateCommand;
282 m_scene.Permissions.OnIsEstateManager += IsEstateManager; 271 scenePermissions.OnRunConsoleCommand += CanRunConsoleCommand;
283 m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; 272
284 m_scene.Permissions.OnDeleteObject += CanDeleteObject; 273 scenePermissions.OnTeleport += CanTeleport;
285 m_scene.Permissions.OnEditObject += CanEditObject; 274
286 m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties; 275 scenePermissions.OnInstantMessage += CanInstantMessage;
287 m_scene.Permissions.OnInstantMessage += CanInstantMessage; 276
288 m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer; 277 scenePermissions.OnAbandonParcel += CanAbandonParcel;
289 m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; 278 scenePermissions.OnReclaimParcel += CanReclaimParcel;
290 m_scene.Permissions.OnMoveObject += CanMoveObject; 279 scenePermissions.OnDeedParcel += CanDeedParcel;
291 m_scene.Permissions.OnObjectEntry += CanObjectEntry; 280 scenePermissions.OnSellParcel += CanSellParcel;
292 m_scene.Permissions.OnReturnObjects += CanReturnObjects; 281 scenePermissions.OnEditParcelProperties += CanEditParcelProperties;
293 m_scene.Permissions.OnRezObject += CanRezObject; 282 scenePermissions.OnTerraformLand += CanTerraformLand;
294 m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; 283 scenePermissions.OnBuyLand += CanBuyLand;
295 m_scene.Permissions.OnRunScript += CanRunScript; 284
296 m_scene.Permissions.OnCompileScript += CanCompileScript; 285 scenePermissions.OnReturnObjects += CanReturnObjects;
297 m_scene.Permissions.OnSellParcel += CanSellParcel; 286
298 m_scene.Permissions.OnTakeObject += CanTakeObject; 287 scenePermissions.OnRezObject += CanRezObject;
299 m_scene.Permissions.OnSellGroupObject += CanSellGroupObject; 288 scenePermissions.OnObjectEntry += CanObjectEntry;
300 m_scene.Permissions.OnTakeCopyObject += CanTakeCopyObject; 289 scenePermissions.OnObjectEnterWithScripts += OnObjectEnterWithScripts;
301 m_scene.Permissions.OnTerraformLand += CanTerraformLand; 290
302 m_scene.Permissions.OnLinkObject += CanLinkObject; 291 scenePermissions.OnDuplicateObject += CanDuplicateObject;
303 m_scene.Permissions.OnDelinkObject += CanDelinkObject; 292 scenePermissions.OnDeleteObjectByIDs += CanDeleteObjectByIDs;
304 m_scene.Permissions.OnBuyLand += CanBuyLand; 293 scenePermissions.OnDeleteObject += CanDeleteObject;
305 294 scenePermissions.OnEditObjectByIDs += CanEditObjectByIDs;
306 m_scene.Permissions.OnViewNotecard += CanViewNotecard; 295 scenePermissions.OnEditObject += CanEditObject;
307 m_scene.Permissions.OnViewScript += CanViewScript; 296 scenePermissions.OnInventoryTransfer += CanInventoryTransfer;
308 m_scene.Permissions.OnEditNotecard += CanEditNotecard; 297 scenePermissions.OnMoveObject += CanMoveObject;
309 m_scene.Permissions.OnEditScript += CanEditScript; 298 scenePermissions.OnTakeObject += CanTakeObject;
310 299 scenePermissions.OnTakeCopyObject += CanTakeCopyObject;
311 m_scene.Permissions.OnCreateObjectInventory += CanCreateObjectInventory; 300 scenePermissions.OnLinkObject += CanLinkObject;
312 m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory; 301 scenePermissions.OnDelinkObject += CanDelinkObject;
313 m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory; 302 scenePermissions.OnDeedObject += CanDeedObject;
314 m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory; 303 scenePermissions.OnSellGroupObject += CanSellGroupObject;
315 m_scene.Permissions.OnResetScript += CanResetScript; 304 scenePermissions.OnSellObjectByUserID += CanSellObjectByUserID;
316 305 scenePermissions.OnSellObject += CanSellObject;
317 m_scene.Permissions.OnCreateUserInventory += CanCreateUserInventory; 306
318 m_scene.Permissions.OnCopyUserInventory += CanCopyUserInventory; 307 scenePermissions.OnCreateObjectInventory += CanCreateObjectInventory;
319 m_scene.Permissions.OnEditUserInventory += CanEditUserInventory; 308 scenePermissions.OnEditObjectInventory += CanEditObjectInventory;
320 m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; 309 scenePermissions.OnCopyObjectInventory += CanCopyObjectInventory;
321 310 scenePermissions.OnDeleteObjectInventory += CanDeleteObjectInventory;
322 m_scene.Permissions.OnTeleport += CanTeleport; 311 scenePermissions.OnDoObjectInvToObjectInv += CanDoObjectInvToObjectInv;
323 312 scenePermissions.OnDropInObjectInv += CanDropInObjectInv;
324 m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia; 313
325 m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia; 314 scenePermissions.OnViewNotecard += CanViewNotecard;
315 scenePermissions.OnViewScript += CanViewScript;
316 scenePermissions.OnEditNotecard += CanEditNotecard;
317 scenePermissions.OnEditScript += CanEditScript;
318 scenePermissions.OnResetScript += CanResetScript;
319 scenePermissions.OnRunScript += CanRunScript;
320 scenePermissions.OnCompileScript += CanCompileScript;
321
322 scenePermissions.OnCreateUserInventory += CanCreateUserInventory;
323 scenePermissions.OnCopyUserInventory += CanCopyUserInventory;
324 scenePermissions.OnEditUserInventory += CanEditUserInventory;
325 scenePermissions.OnDeleteUserInventory += CanDeleteUserInventory;
326
327 scenePermissions.OnControlPrimMedia += CanControlPrimMedia;
328 scenePermissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia;
326 329
327 m_scene.AddCommand("Users", this, "bypass permissions", 330 m_scene.AddCommand("Users", this, "bypass permissions",
328 "bypass permissions <true / false>", 331 "bypass permissions <true / false>",
@@ -351,6 +354,78 @@ namespace OpenSim.Region.CoreModules.World.Permissions
351 return; 354 return;
352 355
353 m_scene.UnregisterModuleInterface<IPermissionsModule>(this); 356 m_scene.UnregisterModuleInterface<IPermissionsModule>(this);
357
358 scenePermissions.OnBypassPermissions -= BypassPermissions;
359 scenePermissions.OnSetBypassPermissions -= SetBypassPermissions;
360 scenePermissions.OnPropagatePermissions -= PropagatePermissions;
361
362 scenePermissions.OnIsGridGod -= IsGridAdministrator;
363 scenePermissions.OnIsAdministrator -= IsAdministrator;
364 scenePermissions.OnIsEstateManager -= IsEstateManager;
365
366 scenePermissions.OnGenerateClientFlags -= GenerateClientFlags;
367
368 scenePermissions.OnIssueEstateCommand -= CanIssueEstateCommand;
369 scenePermissions.OnRunConsoleCommand -= CanRunConsoleCommand;
370
371 scenePermissions.OnTeleport -= CanTeleport;
372
373 scenePermissions.OnInstantMessage -= CanInstantMessage;
374
375 scenePermissions.OnAbandonParcel -= CanAbandonParcel;
376 scenePermissions.OnReclaimParcel -= CanReclaimParcel;
377 scenePermissions.OnDeedParcel -= CanDeedParcel;
378 scenePermissions.OnSellParcel -= CanSellParcel;
379 scenePermissions.OnEditParcelProperties -= CanEditParcelProperties;
380 scenePermissions.OnTerraformLand -= CanTerraformLand;
381 scenePermissions.OnBuyLand -= CanBuyLand;
382
383 scenePermissions.OnRezObject -= CanRezObject;
384 scenePermissions.OnObjectEntry -= CanObjectEntry;
385 scenePermissions.OnObjectEnterWithScripts -= OnObjectEnterWithScripts;
386
387 scenePermissions.OnReturnObjects -= CanReturnObjects;
388
389 scenePermissions.OnDuplicateObject -= CanDuplicateObject;
390 scenePermissions.OnDeleteObjectByIDs -= CanDeleteObjectByIDs;
391 scenePermissions.OnDeleteObject -= CanDeleteObject;
392 scenePermissions.OnEditObjectByIDs -= CanEditObjectByIDs;
393 scenePermissions.OnEditObject -= CanEditObject;
394 scenePermissions.OnInventoryTransfer -= CanInventoryTransfer;
395 scenePermissions.OnMoveObject -= CanMoveObject;
396 scenePermissions.OnTakeObject -= CanTakeObject;
397 scenePermissions.OnTakeCopyObject -= CanTakeCopyObject;
398 scenePermissions.OnLinkObject -= CanLinkObject;
399 scenePermissions.OnDelinkObject -= CanDelinkObject;
400 scenePermissions.OnDeedObject -= CanDeedObject;
401
402 scenePermissions.OnSellGroupObject -= CanSellGroupObject;
403 scenePermissions.OnSellObjectByUserID -= CanSellObjectByUserID;
404 scenePermissions.OnSellObject -= CanSellObject;
405
406 scenePermissions.OnCreateObjectInventory -= CanCreateObjectInventory;
407 scenePermissions.OnEditObjectInventory -= CanEditObjectInventory;
408 scenePermissions.OnCopyObjectInventory -= CanCopyObjectInventory;
409 scenePermissions.OnDeleteObjectInventory -= CanDeleteObjectInventory;
410 scenePermissions.OnDoObjectInvToObjectInv -= CanDoObjectInvToObjectInv;
411 scenePermissions.OnDropInObjectInv -= CanDropInObjectInv;
412
413 scenePermissions.OnViewNotecard -= CanViewNotecard;
414 scenePermissions.OnViewScript -= CanViewScript;
415 scenePermissions.OnEditNotecard -= CanEditNotecard;
416 scenePermissions.OnEditScript -= CanEditScript;
417 scenePermissions.OnResetScript -= CanResetScript;
418 scenePermissions.OnRunScript -= CanRunScript;
419 scenePermissions.OnCompileScript -= CanCompileScript;
420
421 scenePermissions.OnCreateUserInventory -= CanCreateUserInventory;
422 scenePermissions.OnCopyUserInventory -= CanCopyUserInventory;
423 scenePermissions.OnEditUserInventory -= CanEditUserInventory;
424 scenePermissions.OnDeleteUserInventory -= CanDeleteUserInventory;
425
426 scenePermissions.OnControlPrimMedia -= CanControlPrimMedia;
427 scenePermissions.OnInteractWithPrimMedia -= CanInteractWithPrimMedia;
428
354 } 429 }
355 430
356 public void Close() 431 public void Close()
@@ -480,6 +555,36 @@ namespace OpenSim.Region.CoreModules.World.Permissions
480 return false; 555 return false;
481 } 556 }
482 557
558 protected bool GroupMemberPowers(UUID groupID, UUID userID, ref ulong powers)
559 {
560 powers = 0;
561 if (null == GroupsModule)
562 return false;
563
564 GroupMembershipData gmd = GroupsModule.GetMembershipData(groupID, userID);
565
566 if (gmd != null)
567 {
568 powers = gmd.GroupPowers;
569 return true;
570 }
571 return false;
572 }
573
574 protected bool GroupMemberPowers(UUID groupID, ScenePresence sp, ref ulong powers)
575 {
576 powers = 0;
577 IClientAPI client = sp.ControllingClient;
578 if (client == null)
579 return false;
580
581 if(!client.IsGroupMember(groupID))
582 return false;
583
584 powers = client.GetGroupPowers(groupID);
585 return true;
586 }
587
483 /// <summary> 588 /// <summary>
484 /// Parse a user set configuration setting 589 /// Parse a user set configuration setting
485 /// </summary> 590 /// </summary>
@@ -526,13 +631,13 @@ namespace OpenSim.Region.CoreModules.World.Permissions
526 if (user == UUID.Zero) 631 if (user == UUID.Zero)
527 return false; 632 return false;
528 633
529 if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod) 634 if (m_RegionOwnerIsAdmin && m_scene.RegionInfo.EstateSettings.EstateOwner == user)
530 return true; 635 return true;
531 636
532 if (IsEstateManager(user) && m_RegionManagerIsGod) 637 if (m_RegionManagerIsAdmin && IsEstateManager(user))
533 return true; 638 return true;
534 639
535 if (IsGridGod(user, null)) 640 if (IsGridAdministrator(user))
536 return true; 641 return true;
537 642
538 return false; 643 return false;
@@ -544,14 +649,15 @@ namespace OpenSim.Region.CoreModules.World.Permissions
544 /// <param name="user">The user</param> 649 /// <param name="user">The user</param>
545 /// <param name="scene">Unused, can be null</param> 650 /// <param name="scene">Unused, can be null</param>
546 /// <returns></returns> 651 /// <returns></returns>
547 protected bool IsGridGod(UUID user, Scene scene) 652 protected bool IsGridAdministrator(UUID user)
548 { 653 {
549 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 654 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
550 if (m_bypassPermissions) return m_bypassPermissionsValue; 655 if (m_bypassPermissions) return m_bypassPermissionsValue;
551 656
552 if (user == UUID.Zero) return false; 657 if (user == UUID.Zero)
658 return false;
553 659
554 if (m_allowGridGods) 660 if (m_allowGridAdmins)
555 { 661 {
556 ScenePresence sp = m_scene.GetScenePresence(user); 662 ScenePresence sp = m_scene.GetScenePresence(user);
557 if (sp != null) 663 if (sp != null)
@@ -567,10 +673,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
567 673
568 protected bool IsFriendWithPerms(UUID user, UUID objectOwner) 674 protected bool IsFriendWithPerms(UUID user, UUID objectOwner)
569 { 675 {
570 if (user == UUID.Zero) 676 if (FriendsModule == null)
571 return false; 677 return false;
572 678
573 if (FriendsModule == null) 679 if (user == UUID.Zero)
574 return false; 680 return false;
575 681
576 int friendPerms = FriendsModule.GetRightsGrantedByFriend(user, objectOwner); 682 int friendPerms = FriendsModule.GetRightsGrantedByFriend(user, objectOwner);
@@ -606,75 +712,178 @@ namespace OpenSim.Region.CoreModules.World.Permissions
606 712
607 #region Object Permissions 713 #region Object Permissions
608 714
609 public uint GenerateClientFlags(UUID user, UUID objID) 715 const uint DEFAULT_FLAGS = (uint)(
610 { 716 PrimFlags.ObjectCopy | // Tells client you can copy the object
611 // Here's the way this works, 717 PrimFlags.ObjectModify | // tells client you can modify the object
612 // ObjectFlags and Permission flags are two different enumerations 718 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
613 // ObjectFlags, however, tells the client to change what it will allow the user to do. 719 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
614 // So, that means that all of the permissions type ObjectFlags are /temporary/ and only 720 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
615 // supposed to be set when customizing the objectflags for the client. 721 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
722 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
723 );
724
725 const uint NOT_DEFAULT_FLAGS = (uint)~(
726 PrimFlags.ObjectCopy | // Tells client you can copy the object
727 PrimFlags.ObjectModify | // tells client you can modify the object
728 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
729 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
730 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
731 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
732 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
733 );
734
735 const uint EXTRAOWNERMASK = (uint)(
736 PrimFlags.ObjectYouOwner |
737 PrimFlags.ObjectAnyOwner
738 );
739
740 const uint EXTRAGODMASK = (uint)(
741 PrimFlags.ObjectYouOwner |
742 PrimFlags.ObjectAnyOwner |
743 PrimFlags.ObjectOwnerModify |
744 PrimFlags.ObjectModify |
745 PrimFlags.ObjectMove
746 );
747
748 const uint GOD_FLAGS = (uint)(
749 PrimFlags.ObjectCopy | // Tells client you can copy the object
750 PrimFlags.ObjectModify | // tells client you can modify the object
751 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
752 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
753 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
754 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
755 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
756 );
757
758 const uint LOCKED_GOD_FLAGS = (uint)(
759 PrimFlags.ObjectCopy | // Tells client you can copy the object
760 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
761 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
762 PrimFlags.ObjectAnyOwner // Tells client that someone owns the object
763 );
764
765 const uint SHAREDMASK = (uint)(
766 PermissionMask.Move |
767 PermissionMask.Modify |
768 PermissionMask.Copy
769 );
770
771 public uint GenerateClientFlags(SceneObjectPart task, ScenePresence sp, uint curEffectivePerms)
772 {
773 if(sp == null || task == null || curEffectivePerms == 0)
774 return 0;
616 775
617 // These temporary objectflags get computed and added in this function based on the 776 // Remove any of the objectFlags that are temporary. These will get added back if appropriate
618 // Permission mask that's appropriate! 777 uint objflags = curEffectivePerms & NOT_DEFAULT_FLAGS ;
619 // Outside of this method, they should never be added to objectflags!
620 // -teravus
621 778
622 SceneObjectPart task = m_scene.GetSceneObjectPart(objID); 779 uint returnMask;
623 780
624 // this shouldn't ever happen.. return no permissions/objectflags. 781 SceneObjectGroup grp = task.ParentGroup;
625 if (task == null) 782 if(grp == null)
626 return (uint)0; 783 return 0;
627 784
628 uint objflags = task.GetEffectiveObjectFlags(); 785 UUID taskOwnerID = task.OwnerID;
629 UUID objectOwner = task.OwnerID; 786 UUID spID = sp.UUID;
630 787
788 bool unlocked = (grp.RootPart.OwnerMask & (uint)PermissionMask.Move) != 0;
631 789
632 // Remove any of the objectFlags that are temporary. These will get added back if appropriate 790 if(sp.IsGod)
633 // in the next bit of code 791 {
634 792 // do locked on objects owned by admin
635 // libomv will moan about PrimFlags.ObjectYouOfficer being 793 if(!unlocked && spID == taskOwnerID)
636 // deprecated 794 return objflags | LOCKED_GOD_FLAGS;
637#pragma warning disable 0612 795 else
638 objflags &= (uint) 796 return objflags | GOD_FLAGS;
639 ~(PrimFlags.ObjectCopy | // Tells client you can copy the object 797 }
640 PrimFlags.ObjectModify | // tells client you can modify the object 798
641 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod) 799 //bypass option == owner rights
642 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it 800 if (m_bypassPermissions)
643 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
644 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
645 PrimFlags.ObjectOwnerModify | // Tells client that you're the owner of the object
646 PrimFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set
647 );
648#pragma warning restore 0612
649
650 // Creating the three ObjectFlags options for this method to choose from.
651 // Customize the OwnerMask
652 uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags);
653 objectOwnerMask |= (uint)PrimFlags.ObjectYouOwner | (uint)PrimFlags.ObjectAnyOwner | (uint)PrimFlags.ObjectOwnerModify;
654
655 // Customize the GroupMask
656 uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags);
657
658 // Customize the EveryoneMask
659 uint objectEveryoneMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags);
660 if (objectOwner != UUID.Zero)
661 objectEveryoneMask |= (uint)PrimFlags.ObjectAnyOwner;
662
663 PermissionClass permissionClass = GetPermissionClass(user, task);
664
665 switch (permissionClass)
666 { 801 {
667 case PermissionClass.Owner: 802 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, true); //??
668 return objectOwnerMask; 803 returnMask |= EXTRAOWNERMASK;
669 case PermissionClass.Group: 804 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
670 return objectGroupMask | objectEveryoneMask; 805 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
671 case PermissionClass.Everyone: 806 return returnMask;
672 default:
673 return objectEveryoneMask;
674 } 807 }
808
809 // owner
810 if (spID == taskOwnerID)
811 {
812 returnMask = ApplyObjectModifyMasks(grp.EffectiveOwnerPerms, objflags, unlocked);
813 returnMask |= EXTRAOWNERMASK;
814 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
815 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
816 return returnMask;
817 }
818
819 // if not god or owner, do attachments as everyone
820 if(task.ParentGroup.IsAttachment)
821 {
822 returnMask = ApplyObjectModifyMasks(grp.EffectiveEveryOnePerms, objflags, unlocked);
823 if (taskOwnerID != UUID.Zero)
824 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
825 return returnMask;
826 }
827
828 UUID taskGroupID = task.GroupID;
829 bool notGroupdOwned = taskOwnerID != taskGroupID;
830
831 // if friends with rights then owner
832 if (notGroupdOwned && IsFriendWithPerms(spID, taskOwnerID))
833 {
834 returnMask = ApplyObjectModifyMasks(grp.EffectiveOwnerPerms, objflags, unlocked);
835 returnMask |= EXTRAOWNERMASK;
836 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
837 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
838 return returnMask;
839 }
840
841 // group owned or shared ?
842 IClientAPI client = sp.ControllingClient;
843 ulong powers = 0;
844 if(taskGroupID != UUID.Zero && GroupMemberPowers(taskGroupID, sp, ref powers))
845 {
846 if(notGroupdOwned)
847 {
848 // group sharing or everyone
849 returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked);
850 if (taskOwnerID != UUID.Zero)
851 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
852 return returnMask;
853 }
854
855 // object is owned by group, check role powers
856 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
857 {
858 // group sharing or everyone
859 returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked);
860 returnMask |=
861 (uint)PrimFlags.ObjectGroupOwned |
862 (uint)PrimFlags.ObjectAnyOwner;
863 return returnMask;
864 }
865
866 // we may have copy without transfer
867 uint grpEffectiveOwnerPerms = grp.EffectiveOwnerPerms;
868 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
869 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
870 returnMask = ApplyObjectModifyMasks(grpEffectiveOwnerPerms, objflags, unlocked);
871 returnMask |=
872 (uint)PrimFlags.ObjectGroupOwned |
873 (uint)PrimFlags.ObjectYouOwner;
874 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
875 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
876 return returnMask;
877 }
878
879 // fallback is everyone rights
880 returnMask = ApplyObjectModifyMasks(grp.EffectiveEveryOnePerms, objflags, unlocked);
881 if (taskOwnerID != UUID.Zero)
882 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
883 return returnMask;
675 } 884 }
676 885
677 private uint ApplyObjectModifyMasks(uint setPermissionMask, uint objectFlagsMask) 886 private uint ApplyObjectModifyMasks(uint setPermissionMask, uint objectFlagsMask, bool unlocked)
678 { 887 {
679 // We are adding the temporary objectflags to the object's objectflags based on the 888 // We are adding the temporary objectflags to the object's objectflags based on the
680 // permission flag given. These change the F flags on the client. 889 // permission flag given. These change the F flags on the client.
@@ -684,14 +893,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
684 objectFlagsMask |= (uint)PrimFlags.ObjectCopy; 893 objectFlagsMask |= (uint)PrimFlags.ObjectCopy;
685 } 894 }
686 895
687 if ((setPermissionMask & (uint)PermissionMask.Move) != 0) 896 if (unlocked)
688 { 897 {
689 objectFlagsMask |= (uint)PrimFlags.ObjectMove; 898 if ((setPermissionMask & (uint)PermissionMask.Move) != 0)
690 } 899 {
900 objectFlagsMask |= (uint)PrimFlags.ObjectMove;
901 }
691 902
692 if ((setPermissionMask & (uint)PermissionMask.Modify) != 0) 903 if ((setPermissionMask & (uint)PermissionMask.Modify) != 0)
693 { 904 {
694 objectFlagsMask |= (uint)PrimFlags.ObjectModify; 905 objectFlagsMask |= (uint)PrimFlags.ObjectModify;
906 }
695 } 907 }
696 908
697 if ((setPermissionMask & (uint)PermissionMask.Transfer) != 0) 909 if ((setPermissionMask & (uint)PermissionMask.Transfer) != 0)
@@ -702,6 +914,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
702 return objectFlagsMask; 914 return objectFlagsMask;
703 } 915 }
704 916
917 // OARs still need this method that handles offline users
705 public PermissionClass GetPermissionClass(UUID user, SceneObjectPart obj) 918 public PermissionClass GetPermissionClass(UUID user, SceneObjectPart obj)
706 { 919 {
707 if (obj == null) 920 if (obj == null)
@@ -715,136 +928,199 @@ namespace OpenSim.Region.CoreModules.World.Permissions
715 if (user == objectOwner) 928 if (user == objectOwner)
716 return PermissionClass.Owner; 929 return PermissionClass.Owner;
717 930
718 if (IsFriendWithPerms(user, objectOwner) && !obj.ParentGroup.IsAttachment)
719 return PermissionClass.Owner;
720
721 // Estate users should be able to edit anything in the sim if RegionOwnerIsGod is set
722 if (m_RegionOwnerIsGod && IsEstateManager(user) && !IsAdministrator(objectOwner))
723 return PermissionClass.Owner;
724
725 // Admin should be able to edit anything in the sim (including admin objects) 931 // Admin should be able to edit anything in the sim (including admin objects)
726 if (IsAdministrator(user)) 932 if (IsAdministrator(user))
727 return PermissionClass.Owner; 933 return PermissionClass.Owner;
728 934
729/* to review later 935 if(!obj.ParentGroup.IsAttachment)
730 // Users should be able to edit what is over their land.
731 Vector3 taskPos = obj.AbsolutePosition;
732 ILandObject parcel = m_scene.LandChannel.GetLandObject(taskPos.X, taskPos.Y);
733 if (parcel != null && parcel.LandData.OwnerID == user && m_ParcelOwnerIsGod)
734 { 936 {
735 // Admin objects should not be editable by the above 937 if (IsFriendWithPerms(user, objectOwner) )
736 if (!IsAdministrator(objectOwner))
737 return PermissionClass.Owner; 938 return PermissionClass.Owner;
939
940 // Group permissions
941 if (obj.GroupID != UUID.Zero && IsGroupMember(obj.GroupID, user, 0))
942 return PermissionClass.Group;
738 } 943 }
739*/
740 // Group permissions
741 if ((obj.GroupID != UUID.Zero) && IsGroupMember(obj.GroupID, user, 0))
742 return PermissionClass.Group;
743 944
744 return PermissionClass.Everyone; 945 return PermissionClass.Everyone;
745 } 946 }
746 947
747 /// <summary> 948 // get effective object permissions using user UUID. User rights will be fixed
748 /// General permissions checks for any operation involving an object. These supplement more specific checks 949 protected uint GetObjectPermissions(UUID currentUser, SceneObjectGroup group, bool denyOnLocked)
749 /// implemented by callers.
750 /// </summary>
751 /// <param name="currentUser"></param>
752 /// <param name="objId">This is a scene object group UUID</param>
753 /// <param name="denyOnLocked"></param>
754 /// <returns></returns>
755 protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked)
756 { 950 {
757 // Default: deny 951 if (group == null)
758 bool permission = false; 952 return 0;
759 bool locked = false;
760 953
761 SceneObjectPart part = m_scene.GetSceneObjectPart(objId); 954 SceneObjectPart root = group.RootPart;
762 955 if (root == null)
763 if (part == null) 956 return 0;
764 return false;
765
766 SceneObjectGroup group = part.ParentGroup;
767 957
768 UUID objectOwner = group.OwnerID; 958 UUID objectOwner = group.OwnerID;
769 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0); 959 bool locked = denyOnLocked && ((root.OwnerMask & (uint)PermissionMask.Move) == 0);
770 960
771 // People shouldn't be able to do anything with locked objects, except the Administrator 961 if (IsAdministrator(currentUser))
772 // The 'set permissions' runs through a different permission check, so when an object owner
773 // sets an object locked, the only thing that they can do is unlock it.
774 //
775 // Nobody but the object owner can set permissions on an object
776 //
777 if (locked && (!IsAdministrator(currentUser)) && denyOnLocked)
778 { 962 {
779 return false; 963 // do lock on admin owned objects
964 if(locked && currentUser == objectOwner)
965 return (uint)(PermissionMask.AllEffective & ~(PermissionMask.Modify | PermissionMask.Move));
966 return (uint)PermissionMask.AllEffective;
780 } 967 }
781 968
782 // Object owners should be able to edit their own content 969 uint lockmask = (uint)PermissionMask.AllEffective;
970 if(locked)
971 lockmask &= ~(uint)(PermissionMask.Modify | PermissionMask.Move);
972
783 if (currentUser == objectOwner) 973 if (currentUser == objectOwner)
784 { 974 return group.EffectiveOwnerPerms & lockmask;
785 // there is no way that later code can change this back to false 975
786 // so just return true immediately and short circuit the more 976 if (group.IsAttachment)
787 // expensive group checks 977 return 0;
788 return true;
789 978
790 //permission = true; 979 UUID sogGroupID = group.GroupID;
791 } 980 bool notgroudOwned = sogGroupID != objectOwner;
792 else if (group.IsAttachment)
793 {
794 permission = false;
795 }
796 981
797// m_log.DebugFormat( 982 if (notgroudOwned && IsFriendWithPerms(currentUser, objectOwner))
798// "[PERMISSIONS]: group.GroupID = {0}, part.GroupMask = {1}, isGroupMember = {2} for {3}", 983 return group.EffectiveOwnerPerms & lockmask;
799// group.GroupID,
800// m_scene.GetSceneObjectPart(objId).GroupMask,
801// IsGroupMember(group.GroupID, currentUser, 0),
802// currentUser);
803
804 // Group members should be able to edit group objects
805 if ((group.GroupID != UUID.Zero)
806 && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0)
807 && IsGroupMember(group.GroupID, currentUser, 0))
808 {
809 // Return immediately, so that the administrator can shares group objects
810 return true;
811 }
812 984
813 // Friends with benefits should be able to edit the objects too 985 ulong powers = 0;
814 if (IsFriendWithPerms(currentUser, objectOwner)) 986 if (sogGroupID != UUID.Zero && GroupMemberPowers(sogGroupID, currentUser, ref powers))
815 { 987 {
816 // Return immediately, so that the administrator can share objects with friends 988 if(notgroudOwned)
817 return true; 989 return group.EffectiveGroupOrEveryOnePerms & lockmask;
990
991 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
992 return group.EffectiveGroupOrEveryOnePerms & lockmask;
993
994 uint grpEffectiveOwnerPerms = group.EffectiveOwnerPerms & lockmask;
995 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
996 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
997 return grpEffectiveOwnerPerms;
818 } 998 }
819 999
820 // Users should be able to edit what is over their land. 1000 return group.EffectiveEveryOnePerms & lockmask;
821 ILandObject parcel = m_scene.LandChannel.GetLandObject(group.AbsolutePosition.X, group.AbsolutePosition.Y); 1001 }
822 if ((parcel != null) && (parcel.LandData.OwnerID == currentUser)) 1002
1003 // get effective object permissions using present presence. So some may depend on requested rights (ie God)
1004 protected uint GetObjectPermissions(ScenePresence sp, SceneObjectGroup group, bool denyOnLocked)
1005 {
1006 if (sp == null || sp.IsDeleted || group == null || group.IsDeleted)
1007 return 0;
1008
1009 SceneObjectPart root = group.RootPart;
1010 if (root == null)
1011 return 0;
1012
1013 UUID spID = sp.UUID;
1014 UUID objectOwner = group.OwnerID;
1015
1016 bool locked = denyOnLocked && ((root.OwnerMask & (uint)PermissionMask.Move) == 0);
1017
1018 if (sp.IsGod)
823 { 1019 {
824 permission = true; 1020 if(locked && spID == objectOwner)
1021 return (uint)(PermissionMask.AllEffective & ~(PermissionMask.Modify | PermissionMask.Move));
1022 return (uint)PermissionMask.AllEffective;
825 } 1023 }
826 1024
827 // Estate users should be able to edit anything in the sim 1025 uint lockmask = (uint)PermissionMask.AllEffective;
828 if (IsEstateManager(currentUser)) 1026 if(locked)
1027 lockmask &= ~(uint)(PermissionMask.Modify | PermissionMask.Move);
1028
1029 if (spID == objectOwner)
1030 return group.EffectiveOwnerPerms & lockmask;
1031
1032 if (group.IsAttachment)
1033 return 0;
1034
1035 UUID sogGroupID = group.GroupID;
1036 bool notgroudOwned = sogGroupID != objectOwner;
1037
1038 if (notgroudOwned && IsFriendWithPerms(spID, objectOwner))
1039 return group.EffectiveOwnerPerms & lockmask;
1040
1041 ulong powers = 0;
1042 if (sogGroupID != UUID.Zero && GroupMemberPowers(sogGroupID, sp, ref powers))
829 { 1043 {
830 permission = true; 1044 if(notgroudOwned)
1045 return group.EffectiveGroupOrEveryOnePerms & lockmask;
1046
1047 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
1048 return group.EffectiveGroupOrEveryOnePerms & lockmask;
1049
1050 uint grpEffectiveOwnerPerms = group.EffectiveOwnerPerms & lockmask;
1051 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1052 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
1053 return grpEffectiveOwnerPerms;
831 } 1054 }
832 1055
833 // Admin objects should not be editable by the above 1056 return group.EffectiveEveryOnePerms & lockmask;
834 if (IsAdministrator(objectOwner)) 1057 }
1058
1059 private uint GetObjectItemPermissions(UUID userID, TaskInventoryItem ti)
1060 {
1061 UUID tiOwnerID = ti.OwnerID;
1062 if(tiOwnerID == userID)
1063 return ti.CurrentPermissions;
1064
1065 if(IsAdministrator(userID))
1066 return (uint)PermissionMask.AllEffective;
1067 // ??
1068 if (IsFriendWithPerms(userID, tiOwnerID))
1069 return ti.CurrentPermissions;
1070
1071 UUID tiGroupID = ti.GroupID;
1072 if(tiGroupID != UUID.Zero)
835 { 1073 {
836 permission = false; 1074 ulong powers = 0;
1075 if(GroupMemberPowers(tiGroupID, userID, ref powers))
1076 {
1077 if(tiGroupID == ti.OwnerID)
1078 {
1079 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1080 return ti.CurrentPermissions;
1081 }
1082 return ti.GroupPermissions;
1083 }
837 } 1084 }
838 1085
839 // Admin should be able to edit anything in the sim (including admin objects) 1086 return 0;
840 if (IsAdministrator(currentUser)) 1087 }
1088
1089 private uint GetObjectItemPermissions(ScenePresence sp, TaskInventoryItem ti, bool notEveryone)
1090 {
1091 UUID tiOwnerID = ti.OwnerID;
1092 UUID spID = sp.UUID;
1093
1094 if(tiOwnerID == spID)
1095 return ti.CurrentPermissions;
1096
1097 // ??
1098 if (IsFriendWithPerms(spID, tiOwnerID))
1099 return ti.CurrentPermissions;
1100
1101 UUID tiGroupID = ti.GroupID;
1102 if(tiGroupID != UUID.Zero)
841 { 1103 {
842 permission = true; 1104 ulong powers = 0;
1105 if(GroupMemberPowers(tiGroupID, spID, ref powers))
1106 {
1107 if(tiGroupID == ti.OwnerID)
1108 {
1109 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1110 return ti.CurrentPermissions;
1111 }
1112 uint p = ti.GroupPermissions;
1113 if(!notEveryone)
1114 p |= ti.EveryonePermissions;
1115 return p;
1116 }
843 } 1117 }
844 1118
845 return permission; 1119 if(notEveryone)
846 } 1120 return 0;
847 1121
1122 return ti.EveryonePermissions;
1123 }
848 #endregion 1124 #endregion
849 1125
850 #region Generic Permissions 1126 #region Generic Permissions
@@ -869,89 +1145,37 @@ namespace OpenSim.Region.CoreModules.World.Permissions
869 1145
870 public bool GenericEstatePermission(UUID user) 1146 public bool GenericEstatePermission(UUID user)
871 { 1147 {
872 // Default: deny
873 bool permission = false;
874
875 // Estate admins should be able to use estate tools 1148 // Estate admins should be able to use estate tools
876 if (IsEstateManager(user)) 1149 if (IsEstateManager(user))
877 permission = true; 1150 return true;
878 1151
879 // Administrators always have permission 1152 // Administrators always have permission
880 if (IsAdministrator(user)) 1153 if (IsAdministrator(user))
881 permission = true; 1154 return true;
882
883 return permission;
884 }
885
886 protected bool GenericParcelPermission(UUID user, ILandObject parcel, ulong groupPowers)
887 {
888 bool permission = false;
889
890 if (parcel.LandData.OwnerID == user)
891 {
892 permission = true;
893 }
894
895 if ((parcel.LandData.GroupID != UUID.Zero) && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
896 {
897 permission = true;
898 }
899
900 if (IsEstateManager(user))
901 {
902 permission = true;
903 }
904
905 if (IsAdministrator(user))
906 {
907 permission = true;
908 }
909
910 if (m_SimpleBuildPermissions &&
911 (parcel.LandData.Flags & (uint)ParcelFlags.UseAccessList) == 0 && parcel.IsInLandAccessList(user))
912 permission = true;
913 1155
914 return permission; 1156 return false;
915 } 1157 }
916 1158
917 protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers, bool allowEstateManager) 1159 protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers, bool allowEstateManager)
918 { 1160 {
919 if (parcel.LandData.OwnerID == user) 1161 if (parcel.LandData.OwnerID == user)
920 {
921 // Returning immediately so that group deeded objects on group deeded land don't trigger a NRE on
922 // the subsequent redundant checks when using lParcelMediaCommandList()
923 // See http://opensimulator.org/mantis/view.php?id=3999 for more details
924 return true; 1162 return true;
925 }
926 1163
927 if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers)) 1164 if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
928 {
929 return true; 1165 return true;
930 }
931 1166
932 if (allowEstateManager && IsEstateManager(user)) 1167 if (allowEstateManager && IsEstateManager(user))
933 {
934 return true; 1168 return true;
935 }
936 1169
937 if (IsAdministrator(user)) 1170 if (IsAdministrator(user))
938 {
939 return true; 1171 return true;
940 }
941 1172
942 return false; 1173 return false;
943 } 1174 }
944
945 protected bool GenericParcelPermission(UUID user, Vector3 pos, ulong groupPowers)
946 {
947 ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
948 if (parcel == null) return false;
949 return GenericParcelPermission(user, parcel, groupPowers);
950 }
951#endregion 1175#endregion
952 1176
953 #region Permission Checks 1177 #region Permission Checks
954 private bool CanAbandonParcel(UUID user, ILandObject parcel, Scene scene) 1178 private bool CanAbandonParcel(UUID user, ILandObject parcel)
955 { 1179 {
956 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1180 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
957 if (m_bypassPermissions) return m_bypassPermissionsValue; 1181 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -959,7 +1183,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
959 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandRelease, false); 1183 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandRelease, false);
960 } 1184 }
961 1185
962 private bool CanReclaimParcel(UUID user, ILandObject parcel, Scene scene) 1186 private bool CanReclaimParcel(UUID user, ILandObject parcel)
963 { 1187 {
964 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1188 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
965 if (m_bypassPermissions) return m_bypassPermissionsValue; 1189 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -967,108 +1191,223 @@ namespace OpenSim.Region.CoreModules.World.Permissions
967 return GenericParcelOwnerPermission(user, parcel, 0,true); 1191 return GenericParcelOwnerPermission(user, parcel, 0,true);
968 } 1192 }
969 1193
970 private bool CanDeedParcel(UUID user, ILandObject parcel, Scene scene) 1194 private bool CanDeedParcel(UUID user, ILandObject parcel)
971 { 1195 {
972 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1196 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
973 if (m_bypassPermissions) return m_bypassPermissionsValue; 1197 if (m_bypassPermissions) return m_bypassPermissionsValue;
974 1198
1199 if(parcel.LandData.GroupID == UUID.Zero)
1200 return false;
1201
1202 if (IsAdministrator(user))
1203 return true;
1204
975 if (parcel.LandData.OwnerID != user) // Only the owner can deed! 1205 if (parcel.LandData.OwnerID != user) // Only the owner can deed!
976 return false; 1206 return false;
977 1207
978 ScenePresence sp = scene.GetScenePresence(user); 1208 ScenePresence sp = m_scene.GetScenePresence(user);
979 IClientAPI client = sp.ControllingClient; 1209 if(sp == null)
1210 return false;
980 1211
1212 IClientAPI client = sp.ControllingClient;
981 if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0) 1213 if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0)
982 return false; 1214 return false;
983 1215
984 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDeed, false); 1216 return true;
985 } 1217 }
986 1218
987 private bool CanDeedObject(UUID user, UUID group, Scene scene) 1219 private bool CanDeedObject(ScenePresence sp, SceneObjectGroup sog, UUID targetGroupID)
988 { 1220 {
989 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1221 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
990 if (m_bypassPermissions) return m_bypassPermissionsValue; 1222 if (m_bypassPermissions) return m_bypassPermissionsValue;
991 1223
992 ScenePresence sp = scene.GetScenePresence(user); 1224 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted || targetGroupID == UUID.Zero)
993 IClientAPI client = sp.ControllingClient; 1225 return false;
1226
1227 // object has group already?
1228 if(sog.GroupID != targetGroupID)
1229 return false;
1230
1231 // is effectivelly shared?
1232 if(sog.EffectiveGroupPerms == 0)
1233 return false;
1234
1235 if(sp.IsGod)
1236 return true;
1237
1238 // owned by requester?
1239 if(sog.OwnerID != sp.UUID)
1240 return false;
1241
1242 // owner can transfer?
1243 if((sog.EffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1244 return false;
1245
1246 // group member ?
1247 ulong powers = 0;
1248 if(!GroupMemberPowers(targetGroupID, sp, ref powers))
1249 return false;
994 1250
995 if ((client.GetGroupPowers(group) & (ulong)GroupPowers.DeedObject) == 0) 1251 // has group rights?
1252 if ((powers & (ulong)GroupPowers.DeedObject) == 0)
996 return false; 1253 return false;
997 1254
998 return true; 1255 return true;
999 } 1256 }
1000 1257
1001 private bool IsGod(UUID user, Scene scene) 1258 private bool CanDuplicateObject(SceneObjectGroup sog, ScenePresence sp)
1002 { 1259 {
1003 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1260 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1004 if (m_bypassPermissions) return m_bypassPermissionsValue; 1261 if (m_bypassPermissions) return m_bypassPermissionsValue;
1005 1262
1006 return IsAdministrator(user); 1263 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1264 return false;
1265
1266 uint perms = GetObjectPermissions(sp, sog, false);
1267 if((perms & (uint)PermissionMask.Copy) == 0)
1268 return false;
1269
1270 if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0)
1271 return false;
1272
1273 //If they can rez, they can duplicate
1274 return CanRezObject(0, sp.UUID, sog.AbsolutePosition);
1007 } 1275 }
1008 1276
1009 private bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition) 1277 private bool CanDeleteObject(SceneObjectGroup sog, ScenePresence sp)
1010 { 1278 {
1279 // ignoring locked. viewers should warn and ask for confirmation
1280
1011 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1281 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1012 if (m_bypassPermissions) return m_bypassPermissionsValue; 1282 if (m_bypassPermissions) return m_bypassPermissionsValue;
1013 1283
1014 if (!GenericObjectPermission(owner, objectID, true)) 1284 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1015 {
1016 //They can't even edit the object
1017 return false; 1285 return false;
1018 }
1019 1286
1020 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 1287 if(sog.IsAttachment)
1021 if (part == null)
1022 return false; 1288 return false;
1023 1289
1024 if (part.OwnerID == owner) 1290 UUID sogOwnerID = sog.OwnerID;
1291 UUID spID = sp.UUID;
1292
1293 if(sogOwnerID == spID)
1294 return true;
1295
1296 if (sp.IsGod)
1297 return true;
1298
1299 if (IsFriendWithPerms(sog.UUID, sogOwnerID))
1300 return true;
1301
1302 UUID sogGroupID = sog.GroupID;
1303 if (sogGroupID != UUID.Zero)
1025 { 1304 {
1026 if ((part.OwnerMask & PERM_COPY) == 0) 1305 ulong powers = 0;
1027 return false; 1306 if(GroupMemberPowers(sogGroupID, sp, ref powers))
1307 {
1308 if(sogGroupID == sogOwnerID)
1309 {
1310 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1311 return true;
1312 }
1313 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
1314 }
1028 } 1315 }
1029 else if (part.GroupID != UUID.Zero) 1316 return false;
1030 { 1317 }
1031 if ((part.OwnerID == part.GroupID) && ((owner != part.LastOwnerID) || ((part.GroupMask & PERM_TRANS) == 0)))
1032 return false;
1033 1318
1034 if ((part.GroupMask & PERM_COPY) == 0) 1319 private bool CanDeleteObjectByIDs(UUID objectID, UUID userID)
1035 return false; 1320 {
1036 } 1321 // ignoring locked. viewers should warn and ask for confirmation
1037 1322
1038 //If they can rez, they can duplicate 1323 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1039 return CanRezObject(objectCount, owner, objectPosition, scene); 1324 if (m_bypassPermissions) return m_bypassPermissionsValue;
1325
1326 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1327 if (sog == null)
1328 return false;
1329
1330 if(sog.IsAttachment)
1331 return false;
1332
1333 UUID sogOwnerID = sog.OwnerID;
1334
1335 if(sogOwnerID == userID)
1336 return true;
1337
1338 if (IsAdministrator(userID))
1339 return true;
1340
1341 if (IsFriendWithPerms(objectID, sogOwnerID))
1342 return true;
1343
1344 UUID sogGroupID = sog.GroupID;
1345 if (sogGroupID != UUID.Zero)
1346 {
1347 ulong powers = 0;
1348 if(GroupMemberPowers(sogGroupID, userID, ref powers))
1349 {
1350 if(sogGroupID == sogOwnerID)
1351 {
1352 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1353 return true;
1354 }
1355 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
1356 }
1357 }
1358 return false;
1040 } 1359 }
1041 1360
1042 private bool CanDeleteObject(UUID objectID, UUID deleter, Scene scene) 1361 private bool CanEditObjectByIDs(UUID objectID, UUID userID)
1043 { 1362 {
1044 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1363 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1045 if (m_bypassPermissions) return m_bypassPermissionsValue; 1364 if (m_bypassPermissions) return m_bypassPermissionsValue;
1046 1365
1047 return GenericObjectPermission(deleter, objectID, false); 1366 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1367 if (sog == null)
1368 return false;
1369
1370 uint perms = GetObjectPermissions(userID, sog, true);
1371 if((perms & (uint)PermissionMask.Modify) == 0)
1372 return false;
1373 return true;
1048 } 1374 }
1049 1375
1050 private bool CanEditObject(UUID objectID, UUID editorID, Scene scene) 1376 private bool CanEditObject(SceneObjectGroup sog, ScenePresence sp)
1051 { 1377 {
1052 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1378 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1053 if (m_bypassPermissions) return m_bypassPermissionsValue; 1379 if (m_bypassPermissions) return m_bypassPermissionsValue;
1054 1380
1055 return GenericObjectPermission(editorID, objectID, false); 1381 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1382 return false;
1383
1384 uint perms = GetObjectPermissions(sp, sog, true);
1385 if((perms & (uint)PermissionMask.Modify) == 0)
1386 return false;
1387 return true;
1056 } 1388 }
1057 1389
1058 private bool CanEditObjectInventory(UUID objectID, UUID editorID, Scene scene) 1390 private bool CanEditObjectInventory(UUID objectID, UUID userID)
1059 { 1391 {
1060 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1392 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1061 if (m_bypassPermissions) return m_bypassPermissionsValue; 1393 if (m_bypassPermissions) return m_bypassPermissionsValue;
1062 1394
1063 return GenericObjectPermission(editorID, objectID, false); 1395 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1396 if (sog == null)
1397 return false;
1398
1399 uint perms = GetObjectPermissions(userID, sog, true);
1400 if((perms & (uint)PermissionMask.Modify) == 0)
1401 return false;
1402 return true;
1064 } 1403 }
1065 1404
1066 private bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p, Scene scene, bool allowManager) 1405 private bool CanEditParcelProperties(UUID userID, ILandObject parcel, GroupPowers p, bool allowManager)
1067 { 1406 {
1068 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1407 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1069 if (m_bypassPermissions) return m_bypassPermissionsValue; 1408 if (m_bypassPermissions) return m_bypassPermissionsValue;
1070 1409
1071 return GenericParcelOwnerPermission(user, parcel, (ulong)p, false); 1410 return GenericParcelOwnerPermission(userID, parcel, (ulong)p, false);
1072 } 1411 }
1073 1412
1074 /// <summary> 1413 /// <summary>
@@ -1079,18 +1418,18 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1079 /// <param name="user"></param> 1418 /// <param name="user"></param>
1080 /// <param name="scene"></param> 1419 /// <param name="scene"></param>
1081 /// <returns></returns> 1420 /// <returns></returns>
1082 private bool CanEditScript(UUID script, UUID objectID, UUID user, Scene scene) 1421 private bool CanEditScript(UUID script, UUID objectID, UUID userID)
1083 { 1422 {
1084 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1423 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1085 if (m_bypassPermissions) return m_bypassPermissionsValue; 1424 if (m_bypassPermissions) return m_bypassPermissionsValue;
1086 1425
1087 if (m_allowedScriptEditors == UserSet.Administrators && !IsAdministrator(user)) 1426 if (m_allowedScriptEditors == UserSet.Administrators && !IsAdministrator(userID))
1088 return false; 1427 return false;
1089 1428
1090 // Ordinarily, if you can view it, you can edit it 1429 // Ordinarily, if you can view it, you can edit it
1091 // There is no viewing a no mod script 1430 // There is no viewing a no mod script
1092 // 1431 //
1093 return CanViewScript(script, objectID, user, scene); 1432 return CanViewScript(script, objectID, userID);
1094 } 1433 }
1095 1434
1096 /// <summary> 1435 /// <summary>
@@ -1101,7 +1440,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1101 /// <param name="user"></param> 1440 /// <param name="user"></param>
1102 /// <param name="scene"></param> 1441 /// <param name="scene"></param>
1103 /// <returns></returns> 1442 /// <returns></returns>
1104 private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user, Scene scene) 1443 private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user)
1105 { 1444 {
1106 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1445 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1107 if (m_bypassPermissions) return m_bypassPermissionsValue; 1446 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1132,69 +1471,68 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1132 } 1471 }
1133 else // Prim inventory 1472 else // Prim inventory
1134 { 1473 {
1135 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 1474 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1136
1137 if (part == null) 1475 if (part == null)
1138 return false; 1476 return false;
1139 1477
1140 if (part.OwnerID != user) 1478 SceneObjectGroup sog = part.ParentGroup;
1141 { 1479 if (sog == null)
1142 if (part.GroupID == UUID.Zero) 1480 return false;
1143 return false;
1144
1145 if (!IsGroupMember(part.GroupID, user, 0))
1146 return false;
1147 1481
1148 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) 1482 // check object mod right
1149 return false; 1483 uint perms = GetObjectPermissions(user, sog, true);
1150 } 1484 if((perms & (uint)PermissionMask.Modify) == 0)
1151 else
1152 {
1153 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1154 return false; 1485 return false;
1155 }
1156 1486
1157 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard); 1487 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
1158
1159 if (ti == null) 1488 if (ti == null)
1160 return false; 1489 return false;
1161 1490
1162 if (ti.OwnerID != user) 1491 if (ti.OwnerID != user)
1163 { 1492 {
1164 if (ti.GroupID == UUID.Zero) 1493 UUID tiGroupID = ti.GroupID;
1494 if (tiGroupID == UUID.Zero)
1165 return false; 1495 return false;
1166 1496
1167 if (!IsGroupMember(ti.GroupID, user, 0)) 1497 ulong powers = 0;
1498 if(!GroupMemberPowers(tiGroupID, user, ref powers))
1168 return false; 1499 return false;
1500
1501 if(tiGroupID == ti.OwnerID && (powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1502 {
1503 if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) ==
1504 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1505 return true;
1506 }
1507 if ((ti.GroupPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) ==
1508 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1509 return true;
1510 return false;
1169 } 1511 }
1170 1512
1171 // Require full perms 1513 // Require full perms
1172 if ((ti.CurrentPermissions & 1514 if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) !=
1173 ((uint)PermissionMask.Modify | 1515 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1174 (uint)PermissionMask.Copy)) !=
1175 ((uint)PermissionMask.Modify |
1176 (uint)PermissionMask.Copy))
1177 return false; 1516 return false;
1178 } 1517 }
1179
1180 return true; 1518 return true;
1181 } 1519 }
1182 1520
1183 private bool CanInstantMessage(UUID user, UUID target, Scene startScene) 1521 private bool CanInstantMessage(UUID user, UUID target)
1184 { 1522 {
1185 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1523 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1186 if (m_bypassPermissions) return m_bypassPermissionsValue; 1524 if (m_bypassPermissions) return m_bypassPermissionsValue;
1187 1525
1188 // If the sender is an object, check owner instead 1526 // If the sender is an object, check owner instead
1189 // 1527 //
1190 SceneObjectPart part = startScene.GetSceneObjectPart(user); 1528 SceneObjectPart part = m_scene.GetSceneObjectPart(user);
1191 if (part != null) 1529 if (part != null)
1192 user = part.OwnerID; 1530 user = part.OwnerID;
1193 1531
1194 return GenericCommunicationPermission(user, target); 1532 return GenericCommunicationPermission(user, target);
1195 } 1533 }
1196 1534
1197 private bool CanInventoryTransfer(UUID user, UUID target, Scene startScene) 1535 private bool CanInventoryTransfer(UUID user, UUID target)
1198 { 1536 {
1199 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1537 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1200 if (m_bypassPermissions) return m_bypassPermissionsValue; 1538 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1202,7 +1540,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1202 return GenericCommunicationPermission(user, target); 1540 return GenericCommunicationPermission(user, target);
1203 } 1541 }
1204 1542
1205 private bool CanIssueEstateCommand(UUID user, Scene requestFromScene, bool ownerCommand) 1543 private bool CanIssueEstateCommand(UUID user, bool ownerCommand)
1206 { 1544 {
1207 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1545 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1208 if (m_bypassPermissions) return m_bypassPermissionsValue; 1546 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1210,178 +1548,162 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1210 if (IsAdministrator(user)) 1548 if (IsAdministrator(user))
1211 return true; 1549 return true;
1212 1550
1213 if (m_scene.RegionInfo.EstateSettings.IsEstateOwner(user))
1214 return true;
1215
1216 if (ownerCommand) 1551 if (ownerCommand)
1217 return false; 1552 return m_scene.RegionInfo.EstateSettings.IsEstateOwner(user);
1218 1553
1219 return GenericEstatePermission(user); 1554 return IsEstateManager(user);
1220 } 1555 }
1221 1556
1222 private bool CanMoveObject(UUID objectID, UUID moverID, Scene scene) 1557 private bool CanMoveObject(SceneObjectGroup sog, ScenePresence sp)
1223 { 1558 {
1224 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1559 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1560
1561 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1562 return false;
1563
1225 if (m_bypassPermissions) 1564 if (m_bypassPermissions)
1226 { 1565 {
1227 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 1566 if (sog.OwnerID != sp.UUID && sog.IsAttachment)
1228 if (part.OwnerID != moverID) 1567 return false;
1229 {
1230 if (!part.ParentGroup.IsDeleted)
1231 {
1232 if (part.ParentGroup.IsAttachment)
1233 return false;
1234 }
1235 }
1236 return m_bypassPermissionsValue; 1568 return m_bypassPermissionsValue;
1237 } 1569 }
1238 1570
1239 bool permission = GenericObjectPermission(moverID, objectID, true); 1571 uint perms = GetObjectPermissions(sp, sog, true);
1240 if (!permission) 1572 if((perms & (uint)PermissionMask.Move) == 0)
1241 { 1573 return false;
1242 if (!m_scene.Entities.ContainsKey(objectID)) 1574 return true;
1243 { 1575 }
1244 return false;
1245 }
1246 1576
1247 // The client 1577 private bool CanObjectEntry(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint)
1248 // may request to edit linked parts, and therefore, it needs 1578 {
1249 // to also check for SceneObjectPart 1579 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1250 1580
1251 // If it's not an object, we cant edit it. 1581 float newX = newPoint.X;
1252 if ((!(m_scene.Entities[objectID] is SceneObjectGroup))) 1582 float newY = newPoint.Y;
1253 {
1254 return false;
1255 }
1256 1583
1584 // allow outside region this is needed for crossings
1585 if (newX < -1f || newX > (m_scene.RegionInfo.RegionSizeX + 1.0f) ||
1586 newY < -1f || newY > (m_scene.RegionInfo.RegionSizeY + 1.0f) )
1587 return true;
1257 1588
1258 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID]; 1589 if(sog == null || sog.IsDeleted)
1590 return false;
1259 1591
1592 if (m_bypassPermissions)
1593 return m_bypassPermissionsValue;
1260 1594
1261 // UUID taskOwner = null; 1595 ILandObject parcel = m_scene.LandChannel.GetLandObject(newX, newY);
1262 // Added this because at this point in time it wouldn't be wise for 1596 if (parcel == null)
1263 // the administrator object permissions to take effect. 1597 return false;
1264 // UUID objectOwner = task.OwnerID;
1265 1598
1266 // Anyone can move 1599 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowAPrimitiveEntry)) != 0)
1267 if ((task.RootPart.EveryoneMask & PERM_MOVE) != 0) 1600 return true;
1268 permission = true;
1269 1601
1270 // Locked 1602 if (!enteringRegion)
1271 if ((task.RootPart.OwnerMask & PERM_LOCKED) == 0)
1272 permission = false;
1273 }
1274 else
1275 { 1603 {
1276 bool locked = false; 1604 Vector3 oldPoint = sog.AbsolutePosition;
1277 if (!m_scene.Entities.ContainsKey(objectID)) 1605 ILandObject fromparcel = m_scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
1278 { 1606 if (fromparcel != null && fromparcel.Equals(parcel)) // it already entered parcel ????
1279 return false; 1607 return true;
1280 } 1608 }
1281
1282 // If it's not an object, we cant edit it.
1283 if ((!(m_scene.Entities[objectID] is SceneObjectGroup)))
1284 {
1285 return false;
1286 }
1287 1609
1288 SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[objectID]; 1610 UUID userID = sog.OwnerID;
1611 LandData landdata = parcel.LandData;
1289 1612
1290 UUID objectOwner = group.OwnerID; 1613 if (landdata.OwnerID == userID)
1291 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0); 1614 return true;
1292 1615
1293 // This is an exception to the generic object permission. 1616 if (IsAdministrator(userID))
1294 // Administrators who lock their objects should not be able to move them, 1617 return true;
1295 // however generic object permission should return true.
1296 // This keeps locked objects from being affected by random click + drag actions by accident
1297 // and allows the administrator to grab or delete a locked object.
1298 1618
1299 // Administrators and estate managers are still able to click+grab locked objects not 1619 UUID landGroupID = landdata.GroupID;
1300 // owned by them in the scene 1620 if (landGroupID != UUID.Zero)
1301 // This is by design. 1621 {
1622 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowGroupObjectEntry)) != 0)
1623 return IsGroupMember(landGroupID, userID, 0);
1302 1624
1303 if (locked && (moverID == objectOwner)) 1625 if (landdata.IsGroupOwned && IsGroupMember(landGroupID, userID, (ulong)GroupPowers.AllowRez))
1304 return false; 1626 return true;
1305 } 1627 }
1306 return permission; 1628
1629 //Otherwise, false!
1630 return false;
1307 } 1631 }
1308 1632
1309 private bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) 1633 private bool OnObjectEnterWithScripts(SceneObjectGroup sog, ILandObject parcel)
1310 { 1634 {
1311 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1635 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1312 if (m_bypassPermissions) return m_bypassPermissionsValue;
1313
1314 1636
1315 // allow outide region?? 1637 if(sog == null || sog.IsDeleted)
1316 if (newPoint.X < -1f || newPoint.Y < -1f) 1638 return false;
1317 return true;
1318 if (newPoint.X > scene.RegionInfo.RegionSizeX + 1.0f || newPoint.Y > scene.RegionInfo.RegionSizeY + 1.0f)
1319 {
1320 return true;
1321 }
1322 1639
1323 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID]; 1640 if (m_bypassPermissions)
1641 return m_bypassPermissionsValue;
1324 1642
1325 ILandObject land = m_scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y); 1643 if (parcel == null)
1644 return true;
1326 1645
1327 if (!enteringRegion) 1646 int checkflags = ((int)ParcelFlags.AllowAPrimitiveEntry);
1328 { 1647 bool scripts = (sog.ScriptCount() > 0);
1329 ILandObject fromland = m_scene.LandChannel.GetLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y); 1648 if(scripts)
1649 checkflags |= ((int)ParcelFlags.AllowOtherScripts);
1330 1650
1331 if (fromland == land) // Not entering 1651 if ((parcel.LandData.Flags & checkflags) == checkflags)
1332 return true; 1652 return true;
1333 }
1334 1653
1335 if (land == null) 1654 UUID userID = sog.OwnerID;
1336 { 1655 LandData landdata = parcel.LandData;
1337 return false;
1338 }
1339 1656
1340 if ((land.LandData.Flags & ((int)ParcelFlags.AllowAPrimitiveEntry)) != 0) 1657 if (landdata.OwnerID == userID)
1341 {
1342 return true; 1658 return true;
1343 }
1344 1659
1345 if (!m_scene.Entities.ContainsKey(objectID)) 1660 if (IsAdministrator(userID))
1346 { 1661 return true;
1347 return false;
1348 }
1349 1662
1350 // If it's not an object, we cant edit it. 1663 UUID landGroupID = landdata.GroupID;
1351 if (!(m_scene.Entities[objectID] is SceneObjectGroup)) 1664 if (landGroupID != UUID.Zero)
1352 { 1665 {
1353 return false; 1666 checkflags = (int)ParcelFlags.AllowGroupObjectEntry;
1354 } 1667 if(scripts)
1668 checkflags |= ((int)ParcelFlags.AllowGroupScripts);
1355 1669
1670 if ((parcel.LandData.Flags & checkflags) == checkflags)
1671 return IsGroupMember(landGroupID, userID, 0);
1356 1672
1357 if (GenericParcelPermission(task.OwnerID, newPoint, 0)) 1673 if (landdata.IsGroupOwned && IsGroupMember(landGroupID, userID, (ulong)GroupPowers.AllowRez))
1358 { 1674 return true;
1359 return true;
1360 } 1675 }
1361 1676
1362 //Otherwise, false! 1677 //Otherwise, false!
1363 return false; 1678 return false;
1364 } 1679 }
1365 1680
1366 private bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene) 1681
1682 private bool CanReturnObjects(ILandObject land, ScenePresence sp, List<SceneObjectGroup> objects)
1367 { 1683 {
1368 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1684 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1369 if (m_bypassPermissions) return m_bypassPermissionsValue; 1685 if (m_bypassPermissions) return m_bypassPermissionsValue;
1370 1686
1371 GroupPowers powers; 1687 if(sp == null)
1372 ILandObject l; 1688 return true; // assuming that in this case rights are as owner
1373 1689
1374 ScenePresence sp = scene.GetScenePresence(user); 1690 UUID userID = sp.UUID;
1375 if (sp == null) 1691 bool isPrivUser = sp.IsGod || IsEstateManager(userID);
1376 return false;
1377 1692
1378 IClientAPI client = sp.ControllingClient; 1693 IClientAPI client = sp.ControllingClient;
1379 1694
1695 ulong powers = 0;
1696 ILandObject l;
1697
1380 foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects)) 1698 foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects))
1381 { 1699 {
1382 // Any user can return their own objects at any time 1700 if(g.IsAttachment)
1383 // 1701 {
1384 if (GenericObjectPermission(user, g.UUID, false)) 1702 objects.Remove(g);
1703 continue;
1704 }
1705
1706 if (isPrivUser || g.OwnerID == userID)
1385 continue; 1707 continue;
1386 1708
1387 // This is a short cut for efficiency. If land is non-null, 1709 // This is a short cut for efficiency. If land is non-null,
@@ -1395,39 +1717,40 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1395 else 1717 else
1396 { 1718 {
1397 Vector3 pos = g.AbsolutePosition; 1719 Vector3 pos = g.AbsolutePosition;
1398 1720 l = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
1399 l = scene.LandChannel.GetLandObject(pos.X, pos.Y);
1400 } 1721 }
1401 1722
1402 // If it's not over any land, then we can't do a thing 1723 // If it's not over any land, then we can't do a thing
1403 if (l == null) 1724 if (l == null || l.LandData == null)
1404 { 1725 {
1405 objects.Remove(g); 1726 objects.Remove(g);
1406 continue; 1727 continue;
1407 } 1728 }
1408 1729
1730 LandData ldata = l.LandData;
1409 // If we own the land outright, then allow 1731 // If we own the land outright, then allow
1410 // 1732 //
1411 if (l.LandData.OwnerID == user) 1733 if (ldata.OwnerID == userID)
1412 continue; 1734 continue;
1413 1735
1414 // Group voodoo 1736 // Group voodoo
1415 // 1737 //
1416 if (l.LandData.IsGroupOwned) 1738 if (ldata.IsGroupOwned)
1417 { 1739 {
1418 powers = (GroupPowers)client.GetGroupPowers(l.LandData.GroupID); 1740 UUID lGroupID = ldata.GroupID;
1419 // Not a group member, or no rights at all 1741 // Not a group member, or no rights at all
1420 // 1742 //
1421 if (powers == (GroupPowers)0) 1743 powers = client.GetGroupPowers(lGroupID);
1744 if(powers == 0)
1422 { 1745 {
1423 objects.Remove(g); 1746 objects.Remove(g);
1424 continue; 1747 continue;
1425 } 1748 }
1426 1749
1427 // Group deeded object? 1750 // Group deeded object?
1428 // 1751 //
1429 if (g.OwnerID == l.LandData.GroupID && 1752 if (g.OwnerID == lGroupID &&
1430 (powers & GroupPowers.ReturnGroupOwned) == (GroupPowers)0) 1753 (powers & (ulong)GroupPowers.ReturnGroupOwned) == 0)
1431 { 1754 {
1432 objects.Remove(g); 1755 objects.Remove(g);
1433 continue; 1756 continue;
@@ -1435,14 +1758,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1435 1758
1436 // Group set object? 1759 // Group set object?
1437 // 1760 //
1438 if (g.GroupID == l.LandData.GroupID && 1761 if (g.GroupID == lGroupID &&
1439 (powers & GroupPowers.ReturnGroupSet) == (GroupPowers)0) 1762 (powers & (ulong)GroupPowers.ReturnGroupSet) == 0)
1440 { 1763 {
1441 objects.Remove(g); 1764 objects.Remove(g);
1442 continue; 1765 continue;
1443 } 1766 }
1444 1767
1445 if ((powers & GroupPowers.ReturnNonGroup) == (GroupPowers)0) 1768 if ((powers & (ulong)GroupPowers.ReturnNonGroup) == 0)
1446 { 1769 {
1447 objects.Remove(g); 1770 objects.Remove(g);
1448 continue; 1771 continue;
@@ -1465,41 +1788,41 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1465 return true; 1788 return true;
1466 } 1789 }
1467 1790
1468 private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene) 1791 private bool CanRezObject(int objectCount, UUID userID, Vector3 objectPosition)
1469 { 1792 {
1470 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1793 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1471 if (m_bypassPermissions) return m_bypassPermissionsValue; 1794 if (m_bypassPermissions)
1795 return m_bypassPermissionsValue;
1472 1796
1473// m_log.DebugFormat("[PERMISSIONS MODULE]: Checking rez object at {0} in {1}", objectPosition, m_scene.Name); 1797// m_log.DebugFormat("[PERMISSIONS MODULE]: Checking rez object at {0} in {1}", objectPosition, m_scene.Name);
1474 1798
1475 ILandObject parcel = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 1799 ILandObject parcel = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
1476 if (parcel == null) 1800 if (parcel == null || parcel.LandData == null)
1477 return false; 1801 return false;
1478 1802
1479 if ((parcel.LandData.Flags & (uint)ParcelFlags.CreateObjects) != 0) 1803 LandData landdata = parcel.LandData;
1480 { 1804 if ((userID == landdata.OwnerID))
1481 return true; 1805 return true;
1482 } 1806
1483 else if ((owner == parcel.LandData.OwnerID) || IsAdministrator(owner)) 1807 if ((landdata.Flags & (uint)ParcelFlags.CreateObjects) != 0)
1484 {
1485 return true;
1486 }
1487 else if (((parcel.LandData.Flags & (uint)ParcelFlags.CreateGroupObjects) != 0)
1488 && (parcel.LandData.GroupID != UUID.Zero) && IsGroupMember(parcel.LandData.GroupID, owner, 0))
1489 {
1490 return true; 1808 return true;
1491 } 1809
1492 else if (parcel.LandData.GroupID != UUID.Zero && IsGroupMember(parcel.LandData.GroupID, owner, (ulong)GroupPowers.AllowRez)) 1810 if(IsAdministrator(userID))
1493 {
1494 return true; 1811 return true;
1495 } 1812
1496 else 1813 if(landdata.GroupID != UUID.Zero)
1497 { 1814 {
1498 return false; 1815 if ((landdata.Flags & (uint)ParcelFlags.CreateGroupObjects) != 0)
1816 return IsGroupMember(landdata.GroupID, userID, 0);
1817
1818 if (landdata.IsGroupOwned && IsGroupMember(landdata.GroupID, userID, (ulong)GroupPowers.AllowRez))
1819 return true;
1499 } 1820 }
1821
1822 return false;
1500 } 1823 }
1501 1824
1502 private bool CanRunConsoleCommand(UUID user, Scene requestFromScene) 1825 private bool CanRunConsoleCommand(UUID user)
1503 { 1826 {
1504 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1827 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1505 if (m_bypassPermissions) return m_bypassPermissionsValue; 1828 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1508,15 +1831,43 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1508 return IsAdministrator(user); 1831 return IsAdministrator(user);
1509 } 1832 }
1510 1833
1511 private bool CanRunScript(UUID script, UUID objectID, UUID user, Scene scene) 1834 private bool CanRunScript(TaskInventoryItem scriptitem, SceneObjectPart part)
1512 { 1835 {
1513 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1836 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1514 if (m_bypassPermissions) return m_bypassPermissionsValue; 1837 if (m_bypassPermissions) return m_bypassPermissionsValue;
1515 1838
1516 return true; 1839 if(scriptitem == null || part == null)
1840 return false;
1841
1842 SceneObjectGroup sog = part.ParentGroup;
1843 if(sog == null)
1844 return false;
1845
1846 Vector3 pos = sog.AbsolutePosition;
1847 ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
1848 if (parcel == null)
1849 return false;
1850
1851 LandData ldata = parcel.LandData;
1852 if(ldata == null)
1853 return false;
1854
1855 uint lflags = ldata.Flags;
1856
1857 if ((lflags & (uint)ParcelFlags.AllowOtherScripts) != 0)
1858 return true;
1859
1860 if ((part.OwnerID == ldata.OwnerID))
1861 return true;
1862
1863 if (((lflags & (uint)ParcelFlags.AllowGroupScripts) != 0)
1864 && (ldata.GroupID != UUID.Zero) && (ldata.GroupID == part.GroupID))
1865 return true;
1866
1867 return GenericEstatePermission(part.OwnerID);
1517 } 1868 }
1518 1869
1519 private bool CanSellParcel(UUID user, ILandObject parcel, Scene scene) 1870 private bool CanSellParcel(UUID user, ILandObject parcel)
1520 { 1871 {
1521 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1872 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1522 if (m_bypassPermissions) return m_bypassPermissionsValue; 1873 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1524,7 +1875,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1524 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandSetSale, true); 1875 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandSetSale, true);
1525 } 1876 }
1526 1877
1527 private bool CanSellGroupObject(UUID userID, UUID groupID, Scene scene) 1878 private bool CanSellGroupObject(UUID userID, UUID groupID)
1528 { 1879 {
1529 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1880 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1530 if (m_bypassPermissions) return m_bypassPermissionsValue; 1881 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1532,66 +1883,159 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1532 return IsGroupMember(groupID, userID, (ulong)GroupPowers.ObjectSetForSale); 1883 return IsGroupMember(groupID, userID, (ulong)GroupPowers.ObjectSetForSale);
1533 } 1884 }
1534 1885
1535 private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) 1886 private bool CanSellObjectByUserID(SceneObjectGroup sog, UUID userID, byte saleType)
1536 { 1887 {
1537 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1888 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1538 if (m_bypassPermissions) return m_bypassPermissionsValue; 1889 if (m_bypassPermissions) return m_bypassPermissionsValue;
1539 1890
1540 return GenericObjectPermission(stealer,objectID, false); 1891 if (sog == null || sog.IsDeleted || userID == UUID.Zero)
1892 return false;
1893
1894 // sell is not a attachment op
1895 if(sog.IsAttachment)
1896 return false;
1897
1898 if(IsAdministrator(userID))
1899 return true;
1900
1901 uint sogEffectiveOwnerPerms = sog.EffectiveOwnerPerms;
1902 if((sogEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1903 return false;
1904
1905 if(saleType == (byte)SaleType.Copy &&
1906 (sogEffectiveOwnerPerms & (uint)PermissionMask.Copy) == 0)
1907 return false;
1908
1909 UUID sogOwnerID = sog.OwnerID;
1910
1911 if(sogOwnerID == userID)
1912 return true;
1913
1914 // else only group owned can be sold by members with powers
1915 UUID sogGroupID = sog.GroupID;
1916 if(sog.OwnerID != sogGroupID || sogGroupID == UUID.Zero)
1917 return false;
1918
1919 return IsGroupMember(sogGroupID, userID, (ulong)GroupPowers.ObjectSetForSale);
1541 } 1920 }
1542 1921
1543 private bool CanTakeCopyObject(UUID objectID, UUID userID, Scene inScene) 1922 private bool CanSellObject(SceneObjectGroup sog, ScenePresence sp, byte saleType)
1544 { 1923 {
1545 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1924 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1546 if (m_bypassPermissions) return m_bypassPermissionsValue; 1925 if (m_bypassPermissions) return m_bypassPermissionsValue;
1547 1926
1548 bool permission = GenericObjectPermission(userID, objectID, false); 1927 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1928 return false;
1549 1929
1550 SceneObjectGroup so = (SceneObjectGroup)m_scene.Entities[objectID]; 1930 // sell is not a attachment op
1931 if(sog.IsAttachment)
1932 return false;
1551 1933
1552 if (!permission) 1934 if(sp.IsGod)
1553 { 1935 return true;
1554 if (!m_scene.Entities.ContainsKey(objectID))
1555 {
1556 return false;
1557 }
1558 1936
1559 // If it's not an object, we cant edit it. 1937 uint sogEffectiveOwnerPerms = sog.EffectiveOwnerPerms;
1560 if (!(m_scene.Entities[objectID] is SceneObjectGroup)) 1938 if((sogEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1561 { 1939 return false;
1562 return false;
1563 }
1564 1940
1565 // UUID taskOwner = null; 1941 if(saleType == (byte)SaleType.Copy &&
1566 // Added this because at this point in time it wouldn't be wise for 1942 (sogEffectiveOwnerPerms & (uint)PermissionMask.Copy) == 0)
1567 // the administrator object permissions to take effect. 1943 return false;
1568 // UUID objectOwner = task.OwnerID;
1569 1944
1570 if ((so.RootPart.EveryoneMask & PERM_COPY) != 0) 1945 UUID userID = sp.UUID;
1571 permission = true; 1946 UUID sogOwnerID = sog.OwnerID;
1572 }
1573 1947
1574 if (so.OwnerID != userID) 1948 if(sogOwnerID == userID)
1575 { 1949 return true;
1576 if ((so.GetEffectivePermissions() & (PERM_COPY | PERM_TRANS)) != (PERM_COPY | PERM_TRANS)) 1950
1577 permission = false; 1951 // else only group owned can be sold by members with powers
1578 } 1952 UUID sogGroupID = sog.GroupID;
1579 else 1953 if(sog.OwnerID != sogGroupID || sogGroupID == UUID.Zero)
1954 return false;
1955
1956 ulong powers = 0;
1957 if(!GroupMemberPowers(sogGroupID, sp, ref powers))
1958 return false;
1959
1960 if((powers & (ulong)GroupPowers.ObjectSetForSale) == 0)
1961 return false;
1962
1963 return true;
1964 }
1965
1966 private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
1967 {
1968 // ignore locked, viewers shell ask for confirmation
1969 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1970 if (m_bypassPermissions) return m_bypassPermissionsValue;
1971
1972 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1973 return false;
1974
1975 // take is not a attachment op
1976 if(sog.IsAttachment)
1977 return false;
1978
1979 UUID sogOwnerID = sog.OwnerID;
1980 UUID spID = sp.UUID;
1981
1982 if(sogOwnerID == spID)
1983 return true;
1984
1985 if (sp.IsGod)
1986 return true;
1987
1988 if((sog.EffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1989 return false;
1990
1991 if (IsFriendWithPerms(sog.UUID, sogOwnerID))
1992 return true;
1993
1994 UUID sogGroupID = sog.GroupID;
1995 if (sogGroupID != UUID.Zero)
1580 { 1996 {
1581 if ((so.GetEffectivePermissions() & PERM_COPY) != PERM_COPY) 1997 ulong powers = 0;
1582 permission = false; 1998 if(GroupMemberPowers(sogGroupID, sp, ref powers))
1999 {
2000 if(sogGroupID == sogOwnerID)
2001 {
2002 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
2003 return true;
2004 }
2005 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
2006 }
1583 } 2007 }
2008 return false;
2009 }
1584 2010
1585 return permission; 2011 private bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp)
2012 {
2013 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2014 if (m_bypassPermissions) return m_bypassPermissionsValue;
2015
2016 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
2017 return false;
2018
2019 // refuse on attachments
2020 if(sog.IsAttachment && !sp.IsGod)
2021 return false;
2022
2023 uint perms = GetObjectPermissions(sp, sog, true);
2024 if((perms & (uint)PermissionMask.Copy) == 0)
2025 return false;
2026
2027 if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0)
2028 return false;
2029 return true;
1586 } 2030 }
1587 2031
1588 private bool CanTerraformLand(UUID user, Vector3 position, Scene requestFromScene) 2032 private bool CanTerraformLand(UUID userID, Vector3 position)
1589 { 2033 {
1590 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2034 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1591 if (m_bypassPermissions) return m_bypassPermissionsValue; 2035 if (m_bypassPermissions) return m_bypassPermissionsValue;
1592 2036
1593 // Estate override 2037 // Estate override
1594 if (GenericEstatePermission(user)) 2038 if (GenericEstatePermission(userID))
1595 return true; 2039 return true;
1596 2040
1597 float X = position.X; 2041 float X = position.X;
@@ -1609,13 +2053,19 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1609 ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y); 2053 ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y);
1610 if (parcel == null) 2054 if (parcel == null)
1611 return false; 2055 return false;
1612 2056
1613 // Others allowed to terraform? 2057 LandData landdata = parcel.LandData;
1614 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowTerraform)) != 0) 2058 if (landdata == null)
2059 return false;
2060
2061 if ((landdata.Flags & ((int)ParcelFlags.AllowTerraform)) != 0)
1615 return true; 2062 return true;
1616 2063
1617 // Land owner can terraform too 2064 if(landdata.OwnerID == userID)
1618 if (parcel != null && GenericParcelPermission(user, parcel, (ulong)GroupPowers.AllowEditLand)) 2065 return true;
2066
2067 if (landdata.IsGroupOwned && parcel.LandData.GroupID != UUID.Zero &&
2068 IsGroupMember(landdata.GroupID, userID, (ulong)GroupPowers.AllowEditLand))
1619 return true; 2069 return true;
1620 2070
1621 return false; 2071 return false;
@@ -1629,15 +2079,19 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1629 /// <param name="user"></param> 2079 /// <param name="user"></param>
1630 /// <param name="scene"></param> 2080 /// <param name="scene"></param>
1631 /// <returns></returns> 2081 /// <returns></returns>
1632 private bool CanViewScript(UUID script, UUID objectID, UUID user, Scene scene) 2082 private bool CanViewScript(UUID script, UUID objectID, UUID userID)
1633 { 2083 {
1634 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2084 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1635 if (m_bypassPermissions) return m_bypassPermissionsValue; 2085 if (m_bypassPermissions) return m_bypassPermissionsValue;
1636 2086
2087 // A god is a god is a god
2088 if (IsAdministrator(userID))
2089 return true;
2090
1637 if (objectID == UUID.Zero) // User inventory 2091 if (objectID == UUID.Zero) // User inventory
1638 { 2092 {
1639 IInventoryService invService = m_scene.InventoryService; 2093 IInventoryService invService = m_scene.InventoryService;
1640 InventoryItemBase assetRequestItem = invService.GetItem(user, script); 2094 InventoryItemBase assetRequestItem = invService.GetItem(userID, script);
1641 if (assetRequestItem == null && LibraryRootFolder != null) // Library item 2095 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1642 { 2096 {
1643 assetRequestItem = LibraryRootFolder.FindItem(script); 2097 assetRequestItem = LibraryRootFolder.FindItem(script);
@@ -1657,60 +2111,53 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1657 // readable only if it's really full perms 2111 // readable only if it's really full perms
1658 // 2112 //
1659 if ((assetRequestItem.CurrentPermissions & 2113 if ((assetRequestItem.CurrentPermissions &
2114/*
1660 ((uint)PermissionMask.Modify | 2115 ((uint)PermissionMask.Modify |
1661 (uint)PermissionMask.Copy | 2116 (uint)PermissionMask.Copy |
1662 (uint)PermissionMask.Transfer)) != 2117 (uint)PermissionMask.Transfer)) !=
1663 ((uint)PermissionMask.Modify | 2118 ((uint)PermissionMask.Modify |
1664 (uint)PermissionMask.Copy | 2119 (uint)PermissionMask.Copy |
1665 (uint)PermissionMask.Transfer)) 2120 (uint)PermissionMask.Transfer))
2121*/
2122 (uint)(PermissionMask.Modify | PermissionMask.Copy)) !=
2123 (uint)(PermissionMask.Modify | PermissionMask.Copy))
1666 return false; 2124 return false;
1667 } 2125 }
1668 else // Prim inventory 2126 else // Prim inventory
1669 { 2127 {
1670 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 2128 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1671
1672 if (part == null) 2129 if (part == null)
1673 return false; 2130 return false;
1674 2131
1675 if (part.OwnerID != user) 2132 SceneObjectGroup sog = part.ParentGroup;
1676 { 2133 if (sog == null)
1677 if (part.GroupID == UUID.Zero) 2134 return false;
1678 return false;
1679
1680 if (!IsGroupMember(part.GroupID, user, 0))
1681 return false;
1682 2135
1683 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) 2136 uint perms = GetObjectPermissions(userID, sog, true);
1684 return false; 2137 if((perms & (uint)PermissionMask.Modify) == 0)
1685 } 2138 return false;
1686 else
1687 {
1688 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1689 return false;
1690 }
1691 2139
1692 TaskInventoryItem ti = part.Inventory.GetInventoryItem(script); 2140 TaskInventoryItem ti = part.Inventory.GetInventoryItem(script);
1693 2141
1694 if (ti == null) 2142// if (ti == null || ti.InvType != (int)InventoryType.LSL)
2143 if (ti == null) // legacy may not have type
1695 return false; 2144 return false;
1696 2145
1697 if (ti.OwnerID != user) 2146 uint itperms = GetObjectItemPermissions(userID, ti);
1698 {
1699 if (ti.GroupID == UUID.Zero)
1700 return false;
1701
1702 if (!IsGroupMember(ti.GroupID, user, 0))
1703 return false;
1704 }
1705 2147
1706 // Require full perms 2148 // Require full perms
1707 if ((ti.CurrentPermissions & 2149
1708 ((uint)PermissionMask.Modify | 2150 if ((itperms &
2151/*
2152 ((uint)(PermissionMask.Modify |
1709 (uint)PermissionMask.Copy | 2153 (uint)PermissionMask.Copy |
1710 (uint)PermissionMask.Transfer)) != 2154 (uint)PermissionMask.Transfer)) !=
1711 ((uint)PermissionMask.Modify | 2155 ((uint)PermissionMask.Modify |
1712 (uint)PermissionMask.Copy | 2156 (uint)PermissionMask.Copy |
1713 (uint)PermissionMask.Transfer)) 2157 (uint)PermissionMask.Transfer))
2158*/
2159 (uint)(PermissionMask.Modify | PermissionMask.Copy)) !=
2160 (uint)(PermissionMask.Modify | PermissionMask.Copy))
1714 return false; 2161 return false;
1715 } 2162 }
1716 2163
@@ -1725,15 +2172,19 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1725 /// <param name="user"></param> 2172 /// <param name="user"></param>
1726 /// <param name="scene"></param> 2173 /// <param name="scene"></param>
1727 /// <returns></returns> 2174 /// <returns></returns>
1728 private bool CanViewNotecard(UUID notecard, UUID objectID, UUID user, Scene scene) 2175 private bool CanViewNotecard(UUID notecard, UUID objectID, UUID userID)
1729 { 2176 {
1730 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2177 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1731 if (m_bypassPermissions) return m_bypassPermissionsValue; 2178 if (m_bypassPermissions) return m_bypassPermissionsValue;
1732 2179
2180 // A god is a god is a god
2181 if (IsAdministrator(userID))
2182 return true;
2183
1733 if (objectID == UUID.Zero) // User inventory 2184 if (objectID == UUID.Zero) // User inventory
1734 { 2185 {
1735 IInventoryService invService = m_scene.InventoryService; 2186 IInventoryService invService = m_scene.InventoryService;
1736 InventoryItemBase assetRequestItem = invService.GetItem(user, notecard); 2187 InventoryItemBase assetRequestItem = invService.GetItem(userID, notecard);
1737 if (assetRequestItem == null && LibraryRootFolder != null) // Library item 2188 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1738 { 2189 {
1739 assetRequestItem = LibraryRootFolder.FindItem(notecard); 2190 assetRequestItem = LibraryRootFolder.FindItem(notecard);
@@ -1751,40 +2202,29 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1751 } 2202 }
1752 else // Prim inventory 2203 else // Prim inventory
1753 { 2204 {
1754 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 2205 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1755
1756 if (part == null) 2206 if (part == null)
1757 return false; 2207 return false;
1758 2208
1759 if (part.OwnerID != user) 2209 SceneObjectGroup sog = part.ParentGroup;
1760 { 2210 if (sog == null)
1761 if (part.GroupID == UUID.Zero) 2211 return false;
1762 return false;
1763
1764 if (!IsGroupMember(part.GroupID, user, 0))
1765 return false;
1766 }
1767 2212
1768 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) 2213 uint perms = GetObjectPermissions(userID, sog, true);
2214 if((perms & (uint)PermissionMask.Modify) == 0)
1769 return false; 2215 return false;
1770 2216
1771 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard); 2217 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
1772 2218
2219// if (ti == null || ti.InvType != (int)InventoryType.Notecard)
1773 if (ti == null) 2220 if (ti == null)
1774 return false; 2221 return false;
1775 2222
1776 if (ti.OwnerID != user) 2223 uint itperms = GetObjectItemPermissions(userID, ti);
1777 {
1778 if (ti.GroupID == UUID.Zero)
1779 return false;
1780
1781 if (!IsGroupMember(ti.GroupID, user, 0))
1782 return false;
1783 }
1784 2224
1785 // Notecards are always readable unless no copy 2225 // Notecards are always readable unless no copy
1786 // 2226 //
1787 if ((ti.CurrentPermissions & 2227 if ((itperms &
1788 (uint)PermissionMask.Copy) != 2228 (uint)PermissionMask.Copy) !=
1789 (uint)PermissionMask.Copy) 2229 (uint)PermissionMask.Copy)
1790 return false; 2230 return false;
@@ -1800,7 +2240,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1800 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2240 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1801 if (m_bypassPermissions) return m_bypassPermissionsValue; 2241 if (m_bypassPermissions) return m_bypassPermissionsValue;
1802 2242
1803 return GenericObjectPermission(userID, objectID, false); 2243 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2244 if (sog == null)
2245 return false;
2246
2247 uint perms = GetObjectPermissions(userID, sog, true);
2248 if((perms & (uint)PermissionMask.Modify) == 0)
2249 return false;
2250 return true;
1804 } 2251 }
1805 2252
1806 private bool CanDelinkObject(UUID userID, UUID objectID) 2253 private bool CanDelinkObject(UUID userID, UUID objectID)
@@ -1808,10 +2255,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1808 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2255 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1809 if (m_bypassPermissions) return m_bypassPermissionsValue; 2256 if (m_bypassPermissions) return m_bypassPermissionsValue;
1810 2257
1811 return GenericObjectPermission(userID, objectID, false); 2258 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2259 if (sog == null)
2260 return false;
2261
2262 uint perms = GetObjectPermissions(userID, sog, true);
2263 if((perms & (uint)PermissionMask.Modify) == 0)
2264 return false;
2265 return true;
1812 } 2266 }
1813 2267
1814 private bool CanBuyLand(UUID userID, ILandObject parcel, Scene scene) 2268 private bool CanBuyLand(UUID userID, ILandObject parcel)
1815 { 2269 {
1816 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2270 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1817 if (m_bypassPermissions) return m_bypassPermissionsValue; 2271 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1824,6 +2278,130 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1824 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2278 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1825 if (m_bypassPermissions) return m_bypassPermissionsValue; 2279 if (m_bypassPermissions) return m_bypassPermissionsValue;
1826 2280
2281 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
2282 if (part == null)
2283 return false;
2284
2285 SceneObjectGroup sog = part.ParentGroup;
2286 if (sog == null)
2287 return false;
2288
2289 uint perms = GetObjectPermissions(userID, sog, true);
2290 if((perms & (uint)PermissionMask.Modify) == 0)
2291 return false;
2292
2293 TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID);
2294 if(ti == null)
2295 return false;
2296
2297 uint itperms = GetObjectItemPermissions(userID, ti);
2298
2299 if((itperms & (uint)PermissionMask.Copy) == 0)
2300 return false;
2301
2302 if(sog.OwnerID != userID && (itperms & (uint)PermissionMask.Transfer) == 0)
2303 return false;
2304
2305 return true;
2306 }
2307
2308 // object inventory to object inventory item drag and drop
2309 private bool CanDoObjectInvToObjectInv(TaskInventoryItem item, SceneObjectPart sourcePart, SceneObjectPart destPart)
2310 {
2311 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2312
2313 if (sourcePart == null || destPart == null || item == null)
2314 return false;
2315
2316 if (m_bypassPermissions)
2317 return m_bypassPermissionsValue;
2318
2319 SceneObjectGroup srcsog = sourcePart.ParentGroup;
2320 SceneObjectGroup destsog = destPart.ParentGroup;
2321 if (srcsog == null || destsog == null)
2322 return false;
2323
2324 // dest is locked
2325 if((destsog.EffectiveOwnerPerms & (uint)PermissionMask.Move) == 0)
2326 return false;
2327
2328 uint itperms = item.CurrentPermissions;
2329
2330 // if item is no copy the source is modifed
2331 if((itperms & (uint)PermissionMask.Copy) == 0 && (srcsog.EffectiveOwnerPerms & (uint)PermissionMask.Modify) == 0)
2332 return false;
2333
2334 UUID srcOwner = srcsog.OwnerID;
2335 UUID destOwner = destsog.OwnerID;
2336 bool notSameOwner = srcOwner != destOwner;
2337
2338 if(notSameOwner)
2339 {
2340 if((itperms & (uint)PermissionMask.Transfer) == 0)
2341 return false;
2342
2343 // scripts can't be droped
2344 if(item.InvType == (int)InventoryType.LSL)
2345 return false;
2346
2347 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
2348 return false;
2349 }
2350 else
2351 {
2352 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0 &&
2353 (destsog.EffectiveOwnerPerms & (uint)PermissionMask.Modify) == 0)
2354 return false;
2355 }
2356
2357 return true;
2358 }
2359
2360 private bool CanDropInObjectInv(InventoryItemBase item, ScenePresence sp, SceneObjectPart destPart)
2361 {
2362 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2363
2364 if (sp == null || sp.IsDeleted || destPart == null || item == null)
2365 return false;
2366
2367 SceneObjectGroup destsog = destPart.ParentGroup;
2368 if (destsog == null || destsog.IsDeleted)
2369 return false;
2370
2371 if (m_bypassPermissions)
2372 return m_bypassPermissionsValue;
2373
2374 if(sp.IsGod)
2375 return true;
2376
2377 // dest is locked
2378 if((destsog.EffectiveOwnerPerms & (uint)PermissionMask.Move) == 0)
2379 return false;
2380
2381 UUID destOwner = destsog.OwnerID;
2382 UUID spID = sp.UUID;
2383 bool spNotOwner = spID != destOwner;
2384
2385 // scripts can't be droped
2386 if(spNotOwner && item.InvType == (int)InventoryType.LSL)
2387 return false;
2388
2389 if(spNotOwner || item.Owner != destOwner)
2390 {
2391 // no copy item will be moved if it has transfer
2392 uint itperms = item.CurrentPermissions;
2393 if((itperms & (uint)PermissionMask.Transfer) == 0)
2394 return false;
2395 }
2396
2397 // allowdrop is a root part thing and does bypass modify rights
2398 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
2399 return true;
2400
2401 uint perms = GetObjectPermissions(spID, destsog, true);
2402 if((perms & (uint)PermissionMask.Modify) == 0)
2403 return false;
2404
1827 return true; 2405 return true;
1828 } 2406 }
1829 2407
@@ -1832,6 +2410,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1832 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2410 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1833 if (m_bypassPermissions) return m_bypassPermissionsValue; 2411 if (m_bypassPermissions) return m_bypassPermissionsValue;
1834 2412
2413 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
2414 if (part == null)
2415 return false;
2416
2417 SceneObjectGroup sog = part.ParentGroup;
2418 if (sog == null)
2419 return false;
2420
2421 uint perms = GetObjectPermissions(userID, sog, true);
2422 if((perms & (uint)PermissionMask.Modify) == 0)
2423 return false;
2424
2425 TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID);
2426 if(ti == null)
2427 return false;
2428
2429 //TODO item perm ?
1835 return true; 2430 return true;
1836 } 2431 }
1837 2432
@@ -1848,26 +2443,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1848 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2443 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1849 if (m_bypassPermissions) return m_bypassPermissionsValue; 2444 if (m_bypassPermissions) return m_bypassPermissionsValue;
1850 2445
1851 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1852 ScenePresence p = m_scene.GetScenePresence(userID); 2446 ScenePresence p = m_scene.GetScenePresence(userID);
1853 2447
1854 if (part == null || p == null) 2448 if (p == null)
2449 return false;
2450
2451 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2452 if (sog == null)
2453 return false;
2454
2455 uint perms = GetObjectPermissions(userID, sog, true);
2456 if((perms & (uint)PermissionMask.Modify) == 0)
1855 return false; 2457 return false;
1856 2458
1857 if (!IsAdministrator(userID)) 2459 if ((int)InventoryType.LSL == invType)
1858 { 2460 {
1859 if (part.OwnerID != userID) 2461 if (m_allowedScriptCreators == UserSet.Administrators)
1860 { 2462 return false;
1861 // Group permissions
1862 if ((part.GroupID == UUID.Zero) || (p.ControllingClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0))
1863 return false;
1864 } else {
1865 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1866 return false;
1867 }
1868 if ((int)InventoryType.LSL == invType)
1869 if (m_allowedScriptCreators == UserSet.Administrators)
1870 return false;
1871 } 2463 }
1872 2464
1873 return true; 2465 return true;
@@ -1941,22 +2533,22 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1941 return true; 2533 return true;
1942 } 2534 }
1943 2535
1944 private bool CanResetScript(UUID prim, UUID script, UUID agentID, Scene scene) 2536 private bool CanResetScript(UUID primID, UUID script, UUID agentID)
1945 { 2537 {
1946 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2538 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1947 if (m_bypassPermissions) return m_bypassPermissionsValue; 2539 if (m_bypassPermissions) return m_bypassPermissionsValue;
1948 2540
1949 SceneObjectPart part = m_scene.GetSceneObjectPart(prim); 2541 SceneObjectGroup sog = m_scene.GetGroupByPrim(primID);
1950 2542 if (sog == null)
1951 // If we selected a sub-prim to reset, prim won't represent the object, but only a part. 2543 return false;
1952 // We have to check the permissions of the object, though.
1953 if (part.ParentID != 0) prim = part.ParentUUID;
1954 2544
1955 // You can reset the scripts in any object you can edit 2545 uint perms = GetObjectPermissions(agentID, sog, false);
1956 return GenericObjectPermission(agentID, prim, false); 2546 if((perms & (uint)PermissionMask.Modify) == 0) // ??
2547 return false;
2548 return true;
1957 } 2549 }
1958 2550
1959 private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) 2551 private bool CanCompileScript(UUID ownerUUID, int scriptType)
1960 { 2552 {
1961 //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); 2553 //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType);
1962 switch (scriptType) { 2554 switch (scriptType) {
@@ -2014,7 +2606,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
2014// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}", 2606// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}",
2015// agentID, primID, face, me.ControlPermissions); 2607// agentID, primID, face, me.ControlPermissions);
2016 2608
2017 return GenericObjectPermission(agentID, part.ParentGroup.UUID, true); 2609 SceneObjectGroup sog = part.ParentGroup;
2610 if (sog == null)
2611 return false;
2612
2613 uint perms = GetObjectPermissions(agentID, sog, false);
2614 if((perms & (uint)PermissionMask.Modify) == 0)
2615 return false;
2616 return true;
2018 } 2617 }
2019 2618
2020 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) 2619 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face)
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
index 8bac9e6..bb3b860 100644
--- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
+++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
@@ -61,6 +61,8 @@ namespace OpenSim.Region.CoreModules.World.Region
61 protected IDialogModule m_DialogModule = null; 61 protected IDialogModule m_DialogModule = null;
62 protected string m_MarkerPath = String.Empty; 62 protected string m_MarkerPath = String.Empty;
63 private int[] m_CurrentAlerts = null; 63 private int[] m_CurrentAlerts = null;
64 protected bool m_shortCircuitDelays = false;
65 protected bool m_rebootAll = false;
64 66
65 public void Initialise(IConfigSource config) 67 public void Initialise(IConfigSource config)
66 { 68 {
@@ -69,6 +71,9 @@ namespace OpenSim.Region.CoreModules.World.Region
69 { 71 {
70 m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty); 72 m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty);
71 } 73 }
74 IConfig startupConfig = config.Configs["Startup"];
75 m_shortCircuitDelays = startupConfig.GetBoolean("SkipDelayOnEmptyRegion", false);
76 m_rebootAll = startupConfig.GetBoolean("InworldRestartShutsDown", false);
72 } 77 }
73 78
74 public void AddRegion(Scene scene) 79 public void AddRegion(Scene scene)
@@ -250,6 +255,14 @@ namespace OpenSim.Region.CoreModules.World.Region
250 private void OnTimer(object source, ElapsedEventArgs e) 255 private void OnTimer(object source, ElapsedEventArgs e)
251 { 256 {
252 int nextInterval = DoOneNotice(true); 257 int nextInterval = DoOneNotice(true);
258 if (m_shortCircuitDelays)
259 {
260 if (CountAgents() == 0)
261 {
262 m_Scene.RestartNow();
263 return;
264 }
265 }
253 266
254 SetTimer(nextInterval); 267 SetTimer(nextInterval);
255 } 268 }
@@ -349,5 +362,35 @@ namespace OpenSim.Region.CoreModules.World.Region
349 { 362 {
350 } 363 }
351 } 364 }
365
366 int CountAgents()
367 {
368 m_log.Info("[RESTART MODULE]: Counting affected avatars");
369 int agents = 0;
370
371 if (m_rebootAll)
372 {
373 foreach (Scene s in SceneManager.Instance.Scenes)
374 {
375 foreach (ScenePresence sp in s.GetScenePresences())
376 {
377 if (!sp.IsChildAgent && !sp.IsNPC)
378 agents++;
379 }
380 }
381 }
382 else
383 {
384 foreach (ScenePresence sp in m_Scene.GetScenePresences())
385 {
386 if (!sp.IsChildAgent && !sp.IsNPC)
387 agents++;
388 }
389 }
390
391 m_log.InfoFormat("[RESTART MODULE]: Avatars in region: {0}", agents);
392
393 return agents;
394 }
352 } 395 }
353} 396}
diff --git a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
index 04b6f00..167f6b5 100644
--- a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
+++ b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
@@ -105,8 +105,9 @@ namespace OpenSim.Region.CoreModules.World.Vegetation
105 if (rootPart.Shape.PCode != (byte)PCode.Grass) 105 if (rootPart.Shape.PCode != (byte)PCode.Grass)
106 AdaptTree(ref shape); 106 AdaptTree(ref shape);
107 107
108 m_scene.AddNewSceneObject(sceneObject, true);
109 sceneObject.SetGroup(groupID, null); 108 sceneObject.SetGroup(groupID, null);
109 m_scene.AddNewSceneObject(sceneObject, true);
110 sceneObject.AggregatePerms();
110 111
111 return sceneObject; 112 return sceneObject;
112 } 113 }
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 0c4017e..e7c2428 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -278,6 +278,8 @@ namespace OpenSim.Region.Framework.Interfaces
278 /// <param name="datastore"></param> 278 /// <param name="datastore"></param>
279 void ProcessInventoryBackup(ISimulationDataService datastore); 279 void ProcessInventoryBackup(ISimulationDataService datastore);
280 280
281 void AggregateInnerPerms(ref uint owner, ref uint group, ref uint everyone);
282
281 uint MaskEffectivePermissions(); 283 uint MaskEffectivePermissions();
282 284
283 void ApplyNextOwnerPermissions(); 285 void ApplyNextOwnerPermissions();
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index 9585082..1b690ba 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -102,6 +102,8 @@ namespace OpenSim.Region.Framework.Interfaces
102 102
103 ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, EntityTransferContext ctx); 103 ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, EntityTransferContext ctx);
104 104
105 bool CrossAgentCreateFarChild(ScenePresence agent, GridRegion neighbourRegion, Vector3 pos, EntityTransferContext ctx);
106
105 bool HandleIncomingSceneObject(SceneObjectGroup so, Vector3 newPosition); 107 bool HandleIncomingSceneObject(SceneObjectGroup so, Vector3 newPosition);
106 } 108 }
107 109
diff --git a/OpenSim/Region/Framework/Interfaces/IEtcdModule.cs b/OpenSim/Region/Framework/Interfaces/IEtcdModule.cs
new file mode 100644
index 0000000..123cb67
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IEtcdModule.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 System;
29
30public interface IEtcdModule
31{
32 bool Store(string k, string v);
33 bool Store(string k, string v, int ttl);
34 string Get(string k);
35 void Watch(string k, Action<string> callback);
36 void Delete(string k);
37}
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 1e9711d..827f91e 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -3161,7 +3161,7 @@ namespace OpenSim.Region.Framework.Scenes
3161 { 3161 {
3162 foreach (Action<Scene> d in handler.GetInvocationList()) 3162 foreach (Action<Scene> d in handler.GetInvocationList())
3163 { 3163 {
3164 m_log.InfoFormat("[EVENT MANAGER]: TriggerSceneShuttingDown invoque {0}", d.Method.Name.ToString()); 3164 m_log.InfoFormat("[EVENT MANAGER]: TriggerSceneShuttingDown invoke {0}", d.Method.Name.ToString());
3165 try 3165 try
3166 { 3166 {
3167 d(s); 3167 d(s);
diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs
index 7ed80f6..9372366 100644
--- a/OpenSim/Region/Framework/Scenes/GodController.cs
+++ b/OpenSim/Region/Framework/Scenes/GodController.cs
@@ -246,17 +246,14 @@ namespace OpenSim.Region.Framework.Scenes
246 { 246 {
247 bool newstate = false; 247 bool newstate = false;
248 if(m_forceGodModeAlwaysOn) 248 if(m_forceGodModeAlwaysOn)
249 newstate = true; 249 newstate = m_viewergodlevel >= 200;
250 else 250 if(state != null)
251 { 251 {
252 if(state != null) 252 OSDMap s = (OSDMap)state;
253 {
254 OSDMap s = (OSDMap)state;
255 253
256 if (s.ContainsKey("ViewerUiIsGod")) 254 if (s.ContainsKey("ViewerUiIsGod"))
257 newstate = s["ViewerUiIsGod"].AsBoolean(); 255 newstate = s["ViewerUiIsGod"].AsBoolean();
258 m_lastLevelToViewer = m_viewergodlevel; // we are not changing viewer level by default 256 m_lastLevelToViewer = m_viewergodlevel; // we are not changing viewer level by default
259 }
260 } 257 }
261 UpdateGodLevels(newstate); 258 UpdateGodLevels(newstate);
262 } 259 }
@@ -264,6 +261,11 @@ namespace OpenSim.Region.Framework.Scenes
264 public void HasMovedAway() 261 public void HasMovedAway()
265 { 262 {
266 m_lastLevelToViewer = 0; 263 m_lastLevelToViewer = 0;
264 if(m_forceGodModeAlwaysOn)
265 {
266 m_viewergodlevel = m_rightsGodLevel;
267 m_godlevel = m_rightsGodLevel;
268 }
267 } 269 }
268 270
269 public int UserLevel 271 public int UserLevel
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
index e4aa196..d81d8a2 100644
--- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
+++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
@@ -495,6 +495,7 @@ namespace OpenSim.Region.Framework.Scenes
495 495
496 m_group.RootPart.Velocity = Vector3.Zero; 496 m_group.RootPart.Velocity = Vector3.Zero;
497 m_group.RootPart.AngularVelocity = Vector3.Zero; 497 m_group.RootPart.AngularVelocity = Vector3.Zero;
498 m_skippedUpdates = 1000;
498 m_group.SendGroupRootTerseUpdate(); 499 m_group.SendGroupRootTerseUpdate();
499// m_group.RootPart.ScheduleTerseUpdate(); 500// m_group.RootPart.ScheduleTerseUpdate();
500 } 501 }
@@ -517,6 +518,7 @@ namespace OpenSim.Region.Framework.Scenes
517 return; 518 return;
518 if (m_running && !m_waitingCrossing) 519 if (m_running && !m_waitingCrossing)
519 StartTimer(); 520 StartTimer();
521 m_skippedUpdates = 1000;
520 } 522 }
521 } 523 }
522 524
@@ -643,10 +645,15 @@ namespace OpenSim.Region.Framework.Scenes
643 m_group.RootPart.Velocity = Vector3.Zero; 645 m_group.RootPart.Velocity = Vector3.Zero;
644 m_group.RootPart.AngularVelocity = Vector3.Zero; 646 m_group.RootPart.AngularVelocity = Vector3.Zero;
645 m_group.SendGroupRootTerseUpdate(); 647 m_group.SendGroupRootTerseUpdate();
646 // m_group.RootPart.ScheduleTerseUpdate(); 648
647 m_frames.Clear(); 649 m_frames.Clear();
648 } 650 }
649 651
652 Vector3 m_lastPosUpdate;
653 Quaternion m_lastRotationUpdate;
654 Vector3 m_currentVel;
655 int m_skippedUpdates;
656
650 private void DoOnTimer(double tickDuration) 657 private void DoOnTimer(double tickDuration)
651 { 658 {
652 if (m_skipLoops > 0) 659 if (m_skipLoops > 0)
@@ -665,6 +672,7 @@ namespace OpenSim.Region.Framework.Scenes
665 if (m_group.RootPart.Velocity != Vector3.Zero) 672 if (m_group.RootPart.Velocity != Vector3.Zero)
666 { 673 {
667 m_group.RootPart.Velocity = Vector3.Zero; 674 m_group.RootPart.Velocity = Vector3.Zero;
675 m_skippedUpdates = 1000;
668 m_group.SendGroupRootTerseUpdate(); 676 m_group.SendGroupRootTerseUpdate();
669 } 677 }
670 return; 678 return;
@@ -677,7 +685,9 @@ namespace OpenSim.Region.Framework.Scenes
677 // retry to set the position that evtually caused the outbound 685 // retry to set the position that evtually caused the outbound
678 // if still outside region this will call startCrossing below 686 // if still outside region this will call startCrossing below
679 m_isCrossing = false; 687 m_isCrossing = false;
688 m_skippedUpdates = 1000;
680 m_group.AbsolutePosition = m_nextPosition; 689 m_group.AbsolutePosition = m_nextPosition;
690
681 if (!m_isCrossing) 691 if (!m_isCrossing)
682 { 692 {
683 StopTimer(); 693 StopTimer();
@@ -700,10 +710,12 @@ namespace OpenSim.Region.Framework.Scenes
700 } 710 }
701 711
702 m_currentFrame = m_frames[0]; 712 m_currentFrame = m_frames[0];
703 m_currentFrame.TimeMS += (int)tickDuration;
704 } 713 }
705 //force a update on a keyframe transition
706 m_nextPosition = m_group.AbsolutePosition; 714 m_nextPosition = m_group.AbsolutePosition;
715 m_currentVel = (Vector3)m_currentFrame.Position - m_nextPosition;
716 m_currentVel /= (m_currentFrame.TimeMS * 0.001f);
717
718 m_currentFrame.TimeMS += (int)tickDuration;
707 update = true; 719 update = true;
708 } 720 }
709 721
@@ -712,7 +724,7 @@ namespace OpenSim.Region.Framework.Scenes
712 // Do the frame processing 724 // Do the frame processing
713 double remainingSteps = (double)m_currentFrame.TimeMS / tickDuration; 725 double remainingSteps = (double)m_currentFrame.TimeMS / tickDuration;
714 726
715 if (remainingSteps <= 0.0) 727 if (remainingSteps <= 1.0)
716 { 728 {
717 m_group.RootPart.Velocity = Vector3.Zero; 729 m_group.RootPart.Velocity = Vector3.Zero;
718 m_group.RootPart.AngularVelocity = Vector3.Zero; 730 m_group.RootPart.AngularVelocity = Vector3.Zero;
@@ -720,92 +732,71 @@ namespace OpenSim.Region.Framework.Scenes
720 m_nextPosition = (Vector3)m_currentFrame.Position; 732 m_nextPosition = (Vector3)m_currentFrame.Position;
721 m_group.AbsolutePosition = m_nextPosition; 733 m_group.AbsolutePosition = m_nextPosition;
722 734
723 // we are sending imediate updates, no doing force a extra terseUpdate
724 // m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
725
726 m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; 735 m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation;
727 736
728 lock (m_frames) 737 lock (m_frames)
729 { 738 {
730 m_frames.RemoveAt(0); 739 m_frames.RemoveAt(0);
731 if (m_frames.Count > 0) 740 if (m_frames.Count > 0)
741 {
732 m_currentFrame = m_frames[0]; 742 m_currentFrame = m_frames[0];
743 m_currentVel = (Vector3)m_currentFrame.Position - m_nextPosition;
744 m_currentVel /= (m_currentFrame.TimeMS * 0.001f);
745 m_group.RootPart.Velocity = m_currentVel;
746 m_currentFrame.TimeMS += (int)tickDuration;
747 }
748 else
749 m_group.RootPart.Velocity = Vector3.Zero;
733 } 750 }
734
735 update = true; 751 update = true;
736 } 752 }
737 else 753 else
738 { 754 {
739 float completed = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; 755 bool lastSteps = remainingSteps < 4;
740 bool lastStep = m_currentFrame.TimeMS <= tickDuration; 756 Vector3 currentPosition = m_group.AbsolutePosition;
741 757 Vector3 motionThisFrame = (Vector3)m_currentFrame.Position - currentPosition;
742 Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition; 758 motionThisFrame /= (float)remainingSteps;
743 Vector3 motionThisFrame = v / (float)remainingSteps; 759
744 v = v * 1000 / m_currentFrame.TimeMS; 760 m_nextPosition = currentPosition + motionThisFrame;
745 761
746 m_nextPosition = m_group.AbsolutePosition + motionThisFrame; 762 Quaternion currentRotation = m_group.GroupRotation;
747 763 if ((Quaternion)m_currentFrame.Rotation != currentRotation)
748 if (Vector3.Mag(motionThisFrame) >= 0.05f)
749 update = true;
750
751 //int totalSteps = m_currentFrame.TimeTotal / (int)tickDuration;
752 //m_log.DebugFormat("KeyframeMotion.OnTimer: step {0}/{1}, curPosition={2}, finalPosition={3}, motionThisStep={4} (scene {5})",
753 // totalSteps - remainingSteps + 1, totalSteps, m_group.AbsolutePosition, m_currentFrame.Position, motionThisStep, m_scene.RegionInfo.RegionName);
754
755 if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation)
756 { 764 {
757 Quaternion current = m_group.GroupRotation; 765 float completed = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal;
758
759 Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, completed); 766 Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, completed);
760 step.Normalize(); 767 step.Normalize();
761 /* use simpler change detection 768 m_group.RootPart.RotationOffset = step;
762 * float angle = 0; 769 if (Math.Abs(step.X - m_lastRotationUpdate.X) > 0.001f
763 770 || Math.Abs(step.Y - m_lastRotationUpdate.Y) > 0.001f
764 float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; 771 || Math.Abs(step.Z - m_lastRotationUpdate.Z) > 0.001f)
765 float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W;
766 float aa_bb = aa * bb;
767
768 if (aa_bb == 0)
769 {
770 angle = 0;
771 }
772 else
773 {
774 float ab = current.X * step.X +
775 current.Y * step.Y +
776 current.Z * step.Z +
777 current.W * step.W;
778 float q = (ab * ab) / aa_bb;
779
780 if (q > 1.0f)
781 {
782 angle = 0;
783 }
784 else
785 {
786 angle = (float)Math.Acos(2 * q - 1);
787 }
788 }
789
790 if (angle > 0.01f)
791 */
792 if (Math.Abs(step.X - current.X) > 0.001f
793 || Math.Abs(step.Y - current.Y) > 0.001f
794 || Math.Abs(step.Z - current.Z) > 0.001f)
795 // assuming w is a dependente var
796 {
797// m_group.UpdateGroupRotationR(step);
798 m_group.RootPart.RotationOffset = step;
799
800 //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
801 update = true; 772 update = true;
802 }
803 } 773 }
804 }
805 774
806 if (update)
807 {
808 m_group.AbsolutePosition = m_nextPosition; 775 m_group.AbsolutePosition = m_nextPosition;
776 if(lastSteps)
777 m_group.RootPart.Velocity = Vector3.Zero;
778 else
779 m_group.RootPart.Velocity = m_currentVel;
780
781 if(!update && (
782 lastSteps ||
783 m_skippedUpdates * tickDuration > 0.5 ||
784 Math.Abs(m_nextPosition.X - currentPosition.X) > 5f ||
785 Math.Abs(m_nextPosition.Y - currentPosition.Y) > 5f ||
786 Math.Abs(m_nextPosition.Z - currentPosition.Z) > 5f
787 ))
788 {
789 update = true;
790 }
791 else
792 m_skippedUpdates++;
793
794 }
795 if(update)
796 {
797 m_lastPosUpdate = m_nextPosition;
798 m_lastRotationUpdate = m_group.GroupRotation;
799 m_skippedUpdates = 0;
809 m_group.SendGroupRootTerseUpdate(); 800 m_group.SendGroupRootTerseUpdate();
810 } 801 }
811 } 802 }
@@ -850,6 +841,7 @@ namespace OpenSim.Region.Framework.Scenes
850 if (m_group.RootPart.Velocity != Vector3.Zero) 841 if (m_group.RootPart.Velocity != Vector3.Zero)
851 { 842 {
852 m_group.RootPart.Velocity = Vector3.Zero; 843 m_group.RootPart.Velocity = Vector3.Zero;
844 m_skippedUpdates = 1000;
853 m_group.SendGroupRootTerseUpdate(); 845 m_group.SendGroupRootTerseUpdate();
854// m_group.RootPart.ScheduleTerseUpdate(); 846// m_group.RootPart.ScheduleTerseUpdate();
855 } 847 }
@@ -862,6 +854,7 @@ namespace OpenSim.Region.Framework.Scenes
862 if (m_group != null) 854 if (m_group != null)
863 { 855 {
864 m_group.RootPart.Velocity = Vector3.Zero; 856 m_group.RootPart.Velocity = Vector3.Zero;
857 m_skippedUpdates = 1000;
865 m_group.SendGroupRootTerseUpdate(); 858 m_group.SendGroupRootTerseUpdate();
866// m_group.RootPart.ScheduleTerseUpdate(); 859// m_group.RootPart.ScheduleTerseUpdate();
867 860
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
index cbf40c8..53ca849 100644
--- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs
+++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
@@ -172,14 +172,22 @@ namespace OpenSim.Region.Framework.Scenes
172 172
173 if (entity is SceneObjectPart) 173 if (entity is SceneObjectPart)
174 { 174 {
175 SceneObjectGroup sog = ((SceneObjectPart)entity).ParentGroup;
175 // Attachments are high priority, 176 // Attachments are high priority,
176 if (((SceneObjectPart)entity).ParentGroup.IsAttachment) 177 if (sog.IsAttachment)
177 return 2; 178 return 2;
179
180
181 if(presence.ParentPart != null)
182 {
183 if(presence.ParentPart.ParentGroup == sog)
184 return 2;
185 }
178 186
179 pqueue = ComputeDistancePriority(client, entity, false); 187 pqueue = ComputeDistancePriority(client, entity, false);
180 188
181 // Non physical prims are lower priority than physical prims 189 // Non physical prims are lower priority than physical prims
182 PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; 190 PhysicsActor physActor = sog.RootPart.PhysActor;
183 if (physActor == null || !physActor.IsPhysical) 191 if (physActor == null || !physActor.IsPhysical)
184 pqueue++; 192 pqueue++;
185 } 193 }
@@ -302,6 +310,17 @@ namespace OpenSim.Region.Framework.Scenes
302 else 310 else
303 { 311 {
304 SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; 312 SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup;
313 if(presence.ParentPart != null)
314 {
315 if(presence.ParentPart.ParentGroup == group)
316 return pqueue;
317 }
318 if(group.IsAttachment)
319 {
320 if(group.RootPart.LocalId == presence.LocalId)
321 return pqueue;
322 }
323
305 float bradius = group.GetBoundsRadius(); 324 float bradius = group.GetBoundsRadius();
306 Vector3 grppos = group.AbsolutePosition + group.getBoundsCenter(); 325 Vector3 grppos = group.AbsolutePosition + group.getBoundsCenter();
307 distance = Vector3.Distance(presencePos, grppos); 326 distance = Vector3.Distance(presencePos, grppos);
diff --git a/OpenSim/Region/Framework/Scenes/SOPMaterial.cs b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs
index 651c52e..d38ef61 100644
--- a/OpenSim/Region/Framework/Scenes/SOPMaterial.cs
+++ b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenMetaverse.StructuredData;
31using OpenSim.Framework; 32using OpenSim.Framework;
32 33
33namespace OpenSim.Region.Framework.Scenes 34namespace OpenSim.Region.Framework.Scenes
@@ -90,6 +91,87 @@ namespace OpenSim.Region.Framework.Scenes
90 else 91 else
91 return 0; 92 return 0;
92 } 93 }
94 }
95
96 public class FaceMaterial
97 {
98 public UUID ID;
99 public UUID NormalMapID = UUID.Zero;
100 public float NormalOffsetX = 0.0f;
101 public float NormalOffsetY = 0.0f;
102 public float NormalRepeatX = 1.0f;
103 public float NormalRepeatY = 1.0f;
104 public float NormalRotation = 0.0f;
105
106 public UUID SpecularMapID = UUID.Zero;
107 public float SpecularOffsetX = 0.0f;
108 public float SpecularOffsetY = 0.0f;
109 public float SpecularRepeatX = 1.0f;
110 public float SpecularRepeatY = 1.0f;
111 public float SpecularRotation = 0.0f;
112
113 public Color4 SpecularLightColor = new Color4(255,255,255,255);
114 public Byte SpecularLightExponent = 51;
115 public Byte EnvironmentIntensity = 0;
116 public Byte DiffuseAlphaMode = 1;
117 public Byte AlphaMaskCutoff = 0;
118
119 public FaceMaterial()
120 { }
121
122 public FaceMaterial(UUID pID, OSDMap mat)
123 {
124 ID = pID;
125 if(mat == null)
126 return;
127 float scale = 0.0001f;
128 NormalMapID = mat["NormMap"].AsUUID();
129 NormalOffsetX = scale * (float)mat["NormOffsetX"].AsReal();
130 NormalOffsetY = scale * (float)mat["NormOffsetY"].AsReal();
131 NormalRepeatX = scale * (float)mat["NormRepeatX"].AsReal();
132 NormalRepeatY = scale * (float)mat["NormRepeatY"].AsReal();
133 NormalRotation = scale * (float)mat["NormRotation"].AsReal();
134
135 SpecularMapID = mat["SpecMap"].AsUUID();
136 SpecularOffsetX = scale * (float)mat["SpecOffsetX"].AsReal();
137 SpecularOffsetY = scale * (float)mat["SpecOffsetY"].AsReal();
138 SpecularRepeatX = scale * (float)mat["SpecRepeatX"].AsReal();
139 SpecularRepeatY = scale * (float)mat["SpecRepeatY"].AsReal();
140 SpecularRotation = scale * (float)mat["SpecRotation"].AsReal();
93 141
142 SpecularLightColor = mat["SpecColor"].AsColor4();
143 SpecularLightExponent = (Byte)mat["SpecExp"].AsUInteger();
144 EnvironmentIntensity = (Byte)mat["EnvIntensity"].AsUInteger();
145 DiffuseAlphaMode = (Byte)mat["DiffuseAlphaMode"].AsUInteger();
146 AlphaMaskCutoff = (Byte)mat["AlphaMaskCutoff"].AsUInteger();
147 }
148
149 public OSDMap toOSD()
150 {
151 OSDMap mat = new OSDMap();
152 float scale = 10000f;
153
154 mat["NormMap"] = NormalMapID;
155 mat["NormOffsetX"] = (int) (scale * NormalOffsetX);
156 mat["NormOffsetY"] = (int) (scale * NormalOffsetY);
157 mat["NormRepeatX"] = (int) (scale * NormalRepeatX);
158 mat["NormRepeatY"] = (int) (scale * NormalRepeatY);
159 mat["NormRotation"] = (int) (scale * NormalRotation);
160
161 mat["SpecMap"] = SpecularMapID;
162 mat["SpecOffsetX"] = (int) (scale * SpecularOffsetX);
163 mat["SpecOffsetY"] = (int) (scale * SpecularOffsetY);
164 mat["SpecRepeatX"] = (int) (scale * SpecularRepeatX);
165 mat["SpecRepeatY"] = (int) (scale * SpecularRepeatY);
166 mat["SpecRotation"] = (int) (scale * SpecularRotation);
167
168 mat["SpecColor"] = SpecularLightColor;
169 mat["SpecExp"] = SpecularLightExponent;
170 mat["EnvIntensity"] = EnvironmentIntensity;
171 mat["DiffuseAlphaMode"] = DiffuseAlphaMode;
172 mat["AlphaMaskCutoff"] = AlphaMaskCutoff;
173
174 return mat;
175 }
94 } 176 }
95} \ No newline at end of file 177} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index cb06540..2f016fa 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -338,6 +338,7 @@ namespace OpenSim.Region.Framework.Scenes
338 // Update item with new asset 338 // Update item with new asset
339 item.AssetID = asset.FullID; 339 item.AssetID = asset.FullID;
340 group.UpdateInventoryItem(item); 340 group.UpdateInventoryItem(item);
341 group.AggregatePerms();
341 342
342 part.SendPropertiesToClient(remoteClient); 343 part.SendPropertiesToClient(remoteClient);
343 344
@@ -647,7 +648,8 @@ namespace OpenSim.Region.Framework.Scenes
647 // Modify 648 // Modify
648 uint permsMask = ~ ((uint)PermissionMask.Copy | 649 uint permsMask = ~ ((uint)PermissionMask.Copy |
649 (uint)PermissionMask.Transfer | 650 (uint)PermissionMask.Transfer |
650 (uint)PermissionMask.Modify); 651 (uint)PermissionMask.Modify |
652 (uint)PermissionMask.Export);
651 653
652 // Now, reduce the next perms to the mask bits 654 // Now, reduce the next perms to the mask bits
653 // relevant to the operation 655 // relevant to the operation
@@ -677,6 +679,23 @@ namespace OpenSim.Region.Framework.Scenes
677 (uint)PermissionMask.Move; 679 (uint)PermissionMask.Move;
678 uint ownerPerms = item.CurrentPermissions; 680 uint ownerPerms = item.CurrentPermissions;
679 681
682 // These will be applied to the root prim at next rez.
683 // The legacy slam bit (bit 3) and folded permission (bits 0-2)
684 // are preserved due to the above mangling
685 ownerPerms &= nextPerms;
686
687 // Mask the base permissions. This is a conservative
688 // approach altering only the three main perms
689 basePerms &= nextPerms;
690
691 // Mask out the folded portion of the base mask.
692 // While the owner mask carries the actual folded
693 // permissions, the base mask carries the original
694 // base mask, before masking with the folded perms.
695 // We need this later for rezzing.
696 basePerms &= ~(uint)PermissionMask.FoldedMask;
697 basePerms |= ((basePerms >> 13) & 7) | (((basePerms & (uint)PermissionMask.Export) != 0) ? (uint)PermissionMask.FoldedExport : 0);
698
680 // If this is an object, root prim perms may be more 699 // If this is an object, root prim perms may be more
681 // permissive than folded perms. Use folded perms as 700 // permissive than folded perms. Use folded perms as
682 // a mask 701 // a mask
@@ -684,6 +703,9 @@ namespace OpenSim.Region.Framework.Scenes
684 { 703 {
685 // Create a safe mask for the current perms 704 // Create a safe mask for the current perms
686 uint foldedPerms = (item.CurrentPermissions & 7) << 13; 705 uint foldedPerms = (item.CurrentPermissions & 7) << 13;
706 if ((item.CurrentPermissions & (uint)PermissionMask.FoldedExport) != 0)
707 foldedPerms |= (uint)PermissionMask.Export;
708
687 foldedPerms |= permsMask; 709 foldedPerms |= permsMask;
688 710
689 bool isRootMod = (item.CurrentPermissions & 711 bool isRootMod = (item.CurrentPermissions &
@@ -691,6 +713,8 @@ namespace OpenSim.Region.Framework.Scenes
691 true : false; 713 true : false;
692 714
693 // Mask the owner perms to the folded perms 715 // Mask the owner perms to the folded perms
716 // Note that this is only to satisfy the viewer.
717 // The effect of this will be reversed on rez.
694 ownerPerms &= foldedPerms; 718 ownerPerms &= foldedPerms;
695 basePerms &= foldedPerms; 719 basePerms &= foldedPerms;
696 720
@@ -705,15 +729,6 @@ namespace OpenSim.Region.Framework.Scenes
705 } 729 }
706 } 730 }
707 731
708 // These will be applied to the root prim at next rez.
709 // The slam bit (bit 3) and folded permission (bits 0-2)
710 // are preserved due to the above mangling
711 ownerPerms &= nextPerms;
712
713 // Mask the base permissions. This is a conservative
714 // approach altering only the three main perms
715 basePerms &= nextPerms;
716
717 // Assign to the actual item. Make sure the slam bit is 732 // Assign to the actual item. Make sure the slam bit is
718 // set, if it wasn't set before. 733 // set, if it wasn't set before.
719 itemCopy.BasePermissions = basePerms; 734 itemCopy.BasePermissions = basePerms;
@@ -1200,6 +1215,7 @@ namespace OpenSim.Region.Framework.Scenes
1200 } 1215 }
1201 1216
1202 group.RemoveInventoryItem(localID, itemID); 1217 group.RemoveInventoryItem(localID, itemID);
1218 group.AggregatePerms();
1203 } 1219 }
1204 1220
1205 part.SendPropertiesToClient(remoteClient); 1221 part.SendPropertiesToClient(remoteClient);
@@ -1244,6 +1260,10 @@ namespace OpenSim.Region.Framework.Scenes
1244 agentItem.InvType = taskItem.InvType; 1260 agentItem.InvType = taskItem.InvType;
1245 agentItem.Flags = taskItem.Flags; 1261 agentItem.Flags = taskItem.Flags;
1246 1262
1263 // The code below isn't OK. It doesn't account for flags being changed
1264 // in the object inventory, so it will break when you do it. That
1265 // is the previous behaviour, so no matter at this moment. However, there is a lot
1266 // TODO: Fix this after the inventory fixer exists and has beenr run
1247 if ((part.OwnerID != destAgent) && Permissions.PropagatePermissions()) 1267 if ((part.OwnerID != destAgent) && Permissions.PropagatePermissions())
1248 { 1268 {
1249 agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); 1269 agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
@@ -1252,7 +1272,7 @@ namespace OpenSim.Region.Framework.Scenes
1252 else 1272 else
1253 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; 1273 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions;
1254 1274
1255 agentItem.CurrentPermissions = agentItem.BasePermissions; 1275 agentItem.BasePermissions = agentItem.CurrentPermissions;
1256 1276
1257 agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; 1277 agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
1258 agentItem.Flags &= ~(uint)(InventoryItemFlags.ObjectOverwriteBase | InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup | InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner); 1278 agentItem.Flags &= ~(uint)(InventoryItemFlags.ObjectOverwriteBase | InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup | InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner);
@@ -1360,18 +1380,10 @@ namespace OpenSim.Region.Framework.Scenes
1360 return; 1380 return;
1361 } 1381 }
1362 1382
1363 if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1383 if (!Permissions.CanCopyObjectInventory(itemId, part.UUID, remoteClient.AgentId))
1364 {
1365 // If the item to be moved is no copy, we need to be able to
1366 // edit the prim.
1367 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
1368 return;
1369 }
1370 else
1371 { 1384 {
1372 // If the item is copiable, then we just need to have perms 1385 // check also if we can delete the no copy item
1373 // on it. The delete check is a pure rights check 1386 if(!Permissions.CanEditObject(part.UUID, remoteClient.AgentId))
1374 if (!Permissions.CanDeleteObject(part.UUID, remoteClient.AgentId))
1375 return; 1387 return;
1376 } 1388 }
1377 1389
@@ -1449,29 +1461,9 @@ namespace OpenSim.Region.Framework.Scenes
1449 return; 1461 return;
1450 } 1462 }
1451 1463
1452 // Can't transfer this 1464 if(!Permissions.CanDoObjectInvToObjectInv(srcTaskItem, part, destPart))
1453 //
1454 if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
1455 return; 1465 return;
1456 1466
1457 bool overrideNoMod = false;
1458 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1459 overrideNoMod = true;
1460
1461 if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1462 {
1463 // object cannot copy items to an object owned by a different owner
1464 // unless llAllowInventoryDrop has been called
1465
1466 return;
1467 }
1468
1469 // must have both move and modify permission to put an item in an object
1470 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1471 {
1472 return;
1473 }
1474
1475 TaskInventoryItem destTaskItem = new TaskInventoryItem(); 1467 TaskInventoryItem destTaskItem = new TaskInventoryItem();
1476 1468
1477 destTaskItem.ItemID = UUID.Random(); 1469 destTaskItem.ItemID = UUID.Random();
@@ -1512,9 +1504,10 @@ namespace OpenSim.Region.Framework.Scenes
1512 destTaskItem.Type = srcTaskItem.Type; 1504 destTaskItem.Type = srcTaskItem.Type;
1513 1505
1514 destPart.Inventory.AddInventoryItem(destTaskItem, part.OwnerID != destPart.OwnerID); 1506 destPart.Inventory.AddInventoryItem(destTaskItem, part.OwnerID != destPart.OwnerID);
1515
1516 if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1507 if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
1508 {
1517 part.Inventory.RemoveInventoryItem(itemId); 1509 part.Inventory.RemoveInventoryItem(itemId);
1510 }
1518 1511
1519 ScenePresence avatar; 1512 ScenePresence avatar;
1520 1513
@@ -1652,76 +1645,79 @@ namespace OpenSim.Region.Framework.Scenes
1652 uint primLocalID) 1645 uint primLocalID)
1653 { 1646 {
1654 UUID itemID = itemInfo.ItemID; 1647 UUID itemID = itemInfo.ItemID;
1648 if (itemID == UUID.Zero)
1649 {
1650 m_log.ErrorFormat(
1651 "[PRIM INVENTORY]: UpdateTaskInventory called with item ID Zero on update for {1}!",
1652 remoteClient.Name);
1653 return;
1654 }
1655 1655
1656 // Find the prim we're dealing with 1656 // Find the prim we're dealing with
1657 SceneObjectPart part = GetSceneObjectPart(primLocalID); 1657 SceneObjectPart part = GetSceneObjectPart(primLocalID);
1658 if(part == null)
1659 {
1660 m_log.WarnFormat(
1661 "[PRIM INVENTORY]: " +
1662 "Update with item {0} requested of prim {1} for {2} but this prim does not exist",
1663 itemID, primLocalID, remoteClient.Name);
1664 return;
1665 }
1658 1666
1659 if (part != null) 1667 TaskInventoryItem currentItem = part.Inventory.GetInventoryItem(itemID);
1668
1669 if (currentItem == null)
1660 { 1670 {
1661 TaskInventoryItem currentItem = part.Inventory.GetInventoryItem(itemID); 1671 InventoryItemBase item = InventoryService.GetItem(remoteClient.AgentId, itemID);
1662 bool allowInventoryDrop = (part.GetEffectiveObjectFlags()
1663 & (uint)PrimFlags.AllowInventoryDrop) != 0;
1664 1672
1665 // Explicity allow anyone to add to the inventory if the 1673 // if not found Try library
1666 // AllowInventoryDrop flag has been set. Don't however let 1674 if (item == null && LibraryService != null && LibraryService.LibraryRootFolder != null)
1667 // them update an item unless they pass the external checks 1675 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1668 //
1669 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)
1670 && (currentItem != null || !allowInventoryDrop))
1671 return;
1672 1676
1673 if (currentItem == null) 1677 if(item == null)
1674 { 1678 {
1675 UUID copyID = UUID.Random(); 1679 m_log.ErrorFormat(
1676 if (itemID != UUID.Zero) 1680 "[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!",
1677 { 1681 itemID, remoteClient.Name);
1678 InventoryItemBase item = InventoryService.GetItem(remoteClient.AgentId, itemID); 1682 return;
1683 }
1679 1684
1680 // Try library 1685 if (!Permissions.CanDropInObjectInv(item, remoteClient, part))
1681 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) 1686 return;
1682 {
1683 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1684 }
1685 1687
1686 // If we've found the item in the user's inventory or in the library 1688 UUID copyID = UUID.Random();
1687 if (item != null) 1689 bool modrights = Permissions.CanEditObject(part.ParentGroup, remoteClient);
1688 { 1690 part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID, modrights);
1689 part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID); 1691 m_log.InfoFormat(
1690 m_log.InfoFormat( 1692 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
1691 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", 1693 item.Name, primLocalID, remoteClient.Name);
1692 item.Name, primLocalID, remoteClient.Name); 1694 part.SendPropertiesToClient(remoteClient);
1693 part.SendPropertiesToClient(remoteClient); 1695 if (!Permissions.BypassPermissions())
1694 if (!Permissions.BypassPermissions()) 1696 {
1695 { 1697 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
1696 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1698 {
1697 { 1699 List<UUID> uuids = new List<UUID>();
1698 List<UUID> uuids = new List<UUID>(); 1700 uuids.Add(itemID);
1699 uuids.Add(itemID); 1701 RemoveInventoryItem(remoteClient, uuids);
1700 RemoveInventoryItem(remoteClient, uuids);
1701 }
1702 }
1703 }
1704 else
1705 {
1706 m_log.ErrorFormat(
1707 "[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!",
1708 itemID, remoteClient.Name);
1709 }
1710 } 1702 }
1711 } 1703 }
1712 else // Updating existing item with new perms etc 1704 }
1713 { 1705 else // Updating existing item with new perms etc
1706 {
1714// m_log.DebugFormat( 1707// m_log.DebugFormat(
1715// "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", 1708// "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()",
1716// currentItem.Name, part.Name); 1709// currentItem.Name, part.Name);
1717 1710
1718 // Only look for an uploaded updated asset if we are passed a transaction ID. This is only the 1711 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
1719 // case for updates uploded through UDP. Updates uploaded via a capability (e.g. a script update) 1712 return;
1720 // will not pass in a transaction ID in the update message. 1713
1721 if (transactionID != UUID.Zero && AgentTransactionsModule != null) 1714 // Only look for an uploaded updated asset if we are passed a transaction ID. This is only the
1722 { 1715 // case for updates uploded through UDP. Updates uploaded via a capability (e.g. a script update)
1723 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( 1716 // will not pass in a transaction ID in the update message.
1724 remoteClient, part, transactionID, currentItem); 1717 if (transactionID != UUID.Zero && AgentTransactionsModule != null)
1718 {
1719 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction(
1720 remoteClient, part, transactionID, currentItem);
1725 1721
1726// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) 1722// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1727// remoteClient.SendAgentAlertMessage("Notecard saved", false); 1723// remoteClient.SendAgentAlertMessage("Notecard saved", false);
@@ -1729,49 +1725,30 @@ namespace OpenSim.Region.Framework.Scenes
1729// remoteClient.SendAgentAlertMessage("Script saved", false); 1725// remoteClient.SendAgentAlertMessage("Script saved", false);
1730// else 1726// else
1731// remoteClient.SendAgentAlertMessage("Item saved", false); 1727// remoteClient.SendAgentAlertMessage("Item saved", false);
1732 } 1728 }
1733 1729
1734 // Base ALWAYS has move 1730 // Base ALWAYS has move
1735 currentItem.BasePermissions |= (uint)PermissionMask.Move; 1731 currentItem.BasePermissions |= (uint)PermissionMask.Move;
1736 1732
1737 itemInfo.Flags = currentItem.Flags; 1733 itemInfo.Flags = currentItem.Flags;
1738 1734
1739 // Check if we're allowed to mess with permissions 1735 // Check if we're allowed to mess with permissions
1740 if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god 1736 if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god
1737 {
1738 if (remoteClient.AgentId != part.OwnerID) // Not owner
1741 { 1739 {
1742 if (remoteClient.AgentId != part.OwnerID) // Not owner 1740 // Friends and group members can't change any perms
1743 { 1741 itemInfo.BasePermissions = currentItem.BasePermissions;
1744 // Friends and group members can't change any perms 1742 itemInfo.EveryonePermissions = currentItem.EveryonePermissions;
1745 itemInfo.BasePermissions = currentItem.BasePermissions; 1743 itemInfo.GroupPermissions = currentItem.GroupPermissions;
1746 itemInfo.EveryonePermissions = currentItem.EveryonePermissions; 1744 itemInfo.NextPermissions = currentItem.NextPermissions;
1747 itemInfo.GroupPermissions = currentItem.GroupPermissions; 1745 itemInfo.CurrentPermissions = currentItem.CurrentPermissions;
1748 itemInfo.NextPermissions = currentItem.NextPermissions;
1749 itemInfo.CurrentPermissions = currentItem.CurrentPermissions;
1750 }
1751 else
1752 {
1753 // Owner can't change base, and can change other
1754 // only up to base
1755 itemInfo.BasePermissions = currentItem.BasePermissions;
1756 if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions)
1757 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone;
1758 if (itemInfo.GroupPermissions != currentItem.GroupPermissions)
1759 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup;
1760 if (itemInfo.CurrentPermissions != currentItem.CurrentPermissions)
1761 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner;
1762 if (itemInfo.NextPermissions != currentItem.NextPermissions)
1763 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner;
1764 itemInfo.EveryonePermissions &= currentItem.BasePermissions;
1765 itemInfo.GroupPermissions &= currentItem.BasePermissions;
1766 itemInfo.CurrentPermissions &= currentItem.BasePermissions;
1767 itemInfo.NextPermissions &= currentItem.BasePermissions;
1768 }
1769
1770 } 1746 }
1771 else 1747 else
1772 { 1748 {
1773 if (itemInfo.BasePermissions != currentItem.BasePermissions) 1749 // Owner can't change base, and can change other
1774 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteBase; 1750 // only up to base
1751 itemInfo.BasePermissions = currentItem.BasePermissions;
1775 if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions) 1752 if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions)
1776 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; 1753 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone;
1777 if (itemInfo.GroupPermissions != currentItem.GroupPermissions) 1754 if (itemInfo.GroupPermissions != currentItem.GroupPermissions)
@@ -1780,24 +1757,35 @@ namespace OpenSim.Region.Framework.Scenes
1780 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner; 1757 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner;
1781 if (itemInfo.NextPermissions != currentItem.NextPermissions) 1758 if (itemInfo.NextPermissions != currentItem.NextPermissions)
1782 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; 1759 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner;
1760 itemInfo.EveryonePermissions &= currentItem.BasePermissions;
1761 itemInfo.GroupPermissions &= currentItem.BasePermissions;
1762 itemInfo.CurrentPermissions &= currentItem.BasePermissions;
1763 itemInfo.NextPermissions &= currentItem.BasePermissions;
1783 } 1764 }
1784 1765
1785 // Next ALWAYS has move 1766 }
1786 itemInfo.NextPermissions |= (uint)PermissionMask.Move; 1767 else
1768 {
1769 if (itemInfo.BasePermissions != currentItem.BasePermissions)
1770 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteBase;
1771 if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions)
1772 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone;
1773 if (itemInfo.GroupPermissions != currentItem.GroupPermissions)
1774 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup;
1775 if (itemInfo.CurrentPermissions != currentItem.CurrentPermissions)
1776 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner;
1777 if (itemInfo.NextPermissions != currentItem.NextPermissions)
1778 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner;
1779 }
1787 1780
1788 if (part.Inventory.UpdateInventoryItem(itemInfo)) 1781 // Next ALWAYS has move
1789 { 1782 itemInfo.NextPermissions |= (uint)PermissionMask.Move;
1790 part.SendPropertiesToClient(remoteClient); 1783
1791 } 1784 if (part.Inventory.UpdateInventoryItem(itemInfo))
1785 {
1786 part.SendPropertiesToClient(remoteClient);
1792 } 1787 }
1793 } 1788 }
1794 else
1795 {
1796 m_log.WarnFormat(
1797 "[PRIM INVENTORY]: " +
1798 "Update with item {0} requested of prim {1} for {2} but this prim does not exist",
1799 itemID, primLocalID, remoteClient.Name);
1800 }
1801 } 1789 }
1802 1790
1803 /// <summary> 1791 /// <summary>
@@ -1960,6 +1948,8 @@ namespace OpenSim.Region.Framework.Scenes
1960 part.Inventory.AddInventoryItem(taskItem, false); 1948 part.Inventory.AddInventoryItem(taskItem, false);
1961 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); 1949 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
1962 1950
1951 part.ParentGroup.AggregatePerms();
1952
1963 // tell anyone managing scripts that a new script exists 1953 // tell anyone managing scripts that a new script exists
1964 EventManager.TriggerNewScript(agentID, part, taskItem.ItemID); 1954 EventManager.TriggerNewScript(agentID, part, taskItem.ItemID);
1965 1955
@@ -2095,13 +2085,20 @@ namespace OpenSim.Region.Framework.Scenes
2095 /// <param name='action'>DeRezAction</param> 2085 /// <param name='action'>DeRezAction</param>
2096 /// <param name='destinationID'>User folder ID to place derezzed object</param> 2086 /// <param name='destinationID'>User folder ID to place derezzed object</param>
2097 public virtual void DeRezObjects( 2087 public virtual void DeRezObjects(
2098 IClientAPI remoteClient, List<uint> localIDs, UUID groupID, DeRezAction action, UUID destinationID) 2088 IClientAPI remoteClient, List<uint> localIDs, UUID groupID, DeRezAction action, UUID destinationID, bool AddToReturns = true)
2099 { 2089 {
2100 // First, see of we can perform the requested action and 2090 // First, see of we can perform the requested action and
2101 // build a list of eligible objects 2091 // build a list of eligible objects
2102 List<uint> deleteIDs = new List<uint>(); 2092 List<uint> deleteIDs = new List<uint>();
2103 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 2093 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
2104 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); 2094 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
2095 List<SceneObjectGroup> takeDeleteGroups = new List<SceneObjectGroup>();
2096
2097 ScenePresence sp = null;
2098 if(remoteClient != null)
2099 sp = remoteClient.SceneAgent as ScenePresence;
2100 else if(action != DeRezAction.Return)
2101 return; // only Return can be called without a client
2105 2102
2106 // Start with true for both, then remove the flags if objects 2103 // Start with true for both, then remove the flags if objects
2107 // that we can't derez are part of the selection 2104 // that we can't derez are part of the selection
@@ -2157,17 +2154,17 @@ namespace OpenSim.Region.Framework.Scenes
2157 { 2154 {
2158 if (action == DeRezAction.TakeCopy) 2155 if (action == DeRezAction.TakeCopy)
2159 { 2156 {
2160 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 2157 if (!Permissions.CanTakeCopyObject(grp, sp))
2161 permissionToTakeCopy = false; 2158 permissionToTakeCopy = false;
2162 } 2159 }
2163 else 2160 else
2164 { 2161 {
2165 permissionToTakeCopy = false; 2162 permissionToTakeCopy = false;
2166 } 2163 }
2167 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 2164 if (!Permissions.CanTakeObject(grp, sp))
2168 permissionToTake = false; 2165 permissionToTake = false;
2169 2166
2170 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 2167 if (!Permissions.CanDeleteObject(grp, remoteClient))
2171 permissionToDelete = false; 2168 permissionToDelete = false;
2172 } 2169 }
2173 2170
@@ -2208,13 +2205,14 @@ namespace OpenSim.Region.Framework.Scenes
2208 { 2205 {
2209 if (Permissions.CanReturnObjects( 2206 if (Permissions.CanReturnObjects(
2210 null, 2207 null,
2211 remoteClient.AgentId, 2208 remoteClient,
2212 new List<SceneObjectGroup>() {grp})) 2209 new List<SceneObjectGroup>() {grp}))
2213 { 2210 {
2214 permissionToTake = true; 2211 permissionToTake = true;
2215 permissionToDelete = true; 2212 permissionToDelete = true;
2216 2213 if(AddToReturns)
2217 AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); 2214 AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition,
2215 "parcel owner return");
2218 } 2216 }
2219 } 2217 }
2220 else // Auto return passes through here with null agent 2218 else // Auto return passes through here with null agent
@@ -2224,26 +2222,24 @@ namespace OpenSim.Region.Framework.Scenes
2224 } 2222 }
2225 } 2223 }
2226 2224
2227 if (permissionToTake && (!permissionToDelete))
2228 takeGroups.Add(grp);
2229
2230 if (permissionToDelete) 2225 if (permissionToDelete)
2231 { 2226 {
2232 if (permissionToTake) 2227 if (permissionToTake)
2228 takeDeleteGroups.Add(grp);
2229 else
2233 deleteGroups.Add(grp); 2230 deleteGroups.Add(grp);
2234 deleteIDs.Add(grp.LocalId); 2231 deleteIDs.Add(grp.LocalId);
2235 } 2232 }
2233 else if(permissionToTake)
2234 takeGroups.Add(grp);
2236 } 2235 }
2237 2236
2238 SendKillObject(deleteIDs); 2237 SendKillObject(deleteIDs);
2239 2238
2240 if (deleteGroups.Count > 0) 2239 if (takeDeleteGroups.Count > 0)
2241 { 2240 {
2242 foreach (SceneObjectGroup g in deleteGroups)
2243 deleteIDs.Remove(g.LocalId);
2244
2245 m_asyncSceneObjectDeleter.DeleteToInventory( 2241 m_asyncSceneObjectDeleter.DeleteToInventory(
2246 action, destinationID, deleteGroups, remoteClient, 2242 action, destinationID, takeDeleteGroups, remoteClient,
2247 true); 2243 true);
2248 } 2244 }
2249 if (takeGroups.Count > 0) 2245 if (takeGroups.Count > 0)
@@ -2252,7 +2248,7 @@ namespace OpenSim.Region.Framework.Scenes
2252 action, destinationID, takeGroups, remoteClient, 2248 action, destinationID, takeGroups, remoteClient,
2253 false); 2249 false);
2254 } 2250 }
2255 if (deleteIDs.Count > 0) 2251 if (deleteGroups.Count > 0)
2256 { 2252 {
2257 foreach (SceneObjectGroup g in deleteGroups) 2253 foreach (SceneObjectGroup g in deleteGroups)
2258 DeleteSceneObject(g, true); 2254 DeleteSceneObject(g, true);
@@ -2640,6 +2636,7 @@ namespace OpenSim.Region.Framework.Scenes
2640 2636
2641 // We can only call this after adding the scene object, since the scene object references the scene 2637 // We can only call this after adding the scene object, since the scene object references the scene
2642 // to find out if scripts should be activated at all. 2638 // to find out if scripts should be activated at all.
2639 group.AggregatePerms();
2643 group.CreateScriptInstances(param, true, DefaultScriptEngine, 3); 2640 group.CreateScriptInstances(param, true, DefaultScriptEngine, 3);
2644 2641
2645 group.ScheduleGroupForFullUpdate(); 2642 group.ScheduleGroupForFullUpdate();
@@ -2649,7 +2646,7 @@ namespace OpenSim.Region.Framework.Scenes
2649 } 2646 }
2650 2647
2651 public virtual bool returnObjects(SceneObjectGroup[] returnobjects, 2648 public virtual bool returnObjects(SceneObjectGroup[] returnobjects,
2652 UUID AgentId) 2649 IClientAPI client)
2653 { 2650 {
2654 List<uint> localIDs = new List<uint>(); 2651 List<uint> localIDs = new List<uint>();
2655 2652
@@ -2659,8 +2656,8 @@ namespace OpenSim.Region.Framework.Scenes
2659 "parcel owner return"); 2656 "parcel owner return");
2660 localIDs.Add(grp.RootPart.LocalId); 2657 localIDs.Add(grp.RootPart.LocalId);
2661 } 2658 }
2662 DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, 2659 DeRezObjects(client, localIDs, UUID.Zero, DeRezAction.Return,
2663 UUID.Zero); 2660 UUID.Zero, false);
2664 2661
2665 return true; 2662 return true;
2666 } 2663 }
@@ -2691,9 +2688,6 @@ namespace OpenSim.Region.Framework.Scenes
2691 { 2688 {
2692 if (ownerID != UUID.Zero) 2689 if (ownerID != UUID.Zero)
2693 return; 2690 return;
2694
2695 if (!Permissions.CanDeedObject(remoteClient.AgentId, groupID))
2696 return;
2697 } 2691 }
2698 2692
2699 List<SceneObjectGroup> groups = new List<SceneObjectGroup>(); 2693 List<SceneObjectGroup> groups = new List<SceneObjectGroup>();
@@ -2724,21 +2718,22 @@ namespace OpenSim.Region.Framework.Scenes
2724 child.TriggerScriptChangedEvent(Changed.OWNER); 2718 child.TriggerScriptChangedEvent(Changed.OWNER);
2725 } 2719 }
2726 } 2720 }
2727 else // The object was deeded to the group 2721 else // The object deeded to the group
2728 { 2722 {
2729 if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId) 2723 if (!Permissions.CanDeedObject(remoteClient, sog, groupID))
2730 continue; 2724 continue;
2731 2725
2732 if (!Permissions.CanTransferObject(sog.UUID, groupID)) 2726 sog.SetOwnerId(groupID);
2733 continue;
2734 2727
2735 if (sog.GroupID != groupID) 2728 // this is wrong, GroupMask is used for group sharing, still possible to set
2736 continue; 2729 // this whould give owner rights to users that are member of group but don't have role powers to edit
2730// sog.RootPart.GroupMask = sog.RootPart.OwnerMask;
2737 2731
2738 sog.SetOwnerId(groupID); 2732 // we should keep all permissions on deed to group
2739 // Make the group mask be the previous owner mask 2733 // and with this comented code, if user does not set next permissions on the object
2740 sog.RootPart.GroupMask = sog.RootPart.OwnerMask; 2734 // and on ALL contents of ALL prims, he may loose rights, making the object useless
2741 sog.ApplyNextOwnerPermissions(); 2735 sog.ApplyNextOwnerPermissions();
2736 sog.AggregatePerms();
2742 2737
2743 sog.ScheduleGroupForFullUpdate(); 2738 sog.ScheduleGroupForFullUpdate();
2744 2739
@@ -2748,8 +2743,6 @@ namespace OpenSim.Region.Framework.Scenes
2748 child.Inventory.ChangeInventoryOwner(groupID); 2743 child.Inventory.ChangeInventoryOwner(groupID);
2749 child.TriggerScriptChangedEvent(Changed.OWNER); 2744 child.TriggerScriptChangedEvent(Changed.OWNER);
2750 } 2745 }
2751
2752
2753 } 2746 }
2754 } 2747 }
2755 2748
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 2d62b50..4fef9c3 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -183,11 +183,12 @@ namespace OpenSim.Region.Framework.Scenes
183 part.SendFullUpdate(remoteClient); 183 part.SendFullUpdate(remoteClient);
184 184
185 // A prim is only tainted if it's allowed to be edited by the person clicking it. 185 // A prim is only tainted if it's allowed to be edited by the person clicking it.
186 if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) 186 if (Permissions.CanChangeSelectedState(part, (ScenePresence)remoteClient.SceneAgent))
187 || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId))
188 { 187 {
188 bool oldsel = part.IsSelected;
189 part.IsSelected = true; 189 part.IsSelected = true;
190 EventManager.TriggerParcelPrimCountTainted(); 190 if(!oldsel)
191 EventManager.TriggerParcelPrimCountTainted();
191 } 192 }
192 193
193 part.SendPropertiesToClient(remoteClient); 194 part.SendPropertiesToClient(remoteClient);
@@ -229,6 +230,7 @@ namespace OpenSim.Region.Framework.Scenes
229 if (so.OwnerID == remoteClient.AgentId) 230 if (so.OwnerID == remoteClient.AgentId)
230 { 231 {
231 so.SetGroup(groupID, remoteClient); 232 so.SetGroup(groupID, remoteClient);
233 EventManager.TriggerParcelPrimCountTainted();
232 } 234 }
233 } 235 }
234 } 236 }
@@ -250,8 +252,7 @@ namespace OpenSim.Region.Framework.Scenes
250 // handled by group, but by prim. Legacy cruft. 252 // handled by group, but by prim. Legacy cruft.
251 // TODO: Make selection flagging per prim! 253 // TODO: Make selection flagging per prim!
252 // 254 //
253 if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) 255 if (Permissions.CanChangeSelectedState(part, (ScenePresence)remoteClient.SceneAgent))
254 || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId))
255 { 256 {
256 part.IsSelected = false; 257 part.IsSelected = false;
257 if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) 258 if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected)
@@ -327,7 +328,7 @@ namespace OpenSim.Region.Framework.Scenes
327 if(group == null || group.IsDeleted) 328 if(group == null || group.IsDeleted)
328 return; 329 return;
329 330
330 if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.) 331 if (Permissions.CanMoveObject(group, remoteClient))// && PermissionsMngr.)
331 { 332 {
332 group.GrabMovement(objectID, offset, pos, remoteClient); 333 group.GrabMovement(objectID, offset, pos, remoteClient);
333 } 334 }
@@ -388,7 +389,7 @@ namespace OpenSim.Region.Framework.Scenes
388 SceneObjectGroup group = GetGroupByPrim(objectID); 389 SceneObjectGroup group = GetGroupByPrim(objectID);
389 if (group != null) 390 if (group != null)
390 { 391 {
391 if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.) 392 if (Permissions.CanMoveObject(group, remoteClient))// && PermissionsMngr.)
392 { 393 {
393 group.SpinStart(remoteClient); 394 group.SpinStart(remoteClient);
394 } 395 }
@@ -406,7 +407,7 @@ namespace OpenSim.Region.Framework.Scenes
406 SceneObjectGroup group = GetGroupByPrim(objectID); 407 SceneObjectGroup group = GetGroupByPrim(objectID);
407 if (group != null) 408 if (group != null)
408 { 409 {
409 if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.) 410 if (Permissions.CanMoveObject(group, remoteClient))// && PermissionsMngr.)
410 { 411 {
411 group.SpinMovement(rotation, remoteClient); 412 group.SpinMovement(rotation, remoteClient);
412 } 413 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
index 893b38c..c55a7a6 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
@@ -37,52 +37,60 @@ using OpenSim.Region.Framework.Interfaces;
37namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
38{ 38{
39 #region Delegates 39 #region Delegates
40 public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectID); 40 public delegate uint GenerateClientFlagsHandler(SceneObjectPart part, ScenePresence sp, uint curEffectivePerms);
41 public delegate void SetBypassPermissionsHandler(bool value); 41 public delegate void SetBypassPermissionsHandler(bool value);
42 public delegate bool BypassPermissionsHandler(); 42 public delegate bool BypassPermissionsHandler();
43 public delegate bool PropagatePermissionsHandler(); 43 public delegate bool PropagatePermissionsHandler();
44 public delegate bool RezObjectHandler(int objectCount, UUID owner, Vector3 objectPosition, Scene scene); 44 public delegate bool RezObjectHandler(int objectCount, UUID owner, Vector3 objectPosition);
45 public delegate bool DeleteObjectHandler(UUID objectID, UUID deleter, Scene scene); 45 public delegate bool DeleteObjectHandlerByIDs(UUID objectID, UUID deleter);
46 public delegate bool TransferObjectHandler(UUID objectID, UUID recipient, Scene scene); 46 public delegate bool DeleteObjectHandler(SceneObjectGroup sog, ScenePresence sp);
47 public delegate bool TakeObjectHandler(UUID objectID, UUID stealer, Scene scene); 47 public delegate bool TransferObjectHandler(UUID objectID, UUID recipient);
48 public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID, Scene scene); 48 public delegate bool TakeObjectHandler(SceneObjectGroup sog, ScenePresence sp);
49 public delegate bool TakeCopyObjectHandler(UUID objectID, UUID userID, Scene inScene); 49 public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID);
50 public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition); 50 public delegate bool SellObjectHandlerByUserID(SceneObjectGroup sog, UUID userID, byte saleType);
51 public delegate bool EditObjectHandler(UUID objectID, UUID editorID, Scene scene); 51 public delegate bool SellObjectHandler(SceneObjectGroup sog, ScenePresence sp, byte saleType);
52 public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); 52 public delegate bool TakeCopyObjectHandler(SceneObjectGroup sog, ScenePresence sp);
53 public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); 53 public delegate bool DuplicateObjectHandler(SceneObjectGroup sog, ScenePresence sp);
54 public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); 54 public delegate bool EditObjectByIDsHandler(UUID objectID, UUID editorID);
55 public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene); 55 public delegate bool EditObjectHandler(SceneObjectGroup sog, ScenePresence sp);
56 public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene); 56 public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID);
57 public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene); 57 public delegate bool MoveObjectHandler(SceneObjectGroup sog, ScenePresence sp);
58 public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); 58 public delegate bool ObjectEntryHandler(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint);
59 public delegate bool ViewNotecardHandler(UUID script, UUID objectID, UUID user, Scene scene); 59 public delegate bool ObjectEnterWithScriptsHandler(SceneObjectGroup sog, ILandObject land);
60 public delegate bool EditScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); 60 public delegate bool ReturnObjectsHandler(ILandObject land, ScenePresence sp, List<SceneObjectGroup> objects);
61 public delegate bool EditNotecardHandler(UUID notecard, UUID objectID, UUID user, Scene scene); 61 public delegate bool InstantMessageHandler(UUID user, UUID target);
62 public delegate bool RunScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); 62 public delegate bool InventoryTransferHandler(UUID user, UUID target);
63 public delegate bool CompileScriptHandler(UUID ownerUUID, int scriptType, Scene scene); 63 public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user);
64 public delegate bool StartScriptHandler(UUID script, UUID user, Scene scene); 64 public delegate bool ViewNotecardHandler(UUID script, UUID objectID, UUID user);
65 public delegate bool StopScriptHandler(UUID script, UUID user, Scene scene); 65 public delegate bool EditScriptHandler(UUID script, UUID objectID, UUID user);
66 public delegate bool ResetScriptHandler(UUID prim, UUID script, UUID user, Scene scene); 66 public delegate bool EditNotecardHandler(UUID notecard, UUID objectID, UUID user);
67 public delegate bool TerraformLandHandler(UUID user, Vector3 position, Scene requestFromScene); 67 public delegate bool RunScriptHandlerByIDs(UUID script, UUID objectID, UUID user);
68 public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); 68 public delegate bool RunScriptHandler(TaskInventoryItem item, SceneObjectPart part);
69 public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); 69 public delegate bool CompileScriptHandler(UUID ownerUUID, int scriptType);
70 public delegate bool IsGodHandler(UUID user, Scene requestFromScene); 70 public delegate bool StartScriptHandler(UUID script, UUID user);
71 public delegate bool IsGridGodHandler(UUID user, Scene requestFromScene); 71 public delegate bool StopScriptHandler(UUID script, UUID user);
72 public delegate bool ResetScriptHandler(UUID prim, UUID script, UUID user);
73 public delegate bool TerraformLandHandler(UUID user, Vector3 position);
74 public delegate bool RunConsoleCommandHandler(UUID user);
75 public delegate bool IssueEstateCommandHandler(UUID user, bool ownerCommand);
76 public delegate bool IsGodHandler(UUID user);
77 public delegate bool IsGridGodHandler(UUID user);
72 public delegate bool IsAdministratorHandler(UUID user); 78 public delegate bool IsAdministratorHandler(UUID user);
73 public delegate bool IsEstateManagerHandler(UUID user); 79 public delegate bool IsEstateManagerHandler(UUID user);
74 public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); 80 public delegate bool EditParcelHandler(UUID user, ILandObject parcel);
75 public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene, bool allowManager); 81 public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, bool allowManager);
76 public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); 82 public delegate bool SellParcelHandler(UUID user, ILandObject parcel);
77 public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); 83 public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel);
78 public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene); 84 public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel);
79 public delegate bool DeedParcelHandler(UUID user, ILandObject parcel, Scene scene); 85 public delegate bool DeedParcelHandler(UUID user, ILandObject parcel);
80 public delegate bool DeedObjectHandler(UUID user, UUID group, Scene scene); 86 public delegate bool DeedObjectHandler(ScenePresence sp, SceneObjectGroup sog, UUID targetGroupID);
81 public delegate bool BuyLandHandler(UUID user, ILandObject parcel, Scene scene); 87 public delegate bool BuyLandHandler(UUID user, ILandObject parcel);
82 public delegate bool LinkObjectHandler(UUID user, UUID objectID); 88 public delegate bool LinkObjectHandler(UUID user, UUID objectID);
83 public delegate bool DelinkObjectHandler(UUID user, UUID objectID); 89 public delegate bool DelinkObjectHandler(UUID user, UUID objectID);
84 public delegate bool CreateObjectInventoryHandler(int invType, UUID objectID, UUID userID); 90 public delegate bool CreateObjectInventoryHandler(int invType, UUID objectID, UUID userID);
85 public delegate bool CopyObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); 91 public delegate bool CopyObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
92 public delegate bool DoObjectInvToObjectInv(TaskInventoryItem item, SceneObjectPart sourcePart, SceneObjectPart destPart);
93 public delegate bool DoDropInObjectInv(InventoryItemBase item, ScenePresence sp, SceneObjectPart destPart);
86 public delegate bool DeleteObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); 94 public delegate bool DeleteObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
87 public delegate bool TransferObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); 95 public delegate bool TransferObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
88 public delegate bool CreateUserInventoryHandler(int invType, UUID userID); 96 public delegate bool CreateUserInventoryHandler(int invType, UUID userID);
@@ -112,16 +120,23 @@ namespace OpenSim.Region.Framework.Scenes
112 public event BypassPermissionsHandler OnBypassPermissions; 120 public event BypassPermissionsHandler OnBypassPermissions;
113 public event PropagatePermissionsHandler OnPropagatePermissions; 121 public event PropagatePermissionsHandler OnPropagatePermissions;
114 public event RezObjectHandler OnRezObject; 122 public event RezObjectHandler OnRezObject;
123 public event DeleteObjectHandlerByIDs OnDeleteObjectByIDs;
115 public event DeleteObjectHandler OnDeleteObject; 124 public event DeleteObjectHandler OnDeleteObject;
116 public event TransferObjectHandler OnTransferObject; 125 public event TransferObjectHandler OnTransferObject;
117 public event TakeObjectHandler OnTakeObject; 126 public event TakeObjectHandler OnTakeObject;
127
118 public event SellGroupObjectHandler OnSellGroupObject; 128 public event SellGroupObjectHandler OnSellGroupObject;
129 public event SellObjectHandlerByUserID OnSellObjectByUserID;
130 public event SellObjectHandler OnSellObject;
131
119 public event TakeCopyObjectHandler OnTakeCopyObject; 132 public event TakeCopyObjectHandler OnTakeCopyObject;
120 public event DuplicateObjectHandler OnDuplicateObject; 133 public event DuplicateObjectHandler OnDuplicateObject;
134 public event EditObjectByIDsHandler OnEditObjectByIDs;
121 public event EditObjectHandler OnEditObject; 135 public event EditObjectHandler OnEditObject;
122 public event EditObjectInventoryHandler OnEditObjectInventory; 136 public event EditObjectInventoryHandler OnEditObjectInventory;
123 public event MoveObjectHandler OnMoveObject; 137 public event MoveObjectHandler OnMoveObject;
124 public event ObjectEntryHandler OnObjectEntry; 138 public event ObjectEntryHandler OnObjectEntry;
139 public event ObjectEnterWithScriptsHandler OnObjectEnterWithScripts;
125 public event ReturnObjectsHandler OnReturnObjects; 140 public event ReturnObjectsHandler OnReturnObjects;
126 public event InstantMessageHandler OnInstantMessage; 141 public event InstantMessageHandler OnInstantMessage;
127 public event InventoryTransferHandler OnInventoryTransfer; 142 public event InventoryTransferHandler OnInventoryTransfer;
@@ -129,6 +144,7 @@ namespace OpenSim.Region.Framework.Scenes
129 public event ViewNotecardHandler OnViewNotecard; 144 public event ViewNotecardHandler OnViewNotecard;
130 public event EditScriptHandler OnEditScript; 145 public event EditScriptHandler OnEditScript;
131 public event EditNotecardHandler OnEditNotecard; 146 public event EditNotecardHandler OnEditNotecard;
147 public event RunScriptHandlerByIDs OnRunScriptByIDs;
132 public event RunScriptHandler OnRunScript; 148 public event RunScriptHandler OnRunScript;
133 public event CompileScriptHandler OnCompileScript; 149 public event CompileScriptHandler OnCompileScript;
134 public event StartScriptHandler OnStartScript; 150 public event StartScriptHandler OnStartScript;
@@ -137,7 +153,6 @@ namespace OpenSim.Region.Framework.Scenes
137 public event TerraformLandHandler OnTerraformLand; 153 public event TerraformLandHandler OnTerraformLand;
138 public event RunConsoleCommandHandler OnRunConsoleCommand; 154 public event RunConsoleCommandHandler OnRunConsoleCommand;
139 public event IssueEstateCommandHandler OnIssueEstateCommand; 155 public event IssueEstateCommandHandler OnIssueEstateCommand;
140 public event IsGodHandler OnIsGod;
141 public event IsGridGodHandler OnIsGridGod; 156 public event IsGridGodHandler OnIsGridGod;
142 public event IsAdministratorHandler OnIsAdministrator; 157 public event IsAdministratorHandler OnIsAdministrator;
143 public event IsEstateManagerHandler OnIsEstateManager; 158 public event IsEstateManagerHandler OnIsEstateManager;
@@ -153,6 +168,8 @@ namespace OpenSim.Region.Framework.Scenes
153 public event DelinkObjectHandler OnDelinkObject; 168 public event DelinkObjectHandler OnDelinkObject;
154 public event CreateObjectInventoryHandler OnCreateObjectInventory; 169 public event CreateObjectInventoryHandler OnCreateObjectInventory;
155 public event CopyObjectInventoryHandler OnCopyObjectInventory; 170 public event CopyObjectInventoryHandler OnCopyObjectInventory;
171 public event DoObjectInvToObjectInv OnDoObjectInvToObjectInv;
172 public event DoDropInObjectInv OnDropInObjectInv;
156 public event DeleteObjectInventoryHandler OnDeleteObjectInventory; 173 public event DeleteObjectInventoryHandler OnDeleteObjectInventory;
157 public event TransferObjectInventoryHandler OnTransferObjectInventory; 174 public event TransferObjectInventoryHandler OnTransferObjectInventory;
158 public event CreateUserInventoryHandler OnCreateUserInventory; 175 public event CreateUserInventoryHandler OnCreateUserInventory;
@@ -167,7 +184,7 @@ namespace OpenSim.Region.Framework.Scenes
167 184
168 #region Object Permission Checks 185 #region Object Permission Checks
169 186
170 public uint GenerateClientFlags(UUID userID, UUID objectID) 187 public uint GenerateClientFlags( SceneObjectPart part, ScenePresence sp)
171 { 188 {
172 // libomv will moan about PrimFlags.ObjectYouOfficer being 189 // libomv will moan about PrimFlags.ObjectYouOfficer being
173 // obsolete... 190 // obsolete...
@@ -179,12 +196,9 @@ namespace OpenSim.Region.Framework.Scenes
179 PrimFlags.ObjectTransfer | 196 PrimFlags.ObjectTransfer |
180 PrimFlags.ObjectYouOwner | 197 PrimFlags.ObjectYouOwner |
181 PrimFlags.ObjectAnyOwner | 198 PrimFlags.ObjectAnyOwner |
182 PrimFlags.ObjectOwnerModify | 199 PrimFlags.ObjectOwnerModify;
183 PrimFlags.ObjectYouOfficer;
184#pragma warning restore 0612 200#pragma warning restore 0612
185 201
186 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
187
188 if (part == null) 202 if (part == null)
189 return 0; 203 return 0;
190 204
@@ -196,7 +210,7 @@ namespace OpenSim.Region.Framework.Scenes
196 Delegate[] list = handlerGenerateClientFlags.GetInvocationList(); 210 Delegate[] list = handlerGenerateClientFlags.GetInvocationList();
197 foreach (GenerateClientFlagsHandler check in list) 211 foreach (GenerateClientFlagsHandler check in list)
198 { 212 {
199 perms &= check(userID, objectID); 213 perms &= check(part, sp, perms);
200 } 214 }
201 } 215 }
202 return perms; 216 return perms;
@@ -248,7 +262,7 @@ namespace OpenSim.Region.Framework.Scenes
248 Delegate[] list = handler.GetInvocationList(); 262 Delegate[] list = handler.GetInvocationList();
249 foreach (RezObjectHandler h in list) 263 foreach (RezObjectHandler h in list)
250 { 264 {
251 if (h(objectCount, owner,objectPosition, m_scene) == false) 265 if (h(objectCount, owner,objectPosition) == false)
252 return false; 266 return false;
253 } 267 }
254 } 268 }
@@ -262,141 +276,183 @@ namespace OpenSim.Region.Framework.Scenes
262 { 276 {
263 bool result = true; 277 bool result = true;
264 278
265 DeleteObjectHandler handler = OnDeleteObject; 279 DeleteObjectHandlerByIDs handler = OnDeleteObjectByIDs;
266 if (handler != null) 280 if (handler != null)
267 { 281 {
268 Delegate[] list = handler.GetInvocationList(); 282 Delegate[] list = handler.GetInvocationList();
269 foreach (DeleteObjectHandler h in list) 283 foreach (DeleteObjectHandlerByIDs h in list)
270 { 284 {
271 if (h(objectID, deleter, m_scene) == false) 285 if (h(objectID, deleter) == false)
272 { 286 {
273 result = false; 287 result = false;
274 break; 288 break;
275 } 289 }
276 } 290 }
277 } 291 }
278
279 return result; 292 return result;
280 } 293 }
281 294
282 public bool CanTransferObject(UUID objectID, UUID recipient) 295 public bool CanDeleteObject(SceneObjectGroup sog, IClientAPI client)
283 { 296 {
284 bool result = true; 297 DeleteObjectHandler handler = OnDeleteObject;
298 if (handler != null)
299 {
300 if(sog == null || client == null || client.SceneAgent == null)
301 return false;
302
303 ScenePresence sp = client.SceneAgent as ScenePresence;
304
305 Delegate[] list = handler.GetInvocationList();
306 foreach (DeleteObjectHandler h in list)
307 {
308 if (h(sog, sp) == false)
309 return false;
310 }
311 }
312
313 return true;
314 }
285 315
316 public bool CanTransferObject(UUID objectID, UUID recipient)
317 {
286 TransferObjectHandler handler = OnTransferObject; 318 TransferObjectHandler handler = OnTransferObject;
287 if (handler != null) 319 if (handler != null)
288 { 320 {
289 Delegate[] list = handler.GetInvocationList(); 321 Delegate[] list = handler.GetInvocationList();
290 foreach (TransferObjectHandler h in list) 322 foreach (TransferObjectHandler h in list)
291 { 323 {
292 if (h(objectID, recipient, m_scene) == false) 324 if (h(objectID, recipient) == false)
293 { 325 return false;
294 result = false;
295 break;
296 }
297 } 326 }
298 } 327 }
299 328 return true;
300 return result;
301 } 329 }
302 330
303 #endregion 331 #endregion
304 332
305 #region TAKE OBJECT 333 #region TAKE OBJECT
306 public bool CanTakeObject(UUID objectID, UUID AvatarTakingUUID) 334 public bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
307 { 335 {
308 bool result = true;
309
310 TakeObjectHandler handler = OnTakeObject; 336 TakeObjectHandler handler = OnTakeObject;
311 if (handler != null) 337 if (handler != null)
312 { 338 {
339 if(sog == null || sp == null)
340 return false;
341
313 Delegate[] list = handler.GetInvocationList(); 342 Delegate[] list = handler.GetInvocationList();
314 foreach (TakeObjectHandler h in list) 343 foreach (TakeObjectHandler h in list)
315 { 344 {
316 if (h(objectID, AvatarTakingUUID, m_scene) == false) 345 if (h(sog, sp) == false)
317 { 346 return false;
318 result = false;
319 break;
320 }
321 } 347 }
322 } 348 }
323
324// m_log.DebugFormat( 349// m_log.DebugFormat(
325// "[SCENE PERMISSIONS]: CanTakeObject() fired for object {0}, taker {1}, result {2}", 350// "[SCENE PERMISSIONS]: CanTakeObject() fired for object {0}, taker {1}, result {2}",
326// objectID, AvatarTakingUUID, result); 351// objectID, AvatarTakingUUID, result);
327 352 return true;
328 return result;
329 } 353 }
330 354
331 #endregion 355 #endregion
332 356
333 #region SELL GROUP OBJECT 357 #region SELL GROUP OBJECT
334 public bool CanSellGroupObject(UUID userID, UUID groupID, Scene scene) 358 public bool CanSellGroupObject(UUID userID, UUID groupID)
335 { 359 {
336 bool result = true;
337
338 SellGroupObjectHandler handler = OnSellGroupObject; 360 SellGroupObjectHandler handler = OnSellGroupObject;
339 if (handler != null) 361 if (handler != null)
340 { 362 {
341 Delegate[] list = handler.GetInvocationList(); 363 Delegate[] list = handler.GetInvocationList();
342 foreach (SellGroupObjectHandler h in list) 364 foreach (SellGroupObjectHandler h in list)
343 { 365 {
344 if (h(userID, groupID, scene) == false) 366 if (h(userID, groupID) == false)
345 { 367 return false;
346 result = false;
347 break;
348 }
349 } 368 }
350 } 369 }
351
352 //m_log.DebugFormat( 370 //m_log.DebugFormat(
353 // "[SCENE PERMISSIONS]: CanSellGroupObject() fired for user {0}, group {1}, result {2}", 371 // "[SCENE PERMISSIONS]: CanSellGroupObject() fired for user {0}, group {1}, result {2}",
354 // userID, groupID, result); 372 // userID, groupID, result);
373 return true;
374 }
355 375
356 return result; 376 #endregion
377
378 #region SELL OBJECT
379 public bool CanSellObject(IClientAPI client, SceneObjectGroup sog, byte saleType)
380 {
381 SellObjectHandler handler = OnSellObject;
382 if (handler != null)
383 {
384 if(sog == null || client == null || client.SceneAgent == null)
385 return false;
386
387 ScenePresence sp = client.SceneAgent as ScenePresence;
388 Delegate[] list = handler.GetInvocationList();
389 foreach (SellObjectHandler h in list)
390 {
391 if (h(sog, sp, saleType) == false)
392 return false;
393 }
394 }
395 return true;
396 }
397
398 public bool CanSellObject(UUID userID, SceneObjectGroup sog, byte saleType)
399 {
400 SellObjectHandlerByUserID handler = OnSellObjectByUserID;
401 if (handler != null)
402 {
403 if(sog == null)
404 return false;
405 Delegate[] list = handler.GetInvocationList();
406 foreach (SellObjectHandlerByUserID h in list)
407 {
408 if (h(sog, userID, saleType) == false)
409 return false;
410 }
411 }
412 return true;
357 } 413 }
358 414
359 #endregion 415 #endregion
360 416
361 417
362 #region TAKE COPY OBJECT 418 #region TAKE COPY OBJECT
363 public bool CanTakeCopyObject(UUID objectID, UUID userID) 419 public bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp)
364 { 420 {
365 bool result = true;
366
367 TakeCopyObjectHandler handler = OnTakeCopyObject; 421 TakeCopyObjectHandler handler = OnTakeCopyObject;
368 if (handler != null) 422 if (handler != null)
369 { 423 {
424 if(sog == null || sp == null)
425 return false;
370 Delegate[] list = handler.GetInvocationList(); 426 Delegate[] list = handler.GetInvocationList();
371 foreach (TakeCopyObjectHandler h in list) 427 foreach (TakeCopyObjectHandler h in list)
372 { 428 {
373 if (h(objectID, userID, m_scene) == false) 429 if (h(sog, sp) == false)
374 { 430 return false;
375 result = false;
376 break;
377 }
378 } 431 }
379 } 432 }
380
381// m_log.DebugFormat( 433// m_log.DebugFormat(
382// "[SCENE PERMISSIONS]: CanTakeCopyObject() fired for object {0}, user {1}, result {2}", 434// "[SCENE PERMISSIONS]: CanTakeCopyObject() fired for object {0}, user {1}, result {2}",
383// objectID, userID, result); 435// objectID, userID, result);
384 436 return true;
385 return result;
386 } 437 }
387 438
388 #endregion 439 #endregion
389 440
390 #region DUPLICATE OBJECT 441 #region DUPLICATE OBJECT
391 public bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Vector3 objectPosition) 442 public bool CanDuplicateObject(SceneObjectGroup sog, UUID agentID)
392 { 443 {
393 DuplicateObjectHandler handler = OnDuplicateObject; 444 DuplicateObjectHandler handler = OnDuplicateObject;
394 if (handler != null) 445 if (handler != null)
395 { 446 {
447 if(sog == null || sog.IsDeleted)
448 return false;
449 ScenePresence sp = m_scene.GetScenePresence(agentID);
450 if(sp == null || sp.IsDeleted)
451 return false;
396 Delegate[] list = handler.GetInvocationList(); 452 Delegate[] list = handler.GetInvocationList();
397 foreach (DuplicateObjectHandler h in list) 453 foreach (DuplicateObjectHandler h in list)
398 { 454 {
399 if (h(objectCount, objectID, owner, m_scene, objectPosition) == false) 455 if (h(sog, sp) == false)
400 return false; 456 return false;
401 } 457 }
402 } 458 }
@@ -405,16 +461,50 @@ namespace OpenSim.Region.Framework.Scenes
405 461
406 #endregion 462 #endregion
407 463
464 #region persence EDIT or MOVE OBJECT
465 private const uint CANSELECTMASK = (uint)(
466 PrimFlags.ObjectMove |
467 PrimFlags.ObjectModify |
468 PrimFlags.ObjectOwnerModify
469 );
470
471 public bool CanChangeSelectedState(SceneObjectPart part, ScenePresence sp)
472 {
473 uint perms = GenerateClientFlags(part, sp);
474 return (perms & CANSELECTMASK) != 0;
475 }
476
477 #endregion
408 #region EDIT OBJECT 478 #region EDIT OBJECT
409 public bool CanEditObject(UUID objectID, UUID editorID) 479 public bool CanEditObject(UUID objectID, UUID editorID)
410 { 480 {
481 EditObjectByIDsHandler handler = OnEditObjectByIDs;
482 if (handler != null)
483 {
484 Delegate[] list = handler.GetInvocationList();
485 foreach (EditObjectByIDsHandler h in list)
486 {
487 if (h(objectID, editorID) == false)
488 return false;
489 }
490 }
491 return true;
492 }
493
494 public bool CanEditObject(SceneObjectGroup sog, IClientAPI client)
495 {
411 EditObjectHandler handler = OnEditObject; 496 EditObjectHandler handler = OnEditObject;
412 if (handler != null) 497 if (handler != null)
413 { 498 {
499 if(sog == null || client == null || client.SceneAgent == null)
500 return false;
501
502 ScenePresence sp = client.SceneAgent as ScenePresence;
503
414 Delegate[] list = handler.GetInvocationList(); 504 Delegate[] list = handler.GetInvocationList();
415 foreach (EditObjectHandler h in list) 505 foreach (EditObjectHandler h in list)
416 { 506 {
417 if (h(objectID, editorID, m_scene) == false) 507 if (h(sog, sp) == false)
418 return false; 508 return false;
419 } 509 }
420 } 510 }
@@ -429,7 +519,7 @@ namespace OpenSim.Region.Framework.Scenes
429 Delegate[] list = handler.GetInvocationList(); 519 Delegate[] list = handler.GetInvocationList();
430 foreach (EditObjectInventoryHandler h in list) 520 foreach (EditObjectInventoryHandler h in list)
431 { 521 {
432 if (h(objectID, editorID, m_scene) == false) 522 if (h(objectID, editorID) == false)
433 return false; 523 return false;
434 } 524 }
435 } 525 }
@@ -439,15 +529,20 @@ namespace OpenSim.Region.Framework.Scenes
439 #endregion 529 #endregion
440 530
441 #region MOVE OBJECT 531 #region MOVE OBJECT
442 public bool CanMoveObject(UUID objectID, UUID moverID) 532 public bool CanMoveObject(SceneObjectGroup sog, IClientAPI client)
443 { 533 {
444 MoveObjectHandler handler = OnMoveObject; 534 MoveObjectHandler handler = OnMoveObject;
445 if (handler != null) 535 if (handler != null)
446 { 536 {
537 if(sog == null || client == null || client.SceneAgent == null)
538 return false;
539
540 ScenePresence sp = client.SceneAgent as ScenePresence;
541
447 Delegate[] list = handler.GetInvocationList(); 542 Delegate[] list = handler.GetInvocationList();
448 foreach (MoveObjectHandler h in list) 543 foreach (MoveObjectHandler h in list)
449 { 544 {
450 if (h(objectID, moverID, m_scene) == false) 545 if (h(sog, sp) == false)
451 return false; 546 return false;
452 } 547 }
453 } 548 }
@@ -457,7 +552,7 @@ namespace OpenSim.Region.Framework.Scenes
457 #endregion 552 #endregion
458 553
459 #region OBJECT ENTRY 554 #region OBJECT ENTRY
460 public bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint) 555 public bool CanObjectEntry(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint)
461 { 556 {
462 ObjectEntryHandler handler = OnObjectEntry; 557 ObjectEntryHandler handler = OnObjectEntry;
463 if (handler != null) 558 if (handler != null)
@@ -465,7 +560,22 @@ namespace OpenSim.Region.Framework.Scenes
465 Delegate[] list = handler.GetInvocationList(); 560 Delegate[] list = handler.GetInvocationList();
466 foreach (ObjectEntryHandler h in list) 561 foreach (ObjectEntryHandler h in list)
467 { 562 {
468 if (h(objectID, enteringRegion, newPoint, m_scene) == false) 563 if (h(sog, enteringRegion, newPoint) == false)
564 return false;
565 }
566 }
567 return true;
568 }
569
570 public bool CanObjectEnterWithScripts(SceneObjectGroup sog, ILandObject land)
571 {
572 ObjectEnterWithScriptsHandler handler = OnObjectEnterWithScripts;
573 if (handler != null)
574 {
575 Delegate[] list = handler.GetInvocationList();
576 foreach (ObjectEnterWithScriptsHandler h in list)
577 {
578 if (h(sog, land) == false)
469 return false; 579 return false;
470 } 580 }
471 } 581 }
@@ -475,29 +585,30 @@ namespace OpenSim.Region.Framework.Scenes
475 #endregion 585 #endregion
476 586
477 #region RETURN OBJECT 587 #region RETURN OBJECT
478 public bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects) 588 public bool CanReturnObjects(ILandObject land, IClientAPI client, List<SceneObjectGroup> objects)
479 { 589 {
480 bool result = true;
481
482 ReturnObjectsHandler handler = OnReturnObjects; 590 ReturnObjectsHandler handler = OnReturnObjects;
483 if (handler != null) 591 if (handler != null)
484 { 592 {
593 if(objects == null)
594 return false;
595
596 ScenePresence sp = null;
597 if(client != null && client.SceneAgent != null)
598 sp = client.SceneAgent as ScenePresence;
599
485 Delegate[] list = handler.GetInvocationList(); 600 Delegate[] list = handler.GetInvocationList();
486 foreach (ReturnObjectsHandler h in list) 601 foreach (ReturnObjectsHandler h in list)
487 { 602 {
488 if (h(land, user, objects, m_scene) == false) 603 if (h(land, sp, objects) == false)
489 { 604 return false;
490 result = false;
491 break;
492 }
493 } 605 }
494 } 606 }
495
496// m_log.DebugFormat( 607// m_log.DebugFormat(
497// "[SCENE PERMISSIONS]: CanReturnObjects() fired for user {0} for {1} objects on {2}, result {3}", 608// "[SCENE PERMISSIONS]: CanReturnObjects() fired for user {0} for {1} objects on {2}, result {3}",
498// user, objects.Count, land.LandData.Name, result); 609// user, objects.Count, land.LandData.Name, result);
499 610
500 return result; 611 return true;
501 } 612 }
502 613
503 #endregion 614 #endregion
@@ -511,7 +622,7 @@ namespace OpenSim.Region.Framework.Scenes
511 Delegate[] list = handler.GetInvocationList(); 622 Delegate[] list = handler.GetInvocationList();
512 foreach (InstantMessageHandler h in list) 623 foreach (InstantMessageHandler h in list)
513 { 624 {
514 if (h(user, target, m_scene) == false) 625 if (h(user, target) == false)
515 return false; 626 return false;
516 } 627 }
517 } 628 }
@@ -529,7 +640,7 @@ namespace OpenSim.Region.Framework.Scenes
529 Delegate[] list = handler.GetInvocationList(); 640 Delegate[] list = handler.GetInvocationList();
530 foreach (InventoryTransferHandler h in list) 641 foreach (InventoryTransferHandler h in list)
531 { 642 {
532 if (h(user, target, m_scene) == false) 643 if (h(user, target) == false)
533 return false; 644 return false;
534 } 645 }
535 } 646 }
@@ -547,7 +658,7 @@ namespace OpenSim.Region.Framework.Scenes
547 Delegate[] list = handler.GetInvocationList(); 658 Delegate[] list = handler.GetInvocationList();
548 foreach (ViewScriptHandler h in list) 659 foreach (ViewScriptHandler h in list)
549 { 660 {
550 if (h(script, objectID, user, m_scene) == false) 661 if (h(script, objectID, user) == false)
551 return false; 662 return false;
552 } 663 }
553 } 664 }
@@ -562,7 +673,7 @@ namespace OpenSim.Region.Framework.Scenes
562 Delegate[] list = handler.GetInvocationList(); 673 Delegate[] list = handler.GetInvocationList();
563 foreach (ViewNotecardHandler h in list) 674 foreach (ViewNotecardHandler h in list)
564 { 675 {
565 if (h(script, objectID, user, m_scene) == false) 676 if (h(script, objectID, user) == false)
566 return false; 677 return false;
567 } 678 }
568 } 679 }
@@ -580,7 +691,7 @@ namespace OpenSim.Region.Framework.Scenes
580 Delegate[] list = handler.GetInvocationList(); 691 Delegate[] list = handler.GetInvocationList();
581 foreach (EditScriptHandler h in list) 692 foreach (EditScriptHandler h in list)
582 { 693 {
583 if (h(script, objectID, user, m_scene) == false) 694 if (h(script, objectID, user) == false)
584 return false; 695 return false;
585 } 696 }
586 } 697 }
@@ -595,7 +706,7 @@ namespace OpenSim.Region.Framework.Scenes
595 Delegate[] list = handler.GetInvocationList(); 706 Delegate[] list = handler.GetInvocationList();
596 foreach (EditNotecardHandler h in list) 707 foreach (EditNotecardHandler h in list)
597 { 708 {
598 if (h(script, objectID, user, m_scene) == false) 709 if (h(script, objectID, user) == false)
599 return false; 710 return false;
600 } 711 }
601 } 712 }
@@ -607,19 +718,37 @@ namespace OpenSim.Region.Framework.Scenes
607 #region RUN SCRIPT (When Script Placed in Object) 718 #region RUN SCRIPT (When Script Placed in Object)
608 public bool CanRunScript(UUID script, UUID objectID, UUID user) 719 public bool CanRunScript(UUID script, UUID objectID, UUID user)
609 { 720 {
721 RunScriptHandlerByIDs handler = OnRunScriptByIDs;
722 if (handler != null)
723 {
724 Delegate[] list = handler.GetInvocationList();
725 foreach (RunScriptHandlerByIDs h in list)
726 {
727 if (h(script, objectID, user) == false)
728 return false;
729 }
730 }
731 return true;
732 }
733
734 public bool CanRunScript(TaskInventoryItem item, SceneObjectPart part)
735 {
610 RunScriptHandler handler = OnRunScript; 736 RunScriptHandler handler = OnRunScript;
611 if (handler != null) 737 if (handler != null)
612 { 738 {
739 if(item == null || part == null)
740 return false;
613 Delegate[] list = handler.GetInvocationList(); 741 Delegate[] list = handler.GetInvocationList();
614 foreach (RunScriptHandler h in list) 742 foreach (RunScriptHandler h in list)
615 { 743 {
616 if (h(script, objectID, user, m_scene) == false) 744 if (h(item, part) == false)
617 return false; 745 return false;
618 } 746 }
619 } 747 }
620 return true; 748 return true;
621 } 749 }
622 750
751
623 #endregion 752 #endregion
624 753
625 #region COMPILE SCRIPT (When Script needs to get (re)compiled) 754 #region COMPILE SCRIPT (When Script needs to get (re)compiled)
@@ -631,7 +760,7 @@ namespace OpenSim.Region.Framework.Scenes
631 Delegate[] list = handler.GetInvocationList(); 760 Delegate[] list = handler.GetInvocationList();
632 foreach (CompileScriptHandler h in list) 761 foreach (CompileScriptHandler h in list)
633 { 762 {
634 if (h(ownerUUID, scriptType, m_scene) == false) 763 if (h(ownerUUID, scriptType) == false)
635 return false; 764 return false;
636 } 765 }
637 } 766 }
@@ -649,7 +778,7 @@ namespace OpenSim.Region.Framework.Scenes
649 Delegate[] list = handler.GetInvocationList(); 778 Delegate[] list = handler.GetInvocationList();
650 foreach (StartScriptHandler h in list) 779 foreach (StartScriptHandler h in list)
651 { 780 {
652 if (h(script, user, m_scene) == false) 781 if (h(script, user) == false)
653 return false; 782 return false;
654 } 783 }
655 } 784 }
@@ -667,7 +796,7 @@ namespace OpenSim.Region.Framework.Scenes
667 Delegate[] list = handler.GetInvocationList(); 796 Delegate[] list = handler.GetInvocationList();
668 foreach (StopScriptHandler h in list) 797 foreach (StopScriptHandler h in list)
669 { 798 {
670 if (h(script, user, m_scene) == false) 799 if (h(script, user) == false)
671 return false; 800 return false;
672 } 801 }
673 } 802 }
@@ -685,7 +814,7 @@ namespace OpenSim.Region.Framework.Scenes
685 Delegate[] list = handler.GetInvocationList(); 814 Delegate[] list = handler.GetInvocationList();
686 foreach (ResetScriptHandler h in list) 815 foreach (ResetScriptHandler h in list)
687 { 816 {
688 if (h(prim, script, user, m_scene) == false) 817 if (h(prim, script, user) == false)
689 return false; 818 return false;
690 } 819 }
691 } 820 }
@@ -703,7 +832,7 @@ namespace OpenSim.Region.Framework.Scenes
703 Delegate[] list = handler.GetInvocationList(); 832 Delegate[] list = handler.GetInvocationList();
704 foreach (TerraformLandHandler h in list) 833 foreach (TerraformLandHandler h in list)
705 { 834 {
706 if (h(user, pos, m_scene) == false) 835 if (h(user, pos) == false)
707 return false; 836 return false;
708 } 837 }
709 } 838 }
@@ -721,7 +850,7 @@ namespace OpenSim.Region.Framework.Scenes
721 Delegate[] list = handler.GetInvocationList(); 850 Delegate[] list = handler.GetInvocationList();
722 foreach (RunConsoleCommandHandler h in list) 851 foreach (RunConsoleCommandHandler h in list)
723 { 852 {
724 if (h(user, m_scene) == false) 853 if (h(user) == false)
725 return false; 854 return false;
726 } 855 }
727 } 856 }
@@ -739,7 +868,7 @@ namespace OpenSim.Region.Framework.Scenes
739 Delegate[] list = handler.GetInvocationList(); 868 Delegate[] list = handler.GetInvocationList();
740 foreach (IssueEstateCommandHandler h in list) 869 foreach (IssueEstateCommandHandler h in list)
741 { 870 {
742 if (h(user, m_scene, ownerCommand) == false) 871 if (h(user, ownerCommand) == false)
743 return false; 872 return false;
744 } 873 }
745 } 874 }
@@ -750,13 +879,13 @@ namespace OpenSim.Region.Framework.Scenes
750 #region CAN BE GODLIKE 879 #region CAN BE GODLIKE
751 public bool IsGod(UUID user) 880 public bool IsGod(UUID user)
752 { 881 {
753 IsGodHandler handler = OnIsGod; 882 IsAdministratorHandler handler = OnIsAdministrator;
754 if (handler != null) 883 if (handler != null)
755 { 884 {
756 Delegate[] list = handler.GetInvocationList(); 885 Delegate[] list = handler.GetInvocationList();
757 foreach (IsGodHandler h in list) 886 foreach (IsAdministratorHandler h in list)
758 { 887 {
759 if (h(user, m_scene) == false) 888 if (h(user) == false)
760 return false; 889 return false;
761 } 890 }
762 } 891 }
@@ -771,7 +900,7 @@ namespace OpenSim.Region.Framework.Scenes
771 Delegate[] list = handler.GetInvocationList(); 900 Delegate[] list = handler.GetInvocationList();
772 foreach (IsGridGodHandler h in list) 901 foreach (IsGridGodHandler h in list)
773 { 902 {
774 if (h(user, m_scene) == false) 903 if (h(user) == false)
775 return false; 904 return false;
776 } 905 }
777 } 906 }
@@ -819,7 +948,7 @@ namespace OpenSim.Region.Framework.Scenes
819 Delegate[] list = handler.GetInvocationList(); 948 Delegate[] list = handler.GetInvocationList();
820 foreach (EditParcelPropertiesHandler h in list) 949 foreach (EditParcelPropertiesHandler h in list)
821 { 950 {
822 if (h(user, parcel, p, m_scene, allowManager) == false) 951 if (h(user, parcel, p, allowManager) == false)
823 return false; 952 return false;
824 } 953 }
825 } 954 }
@@ -836,7 +965,7 @@ namespace OpenSim.Region.Framework.Scenes
836 Delegate[] list = handler.GetInvocationList(); 965 Delegate[] list = handler.GetInvocationList();
837 foreach (SellParcelHandler h in list) 966 foreach (SellParcelHandler h in list)
838 { 967 {
839 if (h(user, parcel, m_scene) == false) 968 if (h(user, parcel) == false)
840 return false; 969 return false;
841 } 970 }
842 } 971 }
@@ -853,7 +982,7 @@ namespace OpenSim.Region.Framework.Scenes
853 Delegate[] list = handler.GetInvocationList(); 982 Delegate[] list = handler.GetInvocationList();
854 foreach (AbandonParcelHandler h in list) 983 foreach (AbandonParcelHandler h in list)
855 { 984 {
856 if (h(user, parcel, m_scene) == false) 985 if (h(user, parcel) == false)
857 return false; 986 return false;
858 } 987 }
859 } 988 }
@@ -869,7 +998,7 @@ namespace OpenSim.Region.Framework.Scenes
869 Delegate[] list = handler.GetInvocationList(); 998 Delegate[] list = handler.GetInvocationList();
870 foreach (ReclaimParcelHandler h in list) 999 foreach (ReclaimParcelHandler h in list)
871 { 1000 {
872 if (h(user, parcel, m_scene) == false) 1001 if (h(user, parcel) == false)
873 return false; 1002 return false;
874 } 1003 }
875 } 1004 }
@@ -884,22 +1013,27 @@ namespace OpenSim.Region.Framework.Scenes
884 Delegate[] list = handler.GetInvocationList(); 1013 Delegate[] list = handler.GetInvocationList();
885 foreach (DeedParcelHandler h in list) 1014 foreach (DeedParcelHandler h in list)
886 { 1015 {
887 if (h(user, parcel, m_scene) == false) 1016 if (h(user, parcel) == false)
888 return false; 1017 return false;
889 } 1018 }
890 } 1019 }
891 return true; 1020 return true;
892 } 1021 }
893 1022
894 public bool CanDeedObject(UUID user, UUID group) 1023 public bool CanDeedObject(IClientAPI client, SceneObjectGroup sog, UUID targetGroupID)
895 { 1024 {
896 DeedObjectHandler handler = OnDeedObject; 1025 DeedObjectHandler handler = OnDeedObject;
897 if (handler != null) 1026 if (handler != null)
898 { 1027 {
1028 if(sog == null || client == null || client.SceneAgent == null || targetGroupID == UUID.Zero)
1029 return false;
1030
1031 ScenePresence sp = client.SceneAgent as ScenePresence;
1032
899 Delegate[] list = handler.GetInvocationList(); 1033 Delegate[] list = handler.GetInvocationList();
900 foreach (DeedObjectHandler h in list) 1034 foreach (DeedObjectHandler h in list)
901 { 1035 {
902 if (h(user, group, m_scene) == false) 1036 if (h(sp, sog, targetGroupID) == false)
903 return false; 1037 return false;
904 } 1038 }
905 } 1039 }
@@ -914,7 +1048,7 @@ namespace OpenSim.Region.Framework.Scenes
914 Delegate[] list = handler.GetInvocationList(); 1048 Delegate[] list = handler.GetInvocationList();
915 foreach (BuyLandHandler h in list) 1049 foreach (BuyLandHandler h in list)
916 { 1050 {
917 if (h(user, parcel, m_scene) == false) 1051 if (h(user, parcel) == false)
918 return false; 1052 return false;
919 } 1053 }
920 } 1054 }
@@ -990,6 +1124,45 @@ namespace OpenSim.Region.Framework.Scenes
990 return true; 1124 return true;
991 } 1125 }
992 1126
1127 public bool CanDoObjectInvToObjectInv(TaskInventoryItem item, SceneObjectPart sourcePart, SceneObjectPart destPart)
1128 {
1129 DoObjectInvToObjectInv handler = OnDoObjectInvToObjectInv;
1130 if (handler != null)
1131 {
1132 if (sourcePart == null || destPart == null || item == null)
1133 return false;
1134 Delegate[] list = handler.GetInvocationList();
1135 foreach (DoObjectInvToObjectInv h in list)
1136 {
1137 if (h(item, sourcePart, destPart) == false)
1138 return false;
1139 }
1140 }
1141 return true;
1142 }
1143
1144 public bool CanDropInObjectInv(InventoryItemBase item, IClientAPI client, SceneObjectPart destPart)
1145 {
1146 DoDropInObjectInv handler = OnDropInObjectInv;
1147 if (handler != null)
1148 {
1149 if (client == null || client.SceneAgent == null|| destPart == null || item == null)
1150 return false;
1151
1152 ScenePresence sp = client.SceneAgent as ScenePresence;
1153 if(sp == null || sp.IsDeleted)
1154 return false;
1155
1156 Delegate[] list = handler.GetInvocationList();
1157 foreach (DoDropInObjectInv h in list)
1158 {
1159 if (h(item, sp, destPart) == false)
1160 return false;
1161 }
1162 }
1163 return true;
1164 }
1165
993 public bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID) 1166 public bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID)
994 { 1167 {
995 DeleteObjectInventoryHandler handler = OnDeleteObjectInventory; 1168 DeleteObjectInventoryHandler handler = OnDeleteObjectInventory;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2137b42..715ae5c 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -540,6 +540,9 @@ namespace OpenSim.Region.Framework.Scenes
540 private Timer m_mapGenerationTimer = new Timer(); 540 private Timer m_mapGenerationTimer = new Timer();
541 private bool m_generateMaptiles; 541 private bool m_generateMaptiles;
542 542
543 protected int m_lastHealth = -1;
544 protected int m_lastUsers = -1;
545
543 #endregion Fields 546 #endregion Fields
544 547
545 #region Properties 548 #region Properties
@@ -805,6 +808,8 @@ namespace OpenSim.Region.Framework.Scenes
805 private float m_minReprioritizationDistance = 32f; 808 private float m_minReprioritizationDistance = 32f;
806 public bool ObjectsCullingByDistance = false; 809 public bool ObjectsCullingByDistance = false;
807 810
811 private ExpiringCache<UUID, UUID> TeleportTargetsCoolDown = new ExpiringCache<UUID, UUID>();
812
808 public AgentCircuitManager AuthenticateHandler 813 public AgentCircuitManager AuthenticateHandler
809 { 814 {
810 get { return m_authenticateHandler; } 815 get { return m_authenticateHandler; }
@@ -1212,6 +1217,30 @@ namespace OpenSim.Region.Framework.Scenes
1212 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 1217 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
1213 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 1218 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
1214 1219
1220 IConfig restartConfig = config.Configs["RestartModule"];
1221 if (restartConfig != null)
1222 {
1223 string markerPath = restartConfig.GetString("MarkerPath", String.Empty);
1224
1225 if (markerPath != String.Empty)
1226 {
1227 string path = Path.Combine(markerPath, RegionInfo.RegionID.ToString() + ".started");
1228 try
1229 {
1230 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
1231 FileStream fs = File.Create(path);
1232 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
1233 Byte[] buf = enc.GetBytes(pidstring);
1234 fs.Write(buf, 0, buf.Length);
1235 fs.Close();
1236 }
1237 catch (Exception)
1238 {
1239 }
1240 }
1241 }
1242
1243 StartTimerWatchdog();
1215 } 1244 }
1216 1245
1217 public Scene(RegionInfo regInfo) 1246 public Scene(RegionInfo regInfo)
@@ -1482,6 +1511,14 @@ namespace OpenSim.Region.Framework.Scenes
1482 return; 1511 return;
1483 } 1512 }
1484 1513
1514 IEtcdModule etcd = RequestModuleInterface<IEtcdModule>();
1515 if (etcd != null)
1516 {
1517 etcd.Delete("Health");
1518 etcd.Delete("HealthFlags");
1519 etcd.Delete("RootAgents");
1520 }
1521
1485 m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName); 1522 m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName);
1486 1523
1487 1524
@@ -1520,6 +1557,8 @@ namespace OpenSim.Region.Framework.Scenes
1520 m_log.Debug("[SCENE]: Persisting changed objects"); 1557 m_log.Debug("[SCENE]: Persisting changed objects");
1521 Backup(true); 1558 Backup(true);
1522 1559
1560 m_log.Debug("[SCENE]: Closing scene");
1561
1523 m_sceneGraph.Close(); 1562 m_sceneGraph.Close();
1524 1563
1525 base.Close(); 1564 base.Close();
@@ -2351,6 +2390,7 @@ namespace OpenSim.Region.Framework.Scenes
2351 EventManager.TriggerOnSceneObjectLoaded(group); 2390 EventManager.TriggerOnSceneObjectLoaded(group);
2352 SceneObjectPart rootPart = group.GetPart(group.UUID); 2391 SceneObjectPart rootPart = group.GetPart(group.UUID);
2353 rootPart.Flags &= ~PrimFlags.Scripted; 2392 rootPart.Flags &= ~PrimFlags.Scripted;
2393 group.AggregateDeepPerms();
2354 rootPart.TrimPermissions(); 2394 rootPart.TrimPermissions();
2355 2395
2356 // Don't do this here - it will get done later on when sculpt data is loaded. 2396 // Don't do this here - it will get done later on when sculpt data is loaded.
@@ -2603,8 +2643,8 @@ namespace OpenSim.Region.Framework.Scenes
2603 { 2643 {
2604 // Otherwise, use this default creation code; 2644 // Otherwise, use this default creation code;
2605 sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); 2645 sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
2606 AddNewSceneObject(sceneObject, true);
2607 sceneObject.SetGroup(groupID, null); 2646 sceneObject.SetGroup(groupID, null);
2647 AddNewSceneObject(sceneObject, true);
2608 2648
2609 if (AgentPreferencesService != null) // This will override the brave new full perm world! 2649 if (AgentPreferencesService != null) // This will override the brave new full perm world!
2610 { 2650 {
@@ -2622,6 +2662,7 @@ namespace OpenSim.Region.Framework.Scenes
2622 if (UserManagementModule != null) 2662 if (UserManagementModule != null)
2623 sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID); 2663 sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID);
2624 2664
2665 sceneObject.AggregateDeepPerms();
2625 sceneObject.ScheduleGroupForFullUpdate(); 2666 sceneObject.ScheduleGroupForFullUpdate();
2626 2667
2627 return sceneObject; 2668 return sceneObject;
@@ -2768,7 +2809,7 @@ namespace OpenSim.Region.Framework.Scenes
2768 SceneObjectGroup sog = (SceneObjectGroup)e; 2809 SceneObjectGroup sog = (SceneObjectGroup)e;
2769 if (sog != null && !sog.IsAttachment) 2810 if (sog != null && !sog.IsAttachment)
2770 { 2811 {
2771 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) 2812 if (!exceptNoCopy || ((sog.EffectiveOwnerPerms & (uint)PermissionMask.Copy) != 0))
2772 { 2813 {
2773 DeleteSceneObject((SceneObjectGroup)e, false); 2814 DeleteSceneObject((SceneObjectGroup)e, false);
2774 } 2815 }
@@ -2782,7 +2823,7 @@ namespace OpenSim.Region.Framework.Scenes
2782 } 2823 }
2783 if (toReturn.Count > 0) 2824 if (toReturn.Count > 0)
2784 { 2825 {
2785 returnObjects(toReturn.ToArray(), UUID.Zero); 2826 returnObjects(toReturn.ToArray(), null);
2786 } 2827 }
2787 } 2828 }
2788 2829
@@ -2944,15 +2985,15 @@ namespace OpenSim.Region.Framework.Scenes
2944 // Return 'true' if position inside region. 2985 // Return 'true' if position inside region.
2945 public bool PositionIsInCurrentRegion(Vector3 pos) 2986 public bool PositionIsInCurrentRegion(Vector3 pos)
2946 { 2987 {
2947 bool ret = false; 2988 float t = pos.X;
2948 int xx = (int)Math.Floor(pos.X); 2989 if (t < 0 || t >= RegionInfo.RegionSizeX)
2949 int yy = (int)Math.Floor(pos.Y);
2950 if (xx < 0 || yy < 0)
2951 return false; 2990 return false;
2952 2991
2953 if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY ) 2992 t = pos.Y;
2954 ret = true; 2993 if (t < 0 || t >= RegionInfo.RegionSizeY)
2955 return ret; 2994 return false;
2995
2996 return true;
2956 } 2997 }
2957 2998
2958 /// <summary> 2999 /// <summary>
@@ -3603,7 +3644,9 @@ namespace OpenSim.Region.Framework.Scenes
3603 /// <param name="GroupID">Group of new object</param> 3644 /// <param name="GroupID">Group of new object</param>
3604 public void DuplicateObject(uint originalPrim, Vector3 offset, uint flags, UUID AgentID, UUID GroupID) 3645 public void DuplicateObject(uint originalPrim, Vector3 offset, uint flags, UUID AgentID, UUID GroupID)
3605 { 3646 {
3606 SceneObjectGroup copy = SceneGraph.DuplicateObject(originalPrim, offset, flags, AgentID, GroupID, Quaternion.Identity); 3647 bool createSelected = (flags & (uint)PrimFlags.CreateSelected) != 0;
3648 SceneObjectGroup copy = SceneGraph.DuplicateObject(originalPrim, offset, AgentID,
3649 GroupID, Quaternion.Identity, createSelected);
3607 if (copy != null) 3650 if (copy != null)
3608 EventManager.TriggerObjectAddedToScene(copy); 3651 EventManager.TriggerObjectAddedToScene(copy);
3609 } 3652 }
@@ -3633,6 +3676,8 @@ namespace OpenSim.Region.Framework.Scenes
3633 SceneObjectPart target = GetSceneObjectPart(localID); 3676 SceneObjectPart target = GetSceneObjectPart(localID);
3634 SceneObjectPart target2 = GetSceneObjectPart(RayTargetObj); 3677 SceneObjectPart target2 = GetSceneObjectPart(RayTargetObj);
3635 3678
3679 bool createSelected = (dupeFlags & (uint)PrimFlags.CreateSelected) != 0;
3680
3636 if (target != null && target2 != null) 3681 if (target != null && target2 != null)
3637 { 3682 {
3638 Vector3 direction = Vector3.Normalize(RayEnd - RayStart); 3683 Vector3 direction = Vector3.Normalize(RayEnd - RayStart);
@@ -3674,13 +3719,13 @@ namespace OpenSim.Region.Framework.Scenes
3674 Quaternion worldRot = target2.GetWorldRotation(); 3719 Quaternion worldRot = target2.GetWorldRotation();
3675 3720
3676 // SceneObjectGroup obj = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot); 3721 // SceneObjectGroup obj = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot);
3677 copy = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot); 3722 copy = m_sceneGraph.DuplicateObject(localID, pos, AgentID, GroupID, worldRot, createSelected);
3678 //obj.Rotation = worldRot; 3723 //obj.Rotation = worldRot;
3679 //obj.UpdateGroupRotationR(worldRot); 3724 //obj.UpdateGroupRotationR(worldRot);
3680 } 3725 }
3681 else 3726 else
3682 { 3727 {
3683 copy = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, Quaternion.Identity); 3728 copy = m_sceneGraph.DuplicateObject(localID, pos, AgentID, GroupID, Quaternion.Identity, createSelected);
3684 } 3729 }
3685 3730
3686 if (copy != null) 3731 if (copy != null)
@@ -3983,7 +4028,7 @@ namespace OpenSim.Region.Framework.Scenes
3983 4028
3984 if (!LoginsEnabled) 4029 if (!LoginsEnabled)
3985 { 4030 {
3986 reason = "Logins Disabled"; 4031 reason = "Logins to this region are disabled";
3987 return false; 4032 return false;
3988 } 4033 }
3989 4034
@@ -5077,65 +5122,59 @@ Label_GroupsDone:
5077 #endregion 5122 #endregion
5078 5123
5079 #region Script Engine 5124 #region Script Engine
5080 5125 public bool LSLScriptDanger(SceneObjectPart part, Vector3 pos)
5081 private bool ScriptDanger(SceneObjectPart part, Vector3 pos)
5082 { 5126 {
5127
5083 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); 5128 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
5084 if (part != null) 5129 if (parcel == null)
5085 { 5130 return true;
5086 if (parcel != null) 5131
5087 { 5132 LandData ldata = parcel.LandData;
5088 if ((parcel.LandData.Flags & (uint)ParcelFlags.AllowOtherScripts) != 0) 5133 if (ldata == null)
5089 { 5134 return true;
5090 return true; 5135
5091 } 5136 uint landflags = ldata.Flags;
5092 else if ((part.OwnerID == parcel.LandData.OwnerID) || Permissions.IsGod(part.OwnerID)) 5137
5093 { 5138 uint mask = (uint)(ParcelFlags.CreateObjects | ParcelFlags.AllowAPrimitiveEntry);
5094 return true; 5139 if((landflags & mask) != mask)
5095 } 5140 return true;
5096 else if (((parcel.LandData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0) 5141
5097 && (parcel.LandData.GroupID != UUID.Zero) && (parcel.LandData.GroupID == part.GroupID)) 5142 if((landflags & (uint)ParcelFlags.AllowOtherScripts) != 0)
5098 { 5143 return false;
5099 return true;
5100 }
5101 else
5102 {
5103 return false;
5104 }
5105 }
5106 else
5107 {
5108 5144
5109 if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY) 5145 if(part == null)
5110 { 5146 return true;
5111 // The only time parcel != null when an object is inside a region is when 5147 if(part.GroupID == ldata.GroupID && (landflags & (uint)ParcelFlags.AllowGroupScripts) != 0)
5112 // there is nothing behind the landchannel. IE, no land plugin loaded.
5113 return true;
5114 }
5115 else
5116 {
5117 // The object is outside of this region. Stop piping events to it.
5118 return false;
5119 }
5120 }
5121 }
5122 else
5123 {
5124 return false; 5148 return false;
5125 } 5149
5150 return true;
5126 } 5151 }
5127 5152
5128 public bool ScriptDanger(uint localID, Vector3 pos) 5153 private bool ScriptDanger(SceneObjectPart part, Vector3 pos)
5129 { 5154 {
5130 SceneObjectPart part = GetSceneObjectPart(localID); 5155 if (part == null)
5131 if (part != null) 5156 return false;
5157
5158 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
5159 if (parcel != null)
5132 { 5160 {
5133 return ScriptDanger(part, pos); 5161 if ((parcel.LandData.Flags & (uint)ParcelFlags.AllowOtherScripts) != 0)
5162 return true;
5163
5164 if ((part.OwnerID == parcel.LandData.OwnerID) || Permissions.IsGod(part.OwnerID))
5165 return true;
5166
5167 if (((parcel.LandData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0)
5168 && (parcel.LandData.GroupID != UUID.Zero) && (parcel.LandData.GroupID == part.GroupID))
5169 return true;
5134 } 5170 }
5135 else 5171 else
5136 { 5172 {
5137 return false; 5173 if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY)
5174 return true;
5138 } 5175 }
5176
5177 return false;
5139 } 5178 }
5140 5179
5141 public bool PipeEventsForScript(uint localID) 5180 public bool PipeEventsForScript(uint localID)
@@ -5512,23 +5551,24 @@ Label_GroupsDone:
5512 return 0; 5551 return 0;
5513 } 5552 }
5514 5553
5515 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5554 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 2000)
5516 { 5555 {
5517 health+=1; 5556 health+=1;
5518 flags |= 1; 5557 flags |= 1;
5519 } 5558 }
5520 5559
5521 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) 5560 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 2000)
5522 { 5561 {
5523 health+=1; 5562 health+=1;
5524 flags |= 2; 5563 flags |= 2;
5525 } 5564 }
5526 5565
5527 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) 5566 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 2000)
5528 { 5567 {
5529 health+=1; 5568 health+=1;
5530 flags |= 4; 5569 flags |= 4;
5531 } 5570 }
5571 /*
5532 else 5572 else
5533 { 5573 {
5534int pid = System.Diagnostics.Process.GetCurrentProcess().Id; 5574int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
@@ -5541,6 +5581,7 @@ proc.WaitForExit();
5541Thread.Sleep(1000); 5581Thread.Sleep(1000);
5542Environment.Exit(1); 5582Environment.Exit(1);
5543 } 5583 }
5584 */
5544 5585
5545 if (flags != 7) 5586 if (flags != 7)
5546 return health; 5587 return health;
@@ -6305,6 +6346,32 @@ Environment.Exit(1);
6305 public void TimerWatchdog(object sender, ElapsedEventArgs e) 6346 public void TimerWatchdog(object sender, ElapsedEventArgs e)
6306 { 6347 {
6307 CheckHeartbeat(); 6348 CheckHeartbeat();
6349
6350 IEtcdModule etcd = RequestModuleInterface<IEtcdModule>();
6351 int flags;
6352 string message;
6353 if (etcd != null)
6354 {
6355 int health = GetHealth(out flags, out message);
6356 if (health != m_lastHealth)
6357 {
6358 m_lastHealth = health;
6359
6360 etcd.Store("Health", health.ToString(), 300000);
6361 etcd.Store("HealthFlags", flags.ToString(), 300000);
6362 }
6363
6364 int roots = 0;
6365 foreach (ScenePresence sp in GetScenePresences())
6366 if (!sp.IsChildAgent && !sp.IsNPC)
6367 roots++;
6368
6369 if (m_lastUsers != roots)
6370 {
6371 m_lastUsers = roots;
6372 etcd.Store("RootAgents", roots.ToString(), 300000);
6373 }
6374 }
6308 } 6375 }
6309 6376
6310 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 6377 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
@@ -6461,5 +6528,21 @@ Environment.Exit(1);
6461 6528
6462 m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty); 6529 m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty);
6463 } 6530 }
6531
6532 public bool InTeleportTargetsCoolDown(UUID sourceID, UUID targetID, double timeout)
6533 {
6534 lock(TeleportTargetsCoolDown)
6535 {
6536 UUID lastSource = UUID.Zero;
6537 TeleportTargetsCoolDown.TryGetValue(targetID, out lastSource);
6538 if(lastSource == UUID.Zero)
6539 {
6540 TeleportTargetsCoolDown.Add(targetID, sourceID, timeout);
6541 return false;
6542 }
6543 TeleportTargetsCoolDown.AddOrUpdate(targetID, sourceID, timeout);
6544 return lastSource == sourceID;
6545 }
6546 }
6464 } 6547 }
6465} 6548}
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 2f65ce2..a005068 100755
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -343,7 +343,7 @@ namespace OpenSim.Region.Framework.Scenes
343 sceneObject.ForceInventoryPersistence(); 343 sceneObject.ForceInventoryPersistence();
344 sceneObject.HasGroupChanged = true; 344 sceneObject.HasGroupChanged = true;
345 } 345 }
346 346 sceneObject.AggregateDeepPerms();
347 return ret; 347 return ret;
348 } 348 }
349 349
@@ -549,6 +549,8 @@ namespace OpenSim.Region.Framework.Scenes
549 // that are part of the Scene Object being removed 549 // that are part of the Scene Object being removed
550 m_numTotalPrim -= grp.PrimCount; 550 m_numTotalPrim -= grp.PrimCount;
551 551
552 bool isPh = (grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics;
553 int nphysparts = 0;
552 // Go through all parts (primitives and meshes) of this Scene Object 554 // Go through all parts (primitives and meshes) of this Scene Object
553 foreach (SceneObjectPart part in grp.Parts) 555 foreach (SceneObjectPart part in grp.Parts)
554 { 556 {
@@ -559,10 +561,13 @@ namespace OpenSim.Region.Framework.Scenes
559 m_numMesh--; 561 m_numMesh--;
560 else 562 else
561 m_numPrim--; 563 m_numPrim--;
564
565 if(isPh && part.PhysicsShapeType != (byte)PhysShapeType.none)
566 nphysparts++;
562 } 567 }
563 568
564 if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) 569 if (nphysparts > 0 )
565 RemovePhysicalPrim(grp.PrimCount); 570 RemovePhysicalPrim(nphysparts);
566 } 571 }
567 572
568 bool ret = Entities.Remove(uuid); 573 bool ret = Entities.Remove(uuid);
@@ -1358,7 +1363,7 @@ namespace OpenSim.Region.Framework.Scenes
1358 SceneObjectGroup grp = part.ParentGroup; 1363 SceneObjectGroup grp = part.ParentGroup;
1359 if (grp != null) 1364 if (grp != null)
1360 { 1365 {
1361 if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) 1366 if (m_parentScene.Permissions.CanEditObject(grp, remoteClient))
1362 { 1367 {
1363 // These two are exceptions SL makes in the interpretation 1368 // These two are exceptions SL makes in the interpretation
1364 // of the change flags. Must check them here because otherwise 1369 // of the change flags. Must check them here because otherwise
@@ -1379,7 +1384,7 @@ namespace OpenSim.Region.Framework.Scenes
1379 if ((data.change & (ObjectChangeType.Position | ObjectChangeType.Rotation)) != 0) 1384 if ((data.change & (ObjectChangeType.Position | ObjectChangeType.Rotation)) != 0)
1380 { 1385 {
1381 // Are we allowed to move it? 1386 // Are we allowed to move it?
1382 if (m_parentScene.Permissions.CanMoveObject(grp.UUID, remoteClient.AgentId)) 1387 if (m_parentScene.Permissions.CanMoveObject(grp, remoteClient))
1383 { 1388 {
1384 // Strip all but move and rotation from request 1389 // Strip all but move and rotation from request
1385 data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation); 1390 data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation);
@@ -1406,7 +1411,7 @@ namespace OpenSim.Region.Framework.Scenes
1406 1411
1407 if (part != null) 1412 if (part != null)
1408 { 1413 {
1409 if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) 1414 if (m_parentScene.Permissions.CanEditObject(part.ParentGroup, remoteClient))
1410 { 1415 {
1411 bool physbuild = false; 1416 bool physbuild = false;
1412 if (part.ParentGroup.RootPart.PhysActor != null) 1417 if (part.ParentGroup.RootPart.PhysActor != null)
@@ -1428,7 +1433,7 @@ namespace OpenSim.Region.Framework.Scenes
1428 SceneObjectGroup group = GetGroupByPrim(localID); 1433 SceneObjectGroup group = GetGroupByPrim(localID);
1429 if (group != null) 1434 if (group != null)
1430 { 1435 {
1431 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1436 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1432 { 1437 {
1433 bool physbuild = false; 1438 bool physbuild = false;
1434 if (group.RootPart.PhysActor != null) 1439 if (group.RootPart.PhysActor != null)
@@ -1474,7 +1479,7 @@ namespace OpenSim.Region.Framework.Scenes
1474 SceneObjectGroup group = GetGroupByPrim(localID); 1479 SceneObjectGroup group = GetGroupByPrim(localID);
1475 if (group != null) 1480 if (group != null)
1476 { 1481 {
1477 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) 1482 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
1478 { 1483 {
1479 group.UpdateSingleRotation(rot, localID); 1484 group.UpdateSingleRotation(rot, localID);
1480 } 1485 }
@@ -1492,7 +1497,7 @@ namespace OpenSim.Region.Framework.Scenes
1492 SceneObjectGroup group = GetGroupByPrim(localID); 1497 SceneObjectGroup group = GetGroupByPrim(localID);
1493 if (group != null) 1498 if (group != null)
1494 { 1499 {
1495 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) 1500 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
1496 { 1501 {
1497 group.UpdateSingleRotation(rot, pos, localID); 1502 group.UpdateSingleRotation(rot, pos, localID);
1498 } 1503 }
@@ -1510,7 +1515,7 @@ namespace OpenSim.Region.Framework.Scenes
1510 SceneObjectGroup group = GetGroupByPrim(localID); 1515 SceneObjectGroup group = GetGroupByPrim(localID);
1511 if (group != null) 1516 if (group != null)
1512 { 1517 {
1513 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) 1518 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
1514 { 1519 {
1515 group.UpdateGroupRotationR(rot); 1520 group.UpdateGroupRotationR(rot);
1516 } 1521 }
@@ -1529,7 +1534,7 @@ namespace OpenSim.Region.Framework.Scenes
1529 SceneObjectGroup group = GetGroupByPrim(localID); 1534 SceneObjectGroup group = GetGroupByPrim(localID);
1530 if (group != null) 1535 if (group != null)
1531 { 1536 {
1532 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) 1537 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
1533 { 1538 {
1534 group.UpdateGroupRotationPR(pos, rot); 1539 group.UpdateGroupRotationPR(pos, rot);
1535 } 1540 }
@@ -1547,7 +1552,7 @@ namespace OpenSim.Region.Framework.Scenes
1547 SceneObjectGroup group = GetGroupByPrim(localID); 1552 SceneObjectGroup group = GetGroupByPrim(localID);
1548 if (group != null) 1553 if (group != null)
1549 { 1554 {
1550 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId) || group.IsAttachment) 1555 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient) || group.IsAttachment)
1551 { 1556 {
1552 group.UpdateSinglePosition(pos, localID); 1557 group.UpdateSinglePosition(pos, localID);
1553 } 1558 }
@@ -1562,17 +1567,6 @@ namespace OpenSim.Region.Framework.Scenes
1562 /// <param name="remoteClient"></param> 1567 /// <param name="remoteClient"></param>
1563 public void UpdatePrimGroupPosition(uint localId, Vector3 pos, IClientAPI remoteClient) 1568 public void UpdatePrimGroupPosition(uint localId, Vector3 pos, IClientAPI remoteClient)
1564 { 1569 {
1565 UpdatePrimGroupPosition(localId, pos, remoteClient.AgentId);
1566 }
1567
1568 /// <summary>
1569 /// Update the position of the given group.
1570 /// </summary>
1571 /// <param name="localId"></param>
1572 /// <param name="pos"></param>
1573 /// <param name="updatingAgentId"></param>
1574 public void UpdatePrimGroupPosition(uint localId, Vector3 pos, UUID updatingAgentId)
1575 {
1576 SceneObjectGroup group = GetGroupByPrim(localId); 1570 SceneObjectGroup group = GetGroupByPrim(localId);
1577 1571
1578 if (group != null) 1572 if (group != null)
@@ -1580,7 +1574,7 @@ namespace OpenSim.Region.Framework.Scenes
1580 if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) 1574 if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0))
1581 { 1575 {
1582 // Set the new attachment point data in the object 1576 // Set the new attachment point data in the object
1583 byte attachmentPoint = group.GetAttachmentPoint(); 1577 byte attachmentPoint = (byte)group.AttachmentPoint;
1584 group.UpdateGroupPosition(pos); 1578 group.UpdateGroupPosition(pos);
1585 group.IsAttachment = false; 1579 group.IsAttachment = false;
1586 group.AbsolutePosition = group.RootPart.AttachedPos; 1580 group.AbsolutePosition = group.RootPart.AttachedPos;
@@ -1589,8 +1583,8 @@ namespace OpenSim.Region.Framework.Scenes
1589 } 1583 }
1590 else 1584 else
1591 { 1585 {
1592 if (m_parentScene.Permissions.CanMoveObject(group.UUID, updatingAgentId) 1586 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient)
1593 && m_parentScene.Permissions.CanObjectEntry(group.UUID, false, pos)) 1587 && m_parentScene.Permissions.CanObjectEntry(group, false, pos))
1594 { 1588 {
1595 group.UpdateGroupPosition(pos); 1589 group.UpdateGroupPosition(pos);
1596 } 1590 }
@@ -1614,7 +1608,7 @@ namespace OpenSim.Region.Framework.Scenes
1614 1608
1615 if (group != null) 1609 if (group != null)
1616 { 1610 {
1617 if (m_parentScene.Permissions.CanEditObject(group.UUID,remoteClient.AgentId)) 1611 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1618 { 1612 {
1619 group.UpdateTextureEntry(localID, texture); 1613 group.UpdateTextureEntry(localID, texture);
1620 } 1614 }
@@ -1638,7 +1632,7 @@ namespace OpenSim.Region.Framework.Scenes
1638 SceneObjectGroup group = GetGroupByPrim(localID); 1632 SceneObjectGroup group = GetGroupByPrim(localID);
1639 if (group != null) 1633 if (group != null)
1640 { 1634 {
1641 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1635 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1642 { 1636 {
1643 // VolumeDetect can't be set via UI and will always be off when a change is made there 1637 // VolumeDetect can't be set via UI and will always be off when a change is made there
1644 // now only change volume dtc if phantom off 1638 // now only change volume dtc if phantom off
@@ -1685,7 +1679,7 @@ namespace OpenSim.Region.Framework.Scenes
1685 SceneObjectGroup group = GetGroupByPrim(primLocalID); 1679 SceneObjectGroup group = GetGroupByPrim(primLocalID);
1686 if (group != null) 1680 if (group != null)
1687 { 1681 {
1688 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1682 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1689 { 1683 {
1690 group.SetPartName(Util.CleanString(name), primLocalID); 1684 group.SetPartName(Util.CleanString(name), primLocalID);
1691 group.HasGroupChanged = true; 1685 group.HasGroupChanged = true;
@@ -1703,7 +1697,7 @@ namespace OpenSim.Region.Framework.Scenes
1703 SceneObjectGroup group = GetGroupByPrim(primLocalID); 1697 SceneObjectGroup group = GetGroupByPrim(primLocalID);
1704 if (group != null) 1698 if (group != null)
1705 { 1699 {
1706 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1700 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1707 { 1701 {
1708 group.SetPartDescription(Util.CleanString(description), primLocalID); 1702 group.SetPartDescription(Util.CleanString(description), primLocalID);
1709 group.HasGroupChanged = true; 1703 group.HasGroupChanged = true;
@@ -1725,7 +1719,7 @@ namespace OpenSim.Region.Framework.Scenes
1725 SceneObjectGroup group = GetGroupByPrim(primLocalID); 1719 SceneObjectGroup group = GetGroupByPrim(primLocalID);
1726 if (group != null) 1720 if (group != null)
1727 { 1721 {
1728 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1722 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1729 { 1723 {
1730 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); 1724 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID);
1731 if (part != null) 1725 if (part != null)
@@ -1742,7 +1736,7 @@ namespace OpenSim.Region.Framework.Scenes
1742 SceneObjectGroup group = GetGroupByPrim(primLocalID); 1736 SceneObjectGroup group = GetGroupByPrim(primLocalID);
1743 if (group != null) 1737 if (group != null)
1744 { 1738 {
1745 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1739 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1746 { 1740 {
1747 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); 1741 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID);
1748 if (part != null) 1742 if (part != null)
@@ -1996,6 +1990,7 @@ namespace OpenSim.Region.Framework.Scenes
1996 { 1990 {
1997 newRoot.TriggerScriptChangedEvent(Changed.LINK); 1991 newRoot.TriggerScriptChangedEvent(Changed.LINK);
1998 newRoot.ParentGroup.HasGroupChanged = true; 1992 newRoot.ParentGroup.HasGroupChanged = true;
1993 newRoot.ParentGroup.InvalidatePartsLinkMaps();
1999 newRoot.ParentGroup.ScheduleGroupForFullUpdate(); 1994 newRoot.ParentGroup.ScheduleGroupForFullUpdate();
2000 } 1995 }
2001 } 1996 }
@@ -2012,6 +2007,7 @@ namespace OpenSim.Region.Framework.Scenes
2012 // from the database. They will be rewritten immediately, 2007 // from the database. They will be rewritten immediately,
2013 // minus the rows for the unlinked child prims. 2008 // minus the rows for the unlinked child prims.
2014 m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); 2009 m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID);
2010 g.InvalidatePartsLinkMaps();
2015 g.TriggerScriptChangedEvent(Changed.LINK); 2011 g.TriggerScriptChangedEvent(Changed.LINK);
2016 g.HasGroupChanged = true; // Persist 2012 g.HasGroupChanged = true; // Persist
2017 g.ScheduleGroupForFullUpdate(); 2013 g.ScheduleGroupForFullUpdate();
@@ -2025,27 +2021,9 @@ namespace OpenSim.Region.Framework.Scenes
2025 2021
2026 protected internal void MakeObjectSearchable(IClientAPI remoteClient, bool IncludeInSearch, uint localID) 2022 protected internal void MakeObjectSearchable(IClientAPI remoteClient, bool IncludeInSearch, uint localID)
2027 { 2023 {
2028 UUID user = remoteClient.AgentId; 2024 SceneObjectGroup sog = GetGroupByPrim(localID);
2029 UUID objid = UUID.Zero; 2025 if(sog == null)
2030 SceneObjectPart obj = null; 2026 return;
2031
2032 EntityBase[] entityList = GetEntities();
2033 foreach (EntityBase ent in entityList)
2034 {
2035 if (ent is SceneObjectGroup)
2036 {
2037 SceneObjectGroup sog = ent as SceneObjectGroup;
2038
2039 foreach (SceneObjectPart part in sog.Parts)
2040 {
2041 if (part.LocalId == localID)
2042 {
2043 objid = part.UUID;
2044 obj = part;
2045 }
2046 }
2047 }
2048 }
2049 2027
2050 //Protip: In my day, we didn't call them searchable objects, we called them limited point-to-point joints 2028 //Protip: In my day, we didn't call them searchable objects, we called them limited point-to-point joints
2051 //aka ObjectFlags.JointWheel = IncludeInSearch 2029 //aka ObjectFlags.JointWheel = IncludeInSearch
@@ -2062,15 +2040,15 @@ namespace OpenSim.Region.Framework.Scenes
2062 // libomv will complain about PrimFlags.JointWheel being 2040 // libomv will complain about PrimFlags.JointWheel being
2063 // deprecated, so we 2041 // deprecated, so we
2064 #pragma warning disable 0612 2042 #pragma warning disable 0612
2065 if (IncludeInSearch && m_parentScene.Permissions.CanEditObject(objid, user)) 2043 if (IncludeInSearch && m_parentScene.Permissions.CanEditObject(sog, remoteClient))
2066 { 2044 {
2067 obj.ParentGroup.RootPart.AddFlag(PrimFlags.JointWheel); 2045 sog.RootPart.AddFlag(PrimFlags.JointWheel);
2068 obj.ParentGroup.HasGroupChanged = true; 2046 sog.HasGroupChanged = true;
2069 } 2047 }
2070 else if (!IncludeInSearch && m_parentScene.Permissions.CanMoveObject(objid,user)) 2048 else if (!IncludeInSearch && m_parentScene.Permissions.CanMoveObject(sog, remoteClient))
2071 { 2049 {
2072 obj.ParentGroup.RootPart.RemFlag(PrimFlags.JointWheel); 2050 sog.RootPart.RemFlag(PrimFlags.JointWheel);
2073 obj.ParentGroup.HasGroupChanged = true; 2051 sog.HasGroupChanged = true;
2074 } 2052 }
2075 #pragma warning restore 0612 2053 #pragma warning restore 0612
2076 } 2054 }
@@ -2086,7 +2064,7 @@ namespace OpenSim.Region.Framework.Scenes
2086 /// <param name="rot"></param> 2064 /// <param name="rot"></param>
2087 /// <returns>null if duplication fails, otherwise the duplicated object</returns> 2065 /// <returns>null if duplication fails, otherwise the duplicated object</returns>
2088 /// <summary> 2066 /// <summary>
2089 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) 2067 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, UUID AgentID, UUID GroupID, Quaternion rot, bool createSelected)
2090 { 2068 {
2091// m_log.DebugFormat( 2069// m_log.DebugFormat(
2092// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", 2070// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}",
@@ -2095,27 +2073,28 @@ namespace OpenSim.Region.Framework.Scenes
2095 SceneObjectGroup original = GetGroupByPrim(originalPrimID); 2073 SceneObjectGroup original = GetGroupByPrim(originalPrimID);
2096 if (original != null) 2074 if (original != null)
2097 { 2075 {
2098 if (m_parentScene.Permissions.CanDuplicateObject( 2076 if (m_parentScene.Permissions.CanDuplicateObject(original, AgentID))
2099 original.PrimCount, original.UUID, AgentID, original.AbsolutePosition))
2100 { 2077 {
2101 SceneObjectGroup copy = original.Copy(true); 2078 SceneObjectGroup copy = original.Copy(true);
2102 copy.AbsolutePosition = copy.AbsolutePosition + offset; 2079 copy.AbsolutePosition = copy.AbsolutePosition + offset;
2103 2080
2081 SceneObjectPart[] parts = copy.Parts;
2082
2083 m_numTotalPrim += parts.Length;
2084
2104 if (original.OwnerID != AgentID) 2085 if (original.OwnerID != AgentID)
2105 { 2086 {
2106 copy.SetOwnerId(AgentID); 2087 copy.SetOwner(AgentID, GroupID);
2107 copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID);
2108
2109 SceneObjectPart[] partList = copy.Parts;
2110 2088
2111 if (m_parentScene.Permissions.PropagatePermissions()) 2089 if (m_parentScene.Permissions.PropagatePermissions())
2112 { 2090 {
2113 foreach (SceneObjectPart child in partList) 2091 foreach (SceneObjectPart child in parts)
2114 { 2092 {
2115 child.Inventory.ChangeInventoryOwner(AgentID); 2093 child.Inventory.ChangeInventoryOwner(AgentID);
2116 child.TriggerScriptChangedEvent(Changed.OWNER); 2094 child.TriggerScriptChangedEvent(Changed.OWNER);
2117 child.ApplyNextOwnerPermissions(); 2095 child.ApplyNextOwnerPermissions();
2118 } 2096 }
2097 copy.AggregatePerms();
2119 } 2098 }
2120 } 2099 }
2121 2100
@@ -2125,10 +2104,6 @@ namespace OpenSim.Region.Framework.Scenes
2125 lock (SceneObjectGroupsByFullID) 2104 lock (SceneObjectGroupsByFullID)
2126 SceneObjectGroupsByFullID[copy.UUID] = copy; 2105 SceneObjectGroupsByFullID[copy.UUID] = copy;
2127 2106
2128 SceneObjectPart[] parts = copy.Parts;
2129
2130 m_numTotalPrim += parts.Length;
2131
2132 foreach (SceneObjectPart part in parts) 2107 foreach (SceneObjectPart part in parts)
2133 { 2108 {
2134 if (part.GetPrimType() == PrimType.SCULPT) 2109 if (part.GetPrimType() == PrimType.SCULPT)
@@ -2144,28 +2119,19 @@ namespace OpenSim.Region.Framework.Scenes
2144 2119
2145 // PROBABLE END OF FIXME 2120 // PROBABLE END OF FIXME
2146 2121
2147 // Since we copy from a source group that is in selected 2122 copy.IsSelected = createSelected;
2148 // state, but the copy is shown deselected in the viewer,
2149 // We need to clear the selection flag here, else that
2150 // prim never gets persisted at all. The client doesn't
2151 // think it's selected, so it will never send a deselect...
2152 copy.IsSelected = false;
2153
2154 m_numPrim += copy.Parts.Length;
2155 2123
2156 if (rot != Quaternion.Identity) 2124 if (rot != Quaternion.Identity)
2157 {
2158 copy.UpdateGroupRotationR(rot); 2125 copy.UpdateGroupRotationR(rot);
2159 } 2126
2127 // required for physics to update it's position
2128 copy.ResetChildPrimPhysicsPositions();
2160 2129
2161 copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); 2130 copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1);
2162 copy.HasGroupChanged = true;
2163 copy.ScheduleGroupForFullUpdate();
2164 copy.ResumeScripts(); 2131 copy.ResumeScripts();
2165 2132
2166 // required for physics to update it's position 2133 copy.HasGroupChanged = true;
2167 copy.AbsolutePosition = copy.AbsolutePosition; 2134 copy.ScheduleGroupForFullUpdate();
2168
2169 return copy; 2135 return copy;
2170 } 2136 }
2171 } 2137 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 9f98554..12e53a8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -111,7 +111,7 @@ namespace OpenSim.Region.Framework.Scenes
111 /// <param name="item">The user inventory item being added.</param> 111 /// <param name="item">The user inventory item being added.</param>
112 /// <param name="copyItemID">The item UUID that should be used by the new item.</param> 112 /// <param name="copyItemID">The item UUID that should be used by the new item.</param>
113 /// <returns></returns> 113 /// <returns></returns>
114 public bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID) 114 public bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID, bool withModRights = true)
115 { 115 {
116// m_log.DebugFormat( 116// m_log.DebugFormat(
117// "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}", 117// "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}",
@@ -120,69 +120,72 @@ namespace OpenSim.Region.Framework.Scenes
120 UUID newItemId = (copyItemID != UUID.Zero) ? copyItemID : item.ID; 120 UUID newItemId = (copyItemID != UUID.Zero) ? copyItemID : item.ID;
121 121
122 SceneObjectPart part = GetPart(localID); 122 SceneObjectPart part = GetPart(localID);
123 if (part != null) 123 if (part == null)
124 { 124 {
125 TaskInventoryItem taskItem = new TaskInventoryItem(); 125 m_log.ErrorFormat(
126 126 "[PRIM INVENTORY]: " +
127 taskItem.ItemID = newItemId; 127 "Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}",
128 taskItem.AssetID = item.AssetID; 128 localID, Name, UUID, newItemId);
129 taskItem.Name = item.Name; 129 return false;
130 taskItem.Description = item.Description; 130 }
131 taskItem.OwnerID = part.OwnerID; // Transfer ownership 131
132 taskItem.CreatorID = item.CreatorIdAsUuid; 132 TaskInventoryItem taskItem = new TaskInventoryItem();
133 taskItem.Type = item.AssetType;
134 taskItem.InvType = item.InvType;
135
136 if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions())
137 {
138 taskItem.BasePermissions = item.BasePermissions &
139 item.NextPermissions;
140 taskItem.CurrentPermissions = item.CurrentPermissions &
141 item.NextPermissions;
142 taskItem.EveryonePermissions = item.EveryOnePermissions &
143 item.NextPermissions;
144 taskItem.GroupPermissions = item.GroupPermissions &
145 item.NextPermissions;
146 taskItem.NextPermissions = item.NextPermissions;
147 // We're adding this to a prim we don't own. Force
148 // owner change
149 taskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
150 }
151 else
152 {
153 taskItem.BasePermissions = item.BasePermissions;
154 taskItem.CurrentPermissions = item.CurrentPermissions;
155 taskItem.EveryonePermissions = item.EveryOnePermissions;
156 taskItem.GroupPermissions = item.GroupPermissions;
157 taskItem.NextPermissions = item.NextPermissions;
158 }
159 133
160 taskItem.Flags = item.Flags; 134 taskItem.ItemID = newItemId;
135 taskItem.AssetID = item.AssetID;
136 taskItem.Name = item.Name;
137 taskItem.Description = item.Description;
138 taskItem.OwnerID = part.OwnerID; // Transfer ownership
139 taskItem.CreatorID = item.CreatorIdAsUuid;
140 taskItem.Type = item.AssetType;
141 taskItem.InvType = item.InvType;
142
143 if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions())
144 {
145 taskItem.BasePermissions = item.BasePermissions &
146 item.NextPermissions;
147 taskItem.CurrentPermissions = item.CurrentPermissions &
148 item.NextPermissions;
149 taskItem.EveryonePermissions = item.EveryOnePermissions &
150 item.NextPermissions;
151 taskItem.GroupPermissions = item.GroupPermissions &
152 item.NextPermissions;
153 taskItem.NextPermissions = item.NextPermissions;
154 // We're adding this to a prim we don't own. Force
155 // owner change
156 taskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
157
158 }
159 else
160 {
161 taskItem.BasePermissions = item.BasePermissions;
162 taskItem.CurrentPermissions = item.CurrentPermissions;
163 taskItem.EveryonePermissions = item.EveryOnePermissions;
164 taskItem.GroupPermissions = item.GroupPermissions;
165 taskItem.NextPermissions = item.NextPermissions;
166 }
167
168 taskItem.Flags = item.Flags;
161 169
162// m_log.DebugFormat( 170// m_log.DebugFormat(
163// "[PRIM INVENTORY]: Flags are 0x{0:X} for item {1} added to part {2} by {3}", 171// "[PRIM INVENTORY]: Flags are 0x{0:X} for item {1} added to part {2} by {3}",
164// taskItem.Flags, taskItem.Name, localID, remoteClient.Name); 172// taskItem.Flags, taskItem.Name, localID, remoteClient.Name);
165 173
166 // TODO: These are pending addition of those fields to TaskInventoryItem 174 // TODO: These are pending addition of those fields to TaskInventoryItem
167// taskItem.SalePrice = item.SalePrice; 175// taskItem.SalePrice = item.SalePrice;
168// taskItem.SaleType = item.SaleType; 176// taskItem.SaleType = item.SaleType;
169 taskItem.CreationDate = (uint)item.CreationDate; 177 taskItem.CreationDate = (uint)item.CreationDate;
170 178
171 bool addFromAllowedDrop = agentID != part.OwnerID; 179 bool addFromAllowedDrop;
172 180 if(withModRights)
173 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); 181 addFromAllowedDrop = false;
174
175 return true;
176 }
177 else 182 else
178 { 183 addFromAllowedDrop = (part.ParentGroup.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0;
179 m_log.ErrorFormat( 184
180 "[PRIM INVENTORY]: " + 185 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop);
181 "Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}", 186 part.ParentGroup.AggregatePerms();
182 localID, Name, UUID, newItemId); 187 return true;
183 }
184 188
185 return false;
186 } 189 }
187 190
188 /// <summary> 191 /// <summary>
@@ -248,6 +251,194 @@ namespace OpenSim.Region.Framework.Scenes
248 return -1; 251 return -1;
249 } 252 }
250 253
254 // new test code, to place in better place later
255 private object PermissionsLock = new object();
256
257 private uint m_EffectiveEveryOnePerms;
258 public uint EffectiveEveryOnePerms
259 {
260 get
261 {
262 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
263 // bc this is on heavy duty code paths
264 // but for now we need to test the concept
265// AggregateDeepPerms();
266 return m_EffectiveEveryOnePerms;
267 }
268 }
269
270 private uint m_EffectiveGroupPerms;
271 public uint EffectiveGroupPerms
272 {
273 get
274 {
275 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
276 // bc this is on heavy duty code paths
277 // but for now we need to test the concept
278// AggregateDeepPerms();
279 return m_EffectiveGroupPerms;
280 }
281 }
282
283 private uint m_EffectiveGroupOrEveryOnePerms;
284 public uint EffectiveGroupOrEveryOnePerms
285 {
286 get
287 {
288 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
289 // bc this is on heavy duty code paths
290 // but for now we need to test the concept
291// AggregateDeepPerms();
292 return m_EffectiveGroupOrEveryOnePerms;
293 }
294 }
295
296 private uint m_EffectiveOwnerPerms;
297 public uint EffectiveOwnerPerms
298 {
299 get
300 {
301 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
302 // bc this is on heavy duty code paths
303 // but for now we need to test the concept
304 // AggregateDeepPerms();
305 return m_EffectiveOwnerPerms;
306 }
307 }
308
309 // aggregates perms scanning parts and their contents
310 // AggregatePerms does same using cached parts content perms
311 public void AggregateDeepPerms()
312 {
313 lock(PermissionsLock)
314 {
315 // aux
316 const uint allmask = (uint)PermissionMask.AllEffective;
317 const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify);
318 const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer);
319
320 uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move;
321 bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0;
322
323 uint rootOwnerPerms = RootPart.OwnerMask;
324 uint owner = rootOwnerPerms;
325 uint rootGroupPerms = RootPart.GroupMask;
326 uint group = rootGroupPerms;
327 uint rootEveryonePerms = RootPart.EveryoneMask;
328 uint everyone = rootEveryonePerms;
329
330 SceneObjectPart[] parts = m_parts.GetArray();
331 for (int i = 0; i < parts.Length; i++)
332 {
333 SceneObjectPart part = parts[i];
334 part.AggregateInnerPerms();
335 owner &= part.AggregatedInnerOwnerPerms;
336 group &= part.AggregatedInnerGroupPerms;
337 everyone &= part.AggregatedInnerEveryonePerms;
338 }
339 // recover modify and move
340 rootOwnerPerms &= movemodmask;
341 owner |= rootOwnerPerms;
342 if((owner & copytransfermast) == 0)
343 owner |= (uint)PermissionMask.Transfer;
344
345 owner &= basePerms;
346 m_EffectiveOwnerPerms = owner;
347 uint ownertransfermask = owner & (uint)PermissionMask.Transfer;
348
349 // recover modify and move
350 rootGroupPerms &= movemodmask;
351 group |= rootGroupPerms;
352 if(noBaseTransfer)
353 group &=~(uint)PermissionMask.Copy;
354 else
355 group |= ownertransfermask;
356
357 uint groupOrEveryone = group;
358 m_EffectiveGroupPerms = group & owner;
359
360 // recover move
361 rootEveryonePerms &= (uint)PermissionMask.Move;
362 everyone |= rootEveryonePerms;
363 everyone &= ~(uint)PermissionMask.Modify;
364 if(noBaseTransfer)
365 everyone &=~(uint)PermissionMask.Copy;
366 else
367 everyone |= ownertransfermask;
368
369 groupOrEveryone |= everyone;
370
371 m_EffectiveEveryOnePerms = everyone & owner;
372 m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner;
373 }
374 }
375
376 // aggregates perms scanning parts, assuming their contents was already aggregated and cached
377 // ie is AggregateDeepPerms without the part.AggregateInnerPerms() call on parts loop
378 public void AggregatePerms()
379 {
380 lock(PermissionsLock)
381 {
382 // aux
383 const uint allmask = (uint)PermissionMask.AllEffective;
384 const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify);
385 const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer);
386
387 uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move;
388 bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0;
389
390 uint rootOwnerPerms = RootPart.OwnerMask;
391 uint owner = rootOwnerPerms;
392 uint rootGroupPerms = RootPart.GroupMask;
393 uint group = rootGroupPerms;
394 uint rootEveryonePerms = RootPart.EveryoneMask;
395 uint everyone = rootEveryonePerms;
396
397 SceneObjectPart[] parts = m_parts.GetArray();
398 for (int i = 0; i < parts.Length; i++)
399 {
400 SceneObjectPart part = parts[i];
401 owner &= part.AggregatedInnerOwnerPerms;
402 group &= part.AggregatedInnerGroupPerms;
403 everyone &= part.AggregatedInnerEveryonePerms;
404 }
405 // recover modify and move
406 rootOwnerPerms &= movemodmask;
407 owner |= rootOwnerPerms;
408 if((owner & copytransfermast) == 0)
409 owner |= (uint)PermissionMask.Transfer;
410
411 owner &= basePerms;
412 m_EffectiveOwnerPerms = owner;
413 uint ownertransfermask = owner & (uint)PermissionMask.Transfer;
414
415 // recover modify and move
416 rootGroupPerms &= movemodmask;
417 group |= rootGroupPerms;
418 if(noBaseTransfer)
419 group &=~(uint)PermissionMask.Copy;
420 else
421 group |= ownertransfermask;
422
423 uint groupOrEveryone = group;
424 m_EffectiveGroupPerms = group & owner;
425
426 // recover move
427 rootEveryonePerms &= (uint)PermissionMask.Move;
428 everyone |= rootEveryonePerms;
429 everyone &= ~(uint)PermissionMask.Modify;
430 if(noBaseTransfer)
431 everyone &=~(uint)PermissionMask.Copy;
432 else
433 everyone |= ownertransfermask;
434
435 groupOrEveryone |= everyone;
436
437 m_EffectiveEveryOnePerms = everyone & owner;
438 m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner;
439 }
440 }
441
251 public uint GetEffectivePermissions() 442 public uint GetEffectivePermissions()
252 { 443 {
253 return GetEffectivePermissions(false); 444 return GetEffectivePermissions(false);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 5928764..e73795e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -117,9 +117,6 @@ namespace OpenSim.Region.Framework.Scenes
117 NOT_STATUS_ROTATE_Z = 0xF7 117 NOT_STATUS_ROTATE_Z = 0xF7
118 } 118 }
119 119
120 // This flag has the same purpose as InventoryItemFlags.ObjectSlamPerm
121 public static readonly uint SLAM = 16;
122
123 // private PrimCountTaintedDelegate handlerPrimCountTainted = null; 120 // private PrimCountTaintedDelegate handlerPrimCountTainted = null;
124 121
125 /// <summary> 122 /// <summary>
@@ -156,7 +153,7 @@ namespace OpenSim.Region.Framework.Scenes
156 timeLastChanged = DateTime.UtcNow.Ticks; 153 timeLastChanged = DateTime.UtcNow.Ticks;
157 if (!m_hasGroupChanged) 154 if (!m_hasGroupChanged)
158 timeFirstChanged = DateTime.UtcNow.Ticks; 155 timeFirstChanged = DateTime.UtcNow.Ticks;
159 if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) 156 if (m_rootPart != null && m_scene != null)
160 { 157 {
161/* 158/*
162 if (m_rand == null) 159 if (m_rand == null)
@@ -379,6 +376,8 @@ namespace OpenSim.Region.Framework.Scenes
379 public bool m_dupeInProgress = false; 376 public bool m_dupeInProgress = false;
380 internal Dictionary<UUID, string> m_savedScriptState; 377 internal Dictionary<UUID, string> m_savedScriptState;
381 378
379 public UUID MonitoringObject { get; set; }
380
382 #region Properties 381 #region Properties
383 382
384 /// <summary> 383 /// <summary>
@@ -539,7 +538,7 @@ namespace OpenSim.Region.Framework.Scenes
539 538
540 539
541 public bool inTransit = false; 540 public bool inTransit = false;
542 public delegate SceneObjectGroup SOGCrossDelegate(SceneObjectGroup sog,Vector3 pos); 541 private delegate SceneObjectGroup SOGCrossDelegate(SceneObjectGroup sog,Vector3 pos, TeleportObjectData tpData);
543 542
544 /// <summary> 543 /// <summary>
545 /// The absolute position of this scene object in the scene 544 /// The absolute position of this scene object in the scene
@@ -561,7 +560,7 @@ namespace OpenSim.Region.Framework.Scenes
561 { 560 {
562 inTransit = true; 561 inTransit = true;
563 SOGCrossDelegate d = CrossAsync; 562 SOGCrossDelegate d = CrossAsync;
564 d.BeginInvoke(this, val, CrossAsyncCompleted, d); 563 d.BeginInvoke(this, val, null, CrossAsyncCompleted, d);
565 } 564 }
566 return; 565 return;
567 } 566 }
@@ -602,7 +601,6 @@ namespace OpenSim.Region.Framework.Scenes
602 av.sitSOGmoved(); 601 av.sitSOGmoved();
603 } 602 }
604 603
605
606 // now that position is changed tell it to scripts 604 // now that position is changed tell it to scripts
607 if (triggerScriptEvent) 605 if (triggerScriptEvent)
608 { 606 {
@@ -618,64 +616,75 @@ namespace OpenSim.Region.Framework.Scenes
618 } 616 }
619 } 617 }
620 618
621 public SceneObjectGroup CrossAsync(SceneObjectGroup sog, Vector3 val) 619 private SceneObjectGroup CrossAsync(SceneObjectGroup sog, Vector3 val, TeleportObjectData tpdata)
622 { 620 {
623 Scene sogScene = sog.m_scene; 621 Scene sogScene = sog.m_scene;
624 IEntityTransferModule entityTransfer = sogScene.RequestModuleInterface<IEntityTransferModule>(); 622 SceneObjectPart root = sog.RootPart;
625 623
626 Vector3 newpos = Vector3.Zero; 624 bool isTeleport = tpdata != null;
627 OpenSim.Services.Interfaces.GridRegion destination = null;
628 625
629 if (sog.RootPart.DIE_AT_EDGE) 626 if(!isTeleport)
630 { 627 {
631 try 628 if (root.DIE_AT_EDGE)
632 {
633 sogScene.DeleteSceneObject(sog, false);
634 }
635 catch (Exception)
636 { 629 {
637 m_log.Warn("[SCENE]: exception when trying to remove the prim that crossed the border."); 630 try
631 {
632 sogScene.DeleteSceneObject(sog, false);
633 }
634 catch (Exception)
635 {
636 m_log.Warn("[SCENE]: exception when trying to remove the prim that crossed the border.");
637 }
638 return sog;
638 } 639 }
639 return sog;
640 }
641 640
642 if (sog.RootPart.RETURN_AT_EDGE) 641 if (root.RETURN_AT_EDGE)
643 {
644 // We remove the object here
645 try
646 {
647 List<uint> localIDs = new List<uint>();
648 localIDs.Add(sog.RootPart.LocalId);
649 sogScene.AddReturn(sog.OwnerID, sog.Name, sog.AbsolutePosition,
650 "Returned at region cross");
651 sogScene.DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, UUID.Zero);
652 }
653 catch (Exception)
654 { 642 {
655 m_log.Warn("[SCENE]: exception when trying to return the prim that crossed the border."); 643 // We remove the object here
644 try
645 {
646 List<uint> localIDs = new List<uint>();
647 localIDs.Add(root.LocalId);
648 sogScene.AddReturn(sog.OwnerID, sog.Name, sog.AbsolutePosition,
649 "Returned at region cross");
650 sogScene.DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, UUID.Zero, false);
651 }
652 catch (Exception)
653 {
654 m_log.Warn("[SCENE]: exception when trying to return the prim that crossed the border.");
655 }
656 return sog;
656 } 657 }
657 return sog;
658 } 658 }
659 659
660 if (sog.m_rootPart.KeyframeMotion != null) 660 if (root.KeyframeMotion != null)
661 sog.m_rootPart.KeyframeMotion.StartCrossingCheck(); 661 root.KeyframeMotion.StartCrossingCheck();
662
663 if(root.PhysActor != null)
664 root.PhysActor.CrossingStart();
665
666 IEntityTransferModule entityTransfer = sogScene.RequestModuleInterface<IEntityTransferModule>();
662 667
663 if (entityTransfer == null) 668 if (entityTransfer == null)
664 return sog; 669 return sog;
665 670
671 Vector3 newpos = Vector3.Zero;
672 OpenSim.Services.Interfaces.GridRegion destination = null;
673
666 destination = entityTransfer.GetObjectDestination(sog, val, out newpos); 674 destination = entityTransfer.GetObjectDestination(sog, val, out newpos);
667 if (destination == null) 675 if (destination == null)
668 return sog; 676 return sog;
669 677
670 if (sog.m_sittingAvatars.Count == 0) 678 if (sog.m_sittingAvatars.Count == 0)
671 { 679 {
672 entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true, true); 680 entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, !isTeleport, true);
673 return sog; 681 return sog;
674 } 682 }
675 683
676 string reason = String.Empty; 684 string reason = String.Empty;
677 EntityTransferContext ctx = new EntityTransferContext(); 685 EntityTransferContext ctx = new EntityTransferContext();
678 686
687 Vector3 curPos = root.GroupPosition;
679 foreach (ScenePresence av in sog.m_sittingAvatars) 688 foreach (ScenePresence av in sog.m_sittingAvatars)
680 { 689 {
681 // We need to cross these agents. First, let's find 690 // We need to cross these agents. First, let's find
@@ -686,10 +695,15 @@ namespace OpenSim.Region.Framework.Scenes
686 695
687 // We set the avatar position as being the object 696 // We set the avatar position as being the object
688 // position to get the region to send to 697 // position to get the region to send to
698 if(av.IsNPC)
699 continue;
700
701 if(av.IsInTransit)
702 return sog;
703
689 if(!entityTransfer.checkAgentAccessToRegion(av, destination, newpos, ctx, out reason)) 704 if(!entityTransfer.checkAgentAccessToRegion(av, destination, newpos, ctx, out reason))
690 {
691 return sog; 705 return sog;
692 } 706
693 m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); 707 m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName);
694 } 708 }
695 709
@@ -697,8 +711,10 @@ namespace OpenSim.Region.Framework.Scenes
697 // be made to stand up 711 // be made to stand up
698 712
699 List<avtocrossInfo> avsToCross = new List<avtocrossInfo>(); 713 List<avtocrossInfo> avsToCross = new List<avtocrossInfo>();
700 714 List<ScenePresence> avsToCrossFar = new List<ScenePresence>();
701 foreach (ScenePresence av in sog.m_sittingAvatars) 715 ulong destHandle = destination.RegionHandle;
716 List<ScenePresence> sittingAvatars = GetSittingAvatars();
717 foreach (ScenePresence av in sittingAvatars)
702 { 718 {
703 byte cflags = 1; 719 byte cflags = 1;
704 720
@@ -712,68 +728,175 @@ namespace OpenSim.Region.Framework.Scenes
712 else 728 else
713 cflags = 3; 729 cflags = 3;
714 } 730 }
731 if(!av.knowsNeighbourRegion(destHandle))
732 cflags |= 8;
715 733
716 // 1 is crossing 734 // 1 is crossing
717 // 2 is sitting 735 // 2 is sitting
718 // 4 is sitting at sittarget 736 // 4 is sitting at sittarget
719 av.crossingFlags = cflags; 737 // 8 far crossing
720 738
721 avinfo.av = av; 739 avinfo.av = av;
722 avinfo.ParentID = av.ParentID; 740 avinfo.ParentID = av.ParentID;
723 avsToCross.Add(avinfo); 741 avsToCross.Add(avinfo);
724 742
743 if(!av.knowsNeighbourRegion(destHandle))
744 {
745 cflags |= 8;
746 avsToCrossFar.Add(av);
747 }
748
749 if(av.IsNPC)
750 av.crossingFlags = 0;
751 else
752 av.crossingFlags = cflags;
753
725 av.PrevSitOffset = av.OffsetPosition; 754 av.PrevSitOffset = av.OffsetPosition;
726 av.ParentID = 0; 755 av.ParentID = 0;
727 } 756 }
728 757
758 Vector3 vel = root.Velocity;
759 Vector3 avel = root.AngularVelocity;
760 Vector3 acc = root.Acceleration;
761 Quaternion ori = root.RotationOffset;
762
763 if(isTeleport)
764 {
765 root.Stop();
766 sogScene.ForEachScenePresence(delegate(ScenePresence av)
767 {
768 av.ControllingClient.SendEntityUpdate(root,PrimUpdateFlags.SendInTransit);
769 av.ControllingClient.SendEntityTerseUpdateImmediate(root);
770 });
771
772 root.Velocity = tpdata.vel;
773 root.AngularVelocity = tpdata.avel;
774 root.Acceleration = tpdata.acc;
775 root.RotationOffset = tpdata.ori;
776 }
777
729 if (entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true, false)) 778 if (entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true, false))
730 { 779 {
780 if(isTeleport)
781 {
782 sogScene.ForEachScenePresence(delegate(ScenePresence oav)
783 {
784 if(sittingAvatars.Contains(oav))
785 return;
786 if(oav.knowsNeighbourRegion(destHandle))
787 return;
788 oav.ControllingClient.SendEntityUpdate(root, PrimUpdateFlags.Kill);
789 foreach (ScenePresence sav in sittingAvatars)
790 {
791 sav.SendKillTo(oav);
792 }
793 });
794 }
795 bool crossedfar = false;
796 foreach (ScenePresence av in avsToCrossFar)
797 {
798 if(entityTransfer.CrossAgentCreateFarChild(av,destination, newpos, ctx))
799 crossedfar = true;
800 else
801 av.crossingFlags = 0;
802 }
803
804 if(crossedfar)
805 Thread.Sleep(1000);
806
731 foreach (avtocrossInfo avinfo in avsToCross) 807 foreach (avtocrossInfo avinfo in avsToCross)
732 { 808 {
733 ScenePresence av = avinfo.av; 809 ScenePresence av = avinfo.av;
734 if (!av.IsInTransit) // just in case... 810 av.IsInTransit = true;
735 { 811 m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val);
736 m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val);
737 812
738 av.IsInTransit = true; 813 if(av.crossingFlags > 0)
814 entityTransfer.CrossAgentToNewRegionAsync(av, newpos, destination, false, ctx);
739 815
740// CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; 816 if (av.IsChildAgent)
741// d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); 817 {
742 entityTransfer.CrossAgentToNewRegionAsync(av, newpos, destination, av.Flying, ctx); 818 // avatar crossed do some extra cleanup
743 if (av.IsChildAgent) 819 if (av.ParentUUID != UUID.Zero)
744 {
745 // avatar crossed do some extra cleanup
746 if (av.ParentUUID != UUID.Zero)
747 {
748 av.ClearControls();
749 av.ParentPart = null;
750 }
751 }
752 else
753 { 820 {
754 // avatar cross failed we need do dedicated standUp 821 av.ClearControls();
755 // part of it was done at CrossAgentToNewRegionAsync 822 av.ParentPart = null;
756 // so for now just remove the sog controls
757 // this may need extra care
758 av.UnRegisterSeatControls(sog.UUID);
759 } 823 }
760
761 av.ParentUUID = UUID.Zero; 824 av.ParentUUID = UUID.Zero;
825 av.ParentPart = null;
762 // In any case 826 // In any case
763 av.IsInTransit = false; 827 av.IsInTransit = false;
764 av.crossingFlags = 0; 828 av.crossingFlags = 0;
765 m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", av.Firstname, av.Lastname); 829 m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", av.Firstname, av.Lastname);
766 } 830 }
767 else 831 else
768 m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar already in transit {0} to {1}", av.Name, val); 832 {
833 // avatar cross failed we need do dedicated standUp
834 // part of it was done at CrossAgentToNewRegionAsync
835 // so for now just remove the sog controls
836 // this may need extra care
837 av.UnRegisterSeatControls(sog.UUID);
838 av.ParentUUID = UUID.Zero;
839 av.ParentPart = null;
840 Vector3 oldp = curPos;
841 oldp.X = Util.Clamp<float>(oldp.X, 0.5f, sog.m_scene.RegionInfo.RegionSizeX - 0.5f);
842 oldp.Y = Util.Clamp<float>(oldp.Y, 0.5f, sog.m_scene.RegionInfo.RegionSizeY - 0.5f);
843 av.AbsolutePosition = oldp;
844 av.crossingFlags = 0;
845 av.sitAnimation = "SIT";
846 av.IsInTransit = false;
847 if(av.Animator!= null)
848 av.Animator.SetMovementAnimations("STAND");
849 av.AddToPhysicalScene(false);
850 sogScene.ForEachScenePresence(delegate(ScenePresence oav)
851 {
852 if(sittingAvatars.Contains(oav))
853 return;
854 if(oav.knowsNeighbourRegion(destHandle))
855 av.SendAvatarDataToAgent(oav);
856 else
857 {
858 av.SendAvatarDataToAgent(oav);
859 av.SendAppearanceToAgent(oav);
860 if (av.Animator != null)
861 av.Animator.SendAnimPackToClient(oav.ControllingClient);
862 av.SendAttachmentsToAgentNF(oav); // not ok
863 }
864 });
865 m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} failed.", av.Firstname, av.Lastname);
866 }
769 } 867 }
868
869 if(crossedfar)
870 {
871 Thread.Sleep(10000);
872 foreach (ScenePresence av in avsToCrossFar)
873 {
874 if(av.IsChildAgent)
875 {
876 av.Scene.CloseAgent(av.UUID, false);
877 }
878 else
879 av.RemoveNeighbourRegion(destHandle);
880 }
881 }
882 avsToCrossFar.Clear();
770 avsToCross.Clear(); 883 avsToCross.Clear();
771 sog.RemoveScriptInstances(true); 884 sog.RemoveScriptInstances(true);
772 sog.Clear(); 885 sog.Clear();
773 return sog; 886 return sog;
774 } 887 }
775 else // cross failed, put avas back ?? 888 else
776 { 889 {
890 if(isTeleport)
891 {
892 if((tpdata.flags & OSTPOBJ_STOPONFAIL) == 0)
893 {
894 root.Velocity = vel;
895 root.AngularVelocity = avel;
896 root.Acceleration = acc;
897 }
898 root.RotationOffset = ori;
899 }
777 foreach (avtocrossInfo avinfo in avsToCross) 900 foreach (avtocrossInfo avinfo in avsToCross)
778 { 901 {
779 ScenePresence av = avinfo.av; 902 ScenePresence av = avinfo.av;
@@ -783,7 +906,6 @@ namespace OpenSim.Region.Framework.Scenes
783 } 906 }
784 } 907 }
785 avsToCross.Clear(); 908 avsToCross.Clear();
786
787 return sog; 909 return sog;
788 } 910 }
789 911
@@ -795,11 +917,14 @@ namespace OpenSim.Region.Framework.Scenes
795 if (!sog.IsDeleted) 917 if (!sog.IsDeleted)
796 { 918 {
797 SceneObjectPart rootp = sog.m_rootPart; 919 SceneObjectPart rootp = sog.m_rootPart;
920
798 Vector3 oldp = rootp.GroupPosition; 921 Vector3 oldp = rootp.GroupPosition;
799 oldp.X = Util.Clamp<float>(oldp.X, 0.5f, sog.m_scene.RegionInfo.RegionSizeX - 0.5f); 922 oldp.X = Util.Clamp<float>(oldp.X, 0.5f, sog.m_scene.RegionInfo.RegionSizeX - 0.5f);
800 oldp.Y = Util.Clamp<float>(oldp.Y, 0.5f, sog.m_scene.RegionInfo.RegionSizeY - 0.5f); 923 oldp.Y = Util.Clamp<float>(oldp.Y, 0.5f, sog.m_scene.RegionInfo.RegionSizeY - 0.5f);
801 rootp.GroupPosition = oldp; 924 rootp.GroupPosition = oldp;
802 925
926 rootp.Stop();
927
803 SceneObjectPart[] parts = sog.m_parts.GetArray(); 928 SceneObjectPart[] parts = sog.m_parts.GetArray();
804 929
805 foreach (SceneObjectPart part in parts) 930 foreach (SceneObjectPart part in parts)
@@ -813,47 +938,150 @@ namespace OpenSim.Region.Framework.Scenes
813 av.sitSOGmoved(); 938 av.sitSOGmoved();
814 } 939 }
815 940
816 sog.Velocity = Vector3.Zero;
817
818 if (sog.m_rootPart.KeyframeMotion != null) 941 if (sog.m_rootPart.KeyframeMotion != null)
819 sog.m_rootPart.KeyframeMotion.CrossingFailure(); 942 sog.m_rootPart.KeyframeMotion.CrossingFailure();
820 943
821 if (sog.RootPart.PhysActor != null) 944 if (sog.RootPart.PhysActor != null)
822 {
823 sog.RootPart.PhysActor.CrossingFailure(); 945 sog.RootPart.PhysActor.CrossingFailure();
824 }
825 946
826 sog.inTransit = false; 947 sog.inTransit = false;
948 AttachToBackup();
827 sog.ScheduleGroupForFullUpdate(); 949 sog.ScheduleGroupForFullUpdate();
828 } 950 }
829 } 951 }
830 952
831/* outdated 953 private class TeleportObjectData
832 private void CrossAgentToNewRegionCompleted(ScenePresence agent)
833 { 954 {
834 //// If the cross was successful, this agent is a child agent 955 public int flags;
835 if (agent.IsChildAgent) 956 public Vector3 vel;
957 public Vector3 avel;
958 public Vector3 acc;
959 public Quaternion ori;
960 public UUID sourceID;
961 }
962
963 // copy from LSL_constants.cs
964 const int OSTPOBJ_STOPATTARGET = 0x1; // stops at destination
965 const int OSTPOBJ_STOPONFAIL = 0x2; // stops at start if tp fails
966 const int OSTPOBJ_SETROT = 0x4; // the rotation is the final rotation, otherwise is a added rotation
967
968 public int TeleportObject(UUID sourceID, Vector3 targetPosition, Quaternion rotation, int flags)
969 {
970 if(inTransit || IsDeleted || IsAttachmentCheckFull() || IsSelected || Scene == null)
971 return -1;
972
973 inTransit = true;
974
975 PhysicsActor pa = RootPart.PhysActor;
976 if(pa == null || RootPart.KeyframeMotion != null /*|| m_sittingAvatars.Count == 0*/)
836 { 977 {
837 if (agent.ParentUUID != UUID.Zero) 978 inTransit = false;
979 return -1;
980 }
981
982 bool stop = (flags & OSTPOBJ_STOPATTARGET) != 0;
983 bool setrot = (flags & OSTPOBJ_SETROT) != 0;
984
985 rotation.Normalize();
986
987 Quaternion currentRot = RootPart.RotationOffset;
988 if(setrot)
989 rotation = Quaternion.Conjugate(currentRot) * rotation;
990
991 bool dorot = setrot | (Math.Abs(rotation.W) < 0.99999);
992
993 Vector3 vel = Vector3.Zero;
994 Vector3 avel = Vector3.Zero;
995 Vector3 acc = Vector3.Zero;
996
997 if(!stop)
998 {
999 vel = RootPart.Velocity;
1000 avel = RootPart.AngularVelocity;
1001 acc = RootPart.Acceleration;
1002 }
1003 Quaternion ori = RootPart.RotationOffset;
1004
1005 if(dorot)
1006 {
1007 if(!stop)
838 { 1008 {
839 agent.HandleForceReleaseControls(agent.ControllingClient,agent.UUID); 1009 vel *= rotation;
840 agent.ParentPart = null; 1010 avel *= rotation;
841// agent.ParentPosition = Vector3.Zero; 1011 acc *= rotation;
842// agent.ParentUUID = UUID.Zero;
843 } 1012 }
1013 ori *= rotation;
844 } 1014 }
845 1015
846 agent.ParentUUID = UUID.Zero; 1016 if(Scene.PositionIsInCurrentRegion(targetPosition))
847// agent.Reset(); 1017 {
848// else // Not successful 1018 if(Scene.InTeleportTargetsCoolDown(UUID, sourceID, 1.0))
849// agent.RestoreInCurrentScene(); 1019 {
1020 inTransit = false;
1021 return -2;
1022 }
850 1023
851 // In any case 1024 Vector3 curPos = AbsolutePosition;
852 agent.IsInTransit = false; 1025 ILandObject curLand = Scene.LandChannel.GetLandObject(curPos.X, curPos.Y);
1026 float posX = targetPosition.X;
1027 float posY = targetPosition.Y;
1028 ILandObject land = Scene.LandChannel.GetLandObject(posX, posY);
1029 if(land != null && land != curLand)
1030 {
1031 if(!Scene.Permissions.CanObjectEnterWithScripts(this, land))
1032 {
1033 inTransit = false;
1034 return -3;
1035 }
1036
1037 UUID agentID;
1038 foreach (ScenePresence av in m_sittingAvatars)
1039 {
1040 agentID = av.UUID;
1041 if(land.IsRestrictedFromLand(agentID) || land.IsBannedFromLand(agentID))
1042 {
1043 inTransit = false;
1044 return -4;
1045 }
1046 }
1047 }
1048
1049 RootPart.Velocity = vel;
1050 RootPart.AngularVelocity = avel;
1051 RootPart.Acceleration = acc;
1052 RootPart.RotationOffset = ori;
1053
1054 Vector3 s = RootPart.Scale * RootPart.RotationOffset;
1055 float h = Scene.GetGroundHeight(posX, posY) + 0.5f * (float)Math.Abs(s.Z) + 0.01f;
1056 if(targetPosition.Z < h)
1057 targetPosition.Z = h;
1058
1059 inTransit = false;
1060 AbsolutePosition = targetPosition;
1061 RootPart.ScheduleTerseUpdate();
1062 return 1;
1063 }
1064
1065 if(Scene.InTeleportTargetsCoolDown(UUID, sourceID, 20.0))
1066 {
1067 inTransit = false;
1068 return -1;
1069 }
853 1070
854 m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); 1071 TeleportObjectData tdata = new TeleportObjectData();
1072 tdata.flags = flags;
1073 tdata.vel = vel;
1074 tdata.avel = avel;
1075 tdata.acc = acc;
1076 tdata.ori = ori;
1077 tdata.sourceID = sourceID;
1078
1079
1080 SOGCrossDelegate d = CrossAsync;
1081 d.BeginInvoke(this, targetPosition, tdata, CrossAsyncCompleted, d);
1082 return 0;
855 } 1083 }
856*/ 1084
857 public override Vector3 Velocity 1085 public override Vector3 Velocity
858 { 1086 {
859 get { return RootPart.Velocity; } 1087 get { return RootPart.Velocity; }
@@ -1786,63 +2014,6 @@ namespace OpenSim.Region.Framework.Scenes
1786 } 2014 }
1787 } 2015 }
1788 2016
1789 /// <summary>
1790 /// Attach this scene object to the given avatar.
1791 /// </summary>
1792 /// <param name="agentID"></param>
1793 /// <param name="attachmentpoint"></param>
1794 /// <param name="AttachOffset"></param>
1795 private void AttachToAgent(
1796 ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
1797 {
1798 if (avatar != null)
1799 {
1800 // don't attach attachments to child agents
1801 if (avatar.IsChildAgent) return;
1802
1803 // Remove from database and parcel prim count
1804 m_scene.DeleteFromStorage(so.UUID);
1805 m_scene.EventManager.TriggerParcelPrimCountTainted();
1806
1807 so.AttachedAvatar = avatar.UUID;
1808
1809 if (so.RootPart.PhysActor != null)
1810 {
1811 m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor);
1812 so.RootPart.PhysActor = null;
1813 }
1814
1815 so.AbsolutePosition = attachOffset;
1816 so.RootPart.AttachedPos = attachOffset;
1817 so.IsAttachment = true;
1818 so.RootPart.SetParentLocalId(avatar.LocalId);
1819 so.AttachmentPoint = attachmentpoint;
1820
1821 avatar.AddAttachment(this);
1822
1823 if (!silent)
1824 {
1825 // Killing it here will cause the client to deselect it
1826 // It then reappears on the avatar, deselected
1827 // through the full update below
1828 //
1829 if (IsSelected)
1830 {
1831 m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId });
1832 }
1833
1834 IsSelected = false; // fudge....
1835 ScheduleGroupForFullUpdate();
1836 }
1837 }
1838 else
1839 {
1840 m_log.WarnFormat(
1841 "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present",
1842 UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName);
1843 }
1844 }
1845
1846 public byte GetAttachmentPoint() 2017 public byte GetAttachmentPoint()
1847 { 2018 {
1848 return m_rootPart.Shape.State; 2019 return m_rootPart.Shape.State;
@@ -1957,6 +2128,7 @@ namespace OpenSim.Region.Framework.Scenes
1957 2128
1958 if (part.LinkNum == 2) 2129 if (part.LinkNum == 2)
1959 RootPart.LinkNum = 1; 2130 RootPart.LinkNum = 1;
2131 InvalidatePartsLinkMaps();
1960 } 2132 }
1961 2133
1962 /// <summary> 2134 /// <summary>
@@ -2233,7 +2405,8 @@ namespace OpenSim.Region.Framework.Scenes
2233 { 2405 {
2234 if (part.OwnerID != userId) 2406 if (part.OwnerID != userId)
2235 { 2407 {
2236 part.LastOwnerID = part.OwnerID; 2408 if(part.GroupID != part.OwnerID)
2409 part.LastOwnerID = part.OwnerID;
2237 part.OwnerID = userId; 2410 part.OwnerID = userId;
2238 } 2411 }
2239 }); 2412 });
@@ -2313,7 +2486,7 @@ namespace OpenSim.Region.Framework.Scenes
2313 RootPart.UUID); 2486 RootPart.UUID);
2314 m_scene.AddReturn(OwnerID == GroupID ? LastOwnerID : OwnerID, Name, AbsolutePosition, "parcel autoreturn"); 2487 m_scene.AddReturn(OwnerID == GroupID ? LastOwnerID : OwnerID, Name, AbsolutePosition, "parcel autoreturn");
2315 m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero, 2488 m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero,
2316 DeRezAction.Return, UUID.Zero); 2489 DeRezAction.Return, UUID.Zero, false);
2317 2490
2318 return; 2491 return;
2319 } 2492 }
@@ -2443,17 +2616,16 @@ namespace OpenSim.Region.Framework.Scenes
2443 dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); 2616 dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed);
2444 dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; 2617 dupe.m_rootPart.LinkNum = m_rootPart.LinkNum;
2445 2618
2446
2447 if (userExposed) 2619 if (userExposed)
2448 dupe.m_rootPart.TrimPermissions(); 2620 dupe.m_rootPart.TrimPermissions();
2449 2621
2450 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); 2622 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray());
2451 2623
2452 partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) 2624 partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2)
2453 { 2625 {
2454 return p1.LinkNum.CompareTo(p2.LinkNum); 2626 return p1.LinkNum.CompareTo(p2.LinkNum);
2455 } 2627 }
2456 ); 2628 );
2457 2629
2458 foreach (SceneObjectPart part in partList) 2630 foreach (SceneObjectPart part in partList)
2459 { 2631 {
@@ -2505,12 +2677,15 @@ namespace OpenSim.Region.Framework.Scenes
2505 if (dupe.m_rootPart.PhysActor != null) 2677 if (dupe.m_rootPart.PhysActor != null)
2506 dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building 2678 dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building
2507 2679
2680 dupe.AggregateDeepPerms();
2681
2508 dupe.HasGroupChanged = true; 2682 dupe.HasGroupChanged = true;
2509 dupe.AttachToBackup(); 2683 dupe.AttachToBackup();
2510 2684
2511 ScheduleGroupForFullUpdate(); 2685 dupe.ScheduleGroupForFullUpdate();
2512 } 2686 }
2513 2687
2688 dupe.InvalidatePartsLinkMaps();
2514 m_dupeInProgress = false; 2689 m_dupeInProgress = false;
2515 return dupe; 2690 return dupe;
2516 } 2691 }
@@ -2746,25 +2921,33 @@ namespace OpenSim.Region.Framework.Scenes
2746 } 2921 }
2747 2922
2748 /// <summary> 2923 /// <summary>
2749 /// Set the owner of the root part. 2924 /// Set the owner of all linkset.
2750 /// </summary> 2925 /// </summary>
2751 /// <param name="part"></param>
2752 /// <param name="cAgentID"></param> 2926 /// <param name="cAgentID"></param>
2753 /// <param name="cGroupID"></param> 2927 /// <param name="cGroupID"></param>
2754 public void SetRootPartOwner(SceneObjectPart part, UUID cAgentID, UUID cGroupID) 2928 public void SetOwner(UUID cAgentID, UUID cGroupID)
2755 { 2929 {
2756 part.LastOwnerID = part.OwnerID; 2930 SceneObjectPart rpart = RootPart;
2757 part.OwnerID = cAgentID; 2931 UUID oldowner = rpart.OwnerID;
2758 part.GroupID = cGroupID; 2932 ForEachPart(delegate(SceneObjectPart part)
2933 {
2934 if(part.GroupID != part.OwnerID)
2935 part.LastOwnerID = part.OwnerID;
2936 part.OwnerID = cAgentID;
2937 part.GroupID = cGroupID;
2938 });
2759 2939
2760 if (part.OwnerID != cAgentID) 2940 if (oldowner != cAgentID)
2761 { 2941 {
2762 // Apply Next Owner Permissions if we're not bypassing permissions 2942 // Apply Next Owner Permissions if we're not bypassing permissions
2763 if (!m_scene.Permissions.BypassPermissions()) 2943 if (!m_scene.Permissions.BypassPermissions())
2944 {
2764 ApplyNextOwnerPermissions(); 2945 ApplyNextOwnerPermissions();
2946 AggregatePerms();
2947 }
2765 } 2948 }
2766 2949
2767 part.ScheduleFullUpdate(); 2950 rpart.ScheduleFullUpdate();
2768 } 2951 }
2769 2952
2770 /// <summary> 2953 /// <summary>
@@ -3264,6 +3447,7 @@ namespace OpenSim.Region.Framework.Scenes
3264 ResetChildPrimPhysicsPositions(); 3447 ResetChildPrimPhysicsPositions();
3265 3448
3266 InvalidBoundsRadius(); 3449 InvalidBoundsRadius();
3450 InvalidatePartsLinkMaps();
3267 3451
3268 if (m_rootPart.PhysActor != null) 3452 if (m_rootPart.PhysActor != null)
3269 m_rootPart.PhysActor.Building = false; 3453 m_rootPart.PhysActor.Building = false;
@@ -3420,6 +3604,8 @@ namespace OpenSim.Region.Framework.Scenes
3420 objectGroup.HasGroupChangedDueToDelink = true; 3604 objectGroup.HasGroupChangedDueToDelink = true;
3421 3605
3422 InvalidBoundsRadius(); 3606 InvalidBoundsRadius();
3607 InvalidatePartsLinkMaps();
3608 objectGroup.AggregatePerms();
3423 3609
3424 if (sendEvents) 3610 if (sendEvents)
3425 linkPart.TriggerScriptChangedEvent(Changed.LINK); 3611 linkPart.TriggerScriptChangedEvent(Changed.LINK);
@@ -3958,8 +4144,8 @@ namespace OpenSim.Region.Framework.Scenes
3958 4144
3959 public void AdjustChildPrimPermissions(bool forceTaskInventoryPermissive) 4145 public void AdjustChildPrimPermissions(bool forceTaskInventoryPermissive)
3960 { 4146 {
3961 uint newOwnerMask = (uint)(PermissionMask.All | PermissionMask.Export) & 0xfffffff8; // Mask folded bits 4147 uint newOwnerMask = (uint)(PermissionMask.All | PermissionMask.Export) & 0xfffffff0; // Mask folded bits
3962 uint foldedPerms = RootPart.OwnerMask & 3; 4148 uint foldedPerms = RootPart.OwnerMask & (uint)PermissionMask.FoldedMask;
3963 4149
3964 ForEachPart(part => 4150 ForEachPart(part =>
3965 { 4151 {
@@ -3970,14 +4156,14 @@ namespace OpenSim.Region.Framework.Scenes
3970 part.Inventory.ApplyGodPermissions(part.BaseMask); 4156 part.Inventory.ApplyGodPermissions(part.BaseMask);
3971 }); 4157 });
3972 4158
3973 uint lockMask = ~(uint)(PermissionMask.Move | PermissionMask.Modify); 4159 uint lockMask = ~(uint)(PermissionMask.Move);
3974 uint lockBit = RootPart.OwnerMask & (uint)(PermissionMask.Move | PermissionMask.Modify); 4160 uint lockBit = RootPart.OwnerMask & (uint)(PermissionMask.Move);
3975 RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask); 4161 RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask);
3976 4162
3977// m_log.DebugFormat( 4163// m_log.DebugFormat(
3978// "[SCENE OBJECT GROUP]: RootPart.OwnerMask now {0} for {1} in {2}", 4164// "[SCENE OBJECT GROUP]: RootPart.OwnerMask now {0} for {1} in {2}",
3979// (OpenMetaverse.PermissionMask)RootPart.OwnerMask, Name, Scene.Name); 4165// (OpenMetaverse.PermissionMask)RootPart.OwnerMask, Name, Scene.Name);
3980 4166 AggregatePerms();
3981 RootPart.ScheduleFullUpdate(); 4167 RootPart.ScheduleFullUpdate();
3982 } 4168 }
3983 4169
@@ -4002,6 +4188,7 @@ namespace OpenSim.Region.Framework.Scenes
4002 { 4188 {
4003 foreach (SceneObjectPart part in Parts) 4189 foreach (SceneObjectPart part in Parts)
4004 part.Inventory.ApplyGodPermissions(RootPart.BaseMask); 4190 part.Inventory.ApplyGodPermissions(RootPart.BaseMask);
4191 AggregatePerms();
4005 } 4192 }
4006 4193
4007 HasGroupChanged = true; 4194 HasGroupChanged = true;
@@ -4647,7 +4834,7 @@ namespace OpenSim.Region.Framework.Scenes
4647 } 4834 }
4648 if ((change & ObjectChangeType.Position) != 0) 4835 if ((change & ObjectChangeType.Position) != 0)
4649 { 4836 {
4650 if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) 4837 if (IsAttachment || m_scene.Permissions.CanObjectEntry(group, false, data.position))
4651 UpdateGroupPosition(data.position); 4838 UpdateGroupPosition(data.position);
4652 updateType = updatetype.groupterse; 4839 updateType = updatetype.groupterse;
4653 } 4840 }
@@ -5056,6 +5243,49 @@ namespace OpenSim.Region.Framework.Scenes
5056 return Ptot; 5243 return Ptot;
5057 } 5244 }
5058 5245
5246 public void GetInertiaData(out float TotalMass, out Vector3 CenterOfMass, out Vector3 Inertia, out Vector4 aux )
5247 {
5248 PhysicsActor pa = RootPart.PhysActor;
5249
5250 if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null)
5251 {
5252 PhysicsInertiaData inertia;
5253
5254 inertia = pa.GetInertiaData();
5255
5256 TotalMass = inertia.TotalMass;
5257 CenterOfMass = inertia.CenterOfMass;
5258 Inertia = inertia.Inertia;
5259 aux = inertia.InertiaRotation;
5260
5261 return;
5262 }
5263
5264 TotalMass = GetMass();
5265 CenterOfMass = GetCenterOfMass() - AbsolutePosition;
5266 CenterOfMass *= Quaternion.Conjugate(RootPart.RotationOffset);
5267 Inertia = Vector3.Zero;
5268 aux = Vector4.Zero;
5269 }
5270
5271 public void SetInertiaData(float TotalMass, Vector3 CenterOfMass, Vector3 Inertia, Vector4 aux )
5272 {
5273 PhysicsInertiaData inertia = new PhysicsInertiaData();
5274 inertia.TotalMass = TotalMass;
5275 inertia.CenterOfMass = CenterOfMass;
5276 inertia.Inertia = Inertia;
5277 inertia.InertiaRotation = aux;
5278
5279 if(TotalMass < 0)
5280 RootPart.PhysicsInertia = null;
5281 else
5282 RootPart.PhysicsInertia = new PhysicsInertiaData(inertia);
5283
5284 PhysicsActor pa = RootPart.PhysActor;
5285 if(pa !=null)
5286 pa.SetInertiaData(inertia);
5287 }
5288
5059 /// <summary> 5289 /// <summary>
5060 /// Set the user group to which this scene object belongs. 5290 /// Set the user group to which this scene object belongs.
5061 /// </summary> 5291 /// </summary>
@@ -5217,6 +5447,7 @@ namespace OpenSim.Region.Framework.Scenes
5217 { 5447 {
5218 part.ResetOwnerChangeFlag(); 5448 part.ResetOwnerChangeFlag();
5219 }); 5449 });
5450 AggregatePerms();
5220 } 5451 }
5221 5452
5222 // clear some references to easy cg 5453 // clear some references to easy cg
@@ -5230,6 +5461,84 @@ namespace OpenSim.Region.Framework.Scenes
5230 m_PlaySoundSlavePrims.Clear(); 5461 m_PlaySoundSlavePrims.Clear();
5231 m_LoopSoundMasterPrim = null; 5462 m_LoopSoundMasterPrim = null;
5232 m_targets.Clear(); 5463 m_targets.Clear();
5464 m_partsNameToLinkMap.Clear();
5465 }
5466
5467 private Dictionary<string,int> m_partsNameToLinkMap = new Dictionary<string, int>();
5468 private string GetLinkNumber_lastname;
5469 private int GetLinkNumber_lastnumber;
5470
5471 // this scales bad but so does GetLinkNumPart
5472 public int GetLinkNumber(string name)
5473 {
5474 if(String.IsNullOrEmpty(name) || name == "Object")
5475 return -1;
5476
5477 lock(m_partsNameToLinkMap)
5478 {
5479 if(m_partsNameToLinkMap.Count == 0)
5480 {
5481 GetLinkNumber_lastname = String.Empty;
5482 GetLinkNumber_lastnumber = -1;
5483 SceneObjectPart[] parts = m_parts.GetArray();
5484 for (int i = 0; i < parts.Length; i++)
5485 {
5486 string s = parts[i].Name;
5487 if(String.IsNullOrEmpty(s) || s == "Object" || s == "Primitive")
5488 continue;
5489
5490 if(m_partsNameToLinkMap.ContainsKey(s))
5491 {
5492 int ol = parts[i].LinkNum;
5493 if(ol < m_partsNameToLinkMap[s])
5494 m_partsNameToLinkMap[s] = ol;
5495 }
5496 else
5497 m_partsNameToLinkMap[s] = parts[i].LinkNum;
5498 }
5499 }
5500
5501 if(name == GetLinkNumber_lastname)
5502 return GetLinkNumber_lastnumber;
5503
5504 if(m_partsNameToLinkMap.ContainsKey(name))
5505 {
5506 lock(m_partsNameToLinkMap)
5507 {
5508 GetLinkNumber_lastname = name;
5509 GetLinkNumber_lastnumber = m_partsNameToLinkMap[name];
5510 return GetLinkNumber_lastnumber;
5511 }
5512 }
5513 }
5514
5515 if(m_sittingAvatars.Count > 0)
5516 {
5517 int j = m_parts.Count + 1;
5518
5519 ScenePresence[] avs = m_sittingAvatars.ToArray();
5520 for (int i = 0; i < avs.Length; i++, j++)
5521 {
5522 if (avs[i].Name == name)
5523 {
5524 GetLinkNumber_lastname = name;
5525 GetLinkNumber_lastnumber = j;
5526 return j;
5527 }
5528 }
5529 }
5530
5531 return -1;
5532 }
5533
5534 public void InvalidatePartsLinkMaps()
5535 {
5536 lock(m_partsNameToLinkMap)
5537 {
5538 m_partsNameToLinkMap.Clear();
5539 GetLinkNumber_lastname = String.Empty;
5540 GetLinkNumber_lastnumber = -1;
5541 }
5233 } 5542 }
5234 5543
5235 #endregion 5544 #endregion
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index b8ac089..19bf53f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -244,11 +244,6 @@ namespace OpenSim.Region.Framework.Scenes
244 244
245 public uint TimeStampTerse; 245 public uint TimeStampTerse;
246 246
247 // The following two are to hold the attachment data
248 // while an object is inworld
249 [XmlIgnore]
250 public byte AttachPoint = 0;
251
252 [XmlIgnore] 247 [XmlIgnore]
253 public Quaternion AttachRotation = Quaternion.Identity; 248 public Quaternion AttachRotation = Quaternion.Identity;
254 249
@@ -277,7 +272,11 @@ namespace OpenSim.Region.Framework.Scenes
277 272
278 public scriptEvents AggregateScriptEvents; 273 public scriptEvents AggregateScriptEvents;
279 274
280 public Vector3 AttachedPos; 275 public Vector3 AttachedPos
276 {
277 get;
278 set;
279 }
281 280
282 // rotation locks on local X,Y and or Z axis bit flags 281 // rotation locks on local X,Y and or Z axis bit flags
283 // bits are as in llSetStatus defined in SceneObjectGroup.axisSelect enum 282 // bits are as in llSetStatus defined in SceneObjectGroup.axisSelect enum
@@ -407,6 +406,8 @@ namespace OpenSim.Region.Framework.Scenes
407 406
408 private SOPVehicle m_vehicleParams = null; 407 private SOPVehicle m_vehicleParams = null;
409 408
409 private PhysicsInertiaData m_physicsInertia;
410
410 public KeyframeMotion KeyframeMotion 411 public KeyframeMotion KeyframeMotion
411 { 412 {
412 get; set; 413 get; set;
@@ -476,8 +477,8 @@ namespace OpenSim.Region.Framework.Scenes
476 APIDActive = false; 477 APIDActive = false;
477 Flags = 0; 478 Flags = 0;
478 CreateSelected = true; 479 CreateSelected = true;
479
480 TrimPermissions(); 480 TrimPermissions();
481 AggregateInnerPerms();
481 } 482 }
482 483
483 #endregion Constructors 484 #endregion Constructors
@@ -637,6 +638,8 @@ namespace OpenSim.Region.Framework.Scenes
637 set 638 set
638 { 639 {
639 m_name = value; 640 m_name = value;
641 if(ParentGroup != null)
642 ParentGroup.InvalidatePartsLinkMaps();
640 643
641 PhysicsActor pa = PhysActor; 644 PhysicsActor pa = PhysActor;
642 645
@@ -1063,7 +1066,7 @@ namespace OpenSim.Region.Framework.Scenes
1063 m_angularVelocity = value; 1066 m_angularVelocity = value;
1064 1067
1065 PhysicsActor actor = PhysActor; 1068 PhysicsActor actor = PhysActor;
1066 if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this && VehicleType == (int)Vehicle.TYPE_NONE) 1069 if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this)
1067 { 1070 {
1068 actor.RotationalVelocity = m_angularVelocity; 1071 actor.RotationalVelocity = m_angularVelocity;
1069 } 1072 }
@@ -1089,6 +1092,12 @@ namespace OpenSim.Region.Framework.Scenes
1089 m_acceleration = Vector3.Zero; 1092 m_acceleration = Vector3.Zero;
1090 else 1093 else
1091 m_acceleration = value; 1094 m_acceleration = value;
1095
1096 PhysicsActor actor = PhysActor;
1097 if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this)
1098 {
1099 actor.Acceleration = m_acceleration;
1100 }
1092 } 1101 }
1093 } 1102 }
1094 1103
@@ -2013,7 +2022,7 @@ namespace OpenSim.Region.Framework.Scenes
2013 // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future 2022 // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future
2014 public void SetVelocity(Vector3 pVel, bool localGlobalTF) 2023 public void SetVelocity(Vector3 pVel, bool localGlobalTF)
2015 { 2024 {
2016 if (ParentGroup == null || ParentGroup.IsDeleted) 2025 if (ParentGroup == null || ParentGroup.IsDeleted || ParentGroup.inTransit)
2017 return; 2026 return;
2018 2027
2019 if (ParentGroup.IsAttachment) 2028 if (ParentGroup.IsAttachment)
@@ -2040,7 +2049,7 @@ namespace OpenSim.Region.Framework.Scenes
2040 // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future 2049 // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future
2041 public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF) 2050 public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF)
2042 { 2051 {
2043 if (ParentGroup == null || ParentGroup.IsDeleted) 2052 if (ParentGroup == null || ParentGroup.IsDeleted || ParentGroup.inTransit)
2044 return; 2053 return;
2045 2054
2046 if (ParentGroup.IsAttachment) 2055 if (ParentGroup.IsAttachment)
@@ -2074,6 +2083,9 @@ namespace OpenSim.Region.Framework.Scenes
2074 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> 2083 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
2075 public void ApplyAngularImpulse(Vector3 impulsei, bool localGlobalTF) 2084 public void ApplyAngularImpulse(Vector3 impulsei, bool localGlobalTF)
2076 { 2085 {
2086 if (ParentGroup == null || ParentGroup.IsDeleted || ParentGroup.inTransit)
2087 return;
2088
2077 Vector3 impulse = impulsei; 2089 Vector3 impulse = impulsei;
2078 2090
2079 if (localGlobalTF) 2091 if (localGlobalTF)
@@ -2228,7 +2240,11 @@ namespace OpenSim.Region.Framework.Scenes
2228 dupe.LocalId = plocalID; 2240 dupe.LocalId = plocalID;
2229 2241
2230 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 2242 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
2231 dupe.LastOwnerID = OwnerID; 2243 if(OwnerID != GroupID)
2244 dupe.LastOwnerID = OwnerID;
2245 else
2246 dupe.LastOwnerID = LastOwnerID; // redundant ?
2247
2232 dupe.RezzerID = RezzerID; 2248 dupe.RezzerID = RezzerID;
2233 2249
2234 byte[] extraP = new byte[Shape.ExtraParams.Length]; 2250 byte[] extraP = new byte[Shape.ExtraParams.Length];
@@ -2537,6 +2553,35 @@ namespace OpenSim.Region.Framework.Scenes
2537 return (uint)Flags | (uint)LocalFlags; 2553 return (uint)Flags | (uint)LocalFlags;
2538 } 2554 }
2539 2555
2556 // some of this lines need be moved to other place later
2557
2558 // effective permitions considering only this part inventory contents perms
2559 public uint AggregatedInnerOwnerPerms {get; private set; }
2560 public uint AggregatedInnerGroupPerms {get; private set; }
2561 public uint AggregatedInnerEveryonePerms {get; private set; }
2562 private object InnerPermsLock = new object();
2563
2564 public void AggregateInnerPerms()
2565 {
2566 // assuming child prims permissions masks are irrelevant on a linkset
2567 // root part is handle at SOG since its masks are the sog masks
2568 const uint mask = (uint)PermissionMask.AllEffective;
2569
2570 uint owner = mask;
2571 uint group = mask;
2572 uint everyone = mask;
2573
2574 lock(InnerPermsLock) // do we really need this?
2575 {
2576 if(Inventory != null)
2577 Inventory.AggregateInnerPerms(ref owner, ref group, ref everyone);
2578
2579 AggregatedInnerOwnerPerms = owner & mask;
2580 AggregatedInnerGroupPerms = group & mask;
2581 AggregatedInnerEveryonePerms = everyone & mask;
2582 }
2583 }
2584
2540 public Vector3 GetGeometricCenter() 2585 public Vector3 GetGeometricCenter()
2541 { 2586 {
2542 // this is not real geometric center but a average of positions relative to root prim acording to 2587 // this is not real geometric center but a average of positions relative to root prim acording to
@@ -3340,25 +3385,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
3340 /// <param name="remoteClient"></param> 3385 /// <param name="remoteClient"></param>
3341 public void SendFullUpdateToClient(IClientAPI remoteClient) 3386 public void SendFullUpdateToClient(IClientAPI remoteClient)
3342 { 3387 {
3343 SendFullUpdateToClient(remoteClient, OffsetPosition); 3388 if (ParentGroup == null || ParentGroup.IsDeleted)
3344 }
3345
3346 /// <summary>
3347 /// Sends a full update to the client
3348 /// </summary>
3349 /// <param name="remoteClient"></param>
3350 /// <param name="lPos"></param>
3351 public void SendFullUpdateToClient(IClientAPI remoteClient, Vector3 lPos)
3352 {
3353 if (ParentGroup == null)
3354 return;
3355
3356 // Suppress full updates during attachment editing
3357 // sl Does send them
3358 // if (ParentGroup.IsSelected && ParentGroup.IsAttachment)
3359 // return;
3360
3361 if (ParentGroup.IsDeleted)
3362 return; 3389 return;
3363 3390
3364 if (ParentGroup.IsAttachment 3391 if (ParentGroup.IsAttachment
@@ -3516,6 +3543,18 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
3516 Force = force; 3543 Force = force;
3517 } 3544 }
3518 3545
3546 public PhysicsInertiaData PhysicsInertia
3547 {
3548 get
3549 {
3550 return m_physicsInertia;
3551 }
3552 set
3553 {
3554 m_physicsInertia = value;
3555 }
3556 }
3557
3519 public SOPVehicle VehicleParams 3558 public SOPVehicle VehicleParams
3520 { 3559 {
3521 get 3560 get
@@ -3689,7 +3728,18 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
3689 bool hasDimple; 3728 bool hasDimple;
3690 bool hasProfileCut; 3729 bool hasProfileCut;
3691 3730
3692 PrimType primType = GetPrimType(); 3731 if(Shape.SculptEntry)
3732 {
3733 if (Shape.SculptType != (byte)SculptType.Mesh)
3734 return 1; // sculp
3735
3736 //hack to detect new upload with faces data enconded on pbs
3737 if ((Shape.ProfileCurve & 0xf0) != (byte)HollowShape.Triangle)
3738 // old broken upload TODO
3739 return 8;
3740 }
3741
3742 PrimType primType = GetPrimType(true);
3693 HasCutHollowDimpleProfileCut(primType, Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); 3743 HasCutHollowDimpleProfileCut(primType, Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
3694 3744
3695 switch (primType) 3745 switch (primType)
@@ -3733,13 +3783,6 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
3733 if (hasProfileCut) ret += 2; 3783 if (hasProfileCut) ret += 2;
3734 if (hasHollow) ret += 1; 3784 if (hasHollow) ret += 1;
3735 break; 3785 break;
3736 case PrimType.SCULPT:
3737 // Special mesh handling
3738 if (Shape.SculptType == (byte)SculptType.Mesh)
3739 ret = 8; // if it's a mesh then max 8 faces
3740 else
3741 ret = 1; // if it's a sculpt then max 1 face
3742 break;
3743 } 3786 }
3744 3787
3745 return ret; 3788 return ret;
@@ -3750,9 +3793,9 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
3750 /// </summary> 3793 /// </summary>
3751 /// <param name="primShape"></param> 3794 /// <param name="primShape"></param>
3752 /// <returns></returns> 3795 /// <returns></returns>
3753 public PrimType GetPrimType() 3796 public PrimType GetPrimType(bool ignoreSculpt = false)
3754 { 3797 {
3755 if (Shape.SculptEntry) 3798 if (Shape.SculptEntry && !ignoreSculpt)
3756 return PrimType.SCULPT; 3799 return PrimType.SCULPT;
3757 3800
3758 if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) 3801 if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
@@ -4464,7 +4507,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
4464 4507
4465 break; 4508 break;
4466 } 4509 }
4467 4510 AggregateInnerPerms();
4468 SendFullUpdateToAllClients(); 4511 SendFullUpdateToAllClients();
4469 } 4512 }
4470 } 4513 }
@@ -4481,6 +4524,8 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
4481 EveryoneMask = source.EveryoneMask & BaseMask; 4524 EveryoneMask = source.EveryoneMask & BaseMask;
4482 NextOwnerMask = source.NextOwnerMask & BaseMask; 4525 NextOwnerMask = source.NextOwnerMask & BaseMask;
4483 4526
4527 AggregateInnerPerms();
4528
4484 if (OwnerMask != prevOwnerMask || 4529 if (OwnerMask != prevOwnerMask ||
4485 GroupMask != prevGroupMask || 4530 GroupMask != prevGroupMask ||
4486 EveryoneMask != prevEveryoneMask || 4531 EveryoneMask != prevEveryoneMask ||
@@ -4714,8 +4759,13 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
4714 4759
4715 if (VolumeDetectActive) // change if not the default only 4760 if (VolumeDetectActive) // change if not the default only
4716 pa.SetVolumeDetect(1); 4761 pa.SetVolumeDetect(1);
4762
4763 bool isroot = (m_localId == ParentGroup.RootPart.LocalId);
4717 4764
4718 if (m_vehicleParams != null && m_localId == ParentGroup.RootPart.LocalId) 4765 if(isroot && m_physicsInertia != null)
4766 pa.SetInertiaData(m_physicsInertia);
4767
4768 if (isroot && m_vehicleParams != null )
4719 { 4769 {
4720 m_vehicleParams.SetVehicle(pa); 4770 m_vehicleParams.SetVehicle(pa);
4721 if(isPhysical && !isPhantom && m_vehicleParams.CameraDecoupled) 4771 if(isPhysical && !isPhantom && m_vehicleParams.CameraDecoupled)
@@ -5181,7 +5231,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
5181 /// <param name="scene">The scene the prim is being rezzed into</param> 5231 /// <param name="scene">The scene the prim is being rezzed into</param>
5182 public void ApplyPermissionsOnRez(InventoryItemBase item, bool userInventory, Scene scene) 5232 public void ApplyPermissionsOnRez(InventoryItemBase item, bool userInventory, Scene scene)
5183 { 5233 {
5184 if ((OwnerID != item.Owner) || ((item.CurrentPermissions & SceneObjectGroup.SLAM) != 0) || ((item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)) 5234 if ((OwnerID != item.Owner) || ((item.CurrentPermissions & (uint)PermissionMask.Slam) != 0) || ((item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0))
5185 { 5235 {
5186 if (scene.Permissions.PropagatePermissions()) 5236 if (scene.Permissions.PropagatePermissions())
5187 { 5237 {
@@ -5212,16 +5262,13 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
5212 5262
5213 if (OwnerID != item.Owner) 5263 if (OwnerID != item.Owner)
5214 { 5264 {
5215 //LogPermissions("Before ApplyNextOwnerPermissions"); 5265 if(OwnerID != GroupID)
5266 LastOwnerID = OwnerID;
5267 OwnerID = item.Owner;
5268 Inventory.ChangeInventoryOwner(item.Owner);
5216 5269
5217 if (scene.Permissions.PropagatePermissions()) 5270 if (scene.Permissions.PropagatePermissions())
5218 ApplyNextOwnerPermissions(); 5271 ApplyNextOwnerPermissions();
5219
5220 //LogPermissions("After ApplyNextOwnerPermissions");
5221
5222 LastOwnerID = OwnerID;
5223 OwnerID = item.Owner;
5224 Inventory.ChangeInventoryOwner(item.Owner);
5225 } 5272 }
5226 } 5273 }
5227 5274
@@ -5245,6 +5292,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
5245 GroupMask = 0; // Giving an object zaps group permissions 5292 GroupMask = 0; // Giving an object zaps group permissions
5246 5293
5247 Inventory.ApplyNextOwnerPermissions(); 5294 Inventory.ApplyNextOwnerPermissions();
5295 AggregateInnerPerms();
5248 } 5296 }
5249 5297
5250 public void UpdateLookAt() 5298 public void UpdateLookAt()
@@ -5306,6 +5354,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
5306 item.OwnerChanged = false; 5354 item.OwnerChanged = false;
5307 Inventory.UpdateInventoryItem(item, false, false); 5355 Inventory.UpdateInventoryItem(item, false, false);
5308 } 5356 }
5357 AggregateInnerPerms();
5309 } 5358 }
5310 5359
5311 /// <summary> 5360 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 6557003..b53c355 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -360,7 +360,7 @@ namespace OpenSim.Region.Framework.Scenes
360// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}", 360// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}",
361// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); 361// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName);
362 362
363 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 363 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item, m_part))
364 { 364 {
365 StoreScriptError(item.ItemID, "no permission"); 365 StoreScriptError(item.ItemID, "no permission");
366 return false; 366 return false;
@@ -807,6 +807,7 @@ namespace OpenSim.Region.Framework.Scenes
807 else 807 else
808 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 808 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
809 809
810 m_part.AggregateInnerPerms();
810 m_inventorySerial++; 811 m_inventorySerial++;
811 //m_inventorySerial += 2; 812 //m_inventorySerial += 2;
812 HasInventoryChanged = true; 813 HasInventoryChanged = true;
@@ -829,7 +830,7 @@ namespace OpenSim.Region.Framework.Scenes
829// m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 830// m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
830 } 831 }
831 m_items.LockItemsForWrite(false); 832 m_items.LockItemsForWrite(false);
832 833 m_part.AggregateInnerPerms();
833 m_inventorySerial++; 834 m_inventorySerial++;
834 } 835 }
835 836
@@ -943,8 +944,7 @@ namespace OpenSim.Region.Framework.Scenes
943 944
944 group.SetGroup(m_part.GroupID, null); 945 group.SetGroup(m_part.GroupID, null);
945 946
946 // TODO: Remove magic number badness 947 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
947 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number
948 { 948 {
949 if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) 949 if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions())
950 { 950 {
@@ -964,10 +964,10 @@ namespace OpenSim.Region.Framework.Scenes
964 964
965 foreach (SceneObjectPart part in partList) 965 foreach (SceneObjectPart part in partList)
966 { 966 {
967 // TODO: Remove magic number badness 967 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
968 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number
969 { 968 {
970 part.LastOwnerID = part.OwnerID; 969 if(part.GroupID != part.OwnerID)
970 part.LastOwnerID = part.OwnerID;
971 part.OwnerID = item.OwnerID; 971 part.OwnerID = item.OwnerID;
972 part.Inventory.ChangeInventoryOwner(item.OwnerID); 972 part.Inventory.ChangeInventoryOwner(item.OwnerID);
973 } 973 }
@@ -981,6 +981,7 @@ namespace OpenSim.Region.Framework.Scenes
981 } 981 }
982// old code end 982// old code end
983 rootPart.TrimPermissions(); 983 rootPart.TrimPermissions();
984 group.AggregateDeepPerms();
984 } 985 }
985 986
986 return true; 987 return true;
@@ -1022,16 +1023,20 @@ namespace OpenSim.Region.Framework.Scenes
1022 item.AssetID = m_items[item.ItemID].AssetID; 1023 item.AssetID = m_items[item.ItemID].AssetID;
1023 1024
1024 m_items[item.ItemID] = item; 1025 m_items[item.ItemID] = item;
1026
1025 m_inventorySerial++; 1027 m_inventorySerial++;
1026 if (fireScriptEvents) 1028 if (fireScriptEvents)
1027 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 1029 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
1028 1030
1029 if (considerChanged) 1031 if (considerChanged)
1030 { 1032 {
1033 m_part.AggregateInnerPerms();
1034 m_part.ParentGroup.AggregatePerms();
1031 HasInventoryChanged = true; 1035 HasInventoryChanged = true;
1032 m_part.ParentGroup.HasGroupChanged = true; 1036 m_part.ParentGroup.HasGroupChanged = true;
1033 } 1037 }
1034 m_items.LockItemsForWrite(false); 1038 m_items.LockItemsForWrite(false);
1039
1035 return true; 1040 return true;
1036 } 1041 }
1037 else 1042 else
@@ -1068,6 +1073,10 @@ namespace OpenSim.Region.Framework.Scenes
1068 m_items.LockItemsForWrite(true); 1073 m_items.LockItemsForWrite(true);
1069 m_items.Remove(itemID); 1074 m_items.Remove(itemID);
1070 m_items.LockItemsForWrite(false); 1075 m_items.LockItemsForWrite(false);
1076
1077 m_part.AggregateInnerPerms();
1078 m_part.ParentGroup.AggregatePerms();
1079
1071 m_inventorySerial++; 1080 m_inventorySerial++;
1072 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 1081 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
1073 1082
@@ -1170,7 +1179,7 @@ namespace OpenSim.Region.Framework.Scenes
1170 foreach (TaskInventoryItem item in m_items.Values) 1179 foreach (TaskInventoryItem item in m_items.Values)
1171 { 1180 {
1172 UUID ownerID = item.OwnerID; 1181 UUID ownerID = item.OwnerID;
1173 uint everyoneMask = 0; 1182 uint everyoneMask = item.EveryonePermissions;
1174 uint baseMask = item.BasePermissions; 1183 uint baseMask = item.BasePermissions;
1175 uint ownerMask = item.CurrentPermissions; 1184 uint ownerMask = item.CurrentPermissions;
1176 uint groupMask = item.GroupPermissions; 1185 uint groupMask = item.GroupPermissions;
@@ -1319,6 +1328,16 @@ namespace OpenSim.Region.Framework.Scenes
1319 } 1328 }
1320 } 1329 }
1321 1330
1331 public void AggregateInnerPerms(ref uint owner, ref uint group, ref uint everyone)
1332 {
1333 foreach (TaskInventoryItem item in m_items.Values)
1334 {
1335 owner &= item.CurrentPermissions;
1336 group &= item.GroupPermissions;
1337 everyone &= item.EveryonePermissions;
1338 }
1339 }
1340
1322 public uint MaskEffectivePermissions() 1341 public uint MaskEffectivePermissions()
1323 { 1342 {
1324 uint mask=0x7fffffff; 1343 uint mask=0x7fffffff;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 9545c13..6d4cb52 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1778,6 +1778,20 @@ namespace OpenSim.Region.Framework.Scenes
1778 1778
1779 private Dictionary<ulong, spRegionSizeInfo> m_knownChildRegionsSizeInfo = new Dictionary<ulong, spRegionSizeInfo>(); 1779 private Dictionary<ulong, spRegionSizeInfo> m_knownChildRegionsSizeInfo = new Dictionary<ulong, spRegionSizeInfo>();
1780 1780
1781 public void AddNeighbourRegion(GridRegion region, string capsPath)
1782 {
1783 lock (m_knownChildRegions)
1784 {
1785 ulong regionHandle = region.RegionHandle;
1786 m_knownChildRegions.Add(regionHandle,capsPath);
1787
1788 spRegionSizeInfo sizeInfo = new spRegionSizeInfo();
1789 sizeInfo.sizeX = region.RegionSizeX;
1790 sizeInfo.sizeY = region.RegionSizeY;
1791 m_knownChildRegionsSizeInfo[regionHandle] = sizeInfo;
1792 }
1793 }
1794
1781 public void AddNeighbourRegionSizeInfo(GridRegion region) 1795 public void AddNeighbourRegionSizeInfo(GridRegion region)
1782 { 1796 {
1783 lock (m_knownChildRegions) 1797 lock (m_knownChildRegions)
@@ -1826,6 +1840,12 @@ namespace OpenSim.Region.Framework.Scenes
1826 } 1840 }
1827 } 1841 }
1828 1842
1843 public bool knowsNeighbourRegion(ulong regionHandle)
1844 {
1845 lock (m_knownChildRegions)
1846 return m_knownChildRegions.ContainsKey(regionHandle);
1847 }
1848
1829 public void DropOldNeighbours(List<ulong> oldRegions) 1849 public void DropOldNeighbours(List<ulong> oldRegions)
1830 { 1850 {
1831 foreach (ulong handle in oldRegions) 1851 foreach (ulong handle in oldRegions)
@@ -2010,6 +2030,7 @@ namespace OpenSim.Region.Framework.Scenes
2010 return; 2030 return;
2011 } 2031 }
2012 2032
2033
2013 m_log.DebugFormat("[CompleteMovement] MakeRootAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 2034 m_log.DebugFormat("[CompleteMovement] MakeRootAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2014 2035
2015 if(!haveGroupInformation && !IsChildAgent && !IsNPC) 2036 if(!haveGroupInformation && !IsChildAgent && !IsNPC)
@@ -2029,11 +2050,6 @@ namespace OpenSim.Region.Framework.Scenes
2029 m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF); 2050 m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF);
2030 } 2051 }
2031 2052
2032 // Tell the client that we're totally ready
2033 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
2034
2035 m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2036
2037 if (!string.IsNullOrEmpty(m_callbackURI)) 2053 if (!string.IsNullOrEmpty(m_callbackURI))
2038 { 2054 {
2039 // We cannot sleep here since this would hold up the inbound packet processing thread, as 2055 // We cannot sleep here since this would hold up the inbound packet processing thread, as
@@ -2054,6 +2070,7 @@ namespace OpenSim.Region.Framework.Scenes
2054 2070
2055 Scene.SimulationService.ReleaseAgent(originID, UUID, m_callbackURI); 2071 Scene.SimulationService.ReleaseAgent(originID, UUID, m_callbackURI);
2056 m_callbackURI = null; 2072 m_callbackURI = null;
2073 m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2057 } 2074 }
2058// else 2075// else
2059// { 2076// {
@@ -2062,19 +2079,58 @@ namespace OpenSim.Region.Framework.Scenes
2062// client.Name, client.AgentId, m_scene.RegionInfo.RegionName); 2079// client.Name, client.AgentId, m_scene.RegionInfo.RegionName);
2063// } 2080// }
2064 2081
2065 m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 2082
2083 // Tell the client that we're totally ready
2084 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
2085 m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2086
2087 bool isHGTP = (m_teleportFlags & TeleportFlags.ViaHGLogin) != 0;
2088
2089 int delayctnr = Util.EnvironmentTickCount();
2090
2091 if (!IsChildAgent)
2092 {
2093 if( ParentPart != null && !IsNPC && (crossingFlags & 0x08) != 0)
2094 {
2095
2096// SceneObjectPart root = ParentPart.ParentGroup.RootPart;
2097// if(root.LocalId != ParentPart.LocalId)
2098// ControllingClient.SendEntityTerseUpdateImmediate(root);
2099// ControllingClient.SendEntityTerseUpdateImmediate(ParentPart);
2100 ParentPart.ParentGroup.SendFullUpdateToClient(ControllingClient);
2101 }
2102
2103 // verify baked textures and cache
2104 bool cachedbaked = false;
2105
2106 if (IsNPC)
2107 cachedbaked = true;
2108 else
2109 {
2110 if (m_scene.AvatarFactory != null && !isHGTP)
2111 cachedbaked = m_scene.AvatarFactory.ValidateBakedTextureCache(this);
2112
2113 // not sure we need this
2114 if (!cachedbaked)
2115 {
2116 if (m_scene.AvatarFactory != null)
2117 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
2118 }
2119 }
2120 m_log.DebugFormat("[CompleteMovement] Baked check: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2121 }
2066 2122
2067 if(m_teleportFlags > 0) 2123 if(m_teleportFlags > 0)
2068 { 2124 {
2069 gotCrossUpdate = false; // sanity check 2125 gotCrossUpdate = false; // sanity check
2070 Thread.Sleep(500); // let viewers catch us 2126 if(Util.EnvironmentTickCountSubtract(delayctnr)< 500)
2127 Thread.Sleep(500); // let viewers catch us
2071 } 2128 }
2072 2129
2073 if(!gotCrossUpdate) 2130 if(!gotCrossUpdate)
2074 RotateToLookAt(look); 2131 RotateToLookAt(look);
2075 2132
2076 // HG 2133 // HG
2077 bool isHGTP = (m_teleportFlags & TeleportFlags.ViaHGLogin) != 0;
2078 if(isHGTP) 2134 if(isHGTP)
2079 { 2135 {
2080// ControllingClient.SendNameReply(m_uuid, Firstname, Lastname); 2136// ControllingClient.SendNameReply(m_uuid, Firstname, Lastname);
@@ -2101,28 +2157,11 @@ namespace OpenSim.Region.Framework.Scenes
2101 2157
2102 if (!IsChildAgent) 2158 if (!IsChildAgent)
2103 { 2159 {
2104 // verify baked textures and cache
2105 bool cachedbaked = false;
2106
2107 if (IsNPC)
2108 cachedbaked = true;
2109 else
2110 {
2111 if (m_scene.AvatarFactory != null && !isHGTP)
2112 cachedbaked = m_scene.AvatarFactory.ValidateBakedTextureCache(this);
2113
2114 // not sure we need this
2115 if (!cachedbaked)
2116 {
2117 if (m_scene.AvatarFactory != null)
2118 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
2119 }
2120 }
2121
2122 List<ScenePresence> allpresences = m_scene.GetScenePresences(); 2160 List<ScenePresence> allpresences = m_scene.GetScenePresences();
2123 2161
2124 // send avatar object to all presences including us, so they cross it into region 2162 // send avatar object to all presences including us, so they cross it into region
2125 // then hide if necessary 2163 // then hide if necessary
2164
2126 SendInitialAvatarDataToAllAgents(allpresences); 2165 SendInitialAvatarDataToAllAgents(allpresences);
2127 2166
2128 // send this look 2167 // send this look
@@ -2230,13 +2269,18 @@ namespace OpenSim.Region.Framework.Scenes
2230 m_lastChildAgentUpdateDrawDistance = DrawDistance; 2269 m_lastChildAgentUpdateDrawDistance = DrawDistance;
2231 m_lastChildAgentUpdatePosition = AbsolutePosition; 2270 m_lastChildAgentUpdatePosition = AbsolutePosition;
2232 m_childUpdatesBusy = false; // allow them 2271 m_childUpdatesBusy = false; // allow them
2272
2273
2233 } 2274 }
2234 2275
2235 m_log.DebugFormat("[CompleteMovement] openChildAgents: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 2276 m_log.DebugFormat("[CompleteMovement] openChildAgents: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2236 2277
2278
2279
2237 // send the rest of the world 2280 // send the rest of the world
2238 if (m_teleportFlags > 0 && !IsNPC || m_currentParcelHide) 2281 if (m_teleportFlags > 0 && !IsNPC || m_currentParcelHide)
2239 SendInitialDataToMe(); 2282 SendInitialDataToMe();
2283
2240 2284
2241 // priority uses avatar position only 2285 // priority uses avatar position only
2242// m_reprioritizationLastPosition = AbsolutePosition; 2286// m_reprioritizationLastPosition = AbsolutePosition;
@@ -3110,6 +3154,7 @@ namespace OpenSim.Region.Framework.Scenes
3110 3154
3111 Vector3 standPos = sitPartWorldPosition + adjustmentForSitPose; 3155 Vector3 standPos = sitPartWorldPosition + adjustmentForSitPose;
3112 m_pos = standPos; 3156 m_pos = standPos;
3157
3113 } 3158 }
3114 3159
3115 // We need to wait until we have calculated proper stand positions before sitting up the physical 3160 // We need to wait until we have calculated proper stand positions before sitting up the physical
@@ -3124,6 +3169,7 @@ namespace OpenSim.Region.Framework.Scenes
3124 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 3169 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
3125 3170
3126 SendAvatarDataToAllAgents(); 3171 SendAvatarDataToAllAgents();
3172 m_scene.EventManager.TriggerParcelPrimCountTainted(); // update select/ sat on
3127 } 3173 }
3128 3174
3129 // reset to default sitAnimation 3175 // reset to default sitAnimation
@@ -3256,6 +3302,7 @@ namespace OpenSim.Region.Framework.Scenes
3256 // Moved here to avoid a race with default sit anim 3302 // Moved here to avoid a race with default sit anim
3257 // The script event needs to be raised after the default sit anim is set. 3303 // The script event needs to be raised after the default sit anim is set.
3258 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 3304 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
3305 m_scene.EventManager.TriggerParcelPrimCountTainted(); // update select/ sat on
3259 } 3306 }
3260 } 3307 }
3261 3308
@@ -3405,6 +3452,7 @@ namespace OpenSim.Region.Framework.Scenes
3405 3452
3406 Animator.SetMovementAnimations("SIT"); 3453 Animator.SetMovementAnimations("SIT");
3407 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 3454 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
3455 m_scene.EventManager.TriggerParcelPrimCountTainted(); // update select/ sat on
3408 } 3456 }
3409 3457
3410 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) 3458 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
@@ -3968,7 +4016,7 @@ namespace OpenSim.Region.Framework.Scenes
3968 int count = 0; 4016 int count = 0;
3969 foreach (ScenePresence p in presences) 4017 foreach (ScenePresence p in presences)
3970 { 4018 {
3971 p.ControllingClient.SendAvatarDataImmediate(this); 4019 p.ControllingClient.SendEntityFullUpdateImmediate(this);
3972 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.IsViewerUIGod) 4020 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.IsViewerUIGod)
3973 // either just kill the object 4021 // either just kill the object
3974 // p.ControllingClient.SendKillObject(new List<uint> {LocalId}); 4022 // p.ControllingClient.SendKillObject(new List<uint> {LocalId});
@@ -3981,7 +4029,7 @@ namespace OpenSim.Region.Framework.Scenes
3981 4029
3982 public void SendInitialAvatarDataToAgent(ScenePresence p) 4030 public void SendInitialAvatarDataToAgent(ScenePresence p)
3983 { 4031 {
3984 p.ControllingClient.SendAvatarDataImmediate(this); 4032 p.ControllingClient.SendEntityFullUpdateImmediate(this);
3985 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.IsViewerUIGod) 4033 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.IsViewerUIGod)
3986 // either just kill the object 4034 // either just kill the object
3987 // p.ControllingClient.SendKillObject(new List<uint> {LocalId}); 4035 // p.ControllingClient.SendKillObject(new List<uint> {LocalId});
@@ -3998,12 +4046,12 @@ namespace OpenSim.Region.Framework.Scenes
3998 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); 4046 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID);
3999 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && !avatar.IsViewerUIGod) 4047 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && !avatar.IsViewerUIGod)
4000 return; 4048 return;
4001 avatar.ControllingClient.SendAvatarDataImmediate(this); 4049 avatar.ControllingClient.SendEntityFullUpdateImmediate(this);
4002 } 4050 }
4003 4051
4004 public void SendAvatarDataToAgentNF(ScenePresence avatar) 4052 public void SendAvatarDataToAgentNF(ScenePresence avatar)
4005 { 4053 {
4006 avatar.ControllingClient.SendAvatarDataImmediate(this); 4054 avatar.ControllingClient.SendEntityFullUpdateImmediate(this);
4007 } 4055 }
4008 4056
4009 /// <summary> 4057 /// <summary>
@@ -6440,7 +6488,7 @@ namespace OpenSim.Region.Framework.Scenes
6440 if (check) 6488 if (check)
6441 { 6489 {
6442 // check is relative to current parcel only 6490 // check is relative to current parcel only
6443 if (currentParcelUUID == null || oldhide == currentParcelHide) 6491 if (oldhide == currentParcelHide)
6444 return; 6492 return;
6445 6493
6446 allpresences = m_scene.GetScenePresences(); 6494 allpresences = m_scene.GetScenePresences();
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index b8d210c..87d1ace 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -114,7 +114,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
114 // Script state may, or may not, exist. Not having any, is NOT 114 // Script state may, or may not, exist. Not having any, is NOT
115 // ever a problem. 115 // ever a problem.
116 sceneObject.LoadScriptState(reader); 116 sceneObject.LoadScriptState(reader);
117 117 sceneObject.AggregateDeepPerms();
118 return sceneObject; 118 return sceneObject;
119 } 119 }
120 120
@@ -278,7 +278,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
278 // Script state may, or may not, exist. Not having any, is NOT 278 // Script state may, or may not, exist. Not having any, is NOT
279 // ever a problem. 279 // ever a problem.
280 sceneObject.LoadScriptState(doc); 280 sceneObject.LoadScriptState(doc);
281 281 sceneObject.AggregatePerms();
282 return sceneObject; 282 return sceneObject;
283 } 283 }
284 catch (Exception e) 284 catch (Exception e)
@@ -453,9 +453,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
453 m_SOPXmlProcessors.Add("Torque", ProcessTorque); 453 m_SOPXmlProcessors.Add("Torque", ProcessTorque);
454 m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); 454 m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive);
455 455
456
457 m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); 456 m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle);
458 457
458 m_SOPXmlProcessors.Add("PhysicsInertia", ProcessPhysicsInertia);
459
459 m_SOPXmlProcessors.Add("RotationAxisLocks", ProcessRotationAxisLocks); 460 m_SOPXmlProcessors.Add("RotationAxisLocks", ProcessRotationAxisLocks);
460 m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); 461 m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType);
461 m_SOPXmlProcessors.Add("Density", ProcessDensity); 462 m_SOPXmlProcessors.Add("Density", ProcessDensity);
@@ -781,6 +782,23 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
781 } 782 }
782 } 783 }
783 784
785 private static void ProcessPhysicsInertia(SceneObjectPart obj, XmlReader reader)
786 {
787 PhysicsInertiaData pdata = PhysicsInertiaData.FromXml2(reader);
788
789 if (pdata == null)
790 {
791 obj.PhysicsInertia = null;
792 m_log.DebugFormat(
793 "[SceneObjectSerializer]: Parsing PhysicsInertiaData for object part {0} {1} encountered errors. Please see earlier log entries.",
794 obj.Name, obj.UUID);
795 }
796 else
797 {
798 obj.PhysicsInertia = pdata;
799 }
800 }
801
784 private static void ProcessShape(SceneObjectPart obj, XmlReader reader) 802 private static void ProcessShape(SceneObjectPart obj, XmlReader reader)
785 { 803 {
786 List<string> errorNodeNames; 804 List<string> errorNodeNames;
@@ -1498,6 +1516,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1498 if (sop.VehicleParams != null) 1516 if (sop.VehicleParams != null)
1499 sop.VehicleParams.ToXml2(writer); 1517 sop.VehicleParams.ToXml2(writer);
1500 1518
1519 if (sop.PhysicsInertia != null)
1520 sop.PhysicsInertia.ToXml2(writer);
1521
1501 if(sop.RotationAxisLocks != 0) 1522 if(sop.RotationAxisLocks != 0)
1502 writer.WriteElementString("RotationAxisLocks", sop.RotationAxisLocks.ToString().ToLower()); 1523 writer.WriteElementString("RotationAxisLocks", sop.RotationAxisLocks.ToString().ToLower());
1503 writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); 1524 writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower());
@@ -1739,6 +1760,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1739 1760
1740 reader.ReadEndElement(); // SceneObjectPart 1761 reader.ReadEndElement(); // SceneObjectPart
1741 1762
1763 obj.AggregateInnerPerms();
1742 // m_log.DebugFormat("[SceneObjectSerializer]: parsed SOP {0} {1}", obj.Name, obj.UUID); 1764 // m_log.DebugFormat("[SceneObjectSerializer]: parsed SOP {0} {1}", obj.Name, obj.UUID);
1743 return obj; 1765 return obj;
1744 } 1766 }
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
index 01bc491..0f022dd 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
@@ -70,6 +70,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
70 //obj.RegenerateFullIDs(); 70 //obj.RegenerateFullIDs();
71 71
72 scene.AddNewSceneObject(obj, true); 72 scene.AddNewSceneObject(obj, true);
73 obj.AggregateDeepPerms();
73 } 74 }
74 } 75 }
75 else 76 else
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
index 56723bf..4d2eb3f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
67 67
68 SceneObjectGroup dupeSo 68 SceneObjectGroup dupeSo
69 = scene.SceneGraph.DuplicateObject( 69 = scene.SceneGraph.DuplicateObject(
70 part1.LocalId, new Vector3(10, 0, 0), 0, ownerId, UUID.Zero, Quaternion.Identity); 70 part1.LocalId, new Vector3(10, 0, 0), ownerId, UUID.Zero, Quaternion.Identity, false);
71 Assert.That(dupeSo.Parts.Length, Is.EqualTo(2)); 71 Assert.That(dupeSo.Parts.Length, Is.EqualTo(2));
72 72
73 SceneObjectPart dupePart1 = dupeSo.GetLinkNumPart(1); 73 SceneObjectPart dupePart1 = dupeSo.GetLinkNumPart(1);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
index e1e973c..abf8c48 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
@@ -157,29 +157,28 @@ namespace OpenSim.Region.Framework.Scenes.Tests
157 157
158 // Cross 158 // Cross
159 sceneA.SceneGraph.UpdatePrimGroupPosition( 159 sceneA.SceneGraph.UpdatePrimGroupPosition(
160 so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), userId); 160 so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), sp1SceneA.ControllingClient);
161 161
162 // crossing is async 162 // crossing is async
163 Thread.Sleep(500); 163 Thread.Sleep(500);
164 164
165 SceneObjectGroup so1PostCross; 165 SceneObjectGroup so1PostCross;
166 166
167 { 167 ScenePresence sp1SceneAPostCross = sceneA.GetScenePresence(userId);
168 ScenePresence sp1SceneAPostCross = sceneA.GetScenePresence(userId); 168 Assert.IsTrue(sp1SceneAPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly false");
169 Assert.IsTrue(sp1SceneAPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly false");
170 169
171 ScenePresence sp1SceneBPostCross = sceneB.GetScenePresence(userId); 170 ScenePresence sp1SceneBPostCross = sceneB.GetScenePresence(userId);
172 TestClient sceneBTc = ((TestClient)sp1SceneBPostCross.ControllingClient); 171 TestClient sceneBTc = ((TestClient)sp1SceneBPostCross.ControllingClient);
173 sceneBTc.CompleteMovement(); 172 sceneBTc.CompleteMovement();
174 173
175 Assert.IsFalse(sp1SceneBPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true"); 174 Assert.IsFalse(sp1SceneBPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
176 Assert.IsTrue(sp1SceneBPostCross.IsSatOnObject); 175 Assert.IsTrue(sp1SceneBPostCross.IsSatOnObject);
176
177 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id), "uck");
178 so1PostCross = sceneB.GetSceneObjectGroup(so1Id);
179 Assert.NotNull(so1PostCross);
180 Assert.AreEqual(1, so1PostCross.GetSittingAvatarsCount());
177 181
178 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id), "uck");
179 so1PostCross = sceneB.GetSceneObjectGroup(so1Id);
180 Assert.NotNull(so1PostCross);
181 Assert.AreEqual(1, so1PostCross.GetSittingAvatarsCount());
182 }
183 182
184 Vector3 so1PostCrossPos = so1PostCross.AbsolutePosition; 183 Vector3 so1PostCrossPos = so1PostCross.AbsolutePosition;
185 184
@@ -187,7 +186,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
187 186
188 // Recross 187 // Recross
189 sceneB.SceneGraph.UpdatePrimGroupPosition( 188 sceneB.SceneGraph.UpdatePrimGroupPosition(
190 so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), userId); 189 so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), sp1SceneBPostCross.ControllingClient);
191 190
192 // crossing is async 191 // crossing is async
193 Thread.Sleep(500); 192 Thread.Sleep(500);
@@ -255,13 +254,19 @@ namespace OpenSim.Region.Framework.Scenes.Tests
255 lmmA.EventManagerOnNoLandDataFromStorage(); 254 lmmA.EventManagerOnNoLandDataFromStorage();
256 lmmB.EventManagerOnNoLandDataFromStorage(); 255 lmmB.EventManagerOnNoLandDataFromStorage();
257 256
257 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
258 TestClient tc = new TestClient(acd, sceneA);
259 List<TestClient> destinationTestClients = new List<TestClient>();
260 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
261 ScenePresence sp1SceneA = SceneHelpers.AddScenePresence(sceneA, tc, acd);
262
258 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail); 263 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
259 UUID so1Id = so1.UUID; 264 UUID so1Id = so1.UUID;
260 so1.AbsolutePosition = new Vector3(128, 10, 20); 265 so1.AbsolutePosition = new Vector3(128, 10, 20);
261 266
262 // Cross with a negative value. We must make this call rather than setting AbsolutePosition directly 267 // Cross with a negative value. We must make this call rather than setting AbsolutePosition directly
263 // because only this will execute permission checks in the source region. 268 // because only this will execute permission checks in the source region.
264 sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), userId); 269 sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), sp1SceneA.ControllingClient);
265 270
266 // crossing is async 271 // crossing is async
267 Thread.Sleep(500); 272 Thread.Sleep(500);
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 83b534b..d39c224 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -1097,7 +1097,12 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1097 1097
1098 } 1098 }
1099 1099
1100 public void SendAvatarDataImmediate(ISceneEntity avatar) 1100 public void SendEntityFullUpdateImmediate(ISceneEntity ent)
1101 {
1102
1103 }
1104
1105 public void SendEntityTerseUpdateImmediate(ISceneEntity ent)
1101 { 1106 {
1102 1107
1103 } 1108 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
index ed27385..92b5831 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
@@ -134,11 +134,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
134 private int llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint) 134 private int llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint)
135 { 135 {
136 SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host); 136 SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host);
137
138 if (hostPart == null) 137 if (hostPart == null)
139 return 0; 138 return 0;
140 139
141 if (hostPart.ParentGroup.IsAttachment) 140 SceneObjectGroup hostgroup = hostPart.ParentGroup;
141
142 if (hostgroup== null || hostgroup.IsAttachment)
142 return 0; 143 return 0;
143 144
144 IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface<IAttachmentsModule>(); 145 IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface<IAttachmentsModule>();
@@ -156,32 +157,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
156 if (!m_scene.TryGetScenePresence(item.PermsGranter, out target)) 157 if (!m_scene.TryGetScenePresence(item.PermsGranter, out target))
157 return 0; 158 return 0;
158 159
159 if (target.UUID != hostPart.ParentGroup.OwnerID) 160 if (target.UUID != hostgroup.OwnerID)
160 { 161 {
161 uint effectivePerms = hostPart.ParentGroup.GetEffectivePermissions(); 162 uint effectivePerms = hostgroup.EffectiveOwnerPerms;
162 163
163 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) 164 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
164 return 0; 165 return 0;
165 166
166 hostPart.ParentGroup.SetOwnerId(target.UUID); 167 hostgroup.SetOwner(target.UUID, target.ControllingClient.ActiveGroupId);
167 hostPart.ParentGroup.SetRootPartOwner(hostPart.ParentGroup.RootPart, target.UUID, target.ControllingClient.ActiveGroupId);
168 168
169 if (m_scene.Permissions.PropagatePermissions()) 169 if (m_scene.Permissions.PropagatePermissions())
170 { 170 {
171 foreach (SceneObjectPart child in hostPart.ParentGroup.Parts) 171 foreach (SceneObjectPart child in hostgroup.Parts)
172 { 172 {
173 child.Inventory.ChangeInventoryOwner(target.UUID); 173 child.Inventory.ChangeInventoryOwner(target.UUID);
174 child.TriggerScriptChangedEvent(Changed.OWNER); 174 child.TriggerScriptChangedEvent(Changed.OWNER);
175 child.ApplyNextOwnerPermissions(); 175 child.ApplyNextOwnerPermissions();
176 } 176 }
177 hostgroup.AggregatePerms();
177 } 178 }
178 179
179 hostPart.ParentGroup.RootPart.ObjectSaleType = 0; 180 hostgroup.RootPart.ObjectSaleType = 0;
180 hostPart.ParentGroup.RootPart.SalePrice = 10; 181 hostgroup.RootPart.SalePrice = 10;
181 182
182 hostPart.ParentGroup.HasGroupChanged = true; 183 hostgroup.HasGroupChanged = true;
183 hostPart.ParentGroup.RootPart.SendPropertiesToClient(target.ControllingClient); 184 hostgroup.RootPart.SendPropertiesToClient(target.ControllingClient);
184 hostPart.ParentGroup.RootPart.ScheduleFullUpdate(); 185 hostgroup.RootPart.ScheduleFullUpdate();
185 } 186 }
186 187
187 return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, false, true) ? 1 : 0; 188 return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, false, true) ? 1 : 0;
diff --git a/OpenSim/Region/OptionalModules/Framework/Monitoring/EtcdMonitoringModule.cs b/OpenSim/Region/OptionalModules/Framework/Monitoring/EtcdMonitoringModule.cs
new file mode 100644
index 0000000..921bbfb
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Framework/Monitoring/EtcdMonitoringModule.cs
@@ -0,0 +1,195 @@
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 System.Text;
32using log4net;
33using Mono.Addins;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Console;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using netcd;
41using netcd.Serialization;
42using netcd.Advanced;
43using netcd.Advanced.Requests;
44
45namespace OpenSim.Region.OptionalModules.Framework.Monitoring
46{
47 /// <summary>
48 /// Allows to store monitoring data in etcd, a high availability
49 /// name-value store.
50 /// </summary>
51 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EtcdMonitoringModule")]
52 public class EtcdMonitoringModule : INonSharedRegionModule, IEtcdModule
53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 protected Scene m_scene;
57 protected IEtcdClient m_client;
58 protected bool m_enabled = false;
59 protected string m_etcdBasePath = String.Empty;
60 protected bool m_appendRegionID = true;
61
62 public string Name
63 {
64 get { return "EtcdMonitoringModule"; }
65 }
66
67 public Type ReplaceableInterface
68 {
69 get { return null; }
70 }
71
72 public void Initialise(IConfigSource source)
73 {
74 if (source.Configs["Etcd"] == null)
75 return;
76
77 IConfig etcdConfig = source.Configs["Etcd"];
78
79 string etcdUrls = etcdConfig.GetString("EtcdUrls", String.Empty);
80 if (etcdUrls == String.Empty)
81 return;
82
83 m_etcdBasePath = etcdConfig.GetString("BasePath", m_etcdBasePath);
84 m_appendRegionID = etcdConfig.GetBoolean("AppendRegionID", m_appendRegionID);
85
86 if (!m_etcdBasePath.EndsWith("/"))
87 m_etcdBasePath += "/";
88
89 try
90 {
91 string[] endpoints = etcdUrls.Split(new char[] {','});
92 List<Uri> uris = new List<Uri>();
93 foreach (string endpoint in endpoints)
94 uris.Add(new Uri(endpoint.Trim()));
95
96 m_client = new EtcdClient(uris.ToArray(), new DefaultSerializer(), new DefaultSerializer());
97 }
98 catch (Exception e)
99 {
100 m_log.DebugFormat("[ETCD]: Error initializing connection: " + e.ToString());
101 return;
102 }
103
104 m_log.DebugFormat("[ETCD]: Etcd module configured");
105 m_enabled = true;
106 }
107
108 public void Close()
109 {
110 //m_client = null;
111 m_scene = null;
112 }
113
114 public void AddRegion(Scene scene)
115 {
116 m_scene = scene;
117
118 if (m_enabled)
119 {
120 if (m_appendRegionID)
121 m_etcdBasePath += m_scene.RegionInfo.RegionID.ToString() + "/";
122
123 m_log.DebugFormat("[ETCD]: Using base path {0} for all keys", m_etcdBasePath);
124
125 try
126 {
127 m_client.Advanced.CreateDirectory(new CreateDirectoryRequest() {Key = m_etcdBasePath});
128 }
129 catch (Exception e)
130 {
131 m_log.ErrorFormat("Exception trying to create base path {0}: " + e.ToString(), m_etcdBasePath);
132 }
133
134 scene.RegisterModuleInterface<IEtcdModule>(this);
135 }
136 }
137
138 public void RemoveRegion(Scene scene)
139 {
140 }
141
142 public void RegionLoaded(Scene scene)
143 {
144 }
145
146 public bool Store(string k, string v)
147 {
148 return Store(k, v, 0);
149 }
150
151 public bool Store(string k, string v, int ttl)
152 {
153 Response resp = m_client.Advanced.SetKey(new SetKeyRequest() { Key = m_etcdBasePath + k, Value = v, TimeToLive = ttl });
154
155 if (resp == null)
156 return false;
157
158 if (resp.ErrorCode.HasValue)
159 {
160 m_log.DebugFormat("[ETCD]: Error {0} ({1}) storing {2} => {3}", resp.Cause, (int)resp.ErrorCode, m_etcdBasePath + k, v);
161
162 return false;
163 }
164
165 return true;
166 }
167
168 public string Get(string k)
169 {
170 Response resp = m_client.Advanced.GetKey(new GetKeyRequest() { Key = m_etcdBasePath + k });
171
172 if (resp == null)
173 return String.Empty;
174
175 if (resp.ErrorCode.HasValue)
176 {
177 m_log.DebugFormat("[ETCD]: Error {0} ({1}) getting {2}", resp.Cause, (int)resp.ErrorCode, m_etcdBasePath + k);
178
179 return String.Empty;
180 }
181
182 return resp.Node.Value;
183 }
184
185 public void Delete(string k)
186 {
187 m_client.Advanced.DeleteKey(new DeleteKeyRequest() { Key = m_etcdBasePath + k });
188 }
189
190 public void Watch(string k, Action<string> callback)
191 {
192 m_client.Advanced.WatchKey(new WatchKeyRequest() { Key = m_etcdBasePath + k, Callback = (x) => { callback(x.Node.Value); } });
193 }
194 }
195}
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
index 52fa908..e8cb052 100644
--- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
+++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
@@ -329,7 +329,7 @@ namespace OpenSim.Region.OptionalModules.Materials
329 AssetBase matAsset = m_scene.AssetService.Get(id.ToString()); 329 AssetBase matAsset = m_scene.AssetService.Get(id.ToString());
330 if (matAsset == null || matAsset.Data == null || matAsset.Data.Length == 0 ) 330 if (matAsset == null || matAsset.Data == null || matAsset.Data.Length == 0 )
331 { 331 {
332 m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id); 332 //m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id);
333 return; 333 return;
334 } 334 }
335 335
diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
index 9c0fa75..61b6d68 100644
--- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
+++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
@@ -52,6 +52,7 @@ namespace OpenSim.Region.OptionalModules
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 private bool m_enabled; 53 private bool m_enabled;
54 54
55 private Scene m_scene;
55 public string Name { get { return "PrimLimitsModule"; } } 56 public string Name { get { return "PrimLimitsModule"; } }
56 57
57 public Type ReplaceableInterface { get { return null; } } 58 public Type ReplaceableInterface { get { return null; } }
@@ -77,11 +78,12 @@ namespace OpenSim.Region.OptionalModules
77 public void AddRegion(Scene scene) 78 public void AddRegion(Scene scene)
78 { 79 {
79 if (!m_enabled) 80 if (!m_enabled)
80 {
81 return; 81 return;
82 } 82
83 m_scene = scene;
83 scene.Permissions.OnRezObject += CanRezObject; 84 scene.Permissions.OnRezObject += CanRezObject;
84 scene.Permissions.OnObjectEntry += CanObjectEnter; 85 scene.Permissions.OnObjectEntry += CanObjectEnter;
86 scene.Permissions.OnObjectEnterWithScripts += CanObjectEnterWithScripts;
85 scene.Permissions.OnDuplicateObject += CanDuplicateObject; 87 scene.Permissions.OnDuplicateObject += CanDuplicateObject;
86 88
87 m_log.DebugFormat("[PRIM LIMITS]: Region {0} added", scene.RegionInfo.RegionName); 89 m_log.DebugFormat("[PRIM LIMITS]: Region {0} added", scene.RegionInfo.RegionName);
@@ -89,14 +91,13 @@ namespace OpenSim.Region.OptionalModules
89 91
90 public void RemoveRegion(Scene scene) 92 public void RemoveRegion(Scene scene)
91 { 93 {
92 if (m_enabled) 94 if (!m_enabled)
93 {
94 return; 95 return;
95 }
96 96
97 scene.Permissions.OnRezObject -= CanRezObject; 97 m_scene.Permissions.OnRezObject -= CanRezObject;
98 scene.Permissions.OnObjectEntry -= CanObjectEnter; 98 m_scene.Permissions.OnObjectEntry -= CanObjectEnter;
99 scene.Permissions.OnDuplicateObject -= CanDuplicateObject; 99 scene.Permissions.OnObjectEnterWithScripts -= CanObjectEnterWithScripts;
100 m_scene.Permissions.OnDuplicateObject -= CanDuplicateObject;
100 } 101 }
101 102
102 public void RegionLoaded(Scene scene) 103 public void RegionLoaded(Scene scene)
@@ -104,11 +105,12 @@ namespace OpenSim.Region.OptionalModules
104 m_dialogModule = scene.RequestModuleInterface<IDialogModule>(); 105 m_dialogModule = scene.RequestModuleInterface<IDialogModule>();
105 } 106 }
106 107
107 private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition, Scene scene) 108 private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition)
108 { 109 {
109 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 110
111 ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
110 112
111 string response = DoCommonChecks(objectCount, ownerID, lo, scene); 113 string response = DoCommonChecks(objectCount, ownerID, lo);
112 114
113 if (response != null) 115 if (response != null)
114 { 116 {
@@ -119,88 +121,99 @@ namespace OpenSim.Region.OptionalModules
119 } 121 }
120 122
121 //OnDuplicateObject 123 //OnDuplicateObject
122 private bool CanDuplicateObject(int objectCount, UUID objectID, UUID ownerID, Scene scene, Vector3 objectPosition) 124 private bool CanDuplicateObject(SceneObjectGroup sog, ScenePresence sp)
123 { 125 {
124 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 126 Vector3 objectPosition = sog.AbsolutePosition;
127 ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
125 128
126 string response = DoCommonChecks(objectCount, ownerID, lo, scene); 129 string response = DoCommonChecks(sog.PrimCount, sp.UUID, lo);
127 130
128 if (response != null) 131 if (response != null)
129 { 132 {
130 m_dialogModule.SendAlertToUser(ownerID, response); 133 m_dialogModule.SendAlertToUser(sp.UUID, response);
131 return false; 134 return false;
132 } 135 }
133 return true; 136 return true;
134 } 137 }
135 138
136 private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) 139 private bool CanObjectEnter(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint)
137 { 140 {
138 if (newPoint.X < -1f || newPoint.X > (scene.RegionInfo.RegionSizeX + 1) || 141 float newX = newPoint.X;
139 newPoint.Y < -1f || newPoint.Y > (scene.RegionInfo.RegionSizeY) ) 142 float newY = newPoint.Y;
143 if (newX < -1.0f || newX > (m_scene.RegionInfo.RegionSizeX + 1.0f) ||
144 newY < -1.0f || newY > (m_scene.RegionInfo.RegionSizeY + 1.0f) )
140 return true; 145 return true;
141 146
142 SceneObjectPart obj = scene.GetSceneObjectPart(objectID); 147 if (sog == null)
143
144 if (obj == null)
145 return false; 148 return false;
146 149
147 // Prim counts are determined by the location of the root prim. if we're 150 ILandObject newParcel = m_scene.LandChannel.GetLandObject(newX, newY);
148 // moving a child prim, just let it pass
149 if (!obj.IsRoot)
150 {
151 return true;
152 }
153
154 ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y);
155 151
156 if (newParcel == null) 152 if (newParcel == null)
157 return true; 153 return true;
158 154
159 Vector3 oldPoint = obj.GroupPosition; 155 if(!enteringRegion)
160 ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
161
162 // The prim hasn't crossed a region boundry so we don't need to worry
163 // about prim counts here
164 if(oldParcel != null && oldParcel.Equals(newParcel))
165 { 156 {
166 return true; 157 Vector3 oldPoint = sog.AbsolutePosition;
158 ILandObject oldParcel = m_scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
159 if(oldParcel != null && oldParcel.Equals(newParcel))
160 return true;
167 } 161 }
168 162
169 int objectCount = obj.ParentGroup.PrimCount; 163 int objectCount = sog.PrimCount;
170 int usedPrims = newParcel.PrimCounts.Total;
171 int simulatorCapacity = newParcel.GetSimulatorMaxPrimCount();
172 164
173 // TODO: Add Special Case here for temporary prims 165 // TODO: Add Special Case here for temporary prims
174 166
175 string response = DoCommonChecks(objectCount, obj.OwnerID, newParcel, scene); 167 string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel);
176 168
177 if (response != null) 169 if (response != null)
178 { 170 {
179 m_dialogModule.SendAlertToUser(obj.OwnerID, response); 171 if(m_dialogModule != null)
172 m_dialogModule.SendAlertToUser(sog.OwnerID, response);
180 return false; 173 return false;
181 } 174 }
182 return true; 175 return true;
183 } 176 }
184 177
185 private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo, Scene scene) 178 private bool CanObjectEnterWithScripts(SceneObjectGroup sog, ILandObject newParcel)
179 {
180 if (sog == null)
181 return false;
182
183 if (newParcel == null)
184 return true;
185
186 int objectCount = sog.PrimCount;
187
188 // TODO: Add Special Case here for temporary prims
189
190 string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel);
191
192 if (response != null)
193 return false;
194
195 return true;
196 }
197
198 private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo)
186 { 199 {
187 string response = null; 200 string response = null;
188 201
189 int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount(); 202 int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount();
190 if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity) 203 if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity)
191 { 204 {
192 response = "Unable to rez object because the parcel is too full"; 205 response = "Unable to rez object because the parcel is full";
193 } 206 }
194 else 207 else
195 { 208 {
196 int maxPrimsPerUser = scene.RegionInfo.MaxPrimsPerUser; 209 int maxPrimsPerUser = m_scene.RegionInfo.MaxPrimsPerUser;
197 if (maxPrimsPerUser >= 0) 210 if (maxPrimsPerUser >= 0)
198 { 211 {
199 // per-user prim limit is set 212 // per-user prim limit is set
200 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned) 213 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned)
201 { 214 {
202 // caller is not the sole Parcel owner 215 // caller is not the sole Parcel owner
203 EstateSettings estateSettings = scene.RegionInfo.EstateSettings; 216 EstateSettings estateSettings = m_scene.RegionInfo.EstateSettings;
204 if (ownerID != estateSettings.EstateOwner) 217 if (ownerID != estateSettings.EstateOwner)
205 { 218 {
206 // caller is NOT the Estate owner 219 // caller is NOT the Estate owner
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
index a9fdb66..6cf0092 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
@@ -665,7 +665,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
665 taskItem.AssetID = asset.FullID; 665 taskItem.AssetID = asset.FullID;
666 666
667 host.Inventory.AddInventoryItem(taskItem, false); 667 host.Inventory.AddInventoryItem(taskItem, false);
668 668 host.ParentGroup.AggregatePerms();
669 m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); 669 m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString());
670 } 670 }
671 671
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 6a7c735..151a202 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -813,7 +813,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
813 { 813 {
814 } 814 }
815 815
816 public void SendAvatarDataImmediate(ISceneEntity avatar) 816 public void SendEntityFullUpdateImmediate(ISceneEntity avatar)
817 {
818 }
819
820 public void SendEntityTerseUpdateImmediate(ISceneEntity ent)
817 { 821 {
818 } 822 }
819 823
diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
index e22c6ea..b26fa32 100644
--- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
+++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
@@ -523,9 +523,9 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
523 523
524 rootPart.AddFlag(PrimFlags.Phantom); 524 rootPart.AddFlag(PrimFlags.Phantom);
525 525
526 m_scene.AddNewSceneObject(sceneObject, true);
527 sceneObject.SetGroup(groupID, null); 526 sceneObject.SetGroup(groupID, null);
528 527 m_scene.AddNewSceneObject(sceneObject, true);
528 sceneObject.AggregatePerms();
529 return sceneObject; 529 return sceneObject;
530 } 530 }
531 531
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
index 33f0337..2fa98b5 100644
--- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
@@ -256,6 +256,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
256 /// </summary> 256 /// </summary>
257 public string SOPName; 257 public string SOPName;
258 258
259 public virtual void CrossingStart() { }
259 public abstract void CrossingFailure(); 260 public abstract void CrossingFailure();
260 261
261 public abstract void link(PhysicsActor obj); 262 public abstract void link(PhysicsActor obj);
@@ -462,6 +463,23 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
462 public abstract bool SubscribedEvents(); 463 public abstract bool SubscribedEvents();
463 464
464 public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { } 465 public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { }
466 public virtual void AddVDTCCollisionEvent(uint CollidedWith, ContactPoint contact) { }
467
468 public virtual PhysicsInertiaData GetInertiaData()
469 {
470 PhysicsInertiaData data = new PhysicsInertiaData();
471 data.TotalMass = this.Mass;
472 data.CenterOfMass = CenterOfMass - Position;
473 data.Inertia = Vector3.Zero;
474 data.InertiaRotation = Vector4.Zero;
475 return data;
476 }
477
478 public virtual void SetInertiaData(PhysicsInertiaData inertia)
479 {
480 }
481
482 public virtual float SimulationSuspended { get; set; }
465 483
466 // Warning in a parent part it returns itself, not null 484 // Warning in a parent part it returns itself, not null
467 public virtual PhysicsActor ParentActor { get { return this; } } 485 public virtual PhysicsActor ParentActor { get { return this; } }
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
index a2fbf41..9bf71f7 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
@@ -85,7 +85,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
85 private Vector3 m_lastposition; 85 private Vector3 m_lastposition;
86 private Vector3 m_rotationalVelocity; 86 private Vector3 m_rotationalVelocity;
87 private Vector3 _size; 87 private Vector3 _size;
88 private Vector3 _acceleration; 88 private Vector3 m_acceleration;
89 private IntPtr Amotor; 89 private IntPtr Amotor;
90 90
91 internal Vector3 m_force; 91 internal Vector3 m_force;
@@ -109,8 +109,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
109 private float m_waterHeight; 109 private float m_waterHeight;
110 private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. 110 private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
111 111
112 private int body_autodisable_frames; 112 private int m_body_autodisable_frames;
113 public int bodydisablecontrol = 0; 113 public int m_bodydisablecontrol = 0;
114 private float m_gravmod = 1.0f; 114 private float m_gravmod = 1.0f;
115 115
116 // Default we're a Geometry 116 // Default we're a Geometry
@@ -182,18 +182,21 @@ namespace OpenSim.Region.PhysicsModule.ubOde
182 private float m_streamCost; 182 private float m_streamCost;
183 183
184 public d.Mass primdMass; // prim inertia information on it's own referencial 184 public d.Mass primdMass; // prim inertia information on it's own referencial
185 private PhysicsInertiaData m_InertiaOverride;
185 float primMass; // prim own mass 186 float primMass; // prim own mass
186 float primVolume; // prim own volume; 187 float primVolume; // prim own volume;
187 float _mass; // object mass acording to case 188 float m_mass; // object mass acording to case
188 189
189 public int givefakepos; 190 public int givefakepos;
190 private Vector3 fakepos; 191 private Vector3 fakepos;
191 public int givefakeori; 192 public int givefakeori;
192 private Quaternion fakeori; 193 private Quaternion fakeori;
194 private PhysicsInertiaData m_fakeInertiaOverride;
193 195
194 private int m_eventsubscription; 196 private int m_eventsubscription;
195 private int m_cureventsubscription; 197 private int m_cureventsubscription;
196 private CollisionEventUpdate CollisionEventsThisFrame = null; 198 private CollisionEventUpdate CollisionEventsThisFrame = null;
199 private CollisionEventUpdate CollisionVDTCEventsThisFrame = null;
197 private bool SentEmptyCollisionsEvent; 200 private bool SentEmptyCollisionsEvent;
198 201
199 public volatile bool childPrim; 202 public volatile bool childPrim;
@@ -465,6 +468,103 @@ namespace OpenSim.Region.PhysicsModule.ubOde
465 } 468 }
466 } 469 }
467 470
471 public override PhysicsInertiaData GetInertiaData()
472 {
473 PhysicsInertiaData inertia;
474 if(childPrim)
475 {
476 if(_parent != null)
477 return _parent.GetInertiaData();
478 else
479 {
480 inertia = new PhysicsInertiaData();
481 inertia.TotalMass = -1;
482 return inertia;
483 }
484 }
485
486 inertia = new PhysicsInertiaData();
487
488 // double buffering
489 if(m_fakeInertiaOverride != null)
490 {
491 d.Mass objdmass = new d.Mass();
492 objdmass.I.M00 = m_fakeInertiaOverride.Inertia.X;
493 objdmass.I.M11 = m_fakeInertiaOverride.Inertia.Y;
494 objdmass.I.M22 = m_fakeInertiaOverride.Inertia.Z;
495
496 objdmass.mass = m_fakeInertiaOverride.TotalMass;
497
498 if(Math.Abs(m_fakeInertiaOverride.InertiaRotation.W) < 0.999)
499 {
500 d.Matrix3 inertiarotmat = new d.Matrix3();
501 d.Quaternion inertiarot = new d.Quaternion();
502
503 inertiarot.X = m_fakeInertiaOverride.InertiaRotation.X;
504 inertiarot.Y = m_fakeInertiaOverride.InertiaRotation.Y;
505 inertiarot.Z = m_fakeInertiaOverride.InertiaRotation.Z;
506 inertiarot.W = m_fakeInertiaOverride.InertiaRotation.W;
507 d.RfromQ(out inertiarotmat, ref inertiarot);
508 d.MassRotate(ref objdmass, ref inertiarotmat);
509 }
510
511 inertia.TotalMass = m_fakeInertiaOverride.TotalMass;
512 inertia.CenterOfMass = m_fakeInertiaOverride.CenterOfMass;
513 inertia.Inertia.X = objdmass.I.M00;
514 inertia.Inertia.Y = objdmass.I.M11;
515 inertia.Inertia.Z = objdmass.I.M22;
516 inertia.InertiaRotation.X = objdmass.I.M01;
517 inertia.InertiaRotation.Y = objdmass.I.M02;
518 inertia.InertiaRotation.Z = objdmass.I.M12;
519 return inertia;
520 }
521
522 inertia.TotalMass = m_mass;
523
524 if(Body == IntPtr.Zero || prim_geom == IntPtr.Zero)
525 {
526 inertia.CenterOfMass = Vector3.Zero;
527 inertia.Inertia = Vector3.Zero;
528 inertia.InertiaRotation = Vector4.Zero;
529 return inertia;
530 }
531
532 d.Vector3 dtmp;
533 d.Mass m = new d.Mass();
534 lock(_parent_scene.OdeLock)
535 {
536 d.AllocateODEDataForThread(0);
537 dtmp = d.GeomGetOffsetPosition(prim_geom);
538 d.BodyGetMass(Body, out m);
539 }
540
541 Vector3 cm = new Vector3(-dtmp.X, -dtmp.Y, -dtmp.Z);
542 inertia.CenterOfMass = cm;
543 inertia.Inertia = new Vector3(m.I.M00, m.I.M11, m.I.M22);
544 inertia.InertiaRotation = new Vector4(m.I.M01, m.I.M02 , m.I.M12, 0);
545
546 return inertia;
547 }
548
549 public override void SetInertiaData(PhysicsInertiaData inertia)
550 {
551 if(childPrim)
552 {
553 if(_parent != null)
554 _parent.SetInertiaData(inertia);
555 return;
556 }
557
558 if(inertia.TotalMass > 0)
559 m_fakeInertiaOverride = new PhysicsInertiaData(inertia);
560 else
561 m_fakeInertiaOverride = null;
562
563 if (inertia.TotalMass > _parent_scene.maximumMassObject)
564 inertia.TotalMass = _parent_scene.maximumMassObject;
565 AddChange(changes.SetInertia,(object)m_fakeInertiaOverride);
566 }
567
468 public override Vector3 CenterOfMass 568 public override Vector3 CenterOfMass
469 { 569 {
470 get 570 get
@@ -569,7 +669,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
569 { 669 {
570 if (value.IsFinite()) 670 if (value.IsFinite())
571 { 671 {
572 AddChange(changes.Velocity, value); 672 if(m_outbounds)
673 _velocity = value;
674 else
675 AddChange(changes.Velocity, value);
573 } 676 }
574 else 677 else
575 { 678 {
@@ -642,8 +745,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
642 745
643 public override Vector3 Acceleration 746 public override Vector3 Acceleration
644 { 747 {
645 get { return _acceleration; } 748 get { return m_acceleration; }
646 set { } 749 set
750 {
751 if(m_outbounds)
752 m_acceleration = value;
753 }
647 } 754 }
648 755
649 public override Vector3 RotationalVelocity 756 public override Vector3 RotationalVelocity
@@ -663,7 +770,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
663 { 770 {
664 if (value.IsFinite()) 771 if (value.IsFinite())
665 { 772 {
666 AddChange(changes.AngVelocity, value); 773 if(m_outbounds)
774 m_rotationalVelocity = value;
775 else
776 AddChange(changes.AngVelocity, value);
667 } 777 }
668 else 778 else
669 { 779 {
@@ -837,7 +947,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
837 } 947 }
838 public void SetAcceleration(Vector3 accel) 948 public void SetAcceleration(Vector3 accel)
839 { 949 {
840 _acceleration = accel; 950 m_acceleration = accel;
841 } 951 }
842 952
843 public override void AddForce(Vector3 force, bool pushforce) 953 public override void AddForce(Vector3 force, bool pushforce)
@@ -873,31 +983,68 @@ namespace OpenSim.Region.PhysicsModule.ubOde
873 983
874 public override void CrossingFailure() 984 public override void CrossingFailure()
875 { 985 {
876 if (m_outbounds) 986 lock(_parent_scene.OdeLock)
987 {
988 if (m_outbounds)
989 {
990 _position.X = Util.Clip(_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f);
991 _position.Y = Util.Clip(_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f);
992 _position.Z = Util.Clip(_position.Z + 0.2f, -100f, 50000f);
993
994 m_lastposition = _position;
995 _velocity.X = 0;
996 _velocity.Y = 0;
997 _velocity.Z = 0;
998
999 d.AllocateODEDataForThread(0);
1000
1001 m_lastVelocity = _velocity;
1002 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE)
1003 m_vehicle.Stop();
1004
1005 if(Body != IntPtr.Zero)
1006 d.BodySetLinearVel(Body, 0, 0, 0); // stop it
1007 if (prim_geom != IntPtr.Zero)
1008 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1009
1010 m_outbounds = false;
1011 changeDisable(false);
1012 base.RequestPhysicsterseUpdate();
1013 }
1014 }
1015 }
1016
1017 public override void CrossingStart()
1018 {
1019 lock(_parent_scene.OdeLock)
877 { 1020 {
878 _position.X = Util.Clip(_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f); 1021 if (m_outbounds || childPrim)
879 _position.Y = Util.Clip(_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f); 1022 return;
880 _position.Z = Util.Clip(_position.Z + 0.2f, -100f, 50000f); 1023
1024 m_outbounds = true;
881 1025
882 m_lastposition = _position; 1026 m_lastposition = _position;
883 _velocity.X = 0; 1027 m_lastorientation = _orientation;
884 _velocity.Y = 0;
885 _velocity.Z = 0;
886 1028
887 d.AllocateODEDataForThread(0); 1029 d.AllocateODEDataForThread(0);
1030 if(Body != IntPtr.Zero)
1031 {
1032 d.Vector3 dtmp = d.BodyGetAngularVel(Body);
1033 m_rotationalVelocity.X = dtmp.X;
1034 m_rotationalVelocity.Y = dtmp.Y;
1035 m_rotationalVelocity.Z = dtmp.Z;
888 1036
889 m_lastVelocity = _velocity; 1037 dtmp = d.BodyGetLinearVel(Body);
890 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) 1038 _velocity.X = dtmp.X;
891 m_vehicle.Stop(); 1039 _velocity.Y = dtmp.Y;
1040 _velocity.Z = dtmp.Z;
892 1041
893 if(Body != IntPtr.Zero)
894 d.BodySetLinearVel(Body, 0, 0, 0); // stop it 1042 d.BodySetLinearVel(Body, 0, 0, 0); // stop it
895 if (prim_geom != IntPtr.Zero) 1043 d.BodySetAngularVel(Body, 0, 0, 0);
896 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 1044 }
897 1045 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
898 m_outbounds = false; 1046 disableBodySoft(); // stop collisions
899 changeDisable(false); 1047 UnSubscribeEvents();
900 base.RequestPhysicsterseUpdate();
901 } 1048 }
902 } 1049 }
903 1050
@@ -920,8 +1067,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
920 } 1067 }
921 set 1068 set
922 { 1069 {
1070 float old = m_density;
923 m_density = value / 100f; 1071 m_density = value / 100f;
924 // for not prim mass is not updated since this implies full rebuild of body inertia TODO 1072 // if(m_density != old)
1073 // UpdatePrimBodyData();
925 } 1074 }
926 } 1075 }
927 public override float GravModifier 1076 public override float GravModifier
@@ -989,11 +1138,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde
989 m_cureventsubscription = 0; 1138 m_cureventsubscription = 0;
990 if (CollisionEventsThisFrame == null) 1139 if (CollisionEventsThisFrame == null)
991 CollisionEventsThisFrame = new CollisionEventUpdate(); 1140 CollisionEventsThisFrame = new CollisionEventUpdate();
1141 if (CollisionVDTCEventsThisFrame == null)
1142 CollisionVDTCEventsThisFrame = new CollisionEventUpdate();
992 SentEmptyCollisionsEvent = false; 1143 SentEmptyCollisionsEvent = false;
993 } 1144 }
994 1145
995 public override void UnSubscribeEvents() 1146 public override void UnSubscribeEvents()
996 { 1147 {
1148 if (CollisionVDTCEventsThisFrame != null)
1149 {
1150 CollisionVDTCEventsThisFrame.Clear();
1151 CollisionVDTCEventsThisFrame = null;
1152 }
997 if (CollisionEventsThisFrame != null) 1153 if (CollisionEventsThisFrame != null)
998 { 1154 {
999 CollisionEventsThisFrame.Clear(); 1155 CollisionEventsThisFrame.Clear();
@@ -1012,37 +1168,67 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1012 _parent_scene.AddCollisionEventReporting(this); 1168 _parent_scene.AddCollisionEventReporting(this);
1013 } 1169 }
1014 1170
1171 public override void AddVDTCCollisionEvent(uint CollidedWith, ContactPoint contact)
1172 {
1173 if (CollisionVDTCEventsThisFrame == null)
1174 CollisionVDTCEventsThisFrame = new CollisionEventUpdate();
1175
1176 CollisionVDTCEventsThisFrame.AddCollider(CollidedWith, contact);
1177 _parent_scene.AddCollisionEventReporting(this);
1178 }
1179
1015 internal void SleeperAddCollisionEvents() 1180 internal void SleeperAddCollisionEvents()
1016 { 1181 {
1017 if (CollisionEventsThisFrame == null) 1182 if(CollisionEventsThisFrame != null && CollisionEventsThisFrame.m_objCollisionList.Count != 0)
1018 return; 1183 {
1019 if(CollisionEventsThisFrame.m_objCollisionList.Count == 0) 1184 foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionEventsThisFrame.m_objCollisionList)
1020 return; 1185 {
1021 foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionEventsThisFrame.m_objCollisionList) 1186 if(kvp.Key == 0)
1187 continue;
1188 OdePrim other = _parent_scene.getPrim(kvp.Key);
1189 if(other == null)
1190 continue;
1191 ContactPoint cp = kvp.Value;
1192 cp.SurfaceNormal = - cp.SurfaceNormal;
1193 cp.RelativeSpeed = -cp.RelativeSpeed;
1194 other.AddCollisionEvent(ParentActor.LocalID,cp);
1195 }
1196 }
1197 if(CollisionVDTCEventsThisFrame != null && CollisionVDTCEventsThisFrame.m_objCollisionList.Count != 0)
1022 { 1198 {
1023 OdePrim other = _parent_scene.getPrim(kvp.Key); 1199 foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionVDTCEventsThisFrame.m_objCollisionList)
1024 if(other == null) 1200 {
1025 continue; 1201 OdePrim other = _parent_scene.getPrim(kvp.Key);
1026 ContactPoint cp = kvp.Value; 1202 if(other == null)
1027 cp.SurfaceNormal = - cp.SurfaceNormal; 1203 continue;
1028 cp.RelativeSpeed = -cp.RelativeSpeed; 1204 ContactPoint cp = kvp.Value;
1029 other.AddCollisionEvent(ParentActor.LocalID,cp); 1205 cp.SurfaceNormal = - cp.SurfaceNormal;
1206 cp.RelativeSpeed = -cp.RelativeSpeed;
1207 other.AddCollisionEvent(ParentActor.LocalID,cp);
1208 }
1030 } 1209 }
1031 } 1210 }
1032 1211
1212 internal void clearSleeperCollisions()
1213 {
1214 if(CollisionVDTCEventsThisFrame != null && CollisionVDTCEventsThisFrame.Count >0 )
1215 CollisionVDTCEventsThisFrame.Clear();
1216 }
1217
1033 public void SendCollisions(int timestep) 1218 public void SendCollisions(int timestep)
1034 { 1219 {
1035 if (m_cureventsubscription < 50000) 1220 if (m_cureventsubscription < 50000)
1036 m_cureventsubscription += timestep; 1221 m_cureventsubscription += timestep;
1037 1222
1223
1224 if (m_cureventsubscription < m_eventsubscription)
1225 return;
1226
1038 if (CollisionEventsThisFrame == null) 1227 if (CollisionEventsThisFrame == null)
1039 return; 1228 return;
1040 1229
1041 int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count; 1230 int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
1042 1231
1043 if (m_cureventsubscription < m_eventsubscription)
1044 return;
1045
1046 if (!SentEmptyCollisionsEvent || ncolisions > 0) 1232 if (!SentEmptyCollisionsEvent || ncolisions > 0)
1047 { 1233 {
1048 base.SendCollisionUpdate(CollisionEventsThisFrame); 1234 base.SendCollisionUpdate(CollisionEventsThisFrame);
@@ -1091,7 +1277,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1091 m_invTimeStep = 1f / m_timeStep; 1277 m_invTimeStep = 1f / m_timeStep;
1092 1278
1093 m_density = parent_scene.geomDefaultDensity; 1279 m_density = parent_scene.geomDefaultDensity;
1094 body_autodisable_frames = parent_scene.bodyFramesAutoDisable; 1280 m_body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
1095 1281
1096 prim_geom = IntPtr.Zero; 1282 prim_geom = IntPtr.Zero;
1097 collide_geom = IntPtr.Zero; 1283 collide_geom = IntPtr.Zero;
@@ -1714,26 +1900,29 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1714 m_log.Warn("[PHYSICS]: MakeBody root geom already had a body"); 1900 m_log.Warn("[PHYSICS]: MakeBody root geom already had a body");
1715 } 1901 }
1716 1902
1717 d.Matrix3 mymat = new d.Matrix3(); 1903 bool noInertiaOverride = (m_InertiaOverride == null);
1718 d.Quaternion myrot = new d.Quaternion();
1719 d.Mass objdmass = new d.Mass { };
1720 1904
1721 Body = d.BodyCreate(_parent_scene.world); 1905 Body = d.BodyCreate(_parent_scene.world);
1722 1906
1723 objdmass = primdMass; 1907 d.Matrix3 mymat = new d.Matrix3();
1908 d.Quaternion myrot = new d.Quaternion();
1909 d.Mass objdmass = new d.Mass { };
1724 1910
1725 // rotate inertia
1726 myrot.X = _orientation.X; 1911 myrot.X = _orientation.X;
1727 myrot.Y = _orientation.Y; 1912 myrot.Y = _orientation.Y;
1728 myrot.Z = _orientation.Z; 1913 myrot.Z = _orientation.Z;
1729 myrot.W = _orientation.W; 1914 myrot.W = _orientation.W;
1730
1731 d.RfromQ(out mymat, ref myrot); 1915 d.RfromQ(out mymat, ref myrot);
1732 d.MassRotate(ref objdmass, ref mymat);
1733 1916
1734 // set the body rotation 1917 // set the body rotation
1735 d.BodySetRotation(Body, ref mymat); 1918 d.BodySetRotation(Body, ref mymat);
1736 1919
1920 if(noInertiaOverride)
1921 {
1922 objdmass = primdMass;
1923 d.MassRotate(ref objdmass, ref mymat);
1924 }
1925
1737 // recompute full object inertia if needed 1926 // recompute full object inertia if needed
1738 if (childrenPrim.Count > 0) 1927 if (childrenPrim.Count > 0)
1739 { 1928 {
@@ -1756,27 +1945,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1756 continue; 1945 continue;
1757 } 1946 }
1758 1947
1759 tmpdmass = prm.primdMass;
1760
1761 // apply prim current rotation to inertia
1762 quat.X = prm._orientation.X; 1948 quat.X = prm._orientation.X;
1763 quat.Y = prm._orientation.Y; 1949 quat.Y = prm._orientation.Y;
1764 quat.Z = prm._orientation.Z; 1950 quat.Z = prm._orientation.Z;
1765 quat.W = prm._orientation.W; 1951 quat.W = prm._orientation.W;
1766 d.RfromQ(out mat, ref quat); 1952 d.RfromQ(out mat, ref quat);
1767 d.MassRotate(ref tmpdmass, ref mat); 1953
1768
1769 Vector3 ppos = prm._position;
1770 ppos.X -= rcm.X;
1771 ppos.Y -= rcm.Y;
1772 ppos.Z -= rcm.Z;
1773 // refer inertia to root prim center of mass position
1774 d.MassTranslate(ref tmpdmass,
1775 ppos.X,
1776 ppos.Y,
1777 ppos.Z);
1778
1779 d.MassAdd(ref objdmass, ref tmpdmass); // add to total object inertia
1780 // fix prim colision cats 1954 // fix prim colision cats
1781 1955
1782 if (d.GeomGetBody(prm.prim_geom) != IntPtr.Zero) 1956 if (d.GeomGetBody(prm.prim_geom) != IntPtr.Zero)
@@ -1789,6 +1963,24 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1789 d.GeomSetBody(prm.prim_geom, Body); 1963 d.GeomSetBody(prm.prim_geom, Body);
1790 prm.Body = Body; 1964 prm.Body = Body;
1791 d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat); // set relative rotation 1965 d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat); // set relative rotation
1966
1967 if(noInertiaOverride)
1968 {
1969 tmpdmass = prm.primdMass;
1970
1971 d.MassRotate(ref tmpdmass, ref mat);
1972 Vector3 ppos = prm._position;
1973 ppos.X -= rcm.X;
1974 ppos.Y -= rcm.Y;
1975 ppos.Z -= rcm.Z;
1976 // refer inertia to root prim center of mass position
1977 d.MassTranslate(ref tmpdmass,
1978 ppos.X,
1979 ppos.Y,
1980 ppos.Z);
1981
1982 d.MassAdd(ref objdmass, ref tmpdmass); // add to total object inertia
1983 }
1792 } 1984 }
1793 } 1985 }
1794 } 1986 }
@@ -1797,25 +1989,66 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1797 // associate root geom with body 1989 // associate root geom with body
1798 d.GeomSetBody(prim_geom, Body); 1990 d.GeomSetBody(prim_geom, Body);
1799 1991
1800 d.BodySetPosition(Body, _position.X + objdmass.c.X, _position.Y + objdmass.c.Y, _position.Z + objdmass.c.Z); 1992 if(noInertiaOverride)
1993 d.BodySetPosition(Body, _position.X + objdmass.c.X, _position.Y + objdmass.c.Y, _position.Z + objdmass.c.Z);
1994 else
1995 {
1996 Vector3 ncm = m_InertiaOverride.CenterOfMass * _orientation;
1997 d.BodySetPosition(Body,
1998 _position.X + ncm.X,
1999 _position.Y + ncm.Y,
2000 _position.Z + ncm.Z);
2001 }
2002
1801 d.GeomSetOffsetWorldPosition(prim_geom, _position.X, _position.Y, _position.Z); 2003 d.GeomSetOffsetWorldPosition(prim_geom, _position.X, _position.Y, _position.Z);
1802 2004
1803 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body 2005 if(noInertiaOverride)
1804 myrot.X = -myrot.X; 2006 {
1805 myrot.Y = -myrot.Y; 2007 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body
1806 myrot.Z = -myrot.Z; 2008 myrot.X = -myrot.X;
2009 myrot.Y = -myrot.Y;
2010 myrot.Z = -myrot.Z;
1807 2011
1808 d.RfromQ(out mymat, ref myrot); 2012 d.RfromQ(out mymat, ref myrot);
1809 d.MassRotate(ref objdmass, ref mymat); 2013 d.MassRotate(ref objdmass, ref mymat);
1810 2014
1811 d.BodySetMass(Body, ref objdmass); 2015 d.BodySetMass(Body, ref objdmass);
1812 _mass = objdmass.mass; 2016 m_mass = objdmass.mass;
2017 }
2018 else
2019 {
2020 objdmass.c.X = 0;
2021 objdmass.c.Y = 0;
2022 objdmass.c.Z = 0;
2023
2024 objdmass.I.M00 = m_InertiaOverride.Inertia.X;
2025 objdmass.I.M11 = m_InertiaOverride.Inertia.Y;
2026 objdmass.I.M22 = m_InertiaOverride.Inertia.Z;
2027
2028 objdmass.mass = m_InertiaOverride.TotalMass;
2029
2030 if(Math.Abs(m_InertiaOverride.InertiaRotation.W) < 0.999)
2031 {
2032 d.Matrix3 inertiarotmat = new d.Matrix3();
2033 d.Quaternion inertiarot = new d.Quaternion();
2034
2035 inertiarot.X = m_InertiaOverride.InertiaRotation.X;
2036 inertiarot.Y = m_InertiaOverride.InertiaRotation.Y;
2037 inertiarot.Z = m_InertiaOverride.InertiaRotation.Z;
2038 inertiarot.W = m_InertiaOverride.InertiaRotation.W;
2039 d.RfromQ(out inertiarotmat, ref inertiarot);
2040 d.MassRotate(ref objdmass, ref inertiarotmat);
2041 }
2042 d.BodySetMass(Body, ref objdmass);
2043
2044 m_mass = objdmass.mass;
2045 }
1813 2046
1814 // disconnect from world gravity so we can apply buoyancy 2047 // disconnect from world gravity so we can apply buoyancy
1815 d.BodySetGravityMode(Body, false); 2048 d.BodySetGravityMode(Body, false);
1816 2049
1817 d.BodySetAutoDisableFlag(Body, true); 2050 d.BodySetAutoDisableFlag(Body, true);
1818 d.BodySetAutoDisableSteps(Body, body_autodisable_frames); 2051 d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames);
1819 d.BodySetAutoDisableAngularThreshold(Body, 0.05f); 2052 d.BodySetAutoDisableAngularThreshold(Body, 0.05f);
1820 d.BodySetAutoDisableLinearThreshold(Body, 0.05f); 2053 d.BodySetAutoDisableLinearThreshold(Body, 0.05f);
1821 d.BodySetDamping(Body, .004f, .001f); 2054 d.BodySetDamping(Body, .004f, .001f);
@@ -1909,8 +2142,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1909 { 2142 {
1910 d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); 2143 d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z);
1911 d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); 2144 d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
2145
1912 _zeroFlag = false; 2146 _zeroFlag = false;
1913 bodydisablecontrol = 0; 2147 m_bodydisablecontrol = 0;
1914 } 2148 }
1915 _parent_scene.addActiveGroups(this); 2149 _parent_scene.addActiveGroups(this);
1916 } 2150 }
@@ -1988,7 +2222,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1988 SetInStaticSpace(prm); 2222 SetInStaticSpace(prm);
1989 } 2223 }
1990 prm.Body = IntPtr.Zero; 2224 prm.Body = IntPtr.Zero;
1991 prm._mass = prm.primMass; 2225 prm.m_mass = prm.primMass;
1992 prm.m_collisionscore = 0; 2226 prm.m_collisionscore = 0;
1993 } 2227 }
1994 } 2228 }
@@ -2002,7 +2236,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2002 } 2236 }
2003 Body = IntPtr.Zero; 2237 Body = IntPtr.Zero;
2004 } 2238 }
2005 _mass = primMass; 2239 m_mass = primMass;
2006 m_collisionscore = 0; 2240 m_collisionscore = 0;
2007 } 2241 }
2008 2242
@@ -2079,7 +2313,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2079 d.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z); 2313 d.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z);
2080 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body 2314 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body
2081 d.BodySetMass(Body, ref objdmass); 2315 d.BodySetMass(Body, ref objdmass);
2082 _mass = objdmass.mass; 2316 m_mass = objdmass.mass;
2083 } 2317 }
2084 2318
2085 private void FixInertia(Vector3 NewPos) 2319 private void FixInertia(Vector3 NewPos)
@@ -2143,7 +2377,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2143 d.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z); 2377 d.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z);
2144 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body 2378 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body
2145 d.BodySetMass(Body, ref objdmass); 2379 d.BodySetMass(Body, ref objdmass);
2146 _mass = objdmass.mass; 2380 m_mass = objdmass.mass;
2147 } 2381 }
2148 2382
2149 private void FixInertia(Quaternion newrot) 2383 private void FixInertia(Quaternion newrot)
@@ -2209,7 +2443,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2209 d.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z); 2443 d.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z);
2210 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body 2444 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body
2211 d.BodySetMass(Body, ref objdmass); 2445 d.BodySetMass(Body, ref objdmass);
2212 _mass = objdmass.mass; 2446 m_mass = objdmass.mass;
2213 } 2447 }
2214 2448
2215 2449
@@ -2224,7 +2458,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2224 if (primMass > _parent_scene.maximumMassObject) 2458 if (primMass > _parent_scene.maximumMassObject)
2225 primMass = _parent_scene.maximumMassObject; 2459 primMass = _parent_scene.maximumMassObject;
2226 2460
2227 _mass = primMass; // just in case 2461 m_mass = primMass; // just in case
2228 2462
2229 d.MassSetBoxTotal(out primdMass, primMass, 2.0f * m_OBB.X, 2.0f * m_OBB.Y, 2.0f * m_OBB.Z); 2463 d.MassSetBoxTotal(out primdMass, primMass, 2.0f * m_OBB.X, 2.0f * m_OBB.Y, 2.0f * m_OBB.Z);
2230 2464
@@ -2514,7 +2748,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2514 m_angularForceacc = Vector3.Zero; 2748 m_angularForceacc = Vector3.Zero;
2515// m_torque = Vector3.Zero; 2749// m_torque = Vector3.Zero;
2516 _velocity = Vector3.Zero; 2750 _velocity = Vector3.Zero;
2517 _acceleration = Vector3.Zero; 2751 m_acceleration = Vector3.Zero;
2518 m_rotationalVelocity = Vector3.Zero; 2752 m_rotationalVelocity = Vector3.Zero;
2519 _target_velocity = Vector3.Zero; 2753 _target_velocity = Vector3.Zero;
2520 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) 2754 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE)
@@ -2767,8 +3001,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2767 myrot.W = newOri.W; 3001 myrot.W = newOri.W;
2768 d.GeomSetQuaternion(prim_geom, ref myrot); 3002 d.GeomSetQuaternion(prim_geom, ref myrot);
2769 _orientation = newOri; 3003 _orientation = newOri;
2770 if (Body != IntPtr.Zero && m_angularlocks != 0) 3004
2771 createAMotor(m_angularlocks); 3005 if (Body != IntPtr.Zero)
3006 {
3007 if(m_angularlocks != 0)
3008 createAMotor(m_angularlocks);
3009 }
2772 } 3010 }
2773 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) 3011 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
2774 { 3012 {
@@ -3064,7 +3302,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3064 3302
3065 private void changeSetTorque(Vector3 newtorque) 3303 private void changeSetTorque(Vector3 newtorque)
3066 { 3304 {
3067 if (!m_isSelected) 3305 if (!m_isSelected && !m_outbounds)
3068 { 3306 {
3069 if (m_isphysical && Body != IntPtr.Zero) 3307 if (m_isphysical && Body != IntPtr.Zero)
3070 { 3308 {
@@ -3081,14 +3319,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3081 private void changeForce(Vector3 force) 3319 private void changeForce(Vector3 force)
3082 { 3320 {
3083 m_force = force; 3321 m_force = force;
3084 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) 3322 if (!m_isSelected && !m_outbounds && Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
3085 d.BodyEnable(Body); 3323 d.BodyEnable(Body);
3086 } 3324 }
3087 3325
3088 private void changeAddForce(Vector3 theforce) 3326 private void changeAddForce(Vector3 theforce)
3089 { 3327 {
3090 m_forceacc += theforce; 3328 m_forceacc += theforce;
3091 if (!m_isSelected) 3329 if (!m_isSelected && !m_outbounds)
3092 { 3330 {
3093 lock (this) 3331 lock (this)
3094 { 3332 {
@@ -3109,7 +3347,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3109 private void changeAddAngularImpulse(Vector3 aimpulse) 3347 private void changeAddAngularImpulse(Vector3 aimpulse)
3110 { 3348 {
3111 m_angularForceacc += aimpulse * m_invTimeStep; 3349 m_angularForceacc += aimpulse * m_invTimeStep;
3112 if (!m_isSelected) 3350 if (!m_isSelected && !m_outbounds)
3113 { 3351 {
3114 lock (this) 3352 lock (this)
3115 { 3353 {
@@ -3134,7 +3372,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3134 newVel *= len; 3372 newVel *= len;
3135 } 3373 }
3136 3374
3137 if (!m_isSelected) 3375 if (!m_isSelected && !m_outbounds)
3138 { 3376 {
3139 if (Body != IntPtr.Zero) 3377 if (Body != IntPtr.Zero)
3140 { 3378 {
@@ -3142,7 +3380,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3142 enableBodySoft(); 3380 enableBodySoft();
3143 else if (!d.BodyIsEnabled(Body)) 3381 else if (!d.BodyIsEnabled(Body))
3144 d.BodyEnable(Body); 3382 d.BodyEnable(Body);
3145
3146 d.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z); 3383 d.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z);
3147 } 3384 }
3148 //resetCollisionAccounting(); 3385 //resetCollisionAccounting();
@@ -3159,7 +3396,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3159 newAngVel *= len; 3396 newAngVel *= len;
3160 } 3397 }
3161 3398
3162 if (!m_isSelected) 3399 if (!m_isSelected && !m_outbounds)
3163 { 3400 {
3164 if (Body != IntPtr.Zero) 3401 if (Body != IntPtr.Zero)
3165 { 3402 {
@@ -3167,8 +3404,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3167 enableBodySoft(); 3404 enableBodySoft();
3168 else if (!d.BodyIsEnabled(Body)) 3405 else if (!d.BodyIsEnabled(Body))
3169 d.BodyEnable(Body); 3406 d.BodyEnable(Body);
3170
3171
3172 d.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z); 3407 d.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z);
3173 } 3408 }
3174 //resetCollisionAccounting(); 3409 //resetCollisionAccounting();
@@ -3304,6 +3539,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3304 m_useHoverPID = active; 3539 m_useHoverPID = active;
3305 } 3540 }
3306 3541
3542 private void changeInertia(PhysicsInertiaData inertia)
3543 {
3544 m_InertiaOverride = inertia;
3545
3546 if (Body != IntPtr.Zero)
3547 DestroyBody();
3548 MakeBody();
3549 }
3550
3307 #endregion 3551 #endregion
3308 3552
3309 public void Move() 3553 public void Move()
@@ -3317,7 +3561,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3317 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) 3561 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE)
3318 return; 3562 return;
3319 3563
3320 if (++bodydisablecontrol < 50) 3564 if (++m_bodydisablecontrol < 50)
3321 return; 3565 return;
3322 3566
3323 // clear residuals 3567 // clear residuals
@@ -3325,11 +3569,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3325 d.BodySetLinearVel(Body,0f,0f,0f); 3569 d.BodySetLinearVel(Body,0f,0f,0f);
3326 _zeroFlag = true; 3570 _zeroFlag = true;
3327 d.BodyEnable(Body); 3571 d.BodyEnable(Body);
3328 bodydisablecontrol = -4; 3572 m_bodydisablecontrol = -4;
3329 } 3573 }
3330 3574
3331 if(bodydisablecontrol < 0) 3575 if(m_bodydisablecontrol < 0)
3332 bodydisablecontrol ++; 3576 m_bodydisablecontrol ++;
3333 3577
3334 d.Vector3 lpos = d.GeomGetPosition(prim_geom); // root position that is seem by rest of simulator 3578 d.Vector3 lpos = d.GeomGetPosition(prim_geom); // root position that is seem by rest of simulator
3335 3579
@@ -3344,7 +3588,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3344 float fy = 0; 3588 float fy = 0;
3345 float fz = 0; 3589 float fz = 0;
3346 3590
3347 float m_mass = _mass; 3591 float mass = m_mass;
3348 3592
3349 if (m_usePID && m_PIDTau > 0) 3593 if (m_usePID && m_PIDTau > 0)
3350 { 3594 {
@@ -3451,9 +3695,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3451 fz = _parent_scene.gravityz * b; 3695 fz = _parent_scene.gravityz * b;
3452 } 3696 }
3453 3697
3454 fx *= m_mass; 3698 fx *= mass;
3455 fy *= m_mass; 3699 fy *= mass;
3456 fz *= m_mass; 3700 fz *= mass;
3457 3701
3458 // constant force 3702 // constant force
3459 fx += m_force.X; 3703 fx += m_force.X;
@@ -3498,7 +3742,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3498 { 3742 {
3499 bool bodyenabled = d.BodyIsEnabled(Body); 3743 bool bodyenabled = d.BodyIsEnabled(Body);
3500 3744
3501 if(bodydisablecontrol < 0) 3745 if(m_bodydisablecontrol < 0)
3502 return; 3746 return;
3503 3747
3504 if (bodyenabled || !_zeroFlag) 3748 if (bodyenabled || !_zeroFlag)
@@ -3513,9 +3757,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3513 m_outbounds = true; 3757 m_outbounds = true;
3514 3758
3515 lpos.Z = Util.Clip(lpos.Z, -100f, 100000f); 3759 lpos.Z = Util.Clip(lpos.Z, -100f, 100000f);
3516 _acceleration.X = 0; 3760 m_acceleration.X = 0;
3517 _acceleration.Y = 0; 3761 m_acceleration.Y = 0;
3518 _acceleration.Z = 0; 3762 m_acceleration.Z = 0;
3519 3763
3520 _velocity.X = 0; 3764 _velocity.X = 0;
3521 _velocity.Y = 0; 3765 _velocity.Y = 0;
@@ -3638,19 +3882,19 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3638 _orientation.W = ori.W; 3882 _orientation.W = ori.W;
3639 } 3883 }
3640 3884
3641 // update velocities and aceleration 3885 // update velocities and acceleration
3642 if (_zeroFlag || lastZeroFlag) 3886 if (_zeroFlag || lastZeroFlag)
3643 { 3887 {
3644 // disable interpolators 3888 // disable interpolators
3645 _velocity = Vector3.Zero; 3889 _velocity = Vector3.Zero;
3646 _acceleration = Vector3.Zero; 3890 m_acceleration = Vector3.Zero;
3647 m_rotationalVelocity = Vector3.Zero; 3891 m_rotationalVelocity = Vector3.Zero;
3648 } 3892 }
3649 else 3893 else
3650 { 3894 {
3651 d.Vector3 vel = d.BodyGetLinearVel(Body); 3895 d.Vector3 vel = d.BodyGetLinearVel(Body);
3652 3896
3653 _acceleration = _velocity; 3897 m_acceleration = _velocity;
3654 3898
3655 if ((Math.Abs(vel.X) < 0.005f) && 3899 if ((Math.Abs(vel.X) < 0.005f) &&
3656 (Math.Abs(vel.Y) < 0.005f) && 3900 (Math.Abs(vel.Y) < 0.005f) &&
@@ -3658,28 +3902,28 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3658 { 3902 {
3659 _velocity = Vector3.Zero; 3903 _velocity = Vector3.Zero;
3660 float t = -m_invTimeStep; 3904 float t = -m_invTimeStep;
3661 _acceleration = _acceleration * t; 3905 m_acceleration = m_acceleration * t;
3662 } 3906 }
3663 else 3907 else
3664 { 3908 {
3665 _velocity.X = vel.X; 3909 _velocity.X = vel.X;
3666 _velocity.Y = vel.Y; 3910 _velocity.Y = vel.Y;
3667 _velocity.Z = vel.Z; 3911 _velocity.Z = vel.Z;
3668 _acceleration = (_velocity - _acceleration) * m_invTimeStep; 3912 m_acceleration = (_velocity - m_acceleration) * m_invTimeStep;
3669 } 3913 }
3670 3914
3671 if ((Math.Abs(_acceleration.X) < 0.01f) && 3915 if ((Math.Abs(m_acceleration.X) < 0.01f) &&
3672 (Math.Abs(_acceleration.Y) < 0.01f) && 3916 (Math.Abs(m_acceleration.Y) < 0.01f) &&
3673 (Math.Abs(_acceleration.Z) < 0.01f)) 3917 (Math.Abs(m_acceleration.Z) < 0.01f))
3674 { 3918 {
3675 _acceleration = Vector3.Zero; 3919 m_acceleration = Vector3.Zero;
3676 } 3920 }
3677 3921
3678 vel = d.BodyGetAngularVel(Body); 3922 vel = d.BodyGetAngularVel(Body);
3679 if ((Math.Abs(vel.X) < 0.0001) && 3923 if ((Math.Abs(vel.X) < 0.0001) &&
3680 (Math.Abs(vel.Y) < 0.0001) && 3924 (Math.Abs(vel.Y) < 0.0001) &&
3681 (Math.Abs(vel.Z) < 0.0001) 3925 (Math.Abs(vel.Z) < 0.0001)
3682 ) 3926 )
3683 { 3927 {
3684 m_rotationalVelocity = Vector3.Zero; 3928 m_rotationalVelocity = Vector3.Zero;
3685 } 3929 }
@@ -3939,6 +4183,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3939 changePIDHoverActive((bool)arg); 4183 changePIDHoverActive((bool)arg);
3940 break; 4184 break;
3941 4185
4186 case changes.SetInertia:
4187 changeInertia((PhysicsInertiaData) arg);
4188 break;
4189
3942 case changes.Null: 4190 case changes.Null:
3943 donullchange(); 4191 donullchange();
3944 break; 4192 break;
@@ -3955,7 +4203,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3955 _parent_scene.AddChange((PhysicsActor) this, what, arg); 4203 _parent_scene.AddChange((PhysicsActor) this, what, arg);
3956 } 4204 }
3957 4205
3958
3959 private struct strVehicleBoolParam 4206 private struct strVehicleBoolParam
3960 { 4207 {
3961 public int param; 4208 public int param;
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
index bed66cc..86d41ea 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
@@ -155,6 +155,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
155 VehicleRotationParam, 155 VehicleRotationParam,
156 VehicleFlags, 156 VehicleFlags,
157 SetVehicle, 157 SetVehicle,
158 SetInertia,
158 159
159 Null //keep this last used do dim the methods array. does nothing but pulsing the prim 160 Null //keep this last used do dim the methods array. does nothing but pulsing the prim
160 } 161 }
@@ -185,7 +186,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
185 186
186 float frictionMovementMult = 0.8f; 187 float frictionMovementMult = 0.8f;
187 188
188 float TerrainBounce = 0.1f; 189 float TerrainBounce = 0.001f;
189 float TerrainFriction = 0.3f; 190 float TerrainFriction = 0.3f;
190 191
191 public float AvatarFriction = 0;// 0.9f * 0.5f; 192 public float AvatarFriction = 0;// 0.9f * 0.5f;
@@ -502,7 +503,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
502 503
503 d.WorldSetGravity(world, gravityx, gravityy, gravityz); 504 d.WorldSetGravity(world, gravityx, gravityy, gravityz);
504 505
505 d.WorldSetLinearDamping(world, 0.002f); 506 d.WorldSetLinearDamping(world, 0.001f);
506 d.WorldSetAngularDamping(world, 0.002f); 507 d.WorldSetAngularDamping(world, 0.002f);
507 d.WorldSetAngularDampingThreshold(world, 0f); 508 d.WorldSetAngularDampingThreshold(world, 0f);
508 d.WorldSetLinearDampingThreshold(world, 0f); 509 d.WorldSetLinearDampingThreshold(world, 0f);
@@ -528,6 +529,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
528 SharedTmpcontact.surface.mode = comumContactFlags; 529 SharedTmpcontact.surface.mode = comumContactFlags;
529 SharedTmpcontact.surface.mu = 0; 530 SharedTmpcontact.surface.mu = 0;
530 SharedTmpcontact.surface.bounce = 0; 531 SharedTmpcontact.surface.bounce = 0;
532 SharedTmpcontact.surface.bounce_vel = 1.5f;
531 SharedTmpcontact.surface.soft_cfm = comumContactCFM; 533 SharedTmpcontact.surface.soft_cfm = comumContactCFM;
532 SharedTmpcontact.surface.soft_erp = comumContactERP; 534 SharedTmpcontact.surface.soft_erp = comumContactERP;
533 SharedTmpcontact.surface.slip1 = comumContactSLIP; 535 SharedTmpcontact.surface.slip1 = comumContactSLIP;
@@ -726,8 +728,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
726 if (g1 == g2) 728 if (g1 == g2)
727 return; // Can't collide with yourself 729 return; // Can't collide with yourself
728 730
729 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) 731// if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
730 return; 732// return;
731 /* 733 /*
732 // debug 734 // debug
733 PhysicsActor dp2; 735 PhysicsActor dp2;
@@ -1082,9 +1084,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1082 case ActorTypes.Prim: 1084 case ActorTypes.Prim:
1083 if (p2events) 1085 if (p2events)
1084 { 1086 {
1085 AddCollisionEventReporting(p2); 1087 //AddCollisionEventReporting(p2);
1086 p2.AddCollisionEvent(p1.ParentActor.LocalID, contact); 1088 p2.AddCollisionEvent(p1.ParentActor.LocalID, contact);
1087 } 1089 }
1090 else if(p1.IsVolumeDtc)
1091 p2.AddVDTCCollisionEvent(p1.ParentActor.LocalID, contact);
1092
1088 obj2LocalID = p2.ParentActor.LocalID; 1093 obj2LocalID = p2.ParentActor.LocalID;
1089 break; 1094 break;
1090 1095
@@ -1098,9 +1103,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1098 { 1103 {
1099 contact.SurfaceNormal = -contact.SurfaceNormal; 1104 contact.SurfaceNormal = -contact.SurfaceNormal;
1100 contact.RelativeSpeed = -contact.RelativeSpeed; 1105 contact.RelativeSpeed = -contact.RelativeSpeed;
1101 AddCollisionEventReporting(p1); 1106 //AddCollisionEventReporting(p1);
1102 p1.AddCollisionEvent(obj2LocalID, contact); 1107 p1.AddCollisionEvent(obj2LocalID, contact);
1103 } 1108 }
1109 else if(p2.IsVolumeDtc)
1110 {
1111 contact.SurfaceNormal = -contact.SurfaceNormal;
1112 contact.RelativeSpeed = -contact.RelativeSpeed;
1113 //AddCollisionEventReporting(p1);
1114 p1.AddVDTCCollisionEvent(obj2LocalID, contact);
1115 }
1104 break; 1116 break;
1105 } 1117 }
1106 case ActorTypes.Ground: 1118 case ActorTypes.Ground:
@@ -1109,7 +1121,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1109 { 1121 {
1110 if (p2events && !p2.IsVolumeDtc) 1122 if (p2events && !p2.IsVolumeDtc)
1111 { 1123 {
1112 AddCollisionEventReporting(p2); 1124 //AddCollisionEventReporting(p2);
1113 p2.AddCollisionEvent(0, contact); 1125 p2.AddCollisionEvent(0, contact);
1114 } 1126 }
1115 break; 1127 break;
@@ -1161,8 +1173,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1161 { 1173 {
1162 aprim.CollisionScore = 0; 1174 aprim.CollisionScore = 0;
1163 aprim.IsColliding = false; 1175 aprim.IsColliding = false;
1176 if(!aprim.m_outbounds && d.BodyIsEnabled(aprim.Body))
1177 aprim.clearSleeperCollisions();
1164 } 1178 }
1165 } 1179 }
1180
1166 lock (_activegroups) 1181 lock (_activegroups)
1167 { 1182 {
1168 try 1183 try
@@ -1657,11 +1672,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1657 1672
1658// d.WorldSetQuickStepNumIterations(world, curphysiteractions); 1673// d.WorldSetQuickStepNumIterations(world, curphysiteractions);
1659 1674
1660 int loopstartMS = Util.EnvironmentTickCount(); 1675 double loopstartMS = Util.GetTimeStampMS();
1661 int looptimeMS = 0; 1676 double looptimeMS = 0;
1662 int changestimeMS = 0; 1677 double changestimeMS = 0;
1663 int maxChangestime = (int)(reqTimeStep * 500f); // half the time 1678 double maxChangestime = (int)(reqTimeStep * 500f); // half the time
1664 int maxLoopTime = (int)(reqTimeStep * 1200f); // 1.2 the time 1679 double maxLoopTime = (int)(reqTimeStep * 1200f); // 1.2 the time
1680
1681// double collisionTime = 0;
1682// double qstepTIme = 0;
1683// double tmpTime = 0;
1665 1684
1666 d.AllocateODEDataForThread(~0U); 1685 d.AllocateODEDataForThread(~0U);
1667 1686
@@ -1684,7 +1703,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1684 item.actor.Name, item.what.ToString()); 1703 item.actor.Name, item.what.ToString());
1685 } 1704 }
1686 } 1705 }
1687 changestimeMS = Util.EnvironmentTickCountSubtract(loopstartMS); 1706 changestimeMS = Util.GetTimeStampMS() - loopstartMS;
1688 if (changestimeMS > maxChangestime) 1707 if (changestimeMS > maxChangestime)
1689 break; 1708 break;
1690 } 1709 }
@@ -1729,9 +1748,19 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1729 1748
1730 m_rayCastManager.ProcessQueuedRequests(); 1749 m_rayCastManager.ProcessQueuedRequests();
1731 1750
1751// tmpTime = Util.GetTimeStampMS();
1732 collision_optimized(); 1752 collision_optimized();
1733 List<OdePrim> sleepers = new List<OdePrim>(); 1753// collisionTime += Util.GetTimeStampMS() - tmpTime;
1754
1755 lock(_collisionEventPrimRemove)
1756 {
1757 foreach (PhysicsActor obj in _collisionEventPrimRemove)
1758 _collisionEventPrim.Remove(obj);
1734 1759
1760 _collisionEventPrimRemove.Clear();
1761 }
1762
1763 List<OdePrim> sleepers = new List<OdePrim>();
1735 foreach (PhysicsActor obj in _collisionEventPrim) 1764 foreach (PhysicsActor obj in _collisionEventPrim)
1736 { 1765 {
1737 if (obj == null) 1766 if (obj == null)
@@ -1761,18 +1790,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1761 foreach(OdePrim prm in sleepers) 1790 foreach(OdePrim prm in sleepers)
1762 prm.SleeperAddCollisionEvents(); 1791 prm.SleeperAddCollisionEvents();
1763 sleepers.Clear(); 1792 sleepers.Clear();
1764 1793
1765 lock(_collisionEventPrimRemove)
1766 {
1767 foreach (PhysicsActor obj in _collisionEventPrimRemove)
1768 _collisionEventPrim.Remove(obj);
1769
1770 _collisionEventPrimRemove.Clear();
1771 }
1772
1773 // do a ode simulation step 1794 // do a ode simulation step
1795// tmpTime = Util.GetTimeStampMS();
1774 d.WorldQuickStep(world, ODE_STEPSIZE); 1796 d.WorldQuickStep(world, ODE_STEPSIZE);
1775 d.JointGroupEmpty(contactgroup); 1797 d.JointGroupEmpty(contactgroup);
1798// qstepTIme += Util.GetTimeStampMS() - tmpTime;
1776 1799
1777 // update managed ideia of physical data and do updates to core 1800 // update managed ideia of physical data and do updates to core
1778 /* 1801 /*
@@ -1813,7 +1836,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1813 step_time -= ODE_STEPSIZE; 1836 step_time -= ODE_STEPSIZE;
1814 nodeframes++; 1837 nodeframes++;
1815 1838
1816 looptimeMS = Util.EnvironmentTickCountSubtract(loopstartMS); 1839 looptimeMS = Util.GetTimeStampMS() - loopstartMS;
1817 if (looptimeMS > maxLoopTime) 1840 if (looptimeMS > maxLoopTime)
1818 break; 1841 break;
1819 } 1842 }
@@ -1882,6 +1905,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1882 int nbodies = d.NTotalBodies; 1905 int nbodies = d.NTotalBodies;
1883 int ngeoms = d.NTotalGeoms; 1906 int ngeoms = d.NTotalGeoms;
1884*/ 1907*/
1908/*
1909 looptimeMS /= nodeframes;
1910 if(looptimeMS > 0.080)
1911 {
1912 collisionTime /= nodeframes;
1913 qstepTIme /= nodeframes;
1914 }
1915*/
1885 // Finished with all sim stepping. If requested, dump world state to file for debugging. 1916 // Finished with all sim stepping. If requested, dump world state to file for debugging.
1886 // TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed? 1917 // TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed?
1887 // TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots? 1918 // TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots?
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
index 163f439..0117800 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
@@ -454,7 +454,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
454 454
455 if (physicsParms == null) 455 if (physicsParms == null)
456 { 456 {
457 m_log.WarnFormat("[MESH]: unknown mesh type for prim {0}",primName); 457 //m_log.WarnFormat("[MESH]: unknown mesh type for prim {0}",primName);
458 return false; 458 return false;
459 } 459 }
460 460
@@ -712,7 +712,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
712 else 712 else
713 { 713 {
714 // if neither mesh or decomposition present, warn and use convex 714 // if neither mesh or decomposition present, warn and use convex
715 m_log.WarnFormat("[MESH]: Data for PRIM shape type ( mesh or decomposition) not found for prim {0}",primName); 715 //m_log.WarnFormat("[MESH]: Data for PRIM shape type ( mesh or decomposition) not found for prim {0}",primName);
716 } 716 }
717 } 717 }
718 vs.Clear(); 718 vs.Clear();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ad7fc6c..47c3cb8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -424,6 +424,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
424 return lease; 424 return lease;
425 } 425 }
426 426
427 protected SceneObjectPart MonitoringObject()
428 {
429 UUID m = m_host.ParentGroup.MonitoringObject;
430 if (m == UUID.Zero)
431 return null;
432
433 SceneObjectPart p = m_ScriptEngine.World.GetSceneObjectPart(m);
434 if (p == null)
435 m_host.ParentGroup.MonitoringObject = UUID.Zero;
436
437 return p;
438 }
439
427 protected virtual void ScriptSleep(int delay) 440 protected virtual void ScriptSleep(int delay)
428 { 441 {
429 delay = (int)((float)delay * m_ScriptDelayFactor); 442 delay = (int)((float)delay * m_ScriptDelayFactor);
@@ -481,12 +494,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
481 { 494 {
482 UUID item; 495 UUID item;
483 496
484 m_host.AddScriptLPS(1); 497 if ((item = GetScriptByName(name)) == UUID.Zero)
485 498 {
486 if ((item = GetScriptByName(name)) != UUID.Zero) 499 m_host.AddScriptLPS(1);
487 m_ScriptEngine.ResetScript(item);
488 else
489 Error("llResetOtherScript", "Can't find script '" + name + "'"); 500 Error("llResetOtherScript", "Can't find script '" + name + "'");
501 return;
502 }
503 if(item == m_item.ItemID)
504 llResetScript();
505 else
506 {
507 m_host.AddScriptLPS(1);
508 m_ScriptEngine.ResetScript(item);
509 }
490 } 510 }
491 511
492 public LSL_Integer llGetScriptState(string name) 512 public LSL_Integer llGetScriptState(string name)
@@ -2712,9 +2732,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2712 /// <param name="adjust">if TRUE, will cap the distance to 10m.</param> 2732 /// <param name="adjust">if TRUE, will cap the distance to 10m.</param>
2713 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) 2733 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust)
2714 { 2734 {
2715 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 2735 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted || part.ParentGroup.inTransit)
2716 return; 2736 return;
2717 2737
2738
2718 LSL_Vector currentPos = GetPartLocalPos(part); 2739 LSL_Vector currentPos = GetPartLocalPos(part);
2719 LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust); 2740 LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust);
2720 2741
@@ -2722,7 +2743,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2722 if (part.ParentGroup.RootPart == part) 2743 if (part.ParentGroup.RootPart == part)
2723 { 2744 {
2724 SceneObjectGroup parent = part.ParentGroup; 2745 SceneObjectGroup parent = part.ParentGroup;
2725 if (!parent.IsAttachment && !World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos)) 2746 if (!parent.IsAttachment && !World.Permissions.CanObjectEntry(parent, false, (Vector3)toPos))
2726 return; 2747 return;
2727 parent.UpdateGroupPosition((Vector3)toPos); 2748 parent.UpdateGroupPosition((Vector3)toPos);
2728 } 2749 }
@@ -5738,29 +5759,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5738 { 5759 {
5739 m_host.AddScriptLPS(1); 5760 m_host.AddScriptLPS(1);
5740 if (index < 0) 5761 if (index < 0)
5741 {
5742 index = src.Length + index; 5762 index = src.Length + index;
5743 } 5763
5744 if (index >= src.Length || index < 0) 5764 if (index >= src.Length || index < 0)
5745 {
5746 return 0; 5765 return 0;
5747 } 5766
5767 object item = src.Data[index];
5748 5768
5749 // Vectors & Rotations always return zero in SL, but 5769 // Vectors & Rotations always return zero in SL, but
5750 // keys don't always return zero, it seems to be a bit complex. 5770 // keys don't always return zero, it seems to be a bit complex.
5751 else if (src.Data[index] is LSL_Vector || 5771 if (item is LSL_Vector || item is LSL_Rotation)
5752 src.Data[index] is LSL_Rotation)
5753 {
5754 return 0; 5772 return 0;
5755 } 5773
5756 try 5774 try
5757 { 5775 {
5758 5776 if (item is LSL_Integer)
5759 if (src.Data[index] is LSL_Integer) 5777 return (LSL_Integer)item;
5760 return (LSL_Integer)src.Data[index]; 5778 else if (item is LSL_Float)
5761 else if (src.Data[index] is LSL_Float) 5779 return Convert.ToInt32(((LSL_Float)item).value);;
5762 return Convert.ToInt32(((LSL_Float)src.Data[index]).value); 5780 return new LSL_Integer(item.ToString());
5763 return new LSL_Integer(src.Data[index].ToString());
5764 } 5781 }
5765 catch (FormatException) 5782 catch (FormatException)
5766 { 5783 {
@@ -5772,38 +5789,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5772 { 5789 {
5773 m_host.AddScriptLPS(1); 5790 m_host.AddScriptLPS(1);
5774 if (index < 0) 5791 if (index < 0)
5775 {
5776 index = src.Length + index; 5792 index = src.Length + index;
5777 } 5793
5778 if (index >= src.Length || index < 0) 5794 if (index >= src.Length || index < 0)
5779 { 5795 return 0;
5780 return 0.0; 5796
5781 } 5797 object item = src.Data[index];
5782 5798
5783 // Vectors & Rotations always return zero in SL 5799 // Vectors & Rotations always return zero in SL
5784 else if (src.Data[index] is LSL_Vector || 5800 if(item is LSL_Vector || item is LSL_Rotation)
5785 src.Data[index] is LSL_Rotation)
5786 {
5787 return 0; 5801 return 0;
5788 } 5802
5789 // valid keys seem to get parsed as integers then converted to floats 5803 // valid keys seem to get parsed as integers then converted to floats
5790 else 5804 if (item is LSL_Key)
5791 { 5805 {
5792 UUID uuidt; 5806 UUID uuidt;
5793 if (src.Data[index] is LSL_Key && UUID.TryParse(src.Data[index].ToString(), out uuidt)) 5807 string s = item.ToString();
5794 { 5808 if(UUID.TryParse(s, out uuidt))
5795 return Convert.ToDouble(new LSL_Integer(src.Data[index].ToString()).value); 5809 return Convert.ToDouble(new LSL_Integer(s).value);
5796 } 5810// we can't do this because a string is also a LSL_Key for now :(
5811// else
5812// return 0;
5797 } 5813 }
5814
5798 try 5815 try
5799 { 5816 {
5800 if (src.Data[index] is LSL_Integer) 5817 if (item is LSL_Integer)
5801 return Convert.ToDouble(((LSL_Integer)src.Data[index]).value); 5818 return Convert.ToDouble(((LSL_Integer)item).value);
5802 else if (src.Data[index] is LSL_Float) 5819 else if (item is LSL_Float)
5803 return Convert.ToDouble(((LSL_Float)src.Data[index]).value); 5820 return Convert.ToDouble(((LSL_Float)item).value);
5804 else if (src.Data[index] is LSL_String) 5821 else if (item is LSL_String)
5805 { 5822 {
5806 string str = ((LSL_String) src.Data[index]).m_string; 5823 string str = ((LSL_String)item).m_string;
5807 Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); 5824 Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)");
5808 if (m != Match.Empty) 5825 if (m != Match.Empty)
5809 { 5826 {
@@ -5811,12 +5828,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5811 double d = 0.0; 5828 double d = 0.0;
5812 if (!Double.TryParse(str, out d)) 5829 if (!Double.TryParse(str, out d))
5813 return 0.0; 5830 return 0.0;
5814
5815 return d; 5831 return d;
5816 } 5832 }
5817 return 0.0; 5833 return 0.0;
5818 } 5834 }
5819 return Convert.ToDouble(src.Data[index]); 5835 return Convert.ToDouble(item);
5820 } 5836 }
5821 catch (FormatException) 5837 catch (FormatException)
5822 { 5838 {
@@ -5828,13 +5844,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5828 { 5844 {
5829 m_host.AddScriptLPS(1); 5845 m_host.AddScriptLPS(1);
5830 if (index < 0) 5846 if (index < 0)
5831 {
5832 index = src.Length + index; 5847 index = src.Length + index;
5833 } 5848
5834 if (index >= src.Length || index < 0) 5849 if (index >= src.Length || index < 0)
5835 {
5836 return String.Empty; 5850 return String.Empty;
5837 } 5851
5838 return src.Data[index].ToString(); 5852 return src.Data[index].ToString();
5839 } 5853 }
5840 5854
@@ -5842,14 +5856,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5842 { 5856 {
5843 m_host.AddScriptLPS(1); 5857 m_host.AddScriptLPS(1);
5844 if (index < 0) 5858 if (index < 0)
5845 {
5846 index = src.Length + index; 5859 index = src.Length + index;
5847 }
5848 5860
5849 if (index >= src.Length || index < 0) 5861 if (index >= src.Length || index < 0)
5850 { 5862 return String.Empty;
5851 return ""; 5863
5852 } 5864 object item = src.Data[index];
5853 5865
5854 // SL spits out an empty string for types other than key & string 5866 // SL spits out an empty string for types other than key & string
5855 // At the time of patching, LSL_Key is currently LSL_String, 5867 // At the time of patching, LSL_Key is currently LSL_String,
@@ -5858,31 +5870,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5858 // as it's own struct 5870 // as it's own struct
5859 // NOTE: 3rd case is needed because a NULL_KEY comes through as 5871 // NOTE: 3rd case is needed because a NULL_KEY comes through as
5860 // type 'obj' and wrongly returns "" 5872 // type 'obj' and wrongly returns ""
5861 else if (!(src.Data[index] is LSL_String || 5873 if (!(item is LSL_String ||
5862 src.Data[index] is LSL_Key || 5874 item is LSL_Key ||
5863 src.Data[index].ToString() == "00000000-0000-0000-0000-000000000000")) 5875 item.ToString() == "00000000-0000-0000-0000-000000000000"))
5864 { 5876 {
5865 return ""; 5877 return String.Empty;
5866 } 5878 }
5867 5879
5868 return src.Data[index].ToString(); 5880 return item.ToString();
5869 } 5881 }
5870 5882
5871 public LSL_Vector llList2Vector(LSL_List src, int index) 5883 public LSL_Vector llList2Vector(LSL_List src, int index)
5872 { 5884 {
5873 m_host.AddScriptLPS(1); 5885 m_host.AddScriptLPS(1);
5874 if (index < 0) 5886 if (index < 0)
5875 {
5876 index = src.Length + index; 5887 index = src.Length + index;
5877 } 5888
5878 if (index >= src.Length || index < 0) 5889 if (index >= src.Length || index < 0)
5879 {
5880 return new LSL_Vector(0, 0, 0); 5890 return new LSL_Vector(0, 0, 0);
5881 } 5891
5882 if (src.Data[index].GetType() == typeof(LSL_Vector)) 5892 object item = src.Data[index];
5883 { 5893
5884 return (LSL_Vector)src.Data[index]; 5894 if (item.GetType() == typeof(LSL_Vector))
5885 } 5895 return (LSL_Vector)item;
5886 5896
5887 // SL spits always out ZERO_VECTOR for anything other than 5897 // SL spits always out ZERO_VECTOR for anything other than
5888 // strings or vectors. Although keys always return ZERO_VECTOR, 5898 // strings or vectors. Although keys always return ZERO_VECTOR,
@@ -5890,28 +5900,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5890 // a string, a key as string and a string that by coincidence 5900 // a string, a key as string and a string that by coincidence
5891 // is a string, so we're going to leave that up to the 5901 // is a string, so we're going to leave that up to the
5892 // LSL_Vector constructor. 5902 // LSL_Vector constructor.
5893 else if (!(src.Data[index] is LSL_String || 5903 if(item is LSL_Vector)
5894 src.Data[index] is LSL_Vector)) 5904 return (LSL_Vector) item;
5895 { 5905
5896 return new LSL_Vector(0, 0, 0); 5906 if (item is LSL_String)
5897 } 5907 return new LSL_Vector(item.ToString());
5898 else 5908
5899 { 5909 return new LSL_Vector(0, 0, 0);
5900 return new LSL_Vector(src.Data[index].ToString());
5901 }
5902 } 5910 }
5903 5911
5904 public LSL_Rotation llList2Rot(LSL_List src, int index) 5912 public LSL_Rotation llList2Rot(LSL_List src, int index)
5905 { 5913 {
5906 m_host.AddScriptLPS(1); 5914 m_host.AddScriptLPS(1);
5907 if (index < 0) 5915 if (index < 0)
5908 {
5909 index = src.Length + index; 5916 index = src.Length + index;
5910 } 5917
5911 if (index >= src.Length || index < 0) 5918 if (index >= src.Length || index < 0)
5912 {
5913 return new LSL_Rotation(0, 0, 0, 1); 5919 return new LSL_Rotation(0, 0, 0, 1);
5914 } 5920
5921 object item = src.Data[index];
5915 5922
5916 // SL spits always out ZERO_ROTATION for anything other than 5923 // SL spits always out ZERO_ROTATION for anything other than
5917 // strings or vectors. Although keys always return ZERO_ROTATION, 5924 // strings or vectors. Although keys always return ZERO_ROTATION,
@@ -5919,19 +5926,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5919 // a string, a key as string and a string that by coincidence 5926 // a string, a key as string and a string that by coincidence
5920 // is a string, so we're going to leave that up to the 5927 // is a string, so we're going to leave that up to the
5921 // LSL_Rotation constructor. 5928 // LSL_Rotation constructor.
5922 else if (!(src.Data[index] is LSL_String || 5929
5923 src.Data[index] is LSL_Rotation)) 5930 if (item.GetType() == typeof(LSL_Rotation))
5924 { 5931 return (LSL_Rotation)item;
5925 return new LSL_Rotation(0, 0, 0, 1); 5932
5926 } 5933 if (item is LSL_String)
5927 else if (src.Data[index].GetType() == typeof(LSL_Rotation))
5928 {
5929 return (LSL_Rotation)src.Data[index];
5930 }
5931 else
5932 {
5933 return new LSL_Rotation(src.Data[index].ToString()); 5934 return new LSL_Rotation(src.Data[index].ToString());
5934 } 5935
5936 return new LSL_Rotation(0, 0, 0, 1);
5935 } 5937 }
5936 5938
5937 public LSL_List llList2List(LSL_List src, int start, int end) 5939 public LSL_List llList2List(LSL_List src, int start, int end)
@@ -7963,7 +7965,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7963 public LSL_Integer llScriptDanger(LSL_Vector pos) 7965 public LSL_Integer llScriptDanger(LSL_Vector pos)
7964 { 7966 {
7965 m_host.AddScriptLPS(1); 7967 m_host.AddScriptLPS(1);
7966 bool result = World.ScriptDanger(m_host.LocalId, pos); 7968 bool result = World.LSLScriptDanger(m_host, pos);
7967 if (result) 7969 if (result)
7968 { 7970 {
7969 return 1; 7971 return 1;
@@ -7972,7 +7974,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7972 { 7974 {
7973 return 0; 7975 return 0;
7974 } 7976 }
7975
7976 } 7977 }
7977 7978
7978 public void llDialog(string avatar, string message, LSL_List buttons, int chat_channel) 7979 public void llDialog(string avatar, string message, LSL_List buttons, int chat_channel)
@@ -8849,10 +8850,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8849 } 8850 }
8850 8851
8851 public void llSetPhysicsMaterial(int material_bits, 8852 public void llSetPhysicsMaterial(int material_bits,
8852 float material_gravity_modifier, float material_restitution, 8853 LSL_Float material_gravity_modifier, LSL_Float material_restitution,
8853 float material_friction, float material_density) 8854 LSL_Float material_friction, LSL_Float material_density)
8854 { 8855 {
8855 SetPhysicsMaterial(m_host, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); 8856 SetPhysicsMaterial(m_host, material_bits, (float)material_density, (float)material_friction, (float)material_restitution, (float)material_gravity_modifier);
8856 } 8857 }
8857 8858
8858 // vector up using libomv (c&p from sop ) 8859 // vector up using libomv (c&p from sop )
@@ -11297,6 +11298,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11297 } 11298 }
11298 break; 11299 break;
11299 11300
11301 case (int)ScriptBaseClass.PRIM_NORMAL:
11302 case (int)ScriptBaseClass.PRIM_SPECULAR:
11303 case (int)ScriptBaseClass.PRIM_ALPHA_MODE:
11304 if (remain < 1)
11305 return new LSL_List();
11306
11307 face = (int)rules.GetLSLIntegerItem(idx++);
11308 tex = part.Shape.Textures;
11309 if (face == ScriptBaseClass.ALL_SIDES)
11310 {
11311 for (face = 0; face < GetNumberOfSides(part); face++)
11312 {
11313 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
11314 getLSLFaceMaterial(ref res, code, part, texface);
11315 }
11316 }
11317 else
11318 {
11319 if (face >= 0 && face < GetNumberOfSides(part))
11320 {
11321 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
11322 getLSLFaceMaterial(ref res, code, part, texface);
11323 }
11324 }
11325 break;
11326
11300 case (int)ScriptBaseClass.PRIM_LINK_TARGET: 11327 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
11301 11328
11302 // TODO: Should be issuing a runtime script warning in this case. 11329 // TODO: Should be issuing a runtime script warning in this case.
@@ -11310,6 +11337,108 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11310 return new LSL_List(); 11337 return new LSL_List();
11311 } 11338 }
11312 11339
11340/*
11341 private string filterTextureUUIDbyRights(UUID origID, SceneObjectPart part, bool checkTaskInventory, bool returnInvName)
11342 {
11343 if(checkTaskInventory)
11344 {
11345 lock (part.TaskInventory)
11346 {
11347 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in part.TaskInventory)
11348 {
11349 if (inv.Value.AssetID == origID)
11350 {
11351 if(inv.Value.InvType == (int)InventoryType.Texture)
11352 {
11353 if(returnInvName)
11354 return inv.Value.Name;
11355 else
11356 return origID.ToString();
11357 }
11358 else
11359 return UUID.Zero.ToString();
11360 }
11361 }
11362 }
11363 }
11364
11365 if(World.Permissions.CanEditObject(m_host.ParentGroup.UUID, m_host.ParentGroup.RootPart.OwnerID))
11366 return origID.ToString();
11367
11368 return UUID.Zero.ToString();
11369 }
11370*/
11371 private void getLSLFaceMaterial(ref LSL_List res, int code, SceneObjectPart part, Primitive.TextureEntryFace texface)
11372 {
11373 UUID matID = texface.MaterialID;
11374 if(matID != UUID.Zero)
11375 {
11376 AssetBase MatAsset = World.AssetService.Get(matID.ToString());
11377 if(MatAsset != null)
11378 {
11379 Byte[] data = MatAsset.Data;
11380 OSDMap osdmat = (OSDMap)OSDParser.DeserializeLLSDXml(data);
11381 if(osdmat != null && osdmat.ContainsKey("NormMap"))
11382 {
11383 string mapIDstr;
11384 FaceMaterial mat = new FaceMaterial(matID, osdmat);
11385 if(code == ScriptBaseClass.PRIM_NORMAL)
11386 {
11387// mapIDstr = filterTextureUUIDbyRights(mat.NormalMapID, part, true, false);
11388 mapIDstr = mat.NormalMapID.ToString();
11389 res.Add(new LSL_String(mapIDstr));
11390 res.Add(new LSL_Vector(mat.NormalRepeatX, mat.NormalRepeatY, 0));
11391 res.Add(new LSL_Vector(mat.NormalOffsetX, mat.NormalOffsetY, 0));
11392 res.Add(new LSL_Float(mat.NormalRotation));
11393 }
11394 else if(code == ScriptBaseClass.PRIM_SPECULAR )
11395 {
11396// mapIDstr = filterTextureUUIDbyRights(mat.SpecularMapID, part, true, false);
11397 const float colorScale = 1.0f/255f;
11398 mapIDstr = mat.SpecularMapID.ToString();
11399 res.Add(new LSL_String(mapIDstr));
11400 res.Add(new LSL_Vector(mat.SpecularRepeatX, mat.SpecularRepeatY, 0));
11401 res.Add(new LSL_Vector(mat.SpecularOffsetX, mat.SpecularOffsetY, 0));
11402 res.Add(new LSL_Float(mat.SpecularRotation));
11403 res.Add(new LSL_Vector(mat.SpecularLightColor.R * colorScale,
11404 mat.SpecularLightColor.G * colorScale,
11405 mat.SpecularLightColor.B * colorScale));
11406 res.Add(new LSL_Integer(mat.SpecularLightExponent));
11407 res.Add(new LSL_Integer(mat.EnvironmentIntensity));
11408 }
11409 else if(code == ScriptBaseClass.PRIM_ALPHA_MODE)
11410 {
11411 res.Add(new LSL_Integer(mat.DiffuseAlphaMode));
11412 res.Add(new LSL_Integer(mat.AlphaMaskCutoff));
11413 }
11414 return;
11415 }
11416 }
11417 matID = UUID.Zero;
11418 }
11419 if(matID == UUID.Zero)
11420 {
11421 if(code == (int)ScriptBaseClass.PRIM_NORMAL || code == (int)ScriptBaseClass.PRIM_SPECULAR )
11422 {
11423 res.Add(new LSL_String(UUID.Zero.ToString()));
11424 res.Add(new LSL_Vector(1.0, 1.0, 0));
11425 res.Add(new LSL_Vector(0, 0, 0));
11426 res.Add(new LSL_Float(0));
11427
11428 if(code == (int)ScriptBaseClass.PRIM_SPECULAR)
11429 {
11430 res.Add(new LSL_Vector(1.0, 1.0, 1.0));
11431 res.Add(new LSL_Integer(51));
11432 res.Add(new LSL_Integer(0));
11433 }
11434 }
11435 else if(code == (int)ScriptBaseClass.PRIM_ALPHA_MODE)
11436 {
11437 res.Add(new LSL_Integer(1));
11438 res.Add(new LSL_Integer(0));
11439 }
11440 }
11441 }
11313 11442
11314 public LSL_List llGetPrimMediaParams(int face, LSL_List rules) 11443 public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
11315 { 11444 {
@@ -15867,7 +15996,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
15867 return; 15996 return;
15868 } 15997 }
15869 15998
15870 group.RootPart.AttachPoint = group.RootPart.Shape.State;
15871 group.RootPart.AttachedPos = group.AbsolutePosition; 15999 group.RootPart.AttachedPos = group.AbsolutePosition;
15872 16000
15873 group.ResetIDs(); 16001 group.ResetIDs();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index e769c6d..e12cedf 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -260,7 +260,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
260 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); 260 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
261 } 261 }
262 262
263 // Returns of the function is allowed. Throws a script exception if not allowed. 263 // Returns if OSSL is enabled. Throws a script exception if OSSL is not allowed..
264 // for safe funtions always active
265 public void CheckThreatLevel()
266 {
267 if (!m_OSFunctionsEnabled)
268 OSSLError(String.Format("{0} permission denied. All OS functions are disabled.")); // throws
269 }
270
271 // Returns if the function is allowed. Throws a script exception if not allowed.
264 public void CheckThreatLevel(ThreatLevel level, string function) 272 public void CheckThreatLevel(ThreatLevel level, string function)
265 { 273 {
266 if (!m_OSFunctionsEnabled) 274 if (!m_OSFunctionsEnabled)
@@ -1716,7 +1724,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1716 1724
1717 public LSL_Integer osCheckODE() 1725 public LSL_Integer osCheckODE()
1718 { 1726 {
1727 CheckThreatLevel();
1719 m_host.AddScriptLPS(1); 1728 m_host.AddScriptLPS(1);
1729
1720 LSL_Integer ret = 0; // false 1730 LSL_Integer ret = 0; // false
1721 if (m_ScriptEngine.World.PhysicsScene != null) 1731 if (m_ScriptEngine.World.PhysicsScene != null)
1722 { 1732 {
@@ -1757,10 +1767,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1757 1767
1758 public string osGetPhysicsEngineName() 1768 public string osGetPhysicsEngineName()
1759 { 1769 {
1760 // not doing security checks 1770 CheckThreatLevel();
1761 // this whould limit the use of this
1762
1763 m_host.AddScriptLPS(1); 1771 m_host.AddScriptLPS(1);
1772
1764 string ret = "NoEngine"; 1773 string ret = "NoEngine";
1765 if (m_ScriptEngine.World.PhysicsScene != null) 1774 if (m_ScriptEngine.World.PhysicsScene != null)
1766 { 1775 {
@@ -1771,6 +1780,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1771 } 1780 }
1772 return ret; 1781 return ret;
1773 } 1782 }
1783
1774 public string osGetSimulatorVersion() 1784 public string osGetSimulatorVersion()
1775 { 1785 {
1776 // High because it can be used to target attacks to known weaknesses 1786 // High because it can be used to target attacks to known weaknesses
@@ -2038,6 +2048,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2038 m_host.Inventory.AddInventoryItemExclusive(taskItem, false); 2048 m_host.Inventory.AddInventoryItemExclusive(taskItem, false);
2039 else 2049 else
2040 m_host.Inventory.AddInventoryItem(taskItem, false); 2050 m_host.Inventory.AddInventoryItem(taskItem, false);
2051 m_host.ParentGroup.AggregatePerms();
2041 2052
2042 return taskItem; 2053 return taskItem;
2043 } 2054 }
@@ -3537,7 +3548,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3537 3548
3538 LSL_Float health = new LSL_Float(-1); 3549 LSL_Float health = new LSL_Float(-1);
3539 ScenePresence presence = World.GetScenePresence(new UUID(avatar)); 3550 ScenePresence presence = World.GetScenePresence(new UUID(avatar));
3540 if (presence != null) health = presence.Health; 3551 if (presence != null)
3552 health = presence.Health;
3541 return health; 3553 return health;
3542 } 3554 }
3543 3555
@@ -3577,7 +3589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3577 UUID avatarId = new UUID(avatar); 3589 UUID avatarId = new UUID(avatar);
3578 ScenePresence presence = World.GetScenePresence(avatarId); 3590 ScenePresence presence = World.GetScenePresence(avatarId);
3579 3591
3580 if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) 3592 if (presence != null)
3581 { 3593 {
3582 float health = presence.Health; 3594 float health = presence.Health;
3583 health += (float)healing; 3595 health += (float)healing;
@@ -3597,7 +3609,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3597 UUID avatarId = new UUID(avatar); 3609 UUID avatarId = new UUID(avatar);
3598 ScenePresence presence = World.GetScenePresence(avatarId); 3610 ScenePresence presence = World.GetScenePresence(avatarId);
3599 3611
3600 if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) 3612 if (presence != null)
3601 { 3613 {
3602 if (health > 100.0) 3614 if (health > 100.0)
3603 health = 100.0; 3615 health = 100.0;
@@ -3616,7 +3628,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3616 UUID avatarId = new UUID(avatar); 3628 UUID avatarId = new UUID(avatar);
3617 ScenePresence presence = World.GetScenePresence(avatarId); 3629 ScenePresence presence = World.GetScenePresence(avatarId);
3618 3630
3619 if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) 3631 if (presence != null)
3620 presence.HealRate = (float)healrate; 3632 presence.HealRate = (float)healrate;
3621 } 3633 }
3622 3634
@@ -4362,6 +4374,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4362 4374
4363 public void osCollisionSound(string impact_sound, double impact_volume) 4375 public void osCollisionSound(string impact_sound, double impact_volume)
4364 { 4376 {
4377 CheckThreatLevel();
4365 m_host.AddScriptLPS(1); 4378 m_host.AddScriptLPS(1);
4366 4379
4367 if(impact_sound == "") 4380 if(impact_sound == "")
@@ -4394,6 +4407,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4394 // still not very usefull, detector is lost on rez, restarts, etc 4407 // still not very usefull, detector is lost on rez, restarts, etc
4395 public void osVolumeDetect(int detect) 4408 public void osVolumeDetect(int detect)
4396 { 4409 {
4410 CheckThreatLevel();
4397 m_host.AddScriptLPS(1); 4411 m_host.AddScriptLPS(1);
4398 4412
4399 if (m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted || m_host.ParentGroup.IsAttachment) 4413 if (m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted || m_host.ParentGroup.IsAttachment)
@@ -4402,5 +4416,285 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4402 m_host.ScriptSetVolumeDetect(detect != 0); 4416 m_host.ScriptSetVolumeDetect(detect != 0);
4403 } 4417 }
4404 4418
4419 /// <summary>
4420 /// Get inertial data
4421 /// </summary>
4422 /// <remarks>
4423 /// </remarks>
4424 /// <returns>
4425 /// a LSL list with contents:
4426 /// LSL_Float mass, the total mass of a linkset
4427 /// LSL_Vector CenterOfMass, center mass relative to root prim
4428 /// LSL_Vector Inertia, elements of diagonal of inertia Ixx,Iyy,Izz divided by total mass
4429 /// LSL_Vector aux, elements of upper triagle of inertia Ixy (= Iyx), Ixz (= Izx), Iyz(= Izy) divided by total mass
4430 /// </returns>
4431 public LSL_List osGetInertiaData()
4432 {
4433 CheckThreatLevel();
4434 m_host.AddScriptLPS(1);
4435
4436 LSL_List result = new LSL_List();
4437 float TotalMass;
4438 Vector3 CenterOfMass;
4439 Vector3 Inertia;
4440 Vector4 aux;
4441
4442 SceneObjectGroup sog = m_host.ParentGroup;
4443 if(sog== null || sog.IsDeleted)
4444 return result;
4445
4446 sog.GetInertiaData(out TotalMass, out CenterOfMass, out Inertia, out aux );
4447 if(TotalMass > 0)
4448 {
4449 float t = 1.0f/TotalMass;
4450 Inertia.X *= t;
4451 Inertia.Y *= t;
4452 Inertia.Z *= t;
4453
4454 aux.X *= t;
4455 aux.Y *= t;
4456 aux.Z *= t;
4457 }
4458
4459 result.Add(new LSL_Float(TotalMass));
4460 result.Add(new LSL_Vector(CenterOfMass.X, CenterOfMass.Y, CenterOfMass.Z));
4461 result.Add(new LSL_Vector(Inertia.X, Inertia.Y, Inertia.Z));
4462 result.Add(new LSL_Vector(aux.X, aux.Y, aux.Z));
4463 return result;
4464 }
4465
4466 /// <summary>
4467 /// set inertial data
4468 /// replaces the automatic calculation of mass, center of mass and inertia
4469 ///
4470 /// </summary>
4471 /// <param name="Mass">total mass of linkset</param>
4472 /// <param name="centerOfMass">location of center of mass relative to root prim in local coords</param>
4473 /// <param name="principalInertiaScaled">moment of inertia relative to principal axis and center of mass,Ixx, Iyy, Izz divided by mass</param>
4474 /// <param name="lslrot">rotation of the inertia, relative to local axis</param>
4475 /// <remarks>
4476 /// the inertia argument is is inertia divided by mass, so corresponds only to the geometric distribution of mass and both can be changed independently.
4477 /// </remarks>
4478
4479 public void osSetInertia(LSL_Float mass, LSL_Vector centerOfMass, LSL_Vector principalInertiaScaled, LSL_Rotation lslrot)
4480 {
4481 CheckThreatLevel();
4482 m_host.AddScriptLPS(1);
4483
4484 SceneObjectGroup sog = m_host.ParentGroup;
4485 if(sog== null || sog.IsDeleted)
4486 return;
4487
4488 if(mass < 0 || principalInertiaScaled.x < 0 || principalInertiaScaled.y < 0 || principalInertiaScaled.z < 0)
4489 return;
4490
4491 // need more checks
4492
4493 Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z);
4494 Vector3 Inertia;
4495 float m = (float)mass;
4496
4497 Inertia.X = m * (float)principalInertiaScaled.x;
4498 Inertia.Y = m * (float)principalInertiaScaled.y;
4499 Inertia.Z = m * (float)principalInertiaScaled.z;
4500
4501 Vector4 rot = new Vector4((float)lslrot.x, (float)lslrot.y, (float)lslrot.y, (float)lslrot.s);
4502 rot.Normalize();
4503
4504 sog.SetInertiaData(m, CenterOfMass, Inertia, rot );
4505 }
4506
4507 /// <summary>
4508 /// set inertial data as a sphere
4509 /// replaces the automatic calculation of mass, center of mass and inertia
4510 ///
4511 /// </summary>
4512 /// <param name="Mass">total mass of linkset</param>
4513 /// <param name="boxsize">size of the Box</param>
4514 /// <param name="centerOfMass">location of center of mass relative to root prim in local coords</param>
4515 /// <param name="lslrot">rotation of the box, and so inertia, relative to local axis</param>
4516 /// <remarks>
4517 /// </remarks>
4518 public void osSetInertiaAsBox(LSL_Float mass, LSL_Vector boxSize, LSL_Vector centerOfMass, LSL_Rotation lslrot)
4519 {
4520 CheckThreatLevel();
4521 m_host.AddScriptLPS(1);
4522
4523 SceneObjectGroup sog = m_host.ParentGroup;
4524 if(sog== null || sog.IsDeleted)
4525 return;
4526
4527 if(mass < 0)
4528 return;
4529
4530 // need more checks
4531
4532 Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z);
4533 Vector3 Inertia;
4534 float lx = (float)boxSize.x;
4535 float ly = (float)boxSize.y;
4536 float lz = (float)boxSize.z;
4537 float m = (float)mass;
4538 float t = m / 12.0f;
4539
4540 Inertia.X = t * (ly*ly + lz*lz);
4541 Inertia.Y = t * (lx*lx + lz*lz);
4542 Inertia.Z = t * (lx*lx + ly*ly);
4543
4544 Vector4 rot = new Vector4((float)lslrot.x, (float)lslrot.y, (float)lslrot.z, (float)lslrot.s);
4545 rot.Normalize();
4546
4547 sog.SetInertiaData(m, CenterOfMass, Inertia, rot );
4548 }
4549
4550 /// <summary>
4551 /// set inertial data as a sphere
4552 /// replaces the automatic calculation of mass, center of mass and inertia
4553 ///
4554 /// </summary>
4555 /// <param name="Mass">total mass of linkset</param>
4556 /// <param name="radius">radius of the sphere</param>
4557 /// <param name="centerOfMass">location of center of mass relative to root prim in local coords</param>
4558 /// <remarks>
4559 /// </remarks>
4560 public void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, LSL_Vector centerOfMass)
4561 {
4562 CheckThreatLevel();
4563 m_host.AddScriptLPS(1);
4564
4565 SceneObjectGroup sog = m_host.ParentGroup;
4566 if(sog== null || sog.IsDeleted)
4567 return;
4568
4569 if(mass < 0)
4570 return;
4571
4572 // need more checks
4573
4574 Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z);
4575 Vector3 Inertia;
4576 float r = (float)radius;
4577 float m = (float)mass;
4578 float t = 0.4f * m * r * r;
4579
4580 Inertia.X = t;
4581 Inertia.Y = t;
4582 Inertia.Z = t;
4583
4584 sog.SetInertiaData(m, CenterOfMass, Inertia, new Vector4(0f, 0f, 0f,1.0f));
4585 }
4586
4587 /// <summary>
4588 /// set inertial data as a cylinder
4589 /// replaces the automatic calculation of mass, center of mass and inertia
4590 ///
4591 /// </summary>
4592 /// <param name="Mass">total mass of linkset</param>
4593 /// <param name="radius">radius of the cylinder</param>
4594 /// <param name="lenght">lenght of the cylinder</param>
4595 /// <param name="centerOfMass">location of center of mass relative to root prim in local coords</param>
4596 /// <param name="lslrot">rotation of the cylinder, and so inertia, relative to local axis</param>
4597 /// <remarks>
4598 /// cylinder axis aligned with Z axis. For other orientations provide the rotation.
4599 /// </remarks>
4600 public void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, LSL_Vector centerOfMass, LSL_Rotation lslrot)
4601 {
4602 CheckThreatLevel();
4603 m_host.AddScriptLPS(1);
4604
4605 SceneObjectGroup sog = m_host.ParentGroup;
4606 if(sog== null || sog.IsDeleted)
4607 return;
4608
4609 if(mass < 0)
4610 return;
4611
4612 // need more checks
4613
4614 Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z);
4615 Vector3 Inertia;
4616 float m = (float)mass;
4617 float r = (float)radius;
4618 r *= r;
4619 Inertia.Z = 0.5f * m * r;
4620 float t = (float)lenght;
4621 t *= t;
4622 t += 3.0f * r;
4623 t *= 8.333333e-2f * m;
4624
4625 Inertia.X = t;
4626 Inertia.Y = t;
4627
4628 Vector4 rot = new Vector4((float)lslrot.x, (float)lslrot.y, (float)lslrot.z, (float)lslrot.s);
4629 rot.Normalize();
4630
4631 sog.SetInertiaData(m, CenterOfMass, Inertia, rot);
4632 }
4633
4634 /// <summary>
4635 /// removes inertial data manual override
4636 /// default automatic calculation is used again
4637 ///
4638 /// </summary>
4639 public void osClearInertia()
4640 {
4641 CheckThreatLevel();
4642 m_host.AddScriptLPS(1);
4643
4644 SceneObjectGroup sog = m_host.ParentGroup;
4645 if(sog== null || sog.IsDeleted)
4646 return;
4647
4648 sog.SetInertiaData(-1, Vector3.Zero, Vector3.Zero, Vector4.Zero );
4649 }
4650
4651 /// <summary>
4652 /// teleports a object (full linkset)
4653 /// </summary>
4654 /// <param name="objectUUID">the id of the linkset to teleport</param>
4655 /// <param name="targetPos">target position</param>
4656 /// <param name="rotation"> a rotation to apply</param>
4657 /// <param name="flags">several flags/param>
4658 /// <remarks>
4659 /// only does teleport local to region
4660 /// if object has scripts, owner must have rights to run scripts on target location
4661 /// object owner must have rights to enter ojects on target location
4662 /// target location parcel must have enought free prims capacity for the linkset prims
4663 /// all avatars siting on the object must have access to target location
4664 /// has a cool down time. retries before expire reset it
4665 /// fail conditions are silent ignored
4666 /// </remarks>
4667 public LSL_Integer osTeleportObject(LSL_Key objectUUID, LSL_Vector targetPos, LSL_Rotation rotation, LSL_Integer flags)
4668 {
4669 CheckThreatLevel(ThreatLevel.Severe, "osTeleportObject");
4670 m_host.AddScriptLPS(1);
4671
4672 UUID objUUID;
4673 if (!UUID.TryParse(objectUUID, out objUUID))
4674 {
4675 OSSLShoutError("osTeleportObject() invalid object Key");
4676 return -1;
4677 }
4678
4679 SceneObjectGroup sog = World.GetSceneObjectGroup(objUUID);
4680 if(sog== null || sog.IsDeleted)
4681 return -1;
4682
4683 UUID myid = m_host.ParentGroup.UUID;
4684
4685 return sog.TeleportObject(myid, targetPos, rotation, flags);
4686 // a delay here may break vehicles
4687 }
4688
4689 public LSL_Integer osGetLinkNumber(LSL_String name)
4690 {
4691 CheckThreatLevel();
4692 m_host.AddScriptLPS(1);
4693
4694 SceneObjectGroup sog = m_host.ParentGroup;
4695 if(sog== null || sog.IsDeleted)
4696 return -1;
4697 return sog.GetLinkNumber(name);
4698 }
4405 } 4699 }
4406} 4700}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index cc52403..17c977f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -434,7 +434,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
434 LSL_String llXorBase64Strings(string str1, string str2); 434 LSL_String llXorBase64Strings(string str1, string str2);
435 LSL_String llXorBase64StringsCorrect(string str1, string str2); 435 LSL_String llXorBase64StringsCorrect(string str1, string str2);
436 LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); 436 LSL_Integer llGetLinkNumberOfSides(LSL_Integer link);
437 void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density); 437 void llSetPhysicsMaterial(int material_bits, LSL_Float material_gravity_modifier, LSL_Float material_restitution, LSL_Float material_friction, LSL_Float material_density);
438 438
439 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc); 439 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc);
440 void llSetKeyframedMotion(LSL_List frames, LSL_List options); 440 void llSetKeyframedMotion(LSL_List frames, LSL_List options);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index bee060a..bd5d008 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -38,6 +38,7 @@ using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
38using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; 38using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
39using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; 39using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
40 40
41
41namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces 42namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
42{ 43{
43 /// <summary> 44 /// <summary>
@@ -50,7 +51,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
50 /// </summary> 51 /// </summary>
51 public enum ThreatLevel 52 public enum ThreatLevel
52 { 53 {
53 // Not documented, presumably means permanently disabled ?
54 NoAccess = -1, 54 NoAccess = -1,
55 55
56 /// <summary> 56 /// <summary>
@@ -486,6 +486,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
486 LSL_String osRequestURL(LSL_List options); 486 LSL_String osRequestURL(LSL_List options);
487 LSL_String osRequestSecureURL(LSL_List options); 487 LSL_String osRequestSecureURL(LSL_List options);
488 void osCollisionSound(string impact_sound, double impact_volume); 488 void osCollisionSound(string impact_sound, double impact_volume);
489
489 void osVolumeDetect(int detect); 490 void osVolumeDetect(int detect);
491
492 LSL_List osGetInertiaData();
493 void osClearInertia();
494 void osSetInertiaAsBox(LSL_Float mass, vector boxSize, vector centerOfMass, rotation rot);
495 void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, vector centerOfMass);
496 void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot);
497
498 LSL_Integer osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags);
499 LSL_Integer osGetLinkNumber(LSL_String name);
490 } 500 }
491} 501}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 3a90c77..ce0fa48 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -853,5 +853,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
853 /// process message parameter as regex 853 /// process message parameter as regex
854 /// </summary> 854 /// </summary>
855 public const int OS_LISTEN_REGEX_MESSAGE = 0x2; 855 public const int OS_LISTEN_REGEX_MESSAGE = 0x2;
856
857 // for osTeleportObject
858 public const int OSTPOBJ_NONE = 0x0;
859 public const int OSTPOBJ_STOPATTARGET = 0x1; // stops at destination
860 public const int OSTPOBJ_STOPONFAIL = 0x2; // stops at jump point if tp fails
861 public const int OSTPOBJ_SETROT = 0x4; // the rotation is the final rotation, otherwise is a added rotation
862
856 } 863 }
857} 864}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 1a42c3a..c39248b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -2036,7 +2036,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
2036 m_LSL_Functions.llSetKeyframedMotion(frames, options); 2036 m_LSL_Functions.llSetKeyframedMotion(frames, options);
2037 } 2037 }
2038 2038
2039 public void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density) 2039 public void llSetPhysicsMaterial(int material_bits, LSL_Float material_gravity_modifier, LSL_Float material_restitution, LSL_Float material_friction, LSL_Float material_density)
2040 { 2040 {
2041 m_LSL_Functions.llSetPhysicsMaterial(material_bits, material_gravity_modifier, material_restitution, material_friction, material_density); 2041 m_LSL_Functions.llSetPhysicsMaterial(material_bits, material_gravity_modifier, material_restitution, material_friction, material_density);
2042 } 2042 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 6164734..9eac114 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -1114,5 +1114,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1114 { 1114 {
1115 m_OSSL_Functions.osVolumeDetect(detect); 1115 m_OSSL_Functions.osVolumeDetect(detect);
1116 } 1116 }
1117
1118 public LSL_List osGetInertiaData()
1119 {
1120 return m_OSSL_Functions.osGetInertiaData();
1121 }
1122
1123 public void osSetInertiaAsBox(LSL_Float mass, vector boxSize, vector centerOfMass, rotation rot)
1124 {
1125 m_OSSL_Functions.osSetInertiaAsBox(mass, boxSize, centerOfMass, rot);
1126 }
1127
1128 public void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, vector centerOfMass)
1129 {
1130 m_OSSL_Functions.osSetInertiaAsSphere(mass, radius, centerOfMass);
1131 }
1132
1133 public void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot)
1134 {
1135 m_OSSL_Functions.osSetInertiaAsCylinder( mass, radius, lenght, centerOfMass, lslrot);
1136 }
1137
1138 public void osClearInertia()
1139 {
1140 m_OSSL_Functions.osClearInertia();
1141 }
1142
1143 public LSL_Integer osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags)
1144 {
1145 return m_OSSL_Functions.osTeleportObject(objectUUID, targetPos, targetrotation, flags);
1146 }
1147
1148 public LSL_Integer osGetLinkNumber(LSL_String name)
1149 {
1150 return m_OSSL_Functions.osGetLinkNumber(name);
1151 }
1117 } 1152 }
1118} 1153}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
index d652b0d1..16b87b3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
@@ -39,6 +39,7 @@ using OpenSim.Framework;
39using OpenSim.Region.CoreModules.Avatar.AvatarFactory; 39using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.OptionalModules.World.NPC; 40using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.CoreModules.World.Permissions;
42using OpenSim.Region.ScriptEngine.Shared; 43using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api; 44using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Region.ScriptEngine.Shared.Instance; 45using OpenSim.Region.ScriptEngine.Shared.Instance;
@@ -63,12 +64,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
63 base.SetUp(); 64 base.SetUp();
64 65
65 IConfigSource initConfigSource = new IniConfigSource(); 66 IConfigSource initConfigSource = new IniConfigSource();
66 IConfig config = initConfigSource.AddConfig("XEngine"); 67 IConfig config = initConfigSource.AddConfig("Startup");
68 config.Set("serverside_object_permissions", true);
69 config =initConfigSource.AddConfig("Permissions");
70 config.Set("permissionmodules", "DefaultPermissionsModule");
71 config.Set("serverside_object_permissions", true);
72 config.Set("propagate_permissions", true);
73
74 config = initConfigSource.AddConfig("XEngine");
67 config.Set("Enabled", "true"); 75 config.Set("Enabled", "true");
68 76
69 m_scene = new SceneHelpers().SetupScene(); 77 m_scene = new SceneHelpers().SetupScene();
70 SceneHelpers.SetupSceneModules(m_scene, initConfigSource); 78 SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new object[] { new DefaultPermissionsModule() });
71
72 m_engine = new XEngine.XEngine(); 79 m_engine = new XEngine.XEngine();
73 m_engine.Initialise(initConfigSource); 80 m_engine.Initialise(initConfigSource);
74 m_engine.AddRegion(m_scene); 81 m_engine.AddRegion(m_scene);