*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?'

0.6.0-stable
mingchen 2008-05-07 17:33:57 +00:00
parent 5afe6c3ed9
commit 6551f17966
6 changed files with 37 additions and 13 deletions

View File

@ -4047,6 +4047,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//RayEnd: <61.97724, 141.995, 92.58341> //RayEnd: <61.97724, 141.995, 92.58341>
//RayTargetID: 00000000-0000-0000-0000-000000000000 //RayTargetID: 00000000-0000-0000-0000-000000000000
//Check to see if adding the prim is allowed; useful for any module wanting to restrict the
//object from rezing initially
handlerAddPrim = OnAddPrim; handlerAddPrim = OnAddPrim;
if (handlerAddPrim != null) if (handlerAddPrim != null)
handlerAddPrim(AgentId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection); handlerAddPrim(AgentId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);

View File

@ -35,7 +35,7 @@ namespace OpenSim.Region.Environment.Interfaces
#region Object Permissions #region Object Permissions
bool CanRezObject(LLUUID user, LLVector3 position); bool CanRezObject(LLUUID user, LLVector3 position, int count);
/// <summary> /// <summary>
/// Permissions check - can user delete an object? /// Permissions check - can user delete an object?

View File

@ -140,12 +140,21 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
return false; return false;
} }
public virtual bool CanRezObject(LLUUID user, LLVector3 position) public virtual bool CanRezObject(LLUUID user, LLVector3 position, int objectCount)
{ {
bool permission = false; bool permission = false;
string reason = "Insufficient permission"; 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); ILandObject land = m_scene.LandChannel.GetLandObject(position.X, position.Y);
if (land == null) return false; if (land == null) return false;

View File

@ -1267,10 +1267,7 @@ namespace OpenSim.Region.Environment.Scenes
RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1),
BypassRayCast, bRayEndIsIntersection,true,scale, false); BypassRayCast, bRayEndIsIntersection,true,scale, false);
if (!Permissions.CanRezObject(remoteClient.AgentId, pos) && !attachment)
{
return null;
}
// Rez object // Rez object
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
@ -1288,6 +1285,11 @@ namespace OpenSim.Region.Environment.Scenes
{ {
string xmlData = Helpers.FieldToUTF8String(rezAsset.Data); string xmlData = Helpers.FieldToUTF8String(rezAsset.Data);
SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
if (!Permissions.CanRezObject(remoteClient.AgentId, pos, group.Children.Count) && !attachment)
{
return null;
}
group.ResetIDs(); group.ResetIDs();
AddEntity(group); AddEntity(group);
@ -1361,10 +1363,6 @@ namespace OpenSim.Region.Environment.Scenes
{ {
LLUUID ownerID = item.OwnerID; LLUUID ownerID = item.OwnerID;
if (!Permissions.CanRezObject(ownerID, pos))
{
return null;
}
AssetBase rezAsset = AssetCache.GetAsset(item.AssetID, false); AssetBase rezAsset = AssetCache.GetAsset(item.AssetID, false);
@ -1372,6 +1370,11 @@ namespace OpenSim.Region.Environment.Scenes
{ {
string xmlData = Helpers.FieldToUTF8String(rezAsset.Data); string xmlData = Helpers.FieldToUTF8String(rezAsset.Data);
SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
if (!Permissions.CanRezObject(ownerID, pos, group.Children.Count))
{
return null;
}
group.ResetIDs(); group.ResetIDs();
AddEntity(group); AddEntity(group);

View File

@ -241,6 +241,7 @@ namespace OpenSim.Region.Environment.Scenes
m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
m_eventManager = new EventManager(); m_eventManager = new EventManager();
m_externalChecks = new SceneExternalChecks(this);
//Bind Storage Manager functions to some land manager functions for this scene //Bind Storage Manager functions to some land manager functions for this scene
EventManager.OnLandObjectAdded += EventManager.OnLandObjectAdded +=
@ -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); 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 // rez ON the ground, not IN the ground
pos.Z += 0.25F; pos.Z += 0.25F;
@ -3217,5 +3218,7 @@ namespace OpenSim.Region.Environment.Scenes
return visualParams; return visualParams;
} }
#endregion #endregion
} }
} }

View File

@ -72,6 +72,12 @@ namespace OpenSim.Region.Environment.Scenes
} }
protected SceneExternalChecks m_externalChecks;
public SceneExternalChecks ExternalChecks
{
get { return m_externalChecks; }
}
protected string m_datastore; protected string m_datastore;
private uint m_nextLocalId = 8880000; private uint m_nextLocalId = 8880000;