From 6551f17966975081ac9b9f4c3b19d33e9d2c69a5 Mon Sep 17 00:00:00 2001 From: mingchen Date: Wed, 7 May 2008 17:33:57 +0000 Subject: *Added SceneExternalChecks.cs that is used to manage checking the results of multiple functions that register with the class and return the result (usually true/false) based on those results. This is useful for module wanting to put their opinion in decisions such as 'can the user rez this object?' --- .../Environment/Interfaces/IScenePermissions.cs | 4 ++-- .../Modules/World/Permissions/PermissionsModule.cs | 11 ++++++++++- OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | 19 +++++++++++-------- OpenSim/Region/Environment/Scenes/Scene.cs | 7 +++++-- OpenSim/Region/Environment/Scenes/SceneBase.cs | 6 ++++++ 5 files changed, 34 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Interfaces/IScenePermissions.cs b/OpenSim/Region/Environment/Interfaces/IScenePermissions.cs index ad8e139..5d161bb 100644 --- a/OpenSim/Region/Environment/Interfaces/IScenePermissions.cs +++ b/OpenSim/Region/Environment/Interfaces/IScenePermissions.cs @@ -34,8 +34,8 @@ namespace OpenSim.Region.Environment.Interfaces bool BypassPermissions { get; set; } #region Object Permissions - - bool CanRezObject(LLUUID user, LLVector3 position); + + bool CanRezObject(LLUUID user, LLVector3 position, int count); /// /// Permissions check - can user delete an object? diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs index 75e9e57..5203b94 100644 --- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs @@ -140,12 +140,21 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions return false; } - public virtual bool CanRezObject(LLUUID user, LLVector3 position) + public virtual bool CanRezObject(LLUUID user, LLVector3 position, int objectCount) { bool permission = false; + + string reason = "Insufficient permission"; + //Perform ExternalChecks first! + bool results = m_scene.ExternalChecks.ExternalChecksCanRezObject(objectCount, user, position); + if (results == false) + { + return false; + } + ILandObject land = m_scene.LandChannel.GetLandObject(position.X, position.Y); if (land == null) return false; diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 65e6fd8..b536048 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -1267,10 +1267,7 @@ namespace OpenSim.Region.Environment.Scenes RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), BypassRayCast, bRayEndIsIntersection,true,scale, false); - if (!Permissions.CanRezObject(remoteClient.AgentId, pos) && !attachment) - { - return null; - } + // Rez object CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); @@ -1288,6 +1285,11 @@ namespace OpenSim.Region.Environment.Scenes { string xmlData = Helpers.FieldToUTF8String(rezAsset.Data); SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); + if (!Permissions.CanRezObject(remoteClient.AgentId, pos, group.Children.Count) && !attachment) + { + return null; + } + group.ResetIDs(); AddEntity(group); @@ -1361,10 +1363,6 @@ namespace OpenSim.Region.Environment.Scenes { LLUUID ownerID = item.OwnerID; - if (!Permissions.CanRezObject(ownerID, pos)) - { - return null; - } AssetBase rezAsset = AssetCache.GetAsset(item.AssetID, false); @@ -1372,6 +1370,11 @@ namespace OpenSim.Region.Environment.Scenes { string xmlData = Helpers.FieldToUTF8String(rezAsset.Data); SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); + + if (!Permissions.CanRezObject(ownerID, pos, group.Children.Count)) + { + return null; + } group.ResetIDs(); AddEntity(group); diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index a875051..72512c7 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -241,6 +241,7 @@ namespace OpenSim.Region.Environment.Scenes m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; m_eventManager = new EventManager(); + m_externalChecks = new SceneExternalChecks(this); //Bind Storage Manager functions to some land manager functions for this scene EventManager.OnLandObjectAdded += @@ -829,7 +830,7 @@ namespace OpenSim.Region.Environment.Scenes { ForEachScenePresence(delegate(ScenePresence presence) { whatToDo(presence.ControllingClient); }); } - + /// /// /// @@ -1244,7 +1245,7 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f,0.5f,0.5f), false); - if (Permissions.CanRezObject(ownerID, pos)) + if (Permissions.CanRezObject(ownerID, pos, 1)) { // rez ON the ground, not IN the ground pos.Z += 0.25F; @@ -3217,5 +3218,7 @@ namespace OpenSim.Region.Environment.Scenes return visualParams; } #endregion + + } } diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index d9dc1da..dc67436 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -71,6 +71,12 @@ namespace OpenSim.Region.Environment.Scenes get { return m_eventManager; } } + + protected SceneExternalChecks m_externalChecks; + public SceneExternalChecks ExternalChecks + { + get { return m_externalChecks; } + } protected string m_datastore; -- cgit v1.1