aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs99
1 files changed, 23 insertions, 76 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 36844a9..f778367 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -183,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes
183 addFromAllowedDrop = (part.ParentGroup.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0; 183 addFromAllowedDrop = (part.ParentGroup.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0;
184 184
185 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); 185 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop);
186 part.ParentGroup.AggregatePerms(); 186 part.ParentGroup.InvalidateEffectivePerms();
187 return true; 187 return true;
188 188
189 } 189 }
@@ -254,13 +254,26 @@ namespace OpenSim.Region.Framework.Scenes
254 // new test code, to place in better place later 254 // new test code, to place in better place later
255 private object m_PermissionsLock = new object(); 255 private object m_PermissionsLock = new object();
256 private bool m_EffectivePermsInvalid = true; 256 private bool m_EffectivePermsInvalid = true;
257 private bool m_DeepEffectivePermsInvalid = true;
257 258
259 // should called when parts chanced by their contents did not, so we know their cacche is valid
260 // in case of doubt call InvalidateDeepEffectivePerms(), it only costs a bit more cpu time
258 public void InvalidateEffectivePerms() 261 public void InvalidateEffectivePerms()
259 { 262 {
260 lock(m_PermissionsLock) 263 lock(m_PermissionsLock)
261 m_EffectivePermsInvalid = true; 264 m_EffectivePermsInvalid = true;
262 } 265 }
263 266
267 // should called when parts chanced and their contents where accounted for
268 public void InvalidateDeepEffectivePerms()
269 {
270 lock(m_PermissionsLock)
271 {
272 m_DeepEffectivePermsInvalid = true;
273 m_EffectivePermsInvalid = true;
274 }
275 }
276
264 private uint m_EffectiveEveryOnePerms; 277 private uint m_EffectiveEveryOnePerms;
265 public uint EffectiveEveryOnePerms 278 public uint EffectiveEveryOnePerms
266 { 279 {
@@ -317,79 +330,6 @@ namespace OpenSim.Region.Framework.Scenes
317 } 330 }
318 } 331 }
319 332
320 // aggregates perms scanning parts and their contents
321 // AggregatePerms does same using cached parts content perms
322 public void AggregateDeepPerms()
323 {
324 lock(m_PermissionsLock)
325 {
326 // aux
327 const uint allmask = (uint)PermissionMask.AllEffective;
328 const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify);
329 const uint copytransfermask = (uint)(PermissionMask.Copy | PermissionMask.Transfer);
330
331 uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move;
332 bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0;
333
334 uint rootOwnerPerms = RootPart.OwnerMask;
335 uint owner = rootOwnerPerms;
336 uint rootGroupPerms = RootPart.GroupMask;
337 uint group = rootGroupPerms;
338 uint rootEveryonePerms = RootPart.EveryoneMask;
339 uint everyone = rootEveryonePerms;
340
341 // date is time of writing april 30th 2017
342 bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994);
343 SceneObjectPart[] parts = m_parts.GetArray();
344 for (int i = 0; i < parts.Length; i++)
345 {
346 SceneObjectPart part = parts[i];
347 part.AggregateInnerPerms();
348 owner &= part.AggregatedInnerOwnerPerms;
349 group &= part.AggregatedInnerGroupPerms;
350 if(newObject)
351 everyone &= part.AggregatedInnerEveryonePerms;
352 }
353 // recover modify and move
354 rootOwnerPerms &= movemodmask;
355 owner |= rootOwnerPerms;
356 if((owner & copytransfermask) == 0)
357 owner |= (uint)PermissionMask.Transfer;
358
359 owner &= basePerms;
360 m_EffectiveOwnerPerms = owner;
361 uint ownertransfermask = owner & (uint)PermissionMask.Transfer;
362
363 // recover modify and move
364 rootGroupPerms &= movemodmask;
365 group |= rootGroupPerms;
366 if(noBaseTransfer)
367 group &=~(uint)PermissionMask.Copy;
368 else
369 group |= ownertransfermask;
370
371 uint groupOrEveryone = group;
372 m_EffectiveGroupPerms = group & owner;
373
374 // recover move
375 rootEveryonePerms &= (uint)PermissionMask.Move;
376 everyone |= rootEveryonePerms;
377 everyone &= ~(uint)PermissionMask.Modify;
378 if(noBaseTransfer)
379 everyone &=~(uint)PermissionMask.Copy;
380 else
381 everyone |= ownertransfermask;
382
383 groupOrEveryone |= everyone;
384
385 m_EffectiveEveryOnePerms = everyone & owner;
386 m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner;
387 m_EffectivePermsInvalid = false;
388 }
389 }
390
391 // aggregates perms scanning parts, assuming their contents was already aggregated and cached
392 // ie is AggregateDeepPerms without the part.AggregateInnerPerms() call on parts loop
393 public void AggregatePerms() 333 public void AggregatePerms()
394 { 334 {
395 lock(m_PermissionsLock) 335 lock(m_PermissionsLock)
@@ -411,14 +351,20 @@ namespace OpenSim.Region.Framework.Scenes
411 351
412 bool needUpdate = false; 352 bool needUpdate = false;
413 // date is time of writing april 30th 2017 353 // date is time of writing april 30th 2017
414 bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994); 354 bool newobj = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994);
415 SceneObjectPart[] parts = m_parts.GetArray(); 355 SceneObjectPart[] parts = m_parts.GetArray();
416 for (int i = 0; i < parts.Length; i++) 356 for (int i = 0; i < parts.Length; i++)
417 { 357 {
418 SceneObjectPart part = parts[i]; 358 SceneObjectPart part = parts[i];
359
360 if(m_DeepEffectivePermsInvalid)
361 part.AggregateInnerPerms();
362
419 owner &= part.AggregatedInnerOwnerPerms; 363 owner &= part.AggregatedInnerOwnerPerms;
420 group &= part.AggregatedInnerGroupPerms; 364 group &= part.AggregatedInnerGroupPerms;
421 if(newObject) 365 if(newobj)
366 group &= part.AggregatedInnerGroupPerms;
367 if(newobj)
422 everyone &= part.AggregatedInnerEveryonePerms; 368 everyone &= part.AggregatedInnerEveryonePerms;
423 } 369 }
424 // recover modify and move 370 // recover modify and move
@@ -477,6 +423,7 @@ namespace OpenSim.Region.Framework.Scenes
477 m_EffectiveGroupOrEveryOnePerms = tmpPerms; 423 m_EffectiveGroupOrEveryOnePerms = tmpPerms;
478 } 424 }
479 425
426 m_DeepEffectivePermsInvalid = false;
480 m_EffectivePermsInvalid = false; 427 m_EffectivePermsInvalid = false;
481 428
482 if(needUpdate) 429 if(needUpdate)