aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs81
1 files changed, 36 insertions, 45 deletions
diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
index 9c0fa75..af32d05 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,9 +78,9 @@ 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;
85 scene.Permissions.OnDuplicateObject += CanDuplicateObject; 86 scene.Permissions.OnDuplicateObject += CanDuplicateObject;
@@ -89,14 +90,12 @@ namespace OpenSim.Region.OptionalModules
89 90
90 public void RemoveRegion(Scene scene) 91 public void RemoveRegion(Scene scene)
91 { 92 {
92 if (m_enabled) 93 if (!m_enabled)
93 {
94 return; 94 return;
95 }
96 95
97 scene.Permissions.OnRezObject -= CanRezObject; 96 m_scene.Permissions.OnRezObject -= CanRezObject;
98 scene.Permissions.OnObjectEntry -= CanObjectEnter; 97 m_scene.Permissions.OnObjectEntry -= CanObjectEnter;
99 scene.Permissions.OnDuplicateObject -= CanDuplicateObject; 98 m_scene.Permissions.OnDuplicateObject -= CanDuplicateObject;
100 } 99 }
101 100
102 public void RegionLoaded(Scene scene) 101 public void RegionLoaded(Scene scene)
@@ -104,11 +103,12 @@ namespace OpenSim.Region.OptionalModules
104 m_dialogModule = scene.RequestModuleInterface<IDialogModule>(); 103 m_dialogModule = scene.RequestModuleInterface<IDialogModule>();
105 } 104 }
106 105
107 private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition, Scene scene) 106 private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition)
108 { 107 {
109 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 108
109 ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
110 110
111 string response = DoCommonChecks(objectCount, ownerID, lo, scene); 111 string response = DoCommonChecks(objectCount, ownerID, lo);
112 112
113 if (response != null) 113 if (response != null)
114 { 114 {
@@ -119,88 +119,79 @@ namespace OpenSim.Region.OptionalModules
119 } 119 }
120 120
121 //OnDuplicateObject 121 //OnDuplicateObject
122 private bool CanDuplicateObject(int objectCount, UUID objectID, UUID ownerID, Scene scene, Vector3 objectPosition) 122 private bool CanDuplicateObject(SceneObjectGroup sog, ScenePresence sp)
123 { 123 {
124 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 124 Vector3 objectPosition = sog.AbsolutePosition;
125 ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
125 126
126 string response = DoCommonChecks(objectCount, ownerID, lo, scene); 127 string response = DoCommonChecks(sog.PrimCount, sp.UUID, lo);
127 128
128 if (response != null) 129 if (response != null)
129 { 130 {
130 m_dialogModule.SendAlertToUser(ownerID, response); 131 m_dialogModule.SendAlertToUser(sp.UUID, response);
131 return false; 132 return false;
132 } 133 }
133 return true; 134 return true;
134 } 135 }
135 136
136 private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) 137 private bool CanObjectEnter(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint)
137 { 138 {
138 if (newPoint.X < -1f || newPoint.X > (scene.RegionInfo.RegionSizeX + 1) || 139 float newX = newPoint.X;
139 newPoint.Y < -1f || newPoint.Y > (scene.RegionInfo.RegionSizeY) ) 140 float newY = newPoint.Y;
141 if (newX < -1.0f || newX > (m_scene.RegionInfo.RegionSizeX + 1.0f) ||
142 newY < -1.0f || newY > (m_scene.RegionInfo.RegionSizeY + 1.0f) )
140 return true; 143 return true;
141 144
142 SceneObjectPart obj = scene.GetSceneObjectPart(objectID); 145 if (sog == null)
143
144 if (obj == null)
145 return false; 146 return false;
146 147
147 // Prim counts are determined by the location of the root prim. if we're 148 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 149
156 if (newParcel == null) 150 if (newParcel == null)
157 return true; 151 return true;
158 152
159 Vector3 oldPoint = obj.GroupPosition; 153 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 { 154 {
166 return true; 155 Vector3 oldPoint = sog.AbsolutePosition;
156 ILandObject oldParcel = m_scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
157 if(oldParcel != null && oldParcel.Equals(newParcel))
158 return true;
167 } 159 }
168 160
169 int objectCount = obj.ParentGroup.PrimCount; 161 int objectCount = sog.PrimCount;
170 int usedPrims = newParcel.PrimCounts.Total;
171 int simulatorCapacity = newParcel.GetSimulatorMaxPrimCount();
172 162
173 // TODO: Add Special Case here for temporary prims 163 // TODO: Add Special Case here for temporary prims
174 164
175 string response = DoCommonChecks(objectCount, obj.OwnerID, newParcel, scene); 165 string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel);
176 166
177 if (response != null) 167 if (response != null)
178 { 168 {
179 m_dialogModule.SendAlertToUser(obj.OwnerID, response); 169 if(m_dialogModule != null)
170 m_dialogModule.SendAlertToUser(sog.OwnerID, response);
180 return false; 171 return false;
181 } 172 }
182 return true; 173 return true;
183 } 174 }
184 175
185 private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo, Scene scene) 176 private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo)
186 { 177 {
187 string response = null; 178 string response = null;
188 179
189 int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount(); 180 int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount();
190 if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity) 181 if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity)
191 { 182 {
192 response = "Unable to rez object because the parcel is too full"; 183 response = "Unable to rez object because the parcel is full";
193 } 184 }
194 else 185 else
195 { 186 {
196 int maxPrimsPerUser = scene.RegionInfo.MaxPrimsPerUser; 187 int maxPrimsPerUser = m_scene.RegionInfo.MaxPrimsPerUser;
197 if (maxPrimsPerUser >= 0) 188 if (maxPrimsPerUser >= 0)
198 { 189 {
199 // per-user prim limit is set 190 // per-user prim limit is set
200 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned) 191 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned)
201 { 192 {
202 // caller is not the sole Parcel owner 193 // caller is not the sole Parcel owner
203 EstateSettings estateSettings = scene.RegionInfo.EstateSettings; 194 EstateSettings estateSettings = m_scene.RegionInfo.EstateSettings;
204 if (ownerID != estateSettings.EstateOwner) 195 if (ownerID != estateSettings.EstateOwner)
205 { 196 {
206 // caller is NOT the Estate owner 197 // caller is NOT the Estate owner