From 53b72ab4b8685d2bc77ca3d18a40522774a6cdb2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 May 2014 13:31:58 +0100 Subject: minor: Comment out Cacheitems debug log lines for now --- .../ClientStack/Linden/Caps/UploadBakedTextureModule.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index 3b39153..8cdebcd 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs @@ -129,12 +129,12 @@ namespace OpenSim.Region.ClientStack.Linden m_BakedTextureModule = m_scene.RequestModuleInterface(); if (cacheItems.Length > 0) { - m_log.Debug("[Cacheitems]: " + cacheItems.Length); - for (int iter = 0; iter < maxCacheitemsLoop; iter++) - { - m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + - cacheItems[iter].TextureID); - } +// m_log.Debug("[Cacheitems]: " + cacheItems.Length); +// for (int iter = 0; iter < maxCacheitemsLoop; iter++) +// { +// m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + +// cacheItems[iter].TextureID); +// } ScenePresence p = null; if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) -- cgit v1.1 From 7862d1e20dc8c405e594d888722d90178f0cd9f7 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 30 Apr 2014 08:48:05 +0300 Subject: Added range-checking for the parameters to PRIM_POINT_LIGHT (used in llSetLinkPrimitiveParamsFast() ) --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 4d20e13..0e6b24a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1884,9 +1884,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.Shape.LightColorR = Util.Clip((float)color.x, 0.0f, 1.0f); part.Shape.LightColorG = Util.Clip((float)color.y, 0.0f, 1.0f); part.Shape.LightColorB = Util.Clip((float)color.z, 0.0f, 1.0f); - part.Shape.LightIntensity = intensity; - part.Shape.LightRadius = radius; - part.Shape.LightFalloff = falloff; + part.Shape.LightIntensity = Util.Clip((float)intensity, 0.0f, 1.0f); + part.Shape.LightRadius = Util.Clip((float)radius, 0.1f, 20.0f); + part.Shape.LightFalloff = Util.Clip((float)falloff, 0.01f, 2.0f); } else { -- cgit v1.1 From 0fe08c8799b1a3a2d5a07c206c2f9680d1c0798e Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 4 May 2014 13:36:36 +0300 Subject: - When sending the "My Suitcase" folder to the client, always claim it has Folder Type 8. (Previously we had used Folder Type -1 in one place, and LLClientView didn't even bother changing Folder Type 100 to anything else.) --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 7cb5b53..53217a0 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -1761,6 +1761,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP newBlock.Name = Util.StringToBytes256(folder.Name); newBlock.ParentID = folder.ParentID; newBlock.Type = (sbyte)folder.Type; + if (newBlock.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE) + newBlock.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE; return newBlock; } @@ -2010,8 +2012,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP folderBlock.FolderID = folder.ID; folderBlock.ParentID = folder.ParentID; - //folderBlock.Type = -1; folderBlock.Type = (sbyte)folder.Type; + if (folderBlock.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE) + folderBlock.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE; folderBlock.Name = Util.StringToBytes256(folder.Name); return folderBlock; -- cgit v1.1 From 1e5cff32fc41356971d6ad601cbee7ad62472c76 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 5 May 2014 11:06:49 +0300 Subject: Show more meaningful error messages when failed to give an item to another user --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 18 +++++++--- .../Inventory/Transfer/InventoryTransferModule.cs | 11 +++--- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 39 ++++++++++++++++------ .../Framework/Scenes/Tests/UserInventoryTests.cs | 10 +++--- .../Avatar/XmlRpcGroups/GroupsModule.cs | 5 +-- 5 files changed, 56 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 79bc5ef..0eb15f8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -865,18 +865,26 @@ namespace OpenSim.Region.ClientStack.Linden item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID)); if (item != null) { - copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID); - if (copyItem != null && client != null) + string message; + copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID, out message); + if (client != null) { - m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder); - client.SendBulkUpdateInventory(copyItem); + if (copyItem != null) + { + m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder); + client.SendBulkUpdateInventory(copyItem); + } + else + { + client.SendAgentAlertMessage(message, false); + } } } else { m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID); if (client != null) - client.SendAlertMessage("Failed to retrieve item"); + client.SendAgentAlertMessage("Failed to retrieve item", false); } } catch (Exception e) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 0b10dd8..c632798 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -180,8 +180,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory", folderID, new UUID(im.toAgentID)); - InventoryFolderBase folderCopy - = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); + InventoryFolderBase folderCopy + = scene.GiveInventoryFolder(client, receipientID, client.AgentId, folderID, UUID.Zero); if (folderCopy == null) { @@ -217,13 +217,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer "into agent {1}'s inventory", itemID, new UUID(im.toAgentID)); - InventoryItemBase itemCopy = scene.GiveInventoryItem( - new UUID(im.toAgentID), - client.AgentId, itemID); + string message; + InventoryItemBase itemCopy = scene.GiveInventoryItem(new UUID(im.toAgentID), client.AgentId, itemID, out message); if (itemCopy == null) { - client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); + client.SendAgentAlertMessage(message, false); return; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index bb9f457..27cd5c6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.Framework.Scenes { public partial class Scene { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly string LogHeader = "[SCENE INVENTORY]"; /// @@ -534,9 +534,9 @@ namespace OpenSim.Region.Framework.Scenes /// /// ID of the sender of the item /// - public virtual void GiveInventoryItem(IClientAPI recipientClient, UUID senderId, UUID itemId) + public virtual void GiveInventoryItem(IClientAPI recipientClient, UUID senderId, UUID itemId, out string message) { - InventoryItemBase itemCopy = GiveInventoryItem(recipientClient.AgentId, senderId, itemId); + InventoryItemBase itemCopy = GiveInventoryItem(recipientClient.AgentId, senderId, itemId, out message); if (itemCopy != null) recipientClient.SendBulkUpdateInventory(itemCopy); @@ -549,9 +549,9 @@ namespace OpenSim.Region.Framework.Scenes /// ID of the sender of the item /// /// The inventory item copy given, null if the give was unsuccessful - public virtual InventoryItemBase GiveInventoryItem(UUID recipient, UUID senderId, UUID itemId) + public virtual InventoryItemBase GiveInventoryItem(UUID recipient, UUID senderId, UUID itemId, out string message) { - return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero); + return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero, out message); } /// @@ -568,12 +568,15 @@ namespace OpenSim.Region.Framework.Scenes /// The inventory item copy given, null if the give was unsuccessful /// public virtual InventoryItemBase GiveInventoryItem( - UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId) + UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId, out string message) { //Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); if (!Permissions.CanTransferUserInventory(itemId, senderId, recipient)) + { + message = "Not allowed to transfer this item."; return null; + } InventoryItemBase item = new InventoryItemBase(itemId, senderId); item = InventoryService.GetItem(item); @@ -582,6 +585,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.WarnFormat( "[AGENT INVENTORY]: Failed to find item {0} sent by {1} to {2}", itemId, senderId, recipient); + message = string.Format("Item not found: {0}.", itemId); return null; } @@ -590,6 +594,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.WarnFormat( "[AGENT INVENTORY]: Attempt to send item {0} {1} to {2} failed because sender {3} did not match item owner {4}", item.Name, item.ID, recipient, senderId, item.Owner); + message = "Sender did not match item owner."; return null; } @@ -600,7 +605,10 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.BypassPermissions()) { if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) + { + message = "Item doesn't have the Transfer permission."; return null; + } } // Insert a copy of the item into the recipient @@ -736,9 +744,14 @@ namespace OpenSim.Region.Framework.Scenes InventoryFolderBase root = InventoryService.GetRootFolder(recipient); if (root != null) + { itemCopy.Folder = root.ID; + } else - return null; // No destination + { + message = "Can't find a folder to add the item to."; + return null; + } } } @@ -763,6 +776,7 @@ namespace OpenSim.Region.Framework.Scenes } } + message = null; return itemCopy; } @@ -780,7 +794,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// The inventory folder copy given, null if the copy was unsuccessful /// - public virtual InventoryFolderBase GiveInventoryFolder( + public virtual InventoryFolderBase GiveInventoryFolder(IClientAPI client, UUID recipientId, UUID senderId, UUID folderId, UUID recipientParentFolderId) { //// Retrieve the folder from the sender @@ -815,13 +829,18 @@ namespace OpenSim.Region.Framework.Scenes InventoryCollection contents = InventoryService.GetFolderContent(senderId, folderId); foreach (InventoryFolderBase childFolder in contents.Folders) { - GiveInventoryFolder(recipientId, senderId, childFolder.ID, newFolder.ID); + GiveInventoryFolder(client, recipientId, senderId, childFolder.ID, newFolder.ID); } // Give all the items foreach (InventoryItemBase item in contents.Items) { - GiveInventoryItem(recipientId, senderId, item.ID, newFolder.ID); + string message; + if (GiveInventoryItem(recipientId, senderId, item.ID, newFolder.ID, out message) == null) + { + if (client != null) + client.SendAgentAlertMessage(message, false); + } } return newFolder; diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs index e50b4da..0736278 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs @@ -95,7 +95,9 @@ namespace OpenSim.Region.Framework.Tests UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); - scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID); + string message; + + scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID, out message); InventoryItemBase retrievedItem1 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1"); @@ -103,7 +105,7 @@ namespace OpenSim.Region.Framework.Tests Assert.That(retrievedItem1, Is.Not.Null); // Try giving back the freshly received item - scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID); + scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID, out message); List reretrievedItems = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1"); @@ -123,7 +125,7 @@ namespace OpenSim.Region.Framework.Tests InventoryFolderBase folder1 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false); - scene.GiveInventoryFolder(user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero); + scene.GiveInventoryFolder(null, user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero); InventoryFolderBase retrievedFolder1 = UserInventoryHelpers.GetInventoryFolder(scene.InventoryService, user2.PrincipalID, "folder1"); @@ -131,7 +133,7 @@ namespace OpenSim.Region.Framework.Tests Assert.That(retrievedFolder1, Is.Not.Null); // Try giving back the freshly received folder - scene.GiveInventoryFolder(user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero); + scene.GiveInventoryFolder(null, user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero); List reretrievedFolders = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, "folder1"); diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index fc8cae2..f34152c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -560,12 +560,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups if (m_debugEnabled) m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId); + string message; InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId, - giver, attachmentUUID); + giver, attachmentUUID, out message); if (itemCopy == null) { - remoteClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); + remoteClient.SendAgentAlertMessage(message, false); return; } -- cgit v1.1 From eb79c882eab090ee5ee51cadac7bd1dc2e5ddb9f Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 5 May 2014 15:59:24 +0300 Subject: Show more meaningful error messages when failed to move an item from a prim to a user's inventory. Also, actually show the error to the user in more cases. (Previously, sometimes the operation failed without telling the user anything.) --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 64 ++++++++++++++-------- .../Framework/Scenes/Tests/TaskInventoryTests.cs | 6 +- .../Shared/Api/Implementation/LSL_Api.cs | 6 +- .../Shared/Api/Implementation/OSSL_Api.cs | 9 +-- 4 files changed, 56 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 27cd5c6..4988868 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1167,11 +1167,19 @@ namespace OpenSim.Region.Framework.Scenes InventoryFolderBase destFolder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder); - // Move the item to trash. If this is a copiable item, only + // Move the item to trash. If this is a copyable item, only // a copy will be moved and we will still need to delete - // the item from the prim. If it was no copy, is will be + // the item from the prim. If it was no copy, it will be // deleted by this method. - MoveTaskInventoryItem(remoteClient, destFolder.ID, part, itemID); + string message; + InventoryItemBase item2 = MoveTaskInventoryItem(remoteClient, destFolder.ID, part, itemID, out message); + + if (item2 == null) + { + m_log.WarnFormat("[SCENE INVENTORY]: RemoveTaskInventory of item {0} failed: {1}", itemID, message); + remoteClient.SendAgentAlertMessage(message, false); + return; + } if (group.GetInventoryItem(localID, itemID) != null) { @@ -1183,11 +1191,12 @@ namespace OpenSim.Region.Framework.Scenes group.RemoveInventoryItem(localID, itemID); } + part.SendPropertiesToClient(remoteClient); } } - private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) + private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId, out string message) { TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId); @@ -1198,12 +1207,13 @@ namespace OpenSim.Region.Framework.Scenes + " inventory item from a prim's inventory item " + " but the required item does not exist in the prim's inventory", itemId, part.Name, part.UUID); - + message = "Item not found: " + itemId; return null; } if ((destAgent != taskItem.OwnerID) && ((taskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) { + message = "Item doesn't have the Transfer permission."; return null; } @@ -1263,6 +1273,7 @@ namespace OpenSim.Region.Framework.Scenes } } + message = null; return agentItem; } @@ -1273,19 +1284,19 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public InventoryItemBase MoveTaskInventoryItem(IClientAPI remoteClient, UUID folderId, SceneObjectPart part, UUID itemId) + public InventoryItemBase MoveTaskInventoryItem(IClientAPI remoteClient, UUID folderId, SceneObjectPart part, UUID itemId, out string message) { m_log.DebugFormat( "[PRIM INVENTORY]: Adding item {0} from {1} to folder {2} for {3}", itemId, part.Name, folderId, remoteClient.Name); - InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(remoteClient.AgentId, part, itemId); - + InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(remoteClient.AgentId, part, itemId, out message); if (agentItem == null) return null; agentItem.Folder = folderId; AddInventoryItem(remoteClient, agentItem); + message = null; return agentItem; } @@ -1336,7 +1347,11 @@ namespace OpenSim.Region.Framework.Scenes return; } - MoveTaskInventoryItem(remoteClient, folderId, part, itemId); + string message; + InventoryItemBase item = MoveTaskInventoryItem(remoteClient, folderId, part, itemId, out message); + + if (item == null) + remoteClient.SendAgentAlertMessage(message, false); } /// @@ -1350,17 +1365,17 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public InventoryItemBase MoveTaskInventoryItem(UUID avatarId, UUID folderId, SceneObjectPart part, UUID itemId) + public InventoryItemBase MoveTaskInventoryItem(UUID avatarId, UUID folderId, SceneObjectPart part, UUID itemId, out string message) { ScenePresence avatar; if (TryGetScenePresence(avatarId, out avatar)) { - return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); + return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId, out message); } else { - InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId); + InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId, out message); if (agentItem == null) return null; @@ -1474,6 +1489,11 @@ namespace OpenSim.Region.Framework.Scenes public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List items) { + ScenePresence avatar; + IClientAPI remoteClient = null; + if (TryGetScenePresence(destID, out avatar)) + remoteClient = avatar.ControllingClient; + InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); UUID newFolderID = UUID.Random(); @@ -1483,7 +1503,8 @@ namespace OpenSim.Region.Framework.Scenes foreach (UUID itemID in items) { - InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(destID, host, itemID); + string message; + InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(destID, host, itemID, out message); if (agentItem != null) { @@ -1491,18 +1512,17 @@ namespace OpenSim.Region.Framework.Scenes AddInventoryItem(agentItem); } + else + { + if (remoteClient != null) + remoteClient.SendAgentAlertMessage(message, false); + } } - ScenePresence avatar = null; - if (TryGetScenePresence(destID, out avatar)) + if (remoteClient != null) { - //profile.SendInventoryDecendents(avatar.ControllingClient, - // profile.RootFolder.ID, true, false); - //profile.SendInventoryDecendents(avatar.ControllingClient, - // newFolderID, false, true); - - SendInventoryUpdate(avatar.ControllingClient, rootFolder, true, false); - SendInventoryUpdate(avatar.ControllingClient, newFolder, false, true); + SendInventoryUpdate(remoteClient, rootFolder, true, false); + SendInventoryUpdate(remoteClient, newFolder, false, true); } return newFolderID; diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 6e0ea7d..f809267 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -136,7 +136,8 @@ namespace OpenSim.Region.Framework.Tests = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; // Perform test - scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID); + string message; + scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID, out message); InventoryItemBase ncUserItem = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem"); @@ -165,7 +166,8 @@ namespace OpenSim.Region.Framework.Tests scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); // Perform test - scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); + string message; + scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID, out message); InventoryItemBase ncUserItem = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Notecards/ncItem"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0e6b24a..d169912 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4127,10 +4127,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } // destination is an avatar - InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); + string message; + InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId, out message); if (agentItem == null) + { + llSay(0, message); return; + } if (m_TransferModule != null) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 6302455..de2c3f7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -3397,14 +3397,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (sp == null) return; - InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID); + string message; + InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID, out message); if (newItem == null) { m_log.ErrorFormat( - "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}", - itemName, m_host.Name, attachmentPoint, World.Name); - + "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}: {4}", + itemName, m_host.Name, attachmentPoint, World.Name, message); + ((LSL_Api)m_LSL_Api).llSay(0, message); return; } -- cgit v1.1 From 614b9e14c42d69bf8048218c889cc047756b0b5a Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 5 May 2014 16:09:51 +0300 Subject: When moving an item from a prim to a user's inventory, don't delete the item from the prim until it was successfully copied to the user --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 4988868..91f1b63 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1196,6 +1196,10 @@ namespace OpenSim.Region.Framework.Scenes } } + + /// + /// Creates (in memory only) a user inventory item that will contain a copy of a task inventory item. + /// private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId, out string message) { TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId); @@ -1259,11 +1263,24 @@ namespace OpenSim.Region.Framework.Scenes agentItem.GroupPermissions = taskItem.GroupPermissions; } + message = null; + return agentItem; + } + + /// + /// If the task item is not-copyable then remove it from the prim. + /// + private void RemoveNonCopyTaskItemFromPrim(SceneObjectPart part, UUID itemId) + { + TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId); + if (taskItem == null) + return; + if (!Permissions.BypassPermissions()) { if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) { - if (taskItem.Type == 10) + if (taskItem.Type == (int)AssetType.LSLText) { part.RemoveScriptEvents(itemId); EventManager.TriggerRemoveScript(part.LocalId, itemId); @@ -1272,9 +1289,6 @@ namespace OpenSim.Region.Framework.Scenes part.Inventory.RemoveInventoryItem(itemId); } } - - message = null; - return agentItem; } /// @@ -1296,6 +1310,9 @@ namespace OpenSim.Region.Framework.Scenes agentItem.Folder = folderId; AddInventoryItem(remoteClient, agentItem); + + RemoveNonCopyTaskItemFromPrim(part, itemId); + message = null; return agentItem; } @@ -1384,6 +1401,8 @@ namespace OpenSim.Region.Framework.Scenes AddInventoryItem(agentItem); + RemoveNonCopyTaskItemFromPrim(part, itemId); + return agentItem; } } @@ -1511,6 +1530,8 @@ namespace OpenSim.Region.Framework.Scenes agentItem.Folder = newFolderID; AddInventoryItem(agentItem); + + RemoveNonCopyTaskItemFromPrim(host, itemID); } else { -- cgit v1.1 From c9742c826d7bf2bd0f99c93cf7ecb4edc9940064 Mon Sep 17 00:00:00 2001 From: Talun Date: Fri, 2 May 2014 19:48:22 +0100 Subject: Mantis 7146 The lsl function llGetMassMKS is not implemented This patch implements llGetMassMKS as it is described in the wiki http://wiki.secondlife.com/wiki/LlGetMassMKS --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 7 +++++++ OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 1 + OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 +++++ 3 files changed, 13 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d169912..1dcd1cc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3162,6 +3162,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public LSL_Float llGetMassMKS() + { + // this is what the wiki says it does! + // http://wiki.secondlife.com/wiki/LlGetMassMKS + return llGetMass() * 100.0; + } + public void llCollisionFilter(string name, string id, int accept) { m_host.AddScriptLPS(1); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 340edb3..18a1e84 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -149,6 +149,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Vector llGetLocalPos(); LSL_Rotation llGetLocalRot(); LSL_Float llGetMass(); + LSL_Float llGetMassMKS(); LSL_Integer llGetMemoryLimit(); void llGetNextEmail(string address, string subject); LSL_String llGetNotecardLine(string name, int line); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 7cd17e7..49e39fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -584,6 +584,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetMass(); } + public LSL_Float llGetMassMKS() + { + return m_LSL_Functions.llGetMassMKS(); + } + public LSL_Integer llGetMemoryLimit() { return m_LSL_Functions.llGetMemoryLimit(); -- cgit v1.1 From e245638f2421f77bb4478705ef126f849a28c9ad Mon Sep 17 00:00:00 2001 From: Vegaslon Date: Mon, 5 May 2014 19:56:35 -0400 Subject: Change llUnSit to be able to unsit any avatar that is currently sat on the object, not just avatars sitting on the sittarget in the object containing the script. or when the object is owned by the parcel, land group or estate owner. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1dcd1cc..5590cd5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6155,10 +6155,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (UUID.TryParse(id, out key)) { ScenePresence av = World.GetScenePresence(key); + List sittingAvatars = m_host.ParentGroup.GetSittingAvatars(); if (av != null) { - if (llAvatarOnSitTarget() == id) + if (sittingAvatars.Contains(av)) { // if the avatar is sitting on this object, then // we can unsit them. We don't want random scripts unsitting random people -- cgit v1.1 From 0faba7dc33e2048c68f55b8708ade1b1164fcff3 Mon Sep 17 00:00:00 2001 From: Vegaslon Date: Tue, 6 May 2014 11:00:27 -0400 Subject: Fix avatars going to corner of region when they are sitting on a child prim and the prim is deleted. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0356599..3b1c5d8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1421,7 +1421,7 @@ namespace OpenSim.Region.Framework.Scenes Scene.ForEachScenePresence(sp => { - if (!sp.IsChildAgent && sp.ParentID == LocalId) + if (!sp.IsChildAgent && sp.ParentID == part.LocalId) sp.StandUp(); if (!silent) -- cgit v1.1 From cecb446e0e91ede0b05ea9cf40c1313782241f3d Mon Sep 17 00:00:00 2001 From: Kunta Kinte Date: Tue, 29 Apr 2014 07:26:07 -0700 Subject: fix infinite recursion loop in SendGridInstantMessageViaXMLRPCAsync() --- .../Avatar/InstantMessage/MessageTransferModule.cs | 178 +++++++++------------ 1 file changed, 79 insertions(+), 99 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 40a400f..4f8e2cd 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -428,7 +428,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// /// delegate for sending a grid instant message asynchronously /// - public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID); + public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); protected virtual void GridInstantMessageCompleted(IAsyncResult iar) { @@ -442,138 +442,118 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; - d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); + d.BeginInvoke(im, result, GridInstantMessageCompleted, d); } /// - /// Recursive SendGridInstantMessage over XMLRPC method. + /// Internal SendGridInstantMessage over XMLRPC method. /// This is called from within a dedicated thread. - /// The first time this is called, prevRegionHandle will be 0 Subsequent times this is called from - /// itself, prevRegionHandle will be the last region handle that we tried to send. - /// If the handles are the same, we look up the user's location using the grid. - /// If the handles are still the same, we end. The send failed. /// - /// - /// Pass in 0 the first time this method is called. It will be called recursively with the last - /// regionhandle tried - /// - protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) + private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result) { UUID toAgentID = new UUID(im.toAgentID); + UUID regionID; + bool lookupAgent; - PresenceInfo upd = null; - - bool lookupAgent = false; - + /* + * Try to get what region the agent is in from the cache. + */ lock (m_UserRegionMap) { - if (m_UserRegionMap.ContainsKey(toAgentID)) - { - upd = new PresenceInfo(); - upd.RegionID = m_UserRegionMap[toAgentID]; - - // We need to compare the current regionhandle with the previous region handle - // or the recursive loop will never end because it will never try to lookup the agent again - if (prevRegionID == upd.RegionID) - { - lookupAgent = true; - } - } - else - { - lookupAgent = true; - } + lookupAgent = !m_UserRegionMap.TryGetValue(toAgentID, out regionID); } - - // Are we needing to look-up an agent? - if (lookupAgent) + while (true) { - // Non-cached user agent lookup. - PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); - if (presences != null && presences.Length > 0) + + /* + * If not in cache, try to find out what region the agent is in. + * Also do this if we know the existing cache entry is bad. + */ + if (lookupAgent) { - foreach (PresenceInfo p in presences) + PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); + + regionID = UUID.Zero; + if (presences != null) { - if (p.RegionID != UUID.Zero) + foreach (PresenceInfo p in presences) { - upd = p; - break; + if (p.RegionID != UUID.Zero) + { + regionID = p.RegionID; + break; + } } } - } - if (upd != null) - { - // check if we've tried this before.. - // This is one way to end the recursive loop - // - if (upd.RegionID == prevRegionID) + // If not found, message is undeliverable + if (regionID == UUID.Zero) { - // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); - HandleUndeliveredMessage(im, result); - return; + break; } } - else + + /* + * Try to find out about region. + * If unable, message is undeliverable. + */ + GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, regionID); + if (reginfo == null) { - // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); - HandleUndeliveredMessage(im, result); - return; + m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", regionID); + break; } - } - if (upd != null) - { - GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, - upd.RegionID); - if (reginfo != null) + /* + * Try to send message to agent in the region. + */ + Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); + msgdata["region_handle"] = 0; + bool imresult = doIMSending(reginfo, msgdata); + + /* + * If message delivery successful, save cache entry because we know it is good. + * Then tell caller message has been delivered and we are done. + */ + if (imresult) { - Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); - // Not actually used anymore, left in for compatibility - // Remove at next interface change - // - msgdata["region_handle"] = 0; - bool imresult = doIMSending(reginfo, msgdata); - if (imresult) - { - // IM delivery successful, so store the Agent's location in our local cache. - lock (m_UserRegionMap) - { - if (m_UserRegionMap.ContainsKey(toAgentID)) - { - m_UserRegionMap[toAgentID] = upd.RegionID; - } - else - { - m_UserRegionMap.Add(toAgentID, upd.RegionID); - } - } - result(true); - } - else + lock (m_UserRegionMap) { - // try again, but lookup user this time. - // Warning, this must call the Async version - // of this method or we'll be making thousands of threads - // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync - // The version that spawns the thread is SendGridInstantMessageViaXMLRPC - - // This is recursive!!!!! - SendGridInstantMessageViaXMLRPCAsync(im, result, - upd.RegionID); + m_UserRegionMap[toAgentID] = regionID; } + result(true); + return; } - else + + /* + * Message delivery failed. + * If we just looked up what region the agent is in, message is undeliverable. + */ + if (lookupAgent) { - m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); - HandleUndeliveredMessage(im, result); + break; } + + /* + * We used a cached entry that we now know is bad. + * Try again by searching the grid for the user. + */ + lookupAgent = true; } - else + + /* + * Message is undeliverable for one reason or another. + * Remove possible bad entry from cache. + * Then inform caller that the message is undeliverable. + */ + lock (m_UserRegionMap) { - HandleUndeliveredMessage(im, result); + m_UserRegionMap.Remove(toAgentID); } + + // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); + HandleUndeliveredMessage(im, result); } /// -- cgit v1.1 From 8b3c2f7d0c655d72bbca9dcbd092d3ab275d47c5 Mon Sep 17 00:00:00 2001 From: Matt Lehmann Date: Wed, 30 Apr 2014 19:12:52 -0700 Subject: updated version of default user switch for load oar :q :q --- OpenSim/Region/Application/OpenSim.cs | 1 + .../World/Archiver/ArchiveReadRequest.cs | 22 +++++++++++++----- .../CoreModules/World/Archiver/ArchiverModule.cs | 26 +++++++++++++++++++++- 3 files changed, 43 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 544accf..cc505f8 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -272,6 +272,7 @@ namespace OpenSim + " [--no-objects]" + " [--rotation degrees] [--rotation-center \"\"]" + " [--displacement \"\"]" + + " [--default-user \"User Name\"]" + " []", "Load a region's data from an OAR archive.", "--merge will merge the OAR with the existing scene (suppresses terrain and parcel info loading)." + Environment.NewLine diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index a1629fb..fe87350 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -160,10 +160,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver private IAssetService m_assetService = null; + private UUID m_defaultUser; + public ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionaryoptions) { m_rootScene = scene; + if (options.ContainsKey("default-user")) + { + m_defaultUser = (UUID)options["default-user"]; + m_log.InfoFormat("Using User {0} as default user", m_defaultUser.ToString()); + } + else + { + m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner; + } + m_loadPath = loadPath; try { @@ -562,16 +574,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (string.IsNullOrEmpty(part.CreatorData)) { if (!ResolveUserUuid(scene, part.CreatorID)) - part.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner; + part.CreatorID = m_defaultUser; } if (UserManager != null) UserManager.AddUser(part.CreatorID, part.CreatorData); if (!(ResolveUserUuid(scene, part.OwnerID) || ResolveGroupUuid(part.OwnerID))) - part.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner; + part.OwnerID = m_defaultUser; if (!(ResolveUserUuid(scene, part.LastOwnerID) || ResolveGroupUuid(part.LastOwnerID))) - part.LastOwnerID = scene.RegionInfo.EstateSettings.EstateOwner; + part.LastOwnerID = m_defaultUser; if (!ResolveGroupUuid(part.GroupID)) part.GroupID = UUID.Zero; @@ -590,13 +602,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver { if (!(ResolveUserUuid(scene, kvp.Value.OwnerID) || ResolveGroupUuid(kvp.Value.OwnerID))) { - kvp.Value.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner; + kvp.Value.OwnerID = m_defaultUser; } if (string.IsNullOrEmpty(kvp.Value.CreatorData)) { if (!ResolveUserUuid(scene, kvp.Value.CreatorID)) - kvp.Value.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner; + kvp.Value.CreatorID = m_defaultUser; } if (UserManager != null) diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 2b2da6f..6a09caf 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -108,6 +108,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver bool forceParcels = false; bool noObjects = false; Vector3 displacement = new Vector3(0f, 0f, 0f); + String defaultUser = ""; float rotation = 0f; Vector3 rotationCenter = new Vector3(Constants.RegionSize / 2f, Constants.RegionSize / 2f, 0); @@ -119,6 +120,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver options.Add("force-parcels", delegate (string v) { forceParcels = (v != null); }); options.Add("forceparcels", delegate (string v) { forceParcels = (v != null); }); // downward compatibility options.Add("no-objects", delegate (string v) { noObjects = (v != null); }); + options.Add("default-user=", delegate(string v) { defaultUser = (v == null) ? "" : v; }); options.Add("displacement=", delegate (string v) { try { @@ -131,7 +133,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver return; } }); - options.Add("rotation=", delegate (string v) { + options.Add("rotation=", delegate(string v) + { try { rotation = v == null ? 0f : float.Parse(v); @@ -181,6 +184,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (forceTerrain) archiveOptions.Add("force-terrain", null); if (forceParcels) archiveOptions.Add("force-parcels", null); if (noObjects) archiveOptions.Add("no-objects", null); + if (defaultUser != "") + { + UUID defaultUserUUID = UUID.Zero; + try + { + defaultUserUUID = Scene.UserManagementModule.GetUserIdByName(defaultUser); + } + catch + { + m_log.ErrorFormat("[ARCHIVER MODULE] default user must be in format \"First Last\"", defaultUser); + } + if (defaultUserUUID == UUID.Zero) + { + m_log.ErrorFormat("[ARCHIVER MODULE] cannot find specified default user {0}", defaultUser); + return; + } + else + { + archiveOptions.Add("default-user", defaultUserUUID); + } + } archiveOptions.Add("displacement", displacement); archiveOptions.Add("rotation", rotation); archiveOptions.Add("rotation-center", rotationCenter); -- cgit v1.1 From 9e83b430092be363d87c829955f7d266ed996598 Mon Sep 17 00:00:00 2001 From: Matt Lehmann Date: Fri, 2 May 2014 18:00:34 -0700 Subject: new version of patch to add default-user switch new version :qw :wq updated version of default user switch for load oar :q :q --- OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index fe87350..e9c6fb6 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -218,6 +218,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_merge = options.ContainsKey("merge"); m_requestId = requestId; + m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner; + // Zero can never be a valid user id m_validUserUuids[UUID.Zero] = false; -- cgit v1.1 From 78015bbbdc50d41cc002aab838487ab902750c4f Mon Sep 17 00:00:00 2001 From: Dev Random Date: Sat, 12 Apr 2014 17:33:45 -0400 Subject: Console commands for Estate Mgmt --- OpenSim/Region/Application/OpenSim.cs | 113 +++++++++++++++++++++ .../World/Estate/EstateManagementModule.cs | 63 ++++++++++++ .../Region/Framework/Interfaces/IEstateModule.cs | 3 + 3 files changed, 179 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index cc505f8..59b4614 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -402,6 +402,12 @@ namespace OpenSim "Delete a region from disk", RunCommand); + m_console.Commands.AddCommand("Estates", false, "estate create", + "estate create ", + "Creates a new estate with the specified name, owned by the specified user." + + " Estate name must be unique.", + CreateEstateCommand); + m_console.Commands.AddCommand("Estates", false, "estate set owner", "estate set owner [ | ]", "Sets the owner of the specified estate to the specified UUID or user. ", @@ -411,6 +417,11 @@ namespace OpenSim "estate set name ", "Sets the name of the specified estate to the specified value. New name must be unique.", SetEstateNameCommand); + + m_console.Commands.AddCommand("Estates", false, "estate link region", + "estate link region ", + "Attaches the specified region to the specified estate.", + EstateLinkRegionCommand); } protected override void ShutdownSpecific() @@ -1177,6 +1188,58 @@ namespace OpenSim SceneManager.SaveCurrentSceneToArchive(cmdparams); } + protected void CreateEstateCommand(string module, string[] args) + { + string response = null; + UUID userID; + + if (args.Length == 2) + { + response = "No user specified."; + } + else if (!UUID.TryParse(args[2], out userID)) + { + response = String.Format("{0} is not a valid UUID", args[2]); + } + else if (args.Length == 3) + { + response = "No estate name specified."; + } + else + { + Scene scene = SceneManager.CurrentOrFirstScene; + + // TODO: Is there a better choice here? + UUID scopeID = UUID.Zero; + UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, userID); + if (account == null) + { + response = String.Format("Could not find user {0}", userID); + } + else + { + // concatenate it all to "name" + StringBuilder sb = new StringBuilder(args[3]); + for (int i = 4; i < args.Length; i++) + sb.Append (" " + args[i]); + string estateName = sb.ToString().Trim(); + + // send it off for processing. + IEstateModule estateModule = scene.RequestModuleInterface(); + response = estateModule.CreateEstate(estateName, userID); + if (response == String.Empty) + { + List estates = scene.EstateDataService.GetEstates(estateName); + response = String.Format("Estate {0} created as \"{1}\"", estates.ElementAt(0), estateName); + } + } + } + + // give the user some feedback + if (response != null) + MainConsole.Instance.Output(response); + } + protected void SetEstateOwnerCommand(string module, string[] args) { string response = null; @@ -1299,6 +1362,56 @@ namespace OpenSim MainConsole.Instance.Output(response); } + private void EstateLinkRegionCommand(string module, string[] args) + { + int estateId =-1; + UUID regionId = UUID.Zero; + Scene scene = null; + string response = null; + + if (args.Length == 3) + { + response = "No estate specified."; + } + else if (!int.TryParse(args [3], out estateId)) + { + response = String.Format("\"{0}\" is not a valid ID for an Estate", args [3]); + } + else if (args.Length == 4) + { + response = "No region specified."; + } + else if (!UUID.TryParse(args[4], out regionId)) + { + response = String.Format("\"{0}\" is not a valid UUID for a Region", args [4]); + } + else if (!SceneManager.TryGetScene(regionId, out scene)) + { + // region may exist, but on a different sim. + response = String.Format("No access to Region \"{0}\"", args [4]); + } + + if (response != null) + { + MainConsole.Instance.Output(response); + return; + } + + // send it off for processing. + IEstateModule estateModule = scene.RequestModuleInterface(); + response = estateModule.SetRegionEstate(scene.RegionInfo, estateId); + if (response == String.Empty) + { + estateModule.TriggerRegionInfoChange(); + estateModule.sendRegionHandshakeToAll(); + response = String.Format ("Region {0} is now attached to estate {1}", regionId, estateId); + } + + // give the user some feedback + if (response != null) + MainConsole.Instance.Output (response); + } + #endregion private static string CombineParams(string[] commandParams, int pos) diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 54a7302..a032bc7 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -313,6 +313,69 @@ namespace OpenSim.Region.CoreModules.World.Estate return response; } + public string SetRegionEstate(RegionInfo regionInfo, int estateID) + { + string response; + + if (regionInfo.EstateSettings.EstateID == estateID) + { + response = String.Format("\"{0}\" is already part of estate {1}", regionInfo.RegionName, estateID); + } + else + { + // get the current settings from DB + EstateSettings dbSettings = Scene.EstateDataService.LoadEstateSettings(estateID); + if (dbSettings.EstateID == 0) + { + response = String.Format("No estate found with ID {0}", estateID); + } + else if (Scene.EstateDataService.LinkRegion(regionInfo.RegionID, estateID)) + { + // make sure there's a log entry to document the change + m_log.InfoFormat("[ESTATE]: Region {0} ({1}) moved to Estate {2} ({3}).", regionInfo.RegionID, regionInfo.RegionName, estateID, dbSettings.EstateName); + + // propagate the change + ChangeDelegate change = OnEstateInfoChange; + + if (change != null) + change(regionInfo.RegionID); + + response = String.Empty; + } + else + { + response = String.Format("Could not move \"{0}\" to estate {1}", regionInfo.RegionName, estateID); + } + } + return response; + } + + public string CreateEstate(string estateName, UUID ownerID) + { + string response; + if (string.IsNullOrEmpty(estateName)) + { + response = "No estate name specified."; + } + else + { + List estates = Scene.EstateDataService.GetEstates(estateName); + if (estates.Count() > 0) + { + response = String.Format("An estate named \"{0}\" already exists.", estateName); + } + else + { + EstateSettings settings = Scene.EstateDataService.CreateNewEstate(); + settings.EstateOwner = ownerID; + settings.EstateName = estateName; + settings.Save(); + response = String.Empty; + } + } + return response; + } + #endregion #region Packet Data Responders diff --git a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs index 600ecfe..461c880 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs @@ -26,6 +26,7 @@ */ using OpenMetaverse; +using OpenSim.Framework; using OpenSim.Services.Interfaces; namespace OpenSim.Region.Framework.Interfaces @@ -44,6 +45,8 @@ namespace OpenSim.Region.Framework.Interfaces string SetEstateOwner(int estateID, UserAccount account); string SetEstateName(int estateID, string newName); + string SetRegionEstate(RegionInfo regionInfo, int estateID); + string CreateEstate(string estateName, UUID ownerID); /// /// Tell all clients about the current state of the region (terrain textures, water height, etc.). -- cgit v1.1 From e44450cce1cd3a9077aec5514a1b9e65b8cffa0a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 6 May 2014 19:53:35 +0100 Subject: Revert "fix infinite recursion loop in SendGridInstantMessageViaXMLRPCAsync()" There is a problem here with infinite recursion, but this patch loses the 'hunting' behaviour where the code will attempt multiple lookups if the avatar is teleporting rapidly around different simulators. This patch only does a single lookup before giving up. This reverts commit cecb446e0e91ede0b05ea9cf40c1313782241f3d. --- .../Avatar/InstantMessage/MessageTransferModule.cs | 178 ++++++++++++--------- 1 file changed, 99 insertions(+), 79 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 4f8e2cd..40a400f 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -428,7 +428,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// /// delegate for sending a grid instant message asynchronously /// - public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); + public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID); protected virtual void GridInstantMessageCompleted(IAsyncResult iar) { @@ -442,118 +442,138 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; - d.BeginInvoke(im, result, GridInstantMessageCompleted, d); + d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); } /// - /// Internal SendGridInstantMessage over XMLRPC method. + /// Recursive SendGridInstantMessage over XMLRPC method. /// This is called from within a dedicated thread. + /// The first time this is called, prevRegionHandle will be 0 Subsequent times this is called from + /// itself, prevRegionHandle will be the last region handle that we tried to send. + /// If the handles are the same, we look up the user's location using the grid. + /// If the handles are still the same, we end. The send failed. /// - private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result) + /// + /// Pass in 0 the first time this method is called. It will be called recursively with the last + /// regionhandle tried + /// + protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) { UUID toAgentID = new UUID(im.toAgentID); - UUID regionID; - bool lookupAgent; - /* - * Try to get what region the agent is in from the cache. - */ + PresenceInfo upd = null; + + bool lookupAgent = false; + lock (m_UserRegionMap) { - lookupAgent = !m_UserRegionMap.TryGetValue(toAgentID, out regionID); + if (m_UserRegionMap.ContainsKey(toAgentID)) + { + upd = new PresenceInfo(); + upd.RegionID = m_UserRegionMap[toAgentID]; + + // We need to compare the current regionhandle with the previous region handle + // or the recursive loop will never end because it will never try to lookup the agent again + if (prevRegionID == upd.RegionID) + { + lookupAgent = true; + } + } + else + { + lookupAgent = true; + } } + - while (true) + // Are we needing to look-up an agent? + if (lookupAgent) { - - /* - * If not in cache, try to find out what region the agent is in. - * Also do this if we know the existing cache entry is bad. - */ - if (lookupAgent) + // Non-cached user agent lookup. + PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); + if (presences != null && presences.Length > 0) { - PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); - - regionID = UUID.Zero; - if (presences != null) + foreach (PresenceInfo p in presences) { - foreach (PresenceInfo p in presences) + if (p.RegionID != UUID.Zero) { - if (p.RegionID != UUID.Zero) - { - regionID = p.RegionID; - break; - } + upd = p; + break; } } + } - // If not found, message is undeliverable - if (regionID == UUID.Zero) + if (upd != null) + { + // check if we've tried this before.. + // This is one way to end the recursive loop + // + if (upd.RegionID == prevRegionID) { - break; + // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); + HandleUndeliveredMessage(im, result); + return; } } - - /* - * Try to find out about region. - * If unable, message is undeliverable. - */ - GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, regionID); - if (reginfo == null) + else { - m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", regionID); - break; + // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); + HandleUndeliveredMessage(im, result); + return; } + } - /* - * Try to send message to agent in the region. - */ - Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); - msgdata["region_handle"] = 0; - bool imresult = doIMSending(reginfo, msgdata); - - /* - * If message delivery successful, save cache entry because we know it is good. - * Then tell caller message has been delivered and we are done. - */ - if (imresult) + if (upd != null) + { + GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, + upd.RegionID); + if (reginfo != null) { - lock (m_UserRegionMap) + Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); + // Not actually used anymore, left in for compatibility + // Remove at next interface change + // + msgdata["region_handle"] = 0; + bool imresult = doIMSending(reginfo, msgdata); + if (imresult) + { + // IM delivery successful, so store the Agent's location in our local cache. + lock (m_UserRegionMap) + { + if (m_UserRegionMap.ContainsKey(toAgentID)) + { + m_UserRegionMap[toAgentID] = upd.RegionID; + } + else + { + m_UserRegionMap.Add(toAgentID, upd.RegionID); + } + } + result(true); + } + else { - m_UserRegionMap[toAgentID] = regionID; + // try again, but lookup user this time. + // Warning, this must call the Async version + // of this method or we'll be making thousands of threads + // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync + // The version that spawns the thread is SendGridInstantMessageViaXMLRPC + + // This is recursive!!!!! + SendGridInstantMessageViaXMLRPCAsync(im, result, + upd.RegionID); } - result(true); - return; } - - /* - * Message delivery failed. - * If we just looked up what region the agent is in, message is undeliverable. - */ - if (lookupAgent) + else { - break; + m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); + HandleUndeliveredMessage(im, result); } - - /* - * We used a cached entry that we now know is bad. - * Try again by searching the grid for the user. - */ - lookupAgent = true; } - - /* - * Message is undeliverable for one reason or another. - * Remove possible bad entry from cache. - * Then inform caller that the message is undeliverable. - */ - lock (m_UserRegionMap) + else { - m_UserRegionMap.Remove(toAgentID); + HandleUndeliveredMessage(im, result); } - - // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); - HandleUndeliveredMessage(im, result); } /// -- cgit v1.1