change CanDuplicateObject

httptests
UbitUmarov 2017-01-19 19:01:56 +00:00
parent 97e6f21c6c
commit 69bcbd856b
4 changed files with 19 additions and 14 deletions

View File

@ -1221,24 +1221,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return IsAdministrator(user); 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); DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue; if (m_bypassPermissions) return m_bypassPermissionsValue;
SceneObjectGroup sog = scene.GetGroupByPrim(objectID); if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
if (sog == null)
return false; return false;
uint perms = GetObjectPermissions(userID, sog, false); uint perms = GetObjectPermissions(sp, sog, false);
if((perms & (uint)PermissionMask.Copy) == 0) if((perms & (uint)PermissionMask.Copy) == 0)
return false; 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; return false;
//If they can rez, they can duplicate //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) private bool CanDeleteObject(UUID objectID, UUID userID, Scene scene)

View File

@ -47,7 +47,7 @@ namespace OpenSim.Region.Framework.Scenes
public delegate bool TakeObjectHandler(SceneObjectGroup sog, ScenePresence sp); public delegate bool TakeObjectHandler(SceneObjectGroup sog, ScenePresence sp);
public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID, Scene scene); public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID, Scene scene);
public delegate bool TakeCopyObjectHandler(SceneObjectGroup sog, ScenePresence sp); 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 EditObjectByIDsHandler(UUID objectID, UUID editorID, Scene scene);
public delegate bool EditObjectHandler(SceneObjectGroup sog, ScenePresence sp); public delegate bool EditObjectHandler(SceneObjectGroup sog, ScenePresence sp);
public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene);
@ -392,15 +392,20 @@ namespace OpenSim.Region.Framework.Scenes
#endregion #endregion
#region DUPLICATE OBJECT #region DUPLICATE OBJECT
public bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Vector3 objectPosition) public bool CanDuplicateObject(SceneObjectGroup sog, UUID agentID)
{ {
DuplicateObjectHandler handler = OnDuplicateObject; DuplicateObjectHandler handler = OnDuplicateObject;
if (handler != null) 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(); Delegate[] list = handler.GetInvocationList();
foreach (DuplicateObjectHandler h in list) foreach (DuplicateObjectHandler h in list)
{ {
if (h(objectCount, objectID, owner, m_scene, objectPosition) == false) if (h(sog, sp, m_scene) == false)
return false; return false;
} }
} }

View File

@ -2066,8 +2066,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup original = GetGroupByPrim(originalPrimID); SceneObjectGroup original = GetGroupByPrim(originalPrimID);
if (original != null) if (original != null)
{ {
if (m_parentScene.Permissions.CanDuplicateObject( if (m_parentScene.Permissions.CanDuplicateObject(original, AgentID))
original.PrimCount, original.UUID, AgentID, original.AbsolutePosition))
{ {
SceneObjectGroup copy = original.Copy(true); SceneObjectGroup copy = original.Copy(true);
copy.AbsolutePosition = copy.AbsolutePosition + offset; copy.AbsolutePosition = copy.AbsolutePosition + offset;

View File

@ -106,6 +106,7 @@ namespace OpenSim.Region.OptionalModules
private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition, Scene scene) private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition, Scene scene)
{ {
ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
string response = DoCommonChecks(objectCount, ownerID, lo, scene); string response = DoCommonChecks(objectCount, ownerID, lo, scene);
@ -119,15 +120,16 @@ namespace OpenSim.Region.OptionalModules
} }
//OnDuplicateObject //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); 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) if (response != null)
{ {
m_dialogModule.SendAlertToUser(ownerID, response); m_dialogModule.SendAlertToUser(sp.UUID, response);
return false; return false;
} }
return true; return true;