aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
authorDev Random2014-04-10 21:08:54 -0400
committerMelanie2014-04-12 09:28:29 +0100
commitf0998a9222bdbd27bc11ed106cb4087c18b2c05e (patch)
tree37a91063024eee3aae73fb3443fcc57f4a6778f7 /OpenSim/Region/OptionalModules
parentminor: use constants instead of magic numbers in llRequestAgentData() where p... (diff)
downloadopensim-SC-f0998a9222bdbd27bc11ed106cb4087c18b2c05e.zip
opensim-SC-f0998a9222bdbd27bc11ed106cb4087c18b2c05e.tar.gz
opensim-SC-f0998a9222bdbd27bc11ed106cb4087c18b2c05e.tar.bz2
opensim-SC-f0998a9222bdbd27bc11ed106cb4087c18b2c05e.tar.xz
Add per-user checking to PrimLimitsModule
Signed-off-by: Melanie <melanie@t-data.com>
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs93
1 files changed, 69 insertions, 24 deletions
diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
index b977ad8..2b421e5 100644
--- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
+++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
@@ -102,20 +102,34 @@ namespace OpenSim.Region.OptionalModules
102 public void RegionLoaded(Scene scene) 102 public void RegionLoaded(Scene scene)
103 { 103 {
104 m_dialogModule = scene.RequestModuleInterface<IDialogModule>(); 104 m_dialogModule = scene.RequestModuleInterface<IDialogModule>();
105 } 105 }
106 106
107 private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene) 107 private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition, Scene scene)
108 { 108 {
109 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 109 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
110 int usedPrims = lo.PrimCounts.Total;
111 int simulatorCapacity = lo.GetSimulatorMaxPrimCount();
112 110
113 if (objectCount + usedPrims > simulatorCapacity) 111 string response = DoCommonChecks(objectCount, ownerID, lo, scene);
112
113 if (response != null)
114 { 114 {
115 m_dialogModule.SendAlertToUser(owner, "Unable to rez object because the parcel is too full"); 115 m_dialogModule.SendAlertToUser(ownerID, response);
116 return false; 116 return false;
117 } 117 }
118 return true;
119 }
118 120
121 //OnDuplicateObject
122 private bool CanDuplicateObject(int objectCount, UUID objectID, UUID ownerID, Scene scene, Vector3 objectPosition)
123 {
124 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
125
126 string response = DoCommonChecks(objectCount, ownerID, lo, scene);
127
128 if (response != null)
129 {
130 m_dialogModule.SendAlertToUser(ownerID, response);
131 return false;
132 }
119 return true; 133 return true;
120 } 134 }
121 135
@@ -127,12 +141,12 @@ namespace OpenSim.Region.OptionalModules
127 ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y); 141 ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
128 ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y); 142 ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y);
129 143
130 // newParcel will be null only if it outside of our current region. If this is the case, then the 144 // newParcel will be null only if it outside of our current region. If this is the case, then the
131 // receiving permissions will perform the check. 145 // receiving permissions will perform the check.
132 if (newParcel == null) 146 if (newParcel == null)
133 return true; 147 return true;
134 148
135 // The prim hasn't crossed a region boundry so we don't need to worry 149 // The prim hasn't crossed a region boundary so we don't need to worry
136 // about prim counts here 150 // about prim counts here
137 if(oldParcel.Equals(newParcel)) 151 if(oldParcel.Equals(newParcel))
138 { 152 {
@@ -148,32 +162,63 @@ namespace OpenSim.Region.OptionalModules
148 162
149 // TODO: Add Special Case here for temporary prims 163 // TODO: Add Special Case here for temporary prims
150 164
151 int usedPrims = newParcel.PrimCounts.Total; 165 string response = DoCommonChecks(objectCount, obj.OwnerID, newParcel, scene);
152 int simulatorCapacity = newParcel.GetSimulatorMaxPrimCount(); 166
153 167 if (response != null)
154 if (objectCount + usedPrims > simulatorCapacity)
155 { 168 {
156 m_dialogModule.SendAlertToUser(obj.OwnerID, "Unable to move object because the destination parcel is too full"); 169 m_dialogModule.SendAlertToUser(obj.OwnerID, response);
157 return false; 170 return false;
158 } 171 }
159
160 return true; 172 return true;
161 } 173 }
162 174
163 //OnDuplicateObject 175 private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo, Scene scene)
164 private bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition)
165 { 176 {
166 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 177 string response = null;
178 EstateSettings estateSettings = scene.RegionInfo.EstateSettings;
179
180 // counts don't seem to be updated, so force it.
181 scene.EventManager.TriggerParcelPrimCountUpdate();
182
167 int usedPrims = lo.PrimCounts.Total; 183 int usedPrims = lo.PrimCounts.Total;
168 int simulatorCapacity = lo.GetSimulatorMaxPrimCount(); 184 int simulatorCapacity = lo.GetSimulatorMaxPrimCount();
169 185
170 if(objectCount + usedPrims > simulatorCapacity) 186 if ((objectCount + usedPrims) > simulatorCapacity)
171 { 187 {
172 m_dialogModule.SendAlertToUser(owner, "Unable to duplicate object because the parcel is too full"); 188 response = "Unable to rez object because the parcel is too full";
173 return false;
174 } 189 }
175 190 else
176 return true; 191 {
192 int maxPrimsPerUser = scene.RegionInfo.MaxPrimsPerUser;
193 if (maxPrimsPerUser >= 0)
194 {
195 // per-user prim limit is set
196 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned)
197 {
198 // caller is not the sole parcel owner
199 if (ownerID != estateSettings.EstateOwner)
200 {
201 // caller is NOT the Estate owner
202 List<UUID> mgrs = new List<UUID>(estateSettings.EstateManagers);
203 if (!mgrs.Contains(ownerID))
204 {
205 // caller is NOT an Estate Manager, so check quota
206 Dictionary<UUID, int> objectMap = lo.GetLandObjectOwners();
207 int currentCount;
208 if (!objectMap.TryGetValue(ownerID, out currentCount))
209 {
210 currentCount = 0;
211 }
212 if ((currentCount + objectCount) > maxPrimsPerUser)
213 {
214 response = "Unable to rez object because you have reached your limit";
215 }
216 }
217 }
218 }
219 }
220 }
221 return response;
177 } 222 }
178 } 223 }
179} \ No newline at end of file 224}