aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs514
1 files changed, 426 insertions, 88 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index b838177..e289666 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -106,12 +106,12 @@ namespace OpenSim.Region.Framework.Scenes
106 engine.StartProcessing(); 106 engine.StartProcessing();
107 } 107 }
108 108
109 public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) 109 public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item, uint cost)
110 { 110 {
111 IMoneyModule money = RequestModuleInterface<IMoneyModule>(); 111 IMoneyModule money = RequestModuleInterface<IMoneyModule>();
112 if (money != null) 112 if (money != null)
113 { 113 {
114 money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload"); 114 money.ApplyUploadCharge(agentID, (int)cost, "Asset upload");
115 } 115 }
116 116
117 AddInventoryItem(item); 117 AddInventoryItem(item);
@@ -182,7 +182,7 @@ namespace OpenSim.Region.Framework.Scenes
182 return false; 182 return false;
183 } 183 }
184 } 184 }
185 185
186 if (InventoryService.AddItem(item)) 186 if (InventoryService.AddItem(item))
187 { 187 {
188 int userlevel = 0; 188 int userlevel = 0;
@@ -338,8 +338,7 @@ namespace OpenSim.Region.Framework.Scenes
338 338
339 // Update item with new asset 339 // Update item with new asset
340 item.AssetID = asset.FullID; 340 item.AssetID = asset.FullID;
341 if (group.UpdateInventoryItem(item)) 341 group.UpdateInventoryItem(item);
342 remoteClient.SendAlertMessage("Script saved");
343 342
344 part.SendPropertiesToClient(remoteClient); 343 part.SendPropertiesToClient(remoteClient);
345 344
@@ -350,12 +349,7 @@ namespace OpenSim.Region.Framework.Scenes
350 { 349 {
351 // Needs to determine which engine was running it and use that 350 // Needs to determine which engine was running it and use that
352 // 351 //
353 part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); 352 errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 1);
354 errors = part.Inventory.GetScriptErrors(item.ItemID);
355 }
356 else
357 {
358 remoteClient.SendAlertMessage("Script saved");
359 } 353 }
360 354
361 // Tell anyone managing scripts that a script has been reloaded/changed 355 // Tell anyone managing scripts that a script has been reloaded/changed
@@ -421,6 +415,7 @@ namespace OpenSim.Region.Framework.Scenes
421 if (item.Owner != remoteClient.AgentId) 415 if (item.Owner != remoteClient.AgentId)
422 return; 416 return;
423 417
418 item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255);
424 item.Name = itemUpd.Name; 419 item.Name = itemUpd.Name;
425 item.Description = itemUpd.Description; 420 item.Description = itemUpd.Description;
426 421
@@ -886,8 +881,14 @@ namespace OpenSim.Region.Framework.Scenes
886 return; 881 return;
887 } 882 }
888 883
884<<<<<<< HEAD
889 if (newName == String.Empty) 885 if (newName == String.Empty)
890 newName = item.Name; 886 newName = item.Name;
887=======
888 if (newName == null) newName = item.Name;
889
890 AssetBase asset = AssetService.Get(item.AssetID.ToString());
891>>>>>>> avn/ubitvar
891 892
892 if (remoteClient.AgentId == oldAgentID 893 if (remoteClient.AgentId == oldAgentID
893 || (LibraryService != null 894 || (LibraryService != null
@@ -929,6 +930,24 @@ namespace OpenSim.Region.Framework.Scenes
929 } 930 }
930 931
931 /// <summary> 932 /// <summary>
933 /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit)
934 /// </summary>
935 public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder)
936 {
937 List<InventoryItemBase> moveitems = new List<InventoryItemBase>();
938 foreach (InventoryItemBase b in items)
939 {
940 CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null);
941 InventoryItemBase n = InventoryService.GetItem(b);
942 n.Folder = destfolder;
943 moveitems.Add(n);
944 remoteClient.SendInventoryItemCreateUpdate(n, 0);
945 }
946
947 MoveInventoryItem(remoteClient, moveitems);
948 }
949
950 /// <summary>
932 /// Move an item within the agent's inventory. 951 /// Move an item within the agent's inventory.
933 /// </summary> 952 /// </summary>
934 /// <param name="remoteClient"></param> 953 /// <param name="remoteClient"></param>
@@ -963,12 +982,31 @@ namespace OpenSim.Region.Framework.Scenes
963 public void CreateNewInventoryItem( 982 public void CreateNewInventoryItem(
964 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, 983 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID,
965 string name, string description, uint flags, uint callbackID, 984 string name, string description, uint flags, uint callbackID,
985<<<<<<< HEAD
966 UUID assetID, sbyte assetType, sbyte invType, uint nextOwnerMask, int creationDate) 986 UUID assetID, sbyte assetType, sbyte invType, uint nextOwnerMask, int creationDate)
967 { 987 {
968 CreateNewInventoryItem( 988 CreateNewInventoryItem(
969 remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, assetID, assetType, invType, 989 remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, assetID, assetType, invType,
970 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, 990 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0,
971 creationDate, true); 991 creationDate, true);
992=======
993 AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate, UUID transationID)
994 {
995 CreateNewInventoryItem(
996 remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType,
997 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate, transationID);
998 }
999
1000
1001 private void CreateNewInventoryItem(
1002 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID,
1003 string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType,
1004 uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate)
1005 {
1006 CreateNewInventoryItem(remoteClient, creatorID, creatorData, folderID,
1007 name, description, flags, callbackID, asset, invType,
1008 baseMask, currentMask, everyoneMask, nextOwnerMask, groupMask, creationDate, UUID.Zero);
1009>>>>>>> avn/ubitvar
972 } 1010 }
973 1011
974 /// <summary> 1012 /// <summary>
@@ -992,9 +1030,14 @@ namespace OpenSim.Region.Framework.Scenes
992 /// <param name="creationDate">Unix timestamp at which this item was created.</param> 1030 /// <param name="creationDate">Unix timestamp at which this item was created.</param>
993 private void CreateNewInventoryItem( 1031 private void CreateNewInventoryItem(
994 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, 1032 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID,
1033<<<<<<< HEAD
995 string name, string description, uint flags, uint callbackID, UUID assetID, sbyte assetType, sbyte invType, 1034 string name, string description, uint flags, uint callbackID, UUID assetID, sbyte assetType, sbyte invType,
996 uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate, 1035 uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate,
997 bool assetUpload) 1036 bool assetUpload)
1037=======
1038 string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType,
1039 uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate,UUID transationID)
1040>>>>>>> avn/ubitvar
998 { 1041 {
999 InventoryItemBase item = new InventoryItemBase(); 1042 InventoryItemBase item = new InventoryItemBase();
1000 item.Owner = remoteClient.AgentId; 1043 item.Owner = remoteClient.AgentId;
@@ -1015,9 +1058,17 @@ namespace OpenSim.Region.Framework.Scenes
1015 item.BasePermissions = baseMask; 1058 item.BasePermissions = baseMask;
1016 item.CreationDate = creationDate; 1059 item.CreationDate = creationDate;
1017 1060
1061<<<<<<< HEAD
1018 if (AddInventoryItem(item, assetUpload)) 1062 if (AddInventoryItem(item, assetUpload))
1063=======
1064 // special AnimationSet case
1065 if (item.InvType == (int)CustomInventoryType.AnimationSet)
1066 AnimationSet.enforceItemPermitions(item,true);
1067
1068 if (AddInventoryItem(item))
1069>>>>>>> avn/ubitvar
1019 { 1070 {
1020 remoteClient.SendInventoryItemCreateUpdate(item, callbackID); 1071 remoteClient.SendInventoryItemCreateUpdate(item, transationID, callbackID);
1021 } 1072 }
1022 else 1073 else
1023 { 1074 {
@@ -1233,6 +1284,7 @@ namespace OpenSim.Region.Framework.Scenes
1233 agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); 1284 agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
1234 if (taskItem.InvType == (int)InventoryType.Object) 1285 if (taskItem.InvType == (int)InventoryType.Object)
1235 { 1286 {
1287<<<<<<< HEAD
1236 // Bake the new base permissions from folded permissions 1288 // Bake the new base permissions from folded permissions
1237 // The folded perms are in the lowest 3 bits of the current perms 1289 // The folded perms are in the lowest 3 bits of the current perms
1238 // We use base permissions here to avoid baking the "Locked" status 1290 // We use base permissions here to avoid baking the "Locked" status
@@ -1244,6 +1296,13 @@ namespace OpenSim.Region.Framework.Scenes
1244 agentItem.BasePermissions = perms | (uint)PermissionMask.Move; 1296 agentItem.BasePermissions = perms | (uint)PermissionMask.Move;
1245 // Newly given items cannot be "locked" on rez. Make sure by 1297 // Newly given items cannot be "locked" on rez. Make sure by
1246 // setting current equal to base. 1298 // setting current equal to base.
1299=======
1300 uint perms = taskItem.BasePermissions & taskItem.NextPermissions;
1301 PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms);
1302// agentItem.BasePermissions = perms | (uint)PermissionMask.Move;
1303// agentItem.CurrentPermissions = agentItem.BasePermissions;
1304 agentItem.BasePermissions = perms | (uint)PermissionMask.Move;
1305>>>>>>> avn/ubitvar
1247 } 1306 }
1248 1307
1249 agentItem.CurrentPermissions = agentItem.BasePermissions; 1308 agentItem.CurrentPermissions = agentItem.BasePermissions;
@@ -1327,6 +1386,10 @@ namespace OpenSim.Region.Framework.Scenes
1327 { 1386 {
1328 SceneObjectPart part = GetSceneObjectPart(primLocalId); 1387 SceneObjectPart part = GetSceneObjectPart(primLocalId);
1329 1388
1389 // Can't move a null item
1390 if (itemId == UUID.Zero)
1391 return;
1392
1330 if (null == part) 1393 if (null == part)
1331 { 1394 {
1332 m_log.WarnFormat( 1395 m_log.WarnFormat(
@@ -1437,21 +1500,28 @@ namespace OpenSim.Region.Framework.Scenes
1437 return; 1500 return;
1438 } 1501 }
1439 1502
1440 if (part.OwnerID != destPart.OwnerID) 1503 // Can't transfer this
1504 //
1505 if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
1506 return;
1507
1508 bool overrideNoMod = false;
1509 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1510 overrideNoMod = true;
1511
1512 if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1441 { 1513 {
1442 // Source must have transfer permissions 1514 // object cannot copy items to an object owned by a different owner
1443 if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) 1515 // unless llAllowInventoryDrop has been called
1444 return;
1445 1516
1446 // Object cannot copy items to an object owned by a different owner 1517 return;
1447 // unless llAllowInventoryDrop has been called on the destination
1448 if ((destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1449 return;
1450 } 1518 }
1451 1519
1452 // must have both move and modify permission to put an item in an object 1520 // must have both move and modify permission to put an item in an object
1453 if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) 1521 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1522 {
1454 return; 1523 return;
1524 }
1455 1525
1456 TaskInventoryItem destTaskItem = new TaskInventoryItem(); 1526 TaskInventoryItem destTaskItem = new TaskInventoryItem();
1457 1527
@@ -1507,10 +1577,20 @@ namespace OpenSim.Region.Framework.Scenes
1507 1577
1508 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) 1578 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items)
1509 { 1579 {
1580<<<<<<< HEAD
1510 ScenePresence avatar; 1581 ScenePresence avatar;
1511 IClientAPI remoteClient = null; 1582 IClientAPI remoteClient = null;
1512 if (TryGetScenePresence(destID, out avatar)) 1583 if (TryGetScenePresence(destID, out avatar))
1513 remoteClient = avatar.ControllingClient; 1584 remoteClient = avatar.ControllingClient;
1585=======
1586 SceneObjectPart destPart = GetSceneObjectPart(destID);
1587 if (destPart != null) // Move into a prim
1588 {
1589 foreach(UUID itemID in items)
1590 MoveTaskInventoryItem(destID, host, itemID);
1591 return destID; // Prim folder ID == prim ID
1592 }
1593>>>>>>> avn/ubitvar
1514 1594
1515 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); 1595 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID);
1516 1596
@@ -1696,12 +1776,12 @@ namespace OpenSim.Region.Framework.Scenes
1696 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( 1776 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction(
1697 remoteClient, part, transactionID, currentItem); 1777 remoteClient, part, transactionID, currentItem);
1698 1778
1699 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) 1779// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1700 remoteClient.SendAlertMessage("Notecard saved"); 1780// remoteClient.SendAgentAlertMessage("Notecard saved", false);
1701 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) 1781// else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1702 remoteClient.SendAlertMessage("Script saved"); 1782// remoteClient.SendAgentAlertMessage("Script saved", false);
1703 else 1783// else
1704 remoteClient.SendAlertMessage("Item saved"); 1784// remoteClient.SendAgentAlertMessage("Item saved", false);
1705 } 1785 }
1706 1786
1707 // Base ALWAYS has move 1787 // Base ALWAYS has move
@@ -2075,23 +2155,32 @@ namespace OpenSim.Region.Framework.Scenes
2075 // build a list of eligible objects 2155 // build a list of eligible objects
2076 List<uint> deleteIDs = new List<uint>(); 2156 List<uint> deleteIDs = new List<uint>();
2077 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 2157 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
2078 2158 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
2079 // Start with true for both, then remove the flags if objects
2080 // that we can't derez are part of the selection
2081 bool permissionToTake = true;
2082 bool permissionToTakeCopy = true;
2083 bool permissionToDelete = true;
2084 2159
2085 foreach (uint localID in localIDs) 2160 foreach (uint localID in localIDs)
2086 { 2161 {
2162 // Start with true for both, then remove the flags if objects
2163 // that we can't derez are part of the selection
2164 bool permissionToTake = true;
2165 bool permissionToTakeCopy = true;
2166 bool permissionToDelete = true;
2167
2087 // Invalid id 2168 // Invalid id
2088 SceneObjectPart part = GetSceneObjectPart(localID); 2169 SceneObjectPart part = GetSceneObjectPart(localID);
2089 if (part == null) 2170 if (part == null)
2171 {
2172 //Client still thinks the object exists, kill it
2173 deleteIDs.Add(localID);
2090 continue; 2174 continue;
2175 }
2091 2176
2092 // Already deleted by someone else 2177 // Already deleted by someone else
2093 if (part.ParentGroup.IsDeleted) 2178 if (part.ParentGroup.IsDeleted)
2179 {
2180 //Client still thinks the object exists, kill it
2181 deleteIDs.Add(localID);
2094 continue; 2182 continue;
2183 }
2095 2184
2096 // Can't delete child prims 2185 // Can't delete child prims
2097 if (part != part.ParentGroup.RootPart) 2186 if (part != part.ParentGroup.RootPart)
@@ -2099,9 +2188,6 @@ namespace OpenSim.Region.Framework.Scenes
2099 2188
2100 SceneObjectGroup grp = part.ParentGroup; 2189 SceneObjectGroup grp = part.ParentGroup;
2101 2190
2102 deleteIDs.Add(localID);
2103 deleteGroups.Add(grp);
2104
2105 // If child prims have invalid perms, fix them 2191 // If child prims have invalid perms, fix them
2106 grp.AdjustChildPrimPermissions(false); 2192 grp.AdjustChildPrimPermissions(false);
2107 2193
@@ -2121,89 +2207,206 @@ namespace OpenSim.Region.Framework.Scenes
2121 } 2207 }
2122 else 2208 else
2123 { 2209 {
2124 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 2210 if (action == DeRezAction.TakeCopy)
2211 {
2212 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
2213 permissionToTakeCopy = false;
2214 }
2215 else
2216 {
2125 permissionToTakeCopy = false; 2217 permissionToTakeCopy = false;
2126 2218 }
2127 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 2219 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
2128 permissionToTake = false; 2220 permissionToTake = false;
2129 2221
2130 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 2222 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
2131 permissionToDelete = false; 2223 permissionToDelete = false;
2132 } 2224 }
2133 }
2134
2135 // Handle god perms
2136 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
2137 {
2138 permissionToTake = true;
2139 permissionToTakeCopy = true;
2140 permissionToDelete = true;
2141 }
2142
2143 // If we're re-saving, we don't even want to delete
2144 if (action == DeRezAction.SaveToExistingUserInventoryItem)
2145 permissionToDelete = false;
2146 2225
2147 // if we want to take a copy, we also don't want to delete 2226 // Handle god perms
2148 // Note: after this point, the permissionToTakeCopy flag 2227 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
2149 // becomes irrelevant. It already includes the permissionToTake
2150 // permission and after excluding no copy items here, we can
2151 // just use that.
2152 if (action == DeRezAction.TakeCopy)
2153 {
2154 // If we don't have permission, stop right here
2155 if (!permissionToTakeCopy)
2156 { 2228 {
2157 remoteClient.SendAlertMessage("You don't have permission to take the object"); 2229 permissionToTake = true;
2158 return; 2230 permissionToTakeCopy = true;
2231 permissionToDelete = true;
2159 } 2232 }
2160 2233
2161 permissionToTake = true; 2234 // If we're re-saving, we don't even want to delete
2162 // Don't delete 2235 if (action == DeRezAction.SaveToExistingUserInventoryItem)
2163 permissionToDelete = false; 2236 permissionToDelete = false;
2164 }
2165 2237
2166 if (action == DeRezAction.Return) 2238 // if we want to take a copy, we also don't want to delete
2167 { 2239 // Note: after this point, the permissionToTakeCopy flag
2168 if (remoteClient != null) 2240 // becomes irrelevant. It already includes the permissionToTake
2241 // permission and after excluding no copy items here, we can
2242 // just use that.
2243 if (action == DeRezAction.TakeCopy)
2169 { 2244 {
2170 if (Permissions.CanReturnObjects( 2245 // If we don't have permission, stop right here
2171 null, 2246 if (!permissionToTakeCopy)
2172 remoteClient.AgentId,
2173 deleteGroups))
2174 { 2247 {
2175 permissionToTake = true; 2248 remoteClient.SendAlertMessage("You don't have permission to take the object");
2176 permissionToDelete = true; 2249 return;
2250 }
2251
2252 permissionToTake = true;
2253 // Don't delete
2254 permissionToDelete = false;
2255 }
2177 2256
2178 foreach (SceneObjectGroup g in deleteGroups) 2257 if (action == DeRezAction.Return)
2258 {
2259 if (remoteClient != null)
2260 {
2261 if (Permissions.CanReturnObjects(
2262 null,
2263 remoteClient.AgentId,
2264 new List<SceneObjectGroup>() {grp}))
2179 { 2265 {
2180 AddReturn(g.OwnerID == g.GroupID ? g.LastOwnerID : g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 2266 permissionToTake = true;
2267 permissionToDelete = true;
2268
2269 AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
2181 } 2270 }
2182 } 2271 }
2272 else // Auto return passes through here with null agent
2273 {
2274 permissionToTake = true;
2275 permissionToDelete = true;
2276 }
2183 } 2277 }
2184 else // Auto return passes through here with null agent 2278
2279 if (permissionToTake && (!permissionToDelete))
2280 takeGroups.Add(grp);
2281
2282 if (permissionToDelete)
2185 { 2283 {
2186 permissionToTake = true; 2284 if (permissionToTake)
2187 permissionToDelete = true; 2285 deleteGroups.Add(grp);
2286 deleteIDs.Add(grp.LocalId);
2188 } 2287 }
2189 } 2288 }
2190 2289
2290<<<<<<< HEAD
2191 // OK, we're done with permissions. Let's check if any part of the code prevents the objects from being deleted 2291 // OK, we're done with permissions. Let's check if any part of the code prevents the objects from being deleted
2192 bool canDelete = EventManager.TriggerDeRezRequested(remoteClient, deleteGroups, action); 2292 bool canDelete = EventManager.TriggerDeRezRequested(remoteClient, deleteGroups, action);
2193 2293
2194 if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) 2294 if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete))
2295=======
2296 SendKillObject(deleteIDs);
2297
2298 if (deleteGroups.Count > 0)
2299>>>>>>> avn/ubitvar
2195 { 2300 {
2301 foreach (SceneObjectGroup g in deleteGroups)
2302 deleteIDs.Remove(g.LocalId);
2303
2196 m_asyncSceneObjectDeleter.DeleteToInventory( 2304 m_asyncSceneObjectDeleter.DeleteToInventory(
2197 action, destinationID, deleteGroups, remoteClient, 2305 action, destinationID, deleteGroups, remoteClient,
2306<<<<<<< HEAD
2198 permissionToDelete && canDelete); 2307 permissionToDelete && canDelete);
2199 } 2308 }
2200 else if (permissionToDelete && canDelete) 2309 else if (permissionToDelete && canDelete)
2310=======
2311 true);
2312 }
2313 if (takeGroups.Count > 0)
2314 {
2315 m_asyncSceneObjectDeleter.DeleteToInventory(
2316 action, destinationID, takeGroups, remoteClient,
2317 false);
2318 }
2319 if (deleteIDs.Count > 0)
2320>>>>>>> avn/ubitvar
2201 { 2321 {
2202 foreach (SceneObjectGroup g in deleteGroups) 2322 foreach (SceneObjectGroup g in deleteGroups)
2203 DeleteSceneObject(g, false); 2323 DeleteSceneObject(g, true);
2204 } 2324 }
2205 } 2325 }
2206 2326
2327 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
2328 {
2329 itemID = UUID.Zero;
2330 if (grp != null)
2331 {
2332 Vector3 inventoryStoredPosition = new Vector3(
2333 Math.Min(grp.AbsolutePosition.X, RegionInfo.RegionSizeX - 6),
2334 Math.Min(grp.AbsolutePosition.Y, RegionInfo.RegionSizeY - 6),
2335 grp.AbsolutePosition.Z);
2336
2337 Vector3 originalPosition = grp.AbsolutePosition;
2338
2339 grp.AbsolutePosition = inventoryStoredPosition;
2340
2341 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
2342
2343 grp.AbsolutePosition = originalPosition;
2344
2345 AssetBase asset = CreateAsset(
2346 grp.GetPartName(grp.LocalId),
2347 grp.GetPartDescription(grp.LocalId),
2348 (sbyte)AssetType.Object,
2349 Utils.StringToBytes(sceneObjectXml),
2350 remoteClient.AgentId);
2351 AssetService.Store(asset);
2352
2353 InventoryItemBase item = new InventoryItemBase();
2354 item.CreatorId = grp.RootPart.CreatorID.ToString();
2355 item.CreatorData = grp.RootPart.CreatorData;
2356 item.Owner = remoteClient.AgentId;
2357 item.ID = UUID.Random();
2358 item.AssetID = asset.FullID;
2359 item.Description = asset.Description;
2360 item.Name = asset.Name;
2361 item.AssetType = asset.Type;
2362 item.InvType = (int)InventoryType.Object;
2363
2364 InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
2365 if (folder != null)
2366 item.Folder = folder.ID;
2367 else // oopsies
2368 item.Folder = UUID.Zero;
2369
2370 // Set up base perms properly
2371 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
2372 permsBase &= grp.RootPart.BaseMask;
2373 permsBase |= (uint)PermissionMask.Move;
2374
2375 // Make sure we don't lock it
2376 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
2377
2378 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
2379 {
2380 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
2381 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
2382 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2383 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
2384 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
2385 }
2386 else
2387 {
2388 item.BasePermissions = permsBase;
2389 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
2390 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2391 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
2392 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
2393 }
2394 item.CreationDate = Util.UnixTimeSinceEpoch();
2395
2396 // sets itemID so client can show item as 'attached' in inventory
2397 grp.FromItemID = item.ID;
2398
2399 if (AddInventoryItem(item))
2400 remoteClient.SendInventoryItemCreateUpdate(item, 0);
2401 else
2402 m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
2403
2404 itemID = item.ID;
2405 return item.AssetID;
2406 }
2407 return UUID.Zero;
2408 }
2409
2207 /// <summary> 2410 /// <summary>
2208 /// Returns the list of Scene Objects in an asset. 2411 /// Returns the list of Scene Objects in an asset.
2209 /// </summary> 2412 /// </summary>
@@ -2232,10 +2435,34 @@ namespace OpenSim.Region.Framework.Scenes
2232 2435
2233 string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(assetData)); 2436 string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(assetData));
2234 2437
2438<<<<<<< HEAD
2235 try 2439 try
2440=======
2441 if (e == null || attachment) // Single
2442 {
2443 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
2444/*
2445 if (!attachment)
2446 {
2447 g.RootPart.AttachPoint = g.RootPart.Shape.State;
2448 g.RootPart.AttachedPos = g.AbsolutePosition;
2449 g.RootPart.AttachRotation = g.GroupRotation;
2450 if (g.RootPart.Shape.PCode != (byte)PCode.NewTree &&
2451 g.RootPart.Shape.PCode != (byte)PCode.Tree)
2452 g.RootPart.Shape.State = 0;
2453 }
2454*/
2455 objlist.Add(g);
2456 veclist.Add(new Vector3(0, 0, 0));
2457 bbox = g.GetAxisAlignedBoundingBox(out offsetHeight);
2458 return true;
2459 }
2460 else
2461>>>>>>> avn/ubitvar
2236 { 2462 {
2237 using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) 2463 using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null))
2238 { 2464 {
2465<<<<<<< HEAD
2239 using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment })) 2466 using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment }))
2240 { 2467 {
2241 reader.Read(); 2468 reader.Read();
@@ -2299,6 +2526,28 @@ namespace OpenSim.Region.Framework.Scenes
2299 return false; 2526 return false;
2300 } 2527 }
2301 } 2528 }
2529=======
2530 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml);
2531/*
2532 g.RootPart.AttachPoint = g.RootPart.Shape.State;
2533 g.RootPart.AttachedPos = g.AbsolutePosition;
2534 g.RootPart.AttachRotation = g.GroupRotation;
2535 if (g.RootPart.Shape.PCode != (byte)PCode.NewTree &&
2536 g.RootPart.Shape.PCode != (byte)PCode.Tree)
2537 g.RootPart.Shape.State = 0;
2538*/
2539 objlist.Add(g);
2540
2541 XmlElement el = (XmlElement)n;
2542 string rawX = el.GetAttribute("offsetx");
2543 string rawY = el.GetAttribute("offsety");
2544 string rawZ = el.GetAttribute("offsetz");
2545
2546 float x = Convert.ToSingle(rawX);
2547 float y = Convert.ToSingle(rawY);
2548 float z = Convert.ToSingle(rawZ);
2549 veclist.Add(new Vector3(x, y, z));
2550>>>>>>> avn/ubitvar
2302 } 2551 }
2303 } 2552 }
2304 catch (Exception e) 2553 catch (Exception e)
@@ -2371,7 +2620,7 @@ namespace OpenSim.Region.Framework.Scenes
2371 RayStart, RayEnd, RayTargetID, Quaternion.Identity, 2620 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2372 BypassRayCast, bRayEndIsIntersection, true, scale, false); 2621 BypassRayCast, bRayEndIsIntersection, true, scale, false);
2373 2622
2374 RezObject(part, item, pos, null, Vector3.Zero, 0); 2623 RezObject(part, item, pos, null, Vector3.Zero, 0, false);
2375 } 2624 }
2376 } 2625 }
2377 2626
@@ -2387,15 +2636,18 @@ namespace OpenSim.Region.Framework.Scenes
2387 /// <param name="param"></param> 2636 /// <param name="param"></param>
2388 /// <returns>The SceneObjectGroup(s) rezzed, or null if rez was unsuccessful</returns> 2637 /// <returns>The SceneObjectGroup(s) rezzed, or null if rez was unsuccessful</returns>
2389 public virtual List<SceneObjectGroup> RezObject( 2638 public virtual List<SceneObjectGroup> RezObject(
2390 SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param) 2639 SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param, bool atRoot)
2391 { 2640 {
2392 if (null == item) 2641 if (null == item)
2393 return null; 2642 return null;
2394 2643
2395 List<SceneObjectGroup> objlist; 2644 List<SceneObjectGroup> objlist;
2396 List<Vector3> veclist; 2645 List<Vector3> veclist;
2397 2646 Vector3 bbox;
2398 bool success = sourcePart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist); 2647 float offsetHeight;
2648
2649 bool success = sourcePart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist,out bbox, out offsetHeight);
2650
2399 if (!success) 2651 if (!success)
2400 return null; 2652 return null;
2401 2653
@@ -2412,10 +2664,69 @@ namespace OpenSim.Region.Framework.Scenes
2412 sourcePart.Inventory.RemoveInventoryItem(item.ItemID); 2664 sourcePart.Inventory.RemoveInventoryItem(item.ItemID);
2413 } 2665 }
2414 2666
2667 SceneObjectGroup sog;
2668
2669 bool fixrot = false;
2670 Quaternion netRot = Quaternion.Identity;
2671
2672 // position adjust
2673 if (totalPrims > 1) // nothing to do on a single prim
2674 {
2675 if (objlist.Count == 1)
2676 {
2677 // current object position is root position
2678 if(!atRoot)
2679 {
2680 sog = objlist[0];
2681 Quaternion orot;
2682 if (rot == null)
2683 orot = sog.RootPart.GetWorldRotation();
2684 else
2685 orot = rot.Value;
2686 // possible should be bbox, but geometric center looks better
2687 Vector3 off = sog.GetGeometricCenter();
2688// Vector3 off = bbox * 0.5f;
2689 off *= orot;
2690 pos -= off;
2691 }
2692 }
2693 else
2694 {
2695 //veclist[] are relative to bbox corner with min X,Y and Z
2696 // rez at root, and rot will be referenced to first object in list
2697 if (rot == null)
2698 {
2699 // use original rotations
2700 if (atRoot)
2701 pos -= veclist[0];
2702 else
2703 pos -= bbox / 2;
2704 }
2705 else
2706 {
2707 fixrot = true;
2708 sog = objlist[0];
2709 netRot = Quaternion.Conjugate(sog.RootPart.GetWorldRotation());
2710 netRot = netRot * rot.Value;
2711 Vector3 off;
2712 if (atRoot)
2713 off = veclist[0];
2714 else
2715 off = bbox / 2;
2716 off *= netRot;
2717 pos -= off;
2718 }
2719 }
2720 }
2721
2415 for (int i = 0; i < objlist.Count; i++) 2722 for (int i = 0; i < objlist.Count; i++)
2416 { 2723 {
2417 SceneObjectGroup group = objlist[i]; 2724 SceneObjectGroup group = objlist[i];
2418 Vector3 curpos = pos + veclist[i]; 2725 Vector3 curpos;
2726 if(fixrot)
2727 curpos = pos + veclist[i] * netRot;
2728 else
2729 curpos = pos + veclist[i];
2419 2730
2420 if (group.IsAttachment == false && group.RootPart.Shape.State != 0) 2731 if (group.IsAttachment == false && group.RootPart.Shape.State != 0)
2421 { 2732 {
@@ -2424,7 +2735,17 @@ namespace OpenSim.Region.Framework.Scenes
2424 } 2735 }
2425 2736
2426 group.FromPartID = sourcePart.UUID; 2737 group.FromPartID = sourcePart.UUID;
2427 AddNewSceneObject(group, true, curpos, rot, vel); 2738 if( i == 0)
2739 AddNewSceneObject(group, true, curpos, rot, vel);
2740 else
2741 {
2742 Quaternion crot = objlist[i].RootPart.GetWorldRotation();
2743 if (fixrot)
2744 {
2745 crot *= netRot;
2746 }
2747 AddNewSceneObject(group, true, curpos, crot, vel);
2748 }
2428 2749
2429 // We can only call this after adding the scene object, since the scene object references the scene 2750 // We can only call this after adding the scene object, since the scene object references the scene
2430 // to find out if scripts should be activated at all. 2751 // to find out if scripts should be activated at all.
@@ -2455,6 +2776,9 @@ namespace OpenSim.Region.Framework.Scenes
2455 2776
2456 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2777 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2457 { 2778 {
2779 if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId))
2780 return;
2781
2458 SceneObjectPart part = GetSceneObjectPart(objectID); 2782 SceneObjectPart part = GetSceneObjectPart(objectID);
2459 if (part == null) 2783 if (part == null)
2460 return; 2784 return;
@@ -2511,7 +2835,10 @@ namespace OpenSim.Region.Framework.Scenes
2511 } 2835 }
2512 else 2836 else
2513 { 2837 {
2514 if (!Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) 2838 if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId)
2839 continue;
2840
2841 if (!Permissions.CanTransferObject(sog.UUID, groupID))
2515 continue; 2842 continue;
2516 2843
2517 if (sog.GroupID != groupID) 2844 if (sog.GroupID != groupID)
@@ -2622,7 +2949,18 @@ namespace OpenSim.Region.Framework.Scenes
2622 return; 2949 return;
2623 } 2950 }
2624 2951
2952 bool oldUsePhysics = (root.Flags & PrimFlags.Physics) != 0;
2625 m_sceneGraph.LinkObjects(root, children); 2953 m_sceneGraph.LinkObjects(root, children);
2954
2955 ScenePresence sp;
2956 if (TryGetScenePresence(agentId, out sp))
2957 {
2958 root.SendPropertiesToClient(sp.ControllingClient);
2959 if (oldUsePhysics && (root.Flags & PrimFlags.Physics) == 0)
2960 {
2961 sp.ControllingClient.SendAlertMessage("Object physics canceled");
2962 }
2963 }
2626 } 2964 }
2627 2965
2628 private string PermissionString(uint permissions) 2966 private string PermissionString(uint permissions)