From 60065f06b3fd6f680202405e117402b22d62f902 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 23 Apr 2012 22:23:47 +0100 Subject: refactor: Replace calls to InventorySelf() with existing m_itemID in LSL_Api There's no point look up an item ID that we already have. --- .../Shared/Api/Implementation/LSL_Api.cs | 136 +++++++-------------- 1 file changed, 42 insertions(+), 94 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 36c9d5e..6000293 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -85,7 +85,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected IScriptEngine m_ScriptEngine; protected SceneObjectPart m_host; protected uint m_localID; + + /// + /// The UUID of the item that hosts this script + /// protected UUID m_itemID; + protected bool throwErrorOnNotImplemented = true; protected AsyncCommandManager AsyncCommands = null; protected float m_ScriptDelayFactor = 1.0f; @@ -267,25 +272,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - protected UUID InventorySelf() - { - UUID invItemID = new UUID(); - - lock (m_host.TaskInventory) - { - foreach (KeyValuePair inv in m_host.TaskInventory) - { - if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) - { - invItemID = inv.Key; - break; - } - } - } - - return invItemID; - } - protected UUID InventoryKey(string name, int type) { m_host.AddScriptLPS(1); @@ -2697,17 +2683,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGiveMoney(string destination, int amount) { - UUID invItemID=InventorySelf(); - if (invItemID == UUID.Zero) - return 0; - m_host.AddScriptLPS(1); - TaskInventoryItem item = m_host.TaskInventory[invItemID]; + TaskInventoryItem item; lock (m_host.TaskInventory) { - item = m_host.TaskInventory[invItemID]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter == UUID.Zero) @@ -2955,10 +2937,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter != UUID.Zero) @@ -2983,10 +2965,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } m_host.AddScriptLPS(1); @@ -3026,10 +3008,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter != m_host.OwnerID) @@ -3058,10 +3040,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter != m_host.OwnerID) @@ -3313,18 +3295,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - UUID invItemID = InventorySelf(); - if (invItemID == UUID.Zero) - return; - TaskInventoryItem item; lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter == UUID.Zero) @@ -3350,18 +3328,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - UUID invItemID=InventorySelf(); - if (invItemID == UUID.Zero) - return; - TaskInventoryItem item; lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter == UUID.Zero) @@ -3417,21 +3391,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRequestPermissions(string agent, int perm) { - UUID agentID = new UUID(); + UUID agentID; if (!UUID.TryParse(agent, out agentID)) return; - UUID invItemID = InventorySelf(); - - if (invItemID == UUID.Zero) - return; // Not in a prim? How?? - TaskInventoryItem item; lock (m_host.TaskInventory) { - item = m_host.TaskInventory[invItemID]; + item = m_host.TaskInventory[m_itemID]; } if (agentID == UUID.Zero || perm == 0) // Releasing permissions @@ -3466,8 +3435,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { lock (m_host.TaskInventory) { - m_host.TaskInventory[invItemID].PermsGranter = agentID; - m_host.TaskInventory[invItemID].PermsMask = perm; + m_host.TaskInventory[m_itemID].PermsGranter = agentID; + m_host.TaskInventory[m_itemID].PermsMask = perm; } m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( @@ -3490,8 +3459,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { lock (m_host.TaskInventory) { - m_host.TaskInventory[invItemID].PermsGranter = agentID; - m_host.TaskInventory[invItemID].PermsMask = perm; + m_host.TaskInventory[m_itemID].PermsGranter = agentID; + m_host.TaskInventory[m_itemID].PermsMask = perm; } m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( @@ -3515,8 +3484,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { lock (m_host.TaskInventory) { - m_host.TaskInventory[invItemID].PermsGranter = agentID; - m_host.TaskInventory[invItemID].PermsMask = 0; + m_host.TaskInventory[m_itemID].PermsGranter = agentID; + m_host.TaskInventory[m_itemID].PermsMask = 0; } presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; @@ -3524,7 +3493,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } presence.ControllingClient.SendScriptQuestion( - m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); + m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm); return; } @@ -3541,20 +3510,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (taskID != m_host.UUID) return; - UUID invItemID = InventorySelf(); - - if (invItemID == UUID.Zero) - return; - - client.OnScriptAnswer-=handleScriptAnswer; - m_waitingForScriptAnswer=false; + client.OnScriptAnswer -= handleScriptAnswer; + m_waitingForScriptAnswer = false; if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) llReleaseControls(); lock (m_host.TaskInventory) { - m_host.TaskInventory[invItemID].PermsMask = answer; + m_host.TaskInventory[m_itemID].PermsMask = answer; } m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( @@ -3627,7 +3591,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llCreateLink(string target, int parent) { m_host.AddScriptLPS(1); - UUID invItemID = InventorySelf(); + UUID targetID; if (!UUID.TryParse(target, out targetID)) @@ -3636,7 +3600,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api TaskInventoryItem item; lock (m_host.TaskInventory) { - item = m_host.TaskInventory[invItemID]; + item = m_host.TaskInventory[m_itemID]; } if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 @@ -3688,11 +3652,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llBreakLink(int linknum) { m_host.AddScriptLPS(1); - UUID invItemID = InventorySelf(); lock (m_host.TaskInventory) { - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 + if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 && !m_automaticLinkPermission) { ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); @@ -9691,17 +9654,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetCameraPos() { m_host.AddScriptLPS(1); - UUID invItemID = InventorySelf(); - - if (invItemID == UUID.Zero) - return new LSL_Vector(); lock (m_host.TaskInventory) { - if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) + if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero) return new LSL_Vector(); - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) + if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) { ShoutError("No permissions to track the camera"); return new LSL_Vector(); @@ -9720,16 +9679,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation llGetCameraRot() { m_host.AddScriptLPS(1); - UUID invItemID = InventorySelf(); - if (invItemID == UUID.Zero) - return new LSL_Rotation(); lock (m_host.TaskInventory) { - if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) + if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero) return new LSL_Rotation(); - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) + if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) { ShoutError("No permissions to track the camera"); return new LSL_Rotation(); @@ -9907,10 +9863,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - // our key in the object we are in - UUID invItemID = InventorySelf(); - if (invItemID == UUID.Zero) return; - // the object we are in UUID objectID = m_host.ParentUUID; if (objectID == UUID.Zero) return; @@ -9919,10 +9871,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (m_host.TaskInventory) { // we need the permission first, to know which avatar we want to set the camera for - agentID = m_host.TaskInventory[invItemID].PermsGranter; + agentID = m_host.TaskInventory[m_itemID].PermsGranter; if (agentID == UUID.Zero) return; - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; + if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; } ScenePresence presence = World.GetScenePresence(agentID); @@ -9963,10 +9915,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - // our key in the object we are in - UUID invItemID=InventorySelf(); - if (invItemID == UUID.Zero) return; - // the object we are in UUID objectID = m_host.ParentUUID; if (objectID == UUID.Zero) return; @@ -9975,9 +9923,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID agentID; lock (m_host.TaskInventory) { - agentID = m_host.TaskInventory[invItemID].PermsGranter; + agentID = m_host.TaskInventory[m_itemID].PermsGranter; if (agentID == UUID.Zero) return; - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; + if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; } ScenePresence presence = World.GetScenePresence(agentID); -- cgit v1.1 From 1f8d1bcdcf7ae48ad0b3609e532ad87859f6300b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 23 Apr 2012 22:52:46 +0100 Subject: Replace common code to fetch self inventory item (as opposed to uuid) with GetSelfInventoryItem() However, at some point it would be far more convenient to receive the TaskInventoryItem in the constructor rather than just the item UUID, so we don't have to constantly refetch our self item. --- .../Shared/Api/Implementation/LSL_Api.cs | 231 +++++++-------------- 1 file changed, 76 insertions(+), 155 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6000293..a353b25 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -272,6 +272,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + /// + /// Get the inventory item that hosts ourselves. + /// + /// + /// FIXME: It would be far easier to pass in TaskInventoryItem rather than just m_itemID so that we don't need + /// to keep looking ourselves up. + /// + /// + protected TaskInventoryItem GetSelfInventoryItem() + { + lock (m_host.TaskInventory) + return m_host.TaskInventory[m_itemID]; + } + protected UUID InventoryKey(string name, int type) { m_host.AddScriptLPS(1); @@ -2685,12 +2699,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter == UUID.Zero) return 0; @@ -2933,15 +2942,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llTakeControls(int controls, int accept, int pass_on) { - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter != UUID.Zero) { @@ -2961,18 +2962,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llReleaseControls() { - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } - m_host.AddScriptLPS(1); + TaskInventoryItem item = GetSelfInventoryItem(); + if (item.PermsGranter != UUID.Zero) { ScenePresence presence = World.GetScenePresence(item.PermsGranter); @@ -3004,15 +2997,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) // return; - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter != m_host.OwnerID) return; @@ -3036,15 +3021,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.ParentGroup.AttachmentPoint == 0) return; - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter != m_host.OwnerID) return; @@ -3295,15 +3272,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter == UUID.Zero) return; @@ -3328,15 +3297,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter == UUID.Zero) return; @@ -3396,12 +3357,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(agent, out agentID)) return; - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (agentID == UUID.Zero || perm == 0) // Releasing permissions { @@ -3531,39 +3487,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) - { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Type == 10 && item.ItemID == m_itemID) - { - return item.PermsGranter.ToString(); - } - } - } - - return UUID.Zero.ToString(); + return GetSelfInventoryItem().PermsGranter.ToString(); } public LSL_Integer llGetPermissions() { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) - { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Type == 10 && item.ItemID == m_itemID) - { - int perms = item.PermsMask; - if (m_automaticLinkPermission) - perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; - return perms; - } - } - } + int perms = GetSelfInventoryItem().PermsMask; - return 0; + if (m_automaticLinkPermission) + perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; + + return perms; } public LSL_Integer llGetLinkNumber() @@ -3597,11 +3533,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(target, out targetID)) return; - TaskInventoryItem item; - lock (m_host.TaskInventory) - { - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 && !m_automaticLinkPermission) @@ -3653,14 +3585,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) + if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 + && !m_automaticLinkPermission) { - if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 - && !m_automaticLinkPermission) - { - ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); - return; - } + ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); + return; } if (linknum < ScriptBaseClass.LINK_THIS) @@ -4537,23 +4466,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetScriptName() { - string result = String.Empty; - m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) - { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Type == 10 && item.ItemID == m_itemID) - { - result = item.Name != null ? item.Name : String.Empty; - break; - } - } - } + TaskInventoryItem item = GetSelfInventoryItem(); - return result; + return item.Name != null ? item.Name : String.Empty; } public LSL_Integer llGetLinkNumberOfSides(int link) @@ -9655,16 +9572,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) - { - if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero) - return new LSL_Vector(); + TaskInventoryItem item = GetSelfInventoryItem(); - if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) - { - ShoutError("No permissions to track the camera"); - return new LSL_Vector(); - } + if (item.PermsGranter == UUID.Zero) + return new LSL_Vector(); + + if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) + { + ShoutError("No permissions to track the camera"); + return new LSL_Vector(); } ScenePresence presence = World.GetScenePresence(m_host.OwnerID); @@ -9680,16 +9596,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) - { - if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero) - return new LSL_Rotation(); + TaskInventoryItem item = GetSelfInventoryItem(); - if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) - { - ShoutError("No permissions to track the camera"); - return new LSL_Rotation(); - } + if (item.PermsGranter == UUID.Zero) + return new LSL_Rotation(); + + if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) + { + ShoutError("No permissions to track the camera"); + return new LSL_Rotation(); } ScenePresence presence = World.GetScenePresence(m_host.OwnerID); @@ -9865,17 +9780,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // the object we are in UUID objectID = m_host.ParentUUID; - if (objectID == UUID.Zero) return; + if (objectID == UUID.Zero) + return; - UUID agentID; - lock (m_host.TaskInventory) - { - // we need the permission first, to know which avatar we want to set the camera for - agentID = m_host.TaskInventory[m_itemID].PermsGranter; + TaskInventoryItem item = GetSelfInventoryItem(); - if (agentID == UUID.Zero) return; - if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; - } + // we need the permission first, to know which avatar we want to set the camera for + UUID agentID = item.PermsGranter; + + if (agentID == UUID.Zero) + return; + + if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) + return; ScenePresence presence = World.GetScenePresence(agentID); @@ -9917,21 +9834,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // the object we are in UUID objectID = m_host.ParentUUID; - if (objectID == UUID.Zero) return; + if (objectID == UUID.Zero) + return; + + TaskInventoryItem item = GetSelfInventoryItem(); // we need the permission first, to know which avatar we want to clear the camera for - UUID agentID; - lock (m_host.TaskInventory) - { - agentID = m_host.TaskInventory[m_itemID].PermsGranter; - if (agentID == UUID.Zero) return; - if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; - } + UUID agentID = item.PermsGranter; + + if (agentID == UUID.Zero) + return; + + if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) + return; ScenePresence presence = World.GetScenePresence(agentID); // we are not interested in child-agents - if (presence.IsChildAgent) return; + if (presence.IsChildAgent) + return; presence.ControllingClient.SendClearFollowCamProperties(objectID); } -- cgit v1.1 From 40e37d8b78379db08de541c8c7a9fed1d22ec5ef Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Apr 2012 00:03:57 +0100 Subject: Add osForceAttachToAvatar() and osForceDetachFromAvatar() These behave identically to llAttachToAvatar() and llDetachFromAvatar() except that they do not enforce the PERMISSION_ATTACH check Intended for use in completely controlled dedicated environments where these checks are more a UI hinderance than a help. Threat level high. --- .../Shared/Api/Implementation/ApiManager.cs | 41 ++++++------ .../Shared/Api/Implementation/LSL_Api.cs | 73 +++++++++++++--------- .../Shared/Api/Implementation/OSSL_Api.cs | 28 +++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 14 +++++ .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 13 +++- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 7 +++ 6 files changed, 127 insertions(+), 49 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs index 47ed6ba..684138f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs @@ -29,42 +29,43 @@ using System; using System.Collections; using System.Collections.Generic; using System.Reflection; +using log4net; using OpenSim.Region.ScriptEngine.Interfaces; namespace OpenSim.Region.ScriptEngine.Shared.Api { public class ApiManager { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Dictionary m_Apis = new Dictionary(); public string[] GetApis() { - if (m_Apis.Count > 0) + if (m_Apis.Count <= 0) { - List l = new List(m_Apis.Keys); - return l.ToArray(); - } + Assembly a = Assembly.GetExecutingAssembly(); - Assembly a = Assembly.GetExecutingAssembly(); + Type[] types = a.GetExportedTypes(); - Type[] types = a.GetExportedTypes(); - - foreach (Type t in types) - { - string name = t.ToString(); - int idx = name.LastIndexOf('.'); - if (idx != -1) - name = name.Substring(idx+1); - - if (name.EndsWith("_Api")) + foreach (Type t in types) { - name = name.Substring(0, name.Length - 4); - m_Apis[name] = t; + string name = t.ToString(); + int idx = name.LastIndexOf('.'); + if (idx != -1) + name = name.Substring(idx+1); + + if (name.EndsWith("_Api")) + { + name = name.Substring(0, name.Length - 4); + m_Apis[name] = t; + } } } - List ret = new List(m_Apis.Keys); - return ret.ToArray(); +// m_log.DebugFormat("[API MANAGER]: Found {0} apis", m_Apis.Keys.Count); + + return new List(m_Apis.Keys).ToArray(); } public IScriptApi CreateApi(string api) @@ -76,4 +77,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return ret; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9cb97f9..d4c872c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2994,7 +2994,49 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_UrlModule.ReleaseURL(url); } - public void llAttachToAvatar(int attachment) + /// + /// Attach the object containing this script to the avatar that owns it. + /// + /// The attachment point (e.g. ATTACH_CHEST) + /// true if the attach suceeded, false if it did not + public bool AttachToAvatar(int attachmentPoint) + { + SceneObjectGroup grp = m_host.ParentGroup; + ScenePresence presence = World.GetScenePresence(m_host.OwnerID); + + IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; + + if (attachmentsModule != null) + return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false); + else + return false; + } + + /// + /// Detach the object containing this script from the avatar it is attached to. + /// + /// + /// Nothing happens if the object is not attached. + /// + public void DetachFromAvatar() + { + Util.FireAndForget(DetachWrapper, m_host); + } + + private void DetachWrapper(object o) + { + SceneObjectPart host = (SceneObjectPart)o; + + SceneObjectGroup grp = host.ParentGroup; + UUID itemID = grp.FromItemID; + ScenePresence presence = World.GetScenePresence(host.OwnerID); + + IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; + if (attachmentsModule != null) + attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); + } + + public void llAttachToAvatar(int attachmentPoint) { m_host.AddScriptLPS(1); @@ -3007,15 +3049,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) - { - SceneObjectGroup grp = m_host.ParentGroup; - - ScenePresence presence = World.GetScenePresence(m_host.OwnerID); - - IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; - if (attachmentsModule != null) - attachmentsModule.AttachObject(presence, grp, (uint)attachment, false); - } + AttachToAvatar(attachmentPoint); } public void llDetachFromAvatar() @@ -3031,24 +3065,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) - { - IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; - if (attachmentsModule != null) - Util.FireAndForget(DetachWrapper, m_host); - } - } - - private void DetachWrapper(object o) - { - SceneObjectPart host = (SceneObjectPart)o; - - SceneObjectGroup grp = host.ParentGroup; - UUID itemID = grp.FromItemID; - ScenePresence presence = World.GetScenePresence(host.OwnerID); - - IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; - if (attachmentsModule != null) - attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); + DetachFromAvatar(); } public void llTakeCamera(string avatar) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index fe94b79..3f261ea 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -209,6 +209,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api throw new Exception("OSSL Runtime Error: " + msg); } + /// + /// Initialize the LSL interface. + /// + /// + /// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no + /// guarantee the interface is present on Initialize(). There needs to be another post initialize call from + /// ScriptInstance. + /// private void InitLSL() { if (m_LSL_Api != null) @@ -3093,5 +3101,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); } } + + public void osForceAttachToAvatar(int attachmentPoint) + { + CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); + + m_host.AddScriptLPS(1); + + InitLSL(); + ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); + } + + public void osForceDetachFromAvatar() + { + CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); + + m_host.AddScriptLPS(1); + + InitLSL(); + ((LSL_Api)m_LSL_Api).DetachFromAvatar(); + } } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 545bbee..d0c852b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -98,6 +98,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osAvatarPlayAnimation(string avatar, string animation); void osAvatarStopAnimation(string avatar, string animation); + // Attachment commands + + /// + /// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH + /// + /// The attachment point. For example, ATTACH_CHEST + void osForceAttachToAvatar(int attachment); + + /// + /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH + /// + /// Nothing happens if the object is not attached. + void osForceDetachFromAvatar(); + //texture draw functions string osMovePen(string drawList, int x, int y); string osDrawLine(string drawList, int startX, int startY, int endX, int endY); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index b94b9bf..36ac0e3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -289,8 +289,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); } + // Avatar functions - //Texture Draw functions + public void osForceAttachToAvatar(int attachmentPoint) + { + m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint); + } + + public void osForceDetachFromAvatar() + { + m_OSSL_Functions.osForceDetachFromAvatar(); + } + + // Texture Draw functions public string osMovePen(string drawList, int x, int y) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 6e36742..2c8af81 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -964,7 +964,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance public IScriptApi GetApi(string name) { if (m_Apis.ContainsKey(name)) + { +// m_log.DebugFormat("[SCRIPT INSTANCE]: Found api {0} in {1}@{2}", name, ScriptName, PrimName); + return m_Apis[name]; + } + +// m_log.DebugFormat("[SCRIPT INSTANCE]: Did not find api {0} in {1}@{2}", name, ScriptName, PrimName); + return null; } -- cgit v1.1 From 6c21e15cb9542c06e69fd8acd6d4c04aad2cd7da Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Apr 2012 00:32:01 +0100 Subject: Add online/offline indicator to "friends show" region console command. Improve output table formatting. --- .../Avatar/Friends/FriendsCommandsModule.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs index e68f9d0..2602050 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs @@ -58,6 +58,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends private Scene m_scene; private IFriendsModule m_friendsModule; private IUserManagement m_userManagementModule; + private IPresenceService m_presenceService; // private IAvatarFactoryModule m_avatarFactory; @@ -99,8 +100,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends m_friendsModule = m_scene.RequestModuleInterface(); m_userManagementModule = m_scene.RequestModuleInterface(); + m_presenceService = m_scene.RequestModuleInterface(); - if (m_friendsModule != null && m_userManagementModule != null) + if (m_friendsModule != null && m_userManagementModule != null && m_presenceService != null) { m_scene.AddCommand( "Friends", this, "friends show", @@ -162,7 +164,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends MainConsole.Instance.OutputFormat("Friends for {0} {1} {2}:", firstName, lastName, userId); - MainConsole.Instance.OutputFormat("UUID, Name, MyFlags, TheirFlags"); + MainConsole.Instance.OutputFormat( + "{0,-36} {1,-36} {2,-7} {3,7} {4,10}", "UUID", "Name", "Status", "MyFlags", "TheirFlags"); foreach (FriendInfo friend in friends) { @@ -175,14 +178,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends UUID friendId; string friendName; + string onlineText; if (UUID.TryParse(friend.Friend, out friendId)) friendName = m_userManagementModule.GetUserName(friendId); else friendName = friend.Friend; + OpenSim.Services.Interfaces.PresenceInfo[] pi = m_presenceService.GetAgents(new string[] { friend.Friend }); + if (pi.Length > 0) + onlineText = "online"; + else + onlineText = "offline"; + MainConsole.Instance.OutputFormat( - "{0} {1} {2} {3}", friend.Friend, friendName, friend.MyFlags, friend.TheirFlags); + "{0,-36} {1,-36} {2,-7} {3,-7} {4,-10}", + friend.Friend, friendName, onlineText, friend.MyFlags, friend.TheirFlags); } } } -- cgit v1.1 From fd279889788420a63d7454833ab33cb4060edf38 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 23 Apr 2012 21:29:18 -0700 Subject: Changed the Map-related messages from Info to Debug. They're debug messages. --- OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | 4 ++-- OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs | 4 ++-- OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs | 4 ++-- OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index f86c790..aa306c7 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs @@ -225,7 +225,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap int tc = 0; double[,] hm = whichScene.Heightmap.GetDoubles(); tc = Environment.TickCount; - m_log.Info("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); EntityBase[] objs = whichScene.GetEntities(); Dictionary z_sort = new Dictionary(); //SortedList z_sort = new SortedList(); @@ -541,7 +541,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap g.Dispose(); } // lock entities objs - m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); return mapbmp; } diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs index eb1a27f..992bff3 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs @@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap public void TerrainToBitmap(Bitmap mapbmp) { int tc = Environment.TickCount; - m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); double[,] hm = m_scene.Heightmap.GetDoubles(); bool ShadowDebugContinue = true; @@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap } } } - m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); } } } diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs index 1d2141e..d13c2ef 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs @@ -278,7 +278,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap public void TerrainToBitmap(Bitmap mapbmp) { int tc = Environment.TickCount; - m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); // These textures should be in the AssetCache anyway, as every client conneting to this // region needs them. Except on start, when the map is recreated (before anyone connected), @@ -412,7 +412,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap } } } - m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); } } } diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs index 6163fd1..4f4e296 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs @@ -88,11 +88,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); - m_log.Info("[MAPTILE]: Loaded prim mesher " + m_primMesher.ToString()); + m_log.Debug("[MAPTILE]: Loaded prim mesher " + m_primMesher.ToString()); } else { - m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); + m_log.Debug("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); } m_scene.RegisterModuleInterface(this); -- cgit v1.1 From c6f30e044b6cd2ed8493ad0e2914786eef4f7890 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Apr 2012 19:49:52 +0100 Subject: Restore _parent_scene.actor_name_map[prim_geom] = this; accidentally removed from ODEPrim.SetGeom. This occurred in 7a574be3fd from Sat 21 Apr 2012. This should fix collision detection. Mnay thanks to tglion for the spot and the fix in http://opensimulator.org/mantis/view.php?id=5988 --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 3f88353..0716214 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -338,6 +338,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); _parent_scene.geom_name_map[prim_geom] = Name; + _parent_scene.actor_name_map[prim_geom] = this; if (childPrim) { -- cgit v1.1 From 0e3053e4c97670e897496ffa98d7039bf686e6d2 Mon Sep 17 00:00:00 2001 From: Olivier van Helden and Gudule Lapointe (Speculoos.net) Date: Thu, 19 Apr 2012 01:17:56 +0200 Subject: DST settings to match client default Pacific Time (mantis #5972) --- OpenSim/Services/LLLoginService/LLLoginResponse.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index 844c5ae..8fdcf4e 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -349,7 +349,21 @@ namespace OpenSim.Services.LLLoginService private void SetDefaultValues() { - DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; + TimeZoneInfo gridTimeZone; + try + { + // First try to fetch DST from Pacific Standard Time, because this is + // the one expected by the viewer. "US/Pacific" is the string to search + // on linux and mac, and should work also on Windows (to confirm) + gridTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US/Pacific"); + } + catch (Exception e) + { + m_log.WarnFormat("[TIMEZONE]: {0} Falling back to system time. System time should be set to Pacific Standard Time to provide the expected time", e.Message); + gridTimeZone = TimeZoneInfo.Local; + } + DST = gridTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; + StipendSinceLogin = "N"; Gendered = "Y"; EverLoggedIn = "Y"; -- cgit v1.1 From cbe889e10bc06f0a3e31b4094c88bf022635dff9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Apr 2012 20:30:19 +0100 Subject: minor: formatting changes to top of LLLoginResponse.SetDefaultValues(), chiefly some break up of the long line. --- OpenSim/Services/LLLoginService/LLLoginResponse.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index 8fdcf4e..10a44ed 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -350,6 +350,7 @@ namespace OpenSim.Services.LLLoginService private void SetDefaultValues() { TimeZoneInfo gridTimeZone; + try { // First try to fetch DST from Pacific Standard Time, because this is @@ -359,9 +360,13 @@ namespace OpenSim.Services.LLLoginService } catch (Exception e) { - m_log.WarnFormat("[TIMEZONE]: {0} Falling back to system time. System time should be set to Pacific Standard Time to provide the expected time", e.Message); + m_log.WarnFormat( + "[TIMEZONE]: {0} Falling back to system time. System time should be set to Pacific Standard Time to provide the expected time", + e.Message); + gridTimeZone = TimeZoneInfo.Local; } + DST = gridTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; StipendSinceLogin = "N"; -- cgit v1.1 From 6011bfa5e36d77ad58cf50ddd99b8c6289144f57 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 19:19:08 +0300 Subject: OSSL: fixed the threat level check for osParseJSONNew --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 3f261ea..7fc7337 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1617,7 +1617,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public Object osParseJSONNew(string JSON) { - CheckThreatLevel(ThreatLevel.None, "osParseJSON"); + CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); m_host.AddScriptLPS(1); -- cgit v1.1 From c70e85a3271aaa9e6d892240964cb55cbc2960c7 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 18:38:21 +0300 Subject: When reading a region, use null objects to represent NULL fields. Previously NULL fields were converted to an empty string due to the use of ToString(). But if the field was an Int (e.g., "locZ"), then the subsequent attempt to convert an empty string to an int caused an exception. Now the field is null so we don't try to convert it, so there's no exception. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index c20c392..948cdf3 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -187,7 +187,11 @@ namespace OpenSim.Data.MySQL if (s == "locY") continue; - ret.Data[s] = result[s].ToString(); + object value = result[s]; + if (value is DBNull) + ret.Data[s] = null; + else + ret.Data[s] = result[s].ToString(); } retList.Add(ret); -- cgit v1.1 From da5fd53702ce97d13da2cb50da0753d507e6c11b Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 18:39:23 +0300 Subject: Fixed problem with MySQL: it was possible for one thread to use an incomplete list of column names if another thread was creating the list at the same time. Now this is thread-safe. --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 23 +++++++++++++------- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 6 ++++-- OpenSim/Data/MySQL/MySQLRegionData.cs | 29 ++++++++++++++++---------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 8d82f61..664ce84 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -79,14 +79,7 @@ namespace OpenSim.Data.MySQL { ret.PrincipalID = principalID; - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } + CheckColumnNames(result); foreach (string s in m_ColumnNames) { @@ -105,6 +98,20 @@ namespace OpenSim.Data.MySQL } } + private void CheckColumnNames(IDataReader result) + { + if (m_ColumnNames != null) + return; + + List columnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + columnNames.Add(row["ColumnName"].ToString()); + + m_ColumnNames = columnNames; + } + public bool Store(AuthenticationData data) { if (data.Data.ContainsKey("UUID")) diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 754cf72..da8e958 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -91,15 +91,17 @@ namespace OpenSim.Data.MySQL if (m_ColumnNames != null) return; - m_ColumnNames = new List(); + List columnNames = new List(); DataTable schemaTable = reader.GetSchemaTable(); foreach (DataRow row in schemaTable.Rows) { if (row["ColumnName"] != null && (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) - m_ColumnNames.Add(row["ColumnName"].ToString()); + columnNames.Add(row["ColumnName"].ToString()); } + + m_ColumnNames = columnNames; } public virtual T[] Get(string field, string key) diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 948cdf3..d1f1932 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -162,17 +162,7 @@ namespace OpenSim.Data.MySQL ret.sizeX = Convert.ToInt32(result["sizeX"]); ret.sizeY = Convert.ToInt32(result["sizeY"]); - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - { - if (row["ColumnName"] != null) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - } + CheckColumnNames(result); foreach (string s in m_ColumnNames) { @@ -202,6 +192,23 @@ namespace OpenSim.Data.MySQL return retList; } + private void CheckColumnNames(IDataReader result) + { + if (m_ColumnNames != null) + return; + + List columnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + { + if (row["ColumnName"] != null) + columnNames.Add(row["ColumnName"].ToString()); + } + + m_ColumnNames = columnNames; + } + public bool Store(RegionData data) { if (data.Data.ContainsKey("uuid")) -- cgit v1.1 From d3a4d67a207976cd0d116bb9021f7dfc896784e8 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 17:26:37 +0300 Subject: Refactored how asset/inventory types are associated with content types: gathered all the knowledge into a single class. Added the Mesh content type. --- OpenSim/Framework/SLUtil.cs | 382 ++++++++++++++++-------------------- OpenSim/Framework/Tests/UtilTest.cs | 23 ++- 2 files changed, 177 insertions(+), 228 deletions(-) diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index db4541e..537de7a 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs @@ -38,239 +38,189 @@ namespace OpenSim.Framework public static class SLUtil { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + #region SL / file extension / content-type conversions - public static string SLAssetTypeToContentType(int assetType) + private class TypeMapping { - switch ((AssetType)assetType) + private sbyte assetType; + private InventoryType inventoryType; + private string contentType; + private string contentType2; + private string extension; + + public sbyte AssetTypeCode + { + get { return assetType; } + } + + public object AssetType + { + get { + if (Enum.IsDefined(typeof(OpenMetaverse.AssetType), assetType)) + return (OpenMetaverse.AssetType)assetType; + else + return OpenMetaverse.AssetType.Unknown; + } + } + + public InventoryType InventoryType + { + get { return inventoryType; } + } + + public string ContentType + { + get { return contentType; } + } + + public string ContentType2 + { + get { return contentType2; } + } + + public string Extension + { + get { return extension; } + } + + private TypeMapping(sbyte assetType, InventoryType inventoryType, string contentType, string contentType2, string extension) + { + this.assetType = assetType; + this.inventoryType = inventoryType; + this.contentType = contentType; + this.contentType2 = contentType2; + this.extension = extension; + } + + public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string contentType2, string extension) + : this((sbyte)assetType, inventoryType, contentType, contentType2, extension) + { + } + + public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string extension) + : this((sbyte)assetType, inventoryType, contentType, null, extension) { - case AssetType.Texture: - return "image/x-j2c"; - case AssetType.Sound: - return "audio/ogg"; - case AssetType.CallingCard: - return "application/vnd.ll.callingcard"; - case AssetType.Landmark: - return "application/vnd.ll.landmark"; - case AssetType.Clothing: - return "application/vnd.ll.clothing"; - case AssetType.Object: - return "application/vnd.ll.primitive"; - case AssetType.Notecard: - return "application/vnd.ll.notecard"; - case AssetType.Folder: - return "application/vnd.ll.folder"; - case AssetType.RootFolder: - return "application/vnd.ll.rootfolder"; - case AssetType.LSLText: - return "application/vnd.ll.lsltext"; - case AssetType.LSLBytecode: - return "application/vnd.ll.lslbyte"; - case AssetType.TextureTGA: - case AssetType.ImageTGA: - return "image/tga"; - case AssetType.Bodypart: - return "application/vnd.ll.bodypart"; - case AssetType.TrashFolder: - return "application/vnd.ll.trashfolder"; - case AssetType.SnapshotFolder: - return "application/vnd.ll.snapshotfolder"; - case AssetType.LostAndFoundFolder: - return "application/vnd.ll.lostandfoundfolder"; - case AssetType.SoundWAV: - return "audio/x-wav"; - case AssetType.ImageJPEG: - return "image/jpeg"; - case AssetType.Animation: - return "application/vnd.ll.animation"; - case AssetType.Gesture: - return "application/vnd.ll.gesture"; - case AssetType.Simstate: - return "application/x-metaverse-simstate"; - case AssetType.FavoriteFolder: - return "application/vnd.ll.favoritefolder"; - case AssetType.Link: - return "application/vnd.ll.link"; - case AssetType.LinkFolder: - return "application/vnd.ll.linkfolder"; - case AssetType.CurrentOutfitFolder: - return "application/vnd.ll.currentoutfitfolder"; - case AssetType.OutfitFolder: - return "application/vnd.ll.outfitfolder"; - case AssetType.MyOutfitsFolder: - return "application/vnd.ll.myoutfitsfolder"; - case AssetType.Unknown: - default: - return "application/octet-stream"; } } - public static string SLInvTypeToContentType(int invType) + /// + /// Maps between AssetType, InventoryType and Content-Type. + /// Where more than one possibility exists, the first one takes precedence. E.g.: + /// AssetType "AssetType.Texture" -> Content-Type "image-xj2c" + /// Content-Type "image/x-j2c" -> InventoryType "InventoryType.Texture" + /// + private static TypeMapping[] MAPPINGS = new TypeMapping[] { + new TypeMapping(AssetType.Unknown, InventoryType.Unknown, "application/octet-stream", "bin"), + new TypeMapping(AssetType.Texture, InventoryType.Texture, "image/x-j2c", "image/jp2", "j2c"), + new TypeMapping(AssetType.Texture, InventoryType.Snapshot, "image/x-j2c", "image/jp2", "j2c"), + new TypeMapping(AssetType.TextureTGA, InventoryType.Texture, "image/tga", "tga"), + new TypeMapping(AssetType.ImageTGA, InventoryType.Texture, "image/tga", "tga"), + new TypeMapping(AssetType.ImageJPEG, InventoryType.Texture, "image/jpeg", "jpg"), + new TypeMapping(AssetType.Sound, InventoryType.Sound, "audio/ogg", "application/ogg", "ogg"), + new TypeMapping(AssetType.SoundWAV, InventoryType.Sound, "audio/x-wav", "wav"), + new TypeMapping(AssetType.CallingCard, InventoryType.CallingCard, "application/vnd.ll.callingcard", "application/x-metaverse-callingcard", "callingcard"), + new TypeMapping(AssetType.Landmark, InventoryType.Landmark, "application/vnd.ll.landmark", "application/x-metaverse-landmark", "landmark"), + new TypeMapping(AssetType.Clothing, InventoryType.Wearable, "application/vnd.ll.clothing", "application/x-metaverse-clothing", "clothing"), + new TypeMapping(AssetType.Object, InventoryType.Object, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), + new TypeMapping(AssetType.Object, InventoryType.Attachment, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), + new TypeMapping(AssetType.Notecard, InventoryType.Notecard, "application/vnd.ll.notecard", "application/x-metaverse-notecard", "notecard"), + new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"), + new TypeMapping(AssetType.RootFolder, InventoryType.RootCategory, "application/vnd.ll.rootfolder", "rootfolder"), + new TypeMapping(AssetType.LSLText, InventoryType.LSL, "application/vnd.ll.lsltext", "application/x-metaverse-lsl", "lsl"), + new TypeMapping(AssetType.LSLBytecode, InventoryType.LSL, "application/vnd.ll.lslbyte", "application/x-metaverse-lso", "lso"), + new TypeMapping(AssetType.Bodypart, InventoryType.Wearable, "application/vnd.ll.bodypart", "application/x-metaverse-bodypart", "bodypart"), + new TypeMapping(AssetType.TrashFolder, InventoryType.Folder, "application/vnd.ll.trashfolder", "trashfolder"), + new TypeMapping(AssetType.SnapshotFolder, InventoryType.Folder, "application/vnd.ll.snapshotfolder", "snapshotfolder"), + new TypeMapping(AssetType.LostAndFoundFolder, InventoryType.Folder, "application/vnd.ll.lostandfoundfolder", "lostandfoundfolder"), + new TypeMapping(AssetType.Animation, InventoryType.Animation, "application/vnd.ll.animation", "application/x-metaverse-animation", "animation"), + new TypeMapping(AssetType.Gesture, InventoryType.Gesture, "application/vnd.ll.gesture", "application/x-metaverse-gesture", "gesture"), + new TypeMapping(AssetType.Simstate, InventoryType.Snapshot, "application/x-metaverse-simstate", "simstate"), + new TypeMapping(AssetType.FavoriteFolder, InventoryType.Unknown, "application/vnd.ll.favoritefolder", "favoritefolder"), + new TypeMapping(AssetType.Link, InventoryType.Unknown, "application/vnd.ll.link", "link"), + new TypeMapping(AssetType.LinkFolder, InventoryType.Unknown, "application/vnd.ll.linkfolder", "linkfolder"), + new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"), + new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"), + new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"), + new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm") + }; + + private static Dictionary asset2Content; + private static Dictionary asset2Extension; + private static Dictionary inventory2Content; + private static Dictionary content2Asset; + private static Dictionary content2Inventory; + + static SLUtil() { - switch ((InventoryType)invType) + asset2Content = new Dictionary(); + asset2Extension = new Dictionary(); + inventory2Content = new Dictionary(); + content2Asset = new Dictionary(); + content2Inventory = new Dictionary(); + + foreach (TypeMapping mapping in MAPPINGS) { - case InventoryType.Animation: - return "application/vnd.ll.animation"; - case InventoryType.CallingCard: - return "application/vnd.ll.callingcard"; - case InventoryType.Folder: - return "application/vnd.ll.folder"; - case InventoryType.Gesture: - return "application/vnd.ll.gesture"; - case InventoryType.Landmark: - return "application/vnd.ll.landmark"; - case InventoryType.LSL: - return "application/vnd.ll.lsltext"; - case InventoryType.Notecard: - return "application/vnd.ll.notecard"; - case InventoryType.Attachment: - case InventoryType.Object: - return "application/vnd.ll.primitive"; - case InventoryType.Sound: - return "audio/ogg"; - case InventoryType.Snapshot: - case InventoryType.Texture: - return "image/x-j2c"; - case InventoryType.Wearable: - return "application/vnd.ll.clothing"; - default: - return "application/octet-stream"; + sbyte assetType = mapping.AssetTypeCode; + if (!asset2Content.ContainsKey(assetType)) + asset2Content.Add(assetType, mapping.ContentType); + if (!asset2Extension.ContainsKey(assetType)) + asset2Extension.Add(assetType, mapping.Extension); + if (!inventory2Content.ContainsKey(mapping.InventoryType)) + inventory2Content.Add(mapping.InventoryType, mapping.ContentType); + if (!content2Asset.ContainsKey(mapping.ContentType)) + content2Asset.Add(mapping.ContentType, assetType); + if (!content2Inventory.ContainsKey(mapping.ContentType)) + content2Inventory.Add(mapping.ContentType, mapping.InventoryType); + + if (mapping.ContentType2 != null) + { + if (!content2Asset.ContainsKey(mapping.ContentType2)) + content2Asset.Add(mapping.ContentType2, assetType); + if (!content2Inventory.ContainsKey(mapping.ContentType2)) + content2Inventory.Add(mapping.ContentType2, mapping.InventoryType); + } } } + + public static string SLAssetTypeToContentType(int assetType) + { + string contentType; + if (!asset2Content.TryGetValue((sbyte)assetType, out contentType)) + contentType = asset2Content[(sbyte)AssetType.Unknown]; + return contentType; + } + + public static string SLInvTypeToContentType(int invType) + { + string contentType; + if (!inventory2Content.TryGetValue((InventoryType)invType, out contentType)) + contentType = inventory2Content[InventoryType.Unknown]; + return contentType; + } public static sbyte ContentTypeToSLAssetType(string contentType) { - switch (contentType) - { - case "image/x-j2c": - case "image/jp2": - return (sbyte)AssetType.Texture; - case "application/ogg": - case "audio/ogg": - return (sbyte)AssetType.Sound; - case "application/vnd.ll.callingcard": - case "application/x-metaverse-callingcard": - return (sbyte)AssetType.CallingCard; - case "application/vnd.ll.landmark": - case "application/x-metaverse-landmark": - return (sbyte)AssetType.Landmark; - case "application/vnd.ll.clothing": - case "application/x-metaverse-clothing": - return (sbyte)AssetType.Clothing; - case "application/vnd.ll.primitive": - case "application/x-metaverse-primitive": - return (sbyte)AssetType.Object; - case "application/vnd.ll.notecard": - case "application/x-metaverse-notecard": - return (sbyte)AssetType.Notecard; - case "application/vnd.ll.folder": - return (sbyte)AssetType.Folder; - case "application/vnd.ll.rootfolder": - return (sbyte)AssetType.RootFolder; - case "application/vnd.ll.lsltext": - case "application/x-metaverse-lsl": - return (sbyte)AssetType.LSLText; - case "application/vnd.ll.lslbyte": - case "application/x-metaverse-lso": - return (sbyte)AssetType.LSLBytecode; - case "image/tga": - // Note that AssetType.TextureTGA will be converted to AssetType.ImageTGA - return (sbyte)AssetType.ImageTGA; - case "application/vnd.ll.bodypart": - case "application/x-metaverse-bodypart": - return (sbyte)AssetType.Bodypart; - case "application/vnd.ll.trashfolder": - return (sbyte)AssetType.TrashFolder; - case "application/vnd.ll.snapshotfolder": - return (sbyte)AssetType.SnapshotFolder; - case "application/vnd.ll.lostandfoundfolder": - return (sbyte)AssetType.LostAndFoundFolder; - case "audio/x-wav": - return (sbyte)AssetType.SoundWAV; - case "image/jpeg": - return (sbyte)AssetType.ImageJPEG; - case "application/vnd.ll.animation": - case "application/x-metaverse-animation": - return (sbyte)AssetType.Animation; - case "application/vnd.ll.gesture": - case "application/x-metaverse-gesture": - return (sbyte)AssetType.Gesture; - case "application/x-metaverse-simstate": - return (sbyte)AssetType.Simstate; - case "application/vnd.ll.favoritefolder": - return (sbyte)AssetType.FavoriteFolder; - case "application/vnd.ll.link": - return (sbyte)AssetType.Link; - case "application/vnd.ll.linkfolder": - return (sbyte)AssetType.LinkFolder; - case "application/vnd.ll.currentoutfitfolder": - return (sbyte)AssetType.CurrentOutfitFolder; - case "application/vnd.ll.outfitfolder": - return (sbyte)AssetType.OutfitFolder; - case "application/vnd.ll.myoutfitsfolder": - return (sbyte)AssetType.MyOutfitsFolder; - case "application/octet-stream": - default: - return (sbyte)AssetType.Unknown; - } + sbyte assetType; + if (!content2Asset.TryGetValue(contentType, out assetType)) + assetType = (sbyte)AssetType.Unknown; + return (sbyte)assetType; } public static sbyte ContentTypeToSLInvType(string contentType) { - switch (contentType) - { - case "image/x-j2c": - case "image/jp2": - case "image/tga": - case "image/jpeg": - return (sbyte)InventoryType.Texture; - case "application/ogg": - case "audio/ogg": - case "audio/x-wav": - return (sbyte)InventoryType.Sound; - case "application/vnd.ll.callingcard": - case "application/x-metaverse-callingcard": - return (sbyte)InventoryType.CallingCard; - case "application/vnd.ll.landmark": - case "application/x-metaverse-landmark": - return (sbyte)InventoryType.Landmark; - case "application/vnd.ll.clothing": - case "application/x-metaverse-clothing": - case "application/vnd.ll.bodypart": - case "application/x-metaverse-bodypart": - return (sbyte)InventoryType.Wearable; - case "application/vnd.ll.primitive": - case "application/x-metaverse-primitive": - return (sbyte)InventoryType.Object; - case "application/vnd.ll.notecard": - case "application/x-metaverse-notecard": - return (sbyte)InventoryType.Notecard; - case "application/vnd.ll.folder": - return (sbyte)InventoryType.Folder; - case "application/vnd.ll.rootfolder": - return (sbyte)InventoryType.RootCategory; - case "application/vnd.ll.lsltext": - case "application/x-metaverse-lsl": - case "application/vnd.ll.lslbyte": - case "application/x-metaverse-lso": - return (sbyte)InventoryType.LSL; - case "application/vnd.ll.trashfolder": - case "application/vnd.ll.snapshotfolder": - case "application/vnd.ll.lostandfoundfolder": - return (sbyte)InventoryType.Folder; - case "application/vnd.ll.animation": - case "application/x-metaverse-animation": - return (sbyte)InventoryType.Animation; - case "application/vnd.ll.gesture": - case "application/x-metaverse-gesture": - return (sbyte)InventoryType.Gesture; - case "application/x-metaverse-simstate": - return (sbyte)InventoryType.Snapshot; - case "application/octet-stream": - default: - return (sbyte)InventoryType.Unknown; - } + InventoryType invType; + if (!content2Inventory.TryGetValue(contentType, out invType)) + invType = InventoryType.Unknown; + return (sbyte)invType; + } + + public static string SLAssetTypeToExtension(int assetType) + { + string extension; + if (!asset2Extension.TryGetValue((sbyte)assetType, out extension)) + extension = asset2Extension[(sbyte)AssetType.Unknown]; + return extension; } #endregion SL / file extension / content-type conversions @@ -377,4 +327,4 @@ namespace OpenSim.Framework return output; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index 1ca35df..f0d2a3f 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs @@ -214,16 +214,13 @@ namespace OpenSim.Framework.Tests for (int i = 0; i < contenttypes.Length; i++) { - if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18) - { - Assert.That(contenttypes[i] == "image/tga"); - } + int expected; + if (contenttypes[i] == "image/tga") + expected = 12; // if we know only the content-type "image/tga", then we assume the asset type is TextureTGA; not ImageTGA else - { - Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i], - "Expecting {0} but got {1}", assettypes[i], - SLUtil.ContentTypeToSLAssetType(contenttypes[i])); - } + expected = assettypes[i]; + Assert.AreEqual(expected, SLUtil.ContentTypeToSLAssetType(contenttypes[i]), + String.Format("Incorrect AssetType mapped from Content-Type {0}", contenttypes[i])); } int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20}; @@ -237,7 +234,7 @@ namespace OpenSim.Framework.Tests "application/vnd.ll.primitive", "application/vnd.ll.notecard", "application/vnd.ll.folder", - "application/octet-stream", + "application/vnd.ll.rootfolder", "application/vnd.ll.lsltext", "image/x-j2c", "application/vnd.ll.primitive", @@ -247,7 +244,8 @@ namespace OpenSim.Framework.Tests for (int i=0;i - /// Maps between AssetType, InventoryType and Content-Type. - /// Where more than one possibility exists, the first one takes precedence. E.g.: - /// AssetType "AssetType.Texture" -> Content-Type "image-xj2c" - /// Content-Type "image/x-j2c" -> InventoryType "InventoryType.Texture" - /// - private static TypeMapping[] MAPPINGS = new TypeMapping[] { - new TypeMapping(AssetType.Unknown, InventoryType.Unknown, "application/octet-stream", "bin"), - new TypeMapping(AssetType.Texture, InventoryType.Texture, "image/x-j2c", "image/jp2", "j2c"), - new TypeMapping(AssetType.Texture, InventoryType.Snapshot, "image/x-j2c", "image/jp2", "j2c"), - new TypeMapping(AssetType.TextureTGA, InventoryType.Texture, "image/tga", "tga"), - new TypeMapping(AssetType.ImageTGA, InventoryType.Texture, "image/tga", "tga"), - new TypeMapping(AssetType.ImageJPEG, InventoryType.Texture, "image/jpeg", "jpg"), - new TypeMapping(AssetType.Sound, InventoryType.Sound, "audio/ogg", "application/ogg", "ogg"), - new TypeMapping(AssetType.SoundWAV, InventoryType.Sound, "audio/x-wav", "wav"), - new TypeMapping(AssetType.CallingCard, InventoryType.CallingCard, "application/vnd.ll.callingcard", "application/x-metaverse-callingcard", "callingcard"), - new TypeMapping(AssetType.Landmark, InventoryType.Landmark, "application/vnd.ll.landmark", "application/x-metaverse-landmark", "landmark"), - new TypeMapping(AssetType.Clothing, InventoryType.Wearable, "application/vnd.ll.clothing", "application/x-metaverse-clothing", "clothing"), - new TypeMapping(AssetType.Object, InventoryType.Object, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), - new TypeMapping(AssetType.Object, InventoryType.Attachment, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), - new TypeMapping(AssetType.Notecard, InventoryType.Notecard, "application/vnd.ll.notecard", "application/x-metaverse-notecard", "notecard"), - new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"), - new TypeMapping(AssetType.RootFolder, InventoryType.RootCategory, "application/vnd.ll.rootfolder", "rootfolder"), - new TypeMapping(AssetType.LSLText, InventoryType.LSL, "application/vnd.ll.lsltext", "application/x-metaverse-lsl", "lsl"), - new TypeMapping(AssetType.LSLBytecode, InventoryType.LSL, "application/vnd.ll.lslbyte", "application/x-metaverse-lso", "lso"), - new TypeMapping(AssetType.Bodypart, InventoryType.Wearable, "application/vnd.ll.bodypart", "application/x-metaverse-bodypart", "bodypart"), - new TypeMapping(AssetType.TrashFolder, InventoryType.Folder, "application/vnd.ll.trashfolder", "trashfolder"), - new TypeMapping(AssetType.SnapshotFolder, InventoryType.Folder, "application/vnd.ll.snapshotfolder", "snapshotfolder"), - new TypeMapping(AssetType.LostAndFoundFolder, InventoryType.Folder, "application/vnd.ll.lostandfoundfolder", "lostandfoundfolder"), - new TypeMapping(AssetType.Animation, InventoryType.Animation, "application/vnd.ll.animation", "application/x-metaverse-animation", "animation"), - new TypeMapping(AssetType.Gesture, InventoryType.Gesture, "application/vnd.ll.gesture", "application/x-metaverse-gesture", "gesture"), - new TypeMapping(AssetType.Simstate, InventoryType.Snapshot, "application/x-metaverse-simstate", "simstate"), - new TypeMapping(AssetType.FavoriteFolder, InventoryType.Unknown, "application/vnd.ll.favoritefolder", "favoritefolder"), - new TypeMapping(AssetType.Link, InventoryType.Unknown, "application/vnd.ll.link", "link"), - new TypeMapping(AssetType.LinkFolder, InventoryType.Unknown, "application/vnd.ll.linkfolder", "linkfolder"), - new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"), - new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"), - new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"), - new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm") - }; - - private static Dictionary asset2Content; - private static Dictionary asset2Extension; - private static Dictionary inventory2Content; - private static Dictionary content2Asset; - private static Dictionary content2Inventory; - - static SLUtil() + public static string SLInvTypeToContentType(int invType) { - asset2Content = new Dictionary(); - asset2Extension = new Dictionary(); - inventory2Content = new Dictionary(); - content2Asset = new Dictionary(); - content2Inventory = new Dictionary(); - - foreach (TypeMapping mapping in MAPPINGS) + switch ((InventoryType)invType) { - sbyte assetType = mapping.AssetTypeCode; - if (!asset2Content.ContainsKey(assetType)) - asset2Content.Add(assetType, mapping.ContentType); - if (!asset2Extension.ContainsKey(assetType)) - asset2Extension.Add(assetType, mapping.Extension); - if (!inventory2Content.ContainsKey(mapping.InventoryType)) - inventory2Content.Add(mapping.InventoryType, mapping.ContentType); - if (!content2Asset.ContainsKey(mapping.ContentType)) - content2Asset.Add(mapping.ContentType, assetType); - if (!content2Inventory.ContainsKey(mapping.ContentType)) - content2Inventory.Add(mapping.ContentType, mapping.InventoryType); - - if (mapping.ContentType2 != null) - { - if (!content2Asset.ContainsKey(mapping.ContentType2)) - content2Asset.Add(mapping.ContentType2, assetType); - if (!content2Inventory.ContainsKey(mapping.ContentType2)) - content2Inventory.Add(mapping.ContentType2, mapping.InventoryType); - } + case InventoryType.Animation: + return "application/vnd.ll.animation"; + case InventoryType.CallingCard: + return "application/vnd.ll.callingcard"; + case InventoryType.Folder: + return "application/vnd.ll.folder"; + case InventoryType.Gesture: + return "application/vnd.ll.gesture"; + case InventoryType.Landmark: + return "application/vnd.ll.landmark"; + case InventoryType.LSL: + return "application/vnd.ll.lsltext"; + case InventoryType.Notecard: + return "application/vnd.ll.notecard"; + case InventoryType.Attachment: + case InventoryType.Object: + return "application/vnd.ll.primitive"; + case InventoryType.Sound: + return "audio/ogg"; + case InventoryType.Snapshot: + case InventoryType.Texture: + return "image/x-j2c"; + case InventoryType.Wearable: + return "application/vnd.ll.clothing"; + default: + return "application/octet-stream"; } } - - public static string SLAssetTypeToContentType(int assetType) - { - string contentType; - if (!asset2Content.TryGetValue((sbyte)assetType, out contentType)) - contentType = asset2Content[(sbyte)AssetType.Unknown]; - return contentType; - } - - public static string SLInvTypeToContentType(int invType) - { - string contentType; - if (!inventory2Content.TryGetValue((InventoryType)invType, out contentType)) - contentType = inventory2Content[InventoryType.Unknown]; - return contentType; - } public static sbyte ContentTypeToSLAssetType(string contentType) { - sbyte assetType; - if (!content2Asset.TryGetValue(contentType, out assetType)) - assetType = (sbyte)AssetType.Unknown; - return (sbyte)assetType; + switch (contentType) + { + case "image/x-j2c": + case "image/jp2": + return (sbyte)AssetType.Texture; + case "application/ogg": + case "audio/ogg": + return (sbyte)AssetType.Sound; + case "application/vnd.ll.callingcard": + case "application/x-metaverse-callingcard": + return (sbyte)AssetType.CallingCard; + case "application/vnd.ll.landmark": + case "application/x-metaverse-landmark": + return (sbyte)AssetType.Landmark; + case "application/vnd.ll.clothing": + case "application/x-metaverse-clothing": + return (sbyte)AssetType.Clothing; + case "application/vnd.ll.primitive": + case "application/x-metaverse-primitive": + return (sbyte)AssetType.Object; + case "application/vnd.ll.notecard": + case "application/x-metaverse-notecard": + return (sbyte)AssetType.Notecard; + case "application/vnd.ll.folder": + return (sbyte)AssetType.Folder; + case "application/vnd.ll.rootfolder": + return (sbyte)AssetType.RootFolder; + case "application/vnd.ll.lsltext": + case "application/x-metaverse-lsl": + return (sbyte)AssetType.LSLText; + case "application/vnd.ll.lslbyte": + case "application/x-metaverse-lso": + return (sbyte)AssetType.LSLBytecode; + case "image/tga": + // Note that AssetType.TextureTGA will be converted to AssetType.ImageTGA + return (sbyte)AssetType.ImageTGA; + case "application/vnd.ll.bodypart": + case "application/x-metaverse-bodypart": + return (sbyte)AssetType.Bodypart; + case "application/vnd.ll.trashfolder": + return (sbyte)AssetType.TrashFolder; + case "application/vnd.ll.snapshotfolder": + return (sbyte)AssetType.SnapshotFolder; + case "application/vnd.ll.lostandfoundfolder": + return (sbyte)AssetType.LostAndFoundFolder; + case "audio/x-wav": + return (sbyte)AssetType.SoundWAV; + case "image/jpeg": + return (sbyte)AssetType.ImageJPEG; + case "application/vnd.ll.animation": + case "application/x-metaverse-animation": + return (sbyte)AssetType.Animation; + case "application/vnd.ll.gesture": + case "application/x-metaverse-gesture": + return (sbyte)AssetType.Gesture; + case "application/x-metaverse-simstate": + return (sbyte)AssetType.Simstate; + case "application/vnd.ll.favoritefolder": + return (sbyte)AssetType.FavoriteFolder; + case "application/vnd.ll.link": + return (sbyte)AssetType.Link; + case "application/vnd.ll.linkfolder": + return (sbyte)AssetType.LinkFolder; + case "application/vnd.ll.currentoutfitfolder": + return (sbyte)AssetType.CurrentOutfitFolder; + case "application/vnd.ll.outfitfolder": + return (sbyte)AssetType.OutfitFolder; + case "application/vnd.ll.myoutfitsfolder": + return (sbyte)AssetType.MyOutfitsFolder; + case "application/octet-stream": + default: + return (sbyte)AssetType.Unknown; + } } public static sbyte ContentTypeToSLInvType(string contentType) { - InventoryType invType; - if (!content2Inventory.TryGetValue(contentType, out invType)) - invType = InventoryType.Unknown; - return (sbyte)invType; - } - - public static string SLAssetTypeToExtension(int assetType) - { - string extension; - if (!asset2Extension.TryGetValue((sbyte)assetType, out extension)) - extension = asset2Extension[(sbyte)AssetType.Unknown]; - return extension; + switch (contentType) + { + case "image/x-j2c": + case "image/jp2": + case "image/tga": + case "image/jpeg": + return (sbyte)InventoryType.Texture; + case "application/ogg": + case "audio/ogg": + case "audio/x-wav": + return (sbyte)InventoryType.Sound; + case "application/vnd.ll.callingcard": + case "application/x-metaverse-callingcard": + return (sbyte)InventoryType.CallingCard; + case "application/vnd.ll.landmark": + case "application/x-metaverse-landmark": + return (sbyte)InventoryType.Landmark; + case "application/vnd.ll.clothing": + case "application/x-metaverse-clothing": + case "application/vnd.ll.bodypart": + case "application/x-metaverse-bodypart": + return (sbyte)InventoryType.Wearable; + case "application/vnd.ll.primitive": + case "application/x-metaverse-primitive": + return (sbyte)InventoryType.Object; + case "application/vnd.ll.notecard": + case "application/x-metaverse-notecard": + return (sbyte)InventoryType.Notecard; + case "application/vnd.ll.folder": + return (sbyte)InventoryType.Folder; + case "application/vnd.ll.rootfolder": + return (sbyte)InventoryType.RootCategory; + case "application/vnd.ll.lsltext": + case "application/x-metaverse-lsl": + case "application/vnd.ll.lslbyte": + case "application/x-metaverse-lso": + return (sbyte)InventoryType.LSL; + case "application/vnd.ll.trashfolder": + case "application/vnd.ll.snapshotfolder": + case "application/vnd.ll.lostandfoundfolder": + return (sbyte)InventoryType.Folder; + case "application/vnd.ll.animation": + case "application/x-metaverse-animation": + return (sbyte)InventoryType.Animation; + case "application/vnd.ll.gesture": + case "application/x-metaverse-gesture": + return (sbyte)InventoryType.Gesture; + case "application/x-metaverse-simstate": + return (sbyte)InventoryType.Snapshot; + case "application/octet-stream": + default: + return (sbyte)InventoryType.Unknown; + } } #endregion SL / file extension / content-type conversions @@ -327,4 +377,4 @@ namespace OpenSim.Framework return output; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index f0d2a3f..1ca35df 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs @@ -214,13 +214,16 @@ namespace OpenSim.Framework.Tests for (int i = 0; i < contenttypes.Length; i++) { - int expected; - if (contenttypes[i] == "image/tga") - expected = 12; // if we know only the content-type "image/tga", then we assume the asset type is TextureTGA; not ImageTGA + if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18) + { + Assert.That(contenttypes[i] == "image/tga"); + } else - expected = assettypes[i]; - Assert.AreEqual(expected, SLUtil.ContentTypeToSLAssetType(contenttypes[i]), - String.Format("Incorrect AssetType mapped from Content-Type {0}", contenttypes[i])); + { + Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i], + "Expecting {0} but got {1}", assettypes[i], + SLUtil.ContentTypeToSLAssetType(contenttypes[i])); + } } int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20}; @@ -234,7 +237,7 @@ namespace OpenSim.Framework.Tests "application/vnd.ll.primitive", "application/vnd.ll.notecard", "application/vnd.ll.folder", - "application/vnd.ll.rootfolder", + "application/octet-stream", "application/vnd.ll.lsltext", "image/x-j2c", "application/vnd.ll.primitive", @@ -244,8 +247,7 @@ namespace OpenSim.Framework.Tests for (int i=0;i @@ -891,13 +891,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // Calls attach with a Zero position if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) { - m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); +// m_log.Debug( +// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId +// + ", AttachmentPoint: " + AttachmentPt); // Save avatar attachment information - m_log.Debug( - "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId - + ", AttachmentPoint: " + AttachmentPt); - + m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); } } catch (Exception e) -- cgit v1.1 From f24289c47f81caf92c7cb91428008ce1bd038301 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Apr 2012 01:09:23 +0100 Subject: Comment out AvatarService.SetAvatar debug log line for now --- OpenSim/Services/AvatarService/AvatarService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs index c59a9e0..423c781 100644 --- a/OpenSim/Services/AvatarService/AvatarService.cs +++ b/OpenSim/Services/AvatarService/AvatarService.cs @@ -93,7 +93,7 @@ namespace OpenSim.Services.AvatarService if (kvp.Key.StartsWith("_")) count++; - m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}, attachs={1}", principalID, count); +// m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}, attachs={1}", principalID, count); m_Database.Delete("PrincipalID", principalID.ToString()); AvatarBaseData av = new AvatarBaseData(); -- cgit v1.1 From a65ca24701ac34415bf76f4d9094ab42ae721c9a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Apr 2012 01:51:40 +0100 Subject: Add regression test TestSameRegionTeleport() --- .../EntityTransfer/EntityTransferModule.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++ .../Scenes/Tests/ScenePresenceTeleportTests.cs | 36 ++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index feb783f..221e0bd 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -192,7 +192,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.WarnFormat( "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", position, sp.Name, sp.UUID, emergencyPos); - + position = emergencyPos; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b5f789b..9005acd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -990,6 +990,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void Teleport(Vector3 pos) { +// m_log.DebugFormat("[SCENE PRESENCE]: Moving {0} to {1} in {2}", Name, pos, Scene.RegionInfo.RegionName); + bool isFlying = Flying; RemoveFromPhysicalScene(); Velocity = Vector3.Zero; @@ -1002,6 +1004,10 @@ namespace OpenSim.Region.Framework.Scenes public void TeleportWithMomentum(Vector3 pos) { +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Moving {0} to {1} with existing momentum {2} in {3} ", +// Name, pos, Velocity, Scene.RegionInfo.RegionName); + bool isFlying = Flying; RemoveFromPhysicalScene(); CheckLandingPoint(ref pos); diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index bebc10c..eb7bfbd 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs @@ -33,6 +33,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Servers; +using OpenSim.Region.CoreModules.Framework.EntityTransfer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Tests.Common; @@ -47,6 +48,41 @@ namespace OpenSim.Region.Framework.Scenes.Tests [TestFixture] public class ScenePresenceTeleportTests { + [Test] + public void TestSameRegionTeleport() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + EntityTransferModule etm = new EntityTransferModule(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + // Not strictly necessary since FriendsModule assumes it is the default (!) + config.Configs["Modules"].Set("EntityTransferModule", etm.Name); + + TestScene scene = SceneHelpers.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); + SceneHelpers.SetupSceneModules(scene, config, etm); + + Vector3 teleportPosition = new Vector3(10, 11, 12); + Vector3 teleportLookAt = new Vector3(20, 21, 22); + + ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); + sp.AbsolutePosition = new Vector3(30, 31, 32); + scene.RequestTeleportLocation( + sp.ControllingClient, + scene.RegionInfo.RegionHandle, + teleportPosition, + teleportLookAt, + (uint)TeleportFlags.ViaLocation); + + Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition)); + + // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera + // position instead). +// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); + } + /// /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common. /// -- cgit v1.1 From 683cfc6f827c15ee70e4651cbcc7b94a01d2f8e3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Apr 2012 02:07:55 +0100 Subject: refactor: Combine ScenePresence.Teleport() and TeleportWithMomentum() These are identical apart from setting Velocity = zero, which has no practical effect anyway since this is zeroed when the avatar is added back to the physics scene. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 ---------------- .../OptionalModules/Scripting/Minimodule/SPAvatar.cs | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9005acd..8cb4921 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -994,22 +994,6 @@ namespace OpenSim.Region.Framework.Scenes bool isFlying = Flying; RemoveFromPhysicalScene(); - Velocity = Vector3.Zero; - CheckLandingPoint(ref pos); - AbsolutePosition = pos; - AddToPhysicalScene(isFlying); - - SendTerseUpdateToAllClients(); - } - - public void TeleportWithMomentum(Vector3 pos) - { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Moving {0} to {1} with existing momentum {2} in {3} ", -// Name, pos, Velocity, Scene.RegionInfo.RegionName); - - bool isFlying = Flying; - RemoveFromPhysicalScene(); CheckLandingPoint(ref pos); AbsolutePosition = pos; AddToPhysicalScene(isFlying); diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 922eaaf..d192309 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -68,7 +68,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public Vector3 WorldPosition { get { return GetSP().AbsolutePosition; } - set { GetSP().TeleportWithMomentum(value); } + set { GetSP().Teleport(value); } } public bool IsChildAgent -- cgit v1.1 From af86e2939c54837d47303668266ca314d405fb37 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Apr 2012 03:47:26 +0100 Subject: zero out SP velocity before calling SP.Teleport(), as the client expects (though this is also effectively done by physics at the moment) --- .../Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 221e0bd..f094346 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -215,6 +215,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.ControllingClient.SendTeleportStart(teleportFlags); sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); + sp.Velocity = Vector3.Zero; sp.Teleport(position); foreach (SceneObjectGroup grp in sp.GetAttachments()) -- cgit v1.1 From 3be3189ee067b26fa6486535a65a0c0e99a9ef5b Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 25 Apr 2012 04:00:01 +0100 Subject: Commit the avination Teleport() methods (adaptedto justincc's changes) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8cb4921..e8178ce 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -990,13 +990,24 @@ namespace OpenSim.Region.Framework.Scenes /// public void Teleport(Vector3 pos) { -// m_log.DebugFormat("[SCENE PRESENCE]: Moving {0} to {1} in {2}", Name, pos, Scene.RegionInfo.RegionName); + TeleportWithMomentum(pos, null); + } + public void TeleportWithMomentum(Vector3 pos, Vector3? v) + { bool isFlying = Flying; + Vector3 vel = Velocity; RemoveFromPhysicalScene(); CheckLandingPoint(ref pos); AbsolutePosition = pos; AddToPhysicalScene(isFlying); + if (PhysicsActor != null) + { + if (v.HasValue) + PhysicsActor.SetMomentum((Vector3)v); + else + PhysicsActor.SetMomentum(vel); + } SendTerseUpdateToAllClients(); } -- cgit v1.1 From cf1c34605bf58ee783c2a7d0c63f51ecf6d3288a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 24 Apr 2012 22:17:10 -0700 Subject: HG: Moved User-level code down to the HGEntityTransferModule where it belongs. --- .../Framework/EntityTransfer/EntityTransferModule.cs | 15 +-------------- .../Framework/EntityTransfer/HGEntityTransferModule.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 221e0bd..8d810fc 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -61,8 +61,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer set { m_MaxTransferDistance = value; } } - private int m_levelHGTeleport = 0; - protected bool m_Enabled = false; protected Scene m_aScene; protected List m_Scenes = new List(); @@ -106,7 +104,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (transferConfig != null) { MaxTransferDistance = transferConfig.GetInt("max_distance", 4095); - m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); } m_agentsInTransit = new List(); @@ -240,16 +237,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer destinationRegionName = finalDestination.RegionName; - // check if HyperGrid teleport is allowed, based on user level - int flags = m_aScene.GridService.GetRegionFlags(sp.Scene.RegionInfo.ScopeID, reg.RegionID); - - if (((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) && (sp.UserLevel < m_levelHGTeleport)) - { - m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination link is non permitted hypergrid region. Unable to teleport agent."); - sp.ControllingClient.SendTeleportFailed("HyperGrid teleport not permitted"); - return; - } - uint curX = 0, curY = 0; Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY); int curCellX = (int)(curX / Constants.RegionSize); @@ -413,7 +400,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer bool logout = false; if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) { - sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", + sp.ControllingClient.SendTeleportFailed(String.Format("Teleport refused: {0}", reason)); return; } diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 7f9175d..6a92e61 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_Initialized = false; + private int m_levelHGTeleport = 0; private GatekeeperServiceConnector m_GatekeeperConnector; @@ -68,6 +69,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string name = moduleConfig.GetString("EntityTransferModule", ""); if (name == Name) { + IConfig transferConfig = source.Configs["EntityTransfer"]; + if (transferConfig != null) + m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); + InitialiseCommon(source); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); } @@ -164,6 +169,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) { // this user is going to another grid + // check if HyperGrid teleport is allowed, based on user level + if (sp.UserLevel < m_levelHGTeleport) + { + m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination link is non permitted hypergrid region. Unable to teleport agent."); + reason = "HyperGrid teleport not permitted"; + return false; + } + if (agentCircuit.ServiceURLs.ContainsKey("HomeURI")) { string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); -- cgit v1.1 From 7aa25c6762e40ee9254e2982a9fca89913fa0279 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 24 Apr 2012 22:40:07 -0700 Subject: Slight rewording of output messages. --- .../CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 6a92e61..634fb43 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -172,7 +172,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // check if HyperGrid teleport is allowed, based on user level if (sp.UserLevel < m_levelHGTeleport) { - m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination link is non permitted hypergrid region. Unable to teleport agent."); + m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel."); reason = "HyperGrid teleport not permitted"; return false; } -- cgit v1.1 From bec100a662f2734b5da0cc8d4fb731da019b4304 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Wed, 25 Apr 2012 09:51:30 -0700 Subject: Add try/catch around Json script method registration to avoild some issues with .NET 3.5 vs 4.0 differences. See http://opensimulator.org/mantis/view.php?id=5971 --- .../Scripting/JsonStore/JsonStoreScriptModule.cs | 39 +++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index eda2aef..4949097 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs @@ -163,28 +163,37 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore return; } - m_comms.RegisterScriptInvocation(this,"JsonCreateStore"); - m_comms.RegisterScriptInvocation(this,"JsonDestroyStore"); + try + { + m_comms.RegisterScriptInvocation(this,"JsonCreateStore"); + m_comms.RegisterScriptInvocation(this,"JsonDestroyStore"); - m_comms.RegisterScriptInvocation(this,"JsonReadNotecard"); - m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard"); + m_comms.RegisterScriptInvocation(this,"JsonReadNotecard"); + m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard"); - m_comms.RegisterScriptInvocation(this,"JsonTestPath"); - m_comms.RegisterScriptInvocation(this,"JsonTestPathJson"); + m_comms.RegisterScriptInvocation(this,"JsonTestPath"); + m_comms.RegisterScriptInvocation(this,"JsonTestPathJson"); - m_comms.RegisterScriptInvocation(this,"JsonGetValue"); - m_comms.RegisterScriptInvocation(this,"JsonGetValueJson"); + m_comms.RegisterScriptInvocation(this,"JsonGetValue"); + m_comms.RegisterScriptInvocation(this,"JsonGetValueJson"); - m_comms.RegisterScriptInvocation(this,"JsonTakeValue"); - m_comms.RegisterScriptInvocation(this,"JsonTakeValueJson"); + m_comms.RegisterScriptInvocation(this,"JsonTakeValue"); + m_comms.RegisterScriptInvocation(this,"JsonTakeValueJson"); - m_comms.RegisterScriptInvocation(this,"JsonReadValue"); - m_comms.RegisterScriptInvocation(this,"JsonReadValueJson"); + m_comms.RegisterScriptInvocation(this,"JsonReadValue"); + m_comms.RegisterScriptInvocation(this,"JsonReadValueJson"); - m_comms.RegisterScriptInvocation(this,"JsonSetValue"); - m_comms.RegisterScriptInvocation(this,"JsonSetValueJson"); + m_comms.RegisterScriptInvocation(this,"JsonSetValue"); + m_comms.RegisterScriptInvocation(this,"JsonSetValueJson"); - m_comms.RegisterScriptInvocation(this,"JsonRemoveValue"); + m_comms.RegisterScriptInvocation(this,"JsonRemoveValue"); + } + catch (Exception e) + { + // See http://opensimulator.org/mantis/view.php?id=5971 for more information + m_log.WarnFormat("[JsonStroreScripts] script method registration failed; {0}",e.Message); + m_enabled = false; + } } } -- cgit v1.1 From 88553bb884c5c8849ec61362e65fe0950c1e3080 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 25 Apr 2012 19:09:22 +0100 Subject: Port Avination link order to make OpenSim behave like SL. Make Primstar scripts work. Fixes Mantis #5990 --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 42 ++++++++++++++++++++-- .../Shared/Api/Implementation/LSL_Api.cs | 12 ++++--- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 49a3485..2686004 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1969,6 +1969,11 @@ namespace OpenSim.Region.Framework.Scenes /// The group of prims which should be linked to this group public void LinkToGroup(SceneObjectGroup objectGroup) { + LinkToGroup(objectGroup, false); + } + + public void LinkToGroup(SceneObjectGroup objectGroup, bool insert) + { // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); @@ -1979,6 +1984,10 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart linkPart = objectGroup.m_rootPart; + // physics flags from group to be applied to linked parts + bool grpusephys = UsesPhysics; + bool grptemporary = IsTemporary; + Vector3 oldGroupPosition = linkPart.GroupPosition; Quaternion oldRootRotation = linkPart.RotationOffset; @@ -2002,15 +2011,35 @@ namespace OpenSim.Region.Framework.Scenes lock (m_parts.SyncRoot) { - int linkNum = PrimCount + 1; + int linkNum; + if (insert) + { + linkNum = 2; + foreach (SceneObjectPart part in Parts) + { + if (part.LinkNum > 1) + part.LinkNum++; + } + } + else + { + linkNum = PrimCount + 1; + } m_parts.Add(linkPart.UUID, linkPart); linkPart.SetParent(this); linkPart.CreateSelected = true; + // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now + linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive); + if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) + { + linkPart.PhysActor.link(m_rootPart.PhysActor); + this.Scene.PhysicsScene.AddPhysicsActorTaint(linkPart.PhysActor); + } + linkPart.LinkNum = linkNum++; - linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); SceneObjectPart[] ogParts = objectGroup.Parts; Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) @@ -2022,7 +2051,16 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = ogParts[i]; if (part.UUID != objectGroup.m_rootPart.UUID) + { LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); + // let physics know + part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive); + if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) + { + part.PhysActor.link(m_rootPart.PhysActor); + this.Scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); + } + } part.ClearUndoState(); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d4c872c..d641958 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -832,8 +832,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRegionSayTo(string target, int channel, string msg) { - string error = String.Empty; - if (msg.Length > 1023) msg = msg.Substring(0, 1023); @@ -3548,7 +3546,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llCreateLink(string target, int parent) { m_host.AddScriptLPS(1); - UUID targetID; if (!UUID.TryParse(target, out targetID)) @@ -3572,11 +3569,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (targetPart.ParentGroup.AttachmentPoint != 0) return; // Fail silently if attached + + if (targetPart.ParentGroup.RootPart.OwnerID != m_host.ParentGroup.RootPart.OwnerID) + return; + SceneObjectGroup parentPrim = null, childPrim = null; if (targetPart != null) { - if (parent != 0) { + if (parent != 0) + { parentPrim = m_host.ParentGroup; childPrim = targetPart.ParentGroup; } @@ -3588,7 +3590,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Required for linking childPrim.RootPart.ClearUpdateSchedule(); - parentPrim.LinkToGroup(childPrim); + parentPrim.LinkToGroup(childPrim, true); } parentPrim.TriggerScriptChangedEvent(Changed.LINK); -- cgit v1.1 From a2d544c9383391f483bdfb82026e2ebc9c88388f Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Wed, 25 Apr 2012 11:54:57 -0700 Subject: Add a configuration switch to turn on/off the use of the trash folder when deleting objects from a scene. The use of the trash folder causes assets to be created and stored everytime you delete an object from the scene (slows down the delete and adds mostly useless assets to your database). Default is on (use the trash folder) which is the standard behavior. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ bin/OpenSimDefaults.ini | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 10b25ed..816d3b6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1988,7 +1988,7 @@ namespace OpenSim.Region.Framework.Scenes } } - if (permissionToTake) + if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) { m_asyncSceneObjectDeleter.DeleteToInventory( action, destinationID, deleteGroups, remoteClient, diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a87dfb7..7a2b2ed 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -103,6 +103,7 @@ namespace OpenSim.Region.Framework.Scenes public bool m_trustBinaries; public bool m_allowScriptCrossings; public bool m_useFlySlow; + public bool m_useTrashOnDelete = true; /// /// Temporarily setting to trigger appearance resends at 60 second intervals. @@ -709,6 +710,7 @@ namespace OpenSim.Region.Framework.Scenes m_clampPrimSize = true; } + m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); m_dontPersistBefore = diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 3f2f131..cb9ef22 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -337,6 +337,13 @@ ; OpenJPEG if false ; UseCSJ2K = true + + ; Use "Trash" folder for items deleted from the scene + ; When set to True (the default) items deleted from the scene will be + ; stored in the user's trash or lost and found folder. When set to + ; False items will be removed from the scene permanently + UseTrashOnDelete = True + ; Persist avatar baked textures ; Persisting baked textures can speed up login and region border ; crossings especially with large numbers of users, though it -- cgit v1.1