29 using System.Collections.Generic;
31 using System.Reflection;
36 using OpenSim.Framework;
37 using OpenSim.Region.Framework.Interfaces;
38 using OpenSim.Region.Framework.Scenes;
40 namespace OpenSim.
Region.OptionalModules
48 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"PrimLimitsModule")]
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 private bool m_enabled;
55 public string Name {
get {
return "PrimLimitsModule"; } }
57 public Type ReplaceableInterface {
get {
return null; } }
61 string permissionModules = Util.GetConfigVarFromSections<
string>(config,
"permissionmodules",
62 new string[] {
"Startup",
"Permissions" },
"DefaultPermissionsModule");
64 List<string> modules =
new List<string>(permissionModules.Split(
',').Select(m => m.Trim()));
66 if(!modules.Contains(
"PrimLimitsModule"))
69 m_log.DebugFormat(
"[PRIM LIMITS]: Initialized module");
83 scene.Permissions.OnRezObject += CanRezObject;
84 scene.Permissions.OnObjectEntry += CanObjectEnter;
85 scene.Permissions.OnDuplicateObject += CanDuplicateObject;
87 m_log.DebugFormat(
"[PRIM LIMITS]: Region {0} added", scene.RegionInfo.RegionName);
97 scene.Permissions.OnRezObject -= CanRezObject;
98 scene.Permissions.OnObjectEntry -= CanObjectEnter;
99 scene.Permissions.OnDuplicateObject -= CanDuplicateObject;
104 m_dialogModule = scene.RequestModuleInterface<
IDialogModule>();
107 private bool CanRezObject(
int objectCount, UUID ownerID, Vector3 objectPosition,
Scene scene)
109 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
111 string response = DoCommonChecks(objectCount, ownerID, lo, scene);
113 if (response != null)
115 m_dialogModule.SendAlertToUser(ownerID, response);
122 private bool CanDuplicateObject(
int objectCount, UUID objectID, UUID ownerID,
Scene scene, Vector3 objectPosition)
124 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
126 string response = DoCommonChecks(objectCount, ownerID, lo, scene);
128 if (response != null)
130 m_dialogModule.SendAlertToUser(ownerID, response);
136 private bool CanObjectEnter(UUID objectID,
bool enteringRegion, Vector3 newPoint,
Scene scene)
154 ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y);
156 if (newParcel == null)
159 Vector3 oldPoint = obj.GroupPosition;
160 ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
164 if(oldParcel != null && oldParcel.Equals(newParcel))
169 int objectCount = obj.ParentGroup.PrimCount;
170 int usedPrims = newParcel.PrimCounts.Total;
171 int simulatorCapacity = newParcel.GetSimulatorMaxPrimCount();
175 string response = DoCommonChecks(objectCount, obj.
OwnerID, newParcel, scene);
177 if (response != null)
179 m_dialogModule.SendAlertToUser(obj.OwnerID, response);
185 private string DoCommonChecks(
int objectCount, UUID ownerID,
ILandObject lo,
Scene scene)
187 string response = null;
189 int simulatorCapacity = lo.GetSimulatorMaxPrimCount();
192 response =
"Unable to rez object because the parcel is too full";
196 int maxPrimsPerUser = scene.RegionInfo.MaxPrimsPerUser;
197 if (maxPrimsPerUser >= 0)
207 List<UUID> mgrs =
new List<UUID>(estateSettings.EstateManagers);
208 if (!mgrs.Contains(ownerID))
213 response =
"Unable to rez object because you have reached your limit";
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
Enables Prim limits for parcel.
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
uint RegionSizeX
X dimension of the region.
IPrimCounts PrimCounts
Prim counts for this land object.
uint RegionSizeY
X dimension of the region.
IDialogModule m_dialogModule
int Total
Total prims on the parcel.
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
IUserPrimCounts Users
Prims per individual users.
void Initialise(IConfigSource config)
This is called to initialize the region module. For shared modules, this is called exactly once...
bool IsGroupOwned
Returns true if the Land Parcel is owned by a group
virtual RegionInfo RegionInfo
UUID OwnerID
Owner Avatar or Group of the parcel. Naturally, all land masses must be owned by someone ...