From 69bcbd856b8785b2912fa4ceac7411967756107c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 19 Jan 2017 19:01:56 +0000 Subject: [PATCH] change CanDuplicateObject --- .../World/Permissions/PermissionsModule.cs | 11 +++++------ OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | 11 ++++++++--- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 3 +-- .../PrimLimitsModule/PrimLimitsModule.cs | 8 +++++--- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index b4c507231b..341bd7e041 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -1221,24 +1221,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions return IsAdministrator(user); } - private bool CanDuplicateObject(int objectCount, UUID objectID, UUID userID, Scene scene, Vector3 objectPosition) + private bool CanDuplicateObject(SceneObjectGroup sog, ScenePresence sp, Scene scene) { DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); if (m_bypassPermissions) return m_bypassPermissionsValue; - SceneObjectGroup sog = scene.GetGroupByPrim(objectID); - if (sog == null) + if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted) return false; - uint perms = GetObjectPermissions(userID, sog, false); + uint perms = GetObjectPermissions(sp, sog, false); if((perms & (uint)PermissionMask.Copy) == 0) return false; - if(sog.OwnerID != userID && sog.OwnerID != sog.GroupID && (perms & (uint)PermissionMask.Transfer) == 0) + if(sog.OwnerID != sp.UUID && sog.OwnerID != sog.GroupID && (perms & (uint)PermissionMask.Transfer) == 0) return false; //If they can rez, they can duplicate - return CanRezObject(objectCount, userID, objectPosition, scene); + return CanRezObject(0, sp.UUID, sog.AbsolutePosition, scene); } private bool CanDeleteObject(UUID objectID, UUID userID, Scene scene) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index a7f3dd7901..3e75c8ae10 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -47,7 +47,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool TakeObjectHandler(SceneObjectGroup sog, ScenePresence sp); public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID, Scene scene); public delegate bool TakeCopyObjectHandler(SceneObjectGroup sog, ScenePresence sp); - public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition); + public delegate bool DuplicateObjectHandler(SceneObjectGroup sog, ScenePresence sp, Scene scenen); public delegate bool EditObjectByIDsHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool EditObjectHandler(SceneObjectGroup sog, ScenePresence sp); public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); @@ -392,15 +392,20 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region DUPLICATE OBJECT - public bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Vector3 objectPosition) + public bool CanDuplicateObject(SceneObjectGroup sog, UUID agentID) { DuplicateObjectHandler handler = OnDuplicateObject; if (handler != null) { + if(sog == null || sog.IsDeleted) + return false; + ScenePresence sp = m_scene.GetScenePresence(agentID); + if(sp == null || sp.IsDeleted) + return false; Delegate[] list = handler.GetInvocationList(); foreach (DuplicateObjectHandler h in list) { - if (h(objectCount, objectID, owner, m_scene, objectPosition) == false) + if (h(sog, sp, m_scene) == false) return false; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index fc1369272e..9264138af5 100755 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -2066,8 +2066,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup original = GetGroupByPrim(originalPrimID); if (original != null) { - if (m_parentScene.Permissions.CanDuplicateObject( - original.PrimCount, original.UUID, AgentID, original.AbsolutePosition)) + if (m_parentScene.Permissions.CanDuplicateObject(original, AgentID)) { SceneObjectGroup copy = original.Copy(true); copy.AbsolutePosition = copy.AbsolutePosition + offset; diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs index 9c0fa7577d..4875a615f6 100644 --- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs +++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs @@ -106,6 +106,7 @@ namespace OpenSim.Region.OptionalModules private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition, Scene scene) { + ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); string response = DoCommonChecks(objectCount, ownerID, lo, scene); @@ -119,15 +120,16 @@ namespace OpenSim.Region.OptionalModules } //OnDuplicateObject - private bool CanDuplicateObject(int objectCount, UUID objectID, UUID ownerID, Scene scene, Vector3 objectPosition) + private bool CanDuplicateObject(SceneObjectGroup sog, ScenePresence sp, Scene scene) { + Vector3 objectPosition = sog.AbsolutePosition; ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); - string response = DoCommonChecks(objectCount, ownerID, lo, scene); + string response = DoCommonChecks(sog.PrimCount, sp.UUID, lo, scene); if (response != null) { - m_dialogModule.SendAlertToUser(ownerID, response); + m_dialogModule.SendAlertToUser(sp.UUID, response); return false; } return true;