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.cs125
1 files changed, 74 insertions, 51 deletions
diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
index 395bbf1..61b6d68 100644
--- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
+++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
@@ -52,14 +52,15 @@ 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 public string Name { get { return "PrimLimitsModule"; } } 55 private Scene m_scene;
56 56 public string Name { get { return "PrimLimitsModule"; } }
57
57 public Type ReplaceableInterface { get { return null; } } 58 public Type ReplaceableInterface { get { return null; } }
58 59
59 public void Initialise(IConfigSource config) 60 public void Initialise(IConfigSource config)
60 { 61 {
61 string permissionModules = Util.GetConfigVarFromSections<string>(config, "permissionmodules", 62 string permissionModules = Util.GetConfigVarFromSections<string>(config, "permissionmodules",
62 new string[] { "Startup", "Permissions" }, "DefaultPermissionsModule"); 63 new string[] { "Startup", "Permissions" }, "DefaultPermissionsModule");
63 64
64 List<string> modules = new List<string>(permissionModules.Split(',').Select(m => m.Trim())); 65 List<string> modules = new List<string>(permissionModules.Split(',').Select(m => m.Trim()));
65 66
@@ -69,46 +70,47 @@ namespace OpenSim.Region.OptionalModules
69 m_log.DebugFormat("[PRIM LIMITS]: Initialized module"); 70 m_log.DebugFormat("[PRIM LIMITS]: Initialized module");
70 m_enabled = true; 71 m_enabled = true;
71 } 72 }
72 73
73 public void Close() 74 public void Close()
74 { 75 {
75 } 76 }
76 77
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);
88 } 90 }
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 } 100 m_scene.Permissions.OnDuplicateObject -= CanDuplicateObject;
101 101 }
102
102 public void RegionLoaded(Scene scene) 103 public void RegionLoaded(Scene scene)
103 { 104 {
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,78 +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 SceneObjectPart obj = scene.GetSceneObjectPart(objectID); 141 float newX = newPoint.X;
139 Vector3 oldPoint = obj.GroupPosition; 142 float newY = newPoint.Y;
140 int objectCount = obj.ParentGroup.PrimCount; 143 if (newX < -1.0f || newX > (m_scene.RegionInfo.RegionSizeX + 1.0f) ||
141 ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y); 144 newY < -1.0f || newY > (m_scene.RegionInfo.RegionSizeY + 1.0f) )
142 ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y);
143
144 // newParcel will be null only if it outside of our current region. If this is the case, then the
145 // receiving permissions will perform the check.
146 if (newParcel == null)
147 return true; 145 return true;
148 146
149 // The prim hasn't crossed a region boundary so we don't need to worry 147 if (sog == null)
150 // about prim counts here 148 return false;
151 if(oldParcel.Equals(newParcel)) 149
152 { 150 ILandObject newParcel = m_scene.LandChannel.GetLandObject(newX, newY);
151
152 if (newParcel == null)
153 return true; 153 return true;
154 }
155 154
156 // Prim counts are determined by the location of the root prim. if we're 155 if(!enteringRegion)
157 // moving a child prim, just let it pass
158 if(!obj.IsRoot)
159 { 156 {
160 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;
161 } 161 }
162 162
163 int objectCount = sog.PrimCount;
164
163 // TODO: Add Special Case here for temporary prims 165 // TODO: Add Special Case here for temporary prims
164 166
165 string response = DoCommonChecks(objectCount, obj.OwnerID, newParcel, scene); 167 string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel);
166 168
167 if (response != null) 169 if (response != null)
168 { 170 {
169 m_dialogModule.SendAlertToUser(obj.OwnerID, response); 171 if(m_dialogModule != null)
172 m_dialogModule.SendAlertToUser(sog.OwnerID, response);
170 return false; 173 return false;
171 } 174 }
172 return true; 175 return true;
173 } 176 }
174 177
175 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)
176 { 199 {
177 string response = null; 200 string response = null;
178 201
179 int simulatorCapacity = lo.GetSimulatorMaxPrimCount(); 202 int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount();
180 if ((objectCount + lo.PrimCounts.Total) > simulatorCapacity) 203 if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity)
181 { 204 {
182 response = "Unable to rez object because the parcel is too full"; 205 response = "Unable to rez object because the parcel is full";
183 } 206 }
184 else 207 else
185 { 208 {
186 int maxPrimsPerUser = scene.RegionInfo.MaxPrimsPerUser; 209 int maxPrimsPerUser = m_scene.RegionInfo.MaxPrimsPerUser;
187 if (maxPrimsPerUser >= 0) 210 if (maxPrimsPerUser >= 0)
188 { 211 {
189 // per-user prim limit is set 212 // per-user prim limit is set
190 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned) 213 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned)
191 { 214 {
192 // caller is not the sole Parcel owner 215 // caller is not the sole Parcel owner
193 EstateSettings estateSettings = scene.RegionInfo.EstateSettings; 216 EstateSettings estateSettings = m_scene.RegionInfo.EstateSettings;
194 if (ownerID != estateSettings.EstateOwner) 217 if (ownerID != estateSettings.EstateOwner)
195 { 218 {
196 // caller is NOT the Estate owner 219 // caller is NOT the Estate owner