diff options
author | Dev Random | 2014-04-10 21:08:54 -0400 |
---|---|---|
committer | Melanie | 2014-04-12 09:28:29 +0100 |
commit | f0998a9222bdbd27bc11ed106cb4087c18b2c05e (patch) | |
tree | 37a91063024eee3aae73fb3443fcc57f4a6778f7 | |
parent | minor: use constants instead of magic numbers in llRequestAgentData() where p... (diff) | |
download | opensim-SC_OLD-f0998a9222bdbd27bc11ed106cb4087c18b2c05e.zip opensim-SC_OLD-f0998a9222bdbd27bc11ed106cb4087c18b2c05e.tar.gz opensim-SC_OLD-f0998a9222bdbd27bc11ed106cb4087c18b2c05e.tar.bz2 opensim-SC_OLD-f0998a9222bdbd27bc11ed106cb4087c18b2c05e.tar.xz |
Add per-user checking to PrimLimitsModule
Signed-off-by: Melanie <melanie@t-data.com>
-rw-r--r-- | OpenSim/Framework/ILandObject.cs | 1 | ||||
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 18 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs | 93 |
3 files changed, 88 insertions, 24 deletions
diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs index 7a24d1e..8465c86 100644 --- a/OpenSim/Framework/ILandObject.cs +++ b/OpenSim/Framework/ILandObject.cs | |||
@@ -38,6 +38,7 @@ namespace OpenSim.Framework | |||
38 | int GetParcelMaxPrimCount(); | 38 | int GetParcelMaxPrimCount(); |
39 | int GetSimulatorMaxPrimCount(); | 39 | int GetSimulatorMaxPrimCount(); |
40 | int GetPrimsFree(); | 40 | int GetPrimsFree(); |
41 | Dictionary<UUID, int> GetLandObjectOwners(); | ||
41 | 42 | ||
42 | LandData LandData { get; set; } | 43 | LandData LandData { get; set; } |
43 | bool[,] LandBitmap { get; set; } | 44 | bool[,] LandBitmap { get; set; } |
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 2390118..44d05b7 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -127,6 +127,7 @@ namespace OpenSim.Framework | |||
127 | private int m_physPrimMax = 0; | 127 | private int m_physPrimMax = 0; |
128 | private bool m_clampPrimSize = false; | 128 | private bool m_clampPrimSize = false; |
129 | private int m_objectCapacity = 0; | 129 | private int m_objectCapacity = 0; |
130 | private int m_maxPrimsPerUser = -1; | ||
130 | private int m_linksetCapacity = 0; | 131 | private int m_linksetCapacity = 0; |
131 | private int m_agentCapacity = 0; | 132 | private int m_agentCapacity = 0; |
132 | private string m_regionType = String.Empty; | 133 | private string m_regionType = String.Empty; |
@@ -325,6 +326,11 @@ namespace OpenSim.Framework | |||
325 | get { return m_objectCapacity; } | 326 | get { return m_objectCapacity; } |
326 | } | 327 | } |
327 | 328 | ||
329 | public int MaxPrimsPerUser | ||
330 | { | ||
331 | get { return m_maxPrimsPerUser; } | ||
332 | } | ||
333 | |||
328 | public int LinksetCapacity | 334 | public int LinksetCapacity |
329 | { | 335 | { |
330 | get { return m_linksetCapacity; } | 336 | get { return m_linksetCapacity; } |
@@ -709,6 +715,9 @@ namespace OpenSim.Framework | |||
709 | m_objectCapacity = config.GetInt("MaxPrims", 15000); | 715 | m_objectCapacity = config.GetInt("MaxPrims", 15000); |
710 | allKeys.Remove("MaxPrims"); | 716 | allKeys.Remove("MaxPrims"); |
711 | 717 | ||
718 | m_maxPrimsPerUser = config.GetInt("MaxPrimsPerUser", -1); | ||
719 | allKeys.Remove("MaxPrimsPerUser"); | ||
720 | |||
712 | m_linksetCapacity = config.GetInt("LinksetPrims", 0); | 721 | m_linksetCapacity = config.GetInt("LinksetPrims", 0); |
713 | allKeys.Remove("LinksetPrims"); | 722 | allKeys.Remove("LinksetPrims"); |
714 | 723 | ||
@@ -834,6 +843,9 @@ namespace OpenSim.Framework | |||
834 | if (m_objectCapacity > 0) | 843 | if (m_objectCapacity > 0) |
835 | config.Set("MaxPrims", m_objectCapacity); | 844 | config.Set("MaxPrims", m_objectCapacity); |
836 | 845 | ||
846 | if (m_maxPrimsPerUser > -1) | ||
847 | config.Set("MaxPrimsPerUser", m_maxPrimsPerUser); | ||
848 | |||
837 | if (m_linksetCapacity > 0) | 849 | if (m_linksetCapacity > 0) |
838 | config.Set("LinksetPrims", m_linksetCapacity); | 850 | config.Set("LinksetPrims", m_linksetCapacity); |
839 | 851 | ||
@@ -946,6 +958,9 @@ namespace OpenSim.Framework | |||
946 | configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | 958 | configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
947 | "Max objects this sim will hold", m_objectCapacity.ToString(), true); | 959 | "Max objects this sim will hold", m_objectCapacity.ToString(), true); |
948 | 960 | ||
961 | configMember.addConfigurationOption("prims_per_user", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
962 | "Max objects one user may rez", m_maxPrimsPerUser.ToString(), true); | ||
963 | |||
949 | configMember.addConfigurationOption("linkset_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | 964 | configMember.addConfigurationOption("linkset_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
950 | "Max prims an object will hold", m_linksetCapacity.ToString(), true); | 965 | "Max prims an object will hold", m_linksetCapacity.ToString(), true); |
951 | 966 | ||
@@ -1096,6 +1111,9 @@ namespace OpenSim.Framework | |||
1096 | case "object_capacity": | 1111 | case "object_capacity": |
1097 | m_objectCapacity = (int)configuration_result; | 1112 | m_objectCapacity = (int)configuration_result; |
1098 | break; | 1113 | break; |
1114 | case "prims_per_user": | ||
1115 | m_maxPrimsPerUser = (int)configuration_result; | ||
1116 | break; | ||
1099 | case "linkset_capacity": | 1117 | case "linkset_capacity": |
1100 | m_linksetCapacity = (int)configuration_result; | 1118 | m_linksetCapacity = (int)configuration_result; |
1101 | break; | 1119 | break; |
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 | } |