diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
19 files changed, 2340 insertions, 771 deletions
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index 0ac3899..12688bd 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs | |||
@@ -104,8 +104,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | // better than losing the object for now. | 104 | // better than losing the object for now. |
105 | if (permissionToDelete) | 105 | if (permissionToDelete) |
106 | { | 106 | { |
107 | List<uint> killIDs = new List<uint>(); | ||
108 | |||
107 | foreach (SceneObjectGroup g in objectGroups) | 109 | foreach (SceneObjectGroup g in objectGroups) |
110 | { | ||
111 | killIDs.Add(g.LocalId); | ||
108 | g.DeleteGroupFromScene(false); | 112 | g.DeleteGroupFromScene(false); |
113 | } | ||
114 | |||
115 | m_scene.SendKillObject(killIDs); | ||
109 | } | 116 | } |
110 | } | 117 | } |
111 | 118 | ||
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 96da2c3..65c6a29 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -55,8 +55,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
55 | 55 | ||
56 | public delegate void OnTerrainTickDelegate(); | 56 | public delegate void OnTerrainTickDelegate(); |
57 | 57 | ||
58 | public delegate void OnTerrainUpdateDelegate(); | ||
59 | |||
58 | public event OnTerrainTickDelegate OnTerrainTick; | 60 | public event OnTerrainTickDelegate OnTerrainTick; |
59 | 61 | ||
62 | public event OnTerrainUpdateDelegate OnTerrainUpdate; | ||
63 | |||
60 | public delegate void OnBackupDelegate(ISimulationDataService datastore, bool forceBackup); | 64 | public delegate void OnBackupDelegate(ISimulationDataService datastore, bool forceBackup); |
61 | 65 | ||
62 | public event OnBackupDelegate OnBackup; | 66 | public event OnBackupDelegate OnBackup; |
@@ -775,6 +779,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
775 | } | 779 | } |
776 | } | 780 | } |
777 | } | 781 | } |
782 | public void TriggerTerrainUpdate() | ||
783 | { | ||
784 | OnTerrainUpdateDelegate handlerTerrainUpdate = OnTerrainUpdate; | ||
785 | if (handlerTerrainUpdate != null) | ||
786 | { | ||
787 | foreach (OnTerrainUpdateDelegate d in handlerTerrainUpdate.GetInvocationList()) | ||
788 | { | ||
789 | try | ||
790 | { | ||
791 | d(); | ||
792 | } | ||
793 | catch (Exception e) | ||
794 | { | ||
795 | m_log.ErrorFormat( | ||
796 | "[EVENT MANAGER]: Delegate for TriggerTerrainUpdate failed - continuing. {0} {1}", | ||
797 | e.Message, e.StackTrace); | ||
798 | } | ||
799 | } | ||
800 | } | ||
801 | } | ||
778 | 802 | ||
779 | public void TriggerTerrainTick() | 803 | public void TriggerTerrainTick() |
780 | { | 804 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 1b10e3c..0a34a4c 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs | |||
@@ -157,7 +157,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
157 | 157 | ||
158 | private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) | 158 | private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) |
159 | { | 159 | { |
160 | uint pqueue = ComputeDistancePriority(client,entity,true); | 160 | uint pqueue = ComputeDistancePriority(client,entity,false); |
161 | 161 | ||
162 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); | 162 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); |
163 | if (presence != null) | 163 | if (presence != null) |
@@ -226,7 +226,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
226 | 226 | ||
227 | for (int i = 0; i < queues - 1; i++) | 227 | for (int i = 0; i < queues - 1; i++) |
228 | { | 228 | { |
229 | if (distance < 10 * Math.Pow(2.0,i)) | 229 | if (distance < 30 * Math.Pow(2.0,i)) |
230 | break; | 230 | break; |
231 | pqueue++; | 231 | pqueue++; |
232 | } | 232 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 663aa22..53f0f2e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -124,34 +124,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
124 | /// <param name="item"></param> | 124 | /// <param name="item"></param> |
125 | public bool AddInventoryItem(InventoryItemBase item) | 125 | public bool AddInventoryItem(InventoryItemBase item) |
126 | { | 126 | { |
127 | if (UUID.Zero == item.Folder) | 127 | InventoryFolderBase folder; |
128 | |||
129 | if (item.Folder == UUID.Zero) | ||
128 | { | 130 | { |
129 | InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); | 131 | folder = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); |
130 | if (f != null) | 132 | if (folder == null) |
131 | { | 133 | { |
132 | // m_log.DebugFormat( | 134 | folder = InventoryService.GetRootFolder(item.Owner); |
133 | // "[LOCAL INVENTORY SERVICES CONNECTOR]: Found folder {0} type {1} for item {2}", | 135 | |
134 | // f.Name, (AssetType)f.Type, item.Name); | 136 | if (folder == null) |
135 | |||
136 | item.Folder = f.ID; | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | f = InventoryService.GetRootFolder(item.Owner); | ||
141 | if (f != null) | ||
142 | { | ||
143 | item.Folder = f.ID; | ||
144 | } | ||
145 | else | ||
146 | { | ||
147 | m_log.WarnFormat( | ||
148 | "[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", | ||
149 | item.Owner, item.Name); | ||
150 | return false; | 137 | return false; |
151 | } | ||
152 | } | 138 | } |
139 | |||
140 | item.Folder = folder.ID; | ||
153 | } | 141 | } |
154 | 142 | ||
155 | if (InventoryService.AddItem(item)) | 143 | if (InventoryService.AddItem(item)) |
156 | { | 144 | { |
157 | int userlevel = 0; | 145 | int userlevel = 0; |
@@ -271,8 +259,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
271 | 259 | ||
272 | // Update item with new asset | 260 | // Update item with new asset |
273 | item.AssetID = asset.FullID; | 261 | item.AssetID = asset.FullID; |
274 | if (group.UpdateInventoryItem(item)) | 262 | group.UpdateInventoryItem(item); |
275 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
276 | 263 | ||
277 | part.SendPropertiesToClient(remoteClient); | 264 | part.SendPropertiesToClient(remoteClient); |
278 | 265 | ||
@@ -283,12 +270,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
283 | { | 270 | { |
284 | // Needs to determine which engine was running it and use that | 271 | // Needs to determine which engine was running it and use that |
285 | // | 272 | // |
286 | part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); | 273 | errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0); |
287 | errors = part.Inventory.GetScriptErrors(item.ItemID); | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
292 | } | 274 | } |
293 | part.ParentGroup.ResumeScripts(); | 275 | part.ParentGroup.ResumeScripts(); |
294 | return errors; | 276 | return errors; |
@@ -351,6 +333,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
351 | { | 333 | { |
352 | if (UUID.Zero == transactionID) | 334 | if (UUID.Zero == transactionID) |
353 | { | 335 | { |
336 | item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); | ||
354 | item.Name = itemUpd.Name; | 337 | item.Name = itemUpd.Name; |
355 | item.Description = itemUpd.Description; | 338 | item.Description = itemUpd.Description; |
356 | if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) | 339 | if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) |
@@ -728,6 +711,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
728 | return; | 711 | return; |
729 | } | 712 | } |
730 | 713 | ||
714 | if (newName == null) newName = item.Name; | ||
715 | |||
731 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 716 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
732 | 717 | ||
733 | if (asset != null) | 718 | if (asset != null) |
@@ -784,6 +769,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
784 | } | 769 | } |
785 | 770 | ||
786 | /// <summary> | 771 | /// <summary> |
772 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
773 | /// </summary> | ||
774 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
775 | { | ||
776 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
777 | foreach (InventoryItemBase b in items) | ||
778 | { | ||
779 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
780 | InventoryItemBase n = InventoryService.GetItem(b); | ||
781 | n.Folder = destfolder; | ||
782 | moveitems.Add(n); | ||
783 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
784 | } | ||
785 | |||
786 | MoveInventoryItem(remoteClient, moveitems); | ||
787 | } | ||
788 | |||
789 | /// <summary> | ||
787 | /// Move an item within the agent's inventory. | 790 | /// Move an item within the agent's inventory. |
788 | /// </summary> | 791 | /// </summary> |
789 | /// <param name="remoteClient"></param> | 792 | /// <param name="remoteClient"></param> |
@@ -984,25 +987,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
984 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) | 987 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) |
985 | { | 988 | { |
986 | SceneObjectPart part = GetSceneObjectPart(localID); | 989 | SceneObjectPart part = GetSceneObjectPart(localID); |
987 | if (part == null) | 990 | SceneObjectGroup group = null; |
988 | return; | 991 | if (part != null) |
992 | { | ||
993 | group = part.ParentGroup; | ||
994 | } | ||
995 | if (part != null && group != null) | ||
996 | { | ||
997 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | ||
998 | return; | ||
989 | 999 | ||
990 | SceneObjectGroup group = part.ParentGroup; | 1000 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); |
991 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | 1001 | if (item == null) |
992 | return; | 1002 | return; |
993 | |||
994 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); | ||
995 | if (item == null) | ||
996 | return; | ||
997 | 1003 | ||
998 | if (item.Type == 10) | 1004 | if (item.Type == 10) |
999 | { | 1005 | { |
1000 | part.RemoveScriptEvents(itemID); | 1006 | part.RemoveScriptEvents(itemID); |
1001 | EventManager.TriggerRemoveScript(localID, itemID); | 1007 | EventManager.TriggerRemoveScript(localID, itemID); |
1008 | } | ||
1009 | |||
1010 | group.RemoveInventoryItem(localID, itemID); | ||
1011 | part.SendPropertiesToClient(remoteClient); | ||
1002 | } | 1012 | } |
1003 | |||
1004 | group.RemoveInventoryItem(localID, itemID); | ||
1005 | part.SendPropertiesToClient(remoteClient); | ||
1006 | } | 1013 | } |
1007 | 1014 | ||
1008 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) | 1015 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) |
@@ -1213,6 +1220,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1213 | if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) | 1220 | if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) |
1214 | return; | 1221 | return; |
1215 | 1222 | ||
1223 | bool overrideNoMod = false; | ||
1224 | if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) | ||
1225 | overrideNoMod = true; | ||
1226 | |||
1216 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | 1227 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) |
1217 | { | 1228 | { |
1218 | // object cannot copy items to an object owned by a different owner | 1229 | // object cannot copy items to an object owned by a different owner |
@@ -1222,7 +1233,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1222 | } | 1233 | } |
1223 | 1234 | ||
1224 | // must have both move and modify permission to put an item in an object | 1235 | // must have both move and modify permission to put an item in an object |
1225 | if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) | 1236 | if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) |
1226 | { | 1237 | { |
1227 | return; | 1238 | return; |
1228 | } | 1239 | } |
@@ -1281,6 +1292,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1281 | 1292 | ||
1282 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1293 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1283 | { | 1294 | { |
1295 | SceneObjectPart destPart = GetSceneObjectPart(destID); | ||
1296 | if (destPart != null) // Move into a prim | ||
1297 | { | ||
1298 | foreach(UUID itemID in items) | ||
1299 | MoveTaskInventoryItem(destID, host, itemID); | ||
1300 | return destID; // Prim folder ID == prim ID | ||
1301 | } | ||
1302 | |||
1284 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1303 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1285 | 1304 | ||
1286 | UUID newFolderID = UUID.Random(); | 1305 | UUID newFolderID = UUID.Random(); |
@@ -1460,13 +1479,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1460 | { | 1479 | { |
1461 | agentTransactions.HandleTaskItemUpdateFromTransaction( | 1480 | agentTransactions.HandleTaskItemUpdateFromTransaction( |
1462 | remoteClient, part, transactionID, currentItem); | 1481 | remoteClient, part, transactionID, currentItem); |
1463 | |||
1464 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | ||
1465 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
1466 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | ||
1467 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
1468 | else | ||
1469 | remoteClient.SendAgentAlertMessage("Item saved", false); | ||
1470 | } | 1482 | } |
1471 | 1483 | ||
1472 | // Base ALWAYS has move | 1484 | // Base ALWAYS has move |
@@ -1607,7 +1619,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1607 | return; | 1619 | return; |
1608 | 1620 | ||
1609 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1621 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1610 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1622 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), |
1611 | remoteClient.AgentId); | 1623 | remoteClient.AgentId); |
1612 | AssetService.Store(asset); | 1624 | AssetService.Store(asset); |
1613 | 1625 | ||
@@ -1760,23 +1772,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1760 | // build a list of eligible objects | 1772 | // build a list of eligible objects |
1761 | List<uint> deleteIDs = new List<uint>(); | 1773 | List<uint> deleteIDs = new List<uint>(); |
1762 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 1774 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
1763 | 1775 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
1764 | // Start with true for both, then remove the flags if objects | ||
1765 | // that we can't derez are part of the selection | ||
1766 | bool permissionToTake = true; | ||
1767 | bool permissionToTakeCopy = true; | ||
1768 | bool permissionToDelete = true; | ||
1769 | 1776 | ||
1770 | foreach (uint localID in localIDs) | 1777 | foreach (uint localID in localIDs) |
1771 | { | 1778 | { |
1779 | // Start with true for both, then remove the flags if objects | ||
1780 | // that we can't derez are part of the selection | ||
1781 | bool permissionToTake = true; | ||
1782 | bool permissionToTakeCopy = true; | ||
1783 | bool permissionToDelete = true; | ||
1784 | |||
1772 | // Invalid id | 1785 | // Invalid id |
1773 | SceneObjectPart part = GetSceneObjectPart(localID); | 1786 | SceneObjectPart part = GetSceneObjectPart(localID); |
1774 | if (part == null) | 1787 | if (part == null) |
1788 | { | ||
1789 | //Client still thinks the object exists, kill it | ||
1790 | deleteIDs.Add(localID); | ||
1775 | continue; | 1791 | continue; |
1792 | } | ||
1776 | 1793 | ||
1777 | // Already deleted by someone else | 1794 | // Already deleted by someone else |
1778 | if (part.ParentGroup.IsDeleted) | 1795 | if (part.ParentGroup.IsDeleted) |
1796 | { | ||
1797 | //Client still thinks the object exists, kill it | ||
1798 | deleteIDs.Add(localID); | ||
1779 | continue; | 1799 | continue; |
1800 | } | ||
1780 | 1801 | ||
1781 | // Can't delete child prims | 1802 | // Can't delete child prims |
1782 | if (part != part.ParentGroup.RootPart) | 1803 | if (part != part.ParentGroup.RootPart) |
@@ -1784,9 +1805,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1784 | 1805 | ||
1785 | SceneObjectGroup grp = part.ParentGroup; | 1806 | SceneObjectGroup grp = part.ParentGroup; |
1786 | 1807 | ||
1787 | deleteIDs.Add(localID); | ||
1788 | deleteGroups.Add(grp); | ||
1789 | |||
1790 | if (remoteClient == null) | 1808 | if (remoteClient == null) |
1791 | { | 1809 | { |
1792 | // Autoreturn has a null client. Nothing else does. So | 1810 | // Autoreturn has a null client. Nothing else does. So |
@@ -1803,81 +1821,193 @@ namespace OpenSim.Region.Framework.Scenes | |||
1803 | } | 1821 | } |
1804 | else | 1822 | else |
1805 | { | 1823 | { |
1806 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 1824 | if (action == DeRezAction.TakeCopy) |
1825 | { | ||
1826 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
1827 | permissionToTakeCopy = false; | ||
1828 | } | ||
1829 | else | ||
1830 | { | ||
1807 | permissionToTakeCopy = false; | 1831 | permissionToTakeCopy = false; |
1808 | 1832 | } | |
1809 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 1833 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
1810 | permissionToTake = false; | 1834 | permissionToTake = false; |
1811 | 1835 | ||
1812 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 1836 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
1813 | permissionToDelete = false; | 1837 | permissionToDelete = false; |
1814 | } | 1838 | } |
1815 | } | ||
1816 | 1839 | ||
1817 | // Handle god perms | 1840 | // Handle god perms |
1818 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 1841 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
1819 | { | 1842 | { |
1820 | permissionToTake = true; | 1843 | permissionToTake = true; |
1821 | permissionToTakeCopy = true; | 1844 | permissionToTakeCopy = true; |
1822 | permissionToDelete = true; | 1845 | permissionToDelete = true; |
1823 | } | 1846 | } |
1824 | 1847 | ||
1825 | // If we're re-saving, we don't even want to delete | 1848 | // If we're re-saving, we don't even want to delete |
1826 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | 1849 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
1827 | permissionToDelete = false; | 1850 | permissionToDelete = false; |
1828 | 1851 | ||
1829 | // if we want to take a copy, we also don't want to delete | 1852 | // if we want to take a copy, we also don't want to delete |
1830 | // Note: after this point, the permissionToTakeCopy flag | 1853 | // Note: after this point, the permissionToTakeCopy flag |
1831 | // becomes irrelevant. It already includes the permissionToTake | 1854 | // becomes irrelevant. It already includes the permissionToTake |
1832 | // permission and after excluding no copy items here, we can | 1855 | // permission and after excluding no copy items here, we can |
1833 | // just use that. | 1856 | // just use that. |
1834 | if (action == DeRezAction.TakeCopy) | 1857 | if (action == DeRezAction.TakeCopy) |
1835 | { | 1858 | { |
1836 | // If we don't have permission, stop right here | 1859 | // If we don't have permission, stop right here |
1837 | if (!permissionToTakeCopy) | 1860 | if (!permissionToTakeCopy) |
1838 | return; | 1861 | return; |
1839 | 1862 | ||
1840 | permissionToTake = true; | 1863 | permissionToTake = true; |
1841 | // Don't delete | 1864 | // Don't delete |
1842 | permissionToDelete = false; | 1865 | permissionToDelete = false; |
1843 | } | 1866 | } |
1844 | 1867 | ||
1845 | if (action == DeRezAction.Return) | 1868 | if (action == DeRezAction.Return) |
1846 | { | ||
1847 | if (remoteClient != null) | ||
1848 | { | 1869 | { |
1849 | if (Permissions.CanReturnObjects( | 1870 | if (remoteClient != null) |
1850 | null, | ||
1851 | remoteClient.AgentId, | ||
1852 | deleteGroups)) | ||
1853 | { | 1871 | { |
1854 | permissionToTake = true; | 1872 | if (Permissions.CanReturnObjects( |
1855 | permissionToDelete = true; | 1873 | null, |
1856 | 1874 | remoteClient.AgentId, | |
1857 | foreach (SceneObjectGroup g in deleteGroups) | 1875 | deleteGroups)) |
1858 | { | 1876 | { |
1859 | AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 1877 | permissionToTake = true; |
1878 | permissionToDelete = true; | ||
1879 | |||
1880 | AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
1860 | } | 1881 | } |
1861 | } | 1882 | } |
1883 | else // Auto return passes through here with null agent | ||
1884 | { | ||
1885 | permissionToTake = true; | ||
1886 | permissionToDelete = true; | ||
1887 | } | ||
1862 | } | 1888 | } |
1863 | else // Auto return passes through here with null agent | 1889 | |
1890 | if (permissionToTake && (!permissionToDelete)) | ||
1891 | takeGroups.Add(grp); | ||
1892 | |||
1893 | if (permissionToDelete) | ||
1864 | { | 1894 | { |
1865 | permissionToTake = true; | 1895 | if (permissionToTake) |
1866 | permissionToDelete = true; | 1896 | deleteGroups.Add(grp); |
1897 | deleteIDs.Add(grp.LocalId); | ||
1867 | } | 1898 | } |
1868 | } | 1899 | } |
1869 | 1900 | ||
1870 | if (permissionToTake) | 1901 | SendKillObject(deleteIDs); |
1902 | |||
1903 | if (deleteGroups.Count > 0) | ||
1871 | { | 1904 | { |
1905 | foreach (SceneObjectGroup g in deleteGroups) | ||
1906 | deleteIDs.Remove(g.LocalId); | ||
1907 | |||
1872 | m_asyncSceneObjectDeleter.DeleteToInventory( | 1908 | m_asyncSceneObjectDeleter.DeleteToInventory( |
1873 | action, destinationID, deleteGroups, remoteClient, | 1909 | action, destinationID, deleteGroups, remoteClient, |
1874 | permissionToDelete); | 1910 | true); |
1875 | } | 1911 | } |
1876 | else if (permissionToDelete) | 1912 | if (takeGroups.Count > 0) |
1913 | { | ||
1914 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
1915 | action, destinationID, takeGroups, remoteClient, | ||
1916 | false); | ||
1917 | } | ||
1918 | if (deleteIDs.Count > 0) | ||
1877 | { | 1919 | { |
1878 | foreach (SceneObjectGroup g in deleteGroups) | 1920 | foreach (SceneObjectGroup g in deleteGroups) |
1879 | DeleteSceneObject(g, false); | 1921 | DeleteSceneObject(g, true); |
1922 | } | ||
1923 | } | ||
1924 | |||
1925 | public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) | ||
1926 | { | ||
1927 | itemID = UUID.Zero; | ||
1928 | if (grp != null) | ||
1929 | { | ||
1930 | Vector3 inventoryStoredPosition = new Vector3 | ||
1931 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1932 | ? 250 | ||
1933 | : grp.AbsolutePosition.X) | ||
1934 | , | ||
1935 | (grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1936 | ? 250 | ||
1937 | : grp.AbsolutePosition.X, | ||
1938 | grp.AbsolutePosition.Z); | ||
1939 | |||
1940 | Vector3 originalPosition = grp.AbsolutePosition; | ||
1941 | |||
1942 | grp.AbsolutePosition = inventoryStoredPosition; | ||
1943 | |||
1944 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
1945 | |||
1946 | grp.AbsolutePosition = originalPosition; | ||
1947 | |||
1948 | AssetBase asset = CreateAsset( | ||
1949 | grp.GetPartName(grp.LocalId), | ||
1950 | grp.GetPartDescription(grp.LocalId), | ||
1951 | (sbyte)AssetType.Object, | ||
1952 | Utils.StringToBytes(sceneObjectXml), | ||
1953 | remoteClient.AgentId); | ||
1954 | AssetService.Store(asset); | ||
1955 | |||
1956 | InventoryItemBase item = new InventoryItemBase(); | ||
1957 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
1958 | item.CreatorData = grp.RootPart.CreatorData; | ||
1959 | item.Owner = remoteClient.AgentId; | ||
1960 | item.ID = UUID.Random(); | ||
1961 | item.AssetID = asset.FullID; | ||
1962 | item.Description = asset.Description; | ||
1963 | item.Name = asset.Name; | ||
1964 | item.AssetType = asset.Type; | ||
1965 | item.InvType = (int)InventoryType.Object; | ||
1966 | |||
1967 | InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
1968 | if (folder != null) | ||
1969 | item.Folder = folder.ID; | ||
1970 | else // oopsies | ||
1971 | item.Folder = UUID.Zero; | ||
1972 | |||
1973 | // Set up base perms properly | ||
1974 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
1975 | permsBase &= grp.RootPart.BaseMask; | ||
1976 | permsBase |= (uint)PermissionMask.Move; | ||
1977 | |||
1978 | // Make sure we don't lock it | ||
1979 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
1980 | |||
1981 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
1982 | { | ||
1983 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1984 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1985 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1986 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
1987 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
1988 | } | ||
1989 | else | ||
1990 | { | ||
1991 | item.BasePermissions = permsBase; | ||
1992 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; | ||
1993 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1994 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; | ||
1995 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; | ||
1996 | } | ||
1997 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
1998 | |||
1999 | // sets itemID so client can show item as 'attached' in inventory | ||
2000 | grp.SetFromItemID(item.ID); | ||
2001 | |||
2002 | if (AddInventoryItem(item)) | ||
2003 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
2004 | else | ||
2005 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
2006 | |||
2007 | itemID = item.ID; | ||
2008 | return item.AssetID; | ||
1880 | } | 2009 | } |
2010 | return UUID.Zero; | ||
1881 | } | 2011 | } |
1882 | 2012 | ||
1883 | /// <summary> | 2013 | /// <summary> |
@@ -2006,6 +2136,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2006 | 2136 | ||
2007 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2137 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2008 | { | 2138 | { |
2139 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2140 | return; | ||
2141 | |||
2009 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2142 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2010 | if (part == null) | 2143 | if (part == null) |
2011 | return; | 2144 | return; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 270e582..575079f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -374,7 +374,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
374 | List<UserAccount> accounts = UserAccountService.GetUserAccounts(RegionInfo.ScopeID, query); | 374 | List<UserAccount> accounts = UserAccountService.GetUserAccounts(RegionInfo.ScopeID, query); |
375 | 375 | ||
376 | if (accounts == null) | 376 | if (accounts == null) |
377 | { | ||
378 | m_log.DebugFormat("[LLCIENT]: ProcessAvatarPickerRequest: returned null result"); | ||
377 | return; | 379 | return; |
380 | } | ||
378 | 381 | ||
379 | AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); | 382 | AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); |
380 | // TODO: don't create new blocks if recycling an old packet | 383 | // TODO: don't create new blocks if recycling an old packet |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index e1fedf4..48beb9c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | |||
@@ -49,6 +49,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
49 | public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition); | 49 | public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition); |
50 | public delegate bool EditObjectHandler(UUID objectID, UUID editorID, Scene scene); | 50 | public delegate bool EditObjectHandler(UUID objectID, UUID editorID, Scene scene); |
51 | public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); | 51 | public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); |
52 | public delegate bool ViewObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); | ||
52 | public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); | 53 | public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); |
53 | public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); | 54 | public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); |
54 | public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene); | 55 | public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene); |
@@ -116,6 +117,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
116 | public event DuplicateObjectHandler OnDuplicateObject; | 117 | public event DuplicateObjectHandler OnDuplicateObject; |
117 | public event EditObjectHandler OnEditObject; | 118 | public event EditObjectHandler OnEditObject; |
118 | public event EditObjectInventoryHandler OnEditObjectInventory; | 119 | public event EditObjectInventoryHandler OnEditObjectInventory; |
120 | public event ViewObjectInventoryHandler OnViewObjectInventory; | ||
119 | public event MoveObjectHandler OnMoveObject; | 121 | public event MoveObjectHandler OnMoveObject; |
120 | public event ObjectEntryHandler OnObjectEntry; | 122 | public event ObjectEntryHandler OnObjectEntry; |
121 | public event ReturnObjectsHandler OnReturnObjects; | 123 | public event ReturnObjectsHandler OnReturnObjects; |
@@ -401,6 +403,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
401 | return true; | 403 | return true; |
402 | } | 404 | } |
403 | 405 | ||
406 | public bool CanViewObjectInventory(UUID objectID, UUID editorID) | ||
407 | { | ||
408 | ViewObjectInventoryHandler handler = OnViewObjectInventory; | ||
409 | if (handler != null) | ||
410 | { | ||
411 | Delegate[] list = handler.GetInvocationList(); | ||
412 | foreach (ViewObjectInventoryHandler h in list) | ||
413 | { | ||
414 | if (h(objectID, editorID, m_scene) == false) | ||
415 | return false; | ||
416 | } | ||
417 | } | ||
418 | return true; | ||
419 | } | ||
420 | |||
404 | #endregion | 421 | #endregion |
405 | 422 | ||
406 | #region MOVE OBJECT | 423 | #region MOVE OBJECT |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1e111e5..5d4ddea 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -95,6 +95,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
95 | // TODO: need to figure out how allow client agents but deny | 95 | // TODO: need to figure out how allow client agents but deny |
96 | // root agents when ACL denies access to root agent | 96 | // root agents when ACL denies access to root agent |
97 | public bool m_strictAccessControl = true; | 97 | public bool m_strictAccessControl = true; |
98 | public bool m_seeIntoBannedRegion = false; | ||
98 | public int MaxUndoCount = 5; | 99 | public int MaxUndoCount = 5; |
99 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 100 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
100 | public bool LoginLock = false; | 101 | public bool LoginLock = false; |
@@ -110,12 +111,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
110 | 111 | ||
111 | protected int m_splitRegionID; | 112 | protected int m_splitRegionID; |
112 | protected Timer m_restartWaitTimer = new Timer(); | 113 | protected Timer m_restartWaitTimer = new Timer(); |
114 | protected Timer m_timerWatchdog = new Timer(); | ||
113 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 115 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
114 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 116 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
115 | protected string m_simulatorVersion = "OpenSimulator Server"; | 117 | protected string m_simulatorVersion = "OpenSimulator Server"; |
116 | protected ModuleLoader m_moduleLoader; | 118 | protected ModuleLoader m_moduleLoader; |
117 | protected AgentCircuitManager m_authenticateHandler; | 119 | protected AgentCircuitManager m_authenticateHandler; |
118 | protected SceneCommunicationService m_sceneGridService; | 120 | protected SceneCommunicationService m_sceneGridService; |
121 | protected ISnmpModule m_snmpService = null; | ||
119 | 122 | ||
120 | protected ISimulationDataService m_SimulationDataService; | 123 | protected ISimulationDataService m_SimulationDataService; |
121 | protected IEstateDataService m_EstateDataService; | 124 | protected IEstateDataService m_EstateDataService; |
@@ -167,7 +170,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
167 | private int m_update_events = 1; | 170 | private int m_update_events = 1; |
168 | private int m_update_backup = 200; | 171 | private int m_update_backup = 200; |
169 | private int m_update_terrain = 50; | 172 | private int m_update_terrain = 50; |
170 | // private int m_update_land = 1; | 173 | private int m_update_land = 10; |
171 | private int m_update_coarse_locations = 50; | 174 | private int m_update_coarse_locations = 50; |
172 | 175 | ||
173 | private int agentMS; | 176 | private int agentMS; |
@@ -182,6 +185,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
182 | private int landMS; | 185 | private int landMS; |
183 | private int lastCompletedFrame; | 186 | private int lastCompletedFrame; |
184 | 187 | ||
188 | public bool CombineRegions = false; | ||
185 | /// <summary> | 189 | /// <summary> |
186 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched | 190 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched |
187 | /// asynchronously from the update loop. | 191 | /// asynchronously from the update loop. |
@@ -204,10 +208,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
204 | private bool m_scripts_enabled = true; | 208 | private bool m_scripts_enabled = true; |
205 | private string m_defaultScriptEngine; | 209 | private string m_defaultScriptEngine; |
206 | private int m_LastLogin; | 210 | private int m_LastLogin; |
207 | private Thread HeartbeatThread; | 211 | private Thread HeartbeatThread = null; |
208 | private volatile bool shuttingdown; | 212 | private volatile bool shuttingdown; |
209 | 213 | ||
210 | private int m_lastUpdate; | 214 | private int m_lastUpdate; |
215 | private int m_lastIncoming; | ||
216 | private int m_lastOutgoing; | ||
211 | private bool m_firstHeartbeat = true; | 217 | private bool m_firstHeartbeat = true; |
212 | 218 | ||
213 | private object m_deleting_scene_object = new object(); | 219 | private object m_deleting_scene_object = new object(); |
@@ -255,6 +261,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
255 | get { return m_sceneGridService; } | 261 | get { return m_sceneGridService; } |
256 | } | 262 | } |
257 | 263 | ||
264 | public ISnmpModule SnmpService | ||
265 | { | ||
266 | get | ||
267 | { | ||
268 | if (m_snmpService == null) | ||
269 | { | ||
270 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
271 | } | ||
272 | |||
273 | return m_snmpService; | ||
274 | } | ||
275 | } | ||
276 | |||
258 | public ISimulationDataService SimulationDataService | 277 | public ISimulationDataService SimulationDataService |
259 | { | 278 | { |
260 | get | 279 | get |
@@ -536,6 +555,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
536 | m_EstateDataService = estateDataService; | 555 | m_EstateDataService = estateDataService; |
537 | m_regionHandle = m_regInfo.RegionHandle; | 556 | m_regionHandle = m_regInfo.RegionHandle; |
538 | m_regionName = m_regInfo.RegionName; | 557 | m_regionName = m_regInfo.RegionName; |
558 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
559 | m_lastIncoming = 0; | ||
560 | m_lastOutgoing = 0; | ||
539 | 561 | ||
540 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 562 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
541 | m_asyncSceneObjectDeleter.Enabled = true; | 563 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -652,6 +674,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
652 | m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); | 674 | m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); |
653 | 675 | ||
654 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 676 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
677 | |||
678 | m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); | ||
655 | if (RegionInfo.NonphysPrimMax > 0) | 679 | if (RegionInfo.NonphysPrimMax > 0) |
656 | { | 680 | { |
657 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 681 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -683,6 +707,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
683 | m_persistAfter *= 10000000; | 707 | m_persistAfter *= 10000000; |
684 | 708 | ||
685 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 709 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
710 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
686 | 711 | ||
687 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 712 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
688 | if (packetConfig != null) | 713 | if (packetConfig != null) |
@@ -692,6 +717,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
692 | } | 717 | } |
693 | 718 | ||
694 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 719 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
720 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
721 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
695 | 722 | ||
696 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 723 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
697 | if (m_generateMaptiles) | 724 | if (m_generateMaptiles) |
@@ -727,9 +754,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
727 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | 754 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); |
728 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | 755 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); |
729 | } | 756 | } |
730 | catch | 757 | catch (Exception e) |
731 | { | 758 | { |
732 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 759 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
733 | } | 760 | } |
734 | 761 | ||
735 | #endregion Region Config | 762 | #endregion Region Config |
@@ -1140,7 +1167,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1140 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1167 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1141 | if (HeartbeatThread != null) | 1168 | if (HeartbeatThread != null) |
1142 | { | 1169 | { |
1170 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1143 | HeartbeatThread.Abort(); | 1171 | HeartbeatThread.Abort(); |
1172 | Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); | ||
1144 | HeartbeatThread = null; | 1173 | HeartbeatThread = null; |
1145 | } | 1174 | } |
1146 | m_lastUpdate = Util.EnvironmentTickCount(); | 1175 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1183,9 +1212,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1183 | { | 1212 | { |
1184 | while (!shuttingdown) | 1213 | while (!shuttingdown) |
1185 | Update(); | 1214 | Update(); |
1186 | |||
1187 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1188 | m_firstHeartbeat = false; | ||
1189 | } | 1215 | } |
1190 | catch (ThreadAbortException) | 1216 | catch (ThreadAbortException) |
1191 | { | 1217 | { |
@@ -1283,6 +1309,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1283 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1309 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1284 | } | 1310 | } |
1285 | 1311 | ||
1312 | // if (Frame % m_update_land == 0) | ||
1313 | // { | ||
1314 | // int ldMS = Util.EnvironmentTickCount(); | ||
1315 | // UpdateLand(); | ||
1316 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1317 | // } | ||
1318 | |||
1286 | if (Frame % m_update_backup == 0) | 1319 | if (Frame % m_update_backup == 0) |
1287 | { | 1320 | { |
1288 | int backMS = Util.EnvironmentTickCount(); | 1321 | int backMS = Util.EnvironmentTickCount(); |
@@ -1384,12 +1417,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1384 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1417 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1385 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1418 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1386 | 1419 | ||
1420 | |||
1421 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1422 | m_firstHeartbeat = false; | ||
1423 | |||
1387 | if (maintc > 0) | 1424 | if (maintc > 0) |
1388 | Thread.Sleep(maintc); | 1425 | Thread.Sleep(maintc); |
1389 | 1426 | ||
1390 | // Tell the watchdog that this thread is still alive | 1427 | // Tell the watchdog that this thread is still alive |
1391 | Watchdog.UpdateThread(); | 1428 | Watchdog.UpdateThread(); |
1392 | } | 1429 | } |
1393 | 1430 | ||
1394 | public void AddGroupTarget(SceneObjectGroup grp) | 1431 | public void AddGroupTarget(SceneObjectGroup grp) |
1395 | { | 1432 | { |
@@ -1405,9 +1442,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1405 | 1442 | ||
1406 | private void CheckAtTargets() | 1443 | private void CheckAtTargets() |
1407 | { | 1444 | { |
1408 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1445 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1409 | lock (m_groupsWithTargets) | 1446 | lock (m_groupsWithTargets) |
1410 | objs = m_groupsWithTargets.Values; | 1447 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1411 | 1448 | ||
1412 | foreach (SceneObjectGroup entry in objs) | 1449 | foreach (SceneObjectGroup entry in objs) |
1413 | entry.checkAtTargets(); | 1450 | entry.checkAtTargets(); |
@@ -1489,7 +1526,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1489 | msg.fromAgentName = "Server"; | 1526 | msg.fromAgentName = "Server"; |
1490 | msg.dialog = (byte)19; // Object msg | 1527 | msg.dialog = (byte)19; // Object msg |
1491 | msg.fromGroup = false; | 1528 | msg.fromGroup = false; |
1492 | msg.offline = (byte)0; | 1529 | msg.offline = (byte)1; |
1493 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1530 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1494 | msg.Position = Vector3.Zero; | 1531 | msg.Position = Vector3.Zero; |
1495 | msg.RegionID = RegionInfo.RegionID.Guid; | 1532 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1724,14 +1761,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1724 | /// <returns></returns> | 1761 | /// <returns></returns> |
1725 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1762 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1726 | { | 1763 | { |
1764 | |||
1765 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1766 | Vector3 wpos = Vector3.Zero; | ||
1767 | // Check for water surface intersection from above | ||
1768 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1769 | { | ||
1770 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1771 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1772 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1773 | wpos.Z = wheight; | ||
1774 | } | ||
1775 | |||
1727 | Vector3 pos = Vector3.Zero; | 1776 | Vector3 pos = Vector3.Zero; |
1728 | if (RayEndIsIntersection == (byte)1) | 1777 | if (RayEndIsIntersection == (byte)1) |
1729 | { | 1778 | { |
1730 | pos = RayEnd; | 1779 | pos = RayEnd; |
1731 | return pos; | ||
1732 | } | 1780 | } |
1733 | 1781 | else if (RayTargetID != UUID.Zero) | |
1734 | if (RayTargetID != UUID.Zero) | ||
1735 | { | 1782 | { |
1736 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1783 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1737 | 1784 | ||
@@ -1753,7 +1800,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1753 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1800 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1754 | 1801 | ||
1755 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1802 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1756 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1803 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1757 | float ScaleOffset = 0.5f; | 1804 | float ScaleOffset = 0.5f; |
1758 | 1805 | ||
1759 | // If we hit something | 1806 | // If we hit something |
@@ -1776,13 +1823,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1776 | //pos.Z -= 0.25F; | 1823 | //pos.Z -= 0.25F; |
1777 | 1824 | ||
1778 | } | 1825 | } |
1779 | |||
1780 | return pos; | ||
1781 | } | 1826 | } |
1782 | else | 1827 | else |
1783 | { | 1828 | { |
1784 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1829 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1785 | |||
1786 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1830 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1787 | 1831 | ||
1788 | // Un-comment the following line to print the raytrace results to the console. | 1832 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1791,13 +1835,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1791 | if (ei.HitTF) | 1835 | if (ei.HitTF) |
1792 | { | 1836 | { |
1793 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1837 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1794 | } else | 1838 | } |
1839 | else | ||
1795 | { | 1840 | { |
1796 | // fall back to our stupid functionality | 1841 | // fall back to our stupid functionality |
1797 | pos = RayEnd; | 1842 | pos = RayEnd; |
1798 | } | 1843 | } |
1799 | |||
1800 | return pos; | ||
1801 | } | 1844 | } |
1802 | } | 1845 | } |
1803 | else | 1846 | else |
@@ -1808,8 +1851,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1808 | //increase height so its above the ground. | 1851 | //increase height so its above the ground. |
1809 | //should be getting the normal of the ground at the rez point and using that? | 1852 | //should be getting the normal of the ground at the rez point and using that? |
1810 | pos.Z += scale.Z / 2f; | 1853 | pos.Z += scale.Z / 2f; |
1811 | return pos; | 1854 | // return pos; |
1812 | } | 1855 | } |
1856 | |||
1857 | // check against posible water intercept | ||
1858 | if (wpos.Z > pos.Z) pos = wpos; | ||
1859 | return pos; | ||
1813 | } | 1860 | } |
1814 | 1861 | ||
1815 | 1862 | ||
@@ -1893,7 +1940,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1893 | public bool AddRestoredSceneObject( | 1940 | public bool AddRestoredSceneObject( |
1894 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1941 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1895 | { | 1942 | { |
1896 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1943 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1944 | if (result) | ||
1945 | sceneObject.IsDeleted = false; | ||
1946 | return result; | ||
1897 | } | 1947 | } |
1898 | 1948 | ||
1899 | /// <summary> | 1949 | /// <summary> |
@@ -1983,6 +2033,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1983 | /// </summary> | 2033 | /// </summary> |
1984 | public void DeleteAllSceneObjects() | 2034 | public void DeleteAllSceneObjects() |
1985 | { | 2035 | { |
2036 | DeleteAllSceneObjects(false); | ||
2037 | } | ||
2038 | |||
2039 | /// <summary> | ||
2040 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2041 | /// </summary> | ||
2042 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2043 | { | ||
2044 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1986 | lock (Entities) | 2045 | lock (Entities) |
1987 | { | 2046 | { |
1988 | EntityBase[] entities = Entities.GetEntities(); | 2047 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1991,11 +2050,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1991 | if (e is SceneObjectGroup) | 2050 | if (e is SceneObjectGroup) |
1992 | { | 2051 | { |
1993 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2052 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1994 | if (!sog.IsAttachment) | 2053 | if (sog != null && !sog.IsAttachment) |
1995 | DeleteSceneObject((SceneObjectGroup)e, false); | 2054 | { |
2055 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2056 | { | ||
2057 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2058 | } | ||
2059 | else | ||
2060 | { | ||
2061 | toReturn.Add((SceneObjectGroup)e); | ||
2062 | } | ||
2063 | } | ||
1996 | } | 2064 | } |
1997 | } | 2065 | } |
1998 | } | 2066 | } |
2067 | if (toReturn.Count > 0) | ||
2068 | { | ||
2069 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2070 | } | ||
1999 | } | 2071 | } |
2000 | 2072 | ||
2001 | /// <summary> | 2073 | /// <summary> |
@@ -2043,6 +2115,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2043 | } | 2115 | } |
2044 | 2116 | ||
2045 | group.DeleteGroupFromScene(silent); | 2117 | group.DeleteGroupFromScene(silent); |
2118 | if (!silent) | ||
2119 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2046 | 2120 | ||
2047 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2121 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2048 | } | 2122 | } |
@@ -2397,10 +2471,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2397 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2471 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2398 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2472 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2399 | { | 2473 | { |
2474 | if (sceneObject.OwnerID == UUID.Zero) | ||
2475 | { | ||
2476 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2477 | return false; | ||
2478 | } | ||
2479 | |||
2400 | // If the user is banned, we won't let any of their objects | 2480 | // If the user is banned, we won't let any of their objects |
2401 | // enter. Period. | 2481 | // enter. Period. |
2402 | // | 2482 | // |
2403 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2483 | int flags = GetUserFlags(sceneObject.OwnerID); |
2484 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2404 | { | 2485 | { |
2405 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2486 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2406 | "banned avatar"); | 2487 | "banned avatar"); |
@@ -2447,12 +2528,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2447 | } | 2528 | } |
2448 | else | 2529 | else |
2449 | { | 2530 | { |
2531 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2450 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2532 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2451 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2533 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2452 | } | 2534 | } |
2535 | if (sceneObject.OwnerID == UUID.Zero) | ||
2536 | { | ||
2537 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2538 | return false; | ||
2539 | } | ||
2453 | } | 2540 | } |
2454 | else | 2541 | else |
2455 | { | 2542 | { |
2543 | if (sceneObject.OwnerID == UUID.Zero) | ||
2544 | { | ||
2545 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2546 | return false; | ||
2547 | } | ||
2456 | AddRestoredSceneObject(sceneObject, true, false); | 2548 | AddRestoredSceneObject(sceneObject, true, false); |
2457 | 2549 | ||
2458 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2550 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2482,6 +2574,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2482 | return 2; // StateSource.PrimCrossing | 2574 | return 2; // StateSource.PrimCrossing |
2483 | } | 2575 | } |
2484 | 2576 | ||
2577 | public int GetUserFlags(UUID user) | ||
2578 | { | ||
2579 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2580 | /* | ||
2581 | ScenePresence sp; | ||
2582 | if (TryGetScenePresence(user, out sp)) | ||
2583 | { | ||
2584 | return sp.UserFlags; | ||
2585 | } | ||
2586 | else | ||
2587 | { | ||
2588 | */ | ||
2589 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2590 | if (uac == null) | ||
2591 | return 0; | ||
2592 | return uac.UserFlags; | ||
2593 | //} | ||
2594 | } | ||
2485 | #endregion | 2595 | #endregion |
2486 | 2596 | ||
2487 | #region Add/Remove Avatar Methods | 2597 | #region Add/Remove Avatar Methods |
@@ -2503,6 +2613,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2503 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2613 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2504 | 2614 | ||
2505 | CheckHeartbeat(); | 2615 | CheckHeartbeat(); |
2616 | ScenePresence presence; | ||
2506 | 2617 | ||
2507 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2618 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2508 | { | 2619 | { |
@@ -2538,7 +2649,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2538 | 2649 | ||
2539 | EventManager.TriggerOnNewClient(client); | 2650 | EventManager.TriggerOnNewClient(client); |
2540 | if (vialogin) | 2651 | if (vialogin) |
2652 | { | ||
2541 | EventManager.TriggerOnClientLogin(client); | 2653 | EventManager.TriggerOnClientLogin(client); |
2654 | |||
2655 | // Send initial parcel data | ||
2656 | Vector3 pos = createdSp.AbsolutePosition; | ||
2657 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2658 | land.SendLandUpdateToClient(client); | ||
2659 | } | ||
2542 | } | 2660 | } |
2543 | } | 2661 | } |
2544 | 2662 | ||
@@ -2627,19 +2745,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2627 | // and the scene presence and the client, if they exist | 2745 | // and the scene presence and the client, if they exist |
2628 | try | 2746 | try |
2629 | { | 2747 | { |
2630 | // We need to wait for the client to make UDP contact first. | 2748 | ScenePresence sp = GetScenePresence(agentID); |
2631 | // It's the UDP contact that creates the scene presence | 2749 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2632 | ScenePresence sp = WaitGetScenePresence(agentID); | 2750 | |
2633 | if (sp != null) | 2751 | if (sp != null) |
2634 | { | ||
2635 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2636 | |||
2637 | sp.ControllingClient.Close(); | 2752 | sp.ControllingClient.Close(); |
2638 | } | 2753 | |
2639 | else | ||
2640 | { | ||
2641 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2642 | } | ||
2643 | // BANG! SLASH! | 2754 | // BANG! SLASH! |
2644 | m_authenticateHandler.RemoveCircuit(agentID); | 2755 | m_authenticateHandler.RemoveCircuit(agentID); |
2645 | 2756 | ||
@@ -2739,6 +2850,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2739 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2850 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2740 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2851 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2741 | client.OnCopyInventoryItem += CopyInventoryItem; | 2852 | client.OnCopyInventoryItem += CopyInventoryItem; |
2853 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2742 | client.OnMoveInventoryItem += MoveInventoryItem; | 2854 | client.OnMoveInventoryItem += MoveInventoryItem; |
2743 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2855 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2744 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2856 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2916,15 +3028,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2916 | /// </summary> | 3028 | /// </summary> |
2917 | /// <param name="agentId">The avatar's Unique ID</param> | 3029 | /// <param name="agentId">The avatar's Unique ID</param> |
2918 | /// <param name="client">The IClientAPI for the client</param> | 3030 | /// <param name="client">The IClientAPI for the client</param> |
2919 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3031 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2920 | { | 3032 | { |
2921 | if (m_teleportModule != null) | 3033 | if (m_teleportModule != null) |
2922 | m_teleportModule.TeleportHome(agentId, client); | 3034 | return m_teleportModule.TeleportHome(agentId, client); |
2923 | else | 3035 | else |
2924 | { | 3036 | { |
2925 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3037 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2926 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3038 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2927 | } | 3039 | } |
3040 | return false; | ||
2928 | } | 3041 | } |
2929 | 3042 | ||
2930 | /// <summary> | 3043 | /// <summary> |
@@ -3016,6 +3129,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3016 | /// <param name="flags"></param> | 3129 | /// <param name="flags"></param> |
3017 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3130 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3018 | { | 3131 | { |
3132 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3133 | ScenePresence presence; | ||
3134 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3135 | { | ||
3136 | if (presence.Appearance != null) | ||
3137 | { | ||
3138 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3139 | } | ||
3140 | } | ||
3141 | |||
3019 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3142 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3020 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3143 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3021 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3144 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3084,8 +3207,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3084 | regions.Remove(RegionInfo.RegionHandle); | 3207 | regions.Remove(RegionInfo.RegionHandle); |
3085 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3208 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3086 | } | 3209 | } |
3087 | 3210 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3088 | m_eventManager.TriggerClientClosed(agentID, this); | 3211 | m_eventManager.TriggerClientClosed(agentID, this); |
3212 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3089 | } | 3213 | } |
3090 | catch (NullReferenceException) | 3214 | catch (NullReferenceException) |
3091 | { | 3215 | { |
@@ -3093,7 +3217,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3093 | // Avatar is already disposed :/ | 3217 | // Avatar is already disposed :/ |
3094 | } | 3218 | } |
3095 | 3219 | ||
3220 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3096 | m_eventManager.TriggerOnRemovePresence(agentID); | 3221 | m_eventManager.TriggerOnRemovePresence(agentID); |
3222 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3223 | |||
3224 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | ||
3225 | AttachmentsModule.SaveChangedAttachments(avatar); | ||
3097 | 3226 | ||
3098 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | 3227 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) |
3099 | AttachmentsModule.SaveChangedAttachments(avatar); | 3228 | AttachmentsModule.SaveChangedAttachments(avatar); |
@@ -3102,7 +3231,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3102 | delegate(IClientAPI client) | 3231 | delegate(IClientAPI client) |
3103 | { | 3232 | { |
3104 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3233 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3105 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3234 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3106 | catch (NullReferenceException) { } | 3235 | catch (NullReferenceException) { } |
3107 | }); | 3236 | }); |
3108 | 3237 | ||
@@ -3113,8 +3242,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3113 | } | 3242 | } |
3114 | 3243 | ||
3115 | // Remove the avatar from the scene | 3244 | // Remove the avatar from the scene |
3245 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3116 | m_sceneGraph.RemoveScenePresence(agentID); | 3246 | m_sceneGraph.RemoveScenePresence(agentID); |
3247 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3117 | m_clientManager.Remove(agentID); | 3248 | m_clientManager.Remove(agentID); |
3249 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3118 | 3250 | ||
3119 | try | 3251 | try |
3120 | { | 3252 | { |
@@ -3128,9 +3260,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3128 | { | 3260 | { |
3129 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3261 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3130 | } | 3262 | } |
3131 | 3263 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3132 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3264 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3133 | // CleanDroppedAttachments(); | 3265 | // CleanDroppedAttachments(); |
3266 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3134 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3267 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3135 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3268 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3136 | } | 3269 | } |
@@ -3161,19 +3294,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3161 | 3294 | ||
3162 | #region Entities | 3295 | #region Entities |
3163 | 3296 | ||
3164 | public void SendKillObject(uint localID) | 3297 | public void SendKillObject(List<uint> localIDs) |
3165 | { | 3298 | { |
3166 | SceneObjectPart part = GetSceneObjectPart(localID); | 3299 | List<uint> deleteIDs = new List<uint>(); |
3167 | if (part != null) // It is a prim | 3300 | |
3301 | foreach (uint localID in localIDs) | ||
3168 | { | 3302 | { |
3169 | if (!part.ParentGroup.IsDeleted) // Valid | 3303 | SceneObjectPart part = GetSceneObjectPart(localID); |
3304 | if (part != null) // It is a prim | ||
3170 | { | 3305 | { |
3171 | if (part.ParentGroup.RootPart != part) // Child part | 3306 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3172 | return; | 3307 | { |
3308 | if (part.ParentGroup.RootPart != part) // Child part | ||
3309 | continue; | ||
3310 | } | ||
3173 | } | 3311 | } |
3312 | deleteIDs.Add(localID); | ||
3174 | } | 3313 | } |
3175 | 3314 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); | |
3176 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | ||
3177 | } | 3315 | } |
3178 | 3316 | ||
3179 | #endregion | 3317 | #endregion |
@@ -3191,7 +3329,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3191 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3329 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3192 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3330 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3193 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3331 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3194 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3195 | m_sceneGridService.OnGetLandData += GetLandData; | 3332 | m_sceneGridService.OnGetLandData += GetLandData; |
3196 | } | 3333 | } |
3197 | 3334 | ||
@@ -3200,7 +3337,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3200 | /// </summary> | 3337 | /// </summary> |
3201 | public void UnRegisterRegionWithComms() | 3338 | public void UnRegisterRegionWithComms() |
3202 | { | 3339 | { |
3203 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3204 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3340 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3205 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3341 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3206 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3342 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3280,13 +3416,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3280 | sp = null; | 3416 | sp = null; |
3281 | } | 3417 | } |
3282 | 3418 | ||
3283 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3284 | 3419 | ||
3285 | //On login test land permisions | 3420 | //On login test land permisions |
3286 | if (vialogin) | 3421 | if (vialogin) |
3287 | { | 3422 | { |
3288 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3423 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3424 | if (cache != null) | ||
3425 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3426 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3289 | { | 3427 | { |
3428 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3290 | return false; | 3429 | return false; |
3291 | } | 3430 | } |
3292 | } | 3431 | } |
@@ -3309,8 +3448,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3309 | 3448 | ||
3310 | try | 3449 | try |
3311 | { | 3450 | { |
3312 | if (!AuthorizeUser(agent, out reason)) | 3451 | // Always check estate if this is a login. Always |
3313 | return false; | 3452 | // check if banned regions are to be blacked out. |
3453 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3454 | { | ||
3455 | if (!AuthorizeUser(agent, out reason)) | ||
3456 | return false; | ||
3457 | } | ||
3314 | } | 3458 | } |
3315 | catch (Exception e) | 3459 | catch (Exception e) |
3316 | { | 3460 | { |
@@ -3412,6 +3556,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3412 | } | 3556 | } |
3413 | } | 3557 | } |
3414 | // Honor parcel landing type and position. | 3558 | // Honor parcel landing type and position. |
3559 | /* | ||
3560 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3415 | if (land != null) | 3561 | if (land != null) |
3416 | { | 3562 | { |
3417 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3563 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3419,26 +3565,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3419 | agent.startpos = land.LandData.UserLocation; | 3565 | agent.startpos = land.LandData.UserLocation; |
3420 | } | 3566 | } |
3421 | } | 3567 | } |
3568 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3422 | } | 3569 | } |
3423 | 3570 | ||
3424 | return true; | 3571 | return true; |
3425 | } | 3572 | } |
3426 | 3573 | ||
3427 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3574 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3428 | { | 3575 | { |
3429 | 3576 | reason = String.Empty; | |
3430 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3577 | if (Permissions.IsGod(agentID)) |
3431 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3578 | return true; |
3579 | |||
3580 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3581 | if (land == null) | ||
3582 | return false; | ||
3583 | |||
3584 | bool banned = land.IsBannedFromLand(agentID); | ||
3585 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3432 | 3586 | ||
3433 | if (banned || restricted) | 3587 | if (banned || restricted) |
3434 | { | 3588 | { |
3435 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3589 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3436 | if (nearestParcel != null) | 3590 | if (nearestParcel != null) |
3437 | { | 3591 | { |
3438 | //Move agent to nearest allowed | 3592 | //Move agent to nearest allowed |
3439 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3593 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3440 | agent.startpos.X = newPosition.X; | 3594 | posX = newPosition.X; |
3441 | agent.startpos.Y = newPosition.Y; | 3595 | posY = newPosition.Y; |
3442 | } | 3596 | } |
3443 | else | 3597 | else |
3444 | { | 3598 | { |
@@ -3500,7 +3654,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3500 | 3654 | ||
3501 | if (!m_strictAccessControl) return true; | 3655 | if (!m_strictAccessControl) return true; |
3502 | if (Permissions.IsGod(agent.AgentID)) return true; | 3656 | if (Permissions.IsGod(agent.AgentID)) return true; |
3503 | 3657 | ||
3504 | if (AuthorizationService != null) | 3658 | if (AuthorizationService != null) |
3505 | { | 3659 | { |
3506 | if (!AuthorizationService.IsAuthorizedForRegion( | 3660 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3508,14 +3662,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3508 | { | 3662 | { |
3509 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3663 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3510 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3664 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3511 | 3665 | ||
3512 | return false; | 3666 | return false; |
3513 | } | 3667 | } |
3514 | } | 3668 | } |
3515 | 3669 | ||
3516 | if (m_regInfo.EstateSettings != null) | 3670 | if (m_regInfo.EstateSettings != null) |
3517 | { | 3671 | { |
3518 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3672 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3519 | { | 3673 | { |
3520 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3674 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3521 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3675 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3705,6 +3859,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3705 | 3859 | ||
3706 | // We have to wait until the viewer contacts this region after receiving EAC. | 3860 | // We have to wait until the viewer contacts this region after receiving EAC. |
3707 | // That calls AddNewClient, which finally creates the ScenePresence | 3861 | // That calls AddNewClient, which finally creates the ScenePresence |
3862 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3863 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3864 | { | ||
3865 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3866 | return false; | ||
3867 | } | ||
3868 | |||
3708 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3869 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3709 | if (nearestParcel == null) | 3870 | if (nearestParcel == null) |
3710 | { | 3871 | { |
@@ -3720,7 +3881,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3720 | return false; | 3881 | return false; |
3721 | } | 3882 | } |
3722 | 3883 | ||
3723 | |||
3724 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3884 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3725 | 3885 | ||
3726 | if (childAgentUpdate != null) | 3886 | if (childAgentUpdate != null) |
@@ -3787,12 +3947,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3787 | return false; | 3947 | return false; |
3788 | } | 3948 | } |
3789 | 3949 | ||
3950 | public bool IncomingCloseAgent(UUID agentID) | ||
3951 | { | ||
3952 | return IncomingCloseAgent(agentID, false); | ||
3953 | } | ||
3954 | |||
3955 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3956 | { | ||
3957 | return IncomingCloseAgent(agentID, true); | ||
3958 | } | ||
3959 | |||
3790 | /// <summary> | 3960 | /// <summary> |
3791 | /// Tell a single agent to disconnect from the region. | 3961 | /// Tell a single agent to disconnect from the region. |
3792 | /// </summary> | 3962 | /// </summary> |
3793 | /// <param name="regionHandle"></param> | ||
3794 | /// <param name="agentID"></param> | 3963 | /// <param name="agentID"></param> |
3795 | public bool IncomingCloseAgent(UUID agentID) | 3964 | /// <param name="childOnly"></param> |
3965 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3796 | { | 3966 | { |
3797 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3967 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3798 | 3968 | ||
@@ -3804,7 +3974,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3804 | { | 3974 | { |
3805 | m_sceneGraph.removeUserCount(false); | 3975 | m_sceneGraph.removeUserCount(false); |
3806 | } | 3976 | } |
3807 | else | 3977 | else if (!childOnly) |
3808 | { | 3978 | { |
3809 | m_sceneGraph.removeUserCount(true); | 3979 | m_sceneGraph.removeUserCount(true); |
3810 | } | 3980 | } |
@@ -3820,9 +3990,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3820 | } | 3990 | } |
3821 | else | 3991 | else |
3822 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3992 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3993 | presence.ControllingClient.Close(false); | ||
3994 | } | ||
3995 | else if (!childOnly) | ||
3996 | { | ||
3997 | presence.ControllingClient.Close(true); | ||
3823 | } | 3998 | } |
3824 | |||
3825 | presence.ControllingClient.Close(); | ||
3826 | return true; | 3999 | return true; |
3827 | } | 4000 | } |
3828 | 4001 | ||
@@ -4417,34 +4590,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4417 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4590 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4418 | } | 4591 | } |
4419 | 4592 | ||
4420 | public int GetHealth() | 4593 | public int GetHealth(out int flags, out string message) |
4421 | { | 4594 | { |
4422 | // Returns: | 4595 | // Returns: |
4423 | // 1 = sim is up and accepting http requests. The heartbeat has | 4596 | // 1 = sim is up and accepting http requests. The heartbeat has |
4424 | // stopped and the sim is probably locked up, but a remote | 4597 | // stopped and the sim is probably locked up, but a remote |
4425 | // admin restart may succeed | 4598 | // admin restart may succeed |
4426 | // | 4599 | // |
4427 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4600 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4428 | // usable for people within and logins _may_ work | 4601 | // usable for people within |
4429 | // | 4602 | // |
4430 | // 3 = We have seen a new user enter within the past 4 minutes | 4603 | // 3 = Sim is up and one packet thread is running. Sim is |
4604 | // unstable and will not accept new logins | ||
4605 | // | ||
4606 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4607 | // likely usable | ||
4608 | // | ||
4609 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4431 | // which can be seen as positive confirmation of sim health | 4610 | // which can be seen as positive confirmation of sim health |
4432 | // | 4611 | // |
4612 | |||
4613 | flags = 0; | ||
4614 | message = String.Empty; | ||
4615 | |||
4616 | CheckHeartbeat(); | ||
4617 | |||
4618 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4619 | { | ||
4620 | // We're still starting | ||
4621 | // 0 means "in startup", it can't happen another way, since | ||
4622 | // to get here, we must be able to accept http connections | ||
4623 | return 0; | ||
4624 | } | ||
4625 | |||
4433 | int health=1; // Start at 1, means we're up | 4626 | int health=1; // Start at 1, means we're up |
4434 | 4627 | ||
4435 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4628 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4629 | { | ||
4436 | health+=1; | 4630 | health+=1; |
4437 | else | 4631 | flags |= 1; |
4632 | } | ||
4633 | |||
4634 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4635 | { | ||
4636 | health+=1; | ||
4637 | flags |= 2; | ||
4638 | } | ||
4639 | |||
4640 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4641 | { | ||
4642 | health+=1; | ||
4643 | flags |= 4; | ||
4644 | } | ||
4645 | |||
4646 | if (flags != 7) | ||
4438 | return health; | 4647 | return health; |
4439 | 4648 | ||
4440 | // A login in the last 4 mins? We can't be doing too badly | 4649 | // A login in the last 4 mins? We can't be doing too badly |
4441 | // | 4650 | // |
4442 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4651 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4443 | health++; | 4652 | health++; |
4444 | else | ||
4445 | return health; | ||
4446 | |||
4447 | CheckHeartbeat(); | ||
4448 | 4653 | ||
4449 | return health; | 4654 | return health; |
4450 | } | 4655 | } |
@@ -4637,7 +4842,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4637 | if (m_firstHeartbeat) | 4842 | if (m_firstHeartbeat) |
4638 | return; | 4843 | return; |
4639 | 4844 | ||
4640 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4845 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4641 | StartTimer(); | 4846 | StartTimer(); |
4642 | } | 4847 | } |
4643 | 4848 | ||
@@ -5051,6 +5256,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
5051 | } | 5256 | } |
5052 | } | 5257 | } |
5053 | 5258 | ||
5259 | // public void CleanDroppedAttachments() | ||
5260 | // { | ||
5261 | // List<SceneObjectGroup> objectsToDelete = | ||
5262 | // new List<SceneObjectGroup>(); | ||
5263 | // | ||
5264 | // lock (m_cleaningAttachments) | ||
5265 | // { | ||
5266 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5267 | // { | ||
5268 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5269 | // { | ||
5270 | // UUID agentID = grp.OwnerID; | ||
5271 | // if (agentID == UUID.Zero) | ||
5272 | // { | ||
5273 | // objectsToDelete.Add(grp); | ||
5274 | // return; | ||
5275 | // } | ||
5276 | // | ||
5277 | // ScenePresence sp = GetScenePresence(agentID); | ||
5278 | // if (sp == null) | ||
5279 | // { | ||
5280 | // objectsToDelete.Add(grp); | ||
5281 | // return; | ||
5282 | // } | ||
5283 | // } | ||
5284 | // }); | ||
5285 | // } | ||
5286 | // | ||
5287 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5288 | // { | ||
5289 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5290 | // DeleteSceneObject(grp, true); | ||
5291 | // } | ||
5292 | // } | ||
5293 | |||
5294 | public void ThreadAlive(int threadCode) | ||
5295 | { | ||
5296 | switch(threadCode) | ||
5297 | { | ||
5298 | case 1: // Incoming | ||
5299 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5300 | break; | ||
5301 | case 2: // Incoming | ||
5302 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5303 | break; | ||
5304 | } | ||
5305 | } | ||
5306 | |||
5054 | // This method is called across the simulation connector to | 5307 | // This method is called across the simulation connector to |
5055 | // determine if a given agent is allowed in this region | 5308 | // determine if a given agent is allowed in this region |
5056 | // AS A ROOT AGENT. Returning false here will prevent them | 5309 | // AS A ROOT AGENT. Returning false here will prevent them |
@@ -5059,6 +5312,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5059 | // child agent creation, thereby emulating the SL behavior. | 5312 | // child agent creation, thereby emulating the SL behavior. |
5060 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5313 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5061 | { | 5314 | { |
5315 | reason = "You are banned from the region"; | ||
5316 | |||
5317 | if (Permissions.IsGod(agentID)) | ||
5318 | { | ||
5319 | reason = String.Empty; | ||
5320 | return true; | ||
5321 | } | ||
5322 | |||
5062 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5323 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5063 | 5324 | ||
5064 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5325 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5070,11 +5331,82 @@ namespace OpenSim.Region.Framework.Scenes | |||
5070 | } | 5331 | } |
5071 | } | 5332 | } |
5072 | 5333 | ||
5334 | ScenePresence presence = GetScenePresence(agentID); | ||
5335 | IClientAPI client = null; | ||
5336 | AgentCircuitData aCircuit = null; | ||
5337 | |||
5338 | if (presence != null) | ||
5339 | { | ||
5340 | client = presence.ControllingClient; | ||
5341 | if (client != null) | ||
5342 | aCircuit = client.RequestClientInfo(); | ||
5343 | } | ||
5344 | |||
5345 | // We may be called before there is a presence or a client. | ||
5346 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5347 | if (client == null) | ||
5348 | { | ||
5349 | aCircuit = new AgentCircuitData(); | ||
5350 | aCircuit.AgentID = agentID; | ||
5351 | aCircuit.firstname = String.Empty; | ||
5352 | aCircuit.lastname = String.Empty; | ||
5353 | } | ||
5354 | |||
5355 | try | ||
5356 | { | ||
5357 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5358 | { | ||
5359 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5360 | return false; | ||
5361 | } | ||
5362 | } | ||
5363 | catch (Exception e) | ||
5364 | { | ||
5365 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5366 | return false; | ||
5367 | } | ||
5368 | |||
5369 | if (position == Vector3.Zero) // Teleport | ||
5370 | { | ||
5371 | float posX = 128.0f; | ||
5372 | float posY = 128.0f; | ||
5373 | |||
5374 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5375 | { | ||
5376 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5377 | return false; | ||
5378 | } | ||
5379 | } | ||
5380 | else // Walking | ||
5381 | { | ||
5382 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5383 | if (land == null) | ||
5384 | return false; | ||
5385 | |||
5386 | bool banned = land.IsBannedFromLand(agentID); | ||
5387 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5388 | |||
5389 | if (banned || restricted) | ||
5390 | return false; | ||
5391 | } | ||
5392 | |||
5073 | reason = String.Empty; | 5393 | reason = String.Empty; |
5074 | return true; | 5394 | return true; |
5075 | } | 5395 | } |
5076 | 5396 | ||
5077 | /// <summary> | 5397 | public void StartTimerWatchdog() |
5398 | { | ||
5399 | m_timerWatchdog.Interval = 1000; | ||
5400 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5401 | m_timerWatchdog.AutoReset = true; | ||
5402 | m_timerWatchdog.Start(); | ||
5403 | } | ||
5404 | |||
5405 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5406 | { | ||
5407 | CheckHeartbeat(); | ||
5408 | } | ||
5409 | |||
5078 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5410 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5079 | /// autopilot that moves an avatar to a sit target!. | 5411 | /// autopilot that moves an avatar to a sit target!. |
5080 | /// </summary> | 5412 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index dee2ecb..73e9392 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -136,6 +136,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
136 | get { return m_permissions; } | 136 | get { return m_permissions; } |
137 | } | 137 | } |
138 | 138 | ||
139 | protected string m_datastore; | ||
140 | |||
139 | /* Used by the loadbalancer plugin on GForge */ | 141 | /* Used by the loadbalancer plugin on GForge */ |
140 | protected RegionStatus m_regStatus; | 142 | protected RegionStatus m_regStatus; |
141 | public RegionStatus RegionStatus | 143 | public RegionStatus RegionStatus |
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 7cffa70..fe9fe31 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -44,8 +44,6 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
44 | 44 | ||
45 | namespace OpenSim.Region.Framework.Scenes | 45 | namespace OpenSim.Region.Framework.Scenes |
46 | { | 46 | { |
47 | public delegate void KiPrimitiveDelegate(uint localID); | ||
48 | |||
49 | public delegate void RemoveKnownRegionsFromAvatarList(UUID avatarID, List<ulong> regionlst); | 47 | public delegate void RemoveKnownRegionsFromAvatarList(UUID avatarID, List<ulong> regionlst); |
50 | 48 | ||
51 | /// <summary> | 49 | /// <summary> |
@@ -113,8 +111,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
113 | // private LogOffUser handlerLogOffUser = null; | 111 | // private LogOffUser handlerLogOffUser = null; |
114 | // private GetLandData handlerGetLandData = null; // OnGetLandData | 112 | // private GetLandData handlerGetLandData = null; // OnGetLandData |
115 | 113 | ||
116 | public KiPrimitiveDelegate KiPrimitive; | ||
117 | |||
118 | public SceneCommunicationService() | 114 | public SceneCommunicationService() |
119 | { | 115 | { |
120 | } | 116 | } |
@@ -168,7 +164,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
168 | 164 | ||
169 | if (neighbour != null) | 165 | if (neighbour != null) |
170 | { | 166 | { |
171 | m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize); | 167 | // m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize); |
172 | m_scene.EventManager.TriggerOnRegionUp(neighbour); | 168 | m_scene.EventManager.TriggerOnRegionUp(neighbour); |
173 | } | 169 | } |
174 | else | 170 | else |
@@ -183,7 +179,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
183 | //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); | 179 | //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); |
184 | 180 | ||
185 | List<GridRegion> neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); | 181 | List<GridRegion> neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); |
186 | m_log.DebugFormat("[INTERGRID]: Informing {0} neighbours that this region is up", neighbours.Count); | 182 | //m_log.DebugFormat("[INTERGRID]: Informing {0} neighbours that this region is up", neighbours.Count); |
187 | foreach (GridRegion n in neighbours) | 183 | foreach (GridRegion n in neighbours) |
188 | { | 184 | { |
189 | InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; | 185 | InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; |
@@ -259,46 +255,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
259 | 255 | ||
260 | } | 256 | } |
261 | 257 | ||
262 | //public delegate void SendCloseChildAgentDelegate(UUID agentID, ulong regionHandle); | 258 | public delegate void SendCloseChildAgentDelegate(UUID agentID, ulong regionHandle); |
263 | //private void SendCloseChildAgentCompleted(IAsyncResult iar) | ||
264 | //{ | ||
265 | // SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate)iar.AsyncState; | ||
266 | // icon.EndInvoke(iar); | ||
267 | //} | ||
268 | 259 | ||
269 | /// <summary> | 260 | /// <summary> |
270 | /// Closes a child agent on a given region | 261 | /// This Closes child agents on neighboring regions |
262 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | ||
271 | /// </summary> | 263 | /// </summary> |
272 | protected void SendCloseChildAgent(UUID agentID, ulong regionHandle) | 264 | protected void SendCloseChildAgentAsync(UUID agentID, ulong regionHandle) |
273 | { | 265 | { |
274 | 266 | ||
275 | m_log.Debug("[INTERGRID]: Sending close agent to " + regionHandle); | 267 | //m_log.Debug("[INTERGRID]: Sending close agent to " + regionHandle); |
276 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. | 268 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. |
277 | 269 | ||
278 | //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); | 270 | //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); |
279 | uint x = 0, y = 0; | 271 | uint x = 0, y = 0; |
280 | Utils.LongToUInts(regionHandle, out x, out y); | 272 | Utils.LongToUInts(regionHandle, out x, out y); |
281 | GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); | 273 | GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); |
282 | m_scene.SimulationService.CloseAgent(destination, agentID); | 274 | m_scene.SimulationService.CloseChildAgent(destination, agentID); |
275 | } | ||
276 | |||
277 | private void SendCloseChildAgentCompleted(IAsyncResult iar) | ||
278 | { | ||
279 | SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate)iar.AsyncState; | ||
280 | icon.EndInvoke(iar); | ||
283 | } | 281 | } |
284 | 282 | ||
285 | /// <summary> | ||
286 | /// Closes a child agents in a collection of regions. Does so asynchronously | ||
287 | /// so that the caller doesn't wait. | ||
288 | /// </summary> | ||
289 | /// <param name="agentID"></param> | ||
290 | /// <param name="regionslst"></param> | ||
291 | public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst) | 283 | public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst) |
292 | { | 284 | { |
293 | Util.FireAndForget(delegate | 285 | foreach (ulong handle in regionslst) |
294 | { | 286 | { |
295 | foreach (ulong handle in regionslst) | 287 | SendCloseChildAgentDelegate d = SendCloseChildAgentAsync; |
296 | { | 288 | d.BeginInvoke(agentID, handle, |
297 | SendCloseChildAgent(agentID, handle); | 289 | SendCloseChildAgentCompleted, |
298 | } | 290 | d); |
299 | }); | 291 | } |
300 | } | 292 | } |
301 | 293 | ||
302 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) | 294 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) |
303 | { | 295 | { |
304 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); | 296 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b2e5dc3..d780fb3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -43,6 +43,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
43 | 43 | ||
44 | public delegate void ObjectDuplicateDelegate(EntityBase original, EntityBase clone); | 44 | public delegate void ObjectDuplicateDelegate(EntityBase original, EntityBase clone); |
45 | 45 | ||
46 | public delegate void AttachToBackupDelegate(SceneObjectGroup sog); | ||
47 | |||
48 | public delegate void DetachFromBackupDelegate(SceneObjectGroup sog); | ||
49 | |||
50 | public delegate void ChangedBackupDelegate(SceneObjectGroup sog); | ||
51 | |||
46 | public delegate void ObjectCreateDelegate(EntityBase obj); | 52 | public delegate void ObjectCreateDelegate(EntityBase obj); |
47 | 53 | ||
48 | public delegate void ObjectDeleteDelegate(EntityBase obj); | 54 | public delegate void ObjectDeleteDelegate(EntityBase obj); |
@@ -61,6 +67,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
61 | private PhysicsCrash handlerPhysicsCrash = null; | 67 | private PhysicsCrash handlerPhysicsCrash = null; |
62 | 68 | ||
63 | public event ObjectDuplicateDelegate OnObjectDuplicate; | 69 | public event ObjectDuplicateDelegate OnObjectDuplicate; |
70 | public event AttachToBackupDelegate OnAttachToBackup; | ||
71 | public event DetachFromBackupDelegate OnDetachFromBackup; | ||
72 | public event ChangedBackupDelegate OnChangeBackup; | ||
64 | public event ObjectCreateDelegate OnObjectCreate; | 73 | public event ObjectCreateDelegate OnObjectCreate; |
65 | public event ObjectDeleteDelegate OnObjectRemove; | 74 | public event ObjectDeleteDelegate OnObjectRemove; |
66 | 75 | ||
@@ -68,7 +77,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
68 | 77 | ||
69 | #region Fields | 78 | #region Fields |
70 | 79 | ||
71 | protected object m_presenceLock = new object(); | 80 | protected OpenMetaverse.ReaderWriterLockSlim m_scenePresencesLock = new OpenMetaverse.ReaderWriterLockSlim(); |
72 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); | 81 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); |
73 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); | 82 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); |
74 | 83 | ||
@@ -130,13 +139,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
130 | 139 | ||
131 | protected internal void Close() | 140 | protected internal void Close() |
132 | { | 141 | { |
133 | lock (m_presenceLock) | 142 | m_scenePresencesLock.EnterWriteLock(); |
143 | try | ||
134 | { | 144 | { |
135 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); | 145 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); |
136 | List<ScenePresence> newlist = new List<ScenePresence>(); | 146 | List<ScenePresence> newlist = new List<ScenePresence>(); |
137 | m_scenePresenceMap = newmap; | 147 | m_scenePresenceMap = newmap; |
138 | m_scenePresenceArray = newlist; | 148 | m_scenePresenceArray = newlist; |
139 | } | 149 | } |
150 | finally | ||
151 | { | ||
152 | m_scenePresencesLock.ExitWriteLock(); | ||
153 | } | ||
140 | 154 | ||
141 | lock (SceneObjectGroupsByFullID) | 155 | lock (SceneObjectGroupsByFullID) |
142 | SceneObjectGroupsByFullID.Clear(); | 156 | SceneObjectGroupsByFullID.Clear(); |
@@ -275,6 +289,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
275 | protected internal bool AddRestoredSceneObject( | 289 | protected internal bool AddRestoredSceneObject( |
276 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 290 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
277 | { | 291 | { |
292 | if (!m_parentScene.CombineRegions) | ||
293 | { | ||
294 | // KF: Check for out-of-region, move inside and make static. | ||
295 | Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, | ||
296 | sceneObject.RootPart.GroupPosition.Y, | ||
297 | sceneObject.RootPart.GroupPosition.Z); | ||
298 | if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || | ||
299 | npos.X > Constants.RegionSize || | ||
300 | npos.Y > Constants.RegionSize)) | ||
301 | { | ||
302 | if (npos.X < 0.0) npos.X = 1.0f; | ||
303 | if (npos.Y < 0.0) npos.Y = 1.0f; | ||
304 | if (npos.Z < 0.0) npos.Z = 0.0f; | ||
305 | if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; | ||
306 | if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; | ||
307 | |||
308 | foreach (SceneObjectPart part in sceneObject.Parts) | ||
309 | { | ||
310 | part.GroupPosition = npos; | ||
311 | } | ||
312 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
313 | sceneObject.RootPart.AngularVelocity = Vector3.Zero; | ||
314 | sceneObject.RootPart.Acceleration = Vector3.Zero; | ||
315 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
316 | } | ||
317 | } | ||
318 | |||
278 | if (attachToBackup && (!alreadyPersisted)) | 319 | if (attachToBackup && (!alreadyPersisted)) |
279 | { | 320 | { |
280 | sceneObject.ForceInventoryPersistence(); | 321 | sceneObject.ForceInventoryPersistence(); |
@@ -492,6 +533,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
492 | m_updateList[obj.UUID] = obj; | 533 | m_updateList[obj.UUID] = obj; |
493 | } | 534 | } |
494 | 535 | ||
536 | public void FireAttachToBackup(SceneObjectGroup obj) | ||
537 | { | ||
538 | if (OnAttachToBackup != null) | ||
539 | { | ||
540 | OnAttachToBackup(obj); | ||
541 | } | ||
542 | } | ||
543 | |||
544 | public void FireDetachFromBackup(SceneObjectGroup obj) | ||
545 | { | ||
546 | if (OnDetachFromBackup != null) | ||
547 | { | ||
548 | OnDetachFromBackup(obj); | ||
549 | } | ||
550 | } | ||
551 | |||
552 | public void FireChangeBackup(SceneObjectGroup obj) | ||
553 | { | ||
554 | if (OnChangeBackup != null) | ||
555 | { | ||
556 | OnChangeBackup(obj); | ||
557 | } | ||
558 | } | ||
559 | |||
495 | /// <summary> | 560 | /// <summary> |
496 | /// Process all pending updates | 561 | /// Process all pending updates |
497 | /// </summary> | 562 | /// </summary> |
@@ -623,7 +688,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
623 | 688 | ||
624 | Entities[presence.UUID] = presence; | 689 | Entities[presence.UUID] = presence; |
625 | 690 | ||
626 | lock (m_presenceLock) | 691 | m_scenePresencesLock.EnterWriteLock(); |
692 | try | ||
627 | { | 693 | { |
628 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 694 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
629 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 695 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -647,6 +713,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
647 | m_scenePresenceMap = newmap; | 713 | m_scenePresenceMap = newmap; |
648 | m_scenePresenceArray = newlist; | 714 | m_scenePresenceArray = newlist; |
649 | } | 715 | } |
716 | finally | ||
717 | { | ||
718 | m_scenePresencesLock.ExitWriteLock(); | ||
719 | } | ||
650 | } | 720 | } |
651 | 721 | ||
652 | /// <summary> | 722 | /// <summary> |
@@ -661,7 +731,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
661 | agentID); | 731 | agentID); |
662 | } | 732 | } |
663 | 733 | ||
664 | lock (m_presenceLock) | 734 | m_scenePresencesLock.EnterWriteLock(); |
735 | try | ||
665 | { | 736 | { |
666 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 737 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
667 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 738 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -683,6 +754,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
683 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); | 754 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); |
684 | } | 755 | } |
685 | } | 756 | } |
757 | finally | ||
758 | { | ||
759 | m_scenePresencesLock.ExitWriteLock(); | ||
760 | } | ||
686 | } | 761 | } |
687 | 762 | ||
688 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) | 763 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) |
@@ -1396,8 +1471,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1396 | { | 1471 | { |
1397 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) | 1472 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) |
1398 | { | 1473 | { |
1399 | if (m_parentScene.AttachmentsModule != null) | 1474 | // Set the new attachment point data in the object |
1400 | m_parentScene.AttachmentsModule.UpdateAttachmentPosition(group, pos); | 1475 | byte attachmentPoint = group.GetAttachmentPoint(); |
1476 | group.UpdateGroupPosition(pos); | ||
1477 | group.IsAttachment = false; | ||
1478 | group.AbsolutePosition = group.RootPart.AttachedPos; | ||
1479 | group.AttachmentPoint = attachmentPoint; | ||
1480 | group.HasGroupChanged = true; | ||
1401 | } | 1481 | } |
1402 | else | 1482 | else |
1403 | { | 1483 | { |
@@ -1661,10 +1741,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1661 | /// <param name="childPrims"></param> | 1741 | /// <param name="childPrims"></param> |
1662 | protected internal void LinkObjects(SceneObjectPart root, List<SceneObjectPart> children) | 1742 | protected internal void LinkObjects(SceneObjectPart root, List<SceneObjectPart> children) |
1663 | { | 1743 | { |
1744 | SceneObjectGroup parentGroup = root.ParentGroup; | ||
1745 | if (parentGroup == null) return; | ||
1664 | Monitor.Enter(m_updateLock); | 1746 | Monitor.Enter(m_updateLock); |
1747 | |||
1665 | try | 1748 | try |
1666 | { | 1749 | { |
1667 | SceneObjectGroup parentGroup = root.ParentGroup; | 1750 | parentGroup.areUpdatesSuspended = true; |
1668 | 1751 | ||
1669 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); | 1752 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); |
1670 | 1753 | ||
@@ -1676,9 +1759,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1676 | // Make sure no child prim is set for sale | 1759 | // Make sure no child prim is set for sale |
1677 | // So that, on delink, no prims are unwittingly | 1760 | // So that, on delink, no prims are unwittingly |
1678 | // left for sale and sold off | 1761 | // left for sale and sold off |
1679 | child.RootPart.ObjectSaleType = 0; | 1762 | |
1680 | child.RootPart.SalePrice = 10; | 1763 | if (child != null) |
1681 | childGroups.Add(child); | 1764 | { |
1765 | child.RootPart.ObjectSaleType = 0; | ||
1766 | child.RootPart.SalePrice = 10; | ||
1767 | childGroups.Add(child); | ||
1768 | } | ||
1682 | } | 1769 | } |
1683 | 1770 | ||
1684 | foreach (SceneObjectGroup child in childGroups) | 1771 | foreach (SceneObjectGroup child in childGroups) |
@@ -1694,12 +1781,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1694 | // occur on link to invoke this elsewhere (such as object selection) | 1781 | // occur on link to invoke this elsewhere (such as object selection) |
1695 | parentGroup.RootPart.CreateSelected = true; | 1782 | parentGroup.RootPart.CreateSelected = true; |
1696 | parentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1783 | parentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1697 | parentGroup.HasGroupChanged = true; | ||
1698 | parentGroup.ScheduleGroupForFullUpdate(); | ||
1699 | |||
1700 | } | 1784 | } |
1701 | finally | 1785 | finally |
1702 | { | 1786 | { |
1787 | lock (SceneObjectGroupsByLocalPartID) | ||
1788 | { | ||
1789 | foreach (SceneObjectPart part in parentGroup.Parts) | ||
1790 | SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; | ||
1791 | } | ||
1792 | |||
1793 | parentGroup.areUpdatesSuspended = false; | ||
1794 | parentGroup.HasGroupChanged = true; | ||
1795 | parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); | ||
1796 | parentGroup.ScheduleGroupForFullUpdate(); | ||
1703 | Monitor.Exit(m_updateLock); | 1797 | Monitor.Exit(m_updateLock); |
1704 | } | 1798 | } |
1705 | } | 1799 | } |
@@ -1731,21 +1825,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1731 | 1825 | ||
1732 | SceneObjectGroup group = part.ParentGroup; | 1826 | SceneObjectGroup group = part.ParentGroup; |
1733 | if (!affectedGroups.Contains(group)) | 1827 | if (!affectedGroups.Contains(group)) |
1828 | { | ||
1829 | group.areUpdatesSuspended = true; | ||
1734 | affectedGroups.Add(group); | 1830 | affectedGroups.Add(group); |
1831 | } | ||
1735 | } | 1832 | } |
1736 | } | 1833 | } |
1737 | } | 1834 | } |
1738 | 1835 | ||
1739 | foreach (SceneObjectPart child in childParts) | 1836 | if (childParts.Count > 0) |
1740 | { | 1837 | { |
1741 | // Unlink all child parts from their groups | 1838 | foreach (SceneObjectPart child in childParts) |
1742 | // | 1839 | { |
1743 | child.ParentGroup.DelinkFromGroup(child, true); | 1840 | // Unlink all child parts from their groups |
1744 | 1841 | // | |
1745 | // These are not in affected groups and will not be | 1842 | child.ParentGroup.DelinkFromGroup(child, true); |
1746 | // handled further. Do the honors here. | 1843 | child.ParentGroup.HasGroupChanged = true; |
1747 | child.ParentGroup.HasGroupChanged = true; | 1844 | child.ParentGroup.ScheduleGroupForFullUpdate(); |
1748 | child.ParentGroup.ScheduleGroupForFullUpdate(); | 1845 | } |
1749 | } | 1846 | } |
1750 | 1847 | ||
1751 | foreach (SceneObjectPart root in rootParts) | 1848 | foreach (SceneObjectPart root in rootParts) |
@@ -1755,56 +1852,68 @@ namespace OpenSim.Region.Framework.Scenes | |||
1755 | // However, editing linked parts and unlinking may be different | 1852 | // However, editing linked parts and unlinking may be different |
1756 | // | 1853 | // |
1757 | SceneObjectGroup group = root.ParentGroup; | 1854 | SceneObjectGroup group = root.ParentGroup; |
1855 | group.areUpdatesSuspended = true; | ||
1758 | 1856 | ||
1759 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); | 1857 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); |
1760 | int numChildren = newSet.Count; | 1858 | int numChildren = newSet.Count; |
1761 | 1859 | ||
1860 | if (numChildren == 1) | ||
1861 | break; | ||
1862 | |||
1762 | // If there are prims left in a link set, but the root is | 1863 | // If there are prims left in a link set, but the root is |
1763 | // slated for unlink, we need to do this | 1864 | // slated for unlink, we need to do this |
1865 | // Unlink the remaining set | ||
1764 | // | 1866 | // |
1765 | if (numChildren != 1) | 1867 | bool sendEventsToRemainder = true; |
1766 | { | 1868 | if (numChildren > 1) |
1767 | // Unlink the remaining set | 1869 | sendEventsToRemainder = false; |
1768 | // | ||
1769 | bool sendEventsToRemainder = true; | ||
1770 | if (numChildren > 1) | ||
1771 | sendEventsToRemainder = false; | ||
1772 | 1870 | ||
1773 | foreach (SceneObjectPart p in newSet) | 1871 | foreach (SceneObjectPart p in newSet) |
1872 | { | ||
1873 | if (p != group.RootPart) | ||
1774 | { | 1874 | { |
1775 | if (p != group.RootPart) | 1875 | group.DelinkFromGroup(p, sendEventsToRemainder); |
1776 | group.DelinkFromGroup(p, sendEventsToRemainder); | 1876 | if (numChildren > 2) |
1877 | { | ||
1878 | p.ParentGroup.areUpdatesSuspended = true; | ||
1879 | } | ||
1880 | else | ||
1881 | { | ||
1882 | p.ParentGroup.HasGroupChanged = true; | ||
1883 | p.ParentGroup.ScheduleGroupForFullUpdate(); | ||
1884 | } | ||
1777 | } | 1885 | } |
1886 | } | ||
1887 | |||
1888 | // If there is more than one prim remaining, we | ||
1889 | // need to re-link | ||
1890 | // | ||
1891 | if (numChildren > 2) | ||
1892 | { | ||
1893 | // Remove old root | ||
1894 | // | ||
1895 | if (newSet.Contains(root)) | ||
1896 | newSet.Remove(root); | ||
1778 | 1897 | ||
1779 | // If there is more than one prim remaining, we | 1898 | // Preserve link ordering |
1780 | // need to re-link | ||
1781 | // | 1899 | // |
1782 | if (numChildren > 2) | 1900 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) |
1783 | { | 1901 | { |
1784 | // Remove old root | 1902 | return a.LinkNum.CompareTo(b.LinkNum); |
1785 | // | 1903 | }); |
1786 | if (newSet.Contains(root)) | ||
1787 | newSet.Remove(root); | ||
1788 | |||
1789 | // Preserve link ordering | ||
1790 | // | ||
1791 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) | ||
1792 | { | ||
1793 | return a.LinkNum.CompareTo(b.LinkNum); | ||
1794 | }); | ||
1795 | 1904 | ||
1796 | // Determine new root | 1905 | // Determine new root |
1797 | // | 1906 | // |
1798 | SceneObjectPart newRoot = newSet[0]; | 1907 | SceneObjectPart newRoot = newSet[0]; |
1799 | newSet.RemoveAt(0); | 1908 | newSet.RemoveAt(0); |
1800 | 1909 | ||
1801 | foreach (SceneObjectPart newChild in newSet) | 1910 | foreach (SceneObjectPart newChild in newSet) |
1802 | newChild.ClearUpdateSchedule(); | 1911 | newChild.ClearUpdateSchedule(); |
1803 | 1912 | ||
1804 | LinkObjects(newRoot, newSet); | 1913 | newRoot.ParentGroup.areUpdatesSuspended = true; |
1805 | if (!affectedGroups.Contains(newRoot.ParentGroup)) | 1914 | LinkObjects(newRoot, newSet); |
1806 | affectedGroups.Add(newRoot.ParentGroup); | 1915 | if (!affectedGroups.Contains(newRoot.ParentGroup)) |
1807 | } | 1916 | affectedGroups.Add(newRoot.ParentGroup); |
1808 | } | 1917 | } |
1809 | } | 1918 | } |
1810 | 1919 | ||
@@ -1812,8 +1921,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1812 | // | 1921 | // |
1813 | foreach (SceneObjectGroup g in affectedGroups) | 1922 | foreach (SceneObjectGroup g in affectedGroups) |
1814 | { | 1923 | { |
1924 | // Child prims that have been unlinked and deleted will | ||
1925 | // return unless the root is deleted. This will remove them | ||
1926 | // from the database. They will be rewritten immediately, | ||
1927 | // minus the rows for the unlinked child prims. | ||
1928 | m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); | ||
1815 | g.TriggerScriptChangedEvent(Changed.LINK); | 1929 | g.TriggerScriptChangedEvent(Changed.LINK); |
1816 | g.HasGroupChanged = true; // Persist | 1930 | g.HasGroupChanged = true; // Persist |
1931 | g.areUpdatesSuspended = false; | ||
1817 | g.ScheduleGroupForFullUpdate(); | 1932 | g.ScheduleGroupForFullUpdate(); |
1818 | } | 1933 | } |
1819 | } | 1934 | } |
@@ -1931,9 +2046,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1931 | child.ApplyNextOwnerPermissions(); | 2046 | child.ApplyNextOwnerPermissions(); |
1932 | } | 2047 | } |
1933 | } | 2048 | } |
1934 | |||
1935 | copy.RootPart.ObjectSaleType = 0; | ||
1936 | copy.RootPart.SalePrice = 10; | ||
1937 | } | 2049 | } |
1938 | 2050 | ||
1939 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() | 2051 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 905ecc9..6bd9183 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -69,10 +69,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
69 | /// <summary> | 69 | /// <summary> |
70 | /// Stop the scripts contained in all the prims in this group | 70 | /// Stop the scripts contained in all the prims in this group |
71 | /// </summary> | 71 | /// </summary> |
72 | /// <param name="sceneObjectBeingDeleted"> | ||
73 | /// Should be true if these scripts are being removed because the scene | ||
74 | /// object is being deleted. This will prevent spurious updates to the client. | ||
75 | /// </param> | ||
76 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 72 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
77 | { | 73 | { |
78 | SceneObjectPart[] parts = m_parts.GetArray(); | 74 | SceneObjectPart[] parts = m_parts.GetArray(); |
@@ -385,6 +381,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
385 | 381 | ||
386 | public void ResumeScripts() | 382 | public void ResumeScripts() |
387 | { | 383 | { |
384 | if (m_scene.RegionInfo.RegionSettings.DisableScripts) | ||
385 | return; | ||
386 | |||
388 | SceneObjectPart[] parts = m_parts.GetArray(); | 387 | SceneObjectPart[] parts = m_parts.GetArray(); |
389 | for (int i = 0; i < parts.Length; i++) | 388 | for (int i = 0; i < parts.Length; i++) |
390 | parts[i].Inventory.ResumeScripts(); | 389 | parts[i].Inventory.ResumeScripts(); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3f4e112..6e20f90 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -24,11 +24,12 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Drawing; | 30 | using System.Drawing; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Diagnostics; | ||
32 | using System.Linq; | 33 | using System.Linq; |
33 | using System.Threading; | 34 | using System.Threading; |
34 | using System.Xml; | 35 | using System.Xml; |
@@ -105,8 +106,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
105 | /// since the group's last persistent backup | 106 | /// since the group's last persistent backup |
106 | /// </summary> | 107 | /// </summary> |
107 | private bool m_hasGroupChanged = false; | 108 | private bool m_hasGroupChanged = false; |
108 | private long timeFirstChanged; | 109 | private long timeFirstChanged = 0; |
109 | private long timeLastChanged; | 110 | private long timeLastChanged = 0; |
111 | private long m_maxPersistTime = 0; | ||
112 | private long m_minPersistTime = 0; | ||
113 | private Random m_rand; | ||
114 | private bool m_suspendUpdates; | ||
115 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); | ||
116 | |||
117 | public bool areUpdatesSuspended | ||
118 | { | ||
119 | get | ||
120 | { | ||
121 | return m_suspendUpdates; | ||
122 | } | ||
123 | set | ||
124 | { | ||
125 | m_suspendUpdates = value; | ||
126 | if (!value) | ||
127 | { | ||
128 | QueueForUpdateCheck(); | ||
129 | } | ||
130 | } | ||
131 | } | ||
110 | 132 | ||
111 | public bool HasGroupChanged | 133 | public bool HasGroupChanged |
112 | { | 134 | { |
@@ -114,9 +136,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
114 | { | 136 | { |
115 | if (value) | 137 | if (value) |
116 | { | 138 | { |
139 | if (m_isBackedUp) | ||
140 | { | ||
141 | m_scene.SceneGraph.FireChangeBackup(this); | ||
142 | } | ||
117 | timeLastChanged = DateTime.Now.Ticks; | 143 | timeLastChanged = DateTime.Now.Ticks; |
118 | if (!m_hasGroupChanged) | 144 | if (!m_hasGroupChanged) |
119 | timeFirstChanged = DateTime.Now.Ticks; | 145 | timeFirstChanged = DateTime.Now.Ticks; |
146 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | ||
147 | { | ||
148 | if (m_rand == null) | ||
149 | { | ||
150 | byte[] val = new byte[16]; | ||
151 | m_rootPart.UUID.ToBytes(val, 0); | ||
152 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
153 | } | ||
154 | |||
155 | if (m_scene.GetRootAgentCount() == 0) | ||
156 | { | ||
157 | //If the region is empty, this change has been made by an automated process | ||
158 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
159 | |||
160 | float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
161 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); | ||
162 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); | ||
163 | } | ||
164 | else | ||
165 | { | ||
166 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
167 | //but add a random factor so we stagger the object persistance a little | ||
168 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
169 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
170 | } | ||
171 | } | ||
120 | } | 172 | } |
121 | m_hasGroupChanged = value; | 173 | m_hasGroupChanged = value; |
122 | 174 | ||
@@ -131,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
131 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since | 183 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since |
132 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. | 184 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. |
133 | /// </summary> | 185 | /// </summary> |
134 | public bool HasGroupChangedDueToDelink { get; private set; } | 186 | public bool HasGroupChangedDueToDelink { get; set; } |
135 | 187 | ||
136 | private bool isTimeToPersist() | 188 | private bool isTimeToPersist() |
137 | { | 189 | { |
@@ -141,8 +193,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
141 | return false; | 193 | return false; |
142 | if (m_scene.ShuttingDown) | 194 | if (m_scene.ShuttingDown) |
143 | return true; | 195 | return true; |
196 | |||
197 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
198 | { | ||
199 | m_maxPersistTime = m_scene.m_persistAfter; | ||
200 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
201 | } | ||
202 | |||
144 | long currentTime = DateTime.Now.Ticks; | 203 | long currentTime = DateTime.Now.Ticks; |
145 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 204 | |
205 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
206 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
207 | |||
208 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
146 | return true; | 209 | return true; |
147 | return false; | 210 | return false; |
148 | } | 211 | } |
@@ -247,10 +310,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
247 | 310 | ||
248 | private bool m_scriptListens_atTarget; | 311 | private bool m_scriptListens_atTarget; |
249 | private bool m_scriptListens_notAtTarget; | 312 | private bool m_scriptListens_notAtTarget; |
250 | |||
251 | private bool m_scriptListens_atRotTarget; | 313 | private bool m_scriptListens_atRotTarget; |
252 | private bool m_scriptListens_notAtRotTarget; | 314 | private bool m_scriptListens_notAtRotTarget; |
253 | 315 | ||
316 | public bool m_dupeInProgress = false; | ||
254 | internal Dictionary<UUID, string> m_savedScriptState; | 317 | internal Dictionary<UUID, string> m_savedScriptState; |
255 | 318 | ||
256 | #region Properties | 319 | #region Properties |
@@ -281,6 +344,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
281 | get { return m_parts.Count; } | 344 | get { return m_parts.Count; } |
282 | } | 345 | } |
283 | 346 | ||
347 | // protected Quaternion m_rotation = Quaternion.Identity; | ||
348 | // | ||
349 | // public virtual Quaternion Rotation | ||
350 | // { | ||
351 | // get { return m_rotation; } | ||
352 | // set { | ||
353 | // m_rotation = value; | ||
354 | // } | ||
355 | // } | ||
356 | |||
284 | public Quaternion GroupRotation | 357 | public Quaternion GroupRotation |
285 | { | 358 | { |
286 | get { return m_rootPart.RotationOffset; } | 359 | get { return m_rootPart.RotationOffset; } |
@@ -389,7 +462,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
389 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | 462 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); |
390 | } | 463 | } |
391 | } | 464 | } |
392 | 465 | ||
466 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
467 | { | ||
468 | part.IgnoreUndoUpdate = true; | ||
469 | } | ||
393 | if (RootPart.GetStatusSandbox()) | 470 | if (RootPart.GetStatusSandbox()) |
394 | { | 471 | { |
395 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) | 472 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) |
@@ -403,10 +480,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
403 | return; | 480 | return; |
404 | } | 481 | } |
405 | } | 482 | } |
406 | |||
407 | SceneObjectPart[] parts = m_parts.GetArray(); | 483 | SceneObjectPart[] parts = m_parts.GetArray(); |
408 | for (int i = 0; i < parts.Length; i++) | 484 | foreach (SceneObjectPart part in parts) |
409 | parts[i].GroupPosition = val; | 485 | { |
486 | part.GroupPosition = val; | ||
487 | if (!m_dupeInProgress) | ||
488 | { | ||
489 | part.TriggerScriptChangedEvent(Changed.POSITION); | ||
490 | } | ||
491 | } | ||
492 | if (!m_dupeInProgress) | ||
493 | { | ||
494 | foreach (ScenePresence av in m_linkedAvatars) | ||
495 | { | ||
496 | SceneObjectPart p = m_scene.GetSceneObjectPart(av.ParentID); | ||
497 | if (m_parts.TryGetValue(p.UUID, out p)) | ||
498 | { | ||
499 | Vector3 offset = p.GetWorldPosition() - av.ParentPosition; | ||
500 | av.AbsolutePosition += offset; | ||
501 | av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition | ||
502 | av.SendAvatarDataToAllAgents(); | ||
503 | } | ||
504 | } | ||
505 | } | ||
410 | 506 | ||
411 | //if (m_rootPart.PhysActor != null) | 507 | //if (m_rootPart.PhysActor != null) |
412 | //{ | 508 | //{ |
@@ -565,6 +661,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
565 | /// </summary> | 661 | /// </summary> |
566 | public SceneObjectGroup() | 662 | public SceneObjectGroup() |
567 | { | 663 | { |
664 | |||
568 | } | 665 | } |
569 | 666 | ||
570 | /// <summary> | 667 | /// <summary> |
@@ -581,7 +678,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
581 | /// Constructor. This object is added to the scene later via AttachToScene() | 678 | /// Constructor. This object is added to the scene later via AttachToScene() |
582 | /// </summary> | 679 | /// </summary> |
583 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 680 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
584 | { | 681 | { |
585 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); | 682 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
586 | } | 683 | } |
587 | 684 | ||
@@ -629,6 +726,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
629 | /// </summary> | 726 | /// </summary> |
630 | public virtual void AttachToBackup() | 727 | public virtual void AttachToBackup() |
631 | { | 728 | { |
729 | if (IsAttachment) return; | ||
730 | m_scene.SceneGraph.FireAttachToBackup(this); | ||
731 | |||
632 | if (InSceneBackup) | 732 | if (InSceneBackup) |
633 | { | 733 | { |
634 | //m_log.DebugFormat( | 734 | //m_log.DebugFormat( |
@@ -671,6 +771,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
671 | 771 | ||
672 | ApplyPhysics(m_scene.m_physicalPrim); | 772 | ApplyPhysics(m_scene.m_physicalPrim); |
673 | 773 | ||
774 | if (RootPart.PhysActor != null) | ||
775 | RootPart.Buoyancy = RootPart.Buoyancy; | ||
776 | |||
674 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | 777 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
675 | // for the same object with very different properties. The caller must schedule the update. | 778 | // for the same object with very different properties. The caller must schedule the update. |
676 | //ScheduleGroupForFullUpdate(); | 779 | //ScheduleGroupForFullUpdate(); |
@@ -716,9 +819,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
716 | result.normal = inter.normal; | 819 | result.normal = inter.normal; |
717 | result.distance = inter.distance; | 820 | result.distance = inter.distance; |
718 | } | 821 | } |
822 | |||
719 | } | 823 | } |
720 | } | 824 | } |
721 | |||
722 | return result; | 825 | return result; |
723 | } | 826 | } |
724 | 827 | ||
@@ -738,17 +841,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
738 | minZ = 8192f; | 841 | minZ = 8192f; |
739 | 842 | ||
740 | SceneObjectPart[] parts = m_parts.GetArray(); | 843 | SceneObjectPart[] parts = m_parts.GetArray(); |
741 | for (int i = 0; i < parts.Length; i++) | 844 | foreach (SceneObjectPart part in parts) |
742 | { | 845 | { |
743 | SceneObjectPart part = parts[i]; | ||
744 | |||
745 | Vector3 worldPos = part.GetWorldPosition(); | 846 | Vector3 worldPos = part.GetWorldPosition(); |
746 | Vector3 offset = worldPos - AbsolutePosition; | 847 | Vector3 offset = worldPos - AbsolutePosition; |
747 | Quaternion worldRot; | 848 | Quaternion worldRot; |
748 | if (part.ParentID == 0) | 849 | if (part.ParentID == 0) |
850 | { | ||
749 | worldRot = part.RotationOffset; | 851 | worldRot = part.RotationOffset; |
852 | } | ||
750 | else | 853 | else |
854 | { | ||
751 | worldRot = part.GetWorldRotation(); | 855 | worldRot = part.GetWorldRotation(); |
856 | } | ||
752 | 857 | ||
753 | Vector3 frontTopLeft; | 858 | Vector3 frontTopLeft; |
754 | Vector3 frontTopRight; | 859 | Vector3 frontTopRight; |
@@ -760,6 +865,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
760 | Vector3 backBottomLeft; | 865 | Vector3 backBottomLeft; |
761 | Vector3 backBottomRight; | 866 | Vector3 backBottomRight; |
762 | 867 | ||
868 | // Vector3[] corners = new Vector3[8]; | ||
869 | |||
763 | Vector3 orig = Vector3.Zero; | 870 | Vector3 orig = Vector3.Zero; |
764 | 871 | ||
765 | frontTopLeft.X = orig.X - (part.Scale.X / 2); | 872 | frontTopLeft.X = orig.X - (part.Scale.X / 2); |
@@ -794,6 +901,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
794 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); | 901 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); |
795 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); | 902 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); |
796 | 903 | ||
904 | |||
905 | |||
906 | //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
907 | //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
908 | //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
909 | //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
910 | //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
911 | //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
912 | //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
913 | //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
914 | |||
915 | //for (int i = 0; i < 8; i++) | ||
916 | //{ | ||
917 | // corners[i] = corners[i] * worldRot; | ||
918 | // corners[i] += offset; | ||
919 | |||
920 | // if (corners[i].X > maxX) | ||
921 | // maxX = corners[i].X; | ||
922 | // if (corners[i].X < minX) | ||
923 | // minX = corners[i].X; | ||
924 | |||
925 | // if (corners[i].Y > maxY) | ||
926 | // maxY = corners[i].Y; | ||
927 | // if (corners[i].Y < minY) | ||
928 | // minY = corners[i].Y; | ||
929 | |||
930 | // if (corners[i].Z > maxZ) | ||
931 | // maxZ = corners[i].Y; | ||
932 | // if (corners[i].Z < minZ) | ||
933 | // minZ = corners[i].Z; | ||
934 | //} | ||
935 | |||
797 | frontTopLeft = frontTopLeft * worldRot; | 936 | frontTopLeft = frontTopLeft * worldRot; |
798 | frontTopRight = frontTopRight * worldRot; | 937 | frontTopRight = frontTopRight * worldRot; |
799 | frontBottomLeft = frontBottomLeft * worldRot; | 938 | frontBottomLeft = frontBottomLeft * worldRot; |
@@ -815,6 +954,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
815 | backTopLeft += offset; | 954 | backTopLeft += offset; |
816 | backTopRight += offset; | 955 | backTopRight += offset; |
817 | 956 | ||
957 | //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
958 | //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
959 | //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
960 | //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
961 | //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
962 | //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
963 | //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
964 | //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
965 | |||
818 | if (frontTopRight.X > maxX) | 966 | if (frontTopRight.X > maxX) |
819 | maxX = frontTopRight.X; | 967 | maxX = frontTopRight.X; |
820 | if (frontTopLeft.X > maxX) | 968 | if (frontTopLeft.X > maxX) |
@@ -960,15 +1108,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
960 | 1108 | ||
961 | public void SaveScriptedState(XmlTextWriter writer) | 1109 | public void SaveScriptedState(XmlTextWriter writer) |
962 | { | 1110 | { |
1111 | SaveScriptedState(writer, false); | ||
1112 | } | ||
1113 | |||
1114 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1115 | { | ||
963 | XmlDocument doc = new XmlDocument(); | 1116 | XmlDocument doc = new XmlDocument(); |
964 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1117 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
965 | 1118 | ||
966 | SceneObjectPart[] parts = m_parts.GetArray(); | 1119 | SceneObjectPart[] parts = m_parts.GetArray(); |
967 | for (int i = 0; i < parts.Length; i++) | 1120 | for (int i = 0; i < parts.Length; i++) |
968 | { | 1121 | { |
969 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(); | 1122 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(oldIDs); |
970 | foreach (KeyValuePair<UUID, string> kvp in pstates) | 1123 | foreach (KeyValuePair<UUID, string> kvp in pstates) |
971 | states.Add(kvp.Key, kvp.Value); | 1124 | states[kvp.Key] = kvp.Value; |
972 | } | 1125 | } |
973 | 1126 | ||
974 | if (states.Count > 0) | 1127 | if (states.Count > 0) |
@@ -988,6 +1141,168 @@ namespace OpenSim.Region.Framework.Scenes | |||
988 | } | 1141 | } |
989 | 1142 | ||
990 | /// <summary> | 1143 | /// <summary> |
1144 | /// Add the avatar to this linkset (avatar is sat). | ||
1145 | /// </summary> | ||
1146 | /// <param name="agentID"></param> | ||
1147 | public void AddAvatar(UUID agentID) | ||
1148 | { | ||
1149 | ScenePresence presence; | ||
1150 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1151 | { | ||
1152 | if (!m_linkedAvatars.Contains(presence)) | ||
1153 | { | ||
1154 | m_linkedAvatars.Add(presence); | ||
1155 | } | ||
1156 | } | ||
1157 | } | ||
1158 | |||
1159 | /// <summary> | ||
1160 | /// Delete the avatar from this linkset (avatar is unsat). | ||
1161 | /// </summary> | ||
1162 | /// <param name="agentID"></param> | ||
1163 | public void DeleteAvatar(UUID agentID) | ||
1164 | { | ||
1165 | ScenePresence presence; | ||
1166 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1167 | { | ||
1168 | if (m_linkedAvatars.Contains(presence)) | ||
1169 | { | ||
1170 | m_linkedAvatars.Remove(presence); | ||
1171 | } | ||
1172 | } | ||
1173 | } | ||
1174 | |||
1175 | /// <summary> | ||
1176 | /// Returns the list of linked presences (avatars sat on this group) | ||
1177 | /// </summary> | ||
1178 | /// <param name="agentID"></param> | ||
1179 | public List<ScenePresence> GetLinkedAvatars() | ||
1180 | { | ||
1181 | return m_linkedAvatars; | ||
1182 | } | ||
1183 | |||
1184 | /// <summary> | ||
1185 | /// Attach this scene object to the given avatar. | ||
1186 | /// </summary> | ||
1187 | /// <param name="agentID"></param> | ||
1188 | /// <param name="attachmentpoint"></param> | ||
1189 | /// <param name="AttachOffset"></param> | ||
1190 | private void AttachToAgent( | ||
1191 | ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | ||
1192 | { | ||
1193 | if (avatar != null) | ||
1194 | { | ||
1195 | // don't attach attachments to child agents | ||
1196 | if (avatar.IsChildAgent) return; | ||
1197 | |||
1198 | // Remove from database and parcel prim count | ||
1199 | m_scene.DeleteFromStorage(so.UUID); | ||
1200 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1201 | |||
1202 | so.AttachedAvatar = avatar.UUID; | ||
1203 | |||
1204 | if (so.RootPart.PhysActor != null) | ||
1205 | { | ||
1206 | m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); | ||
1207 | so.RootPart.PhysActor = null; | ||
1208 | } | ||
1209 | |||
1210 | so.AbsolutePosition = attachOffset; | ||
1211 | so.RootPart.AttachedPos = attachOffset; | ||
1212 | so.IsAttachment = true; | ||
1213 | so.RootPart.SetParentLocalId(avatar.LocalId); | ||
1214 | so.AttachmentPoint = attachmentpoint; | ||
1215 | |||
1216 | avatar.AddAttachment(this); | ||
1217 | |||
1218 | if (!silent) | ||
1219 | { | ||
1220 | // Killing it here will cause the client to deselect it | ||
1221 | // It then reappears on the avatar, deselected | ||
1222 | // through the full update below | ||
1223 | // | ||
1224 | if (IsSelected) | ||
1225 | { | ||
1226 | m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId }); | ||
1227 | } | ||
1228 | |||
1229 | IsSelected = false; // fudge.... | ||
1230 | ScheduleGroupForFullUpdate(); | ||
1231 | } | ||
1232 | } | ||
1233 | else | ||
1234 | { | ||
1235 | m_log.WarnFormat( | ||
1236 | "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", | ||
1237 | UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName); | ||
1238 | } | ||
1239 | } | ||
1240 | |||
1241 | public byte GetAttachmentPoint() | ||
1242 | { | ||
1243 | return m_rootPart.Shape.State; | ||
1244 | } | ||
1245 | |||
1246 | public void DetachToGround() | ||
1247 | { | ||
1248 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1249 | if (avatar == null) | ||
1250 | return; | ||
1251 | |||
1252 | avatar.RemoveAttachment(this); | ||
1253 | |||
1254 | Vector3 detachedpos = new Vector3(127f,127f,127f); | ||
1255 | if (avatar == null) | ||
1256 | return; | ||
1257 | |||
1258 | detachedpos = avatar.AbsolutePosition; | ||
1259 | RootPart.FromItemID = UUID.Zero; | ||
1260 | |||
1261 | AbsolutePosition = detachedpos; | ||
1262 | AttachedAvatar = UUID.Zero; | ||
1263 | |||
1264 | //SceneObjectPart[] parts = m_parts.GetArray(); | ||
1265 | //for (int i = 0; i < parts.Length; i++) | ||
1266 | // parts[i].AttachedAvatar = UUID.Zero; | ||
1267 | |||
1268 | m_rootPart.SetParentLocalId(0); | ||
1269 | AttachmentPoint = (byte)0; | ||
1270 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); | ||
1271 | HasGroupChanged = true; | ||
1272 | RootPart.Rezzed = DateTime.Now; | ||
1273 | RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
1274 | AttachToBackup(); | ||
1275 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1276 | m_rootPart.ScheduleFullUpdate(); | ||
1277 | m_rootPart.ClearUndoState(); | ||
1278 | } | ||
1279 | |||
1280 | public void DetachToInventoryPrep() | ||
1281 | { | ||
1282 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1283 | //Vector3 detachedpos = new Vector3(127f, 127f, 127f); | ||
1284 | if (avatar != null) | ||
1285 | { | ||
1286 | //detachedpos = avatar.AbsolutePosition; | ||
1287 | avatar.RemoveAttachment(this); | ||
1288 | } | ||
1289 | |||
1290 | AttachedAvatar = UUID.Zero; | ||
1291 | |||
1292 | /*SceneObjectPart[] parts = m_parts.GetArray(); | ||
1293 | for (int i = 0; i < parts.Length; i++) | ||
1294 | parts[i].AttachedAvatar = UUID.Zero;*/ | ||
1295 | |||
1296 | m_rootPart.SetParentLocalId(0); | ||
1297 | //m_rootPart.SetAttachmentPoint((byte)0); | ||
1298 | IsAttachment = false; | ||
1299 | AbsolutePosition = m_rootPart.AttachedPos; | ||
1300 | //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); | ||
1301 | //AttachToBackup(); | ||
1302 | //m_rootPart.ScheduleFullUpdate(); | ||
1303 | } | ||
1304 | |||
1305 | /// <summary> | ||
991 | /// | 1306 | /// |
992 | /// </summary> | 1307 | /// </summary> |
993 | /// <param name="part"></param> | 1308 | /// <param name="part"></param> |
@@ -1037,7 +1352,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1037 | public void AddPart(SceneObjectPart part) | 1352 | public void AddPart(SceneObjectPart part) |
1038 | { | 1353 | { |
1039 | part.SetParent(this); | 1354 | part.SetParent(this); |
1040 | part.LinkNum = m_parts.Add(part.UUID, part); | 1355 | m_parts.Add(part.UUID, part); |
1356 | |||
1357 | part.LinkNum = m_parts.Count; | ||
1358 | |||
1041 | if (part.LinkNum == 2) | 1359 | if (part.LinkNum == 2) |
1042 | RootPart.LinkNum = 1; | 1360 | RootPart.LinkNum = 1; |
1043 | } | 1361 | } |
@@ -1145,6 +1463,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1145 | /// <param name="silent">If true then deletion is not broadcast to clients</param> | 1463 | /// <param name="silent">If true then deletion is not broadcast to clients</param> |
1146 | public void DeleteGroupFromScene(bool silent) | 1464 | public void DeleteGroupFromScene(bool silent) |
1147 | { | 1465 | { |
1466 | // We need to keep track of this state in case this group is still queued for backup. | ||
1467 | IsDeleted = true; | ||
1468 | |||
1469 | DetachFromBackup(); | ||
1470 | |||
1148 | SceneObjectPart[] parts = m_parts.GetArray(); | 1471 | SceneObjectPart[] parts = m_parts.GetArray(); |
1149 | for (int i = 0; i < parts.Length; i++) | 1472 | for (int i = 0; i < parts.Length; i++) |
1150 | { | 1473 | { |
@@ -1162,11 +1485,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1162 | { | 1485 | { |
1163 | if (!IsAttachment || (AttachedAvatar == avatar.ControllingClient.AgentId) || | 1486 | if (!IsAttachment || (AttachedAvatar == avatar.ControllingClient.AgentId) || |
1164 | (AttachmentPoint < 31) || (AttachmentPoint > 38)) | 1487 | (AttachmentPoint < 31) || (AttachmentPoint > 38)) |
1165 | avatar.ControllingClient.SendKillObject(m_regionHandle, part.LocalId); | 1488 | avatar.ControllingClient.SendKillObject(m_regionHandle, new List<uint>() {part.LocalId}); |
1166 | } | 1489 | } |
1167 | } | 1490 | } |
1168 | }); | 1491 | }); |
1169 | } | 1492 | } |
1493 | |||
1494 | |||
1170 | } | 1495 | } |
1171 | 1496 | ||
1172 | public void AddScriptLPS(int count) | 1497 | public void AddScriptLPS(int count) |
@@ -1263,7 +1588,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1263 | 1588 | ||
1264 | public void SetOwnerId(UUID userId) | 1589 | public void SetOwnerId(UUID userId) |
1265 | { | 1590 | { |
1266 | ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); | 1591 | ForEachPart(delegate(SceneObjectPart part) |
1592 | { | ||
1593 | |||
1594 | part.OwnerID = userId; | ||
1595 | |||
1596 | }); | ||
1267 | } | 1597 | } |
1268 | 1598 | ||
1269 | public void ForEachPart(Action<SceneObjectPart> whatToDo) | 1599 | public void ForEachPart(Action<SceneObjectPart> whatToDo) |
@@ -1295,11 +1625,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1295 | return; | 1625 | return; |
1296 | } | 1626 | } |
1297 | 1627 | ||
1628 | if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | ||
1629 | return; | ||
1630 | |||
1298 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let | 1631 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let |
1299 | // any exception propogate upwards. | 1632 | // any exception propogate upwards. |
1300 | try | 1633 | try |
1301 | { | 1634 | { |
1302 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart | 1635 | if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart |
1636 | m_scene.LoginsDisabled || // We're starting up or doing maintenance, don't mess with things | ||
1637 | m_scene.LoadingPrims) // Land may not be valid yet | ||
1638 | |||
1303 | { | 1639 | { |
1304 | ILandObject parcel = m_scene.LandChannel.GetLandObject( | 1640 | ILandObject parcel = m_scene.LandChannel.GetLandObject( |
1305 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); | 1641 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); |
@@ -1326,6 +1662,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1326 | } | 1662 | } |
1327 | } | 1663 | } |
1328 | } | 1664 | } |
1665 | |||
1329 | } | 1666 | } |
1330 | 1667 | ||
1331 | if (m_scene.UseBackup && HasGroupChanged) | 1668 | if (m_scene.UseBackup && HasGroupChanged) |
@@ -1333,6 +1670,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1333 | // don't backup while it's selected or you're asking for changes mid stream. | 1670 | // don't backup while it's selected or you're asking for changes mid stream. |
1334 | if (isTimeToPersist() || forcedBackup) | 1671 | if (isTimeToPersist() || forcedBackup) |
1335 | { | 1672 | { |
1673 | if (m_rootPart.PhysActor != null && | ||
1674 | (!m_rootPart.PhysActor.IsPhysical)) | ||
1675 | { | ||
1676 | // Possible ghost prim | ||
1677 | if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) | ||
1678 | { | ||
1679 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
1680 | { | ||
1681 | // Re-set physics actor positions and | ||
1682 | // orientations | ||
1683 | part.GroupPosition = m_rootPart.GroupPosition; | ||
1684 | } | ||
1685 | } | ||
1686 | } | ||
1336 | // m_log.DebugFormat( | 1687 | // m_log.DebugFormat( |
1337 | // "[SCENE]: Storing {0}, {1} in {2}", | 1688 | // "[SCENE]: Storing {0}, {1} in {2}", |
1338 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1689 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -1410,7 +1761,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1410 | // This is only necessary when userExposed is false! | 1761 | // This is only necessary when userExposed is false! |
1411 | 1762 | ||
1412 | bool previousAttachmentStatus = dupe.IsAttachment; | 1763 | bool previousAttachmentStatus = dupe.IsAttachment; |
1413 | 1764 | ||
1414 | if (!userExposed) | 1765 | if (!userExposed) |
1415 | dupe.IsAttachment = true; | 1766 | dupe.IsAttachment = true; |
1416 | 1767 | ||
@@ -1428,11 +1779,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1428 | dupe.m_rootPart.TrimPermissions(); | 1779 | dupe.m_rootPart.TrimPermissions(); |
1429 | 1780 | ||
1430 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); | 1781 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); |
1431 | 1782 | ||
1432 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | 1783 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) |
1433 | { | 1784 | { |
1434 | return p1.LinkNum.CompareTo(p2.LinkNum); | 1785 | return p1.LinkNum.CompareTo(p2.LinkNum); |
1435 | } | 1786 | } |
1436 | ); | 1787 | ); |
1437 | 1788 | ||
1438 | foreach (SceneObjectPart part in partList) | 1789 | foreach (SceneObjectPart part in partList) |
@@ -1452,7 +1803,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1452 | if (part.PhysActor != null && userExposed) | 1803 | if (part.PhysActor != null && userExposed) |
1453 | { | 1804 | { |
1454 | PrimitiveBaseShape pbs = newPart.Shape; | 1805 | PrimitiveBaseShape pbs = newPart.Shape; |
1455 | 1806 | ||
1456 | newPart.PhysActor | 1807 | newPart.PhysActor |
1457 | = m_scene.PhysicsScene.AddPrimShape( | 1808 | = m_scene.PhysicsScene.AddPrimShape( |
1458 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), | 1809 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), |
@@ -1462,11 +1813,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1462 | newPart.RotationOffset, | 1813 | newPart.RotationOffset, |
1463 | part.PhysActor.IsPhysical, | 1814 | part.PhysActor.IsPhysical, |
1464 | newPart.LocalId); | 1815 | newPart.LocalId); |
1465 | 1816 | ||
1466 | newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); | 1817 | newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); |
1467 | } | 1818 | } |
1468 | } | 1819 | } |
1469 | 1820 | ||
1470 | if (userExposed) | 1821 | if (userExposed) |
1471 | { | 1822 | { |
1472 | dupe.UpdateParentIDs(); | 1823 | dupe.UpdateParentIDs(); |
@@ -1581,6 +1932,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1581 | return Vector3.Zero; | 1932 | return Vector3.Zero; |
1582 | } | 1933 | } |
1583 | 1934 | ||
1935 | // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object | ||
1584 | public void moveToTarget(Vector3 target, float tau) | 1936 | public void moveToTarget(Vector3 target, float tau) |
1585 | { | 1937 | { |
1586 | if (IsAttachment) | 1938 | if (IsAttachment) |
@@ -1608,10 +1960,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
1608 | RootPart.PhysActor.PIDActive = false; | 1960 | RootPart.PhysActor.PIDActive = false; |
1609 | } | 1961 | } |
1610 | 1962 | ||
1963 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
1964 | { | ||
1965 | SceneObjectPart rootpart = m_rootPart; | ||
1966 | if (rootpart != null) | ||
1967 | { | ||
1968 | if (IsAttachment) | ||
1969 | { | ||
1970 | /* | ||
1971 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
1972 | if (avatar != null) | ||
1973 | { | ||
1974 | Rotate the Av? | ||
1975 | } */ | ||
1976 | } | ||
1977 | else | ||
1978 | { | ||
1979 | if (rootpart.PhysActor != null) | ||
1980 | { // APID must be implemented in your physics system for this to function. | ||
1981 | rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); | ||
1982 | rootpart.PhysActor.APIDStrength = strength; | ||
1983 | rootpart.PhysActor.APIDDamping = damping; | ||
1984 | rootpart.PhysActor.APIDActive = true; | ||
1985 | } | ||
1986 | } | ||
1987 | } | ||
1988 | } | ||
1989 | |||
1611 | public void stopLookAt() | 1990 | public void stopLookAt() |
1612 | { | 1991 | { |
1613 | if (RootPart.PhysActor != null) | 1992 | SceneObjectPart rootpart = m_rootPart; |
1614 | RootPart.PhysActor.APIDActive = false; | 1993 | if (rootpart != null) |
1994 | { | ||
1995 | if (rootpart.PhysActor != null) | ||
1996 | { // APID must be implemented in your physics system for this to function. | ||
1997 | rootpart.PhysActor.APIDActive = false; | ||
1998 | } | ||
1999 | } | ||
2000 | |||
1615 | } | 2001 | } |
1616 | 2002 | ||
1617 | /// <summary> | 2003 | /// <summary> |
@@ -1669,6 +2055,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1669 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2055 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1670 | { | 2056 | { |
1671 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | 2057 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); |
2058 | newPart.SetParent(this); | ||
2059 | |||
1672 | AddPart(newPart); | 2060 | AddPart(newPart); |
1673 | 2061 | ||
1674 | SetPartAsNonRoot(newPart); | 2062 | SetPartAsNonRoot(newPart); |
@@ -1815,11 +2203,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1815 | /// Immediately send a full update for this scene object. | 2203 | /// Immediately send a full update for this scene object. |
1816 | /// </summary> | 2204 | /// </summary> |
1817 | public void SendGroupFullUpdate() | 2205 | public void SendGroupFullUpdate() |
1818 | { | 2206 | { |
1819 | if (IsDeleted) | 2207 | if (IsDeleted) |
1820 | return; | 2208 | return; |
1821 | 2209 | ||
1822 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); | 2210 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); |
1823 | 2211 | ||
1824 | RootPart.SendFullUpdateToAllClients(); | 2212 | RootPart.SendFullUpdateToAllClients(); |
1825 | 2213 | ||
@@ -2020,7 +2408,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2020 | objectGroup.IsDeleted = true; | 2408 | objectGroup.IsDeleted = true; |
2021 | 2409 | ||
2022 | objectGroup.m_parts.Clear(); | 2410 | objectGroup.m_parts.Clear(); |
2023 | 2411 | ||
2024 | // Can't do this yet since backup still makes use of the root part without any synchronization | 2412 | // Can't do this yet since backup still makes use of the root part without any synchronization |
2025 | // objectGroup.m_rootPart = null; | 2413 | // objectGroup.m_rootPart = null; |
2026 | 2414 | ||
@@ -2154,6 +2542,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2154 | /// <param name="objectGroup"></param> | 2542 | /// <param name="objectGroup"></param> |
2155 | public virtual void DetachFromBackup() | 2543 | public virtual void DetachFromBackup() |
2156 | { | 2544 | { |
2545 | m_scene.SceneGraph.FireDetachFromBackup(this); | ||
2157 | if (m_isBackedUp && Scene != null) | 2546 | if (m_isBackedUp && Scene != null) |
2158 | m_scene.EventManager.OnBackup -= ProcessBackup; | 2547 | m_scene.EventManager.OnBackup -= ProcessBackup; |
2159 | 2548 | ||
@@ -2172,7 +2561,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2172 | 2561 | ||
2173 | axPos *= parentRot; | 2562 | axPos *= parentRot; |
2174 | part.OffsetPosition = axPos; | 2563 | part.OffsetPosition = axPos; |
2175 | part.GroupPosition = oldGroupPosition + part.OffsetPosition; | 2564 | Vector3 newPos = oldGroupPosition + part.OffsetPosition; |
2565 | part.GroupPosition = newPos; | ||
2176 | part.OffsetPosition = Vector3.Zero; | 2566 | part.OffsetPosition = Vector3.Zero; |
2177 | part.RotationOffset = worldRot; | 2567 | part.RotationOffset = worldRot; |
2178 | 2568 | ||
@@ -2183,7 +2573,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2183 | 2573 | ||
2184 | part.LinkNum = linkNum; | 2574 | part.LinkNum = linkNum; |
2185 | 2575 | ||
2186 | part.OffsetPosition = part.GroupPosition - AbsolutePosition; | 2576 | part.OffsetPosition = newPos - AbsolutePosition; |
2187 | 2577 | ||
2188 | Quaternion rootRotation = m_rootPart.RotationOffset; | 2578 | Quaternion rootRotation = m_rootPart.RotationOffset; |
2189 | 2579 | ||
@@ -2193,7 +2583,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2193 | 2583 | ||
2194 | parentRot = m_rootPart.RotationOffset; | 2584 | parentRot = m_rootPart.RotationOffset; |
2195 | oldRot = part.RotationOffset; | 2585 | oldRot = part.RotationOffset; |
2196 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 2586 | Quaternion newRot = Quaternion.Inverse(parentRot) * worldRot; |
2197 | part.RotationOffset = newRot; | 2587 | part.RotationOffset = newRot; |
2198 | } | 2588 | } |
2199 | 2589 | ||
@@ -2440,8 +2830,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2440 | } | 2830 | } |
2441 | } | 2831 | } |
2442 | 2832 | ||
2833 | RootPart.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, SetVolumeDetect); | ||
2443 | for (int i = 0; i < parts.Length; i++) | 2834 | for (int i = 0; i < parts.Length; i++) |
2444 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); | 2835 | { |
2836 | if (parts[i] != RootPart) | ||
2837 | parts[i].UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, SetVolumeDetect); | ||
2838 | } | ||
2445 | } | 2839 | } |
2446 | } | 2840 | } |
2447 | 2841 | ||
@@ -2454,6 +2848,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2454 | } | 2848 | } |
2455 | } | 2849 | } |
2456 | 2850 | ||
2851 | |||
2852 | |||
2853 | /// <summary> | ||
2854 | /// Gets the number of parts | ||
2855 | /// </summary> | ||
2856 | /// <returns></returns> | ||
2857 | public int GetPartCount() | ||
2858 | { | ||
2859 | return Parts.Count(); | ||
2860 | } | ||
2861 | |||
2457 | /// <summary> | 2862 | /// <summary> |
2458 | /// Update the texture entry for this part | 2863 | /// Update the texture entry for this part |
2459 | /// </summary> | 2864 | /// </summary> |
@@ -2510,7 +2915,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2510 | { | 2915 | { |
2511 | // m_log.DebugFormat( | 2916 | // m_log.DebugFormat( |
2512 | // "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); | 2917 | // "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); |
2513 | |||
2514 | RootPart.StoreUndoState(true); | 2918 | RootPart.StoreUndoState(true); |
2515 | 2919 | ||
2516 | scale.X = Math.Min(scale.X, Scene.m_maxNonphys); | 2920 | scale.X = Math.Min(scale.X, Scene.m_maxNonphys); |
@@ -2611,7 +3015,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2611 | prevScale.X *= x; | 3015 | prevScale.X *= x; |
2612 | prevScale.Y *= y; | 3016 | prevScale.Y *= y; |
2613 | prevScale.Z *= z; | 3017 | prevScale.Z *= z; |
2614 | |||
2615 | // RootPart.IgnoreUndoUpdate = true; | 3018 | // RootPart.IgnoreUndoUpdate = true; |
2616 | RootPart.Resize(prevScale); | 3019 | RootPart.Resize(prevScale); |
2617 | // RootPart.IgnoreUndoUpdate = false; | 3020 | // RootPart.IgnoreUndoUpdate = false; |
@@ -2642,7 +3045,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2642 | } | 3045 | } |
2643 | 3046 | ||
2644 | // obPart.IgnoreUndoUpdate = false; | 3047 | // obPart.IgnoreUndoUpdate = false; |
2645 | // obPart.StoreUndoState(); | 3048 | HasGroupChanged = true; |
3049 | m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); | ||
3050 | ScheduleGroupForTerseUpdate(); | ||
2646 | } | 3051 | } |
2647 | 3052 | ||
2648 | // m_log.DebugFormat( | 3053 | // m_log.DebugFormat( |
@@ -2702,9 +3107,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2702 | { | 3107 | { |
2703 | SceneObjectPart part = GetChildPart(localID); | 3108 | SceneObjectPart part = GetChildPart(localID); |
2704 | 3109 | ||
2705 | // SceneObjectPart[] parts = m_parts.GetArray(); | 3110 | SceneObjectPart[] parts = m_parts.GetArray(); |
2706 | // for (int i = 0; i < parts.Length; i++) | 3111 | for (int i = 0; i < parts.Length; i++) |
2707 | // parts[i].StoreUndoState(); | 3112 | parts[i].StoreUndoState(); |
2708 | 3113 | ||
2709 | if (part != null) | 3114 | if (part != null) |
2710 | { | 3115 | { |
@@ -2760,10 +3165,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2760 | obPart.OffsetPosition = obPart.OffsetPosition + diff; | 3165 | obPart.OffsetPosition = obPart.OffsetPosition + diff; |
2761 | } | 3166 | } |
2762 | 3167 | ||
2763 | AbsolutePosition = newPos; | 3168 | //We have to set undoing here because otherwise an undo state will be saved |
3169 | if (!m_rootPart.Undoing) | ||
3170 | { | ||
3171 | m_rootPart.Undoing = true; | ||
3172 | AbsolutePosition = newPos; | ||
3173 | m_rootPart.Undoing = false; | ||
3174 | } | ||
3175 | else | ||
3176 | { | ||
3177 | AbsolutePosition = newPos; | ||
3178 | } | ||
2764 | 3179 | ||
2765 | HasGroupChanged = true; | 3180 | HasGroupChanged = true; |
2766 | ScheduleGroupForTerseUpdate(); | 3181 | if (m_rootPart.Undoing) |
3182 | { | ||
3183 | ScheduleGroupForFullUpdate(); | ||
3184 | } | ||
3185 | else | ||
3186 | { | ||
3187 | ScheduleGroupForTerseUpdate(); | ||
3188 | } | ||
2767 | } | 3189 | } |
2768 | 3190 | ||
2769 | #endregion | 3191 | #endregion |
@@ -2840,10 +3262,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2840 | public void UpdateSingleRotation(Quaternion rot, uint localID) | 3262 | public void UpdateSingleRotation(Quaternion rot, uint localID) |
2841 | { | 3263 | { |
2842 | SceneObjectPart part = GetChildPart(localID); | 3264 | SceneObjectPart part = GetChildPart(localID); |
2843 | |||
2844 | SceneObjectPart[] parts = m_parts.GetArray(); | 3265 | SceneObjectPart[] parts = m_parts.GetArray(); |
2845 | for (int i = 0; i < parts.Length; i++) | ||
2846 | parts[i].StoreUndoState(); | ||
2847 | 3266 | ||
2848 | if (part != null) | 3267 | if (part != null) |
2849 | { | 3268 | { |
@@ -2881,7 +3300,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2881 | if (part.UUID == m_rootPart.UUID) | 3300 | if (part.UUID == m_rootPart.UUID) |
2882 | { | 3301 | { |
2883 | UpdateRootRotation(rot); | 3302 | UpdateRootRotation(rot); |
2884 | AbsolutePosition = pos; | 3303 | if (!m_rootPart.Undoing) |
3304 | { | ||
3305 | m_rootPart.Undoing = true; | ||
3306 | AbsolutePosition = pos; | ||
3307 | m_rootPart.Undoing = false; | ||
3308 | } | ||
3309 | else | ||
3310 | { | ||
3311 | AbsolutePosition = pos; | ||
3312 | } | ||
2885 | } | 3313 | } |
2886 | else | 3314 | else |
2887 | { | 3315 | { |
@@ -2905,9 +3333,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2905 | 3333 | ||
2906 | Quaternion axRot = rot; | 3334 | Quaternion axRot = rot; |
2907 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 3335 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
2908 | |||
2909 | m_rootPart.StoreUndoState(); | 3336 | m_rootPart.StoreUndoState(); |
2910 | m_rootPart.UpdateRotation(rot); | 3337 | |
3338 | //Don't use UpdateRotation because it schedules an update prematurely | ||
3339 | m_rootPart.RotationOffset = rot; | ||
2911 | if (m_rootPart.PhysActor != null) | 3340 | if (m_rootPart.PhysActor != null) |
2912 | { | 3341 | { |
2913 | m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; | 3342 | m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; |
@@ -2921,15 +3350,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2921 | if (prim.UUID != m_rootPart.UUID) | 3350 | if (prim.UUID != m_rootPart.UUID) |
2922 | { | 3351 | { |
2923 | prim.IgnoreUndoUpdate = true; | 3352 | prim.IgnoreUndoUpdate = true; |
3353 | |||
3354 | Quaternion NewRot = oldParentRot * prim.RotationOffset; | ||
3355 | NewRot = Quaternion.Inverse(axRot) * NewRot; | ||
3356 | prim.RotationOffset = NewRot; | ||
3357 | |||
2924 | Vector3 axPos = prim.OffsetPosition; | 3358 | Vector3 axPos = prim.OffsetPosition; |
3359 | |||
2925 | axPos *= oldParentRot; | 3360 | axPos *= oldParentRot; |
2926 | axPos *= Quaternion.Inverse(axRot); | 3361 | axPos *= Quaternion.Inverse(axRot); |
2927 | prim.OffsetPosition = axPos; | 3362 | prim.OffsetPosition = axPos; |
2928 | Quaternion primsRot = prim.RotationOffset; | 3363 | |
2929 | Quaternion newRot = oldParentRot * primsRot; | ||
2930 | newRot = Quaternion.Inverse(axRot) * newRot; | ||
2931 | prim.RotationOffset = newRot; | ||
2932 | prim.ScheduleTerseUpdate(); | ||
2933 | prim.IgnoreUndoUpdate = false; | 3364 | prim.IgnoreUndoUpdate = false; |
2934 | } | 3365 | } |
2935 | } | 3366 | } |
@@ -2943,8 +3374,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2943 | //// childpart.StoreUndoState(); | 3374 | //// childpart.StoreUndoState(); |
2944 | // } | 3375 | // } |
2945 | // } | 3376 | // } |
2946 | 3377 | HasGroupChanged = true; | |
2947 | m_rootPart.ScheduleTerseUpdate(); | 3378 | ScheduleGroupForFullUpdate(); |
2948 | 3379 | ||
2949 | // m_log.DebugFormat( | 3380 | // m_log.DebugFormat( |
2950 | // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", | 3381 | // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", |
@@ -3172,7 +3603,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3172 | public float GetMass() | 3603 | public float GetMass() |
3173 | { | 3604 | { |
3174 | float retmass = 0f; | 3605 | float retmass = 0f; |
3175 | |||
3176 | SceneObjectPart[] parts = m_parts.GetArray(); | 3606 | SceneObjectPart[] parts = m_parts.GetArray(); |
3177 | for (int i = 0; i < parts.Length; i++) | 3607 | for (int i = 0; i < parts.Length; i++) |
3178 | retmass += parts[i].GetMass(); | 3608 | retmass += parts[i].GetMass(); |
@@ -3266,6 +3696,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3266 | SetFromItemID(uuid); | 3696 | SetFromItemID(uuid); |
3267 | } | 3697 | } |
3268 | 3698 | ||
3699 | public void ResetOwnerChangeFlag() | ||
3700 | { | ||
3701 | ForEachPart(delegate(SceneObjectPart part) | ||
3702 | { | ||
3703 | part.ResetOwnerChangeFlag(); | ||
3704 | }); | ||
3705 | } | ||
3706 | |||
3269 | #endregion | 3707 | #endregion |
3270 | } | 3708 | } |
3271 | } | 3709 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4071159..e4bee0c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -62,7 +62,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
62 | TELEPORT = 512, | 62 | TELEPORT = 512, |
63 | REGION_RESTART = 1024, | 63 | REGION_RESTART = 1024, |
64 | MEDIA = 2048, | 64 | MEDIA = 2048, |
65 | ANIMATION = 16384 | 65 | ANIMATION = 16384, |
66 | POSITION = 32768 | ||
66 | } | 67 | } |
67 | 68 | ||
68 | // I don't really know where to put this except here. | 69 | // I don't really know where to put this except here. |
@@ -184,6 +185,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
184 | 185 | ||
185 | public UUID FromFolderID; | 186 | public UUID FromFolderID; |
186 | 187 | ||
188 | // The following two are to hold the attachment data | ||
189 | // while an object is inworld | ||
190 | [XmlIgnore] | ||
191 | public byte AttachPoint = 0; | ||
192 | |||
193 | [XmlIgnore] | ||
194 | public Vector3 AttachOffset = Vector3.Zero; | ||
195 | |||
196 | [XmlIgnore] | ||
187 | public int STATUS_ROTATE_X; | 197 | public int STATUS_ROTATE_X; |
188 | 198 | ||
189 | public int STATUS_ROTATE_Y; | 199 | public int STATUS_ROTATE_Y; |
@@ -253,6 +263,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
253 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; | 263 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; |
254 | private Vector3 m_sitTargetPosition; | 264 | private Vector3 m_sitTargetPosition; |
255 | private string m_sitAnimation = "SIT"; | 265 | private string m_sitAnimation = "SIT"; |
266 | private bool m_occupied; // KF if any av is sitting on this prim | ||
256 | private string m_text = String.Empty; | 267 | private string m_text = String.Empty; |
257 | private string m_touchName = String.Empty; | 268 | private string m_touchName = String.Empty; |
258 | private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); | 269 | private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); |
@@ -288,6 +299,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
288 | protected Vector3 m_lastAcceleration; | 299 | protected Vector3 m_lastAcceleration; |
289 | protected Vector3 m_lastAngularVelocity; | 300 | protected Vector3 m_lastAngularVelocity; |
290 | protected int m_lastTerseSent; | 301 | protected int m_lastTerseSent; |
302 | protected float m_buoyancy = 0.0f; | ||
291 | 303 | ||
292 | /// <summary> | 304 | /// <summary> |
293 | /// Stores media texture data | 305 | /// Stores media texture data |
@@ -340,7 +352,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
340 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, | 352 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, |
341 | Quaternion rotationOffset, Vector3 offsetPosition) | 353 | Quaternion rotationOffset, Vector3 offsetPosition) |
342 | { | 354 | { |
343 | m_name = "Primitive"; | 355 | m_name = "Object"; |
344 | 356 | ||
345 | Rezzed = DateTime.UtcNow; | 357 | Rezzed = DateTime.UtcNow; |
346 | _creationDate = (int)Utils.DateTimeToUnixTime(Rezzed); | 358 | _creationDate = (int)Utils.DateTimeToUnixTime(Rezzed); |
@@ -395,7 +407,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
395 | private uint _ownerMask = (uint)PermissionMask.All; | 407 | private uint _ownerMask = (uint)PermissionMask.All; |
396 | private uint _groupMask = (uint)PermissionMask.None; | 408 | private uint _groupMask = (uint)PermissionMask.None; |
397 | private uint _everyoneMask = (uint)PermissionMask.None; | 409 | private uint _everyoneMask = (uint)PermissionMask.None; |
398 | private uint _nextOwnerMask = (uint)PermissionMask.All; | 410 | private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); |
399 | private PrimFlags _flags = PrimFlags.None; | 411 | private PrimFlags _flags = PrimFlags.None; |
400 | private DateTime m_expires; | 412 | private DateTime m_expires; |
401 | private DateTime m_rezzed; | 413 | private DateTime m_rezzed; |
@@ -494,12 +506,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
494 | } | 506 | } |
495 | 507 | ||
496 | /// <value> | 508 | /// <value> |
497 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 509 | /// Get the inventory list |
498 | /// </value> | 510 | /// </value> |
499 | public TaskInventoryDictionary TaskInventory | 511 | public TaskInventoryDictionary TaskInventory |
500 | { | 512 | { |
501 | get { return m_inventory.Items; } | 513 | get { |
502 | set { m_inventory.Items = value; } | 514 | return m_inventory.Items; |
515 | } | ||
516 | set { | ||
517 | m_inventory.Items = value; | ||
518 | } | ||
503 | } | 519 | } |
504 | 520 | ||
505 | /// <summary> | 521 | /// <summary> |
@@ -640,14 +656,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
640 | set { m_LoopSoundSlavePrims = value; } | 656 | set { m_LoopSoundSlavePrims = value; } |
641 | } | 657 | } |
642 | 658 | ||
643 | |||
644 | public Byte[] TextureAnimation | 659 | public Byte[] TextureAnimation |
645 | { | 660 | { |
646 | get { return m_TextureAnimation; } | 661 | get { return m_TextureAnimation; } |
647 | set { m_TextureAnimation = value; } | 662 | set { m_TextureAnimation = value; } |
648 | } | 663 | } |
649 | 664 | ||
650 | |||
651 | public Byte[] ParticleSystem | 665 | public Byte[] ParticleSystem |
652 | { | 666 | { |
653 | get { return m_particleSystem; } | 667 | get { return m_particleSystem; } |
@@ -684,9 +698,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
684 | { | 698 | { |
685 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 699 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
686 | PhysicsActor actor = PhysActor; | 700 | PhysicsActor actor = PhysActor; |
687 | if (actor != null && _parentID == 0) | 701 | if (_parentID == 0) |
688 | { | 702 | { |
689 | m_groupPosition = actor.Position; | 703 | if (actor != null) |
704 | m_groupPosition = actor.Position; | ||
705 | return m_groupPosition; | ||
690 | } | 706 | } |
691 | 707 | ||
692 | if (m_parentGroup.IsAttachment) | 708 | if (m_parentGroup.IsAttachment) |
@@ -696,12 +712,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
696 | return sp.AbsolutePosition; | 712 | return sp.AbsolutePosition; |
697 | } | 713 | } |
698 | 714 | ||
715 | // use root prim's group position. Physics may have updated it | ||
716 | if (ParentGroup.RootPart != this) | ||
717 | m_groupPosition = ParentGroup.RootPart.GroupPosition; | ||
699 | return m_groupPosition; | 718 | return m_groupPosition; |
700 | } | 719 | } |
701 | set | 720 | set |
702 | { | 721 | { |
703 | m_groupPosition = value; | 722 | m_groupPosition = value; |
704 | |||
705 | PhysicsActor actor = PhysActor; | 723 | PhysicsActor actor = PhysActor; |
706 | if (actor != null) | 724 | if (actor != null) |
707 | { | 725 | { |
@@ -721,22 +739,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
721 | 739 | ||
722 | // Tell the physics engines that this prim changed. | 740 | // Tell the physics engines that this prim changed. |
723 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 741 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
742 | |||
724 | } | 743 | } |
725 | catch (Exception e) | 744 | catch (Exception e) |
726 | { | 745 | { |
727 | m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); | 746 | m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); |
728 | } | 747 | } |
729 | } | 748 | } |
730 | |||
731 | // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too | ||
732 | if (m_sitTargetAvatar != UUID.Zero) | ||
733 | { | ||
734 | ScenePresence avatar; | ||
735 | if (m_parentGroup.Scene.TryGetScenePresence(m_sitTargetAvatar, out avatar)) | ||
736 | { | ||
737 | avatar.ParentPosition = GetWorldPosition(); | ||
738 | } | ||
739 | } | ||
740 | } | 749 | } |
741 | } | 750 | } |
742 | 751 | ||
@@ -745,7 +754,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
745 | get { return m_offsetPosition; } | 754 | get { return m_offsetPosition; } |
746 | set | 755 | set |
747 | { | 756 | { |
748 | // StoreUndoState(); | 757 | Vector3 oldpos = m_offsetPosition; |
749 | m_offsetPosition = value; | 758 | m_offsetPosition = value; |
750 | 759 | ||
751 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 760 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
@@ -760,7 +769,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
760 | if (m_parentGroup.Scene != null) | 769 | if (m_parentGroup.Scene != null) |
761 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 770 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
762 | } | 771 | } |
772 | |||
773 | if (!m_parentGroup.m_dupeInProgress) | ||
774 | { | ||
775 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); | ||
776 | foreach (ScenePresence av in avs) | ||
777 | { | ||
778 | if (av.ParentID == m_localId) | ||
779 | { | ||
780 | Vector3 offset = (m_offsetPosition - oldpos); | ||
781 | av.AbsolutePosition += offset; | ||
782 | av.SendAvatarDataToAllAgents(); | ||
783 | } | ||
784 | } | ||
785 | } | ||
763 | } | 786 | } |
787 | TriggerScriptChangedEvent(Changed.POSITION); | ||
764 | } | 788 | } |
765 | } | 789 | } |
766 | 790 | ||
@@ -909,7 +933,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
909 | /// <summary></summary> | 933 | /// <summary></summary> |
910 | public Vector3 Acceleration | 934 | public Vector3 Acceleration |
911 | { | 935 | { |
912 | get { return m_acceleration; } | 936 | get |
937 | { | ||
938 | PhysicsActor actor = PhysActor; | ||
939 | if (actor != null) | ||
940 | { | ||
941 | m_acceleration = actor.Acceleration; | ||
942 | } | ||
943 | return m_acceleration; | ||
944 | } | ||
945 | |||
913 | set { m_acceleration = value; } | 946 | set { m_acceleration = value; } |
914 | } | 947 | } |
915 | 948 | ||
@@ -1248,6 +1281,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1248 | _flags = value; | 1281 | _flags = value; |
1249 | } | 1282 | } |
1250 | } | 1283 | } |
1284 | |||
1285 | [XmlIgnore] | ||
1286 | public bool IsOccupied // KF If an av is sittingon this prim | ||
1287 | { | ||
1288 | get { return m_occupied; } | ||
1289 | set { m_occupied = value; } | ||
1290 | } | ||
1251 | 1291 | ||
1252 | /// <summary> | 1292 | /// <summary> |
1253 | /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero | 1293 | /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero |
@@ -1307,6 +1347,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1307 | set { m_collisionSoundVolume = value; } | 1347 | set { m_collisionSoundVolume = value; } |
1308 | } | 1348 | } |
1309 | 1349 | ||
1350 | public float Buoyancy | ||
1351 | { | ||
1352 | get { return m_buoyancy; } | ||
1353 | set | ||
1354 | { | ||
1355 | m_buoyancy = value; | ||
1356 | if (PhysActor != null) | ||
1357 | { | ||
1358 | PhysActor.Buoyancy = value; | ||
1359 | } | ||
1360 | } | ||
1361 | } | ||
1362 | |||
1310 | #endregion Public Properties with only Get | 1363 | #endregion Public Properties with only Get |
1311 | 1364 | ||
1312 | private uint ApplyMask(uint val, bool set, uint mask) | 1365 | private uint ApplyMask(uint val, bool set, uint mask) |
@@ -1678,6 +1731,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1678 | 1731 | ||
1679 | // Move afterwards ResetIDs as it clears the localID | 1732 | // Move afterwards ResetIDs as it clears the localID |
1680 | dupe.LocalId = localID; | 1733 | dupe.LocalId = localID; |
1734 | if(dupe.PhysActor != null) | ||
1735 | dupe.PhysActor.LocalID = localID; | ||
1736 | |||
1681 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. | 1737 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. |
1682 | dupe._lastOwnerID = OwnerID; | 1738 | dupe._lastOwnerID = OwnerID; |
1683 | 1739 | ||
@@ -2039,19 +2095,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2039 | public Vector3 GetWorldPosition() | 2095 | public Vector3 GetWorldPosition() |
2040 | { | 2096 | { |
2041 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; | 2097 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; |
2042 | |||
2043 | Vector3 axPos = OffsetPosition; | 2098 | Vector3 axPos = OffsetPosition; |
2044 | |||
2045 | axPos *= parentRot; | 2099 | axPos *= parentRot; |
2046 | Vector3 translationOffsetPosition = axPos; | 2100 | Vector3 translationOffsetPosition = axPos; |
2047 | 2101 | if(_parentID == 0) | |
2048 | // m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); | 2102 | { |
2049 | 2103 | return GroupPosition; | |
2050 | Vector3 worldPos = GroupPosition + translationOffsetPosition; | 2104 | } |
2051 | 2105 | else | |
2052 | // m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); | 2106 | { |
2053 | 2107 | return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position | |
2054 | return worldPos; | 2108 | } |
2055 | } | 2109 | } |
2056 | 2110 | ||
2057 | /// <summary> | 2111 | /// <summary> |
@@ -2691,17 +2745,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2691 | //Trys to fetch sound id from prim's inventory. | 2745 | //Trys to fetch sound id from prim's inventory. |
2692 | //Prim's inventory doesn't support non script items yet | 2746 | //Prim's inventory doesn't support non script items yet |
2693 | 2747 | ||
2694 | lock (TaskInventory) | 2748 | TaskInventory.LockItemsForRead(true); |
2749 | |||
2750 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
2695 | { | 2751 | { |
2696 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 2752 | if (item.Value.Name == sound) |
2697 | { | 2753 | { |
2698 | if (item.Value.Name == sound) | 2754 | soundID = item.Value.ItemID; |
2699 | { | 2755 | break; |
2700 | soundID = item.Value.ItemID; | ||
2701 | break; | ||
2702 | } | ||
2703 | } | 2756 | } |
2704 | } | 2757 | } |
2758 | |||
2759 | TaskInventory.LockItemsForRead(false); | ||
2705 | } | 2760 | } |
2706 | 2761 | ||
2707 | m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 2762 | m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
@@ -2784,7 +2839,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2784 | 2839 | ||
2785 | public void RotLookAt(Quaternion target, float strength, float damping) | 2840 | public void RotLookAt(Quaternion target, float strength, float damping) |
2786 | { | 2841 | { |
2787 | rotLookAt(target, strength, damping); | 2842 | m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup. |
2788 | } | 2843 | } |
2789 | 2844 | ||
2790 | public void rotLookAt(Quaternion target, float strength, float damping) | 2845 | public void rotLookAt(Quaternion target, float strength, float damping) |
@@ -3030,8 +3085,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3030 | { | 3085 | { |
3031 | const float ROTATION_TOLERANCE = 0.01f; | 3086 | const float ROTATION_TOLERANCE = 0.01f; |
3032 | const float VELOCITY_TOLERANCE = 0.001f; | 3087 | const float VELOCITY_TOLERANCE = 0.001f; |
3033 | const float POSITION_TOLERANCE = 0.05f; | 3088 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
3034 | const int TIME_MS_TOLERANCE = 3000; | 3089 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
3035 | 3090 | ||
3036 | switch (UpdateFlag) | 3091 | switch (UpdateFlag) |
3037 | { | 3092 | { |
@@ -3094,17 +3149,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3094 | if (!UUID.TryParse(sound, out soundID)) | 3149 | if (!UUID.TryParse(sound, out soundID)) |
3095 | { | 3150 | { |
3096 | // search sound file from inventory | 3151 | // search sound file from inventory |
3097 | lock (TaskInventory) | 3152 | TaskInventory.LockItemsForRead(true); |
3153 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
3098 | { | 3154 | { |
3099 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 3155 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) |
3100 | { | 3156 | { |
3101 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) | 3157 | soundID = item.Value.ItemID; |
3102 | { | 3158 | break; |
3103 | soundID = item.Value.ItemID; | ||
3104 | break; | ||
3105 | } | ||
3106 | } | 3159 | } |
3107 | } | 3160 | } |
3161 | TaskInventory.LockItemsForRead(false); | ||
3108 | } | 3162 | } |
3109 | 3163 | ||
3110 | if (soundID == UUID.Zero) | 3164 | if (soundID == UUID.Zero) |
@@ -3515,7 +3569,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3515 | 3569 | ||
3516 | public void StopLookAt() | 3570 | public void StopLookAt() |
3517 | { | 3571 | { |
3518 | m_parentGroup.stopLookAt(); | 3572 | m_parentGroup.stopLookAt(); // This calls method in SceneObjectGroup. |
3519 | 3573 | ||
3520 | m_parentGroup.ScheduleGroupForTerseUpdate(); | 3574 | m_parentGroup.ScheduleGroupForTerseUpdate(); |
3521 | } | 3575 | } |
@@ -3566,45 +3620,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
3566 | // TODO: May need to fix for group comparison | 3620 | // TODO: May need to fix for group comparison |
3567 | if (last.Compare(this)) | 3621 | if (last.Compare(this)) |
3568 | { | 3622 | { |
3569 | // m_log.DebugFormat( | 3623 | // m_log.DebugFormat( |
3570 | // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", | 3624 | // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", |
3571 | // Name, LocalId, m_undo.Count); | 3625 | // Name, LocalId, m_undo.Count); |
3572 | 3626 | ||
3573 | return; | 3627 | return; |
3574 | } | 3628 | } |
3575 | } | 3629 | } |
3576 | } | 3630 | } |
3577 | 3631 | ||
3578 | // m_log.DebugFormat( | 3632 | // m_log.DebugFormat( |
3579 | // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", | 3633 | // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", |
3580 | // Name, LocalId, forGroup, m_undo.Count); | 3634 | // Name, LocalId, forGroup, m_undo.Count); |
3581 | 3635 | ||
3582 | if (m_parentGroup.GetSceneMaxUndo() > 0) | 3636 | if (m_parentGroup.GetSceneMaxUndo() > 0) |
3583 | { | 3637 | { |
3584 | UndoState nUndo = new UndoState(this, forGroup); | 3638 | UndoState nUndo = new UndoState(this, forGroup); |
3585 | 3639 | ||
3586 | m_undo.Push(nUndo); | 3640 | m_undo.Push(nUndo); |
3587 | 3641 | ||
3588 | if (m_redo.Count > 0) | 3642 | if (m_redo.Count > 0) |
3589 | m_redo.Clear(); | 3643 | m_redo.Clear(); |
3590 | 3644 | ||
3591 | // m_log.DebugFormat( | 3645 | // m_log.DebugFormat( |
3592 | // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", | 3646 | // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", |
3593 | // Name, LocalId, forGroup, m_undo.Count); | 3647 | // Name, LocalId, forGroup, m_undo.Count); |
3594 | } | 3648 | } |
3595 | } | 3649 | } |
3596 | } | 3650 | } |
3597 | } | 3651 | } |
3598 | // else | 3652 | // else |
3599 | // { | 3653 | // { |
3600 | // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); | 3654 | // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); |
3601 | // } | 3655 | // } |
3602 | } | 3656 | } |
3603 | // else | 3657 | // else |
3604 | // { | 3658 | // { |
3605 | // m_log.DebugFormat( | 3659 | // m_log.DebugFormat( |
3606 | // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); | 3660 | // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); |
3607 | // } | 3661 | // } |
3608 | } | 3662 | } |
3609 | 3663 | ||
3610 | /// <summary> | 3664 | /// <summary> |
@@ -4652,8 +4706,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4652 | { | 4706 | { |
4653 | m_shape.TextureEntry = textureEntry; | 4707 | m_shape.TextureEntry = textureEntry; |
4654 | TriggerScriptChangedEvent(Changed.TEXTURE); | 4708 | TriggerScriptChangedEvent(Changed.TEXTURE); |
4655 | 4709 | UpdateFlag = UpdateRequired.FULL; | |
4656 | ParentGroup.HasGroupChanged = true; | 4710 | ParentGroup.HasGroupChanged = true; |
4711 | |||
4657 | //This is madness.. | 4712 | //This is madness.. |
4658 | //ParentGroup.ScheduleGroupForFullUpdate(); | 4713 | //ParentGroup.ScheduleGroupForFullUpdate(); |
4659 | //This is sparta | 4714 | //This is sparta |
@@ -4850,5 +4905,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
4850 | Color color = Color; | 4905 | Color color = Color; |
4851 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 4906 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4852 | } | 4907 | } |
4908 | |||
4909 | public void ResetOwnerChangeFlag() | ||
4910 | { | ||
4911 | List<UUID> inv = Inventory.GetInventoryList(); | ||
4912 | |||
4913 | foreach (UUID itemID in inv) | ||
4914 | { | ||
4915 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
4916 | item.OwnerChanged = false; | ||
4917 | Inventory.UpdateInventoryItem(item, false, false); | ||
4918 | } | ||
4919 | } | ||
4853 | } | 4920 | } |
4854 | } | 4921 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 9446741..07e303f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -48,6 +48,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
48 | private string m_inventoryFileName = String.Empty; | 48 | private string m_inventoryFileName = String.Empty; |
49 | private byte[] m_inventoryFileData = new byte[0]; | 49 | private byte[] m_inventoryFileData = new byte[0]; |
50 | private uint m_inventoryFileNameSerial = 0; | 50 | private uint m_inventoryFileNameSerial = 0; |
51 | private bool m_inventoryPrivileged = false; | ||
52 | |||
53 | private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); | ||
51 | 54 | ||
52 | /// <value> | 55 | /// <value> |
53 | /// The part to which the inventory belongs. | 56 | /// The part to which the inventory belongs. |
@@ -84,11 +87,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
84 | /// </value> | 87 | /// </value> |
85 | protected internal TaskInventoryDictionary Items | 88 | protected internal TaskInventoryDictionary Items |
86 | { | 89 | { |
87 | get { return m_items; } | 90 | get { |
91 | return m_items; | ||
92 | } | ||
88 | set | 93 | set |
89 | { | 94 | { |
90 | m_items = value; | 95 | m_items = value; |
91 | m_inventorySerial++; | 96 | m_inventorySerial++; |
97 | QueryScriptStates(); | ||
92 | } | 98 | } |
93 | } | 99 | } |
94 | 100 | ||
@@ -123,38 +129,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
123 | public void ResetInventoryIDs() | 129 | public void ResetInventoryIDs() |
124 | { | 130 | { |
125 | if (null == m_part) | 131 | if (null == m_part) |
126 | return; | 132 | m_items.LockItemsForWrite(true); |
127 | 133 | ||
128 | lock (m_items) | 134 | if (Items.Count == 0) |
129 | { | 135 | { |
130 | if (0 == m_items.Count) | 136 | m_items.LockItemsForWrite(false); |
131 | return; | 137 | return; |
138 | } | ||
132 | 139 | ||
133 | IList<TaskInventoryItem> items = GetInventoryItems(); | 140 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
134 | m_items.Clear(); | 141 | Items.Clear(); |
135 | 142 | ||
136 | foreach (TaskInventoryItem item in items) | 143 | foreach (TaskInventoryItem item in items) |
137 | { | 144 | { |
138 | item.ResetIDs(m_part.UUID); | 145 | item.ResetIDs(m_part.UUID); |
139 | m_items.Add(item.ItemID, item); | 146 | Items.Add(item.ItemID, item); |
140 | } | ||
141 | } | 147 | } |
148 | m_items.LockItemsForWrite(false); | ||
142 | } | 149 | } |
143 | 150 | ||
144 | public void ResetObjectID() | 151 | public void ResetObjectID() |
145 | { | 152 | { |
146 | lock (Items) | 153 | m_items.LockItemsForWrite(true); |
154 | |||
155 | if (Items.Count == 0) | ||
147 | { | 156 | { |
148 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 157 | m_items.LockItemsForWrite(false); |
149 | Items.Clear(); | 158 | return; |
150 | |||
151 | foreach (TaskInventoryItem item in items) | ||
152 | { | ||
153 | item.ParentPartID = m_part.UUID; | ||
154 | item.ParentID = m_part.UUID; | ||
155 | Items.Add(item.ItemID, item); | ||
156 | } | ||
157 | } | 159 | } |
160 | |||
161 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
162 | Items.Clear(); | ||
163 | |||
164 | foreach (TaskInventoryItem item in items) | ||
165 | { | ||
166 | item.ParentPartID = m_part.UUID; | ||
167 | item.ParentID = m_part.UUID; | ||
168 | Items.Add(item.ItemID, item); | ||
169 | } | ||
170 | m_items.LockItemsForWrite(false); | ||
158 | } | 171 | } |
159 | 172 | ||
160 | /// <summary> | 173 | /// <summary> |
@@ -163,12 +176,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
163 | /// <param name="ownerId"></param> | 176 | /// <param name="ownerId"></param> |
164 | public void ChangeInventoryOwner(UUID ownerId) | 177 | public void ChangeInventoryOwner(UUID ownerId) |
165 | { | 178 | { |
166 | lock (Items) | 179 | m_items.LockItemsForWrite(true); |
180 | if (0 == Items.Count) | ||
167 | { | 181 | { |
168 | if (0 == Items.Count) | 182 | m_items.LockItemsForWrite(false); |
169 | { | 183 | return; |
170 | return; | ||
171 | } | ||
172 | } | 184 | } |
173 | 185 | ||
174 | HasInventoryChanged = true; | 186 | HasInventoryChanged = true; |
@@ -184,6 +196,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
184 | item.PermsGranter = UUID.Zero; | 196 | item.PermsGranter = UUID.Zero; |
185 | item.OwnerChanged = true; | 197 | item.OwnerChanged = true; |
186 | } | 198 | } |
199 | m_items.LockItemsForWrite(false); | ||
187 | } | 200 | } |
188 | 201 | ||
189 | /// <summary> | 202 | /// <summary> |
@@ -192,12 +205,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
192 | /// <param name="groupID"></param> | 205 | /// <param name="groupID"></param> |
193 | public void ChangeInventoryGroup(UUID groupID) | 206 | public void ChangeInventoryGroup(UUID groupID) |
194 | { | 207 | { |
195 | lock (Items) | 208 | m_items.LockItemsForWrite(true); |
209 | if (0 == Items.Count) | ||
196 | { | 210 | { |
197 | if (0 == Items.Count) | 211 | m_items.LockItemsForWrite(false); |
198 | { | 212 | return; |
199 | return; | ||
200 | } | ||
201 | } | 213 | } |
202 | 214 | ||
203 | // Don't let this set the HasGroupChanged flag for attachments | 215 | // Don't let this set the HasGroupChanged flag for attachments |
@@ -209,12 +221,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
209 | m_part.ParentGroup.HasGroupChanged = true; | 221 | m_part.ParentGroup.HasGroupChanged = true; |
210 | } | 222 | } |
211 | 223 | ||
212 | List<TaskInventoryItem> items = GetInventoryItems(); | 224 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
213 | foreach (TaskInventoryItem item in items) | 225 | foreach (TaskInventoryItem item in items) |
214 | { | 226 | { |
215 | if (groupID != item.GroupID) | 227 | if (groupID != item.GroupID) |
228 | { | ||
216 | item.GroupID = groupID; | 229 | item.GroupID = groupID; |
230 | } | ||
217 | } | 231 | } |
232 | m_items.LockItemsForWrite(false); | ||
233 | } | ||
234 | |||
235 | private void QueryScriptStates() | ||
236 | { | ||
237 | if (m_part == null || m_part.ParentGroup == null) | ||
238 | return; | ||
239 | |||
240 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
241 | if (engines == null) // No engine at all | ||
242 | return; | ||
243 | |||
244 | Items.LockItemsForRead(true); | ||
245 | foreach (TaskInventoryItem item in Items.Values) | ||
246 | { | ||
247 | if (item.InvType == (int)InventoryType.LSL) | ||
248 | { | ||
249 | foreach (IScriptModule e in engines) | ||
250 | { | ||
251 | bool running; | ||
252 | |||
253 | if (e.HasScript(item.ItemID, out running)) | ||
254 | { | ||
255 | item.ScriptRunning = running; | ||
256 | break; | ||
257 | } | ||
258 | } | ||
259 | } | ||
260 | } | ||
261 | |||
262 | Items.LockItemsForRead(false); | ||
218 | } | 263 | } |
219 | 264 | ||
220 | /// <summary> | 265 | /// <summary> |
@@ -222,9 +267,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
222 | /// </summary> | 267 | /// </summary> |
223 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 268 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
224 | { | 269 | { |
225 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 270 | Items.LockItemsForRead(true); |
226 | foreach (TaskInventoryItem item in scripts) | 271 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
227 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | 272 | Items.LockItemsForRead(false); |
273 | foreach (TaskInventoryItem item in items) | ||
274 | { | ||
275 | if ((int)InventoryType.LSL == item.InvType) | ||
276 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | ||
277 | } | ||
228 | } | 278 | } |
229 | 279 | ||
230 | public ArrayList GetScriptErrors(UUID itemID) | 280 | public ArrayList GetScriptErrors(UUID itemID) |
@@ -257,9 +307,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
257 | /// </param> | 307 | /// </param> |
258 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 308 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
259 | { | 309 | { |
260 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 310 | Items.LockItemsForRead(true); |
261 | foreach (TaskInventoryItem item in scripts) | 311 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
262 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | 312 | Items.LockItemsForRead(false); |
313 | |||
314 | foreach (TaskInventoryItem item in items) | ||
315 | { | ||
316 | if ((int)InventoryType.LSL == item.InvType) | ||
317 | { | ||
318 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | ||
319 | m_part.RemoveScriptEvents(item.ItemID); | ||
320 | } | ||
321 | } | ||
263 | } | 322 | } |
264 | 323 | ||
265 | /// <summary> | 324 | /// <summary> |
@@ -275,7 +334,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
275 | // item.Name, item.ItemID, Name, UUID); | 334 | // item.Name, item.ItemID, Name, UUID); |
276 | 335 | ||
277 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) | 336 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) |
337 | { | ||
338 | StoreScriptError(item.ItemID, "no permission"); | ||
278 | return; | 339 | return; |
340 | } | ||
279 | 341 | ||
280 | m_part.AddFlag(PrimFlags.Scripted); | 342 | m_part.AddFlag(PrimFlags.Scripted); |
281 | 343 | ||
@@ -284,14 +346,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
284 | if (stateSource == 2 && // Prim crossing | 346 | if (stateSource == 2 && // Prim crossing |
285 | m_part.ParentGroup.Scene.m_trustBinaries) | 347 | m_part.ParentGroup.Scene.m_trustBinaries) |
286 | { | 348 | { |
287 | lock (m_items) | 349 | m_items.LockItemsForWrite(true); |
288 | { | 350 | m_items[item.ItemID].PermsMask = 0; |
289 | m_items[item.ItemID].PermsMask = 0; | 351 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
290 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 352 | m_items.LockItemsForWrite(false); |
291 | } | ||
292 | |||
293 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 353 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
294 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 354 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
355 | StoreScriptErrors(item.ItemID, null); | ||
295 | m_part.ParentGroup.AddActiveScriptCount(1); | 356 | m_part.ParentGroup.AddActiveScriptCount(1); |
296 | m_part.ScheduleFullUpdate(); | 357 | m_part.ScheduleFullUpdate(); |
297 | return; | 358 | return; |
@@ -300,6 +361,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
300 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); | 361 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
301 | if (null == asset) | 362 | if (null == asset) |
302 | { | 363 | { |
364 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | ||
365 | StoreScriptError(item.ItemID, msg); | ||
303 | m_log.ErrorFormat( | 366 | m_log.ErrorFormat( |
304 | "[PRIM INVENTORY]: " + | 367 | "[PRIM INVENTORY]: " + |
305 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", | 368 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
@@ -311,15 +374,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
311 | if (m_part.ParentGroup.m_savedScriptState != null) | 374 | if (m_part.ParentGroup.m_savedScriptState != null) |
312 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 375 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
313 | 376 | ||
314 | lock (m_items) | 377 | m_items.LockItemsForWrite(true); |
315 | { | 378 | |
316 | m_items[item.ItemID].PermsMask = 0; | 379 | m_items[item.ItemID].PermsMask = 0; |
317 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 380 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
318 | } | 381 | |
382 | m_items.LockItemsForWrite(false); | ||
319 | 383 | ||
320 | string script = Utils.BytesToString(asset.Data); | 384 | string script = Utils.BytesToString(asset.Data); |
321 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 385 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
322 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 386 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
387 | StoreScriptErrors(item.ItemID, null); | ||
388 | if (!item.ScriptRunning) | ||
389 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript( | ||
390 | m_part.LocalId, item.ItemID); | ||
323 | m_part.ParentGroup.AddActiveScriptCount(1); | 391 | m_part.ParentGroup.AddActiveScriptCount(1); |
324 | m_part.ScheduleFullUpdate(); | 392 | m_part.ScheduleFullUpdate(); |
325 | } | 393 | } |
@@ -383,21 +451,145 @@ namespace OpenSim.Region.Framework.Scenes | |||
383 | 451 | ||
384 | /// <summary> | 452 | /// <summary> |
385 | /// Start a script which is in this prim's inventory. | 453 | /// Start a script which is in this prim's inventory. |
454 | /// Some processing may occur in the background, but this routine returns asap. | ||
386 | /// </summary> | 455 | /// </summary> |
387 | /// <param name="itemId"> | 456 | /// <param name="itemId"> |
388 | /// A <see cref="UUID"/> | 457 | /// A <see cref="UUID"/> |
389 | /// </param> | 458 | /// </param> |
390 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 459 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
391 | { | 460 | { |
392 | TaskInventoryItem item = GetInventoryItem(itemId); | 461 | lock (m_scriptErrors) |
393 | if (item != null) | 462 | { |
394 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | 463 | // Indicate to CreateScriptInstanceInternal() we don't want it to wait for completion |
464 | m_scriptErrors.Remove(itemId); | ||
465 | } | ||
466 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
467 | } | ||
468 | |||
469 | private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
470 | { | ||
471 | m_items.LockItemsForRead(true); | ||
472 | if (m_items.ContainsKey(itemId)) | ||
473 | { | ||
474 | if (m_items.ContainsKey(itemId)) | ||
475 | { | ||
476 | m_items.LockItemsForRead(false); | ||
477 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | ||
478 | } | ||
479 | else | ||
480 | { | ||
481 | m_items.LockItemsForRead(false); | ||
482 | string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, | ||
483 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
484 | StoreScriptError(itemId, msg); | ||
485 | m_log.ErrorFormat( | ||
486 | "[PRIM INVENTORY]: " + | ||
487 | "Couldn't start script with ID {0} since it {1}", itemId, msg); | ||
488 | } | ||
489 | } | ||
395 | else | 490 | else |
491 | { | ||
492 | m_items.LockItemsForRead(false); | ||
493 | string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); | ||
494 | StoreScriptError(itemId, msg); | ||
396 | m_log.ErrorFormat( | 495 | m_log.ErrorFormat( |
397 | "[PRIM INVENTORY]: " + | 496 | "[PRIM INVENTORY]: " + |
398 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 497 | "Couldn't start script with ID {0} since it {1}", itemId, msg); |
399 | itemId, m_part.Name, m_part.UUID, | 498 | } |
400 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 499 | |
500 | } | ||
501 | |||
502 | /// <summary> | ||
503 | /// Start a script which is in this prim's inventory and return any compilation error messages. | ||
504 | /// </summary> | ||
505 | /// <param name="itemId"> | ||
506 | /// A <see cref="UUID"/> | ||
507 | /// </param> | ||
508 | public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
509 | { | ||
510 | ArrayList errors; | ||
511 | |||
512 | // Indicate to CreateScriptInstanceInternal() we want it to | ||
513 | // post any compilation/loading error messages | ||
514 | lock (m_scriptErrors) | ||
515 | { | ||
516 | m_scriptErrors[itemId] = null; | ||
517 | } | ||
518 | |||
519 | // Perform compilation/loading | ||
520 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
521 | |||
522 | // Wait for and retrieve any errors | ||
523 | lock (m_scriptErrors) | ||
524 | { | ||
525 | while ((errors = m_scriptErrors[itemId]) == null) | ||
526 | { | ||
527 | if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000)) | ||
528 | { | ||
529 | m_log.ErrorFormat( | ||
530 | "[PRIM INVENTORY]: " + | ||
531 | "timedout waiting for script {0} errors", itemId); | ||
532 | errors = m_scriptErrors[itemId]; | ||
533 | if (errors == null) | ||
534 | { | ||
535 | errors = new ArrayList(1); | ||
536 | errors.Add("timedout waiting for errors"); | ||
537 | } | ||
538 | break; | ||
539 | } | ||
540 | } | ||
541 | m_scriptErrors.Remove(itemId); | ||
542 | } | ||
543 | return errors; | ||
544 | } | ||
545 | |||
546 | // Signal to CreateScriptInstanceEr() that compilation/loading is complete | ||
547 | private void StoreScriptErrors(UUID itemId, ArrayList errors) | ||
548 | { | ||
549 | lock (m_scriptErrors) | ||
550 | { | ||
551 | // If compilation/loading initiated via CreateScriptInstance(), | ||
552 | // it does not want the errors, so just get out | ||
553 | if (!m_scriptErrors.ContainsKey(itemId)) | ||
554 | { | ||
555 | return; | ||
556 | } | ||
557 | |||
558 | // Initiated via CreateScriptInstanceEr(), if we know what the | ||
559 | // errors are, save them and wake CreateScriptInstanceEr(). | ||
560 | if (errors != null) | ||
561 | { | ||
562 | m_scriptErrors[itemId] = errors; | ||
563 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
564 | return; | ||
565 | } | ||
566 | } | ||
567 | |||
568 | // Initiated via CreateScriptInstanceEr() but we don't know what | ||
569 | // the errors are yet, so retrieve them from the script engine. | ||
570 | // This may involve some waiting internal to GetScriptErrors(). | ||
571 | errors = GetScriptErrors(itemId); | ||
572 | |||
573 | // Get a default non-null value to indicate success. | ||
574 | if (errors == null) | ||
575 | { | ||
576 | errors = new ArrayList(); | ||
577 | } | ||
578 | |||
579 | // Post to CreateScriptInstanceEr() and wake it up | ||
580 | lock (m_scriptErrors) | ||
581 | { | ||
582 | m_scriptErrors[itemId] = errors; | ||
583 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
584 | } | ||
585 | } | ||
586 | |||
587 | // Like StoreScriptErrors(), but just posts a single string message | ||
588 | private void StoreScriptError(UUID itemId, string message) | ||
589 | { | ||
590 | ArrayList errors = new ArrayList(1); | ||
591 | errors.Add(message); | ||
592 | StoreScriptErrors(itemId, errors); | ||
401 | } | 593 | } |
402 | 594 | ||
403 | /// <summary> | 595 | /// <summary> |
@@ -410,15 +602,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
410 | /// </param> | 602 | /// </param> |
411 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) | 603 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) |
412 | { | 604 | { |
413 | bool scriptPresent = false; | 605 | if (m_items.ContainsKey(itemId)) |
414 | |||
415 | lock (m_items) | ||
416 | { | ||
417 | if (m_items.ContainsKey(itemId)) | ||
418 | scriptPresent = true; | ||
419 | } | ||
420 | |||
421 | if (scriptPresent) | ||
422 | { | 606 | { |
423 | if (!sceneObjectBeingDeleted) | 607 | if (!sceneObjectBeingDeleted) |
424 | m_part.RemoveScriptEvents(itemId); | 608 | m_part.RemoveScriptEvents(itemId); |
@@ -443,14 +627,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
443 | /// <returns></returns> | 627 | /// <returns></returns> |
444 | private bool InventoryContainsName(string name) | 628 | private bool InventoryContainsName(string name) |
445 | { | 629 | { |
446 | lock (m_items) | 630 | m_items.LockItemsForRead(true); |
631 | foreach (TaskInventoryItem item in m_items.Values) | ||
447 | { | 632 | { |
448 | foreach (TaskInventoryItem item in m_items.Values) | 633 | if (item.Name == name) |
449 | { | 634 | { |
450 | if (item.Name == name) | 635 | m_items.LockItemsForRead(false); |
451 | return true; | 636 | return true; |
452 | } | 637 | } |
453 | } | 638 | } |
639 | m_items.LockItemsForRead(false); | ||
454 | return false; | 640 | return false; |
455 | } | 641 | } |
456 | 642 | ||
@@ -492,8 +678,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
492 | /// <param name="item"></param> | 678 | /// <param name="item"></param> |
493 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 679 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
494 | { | 680 | { |
495 | List<TaskInventoryItem> il = GetInventoryItems(); | 681 | m_items.LockItemsForRead(true); |
496 | 682 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | |
683 | m_items.LockItemsForRead(false); | ||
497 | foreach (TaskInventoryItem i in il) | 684 | foreach (TaskInventoryItem i in il) |
498 | { | 685 | { |
499 | if (i.Name == item.Name) | 686 | if (i.Name == item.Name) |
@@ -531,14 +718,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
531 | item.Name = name; | 718 | item.Name = name; |
532 | item.GroupID = m_part.GroupID; | 719 | item.GroupID = m_part.GroupID; |
533 | 720 | ||
534 | lock (m_items) | 721 | m_items.LockItemsForWrite(true); |
535 | m_items.Add(item.ItemID, item); | 722 | m_items.Add(item.ItemID, item); |
536 | 723 | m_items.LockItemsForWrite(false); | |
537 | if (allowedDrop) | 724 | if (allowedDrop) |
538 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 725 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
539 | else | 726 | else |
540 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 727 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
541 | 728 | ||
542 | m_inventorySerial++; | 729 | m_inventorySerial++; |
543 | //m_inventorySerial += 2; | 730 | //m_inventorySerial += 2; |
544 | HasInventoryChanged = true; | 731 | HasInventoryChanged = true; |
@@ -554,15 +741,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
554 | /// <param name="items"></param> | 741 | /// <param name="items"></param> |
555 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 742 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
556 | { | 743 | { |
557 | lock (m_items) | 744 | m_items.LockItemsForWrite(true); |
745 | foreach (TaskInventoryItem item in items) | ||
558 | { | 746 | { |
559 | foreach (TaskInventoryItem item in items) | 747 | m_items.Add(item.ItemID, item); |
560 | { | 748 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
561 | m_items.Add(item.ItemID, item); | ||
562 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
563 | } | ||
564 | m_inventorySerial++; | ||
565 | } | 749 | } |
750 | m_items.LockItemsForWrite(false); | ||
751 | |||
752 | m_inventorySerial++; | ||
566 | } | 753 | } |
567 | 754 | ||
568 | /// <summary> | 755 | /// <summary> |
@@ -573,10 +760,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
573 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 760 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
574 | { | 761 | { |
575 | TaskInventoryItem item; | 762 | TaskInventoryItem item; |
576 | 763 | m_items.LockItemsForRead(true); | |
577 | lock (m_items) | 764 | m_items.TryGetValue(itemId, out item); |
578 | m_items.TryGetValue(itemId, out item); | 765 | m_items.LockItemsForRead(false); |
579 | |||
580 | return item; | 766 | return item; |
581 | } | 767 | } |
582 | 768 | ||
@@ -592,15 +778,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
592 | { | 778 | { |
593 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 779 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
594 | 780 | ||
595 | lock (m_items) | 781 | m_items.LockItemsForRead(true); |
782 | |||
783 | foreach (TaskInventoryItem item in m_items.Values) | ||
596 | { | 784 | { |
597 | foreach (TaskInventoryItem item in m_items.Values) | 785 | if (item.Name == name) |
598 | { | 786 | items.Add(item); |
599 | if (item.Name == name) | ||
600 | items.Add(item); | ||
601 | } | ||
602 | } | 787 | } |
603 | 788 | ||
789 | m_items.LockItemsForRead(false); | ||
790 | |||
604 | return items; | 791 | return items; |
605 | } | 792 | } |
606 | 793 | ||
@@ -619,6 +806,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
619 | string xmlData = Utils.BytesToString(rezAsset.Data); | 806 | string xmlData = Utils.BytesToString(rezAsset.Data); |
620 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 807 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
621 | 808 | ||
809 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
810 | group.RootPart.AttachOffset = group.AbsolutePosition; | ||
811 | |||
622 | group.ResetIDs(); | 812 | group.ResetIDs(); |
623 | 813 | ||
624 | SceneObjectPart rootPart = group.GetChildPart(group.UUID); | 814 | SceneObjectPart rootPart = group.GetChildPart(group.UUID); |
@@ -693,8 +883,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
693 | 883 | ||
694 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) | 884 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) |
695 | { | 885 | { |
696 | TaskInventoryItem it = GetInventoryItem(item.ItemID); | 886 | m_items.LockItemsForWrite(true); |
697 | if (it != null) | 887 | |
888 | if (m_items.ContainsKey(item.ItemID)) | ||
698 | { | 889 | { |
699 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); | 890 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); |
700 | 891 | ||
@@ -707,14 +898,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
707 | item.GroupID = m_part.GroupID; | 898 | item.GroupID = m_part.GroupID; |
708 | 899 | ||
709 | if (item.AssetID == UUID.Zero) | 900 | if (item.AssetID == UUID.Zero) |
710 | item.AssetID = it.AssetID; | 901 | item.AssetID = m_items[item.ItemID].AssetID; |
711 | 902 | ||
712 | lock (m_items) | 903 | m_items[item.ItemID] = item; |
713 | { | 904 | m_inventorySerial++; |
714 | m_items[item.ItemID] = item; | ||
715 | m_inventorySerial++; | ||
716 | } | ||
717 | |||
718 | if (fireScriptEvents) | 905 | if (fireScriptEvents) |
719 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 906 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
720 | 907 | ||
@@ -723,7 +910,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
723 | HasInventoryChanged = true; | 910 | HasInventoryChanged = true; |
724 | m_part.ParentGroup.HasGroupChanged = true; | 911 | m_part.ParentGroup.HasGroupChanged = true; |
725 | } | 912 | } |
726 | 913 | m_items.LockItemsForWrite(false); | |
727 | return true; | 914 | return true; |
728 | } | 915 | } |
729 | else | 916 | else |
@@ -734,8 +921,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
734 | item.ItemID, m_part.Name, m_part.UUID, | 921 | item.ItemID, m_part.Name, m_part.UUID, |
735 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 922 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
736 | } | 923 | } |
737 | return false; | 924 | m_items.LockItemsForWrite(false); |
738 | 925 | ||
926 | return false; | ||
739 | } | 927 | } |
740 | 928 | ||
741 | /// <summary> | 929 | /// <summary> |
@@ -746,43 +934,59 @@ namespace OpenSim.Region.Framework.Scenes | |||
746 | /// in this prim's inventory.</returns> | 934 | /// in this prim's inventory.</returns> |
747 | public int RemoveInventoryItem(UUID itemID) | 935 | public int RemoveInventoryItem(UUID itemID) |
748 | { | 936 | { |
749 | TaskInventoryItem item = GetInventoryItem(itemID); | 937 | m_items.LockItemsForRead(true); |
750 | if (item != null) | 938 | |
939 | if (m_items.ContainsKey(itemID)) | ||
751 | { | 940 | { |
752 | int type = m_items[itemID].InvType; | 941 | int type = m_items[itemID].InvType; |
942 | m_items.LockItemsForRead(false); | ||
753 | if (type == 10) // Script | 943 | if (type == 10) // Script |
754 | { | 944 | { |
755 | m_part.RemoveScriptEvents(itemID); | ||
756 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 945 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
757 | } | 946 | } |
947 | m_items.LockItemsForWrite(true); | ||
758 | m_items.Remove(itemID); | 948 | m_items.Remove(itemID); |
949 | m_items.LockItemsForWrite(false); | ||
759 | m_inventorySerial++; | 950 | m_inventorySerial++; |
760 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 951 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
761 | 952 | ||
762 | HasInventoryChanged = true; | 953 | HasInventoryChanged = true; |
763 | m_part.ParentGroup.HasGroupChanged = true; | 954 | m_part.ParentGroup.HasGroupChanged = true; |
764 | 955 | ||
765 | if (!ContainsScripts()) | 956 | int scriptcount = 0; |
957 | m_items.LockItemsForRead(true); | ||
958 | foreach (TaskInventoryItem item in m_items.Values) | ||
959 | { | ||
960 | if (item.Type == 10) | ||
961 | { | ||
962 | scriptcount++; | ||
963 | } | ||
964 | } | ||
965 | m_items.LockItemsForRead(false); | ||
966 | |||
967 | |||
968 | if (scriptcount <= 0) | ||
969 | { | ||
766 | m_part.RemFlag(PrimFlags.Scripted); | 970 | m_part.RemFlag(PrimFlags.Scripted); |
971 | } | ||
767 | 972 | ||
768 | m_part.ScheduleFullUpdate(); | 973 | m_part.ScheduleFullUpdate(); |
769 | 974 | ||
770 | return type; | 975 | return type; |
771 | |||
772 | } | 976 | } |
773 | else | 977 | else |
774 | { | 978 | { |
979 | m_items.LockItemsForRead(false); | ||
775 | m_log.ErrorFormat( | 980 | m_log.ErrorFormat( |
776 | "[PRIM INVENTORY]: " + | 981 | "[PRIM INVENTORY]: " + |
777 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 982 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", |
778 | itemID, m_part.Name, m_part.UUID, | 983 | itemID, m_part.Name, m_part.UUID); |
779 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
780 | } | 984 | } |
781 | 985 | ||
782 | return -1; | 986 | return -1; |
783 | } | 987 | } |
784 | 988 | ||
785 | private bool CreateInventoryFile() | 989 | private bool CreateInventoryFileName() |
786 | { | 990 | { |
787 | // m_log.DebugFormat( | 991 | // m_log.DebugFormat( |
788 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", | 992 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", |
@@ -791,116 +995,125 @@ namespace OpenSim.Region.Framework.Scenes | |||
791 | if (m_inventoryFileName == String.Empty || | 995 | if (m_inventoryFileName == String.Empty || |
792 | m_inventoryFileNameSerial < m_inventorySerial) | 996 | m_inventoryFileNameSerial < m_inventorySerial) |
793 | { | 997 | { |
794 | // Something changed, we need to create a new file | ||
795 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; | 998 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; |
796 | m_inventoryFileNameSerial = m_inventorySerial; | 999 | m_inventoryFileNameSerial = m_inventorySerial; |
797 | 1000 | ||
798 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 1001 | return true; |
1002 | } | ||
1003 | |||
1004 | return false; | ||
1005 | } | ||
1006 | |||
1007 | /// <summary> | ||
1008 | /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client | ||
1009 | /// </summary> | ||
1010 | /// <param name="xferManager"></param> | ||
1011 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) | ||
1012 | { | ||
1013 | bool changed = CreateInventoryFileName(); | ||
1014 | |||
1015 | bool includeAssets = false; | ||
1016 | if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) | ||
1017 | includeAssets = true; | ||
1018 | |||
1019 | if (m_inventoryPrivileged != includeAssets) | ||
1020 | changed = true; | ||
1021 | |||
1022 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | ||
1023 | |||
1024 | Items.LockItemsForRead(true); | ||
1025 | |||
1026 | if (m_inventorySerial == 0) // No inventory | ||
1027 | { | ||
1028 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1029 | Items.LockItemsForRead(false); | ||
1030 | return; | ||
1031 | } | ||
799 | 1032 | ||
800 | lock (m_items) | 1033 | if (m_items.Count == 0) // No inventory |
1034 | { | ||
1035 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1036 | Items.LockItemsForRead(false); | ||
1037 | return; | ||
1038 | } | ||
1039 | |||
1040 | if (!changed) | ||
1041 | { | ||
1042 | if (m_inventoryFileData.Length > 2) | ||
801 | { | 1043 | { |
802 | foreach (TaskInventoryItem item in m_items.Values) | 1044 | xferManager.AddNewFile(m_inventoryFileName, |
803 | { | 1045 | m_inventoryFileData); |
804 | // m_log.DebugFormat( | 1046 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, |
805 | // "[PRIM INVENTORY]: Adding item {0} {1} for serial {2} on prim {3} {4} {5}", | 1047 | Util.StringToBytes256(m_inventoryFileName)); |
806 | // item.Name, item.ItemID, m_inventorySerial, m_part.Name, m_part.UUID, m_part.LocalId); | ||
807 | 1048 | ||
808 | UUID ownerID = item.OwnerID; | 1049 | Items.LockItemsForRead(false); |
809 | uint everyoneMask = 0; | 1050 | return; |
810 | uint baseMask = item.BasePermissions; | 1051 | } |
811 | uint ownerMask = item.CurrentPermissions; | 1052 | } |
812 | uint groupMask = item.GroupPermissions; | ||
813 | 1053 | ||
814 | invString.AddItemStart(); | 1054 | m_inventoryPrivileged = includeAssets; |
815 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | ||
816 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
817 | 1055 | ||
818 | invString.AddPermissionsStart(); | 1056 | foreach (TaskInventoryItem item in m_items.Values) |
1057 | { | ||
1058 | UUID ownerID = item.OwnerID; | ||
1059 | uint everyoneMask = 0; | ||
1060 | uint baseMask = item.BasePermissions; | ||
1061 | uint ownerMask = item.CurrentPermissions; | ||
1062 | uint groupMask = item.GroupPermissions; | ||
819 | 1063 | ||
820 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 1064 | invString.AddItemStart(); |
821 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 1065 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
822 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | 1066 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); |
823 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
824 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
825 | 1067 | ||
826 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | 1068 | invString.AddPermissionsStart(); |
827 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
828 | 1069 | ||
829 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | 1070 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); |
1071 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
1072 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
1073 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
1074 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
830 | 1075 | ||
831 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | 1076 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); |
832 | invString.AddSectionEnd(); | 1077 | invString.AddNameValueLine("owner_id", ownerID.ToString()); |
833 | 1078 | ||
834 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | 1079 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); |
835 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); | ||
836 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); | ||
837 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
838 | 1080 | ||
839 | invString.AddSaleStart(); | 1081 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); |
840 | invString.AddNameValueLine("sale_type", "not"); | 1082 | invString.AddSectionEnd(); |
841 | invString.AddNameValueLine("sale_price", "0"); | ||
842 | invString.AddSectionEnd(); | ||
843 | 1083 | ||
844 | invString.AddNameValueLine("name", item.Name + "|"); | 1084 | if (includeAssets) |
845 | invString.AddNameValueLine("desc", item.Description + "|"); | 1085 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); |
1086 | else | ||
1087 | invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); | ||
1088 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); | ||
1089 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); | ||
1090 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
846 | 1091 | ||
847 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | 1092 | invString.AddSaleStart(); |
848 | invString.AddSectionEnd(); | 1093 | invString.AddNameValueLine("sale_type", "not"); |
849 | } | 1094 | invString.AddNameValueLine("sale_price", "0"); |
850 | } | 1095 | invString.AddSectionEnd(); |
851 | 1096 | ||
852 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | 1097 | invString.AddNameValueLine("name", item.Name + "|"); |
1098 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
853 | 1099 | ||
854 | return true; | 1100 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); |
1101 | invString.AddSectionEnd(); | ||
855 | } | 1102 | } |
856 | 1103 | ||
857 | // No need to recreate, the existing file is fine | 1104 | Items.LockItemsForRead(false); |
858 | return false; | ||
859 | } | ||
860 | 1105 | ||
861 | /// <summary> | 1106 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); |
862 | /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client | ||
863 | /// </summary> | ||
864 | /// <param name="xferManager"></param> | ||
865 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) | ||
866 | { | ||
867 | lock (m_items) | ||
868 | { | ||
869 | // Don't send a inventory xfer name if there are no items. Doing so causes viewer 3 to crash when rezzing | ||
870 | // a new script if any previous deletion has left the prim inventory empty. | ||
871 | if (m_items.Count == 0) // No inventory | ||
872 | { | ||
873 | // m_log.DebugFormat( | ||
874 | // "[PRIM INVENTORY]: Not sending inventory data for part {0} {1} {2} for {3} since no items", | ||
875 | // m_part.Name, m_part.LocalId, m_part.UUID, client.Name); | ||
876 | 1107 | ||
877 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | 1108 | if (m_inventoryFileData.Length > 2) |
878 | return; | 1109 | { |
879 | } | 1110 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); |
880 | 1111 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | |
881 | CreateInventoryFile(); | 1112 | Util.StringToBytes256(m_inventoryFileName)); |
882 | 1113 | return; | |
883 | // In principle, we should only do the rest if the inventory changed; | ||
884 | // by sending m_inventorySerial to the client, it ought to know | ||
885 | // that nothing changed and that it doesn't need to request the file. | ||
886 | // Unfortunately, it doesn't look like the client optimizes this; | ||
887 | // the client seems to always come back and request the Xfer, | ||
888 | // no matter what value m_inventorySerial has. | ||
889 | // FIXME: Could probably be > 0 here rather than > 2 | ||
890 | if (m_inventoryFileData.Length > 2) | ||
891 | { | ||
892 | // Add the file for Xfer | ||
893 | // m_log.DebugFormat( | ||
894 | // "[PRIM INVENTORY]: Adding inventory file {0} (length {1}) for transfer on {2} {3} {4}", | ||
895 | // m_inventoryFileName, m_inventoryFileData.Length, m_part.Name, m_part.UUID, m_part.LocalId); | ||
896 | |||
897 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | ||
898 | } | ||
899 | |||
900 | // Tell the client we're ready to Xfer the file | ||
901 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
902 | Util.StringToBytes256(m_inventoryFileName)); | ||
903 | } | 1114 | } |
1115 | |||
1116 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
904 | } | 1117 | } |
905 | 1118 | ||
906 | /// <summary> | 1119 | /// <summary> |
@@ -911,10 +1124,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
911 | { | 1124 | { |
912 | if (HasInventoryChanged) | 1125 | if (HasInventoryChanged) |
913 | { | 1126 | { |
914 | HasInventoryChanged = false; | 1127 | Items.LockItemsForRead(true); |
915 | List<TaskInventoryItem> items = GetInventoryItems(); | 1128 | datastore.StorePrimInventory(m_part.UUID, Items.Values); |
916 | datastore.StorePrimInventory(m_part.UUID, items); | 1129 | Items.LockItemsForRead(false); |
917 | 1130 | ||
1131 | HasInventoryChanged = false; | ||
918 | } | 1132 | } |
919 | } | 1133 | } |
920 | 1134 | ||
@@ -981,82 +1195,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
981 | { | 1195 | { |
982 | uint mask=0x7fffffff; | 1196 | uint mask=0x7fffffff; |
983 | 1197 | ||
984 | lock (m_items) | 1198 | foreach (TaskInventoryItem item in m_items.Values) |
985 | { | 1199 | { |
986 | foreach (TaskInventoryItem item in m_items.Values) | 1200 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) |
1201 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1202 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1203 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1204 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1205 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1206 | |||
1207 | if (item.InvType == (int)InventoryType.Object) | ||
987 | { | 1208 | { |
988 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | 1209 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
989 | mask &= ~((uint)PermissionMask.Copy >> 13); | 1210 | mask &= ~((uint)PermissionMask.Copy >> 13); |
990 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | 1211 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
991 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1212 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
992 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | 1213 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
993 | mask &= ~((uint)PermissionMask.Modify >> 13); | 1214 | mask &= ~((uint)PermissionMask.Modify >> 13); |
994 | |||
995 | if (item.InvType != (int)InventoryType.Object) | ||
996 | { | ||
997 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | ||
998 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
999 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1000 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1001 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1002 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1003 | } | ||
1004 | else | ||
1005 | { | ||
1006 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1007 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1008 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1009 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1010 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1011 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1012 | } | ||
1013 | |||
1014 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1015 | mask &= ~(uint)PermissionMask.Copy; | ||
1016 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1017 | mask &= ~(uint)PermissionMask.Transfer; | ||
1018 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1019 | mask &= ~(uint)PermissionMask.Modify; | ||
1020 | } | 1215 | } |
1216 | |||
1217 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1218 | mask &= ~(uint)PermissionMask.Copy; | ||
1219 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1220 | mask &= ~(uint)PermissionMask.Transfer; | ||
1221 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1222 | mask &= ~(uint)PermissionMask.Modify; | ||
1021 | } | 1223 | } |
1022 | |||
1023 | return mask; | 1224 | return mask; |
1024 | } | 1225 | } |
1025 | 1226 | ||
1026 | public void ApplyNextOwnerPermissions() | 1227 | public void ApplyNextOwnerPermissions() |
1027 | { | 1228 | { |
1028 | lock (m_items) | 1229 | foreach (TaskInventoryItem item in m_items.Values) |
1029 | { | 1230 | { |
1030 | foreach (TaskInventoryItem item in m_items.Values) | 1231 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) |
1031 | { | 1232 | { |
1032 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) | 1233 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1033 | { | 1234 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |
1034 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | 1235 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1035 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | 1236 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; |
1036 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | 1237 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1037 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | 1238 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
1038 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1039 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | ||
1040 | } | ||
1041 | item.CurrentPermissions &= item.NextPermissions; | ||
1042 | item.BasePermissions &= item.NextPermissions; | ||
1043 | item.EveryonePermissions &= item.NextPermissions; | ||
1044 | item.OwnerChanged = true; | ||
1045 | item.PermsMask = 0; | ||
1046 | item.PermsGranter = UUID.Zero; | ||
1047 | } | 1239 | } |
1240 | item.OwnerChanged = true; | ||
1241 | item.CurrentPermissions &= item.NextPermissions; | ||
1242 | item.BasePermissions &= item.NextPermissions; | ||
1243 | item.EveryonePermissions &= item.NextPermissions; | ||
1244 | item.PermsMask = 0; | ||
1245 | item.PermsGranter = UUID.Zero; | ||
1048 | } | 1246 | } |
1049 | } | 1247 | } |
1050 | 1248 | ||
1051 | public void ApplyGodPermissions(uint perms) | 1249 | public void ApplyGodPermissions(uint perms) |
1052 | { | 1250 | { |
1053 | lock (m_items) | 1251 | foreach (TaskInventoryItem item in m_items.Values) |
1054 | { | 1252 | { |
1055 | foreach (TaskInventoryItem item in m_items.Values) | 1253 | item.CurrentPermissions = perms; |
1056 | { | 1254 | item.BasePermissions = perms; |
1057 | item.CurrentPermissions = perms; | ||
1058 | item.BasePermissions = perms; | ||
1059 | } | ||
1060 | } | 1255 | } |
1061 | 1256 | ||
1062 | m_inventorySerial++; | 1257 | m_inventorySerial++; |
@@ -1069,17 +1264,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1069 | /// <returns></returns> | 1264 | /// <returns></returns> |
1070 | public bool ContainsScripts() | 1265 | public bool ContainsScripts() |
1071 | { | 1266 | { |
1072 | lock (m_items) | 1267 | foreach (TaskInventoryItem item in m_items.Values) |
1073 | { | 1268 | { |
1074 | foreach (TaskInventoryItem item in m_items.Values) | 1269 | if (item.InvType == (int)InventoryType.LSL) |
1075 | { | 1270 | { |
1076 | if (item.InvType == (int)InventoryType.LSL) | 1271 | return true; |
1077 | { | ||
1078 | return true; | ||
1079 | } | ||
1080 | } | 1272 | } |
1081 | } | 1273 | } |
1082 | |||
1083 | return false; | 1274 | return false; |
1084 | } | 1275 | } |
1085 | 1276 | ||
@@ -1087,11 +1278,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1087 | { | 1278 | { |
1088 | List<UUID> ret = new List<UUID>(); | 1279 | List<UUID> ret = new List<UUID>(); |
1089 | 1280 | ||
1090 | lock (m_items) | 1281 | foreach (TaskInventoryItem item in m_items.Values) |
1091 | { | 1282 | ret.Add(item.ItemID); |
1092 | foreach (TaskInventoryItem item in m_items.Values) | ||
1093 | ret.Add(item.ItemID); | ||
1094 | } | ||
1095 | 1283 | ||
1096 | return ret; | 1284 | return ret; |
1097 | } | 1285 | } |
@@ -1122,6 +1310,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1122 | 1310 | ||
1123 | public Dictionary<UUID, string> GetScriptStates() | 1311 | public Dictionary<UUID, string> GetScriptStates() |
1124 | { | 1312 | { |
1313 | return GetScriptStates(false); | ||
1314 | } | ||
1315 | |||
1316 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1317 | { | ||
1125 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1318 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
1126 | 1319 | ||
1127 | if (m_part.ParentGroup.Scene == null) // Group not in a scene | 1320 | if (m_part.ParentGroup.Scene == null) // Group not in a scene |
@@ -1132,25 +1325,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
1132 | if (engines == null) // No engine at all | 1325 | if (engines == null) // No engine at all |
1133 | return ret; | 1326 | return ret; |
1134 | 1327 | ||
1135 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 1328 | Items.LockItemsForRead(true); |
1136 | 1329 | foreach (TaskInventoryItem item in m_items.Values) | |
1137 | foreach (TaskInventoryItem item in scripts) | ||
1138 | { | 1330 | { |
1139 | foreach (IScriptModule e in engines) | 1331 | if (item.InvType == (int)InventoryType.LSL) |
1140 | { | 1332 | { |
1141 | if (e != null) | 1333 | foreach (IScriptModule e in engines) |
1142 | { | 1334 | { |
1143 | string n = e.GetXMLState(item.ItemID); | 1335 | if (e != null) |
1144 | if (n != String.Empty) | ||
1145 | { | 1336 | { |
1146 | if (!ret.ContainsKey(item.ItemID)) | 1337 | string n = e.GetXMLState(item.ItemID); |
1147 | ret[item.ItemID] = n; | 1338 | if (n != String.Empty) |
1148 | break; | 1339 | { |
1340 | if (oldIDs) | ||
1341 | { | ||
1342 | if (!ret.ContainsKey(item.OldItemID)) | ||
1343 | ret[item.OldItemID] = n; | ||
1344 | } | ||
1345 | else | ||
1346 | { | ||
1347 | if (!ret.ContainsKey(item.ItemID)) | ||
1348 | ret[item.ItemID] = n; | ||
1349 | } | ||
1350 | break; | ||
1351 | } | ||
1149 | } | 1352 | } |
1150 | } | 1353 | } |
1151 | } | 1354 | } |
1152 | } | 1355 | } |
1153 | 1356 | Items.LockItemsForRead(false); | |
1154 | return ret; | 1357 | return ret; |
1155 | } | 1358 | } |
1156 | 1359 | ||
@@ -1160,21 +1363,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
1160 | if (engines == null) | 1363 | if (engines == null) |
1161 | return; | 1364 | return; |
1162 | 1365 | ||
1163 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | ||
1164 | 1366 | ||
1165 | foreach (TaskInventoryItem item in scripts) | 1367 | Items.LockItemsForRead(true); |
1368 | |||
1369 | foreach (TaskInventoryItem item in m_items.Values) | ||
1166 | { | 1370 | { |
1167 | foreach (IScriptModule engine in engines) | 1371 | if (item.InvType == (int)InventoryType.LSL) |
1168 | { | 1372 | { |
1169 | if (engine != null) | 1373 | foreach (IScriptModule engine in engines) |
1170 | { | 1374 | { |
1171 | if (item.OwnerChanged) | 1375 | if (engine != null) |
1172 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | 1376 | { |
1173 | item.OwnerChanged = false; | 1377 | if (item.OwnerChanged) |
1174 | engine.ResumeScript(item.ItemID); | 1378 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); |
1379 | item.OwnerChanged = false; | ||
1380 | engine.ResumeScript(item.ItemID); | ||
1381 | } | ||
1175 | } | 1382 | } |
1176 | } | 1383 | } |
1177 | } | 1384 | } |
1385 | |||
1386 | Items.LockItemsForRead(false); | ||
1178 | } | 1387 | } |
1179 | } | 1388 | } |
1180 | } | 1389 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ce638e0..76bc390 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -153,6 +153,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
153 | private int m_lastColCount = -1; //KF: Look for Collision chnages | 153 | private int m_lastColCount = -1; //KF: Look for Collision chnages |
154 | private int m_updateCount = 0; //KF: Update Anims for a while | 154 | private int m_updateCount = 0; //KF: Update Anims for a while |
155 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 155 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
156 | private List<uint> m_lastColliders = new List<uint>(); | ||
156 | 157 | ||
157 | private TeleportFlags m_teleportFlags; | 158 | private TeleportFlags m_teleportFlags; |
158 | public TeleportFlags TeleportFlags | 159 | public TeleportFlags TeleportFlags |
@@ -919,6 +920,62 @@ namespace OpenSim.Region.Framework.Scenes | |||
919 | pos.Y = crossedBorder.BorderLine.Z - 1; | 920 | pos.Y = crossedBorder.BorderLine.Z - 1; |
920 | } | 921 | } |
921 | 922 | ||
923 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
924 | if (land != null) | ||
925 | { | ||
926 | // If we come in via login, landmark or map, we want to | ||
927 | // honor landing points. If we come in via Lure, we want | ||
928 | // to ignore them. | ||
929 | if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || | ||
930 | (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || | ||
931 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0) | ||
932 | { | ||
933 | // Don't restrict gods, estate managers, or land owners to | ||
934 | // the TP point. This behaviour mimics agni. | ||
935 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
936 | land.LandData.UserLocation != Vector3.Zero && | ||
937 | GodLevel < 200 && | ||
938 | ((land.LandData.OwnerID != m_uuid && | ||
939 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
940 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) | ||
941 | { | ||
942 | pos = land.LandData.UserLocation; | ||
943 | } | ||
944 | } | ||
945 | |||
946 | land.SendLandUpdateToClient(ControllingClient); | ||
947 | } | ||
948 | |||
949 | if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) | ||
950 | { | ||
951 | Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); | ||
952 | |||
953 | if (pos.X < 0) | ||
954 | { | ||
955 | emergencyPos.X = (int)Constants.RegionSize + pos.X; | ||
956 | if (!(pos.Y < 0)) | ||
957 | emergencyPos.Y = pos.Y; | ||
958 | if (!(pos.Z < 0)) | ||
959 | emergencyPos.Z = pos.Z; | ||
960 | } | ||
961 | if (pos.Y < 0) | ||
962 | { | ||
963 | emergencyPos.Y = (int)Constants.RegionSize + pos.Y; | ||
964 | if (!(pos.X < 0)) | ||
965 | emergencyPos.X = pos.X; | ||
966 | if (!(pos.Z < 0)) | ||
967 | emergencyPos.Z = pos.Z; | ||
968 | } | ||
969 | if (pos.Z < 0) | ||
970 | { | ||
971 | emergencyPos.Z = 128; | ||
972 | if (!(pos.Y < 0)) | ||
973 | emergencyPos.Y = pos.Y; | ||
974 | if (!(pos.X < 0)) | ||
975 | emergencyPos.X = pos.X; | ||
976 | } | ||
977 | } | ||
978 | |||
922 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 979 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
923 | { | 980 | { |
924 | m_log.WarnFormat( | 981 | m_log.WarnFormat( |
@@ -1081,6 +1138,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1081 | 1138 | ||
1082 | RemoveFromPhysicalScene(); | 1139 | RemoveFromPhysicalScene(); |
1083 | Velocity = Vector3.Zero; | 1140 | Velocity = Vector3.Zero; |
1141 | CheckLandingPoint(ref pos); | ||
1084 | AbsolutePosition = pos; | 1142 | AbsolutePosition = pos; |
1085 | AddToPhysicalScene(isFlying); | 1143 | AddToPhysicalScene(isFlying); |
1086 | 1144 | ||
@@ -1094,6 +1152,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1094 | isFlying = PhysicsActor.Flying; | 1152 | isFlying = PhysicsActor.Flying; |
1095 | 1153 | ||
1096 | RemoveFromPhysicalScene(); | 1154 | RemoveFromPhysicalScene(); |
1155 | CheckLandingPoint(ref pos); | ||
1097 | AbsolutePosition = pos; | 1156 | AbsolutePosition = pos; |
1098 | AddToPhysicalScene(isFlying); | 1157 | AddToPhysicalScene(isFlying); |
1099 | 1158 | ||
@@ -3398,6 +3457,148 @@ namespace OpenSim.Region.Framework.Scenes | |||
3398 | } | 3457 | } |
3399 | } | 3458 | } |
3400 | 3459 | ||
3460 | List<uint> thisHitColliders = new List<uint>(); | ||
3461 | List<uint> endedColliders = new List<uint>(); | ||
3462 | List<uint> startedColliders = new List<uint>(); | ||
3463 | |||
3464 | foreach (uint localid in coldata.Keys) | ||
3465 | { | ||
3466 | thisHitColliders.Add(localid); | ||
3467 | if (!m_lastColliders.Contains(localid)) | ||
3468 | { | ||
3469 | startedColliders.Add(localid); | ||
3470 | } | ||
3471 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3472 | } | ||
3473 | |||
3474 | // calculate things that ended colliding | ||
3475 | foreach (uint localID in m_lastColliders) | ||
3476 | { | ||
3477 | if (!thisHitColliders.Contains(localID)) | ||
3478 | { | ||
3479 | endedColliders.Add(localID); | ||
3480 | } | ||
3481 | } | ||
3482 | //add the items that started colliding this time to the last colliders list. | ||
3483 | foreach (uint localID in startedColliders) | ||
3484 | { | ||
3485 | m_lastColliders.Add(localID); | ||
3486 | } | ||
3487 | // remove things that ended colliding from the last colliders list | ||
3488 | foreach (uint localID in endedColliders) | ||
3489 | { | ||
3490 | m_lastColliders.Remove(localID); | ||
3491 | } | ||
3492 | |||
3493 | // do event notification | ||
3494 | if (startedColliders.Count > 0) | ||
3495 | { | ||
3496 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3497 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3498 | foreach (uint localId in startedColliders) | ||
3499 | { | ||
3500 | if (localId == 0) | ||
3501 | continue; | ||
3502 | |||
3503 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3504 | string data = ""; | ||
3505 | if (obj != null) | ||
3506 | { | ||
3507 | DetectedObject detobj = new DetectedObject(); | ||
3508 | detobj.keyUUID = obj.UUID; | ||
3509 | detobj.nameStr = obj.Name; | ||
3510 | detobj.ownerUUID = obj.OwnerID; | ||
3511 | detobj.posVector = obj.AbsolutePosition; | ||
3512 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3513 | detobj.velVector = obj.Velocity; | ||
3514 | detobj.colliderType = 0; | ||
3515 | detobj.groupUUID = obj.GroupID; | ||
3516 | colliding.Add(detobj); | ||
3517 | } | ||
3518 | } | ||
3519 | |||
3520 | if (colliding.Count > 0) | ||
3521 | { | ||
3522 | StartCollidingMessage.Colliders = colliding; | ||
3523 | |||
3524 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3525 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3526 | } | ||
3527 | } | ||
3528 | |||
3529 | if (endedColliders.Count > 0) | ||
3530 | { | ||
3531 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3532 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3533 | foreach (uint localId in endedColliders) | ||
3534 | { | ||
3535 | if (localId == 0) | ||
3536 | continue; | ||
3537 | |||
3538 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3539 | string data = ""; | ||
3540 | if (obj != null) | ||
3541 | { | ||
3542 | DetectedObject detobj = new DetectedObject(); | ||
3543 | detobj.keyUUID = obj.UUID; | ||
3544 | detobj.nameStr = obj.Name; | ||
3545 | detobj.ownerUUID = obj.OwnerID; | ||
3546 | detobj.posVector = obj.AbsolutePosition; | ||
3547 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3548 | detobj.velVector = obj.Velocity; | ||
3549 | detobj.colliderType = 0; | ||
3550 | detobj.groupUUID = obj.GroupID; | ||
3551 | colliding.Add(detobj); | ||
3552 | } | ||
3553 | } | ||
3554 | |||
3555 | if (colliding.Count > 0) | ||
3556 | { | ||
3557 | EndCollidingMessage.Colliders = colliding; | ||
3558 | |||
3559 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3560 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
3561 | } | ||
3562 | } | ||
3563 | |||
3564 | if (thisHitColliders.Count > 0) | ||
3565 | { | ||
3566 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
3567 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3568 | foreach (uint localId in thisHitColliders) | ||
3569 | { | ||
3570 | if (localId == 0) | ||
3571 | continue; | ||
3572 | |||
3573 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3574 | string data = ""; | ||
3575 | if (obj != null) | ||
3576 | { | ||
3577 | DetectedObject detobj = new DetectedObject(); | ||
3578 | detobj.keyUUID = obj.UUID; | ||
3579 | detobj.nameStr = obj.Name; | ||
3580 | detobj.ownerUUID = obj.OwnerID; | ||
3581 | detobj.posVector = obj.AbsolutePosition; | ||
3582 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3583 | detobj.velVector = obj.Velocity; | ||
3584 | detobj.colliderType = 0; | ||
3585 | detobj.groupUUID = obj.GroupID; | ||
3586 | colliding.Add(detobj); | ||
3587 | } | ||
3588 | } | ||
3589 | |||
3590 | if (colliding.Count > 0) | ||
3591 | { | ||
3592 | CollidingMessage.Colliders = colliding; | ||
3593 | |||
3594 | lock (m_attachments) | ||
3595 | { | ||
3596 | foreach (SceneObjectGroup att in m_attachments) | ||
3597 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
3598 | } | ||
3599 | } | ||
3600 | } | ||
3601 | |||
3401 | if (Invulnerable) | 3602 | if (Invulnerable) |
3402 | return; | 3603 | return; |
3403 | 3604 | ||
@@ -3836,5 +4037,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
3836 | m_reprioritization_called = false; | 4037 | m_reprioritization_called = false; |
3837 | } | 4038 | } |
3838 | } | 4039 | } |
4040 | |||
4041 | private void CheckLandingPoint(ref Vector3 pos) | ||
4042 | { | ||
4043 | // Never constrain lures | ||
4044 | if ((TeleportFlags & TeleportFlags.ViaLure) != 0) | ||
4045 | return; | ||
4046 | |||
4047 | if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) | ||
4048 | return; | ||
4049 | |||
4050 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
4051 | |||
4052 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
4053 | land.LandData.UserLocation != Vector3.Zero && | ||
4054 | land.LandData.OwnerID != m_uuid && | ||
4055 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
4056 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | ||
4057 | { | ||
4058 | float curr = Vector3.Distance(AbsolutePosition, pos); | ||
4059 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | ||
4060 | pos = land.LandData.UserLocation; | ||
4061 | else | ||
4062 | ControllingClient.SendAlertMessage("Can't teleport closer to destination"); | ||
4063 | } | ||
4064 | } | ||
3839 | } | 4065 | } |
3840 | } | 4066 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index d6bb81c..2c3084c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs | |||
@@ -123,7 +123,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
123 | g.ScheduleFullUpdateToAvatar(m_presence); | 123 | g.ScheduleFullUpdateToAvatar(m_presence); |
124 | } | 124 | } |
125 | 125 | ||
126 | while (m_partsUpdateQueue.Count > 0) | 126 | while (m_partsUpdateQueue != null && m_partsUpdateQueue.Count != null && m_partsUpdateQueue.Count > 0) |
127 | { | 127 | { |
128 | SceneObjectPart part = m_partsUpdateQueue.Dequeue(); | 128 | SceneObjectPart part = m_partsUpdateQueue.Dequeue(); |
129 | 129 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 60cc788..680a6fa 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -345,6 +345,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
345 | m_SOPXmlProcessors.Add("PayPrice2", ProcessPayPrice2); | 345 | m_SOPXmlProcessors.Add("PayPrice2", ProcessPayPrice2); |
346 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); | 346 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); |
347 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); | 347 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); |
348 | |||
349 | m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); | ||
348 | #endregion | 350 | #endregion |
349 | 351 | ||
350 | #region TaskInventoryXmlProcessors initialization | 352 | #region TaskInventoryXmlProcessors initialization |
@@ -729,6 +731,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
729 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); | 731 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); |
730 | } | 732 | } |
731 | 733 | ||
734 | private static void ProcessBuoyancy(SceneObjectPart obj, XmlTextReader reader) | ||
735 | { | ||
736 | obj.Buoyancy = (int)reader.ReadElementContentAsFloat("Buoyancy", String.Empty); | ||
737 | } | ||
738 | |||
732 | #endregion | 739 | #endregion |
733 | 740 | ||
734 | #region TaskInventoryXmlProcessors | 741 | #region TaskInventoryXmlProcessors |
@@ -1212,6 +1219,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1212 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); | 1219 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); |
1213 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); | 1220 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); |
1214 | 1221 | ||
1222 | writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); | ||
1223 | |||
1215 | writer.WriteEndElement(); | 1224 | writer.WriteEndElement(); |
1216 | } | 1225 | } |
1217 | 1226 | ||
@@ -1496,12 +1505,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1496 | { | 1505 | { |
1497 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); | 1506 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); |
1498 | 1507 | ||
1499 | if (reader.IsEmptyElement) | ||
1500 | { | ||
1501 | reader.Read(); | ||
1502 | return tinv; | ||
1503 | } | ||
1504 | |||
1505 | reader.ReadStartElement(name, String.Empty); | 1508 | reader.ReadStartElement(name, String.Empty); |
1506 | 1509 | ||
1507 | while (reader.Name == "TaskInventoryItem") | 1510 | while (reader.Name == "TaskInventoryItem") |
@@ -1544,12 +1547,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1544 | 1547 | ||
1545 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); | 1548 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); |
1546 | 1549 | ||
1547 | if (reader.IsEmptyElement) | ||
1548 | { | ||
1549 | reader.Read(); | ||
1550 | return shape; | ||
1551 | } | ||
1552 | |||
1553 | reader.ReadStartElement(name, String.Empty); // Shape | 1550 | reader.ReadStartElement(name, String.Empty); // Shape |
1554 | 1551 | ||
1555 | string nodeName = string.Empty; | 1552 | string nodeName = string.Empty; |
@@ -1589,4 +1586,4 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1589 | 1586 | ||
1590 | #endregion | 1587 | #endregion |
1591 | } | 1588 | } |
1592 | } | 1589 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 860172c..5ed3c79 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs | |||
@@ -30,12 +30,27 @@ using System.Reflection; | |||
30 | using log4net; | 30 | using log4net; |
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSim.Region.Framework.Interfaces; | 32 | using OpenSim.Region.Framework.Interfaces; |
33 | using System; | ||
33 | 34 | ||
34 | namespace OpenSim.Region.Framework.Scenes | 35 | namespace OpenSim.Region.Framework.Scenes |
35 | { | 36 | { |
37 | [Flags] | ||
38 | public enum UndoType | ||
39 | { | ||
40 | STATE_PRIM_POSITION = 1, | ||
41 | STATE_PRIM_ROTATION = 2, | ||
42 | STATE_PRIM_SCALE = 4, | ||
43 | STATE_PRIM_ALL = 7, | ||
44 | STATE_GROUP_POSITION = 8, | ||
45 | STATE_GROUP_ROTATION = 16, | ||
46 | STATE_GROUP_SCALE = 32, | ||
47 | STATE_GROUP_ALL = 56, | ||
48 | STATE_ALL = 63 | ||
49 | } | ||
50 | |||
36 | public class UndoState | 51 | public class UndoState |
37 | { | 52 | { |
38 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
39 | 54 | ||
40 | public Vector3 Position = Vector3.Zero; | 55 | public Vector3 Position = Vector3.Zero; |
41 | public Vector3 Scale = Vector3.Zero; | 56 | public Vector3 Scale = Vector3.Zero; |
@@ -57,37 +72,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
57 | { | 72 | { |
58 | ForGroup = forGroup; | 73 | ForGroup = forGroup; |
59 | 74 | ||
60 | // if (ForGroup) | 75 | // if (ForGroup) |
61 | Position = part.ParentGroup.AbsolutePosition; | 76 | Position = part.ParentGroup.AbsolutePosition; |
62 | // else | 77 | // else |
63 | // Position = part.OffsetPosition; | 78 | // Position = part.OffsetPosition; |
64 | 79 | ||
65 | // m_log.DebugFormat( | 80 | // m_log.DebugFormat( |
66 | // "[UNDO STATE]: Storing undo position {0} for root part", Position); | 81 | // "[UNDO STATE]: Storing undo position {0} for root part", Position); |
67 | 82 | ||
68 | Rotation = part.RotationOffset; | 83 | Rotation = part.RotationOffset; |
69 | 84 | ||
70 | // m_log.DebugFormat( | 85 | // m_log.DebugFormat( |
71 | // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); | 86 | // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); |
72 | 87 | ||
73 | Scale = part.Shape.Scale; | 88 | Scale = part.Shape.Scale; |
74 | 89 | ||
75 | // m_log.DebugFormat( | 90 | // m_log.DebugFormat( |
76 | // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); | 91 | // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); |
77 | } | 92 | } |
78 | else | 93 | else |
79 | { | 94 | { |
80 | Position = part.OffsetPosition; | 95 | Position = part.OffsetPosition; |
81 | // m_log.DebugFormat( | 96 | // m_log.DebugFormat( |
82 | // "[UNDO STATE]: Storing undo position {0} for child part", Position); | 97 | // "[UNDO STATE]: Storing undo position {0} for child part", Position); |
83 | 98 | ||
84 | Rotation = part.RotationOffset; | 99 | Rotation = part.RotationOffset; |
85 | // m_log.DebugFormat( | 100 | // m_log.DebugFormat( |
86 | // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); | 101 | // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); |
87 | 102 | ||
88 | Scale = part.Shape.Scale; | 103 | Scale = part.Shape.Scale; |
89 | // m_log.DebugFormat( | 104 | // m_log.DebugFormat( |
90 | // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); | 105 | // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); |
91 | } | 106 | } |
92 | } | 107 | } |
93 | 108 | ||
@@ -121,9 +136,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
121 | 136 | ||
122 | if (part.ParentID == 0) | 137 | if (part.ParentID == 0) |
123 | { | 138 | { |
124 | // m_log.DebugFormat( | 139 | // m_log.DebugFormat( |
125 | // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", | 140 | // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", |
126 | // Position, part.Name, part.LocalId); | 141 | // Position, part.Name, part.LocalId); |
127 | 142 | ||
128 | if (Position != Vector3.Zero) | 143 | if (Position != Vector3.Zero) |
129 | { | 144 | { |
@@ -133,9 +148,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
133 | part.ParentGroup.UpdateRootPosition(Position); | 148 | part.ParentGroup.UpdateRootPosition(Position); |
134 | } | 149 | } |
135 | 150 | ||
136 | // m_log.DebugFormat( | 151 | // m_log.DebugFormat( |
137 | // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", | 152 | // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", |
138 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | 153 | // part.RotationOffset, Rotation, part.Name, part.LocalId); |
139 | 154 | ||
140 | if (ForGroup) | 155 | if (ForGroup) |
141 | part.UpdateRotation(Rotation); | 156 | part.UpdateRotation(Rotation); |
@@ -144,9 +159,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
144 | 159 | ||
145 | if (Scale != Vector3.Zero) | 160 | if (Scale != Vector3.Zero) |
146 | { | 161 | { |
147 | // m_log.DebugFormat( | 162 | // m_log.DebugFormat( |
148 | // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", | 163 | // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", |
149 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | 164 | // part.Shape.Scale, Scale, part.Name, part.LocalId); |
150 | 165 | ||
151 | if (ForGroup) | 166 | if (ForGroup) |
152 | part.ParentGroup.GroupResize(Scale); | 167 | part.ParentGroup.GroupResize(Scale); |
@@ -161,24 +176,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
161 | // Note: Updating these properties on sop automatically schedules an update if needed | 176 | // Note: Updating these properties on sop automatically schedules an update if needed |
162 | if (Position != Vector3.Zero) | 177 | if (Position != Vector3.Zero) |
163 | { | 178 | { |
164 | // m_log.DebugFormat( | 179 | // m_log.DebugFormat( |
165 | // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", | 180 | // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", |
166 | // part.OffsetPosition, Position, part.Name, part.LocalId); | 181 | // part.OffsetPosition, Position, part.Name, part.LocalId); |
167 | 182 | ||
168 | part.OffsetPosition = Position; | 183 | part.OffsetPosition = Position; |
169 | } | 184 | } |
170 | 185 | ||
171 | // m_log.DebugFormat( | 186 | // m_log.DebugFormat( |
172 | // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", | 187 | // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", |
173 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | 188 | // part.RotationOffset, Rotation, part.Name, part.LocalId); |
174 | 189 | ||
175 | part.UpdateRotation(Rotation); | 190 | part.UpdateRotation(Rotation); |
176 | 191 | ||
177 | if (Scale != Vector3.Zero) | 192 | if (Scale != Vector3.Zero) |
178 | { | 193 | { |
179 | // m_log.DebugFormat( | 194 | // m_log.DebugFormat( |
180 | // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", | 195 | // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", |
181 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | 196 | // part.Shape.Scale, Scale, part.Name, part.LocalId); |
182 | 197 | ||
183 | part.Resize(Scale); | 198 | part.Resize(Scale); |
184 | } | 199 | } |
@@ -247,4 +262,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
247 | m_terrainModule.UndoTerrain(m_terrainChannel); | 262 | m_terrainModule.UndoTerrain(m_terrainChannel); |
248 | } | 263 | } |
249 | } | 264 | } |
250 | } \ No newline at end of file | 265 | } |
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index efb68a2..411e421 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -87,10 +87,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
87 | /// <param name="assetUuids">The assets gathered</param> | 87 | /// <param name="assetUuids">The assets gathered</param> |
88 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) | 88 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) |
89 | { | 89 | { |
90 | // avoid infinite loops | ||
91 | if (assetUuids.ContainsKey(assetUuid)) | ||
92 | return; | ||
93 | |||
94 | try | 90 | try |
95 | { | 91 | { |
96 | assetUuids[assetUuid] = assetType; | 92 | assetUuids[assetUuid] = assetType; |