diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 132 |
1 files changed, 53 insertions, 79 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index db723fa..ec39726 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -38,6 +38,7 @@ using OpenSim.Framework; | |||
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes.Scripting; | 39 | using OpenSim.Region.Framework.Scenes.Scripting; |
40 | using OpenSim.Region.Framework.Scenes.Serialization; | 40 | using OpenSim.Region.Framework.Scenes.Serialization; |
41 | using PermissionMask = OpenSim.Framework.PermissionMask; | ||
41 | 42 | ||
42 | namespace OpenSim.Region.Framework.Scenes | 43 | namespace OpenSim.Region.Framework.Scenes |
43 | { | 44 | { |
@@ -399,6 +400,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
399 | 400 | ||
400 | private UUID RestoreSavedScriptState(UUID loadedID, UUID oldID, UUID newID) | 401 | private UUID RestoreSavedScriptState(UUID loadedID, UUID oldID, UUID newID) |
401 | { | 402 | { |
403 | // m_log.DebugFormat( | ||
404 | // "[PRIM INVENTORY]: Restoring scripted state for item {0}, oldID {1}, loadedID {2}", | ||
405 | // newID, oldID, loadedID); | ||
406 | |||
402 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 407 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
403 | if (engines.Length == 0) // No engine at all | 408 | if (engines.Length == 0) // No engine at all |
404 | return oldID; | 409 | return oldID; |
@@ -411,7 +416,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
411 | XmlDocument doc = new XmlDocument(); | 416 | XmlDocument doc = new XmlDocument(); |
412 | 417 | ||
413 | doc.LoadXml(m_part.ParentGroup.m_savedScriptState[stateID]); | 418 | doc.LoadXml(m_part.ParentGroup.m_savedScriptState[stateID]); |
414 | 419 | ||
415 | ////////// CRUFT WARNING /////////////////////////////////// | 420 | ////////// CRUFT WARNING /////////////////////////////////// |
416 | // | 421 | // |
417 | // Old objects will have <ScriptState><State> ... | 422 | // Old objects will have <ScriptState><State> ... |
@@ -441,6 +446,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
441 | // This created document has only the minimun data | 446 | // This created document has only the minimun data |
442 | // necessary for XEngine to parse it successfully | 447 | // necessary for XEngine to parse it successfully |
443 | 448 | ||
449 | // m_log.DebugFormat("[PRIM INVENTORY]: Adding legacy state {0} in {1}", stateID, newID); | ||
450 | |||
444 | m_part.ParentGroup.m_savedScriptState[stateID] = newDoc.OuterXml; | 451 | m_part.ParentGroup.m_savedScriptState[stateID] = newDoc.OuterXml; |
445 | } | 452 | } |
446 | 453 | ||
@@ -552,7 +559,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
552 | /// </param> | 559 | /// </param> |
553 | public void StopScriptInstance(TaskInventoryItem item) | 560 | public void StopScriptInstance(TaskInventoryItem item) |
554 | { | 561 | { |
555 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript(m_part.LocalId, item.ItemID); | 562 | if (m_part.ParentGroup.Scene != null) |
563 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript(m_part.LocalId, item.ItemID); | ||
556 | 564 | ||
557 | // At the moment, even stopped scripts are counted as active, which is probably wrong. | 565 | // At the moment, even stopped scripts are counted as active, which is probably wrong. |
558 | // m_part.ParentGroup.AddActiveScriptCount(-1); | 566 | // m_part.ParentGroup.AddActiveScriptCount(-1); |
@@ -731,8 +739,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
731 | 739 | ||
732 | return items; | 740 | return items; |
733 | } | 741 | } |
734 | 742 | ||
735 | public SceneObjectGroup GetRezReadySceneObject(TaskInventoryItem item) | 743 | public bool GetRezReadySceneObjects(TaskInventoryItem item, out List<SceneObjectGroup> objlist, out List<Vector3> veclist) |
736 | { | 744 | { |
737 | AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); | 745 | AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
738 | 746 | ||
@@ -741,66 +749,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
741 | m_log.WarnFormat( | 749 | m_log.WarnFormat( |
742 | "[PRIM INVENTORY]: Could not find asset {0} for inventory item {1} in {2}", | 750 | "[PRIM INVENTORY]: Could not find asset {0} for inventory item {1} in {2}", |
743 | item.AssetID, item.Name, m_part.Name); | 751 | item.AssetID, item.Name, m_part.Name); |
744 | return null; | 752 | objlist = null; |
753 | veclist = null; | ||
754 | return false; | ||
745 | } | 755 | } |
746 | 756 | ||
747 | string xmlData = Utils.BytesToString(rezAsset.Data); | 757 | Vector3 bbox; |
748 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 758 | float offsetHeight; |
749 | |||
750 | group.ResetIDs(); | ||
751 | 759 | ||
752 | SceneObjectPart rootPart = group.GetPart(group.UUID); | 760 | m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight); |
753 | 761 | ||
754 | // Since renaming the item in the inventory does not affect the name stored | 762 | for (int i = 0; i < objlist.Count; i++) |
755 | // in the serialization, transfer the correct name from the inventory to the | 763 | { |
756 | // object itself before we rez. | 764 | SceneObjectGroup group = objlist[i]; |
757 | rootPart.Name = item.Name; | ||
758 | rootPart.Description = item.Description; | ||
759 | 765 | ||
760 | SceneObjectPart[] partList = group.Parts; | 766 | group.ResetIDs(); |
761 | 767 | ||
762 | group.SetGroup(m_part.GroupID, null); | 768 | SceneObjectPart rootPart = group.GetPart(group.UUID); |
763 | 769 | ||
764 | // TODO: Remove magic number badness | 770 | // Since renaming the item in the inventory does not affect the name stored |
765 | if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number | 771 | // in the serialization, transfer the correct name from the inventory to the |
766 | { | 772 | // object itself before we rez. |
767 | if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) | 773 | // Only do these for the first object if we are rezzing a coalescence. |
774 | if (i == 0) | ||
768 | { | 775 | { |
769 | foreach (SceneObjectPart part in partList) | 776 | rootPart.Name = item.Name; |
770 | { | 777 | rootPart.Description = item.Description; |
771 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | ||
772 | part.EveryoneMask = item.EveryonePermissions; | ||
773 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | ||
774 | part.NextOwnerMask = item.NextPermissions; | ||
775 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) | ||
776 | part.GroupMask = item.GroupPermissions; | ||
777 | } | ||
778 | |||
779 | group.ApplyNextOwnerPermissions(); | ||
780 | } | 778 | } |
781 | } | ||
782 | 779 | ||
783 | foreach (SceneObjectPart part in partList) | 780 | group.SetGroup(m_part.GroupID, null); |
784 | { | 781 | |
785 | // TODO: Remove magic number badness | 782 | foreach (SceneObjectPart part in group.Parts) |
786 | if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number | ||
787 | { | 783 | { |
788 | part.LastOwnerID = part.OwnerID; | 784 | // Convert between InventoryItem classes. You can never have too many similar but slightly different classes :) |
789 | part.OwnerID = item.OwnerID; | 785 | InventoryItemBase dest = new InventoryItemBase(item.ItemID, item.OwnerID); |
790 | part.Inventory.ChangeInventoryOwner(item.OwnerID); | 786 | dest.BasePermissions = item.BasePermissions; |
787 | dest.CurrentPermissions = item.CurrentPermissions; | ||
788 | dest.EveryOnePermissions = item.EveryonePermissions; | ||
789 | dest.GroupPermissions = item.GroupPermissions; | ||
790 | dest.NextPermissions = item.NextPermissions; | ||
791 | dest.Flags = item.Flags; | ||
792 | |||
793 | part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene); | ||
791 | } | 794 | } |
792 | 795 | ||
793 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | 796 | rootPart.TrimPermissions(); |
794 | part.EveryoneMask = item.EveryonePermissions; | ||
795 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | ||
796 | part.NextOwnerMask = item.NextPermissions; | ||
797 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) | ||
798 | part.GroupMask = item.GroupPermissions; | ||
799 | } | 797 | } |
800 | 798 | ||
801 | rootPart.TrimPermissions(); | 799 | return true; |
802 | |||
803 | return group; | ||
804 | } | 800 | } |
805 | 801 | ||
806 | /// <summary> | 802 | /// <summary> |
@@ -880,8 +876,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
880 | int type = m_items[itemID].InvType; | 876 | int type = m_items[itemID].InvType; |
881 | if (type == 10) // Script | 877 | if (type == 10) // Script |
882 | { | 878 | { |
883 | m_part.RemoveScriptEvents(itemID); | 879 | // route it through here, to handle script cleanup tasks |
884 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 880 | RemoveScriptInstance(itemID, false); |
885 | } | 881 | } |
886 | m_items.Remove(itemID); | 882 | m_items.Remove(itemID); |
887 | m_inventorySerial++; | 883 | m_inventorySerial++; |
@@ -1119,25 +1115,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1119 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1115 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
1120 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | 1116 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) |
1121 | mask &= ~((uint)PermissionMask.Modify >> 13); | 1117 | mask &= ~((uint)PermissionMask.Modify >> 13); |
1122 | |||
1123 | if (item.InvType != (int)InventoryType.Object) | ||
1124 | { | ||
1125 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | ||
1126 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1127 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1128 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1129 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1130 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1131 | } | ||
1132 | else | ||
1133 | { | ||
1134 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1135 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1136 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1137 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1138 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1139 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1140 | } | ||
1141 | 1118 | ||
1142 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | 1119 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) |
1143 | mask &= ~(uint)PermissionMask.Copy; | 1120 | mask &= ~(uint)PermissionMask.Copy; |
@@ -1161,14 +1138,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1161 | // "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", | 1138 | // "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", |
1162 | // item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); | 1139 | // item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); |
1163 | 1140 | ||
1164 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) | 1141 | if (item.InvType == (int)InventoryType.Object) |
1165 | { | 1142 | { |
1166 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | 1143 | uint perms = item.CurrentPermissions; |
1167 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | 1144 | PermissionsUtil.ApplyFoldedPermissions(perms, ref perms); |
1168 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | 1145 | item.CurrentPermissions = perms; |
1169 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | ||
1170 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1171 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | ||
1172 | } | 1146 | } |
1173 | 1147 | ||
1174 | item.CurrentPermissions &= item.NextPermissions; | 1148 | item.CurrentPermissions &= item.NextPermissions; |