change CanObjectEntry() to use a SOG

httptests
UbitUmarov 2017-01-20 14:26:24 +00:00
parent df40cdc83e
commit dac32c4e5a
7 changed files with 40 additions and 51 deletions

View File

@ -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
//

View File

@ -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!

View File

@ -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<SceneObjectGroup> 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;
}
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}