From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- .../PrimLimitsModule/PrimLimitsModule.cs | 125 ++++++++++++--------- 1 file changed, 74 insertions(+), 51 deletions(-) (limited to 'OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs') diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs index 395bbf1..61b6d68 100644 --- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs +++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs @@ -52,14 +52,15 @@ namespace OpenSim.Region.OptionalModules private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_enabled; - public string Name { get { return "PrimLimitsModule"; } } - + private Scene m_scene; + public string Name { get { return "PrimLimitsModule"; } } + public Type ReplaceableInterface { get { return null; } } - + public void Initialise(IConfigSource config) { string permissionModules = Util.GetConfigVarFromSections(config, "permissionmodules", - new string[] { "Startup", "Permissions" }, "DefaultPermissionsModule"); + new string[] { "Startup", "Permissions" }, "DefaultPermissionsModule"); List modules = new List(permissionModules.Split(',').Select(m => m.Trim())); @@ -69,46 +70,47 @@ namespace OpenSim.Region.OptionalModules m_log.DebugFormat("[PRIM LIMITS]: Initialized module"); m_enabled = true; } - + public void Close() { } - + public void AddRegion(Scene scene) { if (!m_enabled) - { return; - } + + m_scene = scene; scene.Permissions.OnRezObject += CanRezObject; scene.Permissions.OnObjectEntry += CanObjectEnter; + scene.Permissions.OnObjectEnterWithScripts += CanObjectEnterWithScripts; scene.Permissions.OnDuplicateObject += CanDuplicateObject; m_log.DebugFormat("[PRIM LIMITS]: Region {0} added", scene.RegionInfo.RegionName); } - + public void RemoveRegion(Scene scene) { - if (m_enabled) - { + if (!m_enabled) return; - } - scene.Permissions.OnRezObject -= CanRezObject; - scene.Permissions.OnObjectEntry -= CanObjectEnter; - scene.Permissions.OnDuplicateObject -= CanDuplicateObject; - } - + m_scene.Permissions.OnRezObject -= CanRezObject; + m_scene.Permissions.OnObjectEntry -= CanObjectEnter; + scene.Permissions.OnObjectEnterWithScripts -= CanObjectEnterWithScripts; + m_scene.Permissions.OnDuplicateObject -= CanDuplicateObject; + } + public void RegionLoaded(Scene scene) { m_dialogModule = scene.RequestModuleInterface(); } - private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition, Scene scene) + private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition) { - ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); + + ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); - string response = DoCommonChecks(objectCount, ownerID, lo, scene); + string response = DoCommonChecks(objectCount, ownerID, lo); if (response != null) { @@ -119,78 +121,99 @@ 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) { - ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); + Vector3 objectPosition = sog.AbsolutePosition; + ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); - string response = DoCommonChecks(objectCount, ownerID, lo, scene); + string response = DoCommonChecks(sog.PrimCount, sp.UUID, lo); if (response != null) { - m_dialogModule.SendAlertToUser(ownerID, response); + m_dialogModule.SendAlertToUser(sp.UUID, response); return false; } return true; } - private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) + private bool CanObjectEnter(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint) { - SceneObjectPart obj = scene.GetSceneObjectPart(objectID); - Vector3 oldPoint = obj.GroupPosition; - int objectCount = obj.ParentGroup.PrimCount; - ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y); - ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y); - - // newParcel will be null only if it outside of our current region. If this is the case, then the - // receiving permissions will perform the check. - if (newParcel == null) + float newX = newPoint.X; + float newY = newPoint.Y; + if (newX < -1.0f || newX > (m_scene.RegionInfo.RegionSizeX + 1.0f) || + newY < -1.0f || newY > (m_scene.RegionInfo.RegionSizeY + 1.0f) ) return true; - // The prim hasn't crossed a region boundary so we don't need to worry - // about prim counts here - if(oldParcel.Equals(newParcel)) - { + if (sog == null) + return false; + + ILandObject newParcel = m_scene.LandChannel.GetLandObject(newX, newY); + + if (newParcel == null) return true; - } - // 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) + if(!enteringRegion) { - return true; + Vector3 oldPoint = sog.AbsolutePosition; + ILandObject oldParcel = m_scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y); + if(oldParcel != null && oldParcel.Equals(newParcel)) + return true; } + int objectCount = sog.PrimCount; + // TODO: Add Special Case here for temporary prims - string response = DoCommonChecks(objectCount, obj.OwnerID, newParcel, scene); + string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel); if (response != null) { - m_dialogModule.SendAlertToUser(obj.OwnerID, response); + if(m_dialogModule != null) + m_dialogModule.SendAlertToUser(sog.OwnerID, response); return false; } return true; } - private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo, Scene scene) + private bool CanObjectEnterWithScripts(SceneObjectGroup sog, ILandObject newParcel) + { + if (sog == null) + return false; + + if (newParcel == null) + return true; + + int objectCount = sog.PrimCount; + + // TODO: Add Special Case here for temporary prims + + string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel); + + if (response != null) + return false; + + return true; + } + + private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo) { string response = null; - int simulatorCapacity = lo.GetSimulatorMaxPrimCount(); - if ((objectCount + lo.PrimCounts.Total) > simulatorCapacity) + int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount(); + if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity) { - response = "Unable to rez object because the parcel is too full"; + response = "Unable to rez object because the parcel is full"; } else { - int maxPrimsPerUser = scene.RegionInfo.MaxPrimsPerUser; + int maxPrimsPerUser = m_scene.RegionInfo.MaxPrimsPerUser; if (maxPrimsPerUser >= 0) { // per-user prim limit is set if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned) { // caller is not the sole Parcel owner - EstateSettings estateSettings = scene.RegionInfo.EstateSettings; + EstateSettings estateSettings = m_scene.RegionInfo.EstateSettings; if (ownerID != estateSettings.EstateOwner) { // caller is NOT the Estate owner -- cgit v1.1