diff options
author | Oren Hurvitz | 2013-11-04 19:28:24 +0200 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-01-10 19:37:59 +0000 |
commit | 13f31fdf85c404896c166932730b7b8bc5416626 (patch) | |
tree | 7fc489557e3b3c040b02c185c5ea97bcdf85434d /OpenSim/Region | |
parent | If an agent is sitting, then do send the rotation in the agent update instead... (diff) | |
download | opensim-SC-13f31fdf85c404896c166932730b7b8bc5416626.zip opensim-SC-13f31fdf85c404896c166932730b7b8bc5416626.tar.gz opensim-SC-13f31fdf85c404896c166932730b7b8bc5416626.tar.bz2 opensim-SC-13f31fdf85c404896c166932730b7b8bc5416626.tar.xz |
Refactored setting permissions when rezzing items: use the same function when rezzing from user inventory and prim inventory.
Also, fixed a bug: when rezzing a coalesced object from a prim's inventory, apply the coalesced object's name and description only to the first sub-object; not to all the objects in the coalescence. (This was already done correctly when rezzing from a user's inventory.)
Diffstat (limited to '')
4 files changed, 92 insertions, 94 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 831922e..da36ed0 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -512,10 +512,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
512 | item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; | 512 | item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; |
513 | item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; | 513 | item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; |
514 | 514 | ||
515 | // Magic number badness. Maybe this deserves an enum. | 515 | // apply next owner perms on rez |
516 | // bit 4 (16) is the "Slam" bit, it means treat as passed | 516 | item.CurrentPermissions |= SceneObjectGroup.SLAM; |
517 | // and apply next owner perms on rez | ||
518 | item.CurrentPermissions |= 16; // Slam! | ||
519 | } | 517 | } |
520 | else | 518 | else |
521 | { | 519 | { |
@@ -809,11 +807,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
809 | group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; | 807 | group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; |
810 | } | 808 | } |
811 | 809 | ||
812 | foreach (SceneObjectPart part in group.Parts) | 810 | if (item == null) |
813 | { | 811 | { |
814 | // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. | 812 | // Change ownership. Normally this is done in DoPreRezWhenFromItem(), but in this case we must do it here. |
815 | part.LastOwnerID = part.OwnerID; | 813 | foreach (SceneObjectPart part in group.Parts) |
816 | part.OwnerID = remoteClient.AgentId; | 814 | { |
815 | // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. | ||
816 | part.LastOwnerID = part.OwnerID; | ||
817 | part.OwnerID = remoteClient.AgentId; | ||
818 | } | ||
817 | } | 819 | } |
818 | 820 | ||
819 | if (!attachment) | 821 | if (!attachment) |
@@ -969,44 +971,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
969 | // "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}", | 971 | // "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}", |
970 | // rootPart.OwnerID, item.Owner, item.CurrentPermissions); | 972 | // rootPart.OwnerID, item.Owner, item.CurrentPermissions); |
971 | 973 | ||
972 | if ((rootPart.OwnerID != item.Owner) || | 974 | if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & SceneObjectGroup.SLAM) != 0) |
973 | (item.CurrentPermissions & 16) != 0) | ||
974 | { | 975 | { |
975 | //Need to kill the for sale here | 976 | //Need to kill the for sale here |
976 | rootPart.ObjectSaleType = 0; | 977 | rootPart.ObjectSaleType = 0; |
977 | rootPart.SalePrice = 10; | 978 | rootPart.SalePrice = 10; |
978 | |||
979 | if (m_Scene.Permissions.PropagatePermissions()) | ||
980 | { | ||
981 | foreach (SceneObjectPart part in so.Parts) | ||
982 | { | ||
983 | if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) | ||
984 | { | ||
985 | part.EveryoneMask = item.EveryOnePermissions; | ||
986 | part.NextOwnerMask = item.NextPermissions; | ||
987 | } | ||
988 | part.GroupMask = 0; // DO NOT propagate here | ||
989 | } | ||
990 | |||
991 | so.ApplyNextOwnerPermissions(); | ||
992 | } | ||
993 | } | 979 | } |
994 | 980 | ||
995 | foreach (SceneObjectPart part in so.Parts) | 981 | foreach (SceneObjectPart part in so.Parts) |
996 | { | 982 | { |
997 | part.FromUserInventoryItemID = fromUserInventoryItemId; | 983 | part.FromUserInventoryItemID = fromUserInventoryItemId; |
998 | 984 | part.ApplyPermissionsOnRez(item, true, m_Scene); | |
999 | if ((part.OwnerID != item.Owner) || | ||
1000 | (item.CurrentPermissions & 16) != 0) | ||
1001 | { | ||
1002 | part.Inventory.ChangeInventoryOwner(item.Owner); | ||
1003 | part.GroupMask = 0; // DO NOT propagate here | ||
1004 | } | ||
1005 | |||
1006 | part.EveryoneMask = item.EveryOnePermissions; | ||
1007 | part.NextOwnerMask = item.NextPermissions; | ||
1008 | } | 985 | } |
1009 | 986 | ||
1010 | rootPart.TrimPermissions(); | 987 | rootPart.TrimPermissions(); |
1011 | 988 | ||
1012 | if (isAttachment) | 989 | if (isAttachment) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4b4e4ba..23507f4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -109,6 +109,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
109 | STATUS_ROTATE_Z = 0x008, | 109 | STATUS_ROTATE_Z = 0x008, |
110 | } | 110 | } |
111 | 111 | ||
112 | // This flag has the same purpose as InventoryItemFlags.ObjectSlamPerm | ||
113 | public static readonly uint SLAM = 16; | ||
114 | |||
112 | // private PrimCountTaintedDelegate handlerPrimCountTainted = null; | 115 | // private PrimCountTaintedDelegate handlerPrimCountTainted = null; |
113 | 116 | ||
114 | /// <summary> | 117 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ea9d0d8..1cf7726 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -4800,6 +4800,64 @@ namespace OpenSim.Region.Framework.Scenes | |||
4800 | { | 4800 | { |
4801 | ParentGroup.AddScriptLPS(count); | 4801 | ParentGroup.AddScriptLPS(count); |
4802 | } | 4802 | } |
4803 | |||
4804 | /// <summary> | ||
4805 | /// Sets a prim's owner and permissions when it's rezzed. | ||
4806 | /// </summary> | ||
4807 | /// <param name="item">The inventory item from which the item was rezzed</param> | ||
4808 | /// <param name="userInventory">True: the item is being rezzed from the user's inventory. False: from a prim's inventory.</param> | ||
4809 | /// <param name="scene">The scene the prim is being rezzed into</param> | ||
4810 | public void ApplyPermissionsOnRez(InventoryItemBase item, bool userInventory, Scene scene) | ||
4811 | { | ||
4812 | if ((OwnerID != item.Owner) || ((item.CurrentPermissions & SceneObjectGroup.SLAM) != 0) || ((item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)) | ||
4813 | { | ||
4814 | if (scene.Permissions.PropagatePermissions()) | ||
4815 | { | ||
4816 | if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) | ||
4817 | { | ||
4818 | // Apply the item's permissions to the object | ||
4819 | //LogPermissions("Before applying item permissions"); | ||
4820 | if (userInventory) | ||
4821 | { | ||
4822 | EveryoneMask = item.EveryOnePermissions; | ||
4823 | NextOwnerMask = item.NextPermissions; | ||
4824 | } | ||
4825 | else | ||
4826 | { | ||
4827 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | ||
4828 | EveryoneMask = item.EveryOnePermissions; | ||
4829 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | ||
4830 | NextOwnerMask = item.NextPermissions; | ||
4831 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) | ||
4832 | GroupMask = item.GroupPermissions; | ||
4833 | } | ||
4834 | //LogPermissions("After applying item permissions"); | ||
4835 | } | ||
4836 | } | ||
4837 | |||
4838 | GroupMask = 0; // DO NOT propagate here | ||
4839 | } | ||
4840 | |||
4841 | if (OwnerID != item.Owner) | ||
4842 | { | ||
4843 | //LogPermissions("Before ApplyNextOwnerPermissions"); | ||
4844 | ApplyNextOwnerPermissions(); | ||
4845 | //LogPermissions("After ApplyNextOwnerPermissions"); | ||
4846 | |||
4847 | LastOwnerID = OwnerID; | ||
4848 | OwnerID = item.Owner; | ||
4849 | Inventory.ChangeInventoryOwner(item.Owner); | ||
4850 | } | ||
4851 | } | ||
4852 | |||
4853 | /// <summary> | ||
4854 | /// Logs the prim's permissions. Useful when debugging permission problems. | ||
4855 | /// </summary> | ||
4856 | /// <param name="message"></param> | ||
4857 | private void LogPermissions(String message) | ||
4858 | { | ||
4859 | PermissionsUtil.LogPermissions(Name, message, BaseMask, OwnerMask, NextOwnerMask); | ||
4860 | } | ||
4803 | 4861 | ||
4804 | public void ApplyNextOwnerPermissions() | 4862 | public void ApplyNextOwnerPermissions() |
4805 | { | 4863 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 380e402..5fa01e3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -764,48 +764,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
764 | // Since renaming the item in the inventory does not affect the name stored | 764 | // Since renaming the item in the inventory does not affect the name stored |
765 | // in the serialization, transfer the correct name from the inventory to the | 765 | // in the serialization, transfer the correct name from the inventory to the |
766 | // object itself before we rez. | 766 | // object itself before we rez. |
767 | rootPart.Name = item.Name; | 767 | // Only do these for the first object if we are rezzing a coalescence. |
768 | rootPart.Description = item.Description; | 768 | if (i == 0) |
769 | |||
770 | SceneObjectPart[] partList = group.Parts; | ||
771 | |||
772 | group.SetGroup(m_part.GroupID, null); | ||
773 | |||
774 | // TODO: Remove magic number badness | ||
775 | if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number | ||
776 | { | 769 | { |
777 | if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) | 770 | rootPart.Name = item.Name; |
778 | { | 771 | rootPart.Description = item.Description; |
779 | foreach (SceneObjectPart part in partList) | ||
780 | { | ||
781 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | ||
782 | part.EveryoneMask = item.EveryonePermissions; | ||
783 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | ||
784 | part.NextOwnerMask = item.NextPermissions; | ||
785 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) | ||
786 | part.GroupMask = item.GroupPermissions; | ||
787 | } | ||
788 | |||
789 | group.ApplyNextOwnerPermissions(); | ||
790 | } | ||
791 | } | 772 | } |
792 | 773 | ||
793 | foreach (SceneObjectPart part in partList) | 774 | group.SetGroup(m_part.GroupID, null); |
794 | { | ||
795 | // TODO: Remove magic number badness | ||
796 | if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number | ||
797 | { | ||
798 | part.LastOwnerID = part.OwnerID; | ||
799 | part.OwnerID = item.OwnerID; | ||
800 | part.Inventory.ChangeInventoryOwner(item.OwnerID); | ||
801 | } | ||
802 | 775 | ||
803 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | 776 | foreach (SceneObjectPart part in group.Parts) |
804 | part.EveryoneMask = item.EveryonePermissions; | 777 | { |
805 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | 778 | // Convert between InventoryItem classes. You can never have too many similar but slightly different classes :) |
806 | part.NextOwnerMask = item.NextPermissions; | 779 | InventoryItemBase dest = new InventoryItemBase(item.ItemID, item.OwnerID); |
807 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) | 780 | dest.BasePermissions = item.BasePermissions; |
808 | part.GroupMask = item.GroupPermissions; | 781 | dest.CurrentPermissions = item.CurrentPermissions; |
782 | dest.EveryOnePermissions = item.EveryonePermissions; | ||
783 | dest.GroupPermissions = item.GroupPermissions; | ||
784 | dest.NextPermissions = item.NextPermissions; | ||
785 | dest.Flags = item.Flags; | ||
786 | |||
787 | part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene); | ||
809 | } | 788 | } |
810 | 789 | ||
811 | rootPart.TrimPermissions(); | 790 | rootPart.TrimPermissions(); |
@@ -1130,25 +1109,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1130 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1109 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
1131 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | 1110 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) |
1132 | mask &= ~((uint)PermissionMask.Modify >> 13); | 1111 | mask &= ~((uint)PermissionMask.Modify >> 13); |
1133 | |||
1134 | if (item.InvType != (int)InventoryType.Object) | ||
1135 | { | ||
1136 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | ||
1137 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1138 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1139 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1140 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1141 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1142 | } | ||
1143 | else | ||
1144 | { | ||
1145 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1146 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1147 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1148 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1149 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1150 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1151 | } | ||
1152 | 1112 | ||
1153 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | 1113 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) |
1154 | mask &= ~(uint)PermissionMask.Copy; | 1114 | mask &= ~(uint)PermissionMask.Copy; |