aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
diff options
context:
space:
mode:
authorMelanie2010-02-08 15:53:20 +0000
committerMelanie2010-02-08 15:53:38 +0000
commitbaaf660511214e52ea4ed20b8e80ec8e1ff06a3a (patch)
tree1e90c7a22ea3354d6bfd5d2b3f8f64f199dbd477 /OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
parentAdded missing configs to Standalone.ini (diff)
parentAdding the Careminster "Configger" tool to OpenSim. The tool will, when launched (diff)
downloadopensim-SC-baaf660511214e52ea4ed20b8e80ec8e1ff06a3a.zip
opensim-SC-baaf660511214e52ea4ed20b8e80ec8e1ff06a3a.tar.gz
opensim-SC-baaf660511214e52ea4ed20b8e80ec8e1ff06a3a.tar.bz2
opensim-SC-baaf660511214e52ea4ed20b8e80ec8e1ff06a3a.tar.xz
Merge branch 'master' into presence-refactor
This was a large, heavily conflicted merge and things MAY have got broken. Please check!
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs265
1 files changed, 173 insertions, 92 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 168912e..d0de513 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -229,7 +229,11 @@ namespace OpenSim.Region.Framework.Scenes
229 /// <summary> 229 /// <summary>
230 /// Stop all the scripts in this prim. 230 /// Stop all the scripts in this prim.
231 /// </summary> 231 /// </summary>
232 public void RemoveScriptInstances() 232 /// <param name="sceneObjectBeingDeleted">
233 /// Should be true if these scripts are being removed because the scene
234 /// object is being deleted. This will prevent spurious updates to the client.
235 /// </param>
236 public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
233 { 237 {
234 lock (Items) 238 lock (Items)
235 { 239 {
@@ -237,8 +241,7 @@ namespace OpenSim.Region.Framework.Scenes
237 { 241 {
238 if ((int)InventoryType.LSL == item.InvType) 242 if ((int)InventoryType.LSL == item.InvType)
239 { 243 {
240 RemoveScriptInstance(item.ItemID); 244 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
241 m_part.RemoveScriptEvents(item.ItemID);
242 } 245 }
243 } 246 }
244 } 247 }
@@ -266,8 +269,12 @@ namespace OpenSim.Region.Framework.Scenes
266 if (stateSource == 1 && // Prim crossing 269 if (stateSource == 1 && // Prim crossing
267 m_part.ParentGroup.Scene.m_trustBinaries) 270 m_part.ParentGroup.Scene.m_trustBinaries)
268 { 271 {
269 m_items[item.ItemID].PermsMask = 0; 272 lock (m_items)
270 m_items[item.ItemID].PermsGranter = UUID.Zero; 273 {
274 m_items[item.ItemID].PermsMask = 0;
275 m_items[item.ItemID].PermsGranter = UUID.Zero;
276 }
277
271 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 278 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
272 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); 279 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
273 m_part.ParentGroup.AddActiveScriptCount(1); 280 m_part.ParentGroup.AddActiveScriptCount(1);
@@ -275,33 +282,38 @@ namespace OpenSim.Region.Framework.Scenes
275 return; 282 return;
276 } 283 }
277 284
278 m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) 285 m_part.ParentGroup.Scene.AssetService.Get(
279 { 286 item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset)
280 if (null == asset) 287 {
281 { 288 if (null == asset)
282 m_log.ErrorFormat( 289 {
283 "[PRIM INVENTORY]: " + 290 m_log.ErrorFormat(
284 "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", 291 "[PRIM INVENTORY]: " +
285 item.Name, item.ItemID, m_part.AbsolutePosition, 292 "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
286 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); 293 item.Name, item.ItemID, m_part.AbsolutePosition,
287 } 294 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
288 else 295 }
289 { 296 else
290 if (m_part.ParentGroup.m_savedScriptState != null) 297 {
291 RestoreSavedScriptState(item.OldItemID, item.ItemID); 298 if (m_part.ParentGroup.m_savedScriptState != null)
292 m_items[item.ItemID].PermsMask = 0; 299 RestoreSavedScriptState(item.OldItemID, item.ItemID);
293 m_items[item.ItemID].PermsGranter = UUID.Zero; 300
294 string script = Utils.BytesToString(asset.Data); 301 lock (m_items)
295 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 302 {
296 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); 303 m_items[item.ItemID].PermsMask = 0;
297 m_part.ParentGroup.AddActiveScriptCount(1); 304 m_items[item.ItemID].PermsGranter = UUID.Zero;
298 m_part.ScheduleFullUpdate(); 305 }
299 } 306
300 }); 307 string script = Utils.BytesToString(asset.Data);
301 } 308 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
302 } 309 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
303 310 m_part.ParentGroup.AddActiveScriptCount(1);
304 static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 311 m_part.ScheduleFullUpdate();
312 }
313 }
314 );
315 }
316 }
305 317
306 private void RestoreSavedScriptState(UUID oldID, UUID newID) 318 private void RestoreSavedScriptState(UUID oldID, UUID newID)
307 { 319 {
@@ -387,10 +399,25 @@ namespace OpenSim.Region.Framework.Scenes
387 /// Stop a script which is in this prim's inventory. 399 /// Stop a script which is in this prim's inventory.
388 /// </summary> 400 /// </summary>
389 /// <param name="itemId"></param> 401 /// <param name="itemId"></param>
390 public void RemoveScriptInstance(UUID itemId) 402 /// <param name="sceneObjectBeingDeleted">
403 /// Should be true if this script is being removed because the scene
404 /// object is being deleted. This will prevent spurious updates to the client.
405 /// </param>
406 public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted)
391 { 407 {
392 if (m_items.ContainsKey(itemId)) 408 bool scriptPresent = false;
409
410 lock (m_items)
411 {
412 if (m_items.ContainsKey(itemId))
413 scriptPresent = true;
414 }
415
416 if (scriptPresent)
393 { 417 {
418 if (!sceneObjectBeingDeleted)
419 m_part.RemoveScriptEvents(itemId);
420
394 m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemId); 421 m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemId);
395 m_part.ParentGroup.AddActiveScriptCount(-1); 422 m_part.ParentGroup.AddActiveScriptCount(-1);
396 } 423 }
@@ -458,13 +485,19 @@ namespace OpenSim.Region.Framework.Scenes
458 /// <param name="item"></param> 485 /// <param name="item"></param>
459 public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) 486 public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop)
460 { 487 {
461 List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); 488 List<TaskInventoryItem> il;
489
490 lock (m_items)
491 {
492 il = new List<TaskInventoryItem>(m_items.Values);
493 }
494
462 foreach (TaskInventoryItem i in il) 495 foreach (TaskInventoryItem i in il)
463 { 496 {
464 if (i.Name == item.Name) 497 if (i.Name == item.Name)
465 { 498 {
466 if (i.InvType == (int)InventoryType.LSL) 499 if (i.InvType == (int)InventoryType.LSL)
467 RemoveScriptInstance(i.ItemID); 500 RemoveScriptInstance(i.ItemID, false);
468 501
469 RemoveInventoryItem(i.ItemID); 502 RemoveInventoryItem(i.ItemID);
470 break; 503 break;
@@ -540,11 +573,37 @@ namespace OpenSim.Region.Framework.Scenes
540 public TaskInventoryItem GetInventoryItem(UUID itemId) 573 public TaskInventoryItem GetInventoryItem(UUID itemId)
541 { 574 {
542 TaskInventoryItem item; 575 TaskInventoryItem item;
543 m_items.TryGetValue(itemId, out item); 576
577 lock (m_items)
578 m_items.TryGetValue(itemId, out item);
544 579
545 return item; 580 return item;
546 } 581 }
582
583 /// <summary>
584 /// Get inventory items by name.
585 /// </summary>
586 /// <param name="name"></param>
587 /// <returns>
588 /// A list of inventory items with that name.
589 /// If no inventory item has that name then an empty list is returned.
590 /// </returns>
591 public IList<TaskInventoryItem> GetInventoryItems(string name)
592 {
593 IList<TaskInventoryItem> items = new List<TaskInventoryItem>();
594
595 lock (m_items)
596 {
597 foreach (TaskInventoryItem item in m_items.Values)
598 {
599 if (item.Name == name)
600 items.Add(item);
601 }
602 }
547 603
604 return items;
605 }
606
548 /// <summary> 607 /// <summary>
549 /// Update an existing inventory item. 608 /// Update an existing inventory item.
550 /// </summary> 609 /// </summary>
@@ -612,6 +671,7 @@ namespace OpenSim.Region.Framework.Scenes
612 int type = m_items[itemID].InvType; 671 int type = m_items[itemID].InvType;
613 if (type == 10) // Script 672 if (type == 10) // Script
614 { 673 {
674 m_part.RemoveScriptEvents(itemID);
615 m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); 675 m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID);
616 } 676 }
617 m_items.Remove(itemID); 677 m_items.Remove(itemID);
@@ -841,54 +901,61 @@ namespace OpenSim.Region.Framework.Scenes
841 { 901 {
842 uint mask=0x7fffffff; 902 uint mask=0x7fffffff;
843 903
844 foreach (TaskInventoryItem item in m_items.Values) 904 lock (m_items)
845 { 905 {
846 if (item.InvType != (int)InventoryType.Object) 906 foreach (TaskInventoryItem item in m_items.Values)
847 {
848 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0)
849 mask &= ~((uint)PermissionMask.Copy >> 13);
850 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0)
851 mask &= ~((uint)PermissionMask.Transfer >> 13);
852 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0)
853 mask &= ~((uint)PermissionMask.Modify >> 13);
854 }
855 else
856 { 907 {
857 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) 908 if (item.InvType != (int)InventoryType.Object)
858 mask &= ~((uint)PermissionMask.Copy >> 13); 909 {
859 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) 910 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0)
860 mask &= ~((uint)PermissionMask.Transfer >> 13); 911 mask &= ~((uint)PermissionMask.Copy >> 13);
861 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) 912 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0)
862 mask &= ~((uint)PermissionMask.Modify >> 13); 913 mask &= ~((uint)PermissionMask.Transfer >> 13);
914 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0)
915 mask &= ~((uint)PermissionMask.Modify >> 13);
916 }
917 else
918 {
919 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
920 mask &= ~((uint)PermissionMask.Copy >> 13);
921 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
922 mask &= ~((uint)PermissionMask.Transfer >> 13);
923 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
924 mask &= ~((uint)PermissionMask.Modify >> 13);
925 }
926
927 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
928 mask &= ~(uint)PermissionMask.Copy;
929 if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
930 mask &= ~(uint)PermissionMask.Transfer;
931 if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0)
932 mask &= ~(uint)PermissionMask.Modify;
863 } 933 }
864
865 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
866 mask &= ~(uint)PermissionMask.Copy;
867 if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
868 mask &= ~(uint)PermissionMask.Transfer;
869 if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0)
870 mask &= ~(uint)PermissionMask.Modify;
871 } 934 }
935
872 return mask; 936 return mask;
873 } 937 }
874 938
875 public void ApplyNextOwnerPermissions() 939 public void ApplyNextOwnerPermissions()
876 { 940 {
877 foreach (TaskInventoryItem item in m_items.Values) 941 lock (m_items)
878 { 942 {
879 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) 943 foreach (TaskInventoryItem item in m_items.Values)
880 { 944 {
881 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) 945 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
882 item.CurrentPermissions &= ~(uint)PermissionMask.Copy; 946 {
883 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) 947 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
884 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; 948 item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
885 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) 949 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
886 item.CurrentPermissions &= ~(uint)PermissionMask.Modify; 950 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
887 item.CurrentPermissions |= 8; 951 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
952 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
953 item.CurrentPermissions |= 8;
954 }
955 item.CurrentPermissions &= item.NextPermissions;
956 item.BasePermissions &= item.NextPermissions;
957 item.EveryonePermissions &= item.NextPermissions;
888 } 958 }
889 item.CurrentPermissions &= item.NextPermissions;
890 item.BasePermissions &= item.NextPermissions;
891 item.EveryonePermissions &= item.NextPermissions;
892 } 959 }
893 960
894 m_part.TriggerScriptChangedEvent(Changed.OWNER); 961 m_part.TriggerScriptChangedEvent(Changed.OWNER);
@@ -896,22 +963,29 @@ namespace OpenSim.Region.Framework.Scenes
896 963
897 public void ApplyGodPermissions(uint perms) 964 public void ApplyGodPermissions(uint perms)
898 { 965 {
899 foreach (TaskInventoryItem item in m_items.Values) 966 lock (m_items)
900 { 967 {
901 item.CurrentPermissions = perms; 968 foreach (TaskInventoryItem item in m_items.Values)
902 item.BasePermissions = perms; 969 {
970 item.CurrentPermissions = perms;
971 item.BasePermissions = perms;
972 }
903 } 973 }
904 } 974 }
905 975
906 public bool ContainsScripts() 976 public bool ContainsScripts()
907 { 977 {
908 foreach (TaskInventoryItem item in m_items.Values) 978 lock (m_items)
909 { 979 {
910 if (item.InvType == (int)InventoryType.LSL) 980 foreach (TaskInventoryItem item in m_items.Values)
911 { 981 {
912 return true; 982 if (item.InvType == (int)InventoryType.LSL)
983 {
984 return true;
985 }
913 } 986 }
914 } 987 }
988
915 return false; 989 return false;
916 } 990 }
917 991
@@ -919,8 +993,11 @@ namespace OpenSim.Region.Framework.Scenes
919 { 993 {
920 List<UUID> ret = new List<UUID>(); 994 List<UUID> ret = new List<UUID>();
921 995
922 foreach (TaskInventoryItem item in m_items.Values) 996 lock (m_items)
923 ret.Add(item.ItemID); 997 {
998 foreach (TaskInventoryItem item in m_items.Values)
999 ret.Add(item.ItemID);
1000 }
924 1001
925 return ret; 1002 return ret;
926 } 1003 }
@@ -933,26 +1010,30 @@ namespace OpenSim.Region.Framework.Scenes
933 if (engines == null) // No engine at all 1010 if (engines == null) // No engine at all
934 return ret; 1011 return ret;
935 1012
936 foreach (TaskInventoryItem item in m_items.Values) 1013 lock (m_items)
937 { 1014 {
938 if (item.InvType == (int)InventoryType.LSL) 1015 foreach (TaskInventoryItem item in m_items.Values)
939 { 1016 {
940 foreach (IScriptModule e in engines) 1017 if (item.InvType == (int)InventoryType.LSL)
941 { 1018 {
942 if (e != null) 1019 foreach (IScriptModule e in engines)
943 { 1020 {
944 string n = e.GetXMLState(item.ItemID); 1021 if (e != null)
945 if (n != String.Empty)
946 { 1022 {
947 if (!ret.ContainsKey(item.ItemID)) 1023 string n = e.GetXMLState(item.ItemID);
948 ret[item.ItemID] = n; 1024 if (n != String.Empty)
949 break; 1025 {
1026 if (!ret.ContainsKey(item.ItemID))
1027 ret[item.ItemID] = n;
1028 break;
1029 }
950 } 1030 }
951 } 1031 }
952 } 1032 }
953 } 1033 }
954 } 1034 }
1035
955 return ret; 1036 return ret;
956 } 1037 }
957 } 1038 }
958} 1039} \ No newline at end of file