aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs359
1 files changed, 202 insertions, 157 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 8b7c16e..5a9efb8 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -47,6 +47,7 @@ using OpenMetaverse;
47using log4net; 47using log4net;
48using Nini.Config; 48using Nini.Config;
49using Mono.Addins; 49using Mono.Addins;
50using PermissionMask = OpenSim.Framework.PermissionMask;
50 51
51namespace OpenSim.Region.CoreModules.Framework.InventoryAccess 52namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
52{ 53{
@@ -202,7 +203,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
202 m_Scene.AssetService.Store(asset); 203 m_Scene.AssetService.Store(asset);
203 m_Scene.CreateNewInventoryItem( 204 m_Scene.CreateNewInventoryItem(
204 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, 205 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
205 name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate); 206 name, description, 0, callbackID, asset.FullID, asset.Type, invType, nextOwnerMask, creationDate);
206 } 207 }
207 else 208 else
208 { 209 {
@@ -259,7 +260,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
259 return UUID.Zero; 260 return UUID.Zero;
260 } 261 }
261 262
262 remoteClient.SendAgentAlertMessage("Notecard saved", false); 263 remoteClient.SendAlertMessage("Notecard saved");
263 } 264 }
264 else if ((InventoryType)item.InvType == InventoryType.LSL) 265 else if ((InventoryType)item.InvType == InventoryType.LSL)
265 { 266 {
@@ -269,7 +270,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
269 return UUID.Zero; 270 return UUID.Zero;
270 } 271 }
271 272
272 remoteClient.SendAgentAlertMessage("Script saved", false); 273 remoteClient.SendAlertMessage("Script saved");
273 } 274 }
274 275
275 AssetBase asset = 276 AssetBase asset =
@@ -291,7 +292,34 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
291 292
292 return UUID.Zero; 293 return UUID.Zero;
293 } 294 }
294 295
296 public virtual bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset)
297 {
298 if (item != null && item.Owner == ownerID && asset != null)
299 {
300// m_log.DebugFormat(
301// "[INVENTORY ACCESS MODULE]: Updating item {0} {1} with new asset {2}",
302// item.Name, item.ID, asset.ID);
303
304 item.AssetID = asset.FullID;
305 item.Description = asset.Description;
306 item.Name = asset.Name;
307 item.AssetType = asset.Type;
308 item.InvType = (int)InventoryType.Object;
309
310 m_Scene.AssetService.Store(asset);
311 m_Scene.InventoryService.UpdateItem(item);
312
313 return true;
314 }
315 else
316 {
317 m_log.ErrorFormat("[INVENTORY ACCESS MODULE]: Given invalid item for inventory update: {0}",
318 (item == null || asset == null? "null item or asset" : "wrong owner"));
319 return false;
320 }
321 }
322
295 public virtual List<InventoryItemBase> CopyToInventory( 323 public virtual List<InventoryItemBase> CopyToInventory(
296 DeRezAction action, UUID folderID, 324 DeRezAction action, UUID folderID,
297 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient, bool asAttachment) 325 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient, bool asAttachment)
@@ -352,23 +380,32 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
352 bool asAttachment) 380 bool asAttachment)
353 { 381 {
354 CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); 382 CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero);
355 Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); 383// Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>();
384
385 Dictionary<SceneObjectGroup, KeyframeMotion> group2Keyframe = new Dictionary<SceneObjectGroup, KeyframeMotion>();
356 386
357 foreach (SceneObjectGroup objectGroup in objlist) 387 foreach (SceneObjectGroup objectGroup in objlist)
358 { 388 {
359 Vector3 inventoryStoredPosition = new Vector3 389 if (objectGroup.RootPart.KeyframeMotion != null)
360 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) 390 {
361 ? 250 391 objectGroup.RootPart.KeyframeMotion.Pause();
362 : objectGroup.AbsolutePosition.X) 392 group2Keyframe.Add(objectGroup, objectGroup.RootPart.KeyframeMotion);
363 , 393 objectGroup.RootPart.KeyframeMotion = null;
364 (objectGroup.AbsolutePosition.Y > (int)Constants.RegionSize) 394 }
365 ? 250
366 : objectGroup.AbsolutePosition.Y,
367 objectGroup.AbsolutePosition.Z);
368
369 originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition;
370 395
371 objectGroup.AbsolutePosition = inventoryStoredPosition; 396// Vector3 inventoryStoredPosition = new Vector3
397// (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
398// ? 250
399// : objectGroup.AbsolutePosition.X)
400// ,
401// (objectGroup.AbsolutePosition.Y > (int)Constants.RegionSize)
402// ? 250
403// : objectGroup.AbsolutePosition.Y,
404// objectGroup.AbsolutePosition.Z);
405//
406// originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition;
407//
408// objectGroup.AbsolutePosition = inventoryStoredPosition;
372 409
373 // Make sure all bits but the ones we want are clear 410 // Make sure all bits but the ones we want are clear
374 // on take. 411 // on take.
@@ -377,7 +414,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
377 objectGroup.RootPart.NextOwnerMask &= 414 objectGroup.RootPart.NextOwnerMask &=
378 ((uint)PermissionMask.Copy | 415 ((uint)PermissionMask.Copy |
379 (uint)PermissionMask.Transfer | 416 (uint)PermissionMask.Transfer |
380 (uint)PermissionMask.Modify); 417 (uint)PermissionMask.Modify |
418 (uint)PermissionMask.Export);
381 objectGroup.RootPart.NextOwnerMask |= 419 objectGroup.RootPart.NextOwnerMask |=
382 (uint)PermissionMask.Move; 420 (uint)PermissionMask.Move;
383 421
@@ -395,9 +433,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
395 else 433 else
396 itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment); 434 itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment);
397 435
398 // Restore the position of each group now that it has been stored to inventory. 436// // Restore the position of each group now that it has been stored to inventory.
399 foreach (SceneObjectGroup objectGroup in objlist) 437// foreach (SceneObjectGroup objectGroup in objlist)
400 objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; 438// objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID];
401 439
402 InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); 440 InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID);
403 441
@@ -407,17 +445,28 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
407 445
408 if (item == null) 446 if (item == null)
409 return null; 447 return null;
448
449 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
450 item.CreatorData = objlist[0].RootPart.CreatorData;
410 451
411 // Can't know creator is the same, so null it in inventory
412 if (objlist.Count > 1) 452 if (objlist.Count > 1)
413 { 453 {
414 item.CreatorId = UUID.Zero.ToString();
415 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; 454 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
455
456 // If the objects have different creators then don't specify a creator at all
457 foreach (SceneObjectGroup objectGroup in objlist)
458 {
459 if ((objectGroup.RootPart.CreatorID.ToString() != item.CreatorId)
460 || (objectGroup.RootPart.CreatorData.ToString() != item.CreatorData))
461 {
462 item.CreatorId = UUID.Zero.ToString();
463 item.CreatorData = string.Empty;
464 break;
465 }
466 }
416 } 467 }
417 else 468 else
418 { 469 {
419 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
420 item.CreatorData = objlist[0].RootPart.CreatorData;
421 item.SaleType = objlist[0].RootPart.ObjectSaleType; 470 item.SaleType = objlist[0].RootPart.ObjectSaleType;
422 item.SalePrice = objlist[0].RootPart.SalePrice; 471 item.SalePrice = objlist[0].RootPart.SalePrice;
423 } 472 }
@@ -438,13 +487,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
438 } 487 }
439 else 488 else
440 { 489 {
441 AddPermissions(item, objlist[0], objlist, remoteClient);
442
443 item.CreationDate = Util.UnixTimeSinceEpoch(); 490 item.CreationDate = Util.UnixTimeSinceEpoch();
444 item.Description = asset.Description; 491 item.Description = asset.Description;
445 item.Name = asset.Name; 492 item.Name = asset.Name;
446 item.AssetType = asset.Type; 493 item.AssetType = asset.Type;
447 494
495 AddPermissions(item, objlist[0], objlist, remoteClient);
496
448 m_Scene.AddInventoryItem(item); 497 m_Scene.AddInventoryItem(item);
449 498
450 if (remoteClient != null && item.Owner == remoteClient.AgentId) 499 if (remoteClient != null && item.Owner == remoteClient.AgentId)
@@ -461,6 +510,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
461 } 510 }
462 } 511 }
463 512
513 // Restore KeyframeMotion
514 foreach (SceneObjectGroup objectGroup in group2Keyframe.Keys)
515 {
516 objectGroup.RootPart.KeyframeMotion = group2Keyframe[objectGroup];
517 objectGroup.RootPart.KeyframeMotion.Start();
518 }
519
464 // This is a hook to do some per-asset post-processing for subclasses that need that 520 // This is a hook to do some per-asset post-processing for subclasses that need that
465 if (remoteClient != null) 521 if (remoteClient != null)
466 ExportAsset(remoteClient.AgentId, asset.FullID); 522 ExportAsset(remoteClient.AgentId, asset.FullID);
@@ -485,49 +541,65 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
485 InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions, 541 InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions,
486 IClientAPI remoteClient) 542 IClientAPI remoteClient)
487 { 543 {
488 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; 544 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7;
545 uint allObjectsNextOwnerPerms = 0x7fffffff;
546 uint allObjectsEveryOnePerms = 0x7fffffff;
547 uint allObjectsGroupPerms = 0x7fffffff;
548
489 foreach (SceneObjectGroup grp in objsForEffectivePermissions) 549 foreach (SceneObjectGroup grp in objsForEffectivePermissions)
550 {
490 effectivePerms &= grp.GetEffectivePermissions(); 551 effectivePerms &= grp.GetEffectivePermissions();
552 allObjectsNextOwnerPerms &= grp.RootPart.NextOwnerMask;
553 allObjectsEveryOnePerms &= grp.RootPart.EveryoneMask;
554 allObjectsGroupPerms &= grp.RootPart.GroupMask;
555 }
491 effectivePerms |= (uint)PermissionMask.Move; 556 effectivePerms |= (uint)PermissionMask.Move;
492 557
558 //PermissionsUtil.LogPermissions(item.Name, "Before AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions);
559
493 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 560 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
494 { 561 {
562 // Changing ownership, so apply the "Next Owner" permissions to all of the
563 // inventory item's permissions.
564
495 uint perms = effectivePerms; 565 uint perms = effectivePerms;
496 uint nextPerms = (perms & 7) << 13; 566 PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms);
497 if ((nextPerms & (uint)PermissionMask.Copy) == 0) 567
498 perms &= ~(uint)PermissionMask.Copy; 568 item.BasePermissions = perms & allObjectsNextOwnerPerms;
499 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
500 perms &= ~(uint)PermissionMask.Transfer;
501 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
502 perms &= ~(uint)PermissionMask.Modify;
503
504 item.BasePermissions = perms & so.RootPart.NextOwnerMask;
505 item.CurrentPermissions = item.BasePermissions; 569 item.CurrentPermissions = item.BasePermissions;
506 item.NextPermissions = perms & so.RootPart.NextOwnerMask; 570 item.NextPermissions = perms & allObjectsNextOwnerPerms;
507 item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; 571 item.EveryOnePermissions = allObjectsEveryOnePerms & allObjectsNextOwnerPerms;
508 item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; 572 item.GroupPermissions = allObjectsGroupPerms & allObjectsNextOwnerPerms;
509 573
510 // Magic number badness. Maybe this deserves an enum. 574 // apply next owner perms on rez
511 // bit 4 (16) is the "Slam" bit, it means treat as passed 575 item.CurrentPermissions |= SceneObjectGroup.SLAM;
512 // and apply next owner perms on rez
513 item.CurrentPermissions |= 16; // Slam!
514 } 576 }
515 else 577 else
516 { 578 {
579 // Not changing ownership.
580 // In this case we apply the permissions in the object's items ONLY to the inventory
581 // item's "Next Owner" permissions, but NOT to its "Current", "Base", etc. permissions.
582 // E.g., if the object contains a No-Transfer item then the item's "Next Owner"
583 // permissions are also No-Transfer.
584 PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref allObjectsNextOwnerPerms);
585
517 item.BasePermissions = effectivePerms; 586 item.BasePermissions = effectivePerms;
518 item.CurrentPermissions = effectivePerms; 587 item.CurrentPermissions = effectivePerms;
519 item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms; 588 item.NextPermissions = allObjectsNextOwnerPerms & effectivePerms;
520 item.EveryOnePermissions = so.RootPart.EveryoneMask & effectivePerms; 589 item.EveryOnePermissions = allObjectsEveryOnePerms & effectivePerms;
521 item.GroupPermissions = so.RootPart.GroupMask & effectivePerms; 590 item.GroupPermissions = allObjectsGroupPerms & effectivePerms;
522 591
523 item.CurrentPermissions &= 592 item.CurrentPermissions &=
524 ((uint)PermissionMask.Copy | 593 ((uint)PermissionMask.Copy |
525 (uint)PermissionMask.Transfer | 594 (uint)PermissionMask.Transfer |
526 (uint)PermissionMask.Modify | 595 (uint)PermissionMask.Modify |
527 (uint)PermissionMask.Move | 596 (uint)PermissionMask.Move |
597 (uint)PermissionMask.Export |
528 7); // Preserve folded permissions 598 7); // Preserve folded permissions
529 } 599 }
530 600
601 //PermissionsUtil.LogPermissions(item.Name, "After AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions);
602
531 return item; 603 return item;
532 } 604 }
533 605
@@ -542,6 +614,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
542 protected InventoryItemBase CreateItemForObject( 614 protected InventoryItemBase CreateItemForObject(
543 DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID) 615 DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID)
544 { 616 {
617// m_log.DebugFormat(
618// "[BASIC INVENTORY ACCESS MODULE]: Creating item for object {0} {1} for folder {2}, action {3}",
619// so.Name, so.UUID, folderID, action);
620//
545 // Get the user info of the item destination 621 // Get the user info of the item destination
546 // 622 //
547 UUID userID = UUID.Zero; 623 UUID userID = UUID.Zero;
@@ -619,18 +695,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
619 if (remoteClient == null || 695 if (remoteClient == null ||
620 so.OwnerID != remoteClient.AgentId) 696 so.OwnerID != remoteClient.AgentId)
621 { 697 {
622 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 698 folder = m_Scene.InventoryService.GetFolderForType(userID, FolderType.LostAndFound);
623 } 699 }
624 else 700 else
625 { 701 {
626 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); 702 folder = m_Scene.InventoryService.GetFolderForType(userID, FolderType.Trash);
627 } 703 }
628 } 704 }
629 else if (action == DeRezAction.Return) 705 else if (action == DeRezAction.Return)
630 { 706 {
631 // Dump to lost + found unconditionally 707 // Dump to lost + found unconditionally
632 // 708 //
633 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 709 folder = m_Scene.InventoryService.GetFolderForType(userID, FolderType.LostAndFound);
634 } 710 }
635 711
636 if (folderID == UUID.Zero && folder == null) 712 if (folderID == UUID.Zero && folder == null)
@@ -639,21 +715,22 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
639 { 715 {
640 // Deletes go to trash by default 716 // Deletes go to trash by default
641 // 717 //
642 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); 718 folder = m_Scene.InventoryService.GetFolderForType(userID, FolderType.Trash);
643 } 719 }
644 else 720 else
645 { 721 {
646 if (remoteClient == null || so.OwnerID != remoteClient.AgentId) 722 if (remoteClient == null || so.RootPart.OwnerID != remoteClient.AgentId)
647 { 723 {
648 // Taking copy of another person's item. Take to 724 // Taking copy of another person's item. Take to
649 // Objects folder. 725 // Objects folder.
650 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object); 726 folder = m_Scene.InventoryService.GetFolderForType(userID, FolderType.Object);
727 so.FromFolderID = UUID.Zero;
651 } 728 }
652 else 729 else
653 { 730 {
654 // Catch all. Use lost & found 731 // Catch all. Use lost & found
655 // 732 //
656 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 733 folder = m_Scene.InventoryService.GetFolderForType(userID, FolderType.LostAndFound);
657 } 734 }
658 } 735 }
659 } 736 }
@@ -663,10 +740,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
663 // 740 //
664 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) 741 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
665 { 742 {
666 if (so.FromFolderID != UUID.Zero && userID == remoteClient.AgentId) 743 if (so.FromFolderID != UUID.Zero && so.RootPart.OwnerID == remoteClient.AgentId)
667 { 744 {
668 InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID); 745 InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID);
669 folder = m_Scene.InventoryService.GetFolder(f); 746 folder = m_Scene.InventoryService.GetFolder(f);
747
748 if(folder.Type == 14 || folder.Type == 16)
749 {
750 // folder.Type = 6;
751 folder = m_Scene.InventoryService.GetFolderForType(userID, FolderType.Object);
752 }
670 } 753 }
671 } 754 }
672 755
@@ -722,7 +805,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
722 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 805 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
723 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) 806 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
724 { 807 {
725 AssetBase rezAsset = m_Scene.AssetService.Get(assetID.ToString()); 808 AssetBase rezAsset = m_Scene.AssetService.Get(assetID.ToString());
726 809
727 if (rezAsset == null) 810 if (rezAsset == null)
728 { 811 {
@@ -731,12 +814,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
731 m_log.WarnFormat( 814 m_log.WarnFormat(
732 "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", 815 "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()",
733 assetID, item.Name, item.ID, remoteClient.Name); 816 assetID, item.Name, item.ID, remoteClient.Name);
817 remoteClient.SendAgentAlertMessage(string.Format("Unable to rez: could not find asset {0} for item {1}.", assetID, item.Name), false);
734 } 818 }
735 else 819 else
736 { 820 {
737 m_log.WarnFormat( 821 m_log.WarnFormat(
738 "[INVENTORY ACCESS MODULE]: Could not find asset {0} for {1} in RezObject()", 822 "[INVENTORY ACCESS MODULE]: Could not find asset {0} for {1} in RezObject()",
739 assetID, remoteClient.Name); 823 assetID, remoteClient.Name);
824 remoteClient.SendAgentAlertMessage(string.Format("Unable to rez: could not find asset {0}.", assetID), false);
740 } 825 }
741 826
742 return null; 827 return null;
@@ -744,67 +829,34 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
744 829
745 SceneObjectGroup group = null; 830 SceneObjectGroup group = null;
746 831
747 string xmlData = Utils.BytesToString(rezAsset.Data); 832 List<SceneObjectGroup> objlist;
748 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(); 833 List<Vector3> veclist;
749 List<Vector3> veclist = new List<Vector3>(); 834 Vector3 bbox;
835 float offsetHeight;
750 byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); 836 byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0);
751 Vector3 pos; 837 Vector3 pos;
752 838
753 XmlDocument doc = new XmlDocument(); 839 bool single
754 doc.LoadXml(xmlData); 840 = m_Scene.GetObjectsToRez(
755 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); 841 rezAsset.Data, attachment, out objlist, out veclist, out bbox, out offsetHeight);
756 if (e == null || attachment) // Single
757 {
758 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
759
760 objlist.Add(g);
761 veclist.Add(new Vector3(0, 0, 0));
762 842
763 float offsetHeight = 0; 843 if (single)
844 {
764 pos = m_Scene.GetNewRezLocation( 845 pos = m_Scene.GetNewRezLocation(
765 RayStart, RayEnd, RayTargetID, Quaternion.Identity, 846 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
766 BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false); 847 BypassRayCast, bRayEndIsIntersection, true, bbox, false);
767 pos.Z += offsetHeight; 848 pos.Z += offsetHeight;
768 } 849 }
769 else 850 else
770 { 851 {
771 XmlElement coll = (XmlElement)e;
772 float bx = Convert.ToSingle(coll.GetAttribute("x"));
773 float by = Convert.ToSingle(coll.GetAttribute("y"));
774 float bz = Convert.ToSingle(coll.GetAttribute("z"));
775 Vector3 bbox = new Vector3(bx, by, bz);
776
777 pos = m_Scene.GetNewRezLocation(RayStart, RayEnd, 852 pos = m_Scene.GetNewRezLocation(RayStart, RayEnd,
778 RayTargetID, Quaternion.Identity, 853 RayTargetID, Quaternion.Identity,
779 BypassRayCast, bRayEndIsIntersection, true, 854 BypassRayCast, bRayEndIsIntersection, true,
780 bbox, false); 855 bbox, false);
781
782 pos -= bbox / 2; 856 pos -= bbox / 2;
783
784 XmlNodeList groups = e.SelectNodes("SceneObjectGroup");
785 foreach (XmlNode n in groups)
786 {
787 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml);
788
789 objlist.Add(g);
790 XmlElement el = (XmlElement)n;
791
792 string rawX = el.GetAttribute("offsetx");
793 string rawY = el.GetAttribute("offsety");
794 string rawZ = el.GetAttribute("offsetz");
795//
796// m_log.DebugFormat(
797// "[INVENTORY ACCESS MODULE]: Converting coalesced object {0} offset <{1}, {2}, {3}>",
798// g.Name, rawX, rawY, rawZ);
799
800 float x = Convert.ToSingle(rawX);
801 float y = Convert.ToSingle(rawY);
802 float z = Convert.ToSingle(rawZ);
803 veclist.Add(new Vector3(x, y, z));
804 }
805 } 857 }
806 858
807 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, attachment)) 859 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, veclist, attachment))
808 return null; 860 return null;
809 861
810 for (int i = 0; i < objlist.Count; i++) 862 for (int i = 0; i < objlist.Count; i++)
@@ -823,11 +875,23 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
823 m_log.Debug("[INVENTORY ACCESS MODULE]: Object has UUID.Zero! Position 3"); 875 m_log.Debug("[INVENTORY ACCESS MODULE]: Object has UUID.Zero! Position 3");
824 } 876 }
825 877
826 foreach (SceneObjectPart part in group.Parts) 878 // if this was previously an attachment and is now being rezzed,
879 // save the old attachment info.
880 if (group.IsAttachment == false && group.RootPart.Shape.State != 0)
827 { 881 {
828 // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. 882 group.RootPart.AttachedPos = group.AbsolutePosition;
829 part.LastOwnerID = part.OwnerID; 883 group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint;
830 part.OwnerID = remoteClient.AgentId; 884 }
885
886 if (item == null)
887 {
888 // Change ownership. Normally this is done in DoPreRezWhenFromItem(), but in this case we must do it here.
889 foreach (SceneObjectPart part in group.Parts)
890 {
891 // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset.
892 part.LastOwnerID = part.OwnerID;
893 part.OwnerID = remoteClient.AgentId;
894 }
831 } 895 }
832 896
833 if (!attachment) 897 if (!attachment)
@@ -855,7 +919,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
855 // one full update during the attachment 919 // one full update during the attachment
856 // process causes some clients to fail to display the 920 // process causes some clients to fail to display the
857 // attachment properly. 921 // attachment properly.
858 m_Scene.AddNewSceneObject(group, true, false); 922 m_Scene.AddNewSceneObject(group, !attachment, false);
859 923
860 // if attachment we set it's asset id so object updates 924 // if attachment we set it's asset id so object updates
861 // can reflect that, if not, we set it's position in world. 925 // can reflect that, if not, we set it's position in world.
@@ -902,10 +966,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
902 /// <param name="item"></param> 966 /// <param name="item"></param>
903 /// <param name="objlist"></param> 967 /// <param name="objlist"></param>
904 /// <param name="pos"></param> 968 /// <param name="pos"></param>
969 /// <param name="veclist">
970 /// List of vector position adjustments for a coalesced objects. For ordinary objects
971 /// this list will contain just Vector3.Zero. The order of adjustments must match the order of objlist
972 /// </param>
905 /// <param name="isAttachment"></param> 973 /// <param name="isAttachment"></param>
906 /// <returns>true if we can processed with rezzing, false if we need to abort</returns> 974 /// <returns>true if we can processed with rezzing, false if we need to abort</returns>
907 private bool DoPreRezWhenFromItem( 975 private bool DoPreRezWhenFromItem(
908 IClientAPI remoteClient, InventoryItemBase item, List<SceneObjectGroup> objlist, Vector3 pos, bool isAttachment) 976 IClientAPI remoteClient, InventoryItemBase item, List<SceneObjectGroup> objlist,
977 Vector3 pos, List<Vector3> veclist, bool isAttachment)
909 { 978 {
910 UUID fromUserInventoryItemId = UUID.Zero; 979 UUID fromUserInventoryItemId = UUID.Zero;
911 980
@@ -928,28 +997,29 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
928 } 997 }
929 } 998 }
930 999
931 int primcount = 0; 1000 for (int i = 0; i < objlist.Count; i++)
932 foreach (SceneObjectGroup g in objlist)
933 primcount += g.PrimCount;
934
935 if (!m_Scene.Permissions.CanRezObject(
936 primcount, remoteClient.AgentId, pos)
937 && !isAttachment)
938 { 1001 {
939 // The client operates in no fail mode. It will 1002 SceneObjectGroup g = objlist[i];
940 // have already removed the item from the folder
941 // if it's no copy.
942 // Put it back if it's not an attachment
943 //
944 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!isAttachment))
945 remoteClient.SendBulkUpdateInventory(item);
946 1003
947 ILandObject land = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); 1004 if (!m_Scene.Permissions.CanRezObject(
948 remoteClient.SendAlertMessage(string.Format( 1005 g.PrimCount, remoteClient.AgentId, pos + veclist[i])
949 "Can't rez object '{0}' at <{1:F3}, {2:F3}, {3:F3}> on parcel '{4}' in region {5}.", 1006 && !isAttachment)
950 item.Name, pos.X, pos.Y, pos.Z, land != null ? land.LandData.Name : "Unknown", m_Scene.RegionInfo.RegionName)); 1007 {
1008 // The client operates in no fail mode. It will
1009 // have already removed the item from the folder
1010 // if it's no copy.
1011 // Put it back if it's not an attachment
1012 //
1013 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!isAttachment))
1014 remoteClient.SendBulkUpdateInventory(item);
951 1015
952 return false; 1016 ILandObject land = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
1017 remoteClient.SendAlertMessage(string.Format(
1018 "Can't rez object '{0}' at <{1:F3}, {2:F3}, {3:F3}> on parcel '{4}' in region {5}.",
1019 item.Name, pos.X, pos.Y, pos.Z, land != null ? land.LandData.Name : "Unknown", m_Scene.Name));
1020
1021 return false;
1022 }
953 } 1023 }
954 1024
955 for (int i = 0; i < objlist.Count; i++) 1025 for (int i = 0; i < objlist.Count; i++)
@@ -977,44 +1047,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
977// "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}", 1047// "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}",
978// rootPart.OwnerID, item.Owner, item.CurrentPermissions); 1048// rootPart.OwnerID, item.Owner, item.CurrentPermissions);
979 1049
980 if ((rootPart.OwnerID != item.Owner) || 1050 if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & SceneObjectGroup.SLAM) != 0)
981 (item.CurrentPermissions & 16) != 0)
982 { 1051 {
983 //Need to kill the for sale here 1052 //Need to kill the for sale here
984 rootPart.ObjectSaleType = 0; 1053 rootPart.ObjectSaleType = 0;
985 rootPart.SalePrice = 10; 1054 rootPart.SalePrice = 10;
986
987 if (m_Scene.Permissions.PropagatePermissions())
988 {
989 foreach (SceneObjectPart part in so.Parts)
990 {
991 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
992 {
993 part.EveryoneMask = item.EveryOnePermissions;
994 part.NextOwnerMask = item.NextPermissions;
995 }
996 part.GroupMask = 0; // DO NOT propagate here
997 }
998
999 so.ApplyNextOwnerPermissions();
1000 }
1001 } 1055 }
1002 1056
1003 foreach (SceneObjectPart part in so.Parts) 1057 foreach (SceneObjectPart part in so.Parts)
1004 { 1058 {
1005 part.FromUserInventoryItemID = fromUserInventoryItemId; 1059 part.FromUserInventoryItemID = fromUserInventoryItemId;
1006 1060 part.ApplyPermissionsOnRez(item, true, m_Scene);
1007 if ((part.OwnerID != item.Owner) ||
1008 (item.CurrentPermissions & 16) != 0)
1009 {
1010 part.Inventory.ChangeInventoryOwner(item.Owner);
1011 part.GroupMask = 0; // DO NOT propagate here
1012 }
1013
1014 part.EveryoneMask = item.EveryOnePermissions;
1015 part.NextOwnerMask = item.NextPermissions;
1016 } 1061 }
1017 1062
1018 rootPart.TrimPermissions(); 1063 rootPart.TrimPermissions();
1019 1064
1020 if (isAttachment) 1065 if (isAttachment)
@@ -1150,4 +1195,4 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1150 1195
1151 #endregion 1196 #endregion
1152 } 1197 }
1153} \ No newline at end of file 1198}