From dac32c4e5acd76a3b42dede1c573dbef1a98c7e1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 20 Jan 2017 14:26:24 +0000 Subject: [PATCH] change CanObjectEntry() to use a SOG --- .../EntityTransfer/EntityTransferModule.cs | 2 +- .../World/Permissions/PermissionsModule.cs | 38 +++++++++--------- .../Framework/Scenes/Scene.Permissions.cs | 6 +-- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- .../Framework/Scenes/SceneObjectGroup.cs | 2 +- .../PrimLimitsModule/PrimLimitsModule.cs | 39 +++++++------------ .../Shared/Api/Implementation/LSL_Api.cs | 2 +- 7 files changed, 40 insertions(+), 51 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 6dc982be3c..92485a130e 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -2620,7 +2620,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { // FIXME: It would be better to never add the scene object at all rather than add it and then delete // it - if (!Scene.Permissions.CanObjectEntry(so.UUID, true, so.AbsolutePosition)) + if (!Scene.Permissions.CanObjectEntry(so, true, so.AbsolutePosition)) { // Deny non attachments based on parcel settings // diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 79308b4c09..95a007ac3d 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -1437,42 +1437,40 @@ namespace OpenSim.Region.CoreModules.World.Permissions return true; } - private bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) + private bool CanObjectEntry(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint, Scene scene) { DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); - if (m_bypassPermissions) return m_bypassPermissionsValue; - // allow outide region this mb needed for crossings ??? - if (newPoint.X < -1f || newPoint.Y < -1f) - return true; - if (newPoint.X > scene.RegionInfo.RegionSizeX + 1.0f || newPoint.Y > scene.RegionInfo.RegionSizeY + 1.0f) + if(sog == null || sog.IsDeleted) + return false; + + float newX = newPoint.X; + float newY = newPoint.Y; + + // allow outside region this mb needed for crossings + if (newX < -1f || newX > (scene.RegionInfo.RegionSizeX + 1.0f) || + newY < -1f || newY > (scene.RegionInfo.RegionSizeY + 1.0f) ) return true; - ILandObject parcel = m_scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y); + if (m_bypassPermissions) + return m_bypassPermissionsValue; + + ILandObject parcel = scene.LandChannel.GetLandObject(newX, newY); if (parcel == null) return false; if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowAPrimitiveEntry)) != 0) return true; - EntityBase ent = null; - if (!m_scene.Entities.TryGetValue(objectID, out ent)) - return false; - - if(ent == null || !(ent is SceneObjectGroup)) - return false; - - SceneObjectGroup task = (SceneObjectGroup)ent; - if (!enteringRegion) { - ILandObject fromparcel = m_scene.LandChannel.GetLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y); - - if (fromparcel == parcel) // it already entered parcel ???? + Vector3 oldPoint = sog.AbsolutePosition; + ILandObject fromparcel = m_scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y); + if (fromparcel != null && fromparcel.Equals(parcel)) // it already entered parcel ???? return true; } - if (GenericParcelPermission(task.OwnerID, parcel, 0)) + if (GenericParcelPermission(sog.OwnerID, parcel, 0)) return true; //Otherwise, false! diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index 9845418446..6925b6c622 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -52,7 +52,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool EditObjectHandler(SceneObjectGroup sog, ScenePresence sp); public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool MoveObjectHandler(SceneObjectGroup sog, ScenePresence sp); - public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); + public delegate bool ObjectEntryHandler(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint, Scene scene); public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List objects, Scene scene); public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene); public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene); @@ -504,7 +504,7 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region OBJECT ENTRY - public bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint) + public bool CanObjectEntry(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint) { ObjectEntryHandler handler = OnObjectEntry; if (handler != null) @@ -512,7 +512,7 @@ namespace OpenSim.Region.Framework.Scenes Delegate[] list = handler.GetInvocationList(); foreach (ObjectEntryHandler h in list) { - if (h(objectID, enteringRegion, newPoint, m_scene) == false) + if (h(sog, enteringRegion, newPoint, m_scene) == false) return false; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 9264138af5..8fc438d502 100755 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1579,7 +1579,7 @@ namespace OpenSim.Region.Framework.Scenes else { if (m_parentScene.Permissions.CanMoveObject(group, remoteClient) - && m_parentScene.Permissions.CanObjectEntry(group.UUID, false, pos)) + && m_parentScene.Permissions.CanObjectEntry(group, false, pos)) { group.UpdateGroupPosition(pos); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d14c450254..83c5db4a01 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -4656,7 +4656,7 @@ namespace OpenSim.Region.Framework.Scenes } if ((change & ObjectChangeType.Position) != 0) { - if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) + if (IsAttachment || m_scene.Permissions.CanObjectEntry(group, false, data.position)) UpdateGroupPosition(data.position); updateType = updatetype.groupterse; } diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs index 4875a615f6..9c0d801641 100644 --- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs +++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs @@ -135,50 +135,41 @@ namespace OpenSim.Region.OptionalModules return true; } - private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) + private bool CanObjectEnter(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint, Scene scene) { - if (newPoint.X < -1f || newPoint.X > (scene.RegionInfo.RegionSizeX + 1) || - newPoint.Y < -1f || newPoint.Y > (scene.RegionInfo.RegionSizeY) ) + float newX = newPoint.X; + float newY = newPoint.Y; + if (newX < -1f || newX > (scene.RegionInfo.RegionSizeX + 1.0f) || + newY < -1f || newY > (scene.RegionInfo.RegionSizeY + 1.0f) ) return true; - SceneObjectPart obj = scene.GetSceneObjectPart(objectID); - - if (obj == null) + if (sog == null) return false; - // Prim counts are determined by the location of the root prim. if we're - // moving a child prim, just let it pass - if (!obj.IsRoot) - { - return true; - } - - ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y); + ILandObject newParcel = scene.LandChannel.GetLandObject(newX, newY); if (newParcel == null) return true; - Vector3 oldPoint = obj.GroupPosition; - ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y); - - // The prim hasn't crossed a region boundry so we don't need to worry - // about prim counts here - if(oldParcel != null && oldParcel.Equals(newParcel)) + if(!enteringRegion) { - return true; + Vector3 oldPoint = sog.AbsolutePosition; + ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y); + if(oldParcel != null && oldParcel.Equals(newParcel)) + return true; } - int objectCount = obj.ParentGroup.PrimCount; + int objectCount = sog.PrimCount; int usedPrims = newParcel.PrimCounts.Total; int simulatorCapacity = newParcel.GetSimulatorMaxPrimCount(); // TODO: Add Special Case here for temporary prims - string response = DoCommonChecks(objectCount, obj.OwnerID, newParcel, scene); + string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel, scene); if (response != null) { - m_dialogModule.SendAlertToUser(obj.OwnerID, response); + m_dialogModule.SendAlertToUser(sog.OwnerID, response); return false; } return true; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 45bdb41ba3..3cdf49ca51 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2722,7 +2722,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (part.ParentGroup.RootPart == part) { SceneObjectGroup parent = part.ParentGroup; - if (!parent.IsAttachment && !World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos)) + if (!parent.IsAttachment && !World.Permissions.CanObjectEntry(parent, false, (Vector3)toPos)) return; parent.UpdateGroupPosition((Vector3)toPos); }