aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs103
1 files changed, 58 insertions, 45 deletions
diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
index 9c0fa75..61b6d68 100644
--- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
+++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
@@ -52,6 +52,7 @@ namespace OpenSim.Region.OptionalModules
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 private bool m_enabled; 53 private bool m_enabled;
54 54
55 private Scene m_scene;
55 public string Name { get { return "PrimLimitsModule"; } } 56 public string Name { get { return "PrimLimitsModule"; } }
56 57
57 public Type ReplaceableInterface { get { return null; } } 58 public Type ReplaceableInterface { get { return null; } }
@@ -77,11 +78,12 @@ namespace OpenSim.Region.OptionalModules
77 public void AddRegion(Scene scene) 78 public void AddRegion(Scene scene)
78 { 79 {
79 if (!m_enabled) 80 if (!m_enabled)
80 {
81 return; 81 return;
82 } 82
83 m_scene = scene;
83 scene.Permissions.OnRezObject += CanRezObject; 84 scene.Permissions.OnRezObject += CanRezObject;
84 scene.Permissions.OnObjectEntry += CanObjectEnter; 85 scene.Permissions.OnObjectEntry += CanObjectEnter;
86 scene.Permissions.OnObjectEnterWithScripts += CanObjectEnterWithScripts;
85 scene.Permissions.OnDuplicateObject += CanDuplicateObject; 87 scene.Permissions.OnDuplicateObject += CanDuplicateObject;
86 88
87 m_log.DebugFormat("[PRIM LIMITS]: Region {0} added", scene.RegionInfo.RegionName); 89 m_log.DebugFormat("[PRIM LIMITS]: Region {0} added", scene.RegionInfo.RegionName);
@@ -89,14 +91,13 @@ namespace OpenSim.Region.OptionalModules
89 91
90 public void RemoveRegion(Scene scene) 92 public void RemoveRegion(Scene scene)
91 { 93 {
92 if (m_enabled) 94 if (!m_enabled)
93 {
94 return; 95 return;
95 }
96 96
97 scene.Permissions.OnRezObject -= CanRezObject; 97 m_scene.Permissions.OnRezObject -= CanRezObject;
98 scene.Permissions.OnObjectEntry -= CanObjectEnter; 98 m_scene.Permissions.OnObjectEntry -= CanObjectEnter;
99 scene.Permissions.OnDuplicateObject -= CanDuplicateObject; 99 scene.Permissions.OnObjectEnterWithScripts -= CanObjectEnterWithScripts;
100 m_scene.Permissions.OnDuplicateObject -= CanDuplicateObject;
100 } 101 }
101 102
102 public void RegionLoaded(Scene scene) 103 public void RegionLoaded(Scene scene)
@@ -104,11 +105,12 @@ namespace OpenSim.Region.OptionalModules
104 m_dialogModule = scene.RequestModuleInterface<IDialogModule>(); 105 m_dialogModule = scene.RequestModuleInterface<IDialogModule>();
105 } 106 }
106 107
107 private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition, Scene scene) 108 private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition)
108 { 109 {
109 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 110
111 ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
110 112
111 string response = DoCommonChecks(objectCount, ownerID, lo, scene); 113 string response = DoCommonChecks(objectCount, ownerID, lo);
112 114
113 if (response != null) 115 if (response != null)
114 { 116 {
@@ -119,88 +121,99 @@ namespace OpenSim.Region.OptionalModules
119 } 121 }
120 122
121 //OnDuplicateObject 123 //OnDuplicateObject
122 private bool CanDuplicateObject(int objectCount, UUID objectID, UUID ownerID, Scene scene, Vector3 objectPosition) 124 private bool CanDuplicateObject(SceneObjectGroup sog, ScenePresence sp)
123 { 125 {
124 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 126 Vector3 objectPosition = sog.AbsolutePosition;
127 ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
125 128
126 string response = DoCommonChecks(objectCount, ownerID, lo, scene); 129 string response = DoCommonChecks(sog.PrimCount, sp.UUID, lo);
127 130
128 if (response != null) 131 if (response != null)
129 { 132 {
130 m_dialogModule.SendAlertToUser(ownerID, response); 133 m_dialogModule.SendAlertToUser(sp.UUID, response);
131 return false; 134 return false;
132 } 135 }
133 return true; 136 return true;
134 } 137 }
135 138
136 private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) 139 private bool CanObjectEnter(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint)
137 { 140 {
138 if (newPoint.X < -1f || newPoint.X > (scene.RegionInfo.RegionSizeX + 1) || 141 float newX = newPoint.X;
139 newPoint.Y < -1f || newPoint.Y > (scene.RegionInfo.RegionSizeY) ) 142 float newY = newPoint.Y;
143 if (newX < -1.0f || newX > (m_scene.RegionInfo.RegionSizeX + 1.0f) ||
144 newY < -1.0f || newY > (m_scene.RegionInfo.RegionSizeY + 1.0f) )
140 return true; 145 return true;
141 146
142 SceneObjectPart obj = scene.GetSceneObjectPart(objectID); 147 if (sog == null)
143
144 if (obj == null)
145 return false; 148 return false;
146 149
147 // Prim counts are determined by the location of the root prim. if we're 150 ILandObject newParcel = m_scene.LandChannel.GetLandObject(newX, newY);
148 // moving a child prim, just let it pass
149 if (!obj.IsRoot)
150 {
151 return true;
152 }
153
154 ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y);
155 151
156 if (newParcel == null) 152 if (newParcel == null)
157 return true; 153 return true;
158 154
159 Vector3 oldPoint = obj.GroupPosition; 155 if(!enteringRegion)
160 ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
161
162 // The prim hasn't crossed a region boundry so we don't need to worry
163 // about prim counts here
164 if(oldParcel != null && oldParcel.Equals(newParcel))
165 { 156 {
166 return true; 157 Vector3 oldPoint = sog.AbsolutePosition;
158 ILandObject oldParcel = m_scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
159 if(oldParcel != null && oldParcel.Equals(newParcel))
160 return true;
167 } 161 }
168 162
169 int objectCount = obj.ParentGroup.PrimCount; 163 int objectCount = sog.PrimCount;
170 int usedPrims = newParcel.PrimCounts.Total;
171 int simulatorCapacity = newParcel.GetSimulatorMaxPrimCount();
172 164
173 // TODO: Add Special Case here for temporary prims 165 // TODO: Add Special Case here for temporary prims
174 166
175 string response = DoCommonChecks(objectCount, obj.OwnerID, newParcel, scene); 167 string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel);
176 168
177 if (response != null) 169 if (response != null)
178 { 170 {
179 m_dialogModule.SendAlertToUser(obj.OwnerID, response); 171 if(m_dialogModule != null)
172 m_dialogModule.SendAlertToUser(sog.OwnerID, response);
180 return false; 173 return false;
181 } 174 }
182 return true; 175 return true;
183 } 176 }
184 177
185 private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo, Scene scene) 178 private bool CanObjectEnterWithScripts(SceneObjectGroup sog, ILandObject newParcel)
179 {
180 if (sog == null)
181 return false;
182
183 if (newParcel == null)
184 return true;
185
186 int objectCount = sog.PrimCount;
187
188 // TODO: Add Special Case here for temporary prims
189
190 string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel);
191
192 if (response != null)
193 return false;
194
195 return true;
196 }
197
198 private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo)
186 { 199 {
187 string response = null; 200 string response = null;
188 201
189 int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount(); 202 int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount();
190 if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity) 203 if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity)
191 { 204 {
192 response = "Unable to rez object because the parcel is too full"; 205 response = "Unable to rez object because the parcel is full";
193 } 206 }
194 else 207 else
195 { 208 {
196 int maxPrimsPerUser = scene.RegionInfo.MaxPrimsPerUser; 209 int maxPrimsPerUser = m_scene.RegionInfo.MaxPrimsPerUser;
197 if (maxPrimsPerUser >= 0) 210 if (maxPrimsPerUser >= 0)
198 { 211 {
199 // per-user prim limit is set 212 // per-user prim limit is set
200 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned) 213 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned)
201 { 214 {
202 // caller is not the sole Parcel owner 215 // caller is not the sole Parcel owner
203 EstateSettings estateSettings = scene.RegionInfo.EstateSettings; 216 EstateSettings estateSettings = m_scene.RegionInfo.EstateSettings;
204 if (ownerID != estateSettings.EstateOwner) 217 if (ownerID != estateSettings.EstateOwner)
205 { 218 {
206 // caller is NOT the Estate owner 219 // caller is NOT the Estate owner