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.cs211
1 files changed, 96 insertions, 115 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index d09ea3e..fadcd5e 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -358,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
358 bool asAttachment) 358 bool asAttachment)
359 { 359 {
360 CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); 360 CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero);
361 Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); 361// Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>();
362 362
363 foreach (SceneObjectGroup objectGroup in objlist) 363 foreach (SceneObjectGroup objectGroup in objlist)
364 { 364 {
@@ -379,7 +379,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
379 objectGroup.AbsolutePosition.Z); 379 objectGroup.AbsolutePosition.Z);
380 380
381 Quaternion inventoryStoredRotation = objectGroup.GroupRotation; 381 Quaternion inventoryStoredRotation = objectGroup.GroupRotation;
382 originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; 382 //originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition;
383 383
384 // Restore attachment data after trip through the sim 384 // Restore attachment data after trip through the sim
385 if (objectGroup.RootPart.AttachPoint > 0) 385 if (objectGroup.RootPart.AttachPoint > 0)
@@ -390,9 +390,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
390 390
391 // Trees could be attached and it's been done, but it makes 391 // Trees could be attached and it's been done, but it makes
392 // no sense. State must be preserved because it's the tree type 392 // no sense. State must be preserved because it's the tree type
393 if (objectGroup.RootPart.Shape.PCode != (byte)PCode.Tree && 393 if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree &&
394 objectGroup.RootPart.Shape.PCode != (byte)PCode.NewTree) 394 objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree)
395 {
395 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint; 396 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
397 if (objectGroup.RootPart.AttachPoint > 0)
398 objectGroup.RootPart.Shape.LastAttachPoint = objectGroup.RootPart.AttachPoint;
399 }
396 400
397 objectGroup.AbsolutePosition = inventoryStoredPosition; 401 objectGroup.AbsolutePosition = inventoryStoredPosition;
398 objectGroup.RootPart.RotationOffset = inventoryStoredRotation; 402 objectGroup.RootPart.RotationOffset = inventoryStoredRotation;
@@ -423,9 +427,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
423 else 427 else
424 itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment); 428 itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment);
425 429
426 // Restore the position of each group now that it has been stored to inventory. 430// // Restore the position of each group now that it has been stored to inventory.
427 foreach (SceneObjectGroup objectGroup in objlist) 431// foreach (SceneObjectGroup objectGroup in objlist)
428 objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; 432// objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID];
429 433
430 InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); 434 InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID);
431 435
@@ -435,17 +439,28 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
435 439
436 if (item == null) 440 if (item == null)
437 return null; 441 return null;
442
443 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
444 item.CreatorData = objlist[0].RootPart.CreatorData;
438 445
439 // Can't know creator is the same, so null it in inventory
440 if (objlist.Count > 1) 446 if (objlist.Count > 1)
441 { 447 {
442 item.CreatorId = UUID.Zero.ToString();
443 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; 448 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
449
450 // If the objects have different creators then don't specify a creator at all
451 foreach (SceneObjectGroup objectGroup in objlist)
452 {
453 if ((objectGroup.RootPart.CreatorID.ToString() != item.CreatorId)
454 || (objectGroup.RootPart.CreatorData.ToString() != item.CreatorData))
455 {
456 item.CreatorId = UUID.Zero.ToString();
457 item.CreatorData = string.Empty;
458 break;
459 }
460 }
444 } 461 }
445 else 462 else
446 { 463 {
447 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
448 item.CreatorData = objlist[0].RootPart.CreatorData;
449 item.SaleType = objlist[0].RootPart.ObjectSaleType; 464 item.SaleType = objlist[0].RootPart.ObjectSaleType;
450 item.SalePrice = objlist[0].RootPart.SalePrice; 465 item.SalePrice = objlist[0].RootPart.SalePrice;
451 } 466 }
@@ -466,13 +481,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
466 } 481 }
467 else 482 else
468 { 483 {
469 AddPermissions(item, objlist[0], objlist, remoteClient);
470
471 item.CreationDate = Util.UnixTimeSinceEpoch(); 484 item.CreationDate = Util.UnixTimeSinceEpoch();
472 item.Description = asset.Description; 485 item.Description = asset.Description;
473 item.Name = asset.Name; 486 item.Name = asset.Name;
474 item.AssetType = asset.Type; 487 item.AssetType = asset.Type;
475 488
489 AddPermissions(item, objlist[0], objlist, remoteClient);
490
476 m_Scene.AddInventoryItem(item); 491 m_Scene.AddInventoryItem(item);
477 492
478 if (remoteClient != null && item.Owner == remoteClient.AgentId) 493 if (remoteClient != null && item.Owner == remoteClient.AgentId)
@@ -527,16 +542,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
527 } 542 }
528 effectivePerms |= (uint)PermissionMask.Move; 543 effectivePerms |= (uint)PermissionMask.Move;
529 544
545 //PermissionsUtil.LogPermissions(item.Name, "Before AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions);
546
530 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 547 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
531 { 548 {
532 uint perms = effectivePerms; 549 uint perms = effectivePerms;
533 uint nextPerms = (perms & 7) << 13; 550 PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms);
534 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
535 perms &= ~(uint)PermissionMask.Copy;
536 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
537 perms &= ~(uint)PermissionMask.Transfer;
538 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
539 perms &= ~(uint)PermissionMask.Modify;
540 551
541 item.BasePermissions = perms & so.RootPart.NextOwnerMask; 552 item.BasePermissions = perms & so.RootPart.NextOwnerMask;
542 item.CurrentPermissions = item.BasePermissions; 553 item.CurrentPermissions = item.BasePermissions;
@@ -544,10 +555,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
544 item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; 555 item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask;
545 item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; 556 item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask;
546 557
547 // Magic number badness. Maybe this deserves an enum. 558 // apply next owner perms on rez
548 // bit 4 (16) is the "Slam" bit, it means treat as passed 559 item.CurrentPermissions |= SceneObjectGroup.SLAM;
549 // and apply next owner perms on rez
550 item.CurrentPermissions |= 16; // Slam!
551 } 560 }
552 else 561 else
553 { 562 {
@@ -564,8 +573,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
564 (uint)PermissionMask.Move | 573 (uint)PermissionMask.Move |
565 (uint)PermissionMask.Export | 574 (uint)PermissionMask.Export |
566 7); // Preserve folded permissions 575 7); // Preserve folded permissions
567 } 576 }
568 577
578 //PermissionsUtil.LogPermissions(item.Name, "After AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions);
579
569 return item; 580 return item;
570 } 581 }
571 582
@@ -707,6 +718,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
707 InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID); 718 InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID);
708 if (f != null) 719 if (f != null)
709 folder = m_Scene.InventoryService.GetFolder(f); 720 folder = m_Scene.InventoryService.GetFolder(f);
721
722 if(folder.Type == 14 || folder.Type == 16)
723 {
724 // folder.Type = 6;
725 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
726 }
710 } 727 }
711 } 728 }
712 729
@@ -779,83 +796,29 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
779 796
780 SceneObjectGroup group = null; 797 SceneObjectGroup group = null;
781 798
782 string xmlData = Utils.BytesToString(rezAsset.Data); 799 List<SceneObjectGroup> objlist;
783 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(); 800 List<Vector3> veclist;
784 List<Vector3> veclist = new List<Vector3>(); 801 Vector3 bbox;
802 float offsetHeight;
785 byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); 803 byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0);
786 Vector3 pos; 804 Vector3 pos;
787 805
788 XmlDocument doc = new XmlDocument(); 806 bool single = m_Scene.GetObjectsToRez(rezAsset.Data, attachment, out objlist, out veclist, out bbox, out offsetHeight);
789 doc.LoadXml(xmlData);
790 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject");
791 Vector3 rez_pos;
792 if (e == null || attachment) // Single
793 {
794 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
795 if (!attachment)
796 {
797 g.RootPart.AttachPoint = g.RootPart.Shape.State;
798 g.RootPart.AttachOffset = g.AbsolutePosition;
799 g.RootPart.AttachRotation = g.GroupRotation;
800 if (g.RootPart.Shape.PCode != (byte)PCode.NewTree &&
801 g.RootPart.Shape.PCode != (byte)PCode.Tree)
802 g.RootPart.Shape.State = 0;
803 }
804 807
805 objlist.Add(g); 808 if (single)
806 veclist.Add(new Vector3(0, 0, 0)); 809 {
807
808 float offsetHeight = 0;
809 pos = m_Scene.GetNewRezLocation( 810 pos = m_Scene.GetNewRezLocation(
810 RayStart, RayEnd, RayTargetID, Quaternion.Identity, 811 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
811 BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false); 812 BypassRayCast, bRayEndIsIntersection, true, bbox, false);
812 pos.Z += offsetHeight; 813 pos.Z += offsetHeight;
813 rez_pos = pos;
814 } 814 }
815 else 815 else
816 { 816 {
817 XmlElement coll = (XmlElement)e;
818 float bx = Convert.ToSingle(coll.GetAttribute("x"));
819 float by = Convert.ToSingle(coll.GetAttribute("y"));
820 float bz = Convert.ToSingle(coll.GetAttribute("z"));
821 Vector3 bbox = new Vector3(bx, by, bz);
822
823 pos = m_Scene.GetNewRezLocation(RayStart, RayEnd, 817 pos = m_Scene.GetNewRezLocation(RayStart, RayEnd,
824 RayTargetID, Quaternion.Identity, 818 RayTargetID, Quaternion.Identity,
825 BypassRayCast, bRayEndIsIntersection, true, 819 BypassRayCast, bRayEndIsIntersection, true,
826 bbox, false); 820 bbox, false);
827
828 rez_pos = pos;
829
830 pos -= bbox / 2; 821 pos -= bbox / 2;
831
832 XmlNodeList groups = e.SelectNodes("SceneObjectGroup");
833 foreach (XmlNode n in groups)
834 {
835 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml);
836 g.RootPart.AttachPoint = g.RootPart.Shape.State;
837 g.RootPart.AttachOffset = g.AbsolutePosition;
838 g.RootPart.AttachRotation = g.GroupRotation;
839 if (g.RootPart.Shape.PCode != (byte)PCode.NewTree &&
840 g.RootPart.Shape.PCode != (byte)PCode.Tree)
841 g.RootPart.Shape.State = 0;
842
843 objlist.Add(g);
844 XmlElement el = (XmlElement)n;
845
846 string rawX = el.GetAttribute("offsetx");
847 string rawY = el.GetAttribute("offsety");
848 string rawZ = el.GetAttribute("offsetz");
849//
850// m_log.DebugFormat(
851// "[INVENTORY ACCESS MODULE]: Converting coalesced object {0} offset <{1}, {2}, {3}>",
852// g.Name, rawX, rawY, rawZ);
853
854 float x = Convert.ToSingle(rawX);
855 float y = Convert.ToSingle(rawY);
856 float z = Convert.ToSingle(rawZ);
857 veclist.Add(new Vector3(x, y, z));
858 }
859 } 822 }
860 823
861 int primcount = 0; 824 int primcount = 0;
@@ -863,7 +826,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
863 primcount += g.PrimCount; 826 primcount += g.PrimCount;
864 827
865 if (!m_Scene.Permissions.CanRezObject( 828 if (!m_Scene.Permissions.CanRezObject(
866 primcount, remoteClient.AgentId, rez_pos) 829 primcount, remoteClient.AgentId, pos)
867 && !attachment) 830 && !attachment)
868 { 831 {
869 // The client operates in no fail mode. It will 832 // The client operates in no fail mode. It will
@@ -880,7 +843,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
880 return null; 843 return null;
881 } 844 }
882 845
883 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, rez_pos, attachment)) 846 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, veclist, attachment))
884 return null; 847 return null;
885 848
886 for (int i = 0; i < objlist.Count; i++) 849 for (int i = 0; i < objlist.Count; i++)
@@ -900,11 +863,23 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
900 m_log.Debug("[INVENTORY ACCESS MODULE]: Object has UUID.Zero! Position 3"); 863 m_log.Debug("[INVENTORY ACCESS MODULE]: Object has UUID.Zero! Position 3");
901 } 864 }
902 865
903 foreach (SceneObjectPart part in group.Parts) 866 // if this was previously an attachment and is now being rezzed,
867 // save the old attachment info.
868 if (group.IsAttachment == false && group.RootPart.Shape.State != 0)
904 { 869 {
905 // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. 870 group.RootPart.AttachedPos = group.AbsolutePosition;
906 part.LastOwnerID = part.OwnerID; 871 group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint;
907 part.OwnerID = remoteClient.AgentId; 872 }
873
874 if (item == null)
875 {
876 // Change ownership. Normally this is done in DoPreRezWhenFromItem(), but in this case we must do it here.
877 foreach (SceneObjectPart part in group.Parts)
878 {
879 // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset.
880 part.LastOwnerID = part.OwnerID;
881 part.OwnerID = remoteClient.AgentId;
882 }
908 } 883 }
909 884
910 if (!attachment) 885 if (!attachment)
@@ -979,10 +954,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
979 /// <param name="item"></param> 954 /// <param name="item"></param>
980 /// <param name="objlist"></param> 955 /// <param name="objlist"></param>
981 /// <param name="pos"></param> 956 /// <param name="pos"></param>
957 /// <param name="veclist">
958 /// List of vector position adjustments for a coalesced objects. For ordinary objects
959 /// this list will contain just Vector3.Zero. The order of adjustments must match the order of objlist
960 /// </param>
982 /// <param name="isAttachment"></param> 961 /// <param name="isAttachment"></param>
983 /// <returns>true if we can processed with rezzing, false if we need to abort</returns> 962 /// <returns>true if we can processed with rezzing, false if we need to abort</returns>
984 private bool DoPreRezWhenFromItem( 963 private bool DoPreRezWhenFromItem(
985 IClientAPI remoteClient, InventoryItemBase item, List<SceneObjectGroup> objlist, Vector3 pos, bool isAttachment) 964 IClientAPI remoteClient, InventoryItemBase item, List<SceneObjectGroup> objlist,
965 Vector3 pos, List<Vector3> veclist, bool isAttachment)
986 { 966 {
987 UUID fromUserInventoryItemId = UUID.Zero; 967 UUID fromUserInventoryItemId = UUID.Zero;
988 968
@@ -1005,28 +985,29 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1005 } 985 }
1006 } 986 }
1007 987
1008 int primcount = 0; 988 for (int i = 0; i < objlist.Count; i++)
1009 foreach (SceneObjectGroup g in objlist)
1010 primcount += g.PrimCount;
1011
1012 if (!m_Scene.Permissions.CanRezObject(
1013 primcount, remoteClient.AgentId, pos)
1014 && !isAttachment)
1015 { 989 {
1016 // The client operates in no fail mode. It will 990 SceneObjectGroup g = objlist[i];
1017 // have already removed the item from the folder
1018 // if it's no copy.
1019 // Put it back if it's not an attachment
1020 //
1021 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!isAttachment))
1022 remoteClient.SendBulkUpdateInventory(item);
1023 991
1024 ILandObject land = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); 992 if (!m_Scene.Permissions.CanRezObject(
1025 remoteClient.SendAlertMessage(string.Format( 993 g.PrimCount, remoteClient.AgentId, pos + veclist[i])
1026 "Can't rez object '{0}' at <{1:F3}, {2:F3}, {3:F3}> on parcel '{4}' in region {5}.", 994 && !isAttachment)
1027 item.Name, pos.X, pos.Y, pos.Z, land != null ? land.LandData.Name : "Unknown", m_Scene.RegionInfo.RegionName)); 995 {
996 // The client operates in no fail mode. It will
997 // have already removed the item from the folder
998 // if it's no copy.
999 // Put it back if it's not an attachment
1000 //
1001 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!isAttachment))
1002 remoteClient.SendBulkUpdateInventory(item);
1028 1003
1029 return false; 1004 ILandObject land = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
1005 remoteClient.SendAlertMessage(string.Format(
1006 "Can't rez object '{0}' at <{1:F3}, {2:F3}, {3:F3}> on parcel '{4}' in region {5}.",
1007 item.Name, pos.X, pos.Y, pos.Z, land != null ? land.LandData.Name : "Unknown", m_Scene.Name));
1008
1009 return false;
1010 }
1030 } 1011 }
1031 1012
1032 for (int i = 0; i < objlist.Count; i++) 1013 for (int i = 0; i < objlist.Count; i++)
@@ -1107,7 +1088,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1107 part.GroupMask = item.GroupPermissions; 1088 part.GroupMask = item.GroupPermissions;
1108 } 1089 }
1109 } 1090 }
1110 1091
1111 rootPart.TrimPermissions(); 1092 rootPart.TrimPermissions();
1112 1093
1113 if (isAttachment) 1094 if (isAttachment)