diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 138 |
1 files changed, 93 insertions, 45 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index a2fceb7..bc3225a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -34,7 +34,6 @@ using System.Reflection; | |||
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using log4net; | 35 | using log4net; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Communications.Cache; | ||
38 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes.Scripting; | 38 | using OpenSim.Region.Framework.Scenes.Scripting; |
40 | 39 | ||
@@ -213,7 +212,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
213 | } | 212 | } |
214 | } | 213 | } |
215 | 214 | ||
216 | private ArrayList GetScriptErrors(UUID itemID) | 215 | public ArrayList GetScriptErrors(UUID itemID) |
217 | { | 216 | { |
218 | ArrayList ret = new ArrayList(); | 217 | ArrayList ret = new ArrayList(); |
219 | 218 | ||
@@ -296,38 +295,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
296 | return; | 295 | return; |
297 | } | 296 | } |
298 | 297 | ||
299 | m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) | 298 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
300 | { | 299 | if (null == asset) |
301 | if (null == asset) | 300 | { |
302 | { | 301 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); |
303 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | 302 | StoreScriptError(item.ItemID, msg); |
304 | StoreScriptError(item.ItemID, msg); | 303 | m_log.ErrorFormat( |
305 | m_log.ErrorFormat( | 304 | "[PRIM INVENTORY]: " + |
306 | "[PRIM INVENTORY]: " + | 305 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
307 | "Couldn't start script {0}, {1} at {2} in {3} since {4}", | 306 | item.Name, item.ItemID, m_part.AbsolutePosition, |
308 | item.Name, item.ItemID, m_part.AbsolutePosition, | 307 | m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); |
309 | m_part.ParentGroup.Scene.RegionInfo.RegionName, msg); | 308 | } |
310 | } | 309 | else |
311 | else | 310 | { |
312 | { | 311 | if (m_part.ParentGroup.m_savedScriptState != null) |
313 | if (m_part.ParentGroup.m_savedScriptState != null) | 312 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
314 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 313 | |
315 | m_items.LockItemsForWrite(true); | 314 | m_items.LockItemsForWrite(true); |
316 | m_items[item.ItemID].PermsMask = 0; | 315 | |
317 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 316 | m_items[item.ItemID].PermsMask = 0; |
318 | m_items.LockItemsForWrite(false); | 317 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
319 | string script = Utils.BytesToString(asset.Data); | 318 | |
320 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 319 | m_items.LockItemsForWrite(false); |
321 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 320 | |
322 | StoreScriptErrors(item.ItemID, null); | 321 | string script = Utils.BytesToString(asset.Data); |
323 | m_part.ParentGroup.AddActiveScriptCount(1); | 322 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
324 | m_part.ScheduleFullUpdate(); | 323 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
325 | } | 324 | StoreScriptErrors(item.ItemID, null); |
326 | }); | 325 | m_part.ParentGroup.AddActiveScriptCount(1); |
327 | } | 326 | m_part.ScheduleFullUpdate(); |
328 | else | 327 | } |
329 | { | ||
330 | StoreScriptError(item.ItemID, "scripts disabled"); | ||
331 | } | 328 | } |
332 | } | 329 | } |
333 | 330 | ||
@@ -654,6 +651,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
654 | item.ParentID = m_part.UUID; | 651 | item.ParentID = m_part.UUID; |
655 | item.ParentPartID = m_part.UUID; | 652 | item.ParentPartID = m_part.UUID; |
656 | item.Name = name; | 653 | item.Name = name; |
654 | item.GroupID = m_part.GroupID; | ||
657 | 655 | ||
658 | m_items.LockItemsForWrite(true); | 656 | m_items.LockItemsForWrite(true); |
659 | m_items.Add(item.ItemID, item); | 657 | m_items.Add(item.ItemID, item); |
@@ -716,15 +714,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
716 | { | 714 | { |
717 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 715 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
718 | 716 | ||
719 | lock (m_items) | 717 | m_items.LockItemsForRead(true); |
718 | |||
719 | foreach (TaskInventoryItem item in m_items.Values) | ||
720 | { | 720 | { |
721 | foreach (TaskInventoryItem item in m_items.Values) | 721 | if (item.Name == name) |
722 | { | 722 | items.Add(item); |
723 | if (item.Name == name) | ||
724 | items.Add(item); | ||
725 | } | ||
726 | } | 723 | } |
727 | 724 | ||
725 | m_items.LockItemsForRead(false); | ||
726 | |||
728 | return items; | 727 | return items; |
729 | } | 728 | } |
730 | 729 | ||
@@ -736,6 +735,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
736 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> | 735 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> |
737 | public bool UpdateInventoryItem(TaskInventoryItem item) | 736 | public bool UpdateInventoryItem(TaskInventoryItem item) |
738 | { | 737 | { |
738 | return UpdateInventoryItem(item, true); | ||
739 | } | ||
740 | |||
741 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) | ||
742 | { | ||
739 | m_items.LockItemsForWrite(true); | 743 | m_items.LockItemsForWrite(true); |
740 | 744 | ||
741 | if (m_items.ContainsKey(item.ItemID)) | 745 | if (m_items.ContainsKey(item.ItemID)) |
@@ -743,6 +747,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
743 | item.ParentID = m_part.UUID; | 747 | item.ParentID = m_part.UUID; |
744 | item.ParentPartID = m_part.UUID; | 748 | item.ParentPartID = m_part.UUID; |
745 | item.Flags = m_items[item.ItemID].Flags; | 749 | item.Flags = m_items[item.ItemID].Flags; |
750 | |||
751 | // If group permissions have been set on, check that the groupID is up to date in case it has | ||
752 | // changed since permissions were last set. | ||
753 | if (item.GroupPermissions != (uint)PermissionMask.None) | ||
754 | item.GroupID = m_part.GroupID; | ||
755 | |||
746 | if (item.AssetID == UUID.Zero) | 756 | if (item.AssetID == UUID.Zero) |
747 | { | 757 | { |
748 | item.AssetID = m_items[item.ItemID].AssetID; | 758 | item.AssetID = m_items[item.ItemID].AssetID; |
@@ -760,8 +770,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
760 | 770 | ||
761 | m_items[item.ItemID] = item; | 771 | m_items[item.ItemID] = item; |
762 | m_inventorySerial++; | 772 | m_inventorySerial++; |
763 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 773 | if (fireScriptEvents) |
764 | 774 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | |
765 | HasInventoryChanged = true; | 775 | HasInventoryChanged = true; |
766 | m_part.ParentGroup.HasGroupChanged = true; | 776 | m_part.ParentGroup.HasGroupChanged = true; |
767 | m_items.LockItemsForWrite(false); | 777 | m_items.LockItemsForWrite(false); |
@@ -896,6 +906,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
896 | uint everyoneMask = 0; | 906 | uint everyoneMask = 0; |
897 | uint baseMask = item.BasePermissions; | 907 | uint baseMask = item.BasePermissions; |
898 | uint ownerMask = item.CurrentPermissions; | 908 | uint ownerMask = item.CurrentPermissions; |
909 | uint groupMask = item.GroupPermissions; | ||
899 | 910 | ||
900 | invString.AddItemStart(); | 911 | invString.AddItemStart(); |
901 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 912 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
@@ -905,7 +916,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
905 | 916 | ||
906 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 917 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); |
907 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 918 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); |
908 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); | 919 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); |
909 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | 920 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); |
910 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | 921 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); |
911 | 922 | ||
@@ -1112,6 +1123,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1112 | 1123 | ||
1113 | public Dictionary<UUID, string> GetScriptStates() | 1124 | public Dictionary<UUID, string> GetScriptStates() |
1114 | { | 1125 | { |
1126 | return GetScriptStates(false); | ||
1127 | } | ||
1128 | |||
1129 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1130 | { | ||
1115 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 1131 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
1116 | 1132 | ||
1117 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1133 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
@@ -1129,8 +1145,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1129 | string n = e.GetXMLState(item.ItemID); | 1145 | string n = e.GetXMLState(item.ItemID); |
1130 | if (n != String.Empty) | 1146 | if (n != String.Empty) |
1131 | { | 1147 | { |
1132 | if (!ret.ContainsKey(item.ItemID)) | 1148 | if (oldIDs) |
1133 | ret[item.ItemID] = n; | 1149 | { |
1150 | if (!ret.ContainsKey(item.OldItemID)) | ||
1151 | ret[item.OldItemID] = n; | ||
1152 | } | ||
1153 | else | ||
1154 | { | ||
1155 | if (!ret.ContainsKey(item.ItemID)) | ||
1156 | ret[item.ItemID] = n; | ||
1157 | } | ||
1134 | break; | 1158 | break; |
1135 | } | 1159 | } |
1136 | } | 1160 | } |
@@ -1139,5 +1163,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1139 | } | 1163 | } |
1140 | return ret; | 1164 | return ret; |
1141 | } | 1165 | } |
1166 | |||
1167 | public void ResumeScripts() | ||
1168 | { | ||
1169 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
1170 | if (engines == null) | ||
1171 | return; | ||
1172 | |||
1173 | |||
1174 | Items.LockItemsForRead(true); | ||
1175 | |||
1176 | foreach (TaskInventoryItem item in m_items.Values) | ||
1177 | { | ||
1178 | if (item.InvType == (int)InventoryType.LSL) | ||
1179 | { | ||
1180 | foreach (IScriptModule engine in engines) | ||
1181 | { | ||
1182 | if (engine != null) | ||
1183 | engine.ResumeScript(item.ItemID); | ||
1184 | } | ||
1185 | } | ||
1186 | } | ||
1187 | |||
1188 | Items.LockItemsForRead(false); | ||
1189 | } | ||
1142 | } | 1190 | } |
1143 | } | 1191 | } |