aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IHyperService.cs37
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs209
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs95
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs23
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs431
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs37
-rw-r--r--OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs269
14 files changed, 466 insertions, 683 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index f8af367..2af2548 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Region.Framework.Interfaces
44 /// <param name="rot"></param> 44 /// <param name="rot"></param>
45 /// <param name="silent"></param> 45 /// <param name="silent"></param>
46 void AttachObject( 46 void AttachObject(
47 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent); 47 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent);
48 48
49 /// <summary> 49 /// <summary>
50 /// Attach an object to an avatar. 50 /// Attach an object to an avatar.
@@ -57,7 +57,7 @@ namespace OpenSim.Region.Framework.Interfaces
57 /// <param name="silent"></param> 57 /// <param name="silent"></param>
58 /// <returns>true if the object was successfully attached, false otherwise</returns> 58 /// <returns>true if the object was successfully attached, false otherwise</returns>
59 bool AttachObject( 59 bool AttachObject(
60 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent); 60 IClientAPI remoteClient, SceneObjectGroup grp, uint AttachmentPt, bool silent);
61 61
62 /// <summary> 62 /// <summary>
63 /// Rez an attachment from user inventory and change inventory status to match. 63 /// Rez an attachment from user inventory and change inventory status to match.
diff --git a/OpenSim/Region/Framework/Interfaces/IHyperService.cs b/OpenSim/Region/Framework/Interfaces/IHyperService.cs
deleted file mode 100644
index 51ea28a..0000000
--- a/OpenSim/Region/Framework/Interfaces/IHyperService.cs
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using OpenMetaverse;
29
30namespace OpenSim.Region.Framework.Interfaces
31{
32 public interface IHyperAssetService
33 {
34 string GetUserAssetServer(UUID userID);
35 string GetSimAssetServer();
36 }
37}
diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
index 97f4188..05fc2ad 100644
--- a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
@@ -43,5 +43,9 @@ namespace OpenSim.Region.Framework.Interfaces
43 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 43 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
44 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment); 44 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment);
45 void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver); 45 void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver);
46 bool GetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID);
47
48 // Must be here because of textures in user's inventory
49 bool IsForeignUser(UUID userID, out string assetServerURL);
46 } 50 }
47} 51}
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index ef125cd..9db2e41 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -179,7 +179,7 @@ namespace OpenSim.Region.Framework.Scenes
179 public event ScriptChangedEvent OnScriptChangedEvent; 179 public event ScriptChangedEvent OnScriptChangedEvent;
180 public delegate void ScriptChangedEvent(uint localID, uint change); 180 public delegate void ScriptChangedEvent(uint localID, uint change);
181 181
182 public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed); 182 public delegate void ScriptControlEvent(UUID item, UUID avatarID, uint held, uint changed);
183 public event ScriptControlEvent OnScriptControlEvent; 183 public event ScriptControlEvent OnScriptControlEvent;
184 184
185 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); 185 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
@@ -1595,7 +1595,7 @@ namespace OpenSim.Region.Framework.Scenes
1595 } 1595 }
1596 } 1596 }
1597 1597
1598 internal void TriggerControlEvent(uint p, UUID scriptUUID, UUID avatarID, uint held, uint _changed) 1598 internal void TriggerControlEvent(UUID scriptUUID, UUID avatarID, uint held, uint _changed)
1599 { 1599 {
1600 ScriptControlEvent handlerScriptControlEvent = OnScriptControlEvent; 1600 ScriptControlEvent handlerScriptControlEvent = OnScriptControlEvent;
1601 if (handlerScriptControlEvent != null) 1601 if (handlerScriptControlEvent != null)
@@ -1604,7 +1604,7 @@ namespace OpenSim.Region.Framework.Scenes
1604 { 1604 {
1605 try 1605 try
1606 { 1606 {
1607 d(p, scriptUUID, avatarID, held, _changed); 1607 d(scriptUUID, avatarID, held, _changed);
1608 } 1608 }
1609 catch (Exception e) 1609 catch (Exception e)
1610 { 1610 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index f9da341..01edf51 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes
73 IMoneyModule money=RequestModuleInterface<IMoneyModule>(); 73 IMoneyModule money=RequestModuleInterface<IMoneyModule>();
74 if (money != null) 74 if (money != null)
75 { 75 {
76 money.ApplyUploadCharge(agentID); 76 money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload");
77 } 77 }
78 78
79 AddInventoryItem(agentID, item); 79 AddInventoryItem(agentID, item);
@@ -265,6 +265,10 @@ namespace OpenSim.Region.Framework.Scenes
265 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID, 265 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
266 UUID itemID, InventoryItemBase itemUpd) 266 UUID itemID, InventoryItemBase itemUpd)
267 { 267 {
268 // This one will let people set next perms on items in agent
269 // inventory. Rut-Roh. Whatever. Make this secure. Yeah.
270 //
271 // Passing something to another avatar or a an object will already
268 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 272 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
269 item = InventoryService.GetItem(item); 273 item = InventoryService.GetItem(item);
270 274
@@ -274,11 +278,9 @@ namespace OpenSim.Region.Framework.Scenes
274 { 278 {
275 item.Name = itemUpd.Name; 279 item.Name = itemUpd.Name;
276 item.Description = itemUpd.Description; 280 item.Description = itemUpd.Description;
277 item.NextPermissions = itemUpd.NextPermissions; 281 item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions;
278 item.CurrentPermissions |= 8; // Slam! 282 item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions;
279 item.EveryOnePermissions = itemUpd.EveryOnePermissions; 283 item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions;
280 item.GroupPermissions = itemUpd.GroupPermissions;
281
282 item.GroupID = itemUpd.GroupID; 284 item.GroupID = itemUpd.GroupID;
283 item.GroupOwned = itemUpd.GroupOwned; 285 item.GroupOwned = itemUpd.GroupOwned;
284 item.CreationDate = itemUpd.CreationDate; 286 item.CreationDate = itemUpd.CreationDate;
@@ -384,28 +386,103 @@ namespace OpenSim.Region.Framework.Scenes
384 386
385 if (Permissions.PropagatePermissions() && recipient != senderId) 387 if (Permissions.PropagatePermissions() && recipient != senderId)
386 { 388 {
387 // First, make sore base is limited to the next perms 389 // Trying to do this right this time. This is evil. If
388 itemCopy.BasePermissions = item.BasePermissions & (item.NextPermissions | (uint)PermissionMask.Move); 390 // you believe in Good, go elsewhere. Vampires and other
389 // By default, current equals base 391 // evil creatores only beyond this point. You have been
390 itemCopy.CurrentPermissions = itemCopy.BasePermissions & item.CurrentPermissions; 392 // warned.
391 393
392 // If this is an object, replace current perms 394 // We're going to mask a lot of things by the next perms
393 // with folded perms 395 // Tweak the next perms to be nicer to our data
396 //
397 // In this mask, all the bits we do NOT want to mess
398 // with are set. These are:
399 //
400 // Transfer
401 // Copy
402 // Modufy
403 uint permsMask = ~ ((uint)PermissionMask.Copy |
404 (uint)PermissionMask.Transfer |
405 (uint)PermissionMask.Modify);
406
407 // Now, reduce the next perms to the mask bits
408 // relevant to the operation
409 uint nextPerms = permsMask | (item.NextPermissions &
410 ((uint)PermissionMask.Copy |
411 (uint)PermissionMask.Transfer |
412 (uint)PermissionMask.Modify));
413
414 // nextPerms now has all bits set, except for the actual
415 // next permission bits.
416
417 // This checks for no mod, no copy, no trans.
418 // This indicates an error or messed up item. Do it like
419 // SL and assume trans
420 if (nextPerms == permsMask)
421 nextPerms |= (uint)PermissionMask.Transfer;
422
423 // Inventory owner perms are the logical AND of the
424 // folded perms and the root prim perms, however, if
425 // the root prim is mod, the inventory perms will be
426 // mod. This happens on "take" and is of little concern
427 // here, save for preventing escalation
428
429 // This hack ensures that items previously permalocked
430 // get unlocked when they're passed or rezzed
431 uint basePerms = item.BasePermissions |
432 (uint)PermissionMask.Move;
433 uint ownerPerms = item.CurrentPermissions;
434
435 // If this is an object, root prim perms may be more
436 // permissive than folded perms. Use folded perms as
437 // a mask
394 if (item.InvType == (int)InventoryType.Object) 438 if (item.InvType == (int)InventoryType.Object)
395 { 439 {
396 itemCopy.CurrentPermissions &= ~(uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); 440 // Create a safe mask for the current perms
397 itemCopy.CurrentPermissions |= (item.CurrentPermissions & 7) << 13; 441 uint foldedPerms = (item.CurrentPermissions & 7) << 13;
442 foldedPerms |= permsMask;
443
444 bool isRootMod = (item.CurrentPermissions &
445 (uint)PermissionMask.Modify) != 0 ?
446 true : false;
447
448 // Mask the owner perms to the folded perms
449 ownerPerms &= foldedPerms;
450 basePerms &= foldedPerms;
451
452 // If the root was mod, let the mask reflect that
453 // We also need to adjust the base here, because
454 // we should be able to edit in-inventory perms
455 // for the root prim, if it's mod.
456 if (isRootMod)
457 {
458 ownerPerms |= (uint)PermissionMask.Modify;
459 basePerms |= (uint)PermissionMask.Modify;
460 }
398 } 461 }
399 462
400 // Ensure there is no escalation 463 // These will be applied to the root prim at next rez.
401 itemCopy.CurrentPermissions &= (item.NextPermissions | (uint)PermissionMask.Move); 464 // The slam bit (bit 3) and folded permission (bits 0-2)
465 // are preserved due to the above mangling
466 ownerPerms &= nextPerms;
402 467
403 // Need slam bit on xfer 468 // Mask the base permissions. This is a conservative
404 itemCopy.CurrentPermissions |= 8; 469 // approach altering only the three main perms
470 basePerms &= nextPerms;
471
472 // Assign to the actual item. Make sure the slam bit is
473 // set, if it wasn't set before.
474 itemCopy.BasePermissions = basePerms;
475 itemCopy.CurrentPermissions = ownerPerms | 16; // Slam
405 476
406 itemCopy.NextPermissions = item.NextPermissions; 477 itemCopy.NextPermissions = item.NextPermissions;
407 478
408 itemCopy.EveryOnePermissions = 0; 479 // This preserves "everyone can move"
480 itemCopy.EveryOnePermissions = item.EveryOnePermissions &
481 nextPerms;
482
483 // Intentionally killing "share with group" here, as
484 // the recipient will not have the group this is
485 // set to
409 itemCopy.GroupPermissions = 0; 486 itemCopy.GroupPermissions = 0;
410 } 487 }
411 else 488 else
@@ -839,6 +916,9 @@ namespace OpenSim.Region.Framework.Scenes
839 SceneObjectGroup group = part.ParentGroup; 916 SceneObjectGroup group = part.ParentGroup;
840 if (group != null) 917 if (group != null)
841 { 918 {
919 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
920 return;
921
842 TaskInventoryItem item = group.GetInventoryItem(localID, itemID); 922 TaskInventoryItem item = group.GetInventoryItem(localID, itemID);
843 if (item == null) 923 if (item == null)
844 return; 924 return;
@@ -903,7 +983,7 @@ namespace OpenSim.Region.Framework.Scenes
903 else 983 else
904 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; 984 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions;
905 985
906 agentItem.CurrentPermissions |= 8; 986 agentItem.CurrentPermissions |= 16; // Slam
907 agentItem.NextPermissions = taskItem.NextPermissions; 987 agentItem.NextPermissions = taskItem.NextPermissions;
908 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); 988 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
909 agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; 989 agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions;
@@ -978,9 +1058,21 @@ namespace OpenSim.Region.Framework.Scenes
978 return; 1058 return;
979 } 1059 }
980 1060
981 // Only owner can copy 1061 TaskInventoryItem item = part.Inventory.GetInventoryItem(itemId);
982 if (remoteClient.AgentId != taskItem.OwnerID) 1062 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
983 return; 1063 {
1064 // If the item to be moved is no copy, we need to be able to
1065 // edit the prim.
1066 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
1067 return;
1068 }
1069 else
1070 {
1071 // If the item is copiable, then we just need to have perms
1072 // on it. The delete check is a pure rights check
1073 if (!Permissions.CanDeleteObject(part.UUID, remoteClient.AgentId))
1074 return;
1075 }
984 1076
985 MoveTaskInventoryItem(remoteClient, folderId, part, itemId); 1077 MoveTaskInventoryItem(remoteClient, folderId, part, itemId);
986 } 1078 }
@@ -1094,7 +1186,7 @@ namespace OpenSim.Region.Framework.Scenes
1094 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); 1186 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move);
1095 destTaskItem.BasePermissions = srcTaskItem.BasePermissions & 1187 destTaskItem.BasePermissions = srcTaskItem.BasePermissions &
1096 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); 1188 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move);
1097 destTaskItem.CurrentPermissions |= 8; // Slam! 1189 destTaskItem.CurrentPermissions |= 16; // Slam!
1098 } 1190 }
1099 } 1191 }
1100 1192
@@ -1263,10 +1355,48 @@ namespace OpenSim.Region.Framework.Scenes
1263 { 1355 {
1264 agentTransactions.HandleTaskItemUpdateFromTransaction( 1356 agentTransactions.HandleTaskItemUpdateFromTransaction(
1265 remoteClient, part, transactionID, currentItem); 1357 remoteClient, part, transactionID, currentItem);
1358
1359 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1360 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1361 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1362 remoteClient.SendAgentAlertMessage("Script saved", false);
1363 else
1364 remoteClient.SendAgentAlertMessage("Item saved", false);
1365 }
1366
1367 // Base ALWAYS has move
1368 currentItem.BasePermissions |= (uint)PermissionMask.Move;
1369
1370 // Check if we're allowed to mess with permissions
1371 if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god
1372 {
1373 if (remoteClient.AgentId != part.OwnerID) // Not owner
1374 {
1375 // Friends and group members can't change any perms
1376 itemInfo.BasePermissions = currentItem.BasePermissions;
1377 itemInfo.EveryonePermissions = currentItem.EveryonePermissions;
1378 itemInfo.GroupPermissions = currentItem.GroupPermissions;
1379 itemInfo.NextPermissions = currentItem.NextPermissions;
1380 itemInfo.CurrentPermissions = currentItem.CurrentPermissions;
1381 }
1382 else
1383 {
1384 // Owner can't change base, and can change other
1385 // only up to base
1386 itemInfo.BasePermissions = currentItem.BasePermissions;
1387 itemInfo.EveryonePermissions &= currentItem.BasePermissions;
1388 itemInfo.GroupPermissions &= currentItem.BasePermissions;
1389 itemInfo.CurrentPermissions &= currentItem.BasePermissions;
1390 itemInfo.NextPermissions &= currentItem.BasePermissions;
1391 }
1392
1266 } 1393 }
1394
1395 // Next ALWAYS has move
1396 itemInfo.NextPermissions |= (uint)PermissionMask.Move;
1397
1267 if (part.Inventory.UpdateInventoryItem(itemInfo)) 1398 if (part.Inventory.UpdateInventoryItem(itemInfo))
1268 { 1399 {
1269 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1270 part.GetProperties(remoteClient); 1400 part.GetProperties(remoteClient);
1271 } 1401 }
1272 } 1402 }
@@ -1478,7 +1608,7 @@ namespace OpenSim.Region.Framework.Scenes
1478 srcTaskItem.NextPermissions; 1608 srcTaskItem.NextPermissions;
1479 destTaskItem.BasePermissions = srcTaskItem.BasePermissions & 1609 destTaskItem.BasePermissions = srcTaskItem.BasePermissions &
1480 srcTaskItem.NextPermissions; 1610 srcTaskItem.NextPermissions;
1481 destTaskItem.CurrentPermissions |= 8; // Slam! 1611 destTaskItem.CurrentPermissions |= 16; // Slam!
1482 } 1612 }
1483 } 1613 }
1484 1614
@@ -1597,7 +1727,7 @@ namespace OpenSim.Region.Framework.Scenes
1597 } 1727 }
1598 1728
1599 // Handle god perms 1729 // Handle god perms
1600 if (Permissions.IsGod(remoteClient.AgentId)) 1730 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1601 { 1731 {
1602 permissionToTake = true; 1732 permissionToTake = true;
1603 permissionToTakeCopy = true; 1733 permissionToTakeCopy = true;
@@ -1608,7 +1738,7 @@ namespace OpenSim.Region.Framework.Scenes
1608 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1738 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1609 permissionToDelete = false; 1739 permissionToDelete = false;
1610 1740
1611 // if we want to take a copy,, we also don't want to delete 1741 // if we want to take a copy, we also don't want to delete
1612 // Note: after this point, the permissionToTakeCopy flag 1742 // Note: after this point, the permissionToTakeCopy flag
1613 // becomes irrelevant. It already includes the permissionToTake 1743 // becomes irrelevant. It already includes the permissionToTake
1614 // permission and after excluding no copy items here, we can 1744 // permission and after excluding no copy items here, we can
@@ -1619,6 +1749,7 @@ namespace OpenSim.Region.Framework.Scenes
1619 if (!permissionToTakeCopy) 1749 if (!permissionToTakeCopy)
1620 return; 1750 return;
1621 1751
1752 permissionToTake = true;
1622 // Don't delete 1753 // Don't delete
1623 permissionToDelete = false; 1754 permissionToDelete = false;
1624 } 1755 }
@@ -1863,17 +1994,14 @@ namespace OpenSim.Region.Framework.Scenes
1863 1994
1864 group.SetGroup(sourcePart.GroupID, null); 1995 group.SetGroup(sourcePart.GroupID, null);
1865 1996
1866 if (rootPart.OwnerID != item.OwnerID) 1997 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
1867 { 1998 {
1868 if (Permissions.PropagatePermissions()) 1999 if (Permissions.PropagatePermissions())
1869 { 2000 {
1870 if ((item.CurrentPermissions & 8) != 0) 2001 foreach (SceneObjectPart part in partList)
1871 { 2002 {
1872 foreach (SceneObjectPart part in partList) 2003 part.EveryoneMask = item.EveryonePermissions;
1873 { 2004 part.NextOwnerMask = item.NextPermissions;
1874 part.EveryoneMask = item.EveryonePermissions;
1875 part.NextOwnerMask = item.NextPermissions;
1876 }
1877 } 2005 }
1878 group.ApplyNextOwnerPermissions(); 2006 group.ApplyNextOwnerPermissions();
1879 } 2007 }
@@ -1881,17 +2009,14 @@ namespace OpenSim.Region.Framework.Scenes
1881 2009
1882 foreach (SceneObjectPart part in partList) 2010 foreach (SceneObjectPart part in partList)
1883 { 2011 {
1884 if (part.OwnerID != item.OwnerID) 2012 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
1885 { 2013 {
1886 part.LastOwnerID = part.OwnerID; 2014 part.LastOwnerID = part.OwnerID;
1887 part.OwnerID = item.OwnerID; 2015 part.OwnerID = item.OwnerID;
1888 part.Inventory.ChangeInventoryOwner(item.OwnerID); 2016 part.Inventory.ChangeInventoryOwner(item.OwnerID);
1889 } 2017 }
1890 else if ((item.CurrentPermissions & 8) != 0) // Slam! 2018 part.EveryoneMask = item.EveryonePermissions;
1891 { 2019 part.NextOwnerMask = item.NextPermissions;
1892 part.EveryoneMask = item.EveryonePermissions;
1893 part.NextOwnerMask = item.NextPermissions;
1894 }
1895 } 2020 }
1896 2021
1897 rootPart.TrimPermissions(); 2022 rootPart.TrimPermissions();
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
index 7dab04f..a523351 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
@@ -64,6 +64,7 @@ namespace OpenSim.Region.Framework.Scenes
64 public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); 64 public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene);
65 public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); 65 public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand);
66 public delegate bool IsGodHandler(UUID user, Scene requestFromScene); 66 public delegate bool IsGodHandler(UUID user, Scene requestFromScene);
67 public delegate bool IsAdministratorHandler(UUID user);
67 public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); 68 public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene);
68 public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); 69 public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene);
69 public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); 70 public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene);
@@ -122,6 +123,7 @@ namespace OpenSim.Region.Framework.Scenes
122 public event RunConsoleCommandHandler OnRunConsoleCommand; 123 public event RunConsoleCommandHandler OnRunConsoleCommand;
123 public event IssueEstateCommandHandler OnIssueEstateCommand; 124 public event IssueEstateCommandHandler OnIssueEstateCommand;
124 public event IsGodHandler OnIsGod; 125 public event IsGodHandler OnIsGod;
126 public event IsAdministratorHandler OnIsAdministrator;
125 public event EditParcelHandler OnEditParcel; 127 public event EditParcelHandler OnEditParcel;
126 public event SellParcelHandler OnSellParcel; 128 public event SellParcelHandler OnSellParcel;
127 public event AbandonParcelHandler OnAbandonParcel; 129 public event AbandonParcelHandler OnAbandonParcel;
@@ -652,6 +654,21 @@ namespace OpenSim.Region.Framework.Scenes
652 } 654 }
653 return true; 655 return true;
654 } 656 }
657
658 public bool IsAdministrator(UUID user)
659 {
660 IsAdministratorHandler handler = OnIsAdministrator;
661 if (handler != null)
662 {
663 Delegate[] list = handler.GetInvocationList();
664 foreach (IsAdministratorHandler h in list)
665 {
666 if (h(user) == false)
667 return false;
668 }
669 }
670 return true;
671 }
655 #endregion 672 #endregion
656 673
657 #region EDIT PARCEL 674 #region EDIT PARCEL
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e2ab643..93f684c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -136,6 +136,7 @@ namespace OpenSim.Region.Framework.Scenes
136 136
137 protected SceneCommunicationService m_sceneGridService; 137 protected SceneCommunicationService m_sceneGridService;
138 public bool LoginsDisabled = true; 138 public bool LoginsDisabled = true;
139 public bool LoadingPrims = false;
139 140
140 public new float TimeDilation 141 public new float TimeDilation
141 { 142 {
@@ -478,8 +479,6 @@ namespace OpenSim.Region.Framework.Scenes
478 set { m_sceneGraph.RestorePresences = value; } 479 set { m_sceneGraph.RestorePresences = value; }
479 } 480 }
480 481
481 public int objectCapacity = 45000;
482
483 #endregion 482 #endregion
484 483
485 #region BinaryStats 484 #region BinaryStats
@@ -687,7 +686,7 @@ namespace OpenSim.Region.Framework.Scenes
687 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 686 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
688 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 687 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
689 688
690 StatsReporter.SetObjectCapacity(objectCapacity); 689 StatsReporter.SetObjectCapacity(RegionInfo.ObjectCapacity);
691 690
692 // Old 691 // Old
693 /* 692 /*
@@ -1879,6 +1878,7 @@ namespace OpenSim.Region.Framework.Scenes
1879 /// </summary> 1878 /// </summary>
1880 public virtual void LoadPrimsFromStorage(UUID regionID) 1879 public virtual void LoadPrimsFromStorage(UUID regionID)
1881 { 1880 {
1881 LoadingPrims = true;
1882 m_log.Info("[SCENE]: Loading objects from datastore"); 1882 m_log.Info("[SCENE]: Loading objects from datastore");
1883 1883
1884 List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(regionID); 1884 List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(regionID);
@@ -1902,6 +1902,7 @@ namespace OpenSim.Region.Framework.Scenes
1902 } 1902 }
1903 1903
1904 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); 1904 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
1905 LoadingPrims = false;
1905 } 1906 }
1906 1907
1907 1908
@@ -2573,8 +2574,7 @@ namespace OpenSim.Region.Framework.Scenes
2573 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2574 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2574 2575
2575 if (AttachmentsModule != null) 2576 if (AttachmentsModule != null)
2576 AttachmentsModule.AttachObject( 2577 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2577 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
2578 2578
2579 } 2579 }
2580 else 2580 else
@@ -2725,7 +2725,9 @@ namespace OpenSim.Region.Framework.Scenes
2725 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); 2725 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2726 if (userVerification != null && ep != null) 2726 if (userVerification != null && ep != null)
2727 { 2727 {
2728 if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString())) 2728 System.Net.IPAddress addr = NetworkUtil.GetExternalIPOf(ep.Address);
2729
2730 if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString()))
2729 { 2731 {
2730 // uh-oh, this is fishy 2732 // uh-oh, this is fishy
2731 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); 2733 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
@@ -2783,17 +2785,11 @@ namespace OpenSim.Region.Framework.Scenes
2783 SubscribeToClientPrimEvents(client); 2785 SubscribeToClientPrimEvents(client);
2784 SubscribeToClientPrimRezEvents(client); 2786 SubscribeToClientPrimRezEvents(client);
2785 SubscribeToClientInventoryEvents(client); 2787 SubscribeToClientInventoryEvents(client);
2786 SubscribeToClientAttachmentEvents(client);
2787 SubscribeToClientTeleportEvents(client); 2788 SubscribeToClientTeleportEvents(client);
2788 SubscribeToClientScriptEvents(client); 2789 SubscribeToClientScriptEvents(client);
2789 SubscribeToClientParcelEvents(client); 2790 SubscribeToClientParcelEvents(client);
2790 SubscribeToClientGridEvents(client); 2791 SubscribeToClientGridEvents(client);
2791 SubscribeToClientGodEvents(client);
2792
2793 SubscribeToClientNetworkEvents(client); 2792 SubscribeToClientNetworkEvents(client);
2794
2795
2796 // EventManager.TriggerOnNewClient(client);
2797 } 2793 }
2798 2794
2799 public virtual void SubscribeToClientTerrainEvents(IClientAPI client) 2795 public virtual void SubscribeToClientTerrainEvents(IClientAPI client)
@@ -2803,8 +2799,7 @@ namespace OpenSim.Region.Framework.Scenes
2803 } 2799 }
2804 2800
2805 public virtual void SubscribeToClientPrimEvents(IClientAPI client) 2801 public virtual void SubscribeToClientPrimEvents(IClientAPI client)
2806 { 2802 {
2807
2808 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition; 2803 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition;
2809 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 2804 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2810 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation; 2805 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation;
@@ -2874,18 +2869,6 @@ namespace OpenSim.Region.Framework.Scenes
2874 client.OnMoveTaskItem += ClientMoveTaskInventoryItem; 2869 client.OnMoveTaskItem += ClientMoveTaskInventoryItem;
2875 } 2870 }
2876 2871
2877 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client)
2878 {
2879 if (AttachmentsModule != null)
2880 {
2881 client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory;
2882 client.OnRezMultipleAttachmentsFromInv += AttachmentsModule.RezMultipleAttachmentsFromInventory;
2883 client.OnObjectAttach += AttachmentsModule.AttachObject;
2884 client.OnObjectDetach += AttachmentsModule.DetachObject;
2885 client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory;
2886 }
2887 }
2888
2889 public virtual void SubscribeToClientTeleportEvents(IClientAPI client) 2872 public virtual void SubscribeToClientTeleportEvents(IClientAPI client)
2890 { 2873 {
2891 client.OnTeleportLocationRequest += RequestTeleportLocation; 2874 client.OnTeleportLocationRequest += RequestTeleportLocation;
@@ -2915,44 +2898,29 @@ namespace OpenSim.Region.Framework.Scenes
2915 client.OnSetStartLocationRequest += SetHomeRezPoint; 2898 client.OnSetStartLocationRequest += SetHomeRezPoint;
2916 client.OnRegionHandleRequest += RegionHandleRequest; 2899 client.OnRegionHandleRequest += RegionHandleRequest;
2917 } 2900 }
2918 2901
2919 public virtual void SubscribeToClientGodEvents(IClientAPI client)
2920 {
2921 IGodsModule godsModule = RequestModuleInterface<IGodsModule>();
2922 client.OnGodKickUser += godsModule.KickUser;
2923 client.OnRequestGodlikePowers += godsModule.RequestGodlikePowers;
2924 }
2925
2926 public virtual void SubscribeToClientNetworkEvents(IClientAPI client) 2902 public virtual void SubscribeToClientNetworkEvents(IClientAPI client)
2927 { 2903 {
2928 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; 2904 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats;
2929 client.OnViewerEffect += ProcessViewerEffect; 2905 client.OnViewerEffect += ProcessViewerEffect;
2930 } 2906 }
2931 2907
2932 protected virtual void UnsubscribeToClientEvents(IClientAPI client)
2933 {
2934 }
2935
2936 /// <summary> 2908 /// <summary>
2937 /// Register for events from the client 2909 /// Unsubscribe the client from events.
2938 /// </summary> 2910 /// </summary>
2939 /// <param name="client">The IClientAPI of the connected client</param> 2911 /// FIXME: Not called anywhere!
2912 /// <param name="client">The IClientAPI of the client</param>
2940 public virtual void UnSubscribeToClientEvents(IClientAPI client) 2913 public virtual void UnSubscribeToClientEvents(IClientAPI client)
2941 { 2914 {
2942 UnSubscribeToClientTerrainEvents(client); 2915 UnSubscribeToClientTerrainEvents(client);
2943 UnSubscribeToClientPrimEvents(client); 2916 UnSubscribeToClientPrimEvents(client);
2944 UnSubscribeToClientPrimRezEvents(client); 2917 UnSubscribeToClientPrimRezEvents(client);
2945 UnSubscribeToClientInventoryEvents(client); 2918 UnSubscribeToClientInventoryEvents(client);
2946 UnSubscribeToClientAttachmentEvents(client);
2947 UnSubscribeToClientTeleportEvents(client); 2919 UnSubscribeToClientTeleportEvents(client);
2948 UnSubscribeToClientScriptEvents(client); 2920 UnSubscribeToClientScriptEvents(client);
2949 UnSubscribeToClientParcelEvents(client); 2921 UnSubscribeToClientParcelEvents(client);
2950 UnSubscribeToClientGridEvents(client); 2922 UnSubscribeToClientGridEvents(client);
2951 UnSubscribeToClientGodEvents(client);
2952
2953 UnSubscribeToClientNetworkEvents(client); 2923 UnSubscribeToClientNetworkEvents(client);
2954
2955 // EventManager.TriggerOnNewClient(client);
2956 } 2924 }
2957 2925
2958 public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) 2926 public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client)
@@ -3029,18 +2997,6 @@ namespace OpenSim.Region.Framework.Scenes
3029 client.OnMoveTaskItem -= ClientMoveTaskInventoryItem; 2997 client.OnMoveTaskItem -= ClientMoveTaskInventoryItem;
3030 } 2998 }
3031 2999
3032 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client)
3033 {
3034 if (AttachmentsModule != null)
3035 {
3036 client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory;
3037 client.OnRezMultipleAttachmentsFromInv -= AttachmentsModule.RezMultipleAttachmentsFromInventory;
3038 client.OnObjectAttach -= AttachmentsModule.AttachObject;
3039 client.OnObjectDetach -= AttachmentsModule.DetachObject;
3040 client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory;
3041 }
3042 }
3043
3044 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) 3000 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client)
3045 { 3001 {
3046 client.OnTeleportLocationRequest -= RequestTeleportLocation; 3002 client.OnTeleportLocationRequest -= RequestTeleportLocation;
@@ -3072,13 +3028,6 @@ namespace OpenSim.Region.Framework.Scenes
3072 client.OnRegionHandleRequest -= RegionHandleRequest; 3028 client.OnRegionHandleRequest -= RegionHandleRequest;
3073 } 3029 }
3074 3030
3075 public virtual void UnSubscribeToClientGodEvents(IClientAPI client)
3076 {
3077 IGodsModule godsModule = RequestModuleInterface<IGodsModule>();
3078 client.OnGodKickUser -= godsModule.KickUser;
3079 client.OnRequestGodlikePowers -= godsModule.RequestGodlikePowers;
3080 }
3081
3082 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) 3031 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client)
3083 { 3032 {
3084 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats; 3033 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats;
@@ -4119,20 +4068,6 @@ namespace OpenSim.Region.Framework.Scenes
4119 4068
4120 #region Other Methods 4069 #region Other Methods
4121 4070
4122 public void SetObjectCapacity(int objects)
4123 {
4124 // Region specific config overrides global
4125 //
4126 if (RegionInfo.ObjectCapacity != 0)
4127 objects = RegionInfo.ObjectCapacity;
4128
4129 if (StatsReporter != null)
4130 {
4131 StatsReporter.SetObjectCapacity(objects);
4132 }
4133 objectCapacity = objects;
4134 }
4135
4136 #endregion 4071 #endregion
4137 4072
4138 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) 4073 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set)
@@ -4731,7 +4666,7 @@ namespace OpenSim.Region.Framework.Scenes
4731 part.NextOwnerMask; 4666 part.NextOwnerMask;
4732 item.GroupPermissions = part.GroupMask & 4667 item.GroupPermissions = part.GroupMask &
4733 part.NextOwnerMask; 4668 part.NextOwnerMask;
4734 item.CurrentPermissions |= 8; // Slam! 4669 item.CurrentPermissions |= 16; // Slam!
4735 item.CreationDate = Util.UnixTimeSinceEpoch(); 4670 item.CreationDate = Util.UnixTimeSinceEpoch();
4736 4671
4737 if (InventoryService.AddItem(item)) 4672 if (InventoryService.AddItem(item))
@@ -5306,4 +5241,4 @@ namespace OpenSim.Region.Framework.Scenes
5306 return offsets.ToArray(); 5241 return offsets.ToArray();
5307 } 5242 }
5308 } 5243 }
5309} 5244} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 40332a6..f47450f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -78,8 +78,6 @@ namespace OpenSim.Region.Framework.Scenes
78// protected internal Dictionary<UUID, EntityBase> Entities = new Dictionary<UUID, EntityBase>(); 78// protected internal Dictionary<UUID, EntityBase> Entities = new Dictionary<UUID, EntityBase>();
79 protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>(); 79 protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>();
80 80
81 protected internal BasicQuadTreeNode QuadTree;
82
83 protected RegionInfo m_regInfo; 81 protected RegionInfo m_regInfo;
84 protected Scene m_parentScene; 82 protected Scene m_parentScene;
85 protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>(); 83 protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>();
@@ -107,9 +105,6 @@ namespace OpenSim.Region.Framework.Scenes
107 { 105 {
108 m_parentScene = parent; 106 m_parentScene = parent;
109 m_regInfo = regInfo; 107 m_regInfo = regInfo;
110 QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, (short)Constants.RegionSize, (short)Constants.RegionSize);
111 QuadTree.Subdivide();
112 QuadTree.Subdivide();
113 } 108 }
114 109
115 public PhysicsScene PhysicsScene 110 public PhysicsScene PhysicsScene
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index f7e46af..9a01a28 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -172,13 +172,14 @@ namespace OpenSim.Region.Framework.Scenes
172 taskItem.GroupPermissions = item.GroupPermissions & 172 taskItem.GroupPermissions = item.GroupPermissions &
173 item.NextPermissions; 173 item.NextPermissions;
174 taskItem.NextPermissions = item.NextPermissions; 174 taskItem.NextPermissions = item.NextPermissions;
175 taskItem.CurrentPermissions |= 8; 175 // We're adding this to a prim we don't own. Force
176 // owner change
177 taskItem.CurrentPermissions |= 16; // Slam
176 } 178 }
177 else 179 else
178 { 180 {
179 taskItem.BasePermissions = item.BasePermissions; 181 taskItem.BasePermissions = item.BasePermissions;
180 taskItem.CurrentPermissions = item.CurrentPermissions; 182 taskItem.CurrentPermissions = item.CurrentPermissions;
181 taskItem.CurrentPermissions |= 8;
182 taskItem.EveryonePermissions = item.EveryOnePermissions; 183 taskItem.EveryonePermissions = item.EveryOnePermissions;
183 taskItem.GroupPermissions = item.GroupPermissions; 184 taskItem.GroupPermissions = item.GroupPermissions;
184 taskItem.NextPermissions = item.NextPermissions; 185 taskItem.NextPermissions = item.NextPermissions;
@@ -281,7 +282,7 @@ namespace OpenSim.Region.Framework.Scenes
281 PermissionMask.Move | 282 PermissionMask.Move |
282 PermissionMask.Transfer) | 7; 283 PermissionMask.Transfer) | 7;
283 284
284 uint ownerMask = 0x7ffffff; 285 uint ownerMask = 0x7fffffff;
285 foreach (SceneObjectPart part in m_parts.Values) 286 foreach (SceneObjectPart part in m_parts.Values)
286 { 287 {
287 ownerMask &= part.OwnerMask; 288 ownerMask &= part.OwnerMask;
@@ -295,12 +296,16 @@ namespace OpenSim.Region.Framework.Scenes
295 if ((ownerMask & (uint)PermissionMask.Transfer) == 0) 296 if ((ownerMask & (uint)PermissionMask.Transfer) == 0)
296 perms &= ~(uint)PermissionMask.Transfer; 297 perms &= ~(uint)PermissionMask.Transfer;
297 298
298 if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Modify) == 0) 299 // If root prim permissions are applied here, this would screw
299 perms &= ~((uint)PermissionMask.Modify >> 13); 300 // with in-inventory manipulation of the next owner perms
300 if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Copy) == 0) 301 // in a major way. So, let's move this to the give itself.
301 perms &= ~((uint)PermissionMask.Copy >> 13); 302 // Yes. I know. Evil.
302 if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Transfer) == 0) 303// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Modify) == 0)
303 perms &= ~((uint)PermissionMask.Transfer >> 13); 304// perms &= ~((uint)PermissionMask.Modify >> 13);
305// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Copy) == 0)
306// perms &= ~((uint)PermissionMask.Copy >> 13);
307// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Transfer) == 0)
308// perms &= ~((uint)PermissionMask.Transfer >> 13);
304 309
305 return perms; 310 return perms;
306 } 311 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 1ca390a..17275d0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -294,7 +294,7 @@ namespace OpenSim.Region.Framework.Scenes
294 294
295 if ((m_scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || m_scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) 295 if ((m_scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || m_scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W)
296 || m_scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || m_scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) 296 || m_scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || m_scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S))
297 && !IsAttachmentCheckFull()) 297 && !IsAttachmentCheckFull() && (!m_scene.LoadingPrims))
298 { 298 {
299 m_scene.CrossPrimGroupIntoNewRegion(val, this, true); 299 m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
300 } 300 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 59fd805..e331bb0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -180,6 +180,9 @@ namespace OpenSim.Region.Framework.Scenes
180 public UUID FromItemID; 180 public UUID FromItemID;
181 181
182 [XmlIgnore] 182 [XmlIgnore]
183 public UUID FromFolderID;
184
185 [XmlIgnore]
183 public int STATUS_ROTATE_X; 186 public int STATUS_ROTATE_X;
184 187
185 [XmlIgnore] 188 [XmlIgnore]
@@ -4137,6 +4140,13 @@ namespace OpenSim.Region.Framework.Scenes
4137 case 16: 4140 case 16:
4138 _nextOwnerMask = ApplyMask(_nextOwnerMask, set, mask) & 4141 _nextOwnerMask = ApplyMask(_nextOwnerMask, set, mask) &
4139 baseMask; 4142 baseMask;
4143 // Prevent the client from creating no mod, no copy
4144 // objects
4145 if ((_nextOwnerMask & (uint)PermissionMask.Copy) == 0)
4146 _nextOwnerMask |= (uint)PermissionMask.Transfer;
4147
4148 _nextOwnerMask |= (uint)PermissionMask.Move;
4149
4140 break; 4150 break;
4141 } 4151 }
4142 SendFullUpdateToAllClients(); 4152 SendFullUpdateToAllClients();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 3a8f168..4ae53a2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -118,20 +118,20 @@ namespace OpenSim.Region.Framework.Scenes
118 /// <param name="linkNum">Link number for the part</param> 118 /// <param name="linkNum">Link number for the part</param>
119 public void ResetInventoryIDs() 119 public void ResetInventoryIDs()
120 { 120 {
121 lock (Items) 121 lock (m_items)
122 { 122 {
123 if (0 == Items.Count) 123 if (0 == m_items.Count)
124 return; 124 return;
125 125
126 HasInventoryChanged = true; 126 HasInventoryChanged = true;
127 m_part.ParentGroup.HasGroupChanged = true; 127 m_part.ParentGroup.HasGroupChanged = true;
128 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 128 IList<TaskInventoryItem> items = GetInventoryItems();
129 Items.Clear(); 129 m_items.Clear();
130 130
131 foreach (TaskInventoryItem item in items) 131 foreach (TaskInventoryItem item in items)
132 { 132 {
133 item.ResetIDs(m_part.UUID); 133 item.ResetIDs(m_part.UUID);
134 Items.Add(item.ItemID, item); 134 m_items.Add(item.ItemID, item);
135 } 135 }
136 } 136 }
137 } 137 }
@@ -148,17 +148,17 @@ namespace OpenSim.Region.Framework.Scenes
148 { 148 {
149 return; 149 return;
150 } 150 }
151 }
151 152
152 HasInventoryChanged = true; 153 HasInventoryChanged = true;
153 m_part.ParentGroup.HasGroupChanged = true; 154 m_part.ParentGroup.HasGroupChanged = true;
154 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 155 List<TaskInventoryItem> items = GetInventoryItems();
155 foreach (TaskInventoryItem item in items) 156 foreach (TaskInventoryItem item in items)
157 {
158 if (ownerId != item.OwnerID)
156 { 159 {
157 if (ownerId != item.OwnerID) 160 item.LastOwnerID = item.OwnerID;
158 { 161 item.OwnerID = ownerId;
159 item.LastOwnerID = item.OwnerID;
160 item.OwnerID = ownerId;
161 }
162 } 162 }
163 } 163 }
164 } 164 }
@@ -175,17 +175,15 @@ namespace OpenSim.Region.Framework.Scenes
175 { 175 {
176 return; 176 return;
177 } 177 }
178 }
178 179
179 HasInventoryChanged = true; 180 HasInventoryChanged = true;
180 m_part.ParentGroup.HasGroupChanged = true; 181 m_part.ParentGroup.HasGroupChanged = true;
181 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 182 List<TaskInventoryItem> items = GetInventoryItems();
182 foreach (TaskInventoryItem item in items) 183 foreach (TaskInventoryItem item in items)
183 { 184 {
184 if (groupID != item.GroupID) 185 if (groupID != item.GroupID)
185 { 186 item.GroupID = groupID;
186 item.GroupID = groupID;
187 }
188 }
189 } 187 }
190 } 188 }
191 189
@@ -194,17 +192,9 @@ namespace OpenSim.Region.Framework.Scenes
194 /// </summary> 192 /// </summary>
195 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) 193 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
196 { 194 {
197 lock (m_items) 195 List<TaskInventoryItem> scripts = GetInventoryScripts();
198 { 196 foreach (TaskInventoryItem item in scripts)
199 foreach (TaskInventoryItem item in Items.Values) 197 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
200 {
201 if ((int)InventoryType.LSL == item.InvType)
202 {
203 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
204 Thread.Sleep(10); // workaround for Mono cpu utilization > 100% bug
205 }
206 }
207 }
208 } 198 }
209 199
210 public ArrayList GetScriptErrors(UUID itemID) 200 public ArrayList GetScriptErrors(UUID itemID)
@@ -237,16 +227,9 @@ namespace OpenSim.Region.Framework.Scenes
237 /// </param> 227 /// </param>
238 public void RemoveScriptInstances(bool sceneObjectBeingDeleted) 228 public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
239 { 229 {
240 lock (Items) 230 List<TaskInventoryItem> scripts = GetInventoryScripts();
241 { 231 foreach (TaskInventoryItem item in scripts)
242 foreach (TaskInventoryItem item in Items.Values) 232 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
243 {
244 if ((int)InventoryType.LSL == item.InvType)
245 {
246 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
247 }
248 }
249 }
250 } 233 }
251 234
252 /// <summary> 235 /// <summary>
@@ -259,7 +242,7 @@ namespace OpenSim.Region.Framework.Scenes
259 // m_log.InfoFormat( 242 // m_log.InfoFormat(
260 // "[PRIM INVENTORY]: " + 243 // "[PRIM INVENTORY]: " +
261 // "Starting script {0}, {1} in prim {2}, {3}", 244 // "Starting script {0}, {1} in prim {2}, {3}",
262 // item.Name, item.ItemID, m_part.Name, m_part.UUID); 245 // item.Name, item.ItemID, Name, UUID);
263 246
264 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 247 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
265 return; 248 return;
@@ -295,20 +278,20 @@ namespace OpenSim.Region.Framework.Scenes
295 } 278 }
296 else 279 else
297 { 280 {
281 if (m_part.ParentGroup.m_savedScriptState != null)
282 RestoreSavedScriptState(item.OldItemID, item.ItemID);
283
298 lock (m_items) 284 lock (m_items)
299 { 285 {
300 if (m_part.ParentGroup.m_savedScriptState != null)
301 RestoreSavedScriptState(item.OldItemID, item.ItemID);
302
303 m_items[item.ItemID].PermsMask = 0; 286 m_items[item.ItemID].PermsMask = 0;
304 m_items[item.ItemID].PermsGranter = UUID.Zero; 287 m_items[item.ItemID].PermsGranter = UUID.Zero;
305
306 string script = Utils.BytesToString(asset.Data);
307 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
308 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
309 m_part.ParentGroup.AddActiveScriptCount(1);
310 m_part.ScheduleFullUpdate();
311 } 288 }
289
290 string script = Utils.BytesToString(asset.Data);
291 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
292 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
293 m_part.ParentGroup.AddActiveScriptCount(1);
294 m_part.ScheduleFullUpdate();
312 } 295 }
313 } 296 }
314 } 297 }
@@ -376,21 +359,15 @@ namespace OpenSim.Region.Framework.Scenes
376 /// </param> 359 /// </param>
377 public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) 360 public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
378 { 361 {
379 lock (m_items) 362 TaskInventoryItem item = GetInventoryItem(itemId);
380 { 363 if (item != null)
381 if (m_items.ContainsKey(itemId)) 364 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
382 { 365 else
383 CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); 366 m_log.ErrorFormat(
384 } 367 "[PRIM INVENTORY]: " +
385 else 368 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
386 { 369 itemId, m_part.Name, m_part.UUID,
387 m_log.ErrorFormat( 370 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
388 "[PRIM INVENTORY]: " +
389 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
390 itemId, m_part.Name, m_part.UUID,
391 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
392 }
393 }
394 } 371 }
395 372
396 /// <summary> 373 /// <summary>
@@ -431,16 +408,18 @@ namespace OpenSim.Region.Framework.Scenes
431 408
432 /// <summary> 409 /// <summary>
433 /// Check if the inventory holds an item with a given name. 410 /// Check if the inventory holds an item with a given name.
434 /// This method assumes that the task inventory is already locked.
435 /// </summary> 411 /// </summary>
436 /// <param name="name"></param> 412 /// <param name="name"></param>
437 /// <returns></returns> 413 /// <returns></returns>
438 private bool InventoryContainsName(string name) 414 private bool InventoryContainsName(string name)
439 { 415 {
440 foreach (TaskInventoryItem item in Items.Values) 416 lock (m_items)
441 { 417 {
442 if (item.Name == name) 418 foreach (TaskInventoryItem item in m_items.Values)
443 return true; 419 {
420 if (item.Name == name)
421 return true;
422 }
444 } 423 }
445 return false; 424 return false;
446 } 425 }
@@ -483,12 +462,7 @@ namespace OpenSim.Region.Framework.Scenes
483 /// <param name="item"></param> 462 /// <param name="item"></param>
484 public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) 463 public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop)
485 { 464 {
486 List<TaskInventoryItem> il; 465 List<TaskInventoryItem> il = GetInventoryItems();
487
488 lock (m_items)
489 {
490 il = new List<TaskInventoryItem>(m_items.Values);
491 }
492 466
493 foreach (TaskInventoryItem i in il) 467 foreach (TaskInventoryItem i in il)
494 { 468 {
@@ -528,14 +502,12 @@ namespace OpenSim.Region.Framework.Scenes
528 item.GroupID = m_part.GroupID; 502 item.GroupID = m_part.GroupID;
529 503
530 lock (m_items) 504 lock (m_items)
531 {
532 m_items.Add(item.ItemID, item); 505 m_items.Add(item.ItemID, item);
533 506
534 if (allowedDrop) 507 if (allowedDrop)
535 m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); 508 m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP);
536 else 509 else
537 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 510 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
538 }
539 511
540 m_inventorySerial++; 512 m_inventorySerial++;
541 //m_inventorySerial += 2; 513 //m_inventorySerial += 2;
@@ -559,9 +531,8 @@ namespace OpenSim.Region.Framework.Scenes
559 m_items.Add(item.ItemID, item); 531 m_items.Add(item.ItemID, item);
560// m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 532// m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
561 } 533 }
534 m_inventorySerial++;
562 } 535 }
563
564 m_inventorySerial++;
565 } 536 }
566 537
567 /// <summary> 538 /// <summary>
@@ -616,45 +587,44 @@ namespace OpenSim.Region.Framework.Scenes
616 587
617 public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) 588 public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents)
618 { 589 {
619 lock(m_items) 590 TaskInventoryItem it = GetInventoryItem(item.ItemID);
591 if (it != null)
620 { 592 {
621 if (m_items.ContainsKey(item.ItemID)) 593 item.ParentID = m_part.UUID;
622 { 594 item.ParentPartID = m_part.UUID;
623 if (m_items.ContainsKey(item.ItemID)) 595 item.Flags = m_items[item.ItemID].Flags;
624 { 596
625 item.ParentID = m_part.UUID; 597 // If group permissions have been set on, check that the groupID is up to date in case it has
626 item.ParentPartID = m_part.UUID; 598 // changed since permissions were last set.
627 item.Flags = m_items[item.ItemID].Flags; 599 if (item.GroupPermissions != (uint)PermissionMask.None)
628 600 item.GroupID = m_part.GroupID;
629 // If group permissions have been set on, check that the groupID is up to date in case it has 601
630 // changed since permissions were last set. 602 if (item.AssetID == UUID.Zero)
631 if (item.GroupPermissions != (uint)PermissionMask.None) 603 item.AssetID = it.AssetID;
632 item.GroupID = m_part.GroupID;
633
634 if (item.AssetID == UUID.Zero)
635 {
636 item.AssetID = m_items[item.ItemID].AssetID;
637 }
638 m_items[item.ItemID] = item;
639 m_inventorySerial++;
640 if (fireScriptEvents)
641 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
642 HasInventoryChanged = true;
643 m_part.ParentGroup.HasGroupChanged = true;
644 return true;
645 }
646 else
647 {
648 m_log.ErrorFormat(
649 "[PRIM INVENTORY]: " +
650 "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
651 item.ItemID, m_part.Name, m_part.UUID,
652 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
653 }
654 604
605 lock (m_items)
606 {
607 m_items[item.ItemID] = item;
608 m_inventorySerial++;
655 } 609 }
656 return false; 610
611 if (fireScriptEvents)
612 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
613
614 HasInventoryChanged = true;
615 m_part.ParentGroup.HasGroupChanged = true;
616 return true;
657 } 617 }
618 else
619 {
620 m_log.ErrorFormat(
621 "[PRIM INVENTORY]: " +
622 "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
623 item.ItemID, m_part.Name, m_part.UUID,
624 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
625 }
626 return false;
627
658 } 628 }
659 629
660 /// <summary> 630 /// <summary>
@@ -665,52 +635,37 @@ namespace OpenSim.Region.Framework.Scenes
665 /// in this prim's inventory.</returns> 635 /// in this prim's inventory.</returns>
666 public int RemoveInventoryItem(UUID itemID) 636 public int RemoveInventoryItem(UUID itemID)
667 { 637 {
668 lock (m_items) 638 TaskInventoryItem item = GetInventoryItem(itemID);
639 if (item != null)
669 { 640 {
670 if (m_items.ContainsKey(itemID)) 641 int type = m_items[itemID].InvType;
642 if (type == 10) // Script
671 { 643 {
672 int type = m_items[itemID].InvType; 644 m_part.RemoveScriptEvents(itemID);
673 if (type == 10) // Script 645 m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID);
674 { 646 }
675 m_part.RemoveScriptEvents(itemID); 647 m_items.Remove(itemID);
676 m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); 648 m_inventorySerial++;
677 } 649 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
678 m_items.Remove(itemID);
679 m_inventorySerial++;
680 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
681
682 HasInventoryChanged = true;
683 m_part.ParentGroup.HasGroupChanged = true;
684 650
685 int scriptcount = 0; 651 HasInventoryChanged = true;
686 lock (m_items) 652 m_part.ParentGroup.HasGroupChanged = true;
687 {
688 foreach (TaskInventoryItem item in m_items.Values)
689 {
690 if (item.Type == 10)
691 {
692 scriptcount++;
693 }
694 }
695 }
696 653
697 if (scriptcount <= 0) 654 if (!ContainsScripts())
698 { 655 m_part.RemFlag(PrimFlags.Scripted);
699 m_part.RemFlag(PrimFlags.Scripted);
700 }
701 656
702 m_part.ScheduleFullUpdate(); 657 m_part.ScheduleFullUpdate();
703 658
704 return type; 659 return type;
705 } 660
706 else 661 }
707 { 662 else
708 m_log.ErrorFormat( 663 {
709 "[PRIM INVENTORY]: " + 664 m_log.ErrorFormat(
710 "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", 665 "[PRIM INVENTORY]: " +
711 itemID, m_part.Name, m_part.UUID, 666 "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
712 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); 667 itemID, m_part.Name, m_part.UUID,
713 } 668 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
714 } 669 }
715 670
716 return -1; 671 return -1;
@@ -764,52 +719,50 @@ namespace OpenSim.Region.Framework.Scenes
764 // isn't available (such as drag from prim inventory to agent inventory) 719 // isn't available (such as drag from prim inventory to agent inventory)
765 InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); 720 InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
766 721
767 lock (m_items) 722 List<TaskInventoryItem> items = GetInventoryItems();
723 foreach (TaskInventoryItem item in items)
768 { 724 {
769 foreach (TaskInventoryItem item in m_items.Values) 725 UUID ownerID = item.OwnerID;
770 { 726 uint everyoneMask = 0;
771 UUID ownerID = item.OwnerID; 727 uint baseMask = item.BasePermissions;
772 uint everyoneMask = 0; 728 uint ownerMask = item.CurrentPermissions;
773 uint baseMask = item.BasePermissions; 729 uint groupMask = item.GroupPermissions;
774 uint ownerMask = item.CurrentPermissions;
775 uint groupMask = item.GroupPermissions;
776 730
777 invString.AddItemStart(); 731 invString.AddItemStart();
778 invString.AddNameValueLine("item_id", item.ItemID.ToString()); 732 invString.AddNameValueLine("item_id", item.ItemID.ToString());
779 invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); 733 invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
780 734
781 invString.AddPermissionsStart(); 735 invString.AddPermissionsStart();
782 736
783 invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); 737 invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
784 invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); 738 invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
785 invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); 739 invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask));
786 invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); 740 invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
787 invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); 741 invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
788 742
789 invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); 743 invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
790 invString.AddNameValueLine("owner_id", ownerID.ToString()); 744 invString.AddNameValueLine("owner_id", ownerID.ToString());
791 745
792 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); 746 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
793 747
794 invString.AddNameValueLine("group_id", item.GroupID.ToString()); 748 invString.AddNameValueLine("group_id", item.GroupID.ToString());
795 invString.AddSectionEnd(); 749 invString.AddSectionEnd();
796 750
797 invString.AddNameValueLine("asset_id", item.AssetID.ToString()); 751 invString.AddNameValueLine("asset_id", item.AssetID.ToString());
798 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); 752 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
799 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); 753 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
800 invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); 754 invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));
801 755
802 invString.AddSaleStart(); 756 invString.AddSaleStart();
803 invString.AddNameValueLine("sale_type", "not"); 757 invString.AddNameValueLine("sale_type", "not");
804 invString.AddNameValueLine("sale_price", "0"); 758 invString.AddNameValueLine("sale_price", "0");
805 invString.AddSectionEnd(); 759 invString.AddSectionEnd();
806 760
807 invString.AddNameValueLine("name", item.Name + "|"); 761 invString.AddNameValueLine("name", item.Name + "|");
808 invString.AddNameValueLine("desc", item.Description + "|"); 762 invString.AddNameValueLine("desc", item.Description + "|");
809 763
810 invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); 764 invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
811 invString.AddSectionEnd(); 765 invString.AddSectionEnd();
812 }
813 } 766 }
814 767
815 fileData = Utils.StringToBytes(invString.BuildString); 768 fileData = Utils.StringToBytes(invString.BuildString);
@@ -831,12 +784,10 @@ namespace OpenSim.Region.Framework.Scenes
831 { 784 {
832 if (HasInventoryChanged) 785 if (HasInventoryChanged)
833 { 786 {
834 lock (Items)
835 {
836 datastore.StorePrimInventory(m_part.UUID, Items.Values);
837 }
838
839 HasInventoryChanged = false; 787 HasInventoryChanged = false;
788 List<TaskInventoryItem> items = GetInventoryItems();
789 datastore.StorePrimInventory(m_part.UUID, items);
790
840 } 791 }
841 } 792 }
842 793
@@ -952,7 +903,6 @@ namespace OpenSim.Region.Framework.Scenes
952 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; 903 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
953 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) 904 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
954 item.CurrentPermissions &= ~(uint)PermissionMask.Modify; 905 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
955 item.CurrentPermissions |= 8;
956 } 906 }
957 item.CurrentPermissions &= item.NextPermissions; 907 item.CurrentPermissions &= item.NextPermissions;
958 item.BasePermissions &= item.NextPermissions; 908 item.BasePermissions &= item.NextPermissions;
@@ -1002,6 +952,30 @@ namespace OpenSim.Region.Framework.Scenes
1002 952
1003 return ret; 953 return ret;
1004 } 954 }
955
956 public List<TaskInventoryItem> GetInventoryItems()
957 {
958 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
959
960 lock (m_items)
961 ret = new List<TaskInventoryItem>(m_items.Values);
962
963 return ret;
964 }
965
966 public List<TaskInventoryItem> GetInventoryScripts()
967 {
968 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
969
970 lock (m_items)
971 {
972 foreach (TaskInventoryItem item in m_items.Values)
973 if (item.InvType == (int)InventoryType.LSL)
974 ret.Add(item);
975 }
976
977 return ret;
978 }
1005 979
1006 public Dictionary<UUID, string> GetScriptStates() 980 public Dictionary<UUID, string> GetScriptStates()
1007 { 981 {
@@ -1011,24 +985,20 @@ namespace OpenSim.Region.Framework.Scenes
1011 if (engines == null) // No engine at all 985 if (engines == null) // No engine at all
1012 return ret; 986 return ret;
1013 987
1014 lock (m_items) 988 List<TaskInventoryItem> scripts = GetInventoryScripts();
989
990 foreach (TaskInventoryItem item in scripts)
1015 { 991 {
1016 foreach (TaskInventoryItem item in m_items.Values) 992 foreach (IScriptModule e in engines)
1017 { 993 {
1018 if (item.InvType == (int)InventoryType.LSL) 994 if (e != null)
1019 { 995 {
1020 foreach (IScriptModule e in engines) 996 string n = e.GetXMLState(item.ItemID);
997 if (n != String.Empty)
1021 { 998 {
1022 if (e != null) 999 if (!ret.ContainsKey(item.ItemID))
1023 { 1000 ret[item.ItemID] = n;
1024 string n = e.GetXMLState(item.ItemID); 1001 break;
1025 if (n != String.Empty)
1026 {
1027 if (!ret.ContainsKey(item.ItemID))
1028 ret[item.ItemID] = n;
1029 break;
1030 }
1031 }
1032 } 1002 }
1033 } 1003 }
1034 } 1004 }
@@ -1043,25 +1013,22 @@ namespace OpenSim.Region.Framework.Scenes
1043 if (engines == null) 1013 if (engines == null)
1044 return; 1014 return;
1045 1015
1046 lock (m_items) 1016 List<TaskInventoryItem> scripts = GetInventoryScripts();
1017
1018 foreach (TaskInventoryItem item in scripts)
1047 { 1019 {
1048 foreach (TaskInventoryItem item in m_items.Values) 1020 foreach (IScriptModule engine in engines)
1049 { 1021 {
1050 if (item.InvType == (int)InventoryType.LSL) 1022 if (engine != null)
1051 { 1023 {
1052 foreach (IScriptModule engine in engines) 1024 if (item.OwnerChanged)
1053 { 1025 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1054 if (engine != null) 1026 item.OwnerChanged = false;
1055 { 1027 engine.ResumeScript(item.ItemID);
1056 if (item.OwnerChanged)
1057 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1058 item.OwnerChanged = false;
1059 engine.ResumeScript(item.ItemID);
1060 }
1061 }
1062 } 1028 }
1063 } 1029 }
1064 } 1030 }
1065 } 1031 }
1032
1066 } 1033 }
1067} 1034}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6c119c2..1e8ce22 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -60,7 +60,6 @@ namespace OpenSim.Region.Framework.Scenes
60 struct ScriptControllers 60 struct ScriptControllers
61 { 61 {
62 public UUID itemID; 62 public UUID itemID;
63 public uint objID;
64 public ScriptControlled ignoreControls; 63 public ScriptControlled ignoreControls;
65 public ScriptControlled eventControls; 64 public ScriptControlled eventControls;
66 } 65 }
@@ -3057,6 +3056,18 @@ namespace OpenSim.Region.Framework.Scenes
3057 cAgent.Attachments = attachs; 3056 cAgent.Attachments = attachs;
3058 } 3057 }
3059 3058
3059 lock (scriptedcontrols)
3060 {
3061 ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
3062 int i = 0;
3063
3064 foreach (ScriptControllers c in scriptedcontrols.Values)
3065 {
3066 controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls);
3067 }
3068 cAgent.Controllers = controls;
3069 }
3070
3060 // Animations 3071 // Animations
3061 try 3072 try
3062 { 3073 {
@@ -3137,6 +3148,27 @@ namespace OpenSim.Region.Framework.Scenes
3137 } 3148 }
3138 catch { } 3149 catch { }
3139 3150
3151 try
3152 {
3153 lock (scriptedcontrols)
3154 {
3155 if (cAgent.Controllers != null)
3156 {
3157 scriptedcontrols.Clear();
3158
3159 foreach (ControllerData c in cAgent.Controllers)
3160 {
3161 ScriptControllers sc = new ScriptControllers();
3162 sc.itemID = c.ItemID;
3163 sc.ignoreControls = (ScriptControlled)c.IgnoreControls;
3164 sc.eventControls = (ScriptControlled)c.EventControls;
3165
3166 scriptedcontrols[sc.itemID] = sc;
3167 }
3168 }
3169 }
3170 }
3171 catch { }
3140 // Animations 3172 // Animations
3141 try 3173 try
3142 { 3174 {
@@ -3468,7 +3500,6 @@ namespace OpenSim.Region.Framework.Scenes
3468 obj.eventControls = ScriptControlled.CONTROL_ZERO; 3500 obj.eventControls = ScriptControlled.CONTROL_ZERO;
3469 3501
3470 obj.itemID = Script_item_UUID; 3502 obj.itemID = Script_item_UUID;
3471 obj.objID = Obj_localID;
3472 if (pass_on == 0 && accept == 0) 3503 if (pass_on == 0 && accept == 0)
3473 { 3504 {
3474 IgnoredControls |= (ScriptControlled)controls; 3505 IgnoredControls |= (ScriptControlled)controls;
@@ -3611,7 +3642,7 @@ namespace OpenSim.Region.Framework.Scenes
3611 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) 3642 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO)
3612 { 3643 {
3613 // only send if still pressed or just changed 3644 // only send if still pressed or just changed
3614 m_scene.EventManager.TriggerControlEvent(scriptControlData.objID, scriptUUID, UUID, (uint)localHeld, (uint)localChange); 3645 m_scene.EventManager.TriggerControlEvent(scriptUUID, UUID, (uint)localHeld, (uint)localChange);
3615 } 3646 }
3616 } 3647 }
3617 } 3648 }
diff --git a/OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs
deleted file mode 100644
index 38a9203..0000000
--- a/OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs
+++ /dev/null
@@ -1,269 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenSim.Region.Framework.Scenes;
31
32namespace OpenSim.Region.Framework.Scenes.Types
33{
34 public class BasicQuadTreeNode
35 {
36 private List<SceneObjectGroup> m_objects = new List<SceneObjectGroup>();
37 private BasicQuadTreeNode[] m_childNodes = null;
38 private BasicQuadTreeNode m_parent = null;
39
40 private short m_leftX;
41 private short m_leftY;
42 private short m_width;
43 private short m_height;
44 //private int m_quadNumber;
45 private string m_quadID;
46
47 public BasicQuadTreeNode(BasicQuadTreeNode parent, string quadID, short leftX, short leftY, short width,
48 short height)
49 {
50 m_parent = parent;
51 m_quadID = quadID;
52 m_leftX = leftX;
53 m_leftY = leftY;
54 m_width = width;
55 m_height = height;
56 // m_log.Debug("creating quadtree node " + m_quadID);
57 }
58
59 public void AddObject(SceneObjectGroup obj)
60 {
61 if (m_childNodes == null)
62 {
63 if (!m_objects.Contains(obj))
64 {
65 m_objects.Add(obj);
66 }
67 }
68 else
69 {
70 if (obj.AbsolutePosition.X < (m_leftX + (m_width/2)))
71 {
72 if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2)))
73 {
74 m_childNodes[0].AddObject(obj);
75 }
76 else
77 {
78 m_childNodes[2].AddObject(obj);
79 }
80 }
81 else
82 {
83 if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2)))
84 {
85 m_childNodes[1].AddObject(obj);
86 }
87 else
88 {
89 m_childNodes[3].AddObject(obj);
90 }
91 }
92 }
93 }
94
95 public void Subdivide()
96 {
97 if (m_childNodes == null)
98 {
99 m_childNodes = new BasicQuadTreeNode[4];
100 m_childNodes[0] =
101 new BasicQuadTreeNode(this, m_quadID + "1/", m_leftX, m_leftY, (short) (m_width/2),
102 (short) (m_height/2));
103 m_childNodes[1] =
104 new BasicQuadTreeNode(this, m_quadID + "2/", (short) (m_leftX + (m_width/2)), m_leftY,
105 (short) (m_width/2), (short) (m_height/2));
106 m_childNodes[2] =
107 new BasicQuadTreeNode(this, m_quadID + "3/", m_leftX, (short) (m_leftY + (m_height/2)),
108 (short) (m_width/2), (short) (m_height/2));
109 m_childNodes[3] =
110 new BasicQuadTreeNode(this, m_quadID + "4/", (short) (m_leftX + (m_width/2)),
111 (short) (m_height + (m_height/2)), (short) (m_width/2), (short) (m_height/2));
112 }
113 else
114 {
115 for (int i = 0; i < m_childNodes.Length; i++)
116 {
117 m_childNodes[i].Subdivide();
118 }
119 }
120 }
121
122 public List<SceneObjectGroup> GetObjectsFrom(float x, float y)
123 {
124 if (m_childNodes == null)
125 {
126 return new List<SceneObjectGroup>(m_objects);
127 }
128 else
129 {
130 if (x < m_leftX + (m_width/2))
131 {
132 if (y < m_leftY + (m_height/2))
133 {
134 return m_childNodes[0].GetObjectsFrom(x, y);
135 }
136 else
137 {
138 return m_childNodes[2].GetObjectsFrom(x, y);
139 }
140 }
141 else
142 {
143 if (y < m_leftY + (m_height/2))
144 {
145 return m_childNodes[1].GetObjectsFrom(x, y);
146 }
147 else
148 {
149 return m_childNodes[3].GetObjectsFrom(x, y);
150 }
151 }
152 }
153 }
154
155 public List<SceneObjectGroup> GetObjectsFrom(string nodeName)
156 {
157 if (nodeName == m_quadID)
158 {
159 return new List<SceneObjectGroup>(m_objects);
160 }
161 else if (m_childNodes != null)
162 {
163 for (int i = 0; i < 4; i++)
164 {
165 List<SceneObjectGroup> retVal;
166 retVal = m_childNodes[i].GetObjectsFrom(nodeName);
167 if (retVal != null)
168 {
169 return retVal;
170 }
171 }
172 }
173 return null;
174 }
175
176 public string GetNodeID(float x, float y)
177 {
178 if (m_childNodes == null)
179 {
180 return m_quadID;
181 }
182 else
183 {
184 if (x < m_leftX + (m_width/2))
185 {
186 if (y < m_leftY + (m_height/2))
187 {
188 return m_childNodes[0].GetNodeID(x, y);
189 }
190 else
191 {
192 return m_childNodes[2].GetNodeID(x, y);
193 }
194 }
195 else
196 {
197 if (y < m_leftY + (m_height/2))
198 {
199 return m_childNodes[1].GetNodeID(x, y);
200 }
201 else
202 {
203 return m_childNodes[3].GetNodeID(x, y);
204 }
205 }
206 }
207 }
208
209 public void Update()
210 {
211 if (m_childNodes != null)
212 {
213 for (int i = 0; i < 4; i++)
214 {
215 m_childNodes[i].Update();
216 }
217 }
218 else
219 {
220 List<SceneObjectGroup> outBounds = new List<SceneObjectGroup>();
221 foreach (SceneObjectGroup group in m_objects)
222 {
223 if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) &&
224 ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height))))
225 {
226 //still in bounds
227 }
228 else
229 {
230 outBounds.Add(group);
231 }
232 }
233
234 foreach (SceneObjectGroup removee in outBounds)
235 {
236 m_objects.Remove(removee);
237 if (m_parent != null)
238 {
239 m_parent.PassUp(removee);
240 }
241 }
242 outBounds.Clear();
243 }
244 }
245
246 public void PassUp(SceneObjectGroup group)
247 {
248 if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) &&
249 ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height))))
250 {
251 AddObject(group);
252 }
253 else
254 {
255 if (m_parent != null)
256 {
257 m_parent.PassUp(group);
258 }
259 }
260 }
261
262 public string[] GetNeighbours(string nodeName)
263 {
264 string[] retVal = new string[1];
265 retVal[0] = String.Empty;
266 return retVal;
267 }
268 }
269}